Surpriseplus
2022-09-29 87c914ffe57995f1a9844fa19cbd4fe19ca7b91a
角色管理新增,删除,修改
已添加1个文件
已修改4个文件
1130 ■■■■ 文件已修改
src/api/api.js 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/lang/en.js 169 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/lang/zh.js 155 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/userManage/roleDepTree.vue 351 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/userManage/roleManage.vue 410 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/api.js
@@ -6,30 +6,61 @@
 * @LastEditors: çŽ‹æ—­
 * @LastEditTime: 2022-04-19 20:29:30
 */
import request from "@/utils/request";
import request from '@/utils/request';
//字典管理列表
export function selectByPageAndCount(params) {
  //请求地址
  return request.get("/dict/selectByPageAndCount", {params:params});
  return request.get('/dict/selectByPageAndCount', { params: params });
}
//字典管理列表
export function selectDictTab(params) {
  //请求地址
  return request.get("/dict/selectDictTab", {params:params});
  return request.get('/dict/selectDictTab', { params: params });
}
//字典管理列表删除
export function deleteDicts(params) {
  //请求地址
  return request.get("/dict/deleteDicts", {params:params});
  return request.get('/dict/deleteDicts', { params: params });
}
//字典管理列表编辑
export function updateDict(params) {
  //请求地址
  return request.post("/dict/updateDict", params);
  return request.post('/dict/updateDict', params);
}
//字典管理新增
export function insertDict(params) {
  //请求地址
  return request.post("/dict/insertDict", params);
}
  return request.post('/dict/insertDict', params);
}
//角色管理列表
export function select_Role_ByPageAndCount(params) {
  //请求地址
  return request.get('/role/selectByPageAndCount', { params: params });
}
//角色管理新增
export function insertRole(params) {
  //请求地址
  return request.post('/role/insertRole', params);
}
//角色管理删除
export function deleteRole(params) {
  //请求地址
  return request.get('/role/deleteRole', { params: params });
}
//角色管理修改
export function updateRole(params) {
  //请求地址
  return request.post('/role/updateRole', params);
}
//组织机构列表
export function selectdepTab(params) {
  //请求地址
  return request.get('/dep/selectDepAll', { params: params });
}
//组织机构根据id查询
export function selectDep(params) {
  //请求地址
  return request.get('/dep/selectDep', { params: params });
}
src/assets/lang/en.js
@@ -27,40 +27,40 @@
    SpatialData: 'SpatialData',
    versionManage: 'versionManage',
    dictionaryManage: 'dictionaryManage',
    dictionaryManageObj:{
      tableName:"table name",
      selectTableName:"select table name",
      add:"add",
      del:"delete",
      number:"number",
      fieldName:"field name",
      fieldAliasName:"field alias name",
      fieldType:"field Type",
      fieldLength:"field length",
      FieldPrecision:"Field Precision",
      rangeAssociationTable:"range association table",
      remark:"remark",
      creationTime:"creation time",
      createPersonnel:"create personnel",
      updateTime:"update time",
      updatePersonnel:"update personnel",
      operation:"operation",
      lookOver:"look over",
      revamp:"revamp",
      particulars:"particulars",
      tableAliasName:"table alias name",
      cancel:"cancel",
      confirm:"confirm",
      tips:"tips",
      deletedSuccessfully:"deleted successfully",
      DeleteFailed:"delete failed",
      tipsDelete:"Are you sure you want to delete the selected content?",
      FailedAdd:"Failed to add",
      NewSuccess:"Successfully added",
      tipsAdd:"Are you sure you want to add it?",
      failModify:"fail to modify",
      modifySuccessfully:"modify successfully",
      tipsUp:"Are you sure to save the changes?",
    dictionaryManageObj: {
      tableName: 'table name',
      selectTableName: 'select table name',
      add: 'add',
      del: 'delete',
      number: 'number',
      fieldName: 'field name',
      fieldAliasName: 'field alias name',
      fieldType: 'field Type',
      fieldLength: 'field length',
      FieldPrecision: 'Field Precision',
      rangeAssociationTable: 'range association table',
      remark: 'remark',
      creationTime: 'creation time',
      createPersonnel: 'create personnel',
      updateTime: 'update time',
      updatePersonnel: 'update personnel',
      operation: 'operation',
      lookOver: 'look over',
      revamp: 'revamp',
      particulars: 'particulars',
      tableAliasName: 'table alias name',
      cancel: 'cancel',
      confirm: 'confirm',
      tips: 'tips',
      deletedSuccessfully: 'deleted successfully',
      DeleteFailed: 'delete failed',
      tipsDelete: 'Are you sure you want to delete the selected content?',
      FailedAdd: 'Failed to add',
      NewSuccess: 'Successfully added',
      tipsAdd: 'Are you sure you want to add it?',
      failModify: 'fail to modify',
      modifySuccessfully: 'modify successfully',
      tipsUp: 'Are you sure to save the changes?',
    },
    styleManage: 'styleManage',
  },
