/**
 * long description for the file
 *
 * @summary 数据权限配置 - 添加
 * @author wu <308822989@qq.com>
 *
 * Created at     : 2018-08-09 15:51:52
 * Last modified  : 2018-08-27 14:53:45
 */

import axios from '@/config/axios.js';
import {
  proPath
} from '@/config/config.js';

const state = {
  //  行操作类型
  operType: [
      {
      label: '浏览',
      value: '1'
    },
    {
      label: '读写',
      value: '2'
    },
    {
      label: '删除',
      value: '3'
    }
  ],
  //  列操作类型
  colOperType: [{
    label: '浏览',
    value: '1'
  },
  {
    label: '读写',
    value: '2'
  },
  {
    label: '不显示',
    value: '3'
  }
  ],
  //  行操作符
  operator: [{
    label: '包含（in）',
    value: 'in'
  },
  {
    label: '等于',
    value: '='
  },
  {
    label: '>',
    value: '>'
  },
  {
    label: '<',
    value: '<'
  },
  {
    label: '>=',
    value: '>='
  },
  {
    label: '<=',
    value: '<='
  }, {
    label: '!=',
    value: '!='
  },
  {
    label: 'like',
    value: 'like'
  }
  ],
  //  数据授权范围
  //  行操作符
  region: [{
    label: '当前用户',
    value: '1'
  },
  {
    label: '当前机构',
    value: '2'
  },
  {
    label: '当前机构(含下级)',
    value: '3'
  },
  {
    label: '当前机构(含上级)',
    value: '4'
  },
  {
    label: '当前角色',
    value: '5'
  },
  {
    label: '实际值',
    value: '6'
  }
  ]
}

const getters = {}

const mutations = {}
const actions = {
  //  取数据库表列表
  tableList ({
    commit,
    state
  }, form) {
    let res = axios.get(proPath + 'v1/mdtables/', {
      params: form
    });
    return res;
  },
  //  取数据库表字段
  tableListField ({
    commit,
    state
  }, form) {
    let res = axios.get(proPath + 'v1/mdfields/listfield', {
      params: form
    });
    return res;
  },
  //  提交数据权限配置数据
  saveSysDaTablePolicy ({
    commit,
    state
  }, form) {
    let res = axios.put(proPath + 'v1/sysdatablepolicys/saveSysDaTablePolicy', form);
    return res;
  },
  //  提交数据权限配置数据
  updateSysDaTablePolicy ({
    commit,
    state
  }, form) {
    let res = axios.put(proPath + 'v1/sysdatablepolicys/updateSysDaTablePolicy', form);
    return res;
  },
  //  读取表的数据权限配置
  listrule ({
    commit,
    state
  }, form) {
    let res = axios.get(proPath + 'v1/sysdatablepolicys/listrule', {
      params: form
    });
    return res;
  }

}

//
export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
