林火综合应急信息管理系统前端
guoshilong
2023-03-13 9ecc792eb82c7a94f35ea7f2056567202c6efbff
src/views/system/user.vue
@@ -1,15 +1,15 @@
<template>
  <el-row>
    <el-col :span="5">
      <div class="box">
        <el-scrollbar>
          <basic-container>
            <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
          </basic-container>
        </el-scrollbar>
      </div>
    </el-col>
    <el-col :span="19">
<!--    <el-col :span="5">-->
<!--      <div class="box">-->
<!--        <el-scrollbar>-->
<!--          <basic-container>-->
<!--            <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>-->
<!--          </basic-container>-->
<!--        </el-scrollbar>-->
<!--      </div>-->
<!--    </el-col>-->
    <el-col :span="24">
      <basic-container>
        <avue-crud :option="option"
                   :search.sync="search"
@@ -38,13 +38,13 @@
                       v-if="permission.user_delete"
                       @click="handleDelete">删 除
            </el-button>
            <el-button type="info"
                       size="small"
                       plain
                       v-if="permission.user_role"
                       icon="el-icon-user"
                       @click="handleGrant">角色配置
            </el-button>
<!--            <el-button type="info"-->
<!--                       size="small"-->
<!--                       plain-->
<!--                       v-if="permission.user_role"-->
<!--                       icon="el-icon-user"-->
<!--                       @click="handleGrant">角色配置-->
<!--            </el-button>-->
            <el-button type="info"
                       size="small"
                       plain
@@ -52,34 +52,34 @@
                       icon="el-icon-refresh"
                       @click="handleReset">密码重置
            </el-button>
            <el-button type="info"
                       size="small"
                       plain
                       v-if="userInfo.role_name.includes('admin')"
                       icon="el-icon-setting"
                       @click="handlePlatform">平台配置
            </el-button>
            <el-button type="info"
                       size="small"
                       plain
                       v-if="userInfo.role_name.includes('admin')"
                       icon="el-icon-coordinate"
                       @click="handleLock">账号解封
            </el-button>
            <el-button type="success"
                       size="small"
                       plain
                       v-if="userInfo.role_name.includes('admin')"
                       icon="el-icon-upload2"
                       @click="handleImport">导入
            </el-button>
            <el-button type="warning"
                       size="small"
                       plain
                       v-if="userInfo.role_name.includes('admin')"
                       icon="el-icon-download"
                       @click="handleExport">导出
            </el-button>
<!--            <el-button type="info"-->
<!--                       size="small"-->
<!--                       plain-->
<!--                       v-if="userInfo.role_name.includes('admin')"-->
<!--                       icon="el-icon-setting"-->
<!--                       @click="handlePlatform">平台配置-->
<!--            </el-button>-->
<!--            <el-button type="info"-->
<!--                       size="small"-->
<!--                       plain-->
<!--                       v-if="userInfo.role_name.includes('admin')"-->
<!--                       icon="el-icon-coordinate"-->
<!--                       @click="handleLock">账号解封-->
<!--            </el-button>-->
<!--            <el-button type="success"-->
<!--                       size="small"-->
<!--                       plain-->
<!--                       v-if="userInfo.role_name.includes('admin')"-->
<!--                       icon="el-icon-upload2"-->
<!--                       @click="handleImport">导入-->
<!--            </el-button>-->
<!--            <el-button type="warning"-->
<!--                       size="small"-->
<!--                       plain-->
<!--                       v-if="userInfo.role_name.includes('admin')"-->
<!--                       icon="el-icon-download"-->
<!--                       @click="handleExport">导出-->
<!--            </el-button>-->
          </template>
          <template slot-scope="{row}"
                    slot="tenantName">
@@ -180,7 +180,6 @@
  import {exportBlob} from "@/api/common";
  import {getDeptTree, getDeptLazyTree} from "@/api/system/dept";
  import {getRoleTree} from "@/api/system/role";
  import {getPostList} from "@/api/system/post";
  import {mapGetters} from "vuex";
  import website from '@/config/website';
  import {getToken} from '@/util/auth';