@@ -378,45 +378,45 @@
      fv9: 'Other',
    },
    orgManage: 'Org Manage',
    orgManageObj:{
      companyName:"companyName",
      flatType:"flatType",
      inquire:"inquire",
      delete:"delete",
      add:"add",
      num:"num",
      phone:"phone",
      operate:"operate",
      edit:"edit",
      unitInformation:"unitInformation",
      userList:"userList",
      username:"username",
      ChineseNameUsername:"ChineseName username",
      phoneNumberToTeceiveShortMessages:"phoneNumber to teceiveShort messages",
      status:"status",
      confirm:"confirm",
      close:"close",
      administrativeDvisionsList:"administrativeDvisions List",
      name:"name",
      coding:"coding",
      codeOfAdministrativeDivision:"code of administrative division",
      LevelForExaminationAndApproval:"Level for examination and approval",
      seaAreaUseClass:"seaAreaUseClass",
      reset:"reset",
      immediatelyCreate:"immediatelyCreate",
      pinyinInitials:"pinyinInitials",
      abbreviation:"abbreviation",
      unitCode:"unitCode",
      organizationCode:"organizationCode",
      companyAdministrator:"companyAdministrator",
      picture:"picture",
      division:"division",
      EMail:"EMail",
      fax:"fax",
      postalCode:"postalCode",
      website:"website",
      cmpanyAddress:"cmpanyAddress",
      companyIntroduction:"companyIntroduction",
    orgManageObj: {
      companyName: 'companyName',
      flatType: 'flatType',
      inquire: 'inquire',
      delete: 'delete',
      add: 'add',
      num: 'num',
      phone: 'phone',
      operate: 'operate',
      edit: 'edit',
      unitInformation: 'unitInformation',
      userList: 'userList',
      username: 'username',
      ChineseNameUsername: 'ChineseName username',
      phoneNumberToTeceiveShortMessages: 'phoneNumber to teceiveShort messages',
      status: 'status',
      confirm: 'confirm',
      close: 'close',
      administrativeDvisionsList: 'administrativeDvisions List',
      name: 'name',
      coding: 'coding',
      codeOfAdministrativeDivision: 'code of administrative division',
      LevelForExaminationAndApproval: 'Level for examination and approval',
      seaAreaUseClass: 'seaAreaUseClass',
      reset: 'reset',
      immediatelyCreate: 'immediatelyCreate',
      pinyinInitials: 'pinyinInitials',
      abbreviation: 'abbreviation',
      unitCode: 'unitCode',
      organizationCode: 'organizationCode',
      companyAdministrator: 'companyAdministrator',
      picture: 'picture',
      division: 'division',
      EMail: 'EMail',
      fax: 'fax',
      postalCode: 'postalCode',
      website: 'website',
      cmpanyAddress: 'cmpanyAddress',
      companyIntroduction: 'companyIntroduction',
    },
    userAuditing: 'User Auditing',
    UA: {
@@ -442,16 +442,23 @@
    },
    roleManage: 'Role Manage',
    RM: {
      roleName: 'roleName',
      ownedSystem: 'ownedSystem',
      add: 'add',
      query: 'query',
      reset: 'reset',
      index: 'index',
      roleName: 'RoleName',
      ownedSystem: 'Affiliated unit',
      add: 'Add',
      query: 'Query',
      reset: 'Reset',
      index: 'Index',
      Permission: 'Permission',
      resourcePermission: 'Resource Permission',
      groupSetting: 'groupSetting',
      one: 'one',
      groupSetting: 'GroupSetting',
      one: 'One',
      describe: 'Describe',
      remarks: 'Remarks',
      creationtime: 'Creation Time',
      creationuser: 'Creation Personne',
      updateontime: 'Update Time',
      updateonuser: 'Update Personnel',
      insertRole: 'Add role information',
    },
    groupManage: 'groupManage',
    GM: {
src/assets/lang/zh.js
@@ -27,40 +27,40 @@
    SpatialData: '空间数据管理',
    versionManage: '版本管理',
    dictionaryManage: '字典管理',
    dictionaryManageObj:{
      tableName:"表名称",
      selectTableName:"选择表名称",
      add:"新增",
      del:"删除",
      number:"编号",
      fieldName:"字段名称",
      fieldAliasName:"字段显示名称",
      fieldType:"字段类型",
      fieldLength:"字段长度",
      FieldPrecision:"字段精度",
      rangeAssociationTable:"值域关联表",
      remark:"备注",
      creationTime:"创建时间",
      createPersonnel:"创建人员",
      updateTime:"更新时间",
      updatePersonnel:"更新人员",
      operation:"操作",
      lookOver:"查看",
      revamp:"修改",
      particulars:"详细信息",
      tableAliasName:"表显示名称",
      cancel:"取 æ¶ˆ",
      confirm:"ç¡® å®š",
      tips:"提示",
      deletedSuccessfully:"删除成功!",
      DeleteFailed:"列表删除失败",
      tipsDelete:"确定是否删除所选内容?",
      NewSuccess:"新增成功",
      FailedAdd:"新增失败",
      tipsAdd:"是否确定添加?",
      failModify:"修改失败",
      modifySuccessfully:"修改成功",
      tipsUp:"是否确定保存修改内容?",
    dictionaryManageObj: {
      tableName: '表名称',
      selectTableName: '选择表名称',
      add: '新增',
      del: '删除',
      number: '编号',
      fieldName: '字段名称',
      fieldAliasName: '字段显示名称',
      fieldType: '字段类型',
      fieldLength: '字段长度',
      FieldPrecision: '字段精度',
      rangeAssociationTable: '值域关联表',
      remark: '备注',
      creationTime: '创建时间',
      createPersonnel: '创建人员',
      updateTime: '更新时间',
      updatePersonnel: '更新人员',
      operation: '操作',
      lookOver: '查看',
      revamp: '修改',
      particulars: '详细信息',
      tableAliasName: '表显示名称',
      cancel: '取 æ¶ˆ',
      confirm: 'ç¡® å®š',
      tips: '提示',
      deletedSuccessfully: '删除成功!',
      DeleteFailed: '列表删除失败',
      tipsDelete: '确定是否删除所选内容?',
      NewSuccess: '新增成功',
      FailedAdd: '新增失败',
      tipsAdd: '是否确定添加?',
      failModify: '修改失败',
      modifySuccessfully: '修改成功',
      tipsUp: '是否确定保存修改内容?',
    },
    styleManage: '样式管理',
  },
@@ -377,45 +377,45 @@
      fv9: '其他',
    },
    orgManage: '组织机构管理',
    orgManageObj:{
      companyName:"单位名称",
      flatType:"单位类型",
      inquire:"查询",
      delete:"清除",
      add:"新增",
      num:"序号",
      phone:"联系电话",
      operate:"操作",
      edit:"编辑",
      unitInformation:"单位信息",
      userList:"用户-列表",
      username:"用户名称",
      ChineseNameUsername:"中文名【用户名】",
      phoneNumberToTeceiveShortMessages:"手机号【接收短信】",
      status:"状态",
      confirm:"确定",
      close:"关闭",
      administrativeDvisionsList:"行政区划-列表",
      name:"区域名称",
      coding:"编码",
      codeOfAdministrativeDivision:"行政区划代码",
      LevelForExaminationAndApproval:"审批级别",
      seaAreaUseClass:"海域使用等级",
      reset:"重置",
      immediatelyCreate:"立即创建",
      pinyinInitials:"拼音首字母",
      abbreviation:"单位简称",
      unitCode:"单位编码",
      organizationCode:"单位组织机构代码",
      companyAdministrator:"单位管理员",
      picture:"图片",
      division:"所属区划",
      EMail:"E-Mail地址",
      fax:"传真",
      postalCode:"邮政编码",
      website:"网址",
      cmpanyAddress:"单位地址",
      companyIntroduction:"单位介绍",
    orgManageObj: {
      companyName: '单位名称',
      flatType: '单位类型',
      inquire: '查询',
      delete: '清除',
      add: '新增',
      num: '序号',
      phone: '联系电话',
      operate: '操作',
      edit: '编辑',
      unitInformation: '单位信息',
      userList: '用户-列表',
      username: '用户名称',
      ChineseNameUsername: '中文名【用户名】',
      phoneNumberToTeceiveShortMessages: '手机号【接收短信】',
      status: '状态',
      confirm: '确定',
      close: '关闭',
      administrativeDvisionsList: '行政区划-列表',
      name: '区域名称',
      coding: '编码',
      codeOfAdministrativeDivision: '行政区划代码',
      LevelForExaminationAndApproval: '审批级别',
      seaAreaUseClass: '海域使用等级',
      reset: '重置',
      immediatelyCreate: '立即创建',
      pinyinInitials: '拼音首字母',
      abbreviation: '单位简称',
      unitCode: '单位编码',
      organizationCode: '单位组织机构代码',
      companyAdministrator: '单位管理员',
      picture: '图片',
      division: '所属区划',
      EMail: 'E-Mail地址',
      fax: '传真',
      postalCode: '邮政编码',
      website: '网址',
      cmpanyAddress: '单位地址',
      companyIntroduction: '单位介绍',
    },
    userAuditing: '用户审核',
    UA: {
@@ -443,7 +443,7 @@
    roleManage: '角色管理',
    RM: {
      roleName: '角色名称',
      ownedSystem: '所属系统',
      ownedSystem: '所属单位',
      add: '新增',
      query: '查询',
      reset: '清除',
@@ -453,6 +453,13 @@
      groupSetting: '群组设置',
      operate: '操作',
      one: '一张图',
      describe: '描述',
      remarks: '备注',
      creationtime: '创建时间',
      creationuser: '创建人员',
      updateontime: '修改时间',
      updateonuser: '修改人员',
      insertRole: '添加角色信息',
    },
    groupManage: '群组管理',
    GM: {
src/views/userManage/roleDepTree.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,351 @@
<template>
  <div class="wrap">
    <div class="bread">
      <el-breadcrumb separator="el-icon-arrow-right">
        <el-breadcrumb-item>{{ breadLabel }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="treeBox">
      <el-tree
        ref="tree"
        :props="defaultProps"
        node-key="id"
        :data="dirData"
        :expand-on-click-node="false"
        :default-expanded-keys="[1, 2, 3, 4, 5, 6, 7, 8, 9]"
        :draggable="draggable"
        @node-drag-start="handleDragStart"
        @node-click="handleNodeClick"
        @node-drop="handleDrop"
      >
        <span class="custom-tree-node" slot-scope="{ node, data }">
          <span>{{ node.label }}</span>
          <span class="btnBox" v-show="showEdit">
            <el-button type="text" size="mini" @click="() => append(data)">
              <i class="el-icon-circle-plus"></i>
            </el-button>
            <el-button
              type="text"
              size="mini"
              @click="() => remove(node, data)"
            >
              <i class="el-icon-delete-solid"></i>
            </el-button>
          </span>
        </span>
      </el-tree>
      <!-- <div style="margin-left:130px;">
        <el-button @click="sendChange">保存</el-button>
      </div> -->
    </div>
  </div>
</template>
<script>
import { selectdepTab } from '../../api/api';
export default {
  name: 'catalogueTree',
  props: ['showBtn'],
  data() {
    return {
      draggable: false,
      id: null,
      showEdit: false,
      showBread: false,
      oriData: [], //原始树数据
      dirData: [], //el树数据
      old_dirDat: [], //el树数据(拖动前)
      newData: [], //拖动后原始数据
      breadList: [], //面包屑数组
      breadLabel: '', //面包屑文字
      filterText: '',
      defaultProps: {
        children: 'children',
        label: 'name',
      },
    };
  },
  methods: {
    // è¯·æ±‚目录树
    async getDirTree() {
      this.selectData = [];
      const data = await selectdepTab();
      if (data.code != 200) {
        this.$message.error('下拉调用失败');
      } else {
        this.oriData = data.result;
        this.newData = data.result;
        this.dirData = this.treeData(data.result);
      }
    },
    treeData(source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // å¯¹æºæ•°æ®æ·±åº¦å…‹éš†
      return cloneData.filter((father) => {
        // å¾ªçŽ¯æ‰€æœ‰é¡¹
        let branchArr = cloneData.filter((child) => father.id == child.pid); // å¯¹æ¯”ID,分别上下级菜单,并返回数据
        branchArr.length > 0 ? (father.children = branchArr) : ''; // ç»™çˆ¶çº§æ·»åŠ ä¸€ä¸ªchildren属性,并赋值
        // å±žäºŽåŒä¸€å¯¹è±¡é—®é¢˜ï¼Œä¾‹å¦‚:令 a=b、c=1 ï¼Œç„¶åŽå†ä»¤ b.c=c ï¼Œ é‚£ä¹ˆ a.c=b.c=c=1 ï¼›åŒç†ï¼ŒåŽç»­ä»¤ c.d=2 ,那么 a.c.d ä¹Ÿæ˜¯=2;
        // ç”±æ­¤å¾ªçŽ¯å¤šæ¬¡åŽï¼Œå°±èƒ½å½¢æˆç›¸åº”çš„æ ‘å½¢æ•°æ®ç»“æž„
        return father.pid == 0; // è¿”回一级菜单
      });
    },
    append(data) {
      this.$prompt('请输入名称', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      })
        .then(({ value }) => {
          const newChild = {
            id: this.id + 1,
            name: value,
            pid: data.id,
            // children: [],
            oid: data.children ? data.children.length + 1 : 1,
          };
          this.id = newChild.id; //修改新的最大I
          console.log(newChild);
          if (!data.children) {
            this.$set(data, 'children', []);
          }
          data.children.push(newChild);
          this.newData.push(newChild);
          this.sendChange();
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '取消输入',
          });
        });
    },
    remove(node, data) {
      this.$confirm('此操作将删除该节点, æ˜¯å¦ç»§ç»­?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          const parent = node.parent;
          const children = parent.data.children || parent.data;
          const index = children.findIndex((d) => d.id === data.id);
          let res = children.splice(index, 1);
          var std = [];
          for (var i in res) {
            std.push(res[i].id);
          }
          deleteDirTree(std);
          this.getDirTree();
          this.$message({
            type: 'success',
            message: '删除成功!',
          });
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除',
          });
        });
      // this.dialogMessage="是否删除"
      // this.dialogFlag = 1;
      // this.dialogFrom ={
      //   node:node,
      //   val:data
      // }
      //   this.dialogVisible=true;//目录树更改弹窗
      // const parent = node.parent;
      // const children = parent.data.children || parent.data;
      // const index = children.findIndex((d) => d.id === data.id);
      // let res = children.splice(index, 1);
      // // console.log(res);
      // // console.log(data);
      // console.log(this.flaten(res));
    },
    flaten(arr) {
      return arr.reduce((p, v, i) => {
        for (let i = 0; i < p.length; i++) {
          if (p[i].children) {
            delete p[i].children;
          }
        }
        return p.concat(v.children ? this.flaten(v.children).concat(v) : v);
      }, []);
    },
    handleNodeClick(data) {
      // console.log(data);
      this.$store.commit('changeNode', data);
      this.breadList = [];
      this.getTreeNode(this.$refs.tree.getNode(data.id));
    },
    getTreeNode(node) {
      if (node && node.label) {
        this.breadList.unshift(node.label);
        this.getTreeNode(node.parent); //递归
        this.breadLabel = this.breadList.join('>');
        this.$store.commit('changeCata', this.breadLabel);
      }
    },
    handleDragStart(node, ev) {
      this.old_dirDat = JSON.parse(JSON.stringify(this.dirData)); //将备份的dir重新赋值
    },
    handleDrop(draggingNode, dropNode, dropType, ev) {
      // console.log("被拖拽节点", draggingNode);
      // console.log("进入的节点", dropNode);
      // console.log("放置位置", dropType);
      // console.log("事件", ev);
      // if (dropType !== "inner") {
      //   // 1.修改父节点pid
      //   draggingNode.data.pid = dropNode.data.pid;
      //   dropNode.parent.childNodes.forEach((item, index) => {
      //     // 2.修改自身顺序oid
      //     item.data.oid = index + 1;
      //   });
      // }
      // // console.log(draggingNode.data.id);
      // let res = this.oriData.filter((item) => item.id == draggingNode.data.id);
      // console.log(res);
      this.$confirm('此操作将保存目录更改, æ˜¯å¦ç»§ç»­?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          let paramData = [];
          let data = dropType != 'inner' ? dropNode.parent.data : dropNode.data;
          let nodeData =
            dropNode.level == 1 && dropType != 'inner' ? data : data.children;
          let pid = '';
          nodeData.forEach((item, i) => {
            if (dropType != 'inner') {
              if (draggingNode.data.pid === dropNode.data.pid) {
                pid = item.pid;
              } else {
                pid = dropNode.data.pid;
              }
            } else {
              pid = data.id;
            }
            let collection = {
              id: item.id,
              name: item.name,
              pid,
              oid: i + 1,
            };
            paramData.push(collection);
          });
          // console.log(paramData);
          let arr = [];
          this.oriData.forEach((e) => {
            paramData.forEach((item) => {
              if (item.id === e.id) {
                e = item;
              }
            });
            arr.push(e);
          });
          this.newData = arr;
          this.sendChange();
          this.$message({
            type: 'success',
            message: '更改成功!',
          });
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消更改',
          });
          this.dirData = this.old_dirDat; //将备份的dir重新赋值
        });
    },
    sendChange() {
      updateDirTree(this.newData).then((res) => {
        console.log(res);
        if (res.status == 200) {
          this.$message({
            type: 'success',
            message: '更新成功!',
          });
        }
      });
    },
  },
  mounted() {
    this.getDirTree();
  },
  watch: {
    showBtn: {
      immediate: true,
      handler(val) {
        if (val) {
          this.showEdit = val;
          this.draggable = val;
        }
      },
    },
    showBread: {
      immediate: true,
      handler(val) {
        if (val) this.showBread = val;
      },
    },
  },
};
</script>
<style lang="less" scoped>
.wrap {
  width: 98.5%;
  height: 100%;
  .bread {
    width: 100%;
    height: 5%;
    margin: 0 auto;
    overflow: auto;
  }
  .treeBox {
    margin-top: 1%;
    width: 100%;
    height: 94%;
    overflow: auto;
    .el-tree {
      background: transparent;
      font-size: 15px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #000000;
      // /deep/ .el-tree-node__label {
      //   font-size: 18px;
      // }
      /deep/ .el-tree-node {
        padding-top: 10px;
        // padding-bottom: 10px;
      }
      /deep/ .el-tree-node:focus > .el-tree-node__content {
        background-color: #b9b9b9;
      }
      /deep/ .el-tree-node__content:hover {
        background-color: rgb(153, 153, 153);
      }
      .btnBox {
        margin-left: 5px;
        .el-button + .el-button {
          margin-left: 5px;
        }
      }
    }
  }
}
</style>
src/views/userManage/roleManage.vue
@@ -16,29 +16,34 @@
          :label="$t('userManage.RM.ownedSystem')"
          prop="ownedSystem"
        >
          <el-select v-model="roleForm.ownedSystem">
            <el-option :label="$t('userManage.RM.one')" value="one" />
          </el-select>
          <el-input
            v-model="roleForm.value"
            :disabled="true"
            :placeholder="$t('common.pleaseInput')"
          />
          <el-button style="margin-left: 20px" @click="showDepTree(1)">{{
            $t('common.choose')
          }}</el-button>
        </el-form-item>
        <br />
        <el-form-item>
          <el-button
          <el-button @click="InsertFormdialog = true"
            ><i class="el-icon-circle-plus-outline"></i> &nbsp;{{
              $t("userManage.RM.add")
              $t('userManage.RM.add')
            }}</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-button
            ><i class="el-icon-search"></i> &nbsp;{{
              $t("userManage.RM.query")
              $t('userManage.RM.query')
            }}</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-button @click="resetForm('ruleForm')"
            ><i class="el-icon-delete"></i>&nbsp;{{
              $t("userManage.RM.reset")
              $t('userManage.RM.reset')
            }}</el-button
          >
        </el-form-item>
@@ -52,100 +57,396 @@
          :label="$t('userManage.RM.index')"
          width="70px"
        />
        <el-table-column align="center" prop="id" v-if="false" />
        <el-table-column
          align="center"
          prop="roleName"
          prop="name"
          :label="$t('userManage.RM.roleName')"
        />
        <el-table-column
          align="center"
          prop="ownedSystem"
          prop="depid"
          :label="$t('userManage.RM.ownedSystem')"
        />
        <el-table-column
          align="center"
          prop="Permission"
          :label="$t('userManage.RM.Permission')"
          prop="descr"
          :label="$t('userManage.RM.describe')"
        />
        <el-table-column
          align="center"
          prop="createUser"
          :label="$t('userManage.RM.creationuser')"
        />
        <el-table-column
          align="center"
          prop="resourcePermission"
          :label="$t('userManage.RM.resourcePermission')"
          prop="createTime"
          :label="$t('userManage.RM.creationtime')"
        />
        <el-table-column
          align="center"
          prop="roleSetting"
          :label="$t('userManage.RM.groupSetting')"
          prop="UpdateUser"
          :label="$t('userManage.RM.updateonuser')"
        />
        <el-table-column
          align="center"
          prop="updateTime"
          :label="$t('userManage.RM.updateontime')"
        />
        <el-table-column
          align="center"
          prop="bak"
          :label="$t('userManage.RM.remarks')"
        />
        <el-table-column
          fixed="right"
          :label="$t('common.operate')"
          width="300"
          width="200"
        >
          <template #default>
            <el-button type="warning" size="small">{{
              $t("common.update")
            }}</el-button>
            <el-button type="danger" size="small">{{
              $t("common.delete")
            }}</el-button>
          <template slot-scope="scope">
            <el-button
              type="warning"
              @click="handleEdit(scope.$index, scope.row)"
              size="small"
              >{{ $t('common.update') }}</el-button
            >
            <el-button
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              size="small"
              >{{ $t('common.delete') }}</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div style="margin-top: 40px" class="pagination_box">
      <div style="margin-top: 25px" class="pagination_box">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :current-page="listData.pageIndex"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="10"
          :page-size="listData.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="0"
          :total="count"
        >
        </el-pagination>
      </div>
    </div>
    <el-dialog
      :title="$t('userManage.RM.insertRole')"
      top="15vh"
      width="80vh"
      style="overflow: hidden"
      :visible.sync="InsertFormdialog"
    >
      <el-form :model="insertform">
        <el-form-item
          :label="$t('userManage.RM.roleName')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="insertform.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.ownedSystem')"
          :label-width="formLabelWidth"
          :prop="insertform.depValue"
          :rules="[{ required: true, message: '不能为空' }]"
        >
          <el-input
            v-model="insertform.depValue"
            :disabled="true"
            :placeholder="$t('common.pleaseInput')"
          />
          <el-button style="margin-left: 20px" @click="showDepTree(2)">{{
            $t('common.choose')
          }}</el-button>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.describe')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="insertform.descr" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.remarks')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="insertform.bak" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="insertFromClose">{{ $t('common.close') }}</el-button>
        <el-button type="primary" @click="insertFromData">{{
          $t('common.confirm')
        }}</el-button>
      </div>
    </el-dialog>
    <el-dialog
      :title="$t('userManage.RM.insertRole')"
      top="15vh"
      width="80vh"
      style="overflow: hidden"
      :visible.sync="UpdateFormdialog"
    >
      <el-form :model="updateform">
        <el-form-item
          :label="$t('userManage.RM.roleName')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="updateform.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.ownedSystem')"
          :label-width="formLabelWidth"
          :prop="updateform.depValue"
        >
          <el-input
            v-model="updateform.depValue"
            :disabled="true"
            :placeholder="$t('common.pleaseInput')"
          />
          <el-button style="margin-left: 20px" @click="showDepTree(3)">{{
            $t('common.choose')
          }}</el-button>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.describe')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="updateform.descr" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.remarks')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="updateform.bak" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="updateFromClose">{{ $t('common.close') }}</el-button>
        <el-button type="primary" @click="updateFromData">{{
          $t('common.confirm')
        }}</el-button>
      </div>
    </el-dialog>
    <div class="leftTree" v-if="showCata">
      <div class="treeBox">
        <role-dep-tree></role-dep-tree>
      </div>
      <div class="btnBox">
        <el-button type="primary" size="small" @click="selectCataName"
          >确定</el-button
        >
        <el-button type="primary" size="small" @click="showCata = false"
          >取消</el-button
        >
      </div>
    </div>
  </div>