@@ -274,28 +273,10 @@
          border: true,
          index: true,
          selection: true,
          viewBtn: true,
          viewBtn: false,
          dialogType: 'drawer',
          dialogClickModal: false,
          column: [
            {
              label: "登录账号",
              prop: "account",
              search: true,
              display: false
            },
            {
              label: "所属租户",
              prop: "tenantName",
              slot: true,
              display: false
            },
            {
              label: "用户姓名",
              prop: "realName",
              search: true,
              display: false
            },
            {
              label: "所属角色",
              prop: "roleName",
@@ -303,35 +284,109 @@
              display: false
            },
            {
              label: "所属部门",
              label: "所属角色",
              prop: "roleId",
              search:true,
              searchOrder:1,
              searchSpan:3,
              multiple: true,
              type: "tree",
              dicData: [],
              props: {
                label: "title"
              },
              checkStrictly: true,
              slot: true,
              hide:true,
              rules: [{
                required: true,
                message: "请选择所属角色",
                trigger: "click"
              }],
              display: false
            },
            {
              label: "用户名",
              prop: "account",
              search: true,
              searchSpan:4,
              searchOrder:10,
              display: false
            },
            {
              label: "真实姓名",
              prop: "realName",
              search: true,
              searchSpan:4,
              searchOrder:9,
              display: false
            },
            {
              label: "性别",
              prop: "sex",
              type: "select",
              dicData: [
                {
                  label: "男",
                  value: 1
                },
                {
                  label: "女",
                  value: 2
                },
                {
                  label: "未知",
                  value: 3
                }
              ],
              display: false,
            },
            {
              label: "手机号码",
              prop: "phone",
              search: true,
              searchSpan:4,
              searchOrder:8,
              display: false,
            },
            {
              label: "所属单位",
              prop: "deptName",
              slot: true,
              display: false
            },
            {
              label: "用户平台",
              prop: "userTypeName",
              label: "所属单位",
              prop: "deptId",
              search: true,
              searchSpan:3,
              searchOrder:7,
              type: "tree",
              // multiple: true,
              dicData: [],
              props: {
                label: "title",
                value:'id'
              },
              checkStrictly: true,
              slot: true,
              rules: [{
                required: true,
                message: "请选择所属单位",
                trigger: "click"
              }],
              display: false
            },
            {
              label: "用户平台",
              label: "启用状态",
              prop: "status",
              type: "select",
              dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
              dicUrl: '/api/blade-system/dict-biz/dictionary?code=user_status',
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              dataType: "number",
              search: true,
              hide: true,
              display: false,
              prop: "userType",
              rules: [{
                required: true,
                message: "请选择用户平台",
                trigger: "blur"
              }]
              display: false
            },
          ],
          group: [
@@ -341,26 +396,6 @@
              icon: 'el-icon-user-solid',
              column: [
                {
                  label: "所属租户",
                  prop: "tenantId",
                  type: "tree",
                  dicUrl: "/api/blade-system/tenant/select",
                  props: {
                    label: "tenantName",
                    value: "tenantId"
                  },
                  hide: !website.tenantMode,
                  addDisplay: website.tenantMode,
                  editDisplay: website.tenantMode,
                  viewDisplay: website.tenantMode,
                  rules: [{
                    required: true,
                    message: "请输入所属租户",
                    trigger: "click"
                  }],
                  span: 24,
                },
                {
                  label: "登录账号",
                  prop: "account",
                  rules: [{
@@ -368,23 +403,6 @@
                    message: "请输入登录账号",
                    trigger: "blur"
                  }],
                },
                {
                  label: "用户平台",
                  type: "select",
                  dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  dataType: "number",
                  slot: true,
                  prop: "userType",
                  rules: [{
                    required: true,
                    message: "请选择用户平台",
                    trigger: "blur"
                  }]
                },
                {
                  label: '密码',
@@ -444,7 +462,7 @@
                  overHidden: true
                },
                {
                  label: "用户性别",
                  label: "性别",
                  prop: "sex",
                  type: "select",
                  dicData: [
@@ -463,14 +481,14 @@
                  ],
                  hide: true
                },
                {
                  label: "用户生日",
                  type: "date",
                  prop: "birthday",
                  format: "yyyy-MM-dd hh:mm:ss",
                  valueFormat: "yyyy-MM-dd hh:mm:ss",
                  hide: true
                },
                // {
                //   label: "用户生日",
                //   type: "date",
                //   prop: "birthday",
                //   format: "yyyy-MM-dd hh:mm:ss",
                //   valueFormat: "yyyy-MM-dd hh:mm:ss",
                //   hide: true
                // },
                {
                  label: "账号状态",
                  prop: "statusName",
@@ -484,14 +502,15 @@
              prop: 'dutyInfo',
              icon: 'el-icon-s-custom',
              column: [
                {
                  label: "用户编号",
                  prop: "code",
                },
                // {
                //   label: "用户编号",
                //   prop: "code",
                // },
                {
                  label: "所属角色",
                  prop: "roleId",
                  multiple: true,
                  search:true,
                  multiple: false,
                  type: "tree",
                  dicData: [],
                  props: {
@@ -506,10 +525,10 @@
                  }]
                },
                {
                  label: "所属部门",
                  label: "所属单位",
                  prop: "deptId",
                  type: "tree",
                  multiple: true,
                  // multiple: true,
                  dicData: [],
                  props: {
                    label: "title"
@@ -518,26 +537,26 @@
                  slot: true,
                  rules: [{
                    required: true,
                    message: "请选择所属部门",
                    message: "请选择所属单位",
                    trigger: "click"
                  }]
                },
                {
                  label: "所属岗位",
                  prop: "postId",
                  type: "tree",
                  multiple: true,
                  dicData: [],
                  props: {
                    label: "postName",
                    value: "id"
                  },
                  rules: [{
                    required: true,
                    message: "请选择所属岗位",
                    trigger: "click"
                  }],
                },
                // {
                //   label: "所属岗位",
                //   prop: "postId",
                //   type: "tree",
                //   multiple: true,
                //   dicData: [],
                //   props: {
                //     label: "postName",
                //     value: "id"
                //   },
                //   rules: [{
                //     required: true,
                //     message: "请选择所属岗位",
                //     trigger: "click"
                //   }],
                // },
              ]
            },
          ]
@@ -723,15 +742,19 @@
        getRoleTree(tenantId).then(res => {
          const column = this.findObject(this.option.group, "roleId");
          column.dicData = res.data.data;
          const columnRole = this.findObject(this.option.column, "roleId");
          columnRole.dicData = res.data.data;
        });
        getDeptTree(tenantId).then(res => {
          const column = this.findObject(this.option.group, "deptId");
          column.dicData = res.data.data;
          const columnDept = this.findObject(this.option.column, "deptId");
          columnDept.dicData = res.data.data;
        });
        getPostList(tenantId).then(res => {
          const column = this.findObject(this.option.group, "postId");
          column.dicData = res.data.data;
        });
        // getPostList(tenantId).then(res => {
        //   const column = this.findObject(this.option.group, "postId");
        //   column.dicData = res.data.data;
        // });
      },
      submitRole() {
        const roleList = this.$refs.treeRole.getCheckedKeys().join(",");
@@ -745,9 +768,9 @@
        });
      },
      rowSave(row, done, loading) {
        row.deptId = row.deptId.join(",");
        row.roleId = row.roleId.join(",");
        row.postId = row.postId.join(",");
        // row.deptId = row.deptId.join(",");
        // row.roleId = row.roleId.join(",");
        // row.postId = row.postId.join(",");
        add(row).then(() => {
          this.initFlag = false;
          this.onLoad(this.page);
@@ -762,9 +785,9 @@
        });
      },
      rowUpdate(row, index, done, loading) {
        row.deptId = row.deptId.join(",");
        row.roleId = row.roleId.join(",");
        row.postId = row.postId.join(",");
        // row.deptId = row.deptId.join(",");
        // row.roleId = row.roleId.join(",");
        // row.postId = row.postId.join(",");
        update(row).then(() => {
          this.initFlag = false;
          this.onLoad(this.page);
@@ -926,15 +949,16 @@
        if (["edit", "view"].includes(type)) {
          getUser(this.form.id).then(res => {
            this.form = res.data.data;
            if(this.form.hasOwnProperty("deptId")){
              this.form.deptId = this.form.deptId.split(",");
            }
            if(this.form.hasOwnProperty("roleId")){
              this.form.roleId = this.form.roleId.split(",");
            }
            if(this.form.hasOwnProperty("postId")){
              this.form.postId = this.form.postId.split(",");
            }
            //设置为多选时打开
            // if(this.form.hasOwnProperty("deptId")){
            //   this.form.deptId = this.form.deptId.split(",");
            // }
            // if(this.form.hasOwnProperty("roleId")){
            //   this.form.roleId = this.form.roleId.split(",");
            // }
            // if(this.form.hasOwnProperty("postId")){
            //   this.form.postId = this.form.postId.split(",");
            // }
          });
        }
        this.initFlag = true;
@@ -951,14 +975,22 @@
      },
      onLoad(page, params = {}) {
        this.loading = true;
        if (this.query.deptId){
          this.treeDeptId = this.query.deptId
        }
        getList(page.currentPage, page.pageSize, Object.assign(params, this.query), this.treeDeptId).then(res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.data.forEach(e=>{
            e.status = e.status + ""
          })
          this.loading = false;
          this.selectionClear();
        });
      },
      //下面的方法业务都不需要
      platformRowUpdate(row, index, done, loading) {
        updatePlatform(row.id, row.userType, row.userExt).then(() => {
          this.platformOnLoad(this.platformPage);