</template>
  <script>
import MyBread from "../../components/MyBread.vue";
<script>
import MyBread from '../../components/MyBread.vue';
import roleDepTree from './roleDepTree.vue';
import {
  select_Role_ByPageAndCount,
  selectdepTab,
  insertRole,
  deleteRole,
  selectDep,
  updateRole,
} from '../../api/api';
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {
    MyBread,
    roleDepTree,
  },
  data() {
    return {
      currentPage: 1,
      roleForm: {
        groupName: "",
        ownedSystem: "",
      },
      showCata: false,
      formLabelWidth: '120px',
      InsertFormdialog: false,
      UpdateFormdialog: false,
      roleForm: {},
      cataName: '',
      depValue: '',
      elTreeFlag: 0,
      path_id: '',
      tableData: [],
      insertform: {},
      updateform: {},
      count: 0,
      selData: [],
      listData: {
        pageIndex: 1,
        pageSize: 10,
      },
    };
  },
  methods: {
    showDepTree(res) {
      this.showCata = true;
      this.elTreeFlag = res;
    },
    selectCataName() {
      this.cataName = this.$store.state.catalogueName;
      this.path_id = this.$store.state.cataNode.id;
      var value;
      if (this.cataName.indexOf('>') != -1) {
        var data = this.$store.state.catalogueName.split('>');
        value = data[data.length - 1];
      } else {
        value = this.$store.state.catalogueName;
      }
      this.$store.commit('changeCata', ''); //清空state的面包屑
      this.$store.commit('changeNode', ''); //清空state的节点对象
      this.showCata = false;
      switch (this.elTreeFlag) {
        case 1:
          this.roleForm.value = value;
          break;
        case 2:
          this.insertform.depid = this.path_id;
          this.insertform.depValue = value;
          break;
        case 3:
          this.updateform.depid = this.path_id;
          this.updateform.depValue = value;
          break;
      }
    },
    async getRoleTabelData() {
      if (this.listData.tab == '') {
        delete this.listData.tab;
      }
      const data = await select_Role_ByPageAndCount(this.listData);
      if (data.code != 200) {
        this.$message.error('列表调用失败');
      }
      this.tableData = data.result;
      this.count = data.count;
    },
    async getSelectDepTab() {
      this.selectData = [];
      const data = await selectdepTab();
      if (data.code != 200) {
        this.$message.error('下拉调用失败');
      }
      data.result.forEach((e) => {
        if (e) {
          this.selData.push({
            label: e.name,
            value: e.id,
          });
        }
      });
    },
    insertFromClose() {
      this.InsertFormdialog = false;
      this.insertform = {};
    },
    async insertFromData() {
      if (this.insertform.depValue == null) {
        this.$message({
          message: '请选择角色所属单位',
          type: 'warning',
        });
        return;
      }
      const data = await insertRole(this.insertform);
      if (data.code == 200) {
        this.InsertFormdialog = false;
        this.insertform = {};
        this.$message({
          message: '添加成功!',
          type: 'success',
        });
        this.getRoleTabelData();
      } else {
        this.$message({
          message: '添加失败!',
          type: 'warning',
        });
      }
    },
    updateFromClose() {
      this.UpdateFormdialog = false;
      this.updateform = {};
    },
    async updateFromData() {
      if (this.updateform.depValue == null) {
        this.$message({
          message: '请选择角色所属单位',
          type: 'warning',
        });
        return;
      }
      const data = await updateRole(this.updateform);
      if (data.code == 200) {
        this.UpdateFormdialog = false;
        this.updateform = {};
        this.$message({
          message: '修改成功!',
          type: 'success',
        });
        this.getRoleTabelData();
      } else {
        this.$message({
          message: '修改失败!',
          type: 'warning',
        });
      }
    },
    async handleDelete(index, row) {
      const data = await deleteRole({ id: row.id.toString() });
      if (data.code == 200) {
        this.InsertFormdialog = false;
        this.$message({
          message: '删除成功!',
          type: 'success',
        });
        this.getRoleTabelData();
      } else {
        this.$message({
          message: '删除失败!',
          type: 'warning',
        });
      }
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} æ¡`);
      this.listData.pageSize = val;
      this.getRoleTabelData();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.listData.pageIndex = val;
      this.getRoleTabelData();
    },
    async handleEdit(index, row) {
      this.updateform = row;
      const data = await selectDep({ id: row.depid });
      this.updateform.depValue = data.result.name;
      this.UpdateFormdialog = true;
    },
    onSubmit() {
      console.log("submit!");
      console.log('submit!');
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
  created() {},
  created() {
    this.getRoleTabelData();
    this.getSelectDepTab();
  },
};
</script>
  <style lang="less" scoped>
<style lang="less" scoped>
//@import url(); å¼•入公共cssç±»
.logLog_box {
  background: rgb(240, 242, 245);
@@ -156,21 +457,43 @@
  .el-input {
    width: 300px;
  }
  .leftTree {
    position: absolute;
    z-index: 9999;
    top: 9%;
    left: 37%;
    width: 400px;
    height: 600px;
    background: #f0f2f5;
    border: 1px solid #000;
    .treeBox {
      height: 550px;
      overflow: auto;
      /deep/ .el-tree-node__content:hover {
        background-color: rgb(153, 153, 153);
      }
    }
    .btnBox {
      width: 123px;
      margin: 10px auto 0;
      // background-color: red;
    }
  }
  .inquire {
    height: 110px;
    height: 115px;
    overflow: auto;
    padding: 10px;
    margin-top: 20px;
    background: #fff;
    border-radius: 5px;
    border: 1px solid rgb(202, 201, 204);
    margin-bottom: 20px;
    margin-bottom: 10px;
    .el-form-item {
      margin: 7px;
    }
  }
  .table_box {
    height: 65%;
    height: 70%;
    padding: 10px;
    background: #fff;
    border-radius: 5px;
@@ -181,4 +504,3 @@
  }
}
</style>