Przeglądaj źródła

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

ysy 1 rok temu
rodzic
commit
185b0b9df6

+ 26 - 19
src/api/system/user/index.js

@@ -4,7 +4,7 @@ import request from '@/utils/request';
  * 分页查询用户
  * @param params 查询条件
  */
-export async function pageUsers (params) {
+export async function pageUsers(params) {
   let par = new URLSearchParams(params);
   const res = await request.get(
     `/system/account/getAccountPage?` + par,
@@ -17,16 +17,23 @@ export async function pageUsers (params) {
 }
 
 // 修改用户信息
-export async function putUsers (params) {
+export async function putUsers(params) {
   const res = await request.post('/system/account/update', params);
   if (res.data.code == 0) {
     return res.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
-
+// 用户详情
+export async function getById(id) {
+  const res = await request.get(`/system/account/getById/` + id);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 // 新增用户
-export async function addUsers (params) {
+export async function addUsers(params) {
   const res = await request.post('/system/account/submit', params);
   if (res.data.code == 0) {
     return res.data;
@@ -35,7 +42,7 @@ export async function addUsers (params) {
 }
 
 // 删除用户
-export async function deleteUsers (params) {
+export async function deleteUsers(params) {
   const res = await request.post('/system/account/removeById', params);
   if (res.data.code == 0) {
     return res.data;
@@ -44,7 +51,7 @@ export async function deleteUsers (params) {
 }
 
 // 管理员重置密码
-export async function resetPassword (params) {
+export async function resetPassword(params) {
   const res = await request.get(`/system/account/resetPassword/` + params, {});
   if (res.data.code == 0) {
     return res.data;
@@ -53,7 +60,7 @@ export async function resetPassword (params) {
 }
 
 // 修改用户密码
-export async function updatePassword (params) {
+export async function updatePassword(params) {
   const res = await request.post('/system/account/updatePassword', params);
   if (res.data.code == 0) {
     return res.data;
@@ -62,7 +69,7 @@ export async function updatePassword (params) {
 }
 
 // 退出登录
-export async function userLogout (params) {
+export async function userLogout(params) {
   const res = await request.post('/main/user/logout', params);
   if (res.data.code == 0) {
     return res.data;
@@ -74,7 +81,7 @@ export async function userLogout (params) {
  * 查询未绑定用户账号
  * @param params 查询条件
  */
-export async function getNotBoundAccount (params) {
+export async function getNotBoundAccount(params) {
   const res = await request.get('/system/account/getNotBoundAccount');
   if (res.data.code == 0) {
     return res.data.data;
@@ -87,7 +94,7 @@ export async function getNotBoundAccount (params) {
  * 查询用户列表
  * @param params 查询条件
  */
-export async function listUsers (params) {
+export async function listUsers(params) {
   const res = await request.get('/system/user', {
     params
   });
@@ -101,7 +108,7 @@ export async function listUsers (params) {
  * 根据id查询用户
  * @param id 用户id
  */
-export async function getUser (id) {
+export async function getUser(id) {
   const res = await request.get('/system/user/' + id);
   if (res.data.code === 0) {
     return res.data.data;
@@ -113,7 +120,7 @@ export async function getUser (id) {
  * 添加用户
  * @param data 用户信息
  */
-export async function addUser (data) {
+export async function addUser(data) {
   const res = await request.post('/system/user', data);
   if (res.data.code === 0) {
     return res.data.message;
@@ -125,7 +132,7 @@ export async function addUser (data) {
  * 修改用户
  * @param data 用户信息
  */
-export async function updateUser (data) {
+export async function updateUser(data) {
   const res = await request.put('/system/user', data);
   if (res.data.code === 0) {
     return res.data.message;
@@ -137,7 +144,7 @@ export async function updateUser (data) {
  * 删除用户
  * @param id 用户id
  */
-export async function removeUser (id) {
+export async function removeUser(id) {
   const res = await request.delete('/system/user/' + id);
   if (res.data.code === 0) {
     return res.data.message;
@@ -149,7 +156,7 @@ export async function removeUser (id) {
  * 批量删除用户
  * @param data 用户id集合
  */
-export async function removeUsers (data) {
+export async function removeUsers(data) {
   const res = await request.delete('/system/user/batch', {
     data
   });
@@ -164,7 +171,7 @@ export async function removeUsers (data) {
  * @param userId 用户id
  * @param status 状态
  */
-export async function updateUserStatus (userId, status) {
+export async function updateUserStatus(userId, status) {
   const res = await request.put('/system/user/status', {
     userId,
     status
@@ -181,7 +188,7 @@ export async function updateUserStatus (userId, status) {
  * @param password 密码
  * @returns {Promise<string>}
  */
-export async function updateUserPassword (userId, password = '123456') {
+export async function updateUserPassword(userId, password = '123456') {
   const res = await request.put('/system/user/password', {
     userId,
     password
@@ -196,7 +203,7 @@ export async function updateUserPassword (userId, password = '123456') {
  * 导入用户
  * @param file excel文件
  */
-export async function importUsers (file) {
+export async function importUsers(file) {
   const formData = new FormData();
   formData.append('file', file);
   const res = await request.post('/system/user/import', formData);
@@ -212,7 +219,7 @@ export async function importUsers (file) {
  * @param value 字段的值
  * @param id 修改时的id
  */
-export async function checkExistence (field, value, id) {
+export async function checkExistence(field, value, id) {
   const res = await request.get('/system/user/existence', {
     params: { field, value, id }
   });

+ 4 - 4
src/views/system/organization/components/org-user-edit.vue

@@ -126,9 +126,9 @@
               :disabled="true"
               :maxlength="11"
               v-model="form.loginName"
-              v-if="isUpdate && data.accountId"
+            
             />
-            <el-select
+            <!-- <el-select
               clearable
               class="ele-block"
               v-model="form.accountId"
@@ -143,7 +143,7 @@
                 :value="item.id"
               >
               </el-option>
-            </el-select>
+            </el-select> -->
           </el-form-item>
           <el-form-item label="手机号:" prop="phone">
             <el-input
@@ -939,7 +939,7 @@ export default {
         ],
         jobNumber: [
           {
-            required: true,
+            required: false,
             trigger: 'blur',
             validator: (_rule, value, callback) => {
               if (!value) {

+ 2 - 2
src/views/system/role/components/role-edit.vue

@@ -16,7 +16,7 @@
           placeholder="请输入角色名称"
         />
       </el-form-item>
-      <el-form-item label="组织ID:" prop="groupId">
+      <!-- <el-form-item label="组织ID:" prop="groupId">
         <ele-tree-select
           clearable
           :data="organizationList"
@@ -27,7 +27,7 @@
             v-model="form.groupId"
 
         />
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item label="启用状态:" prop="enable">
         <el-switch
           v-model="form.enable"

+ 7 - 7
src/views/system/role/index.vue

@@ -146,13 +146,13 @@ export default {
           showOverflowTooltip: true,
           minWidth: 110
         },
-        {
-          prop: 'groupName',
-          label: '组织名称',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
+        // {
+        //   prop: 'groupName',
+        //   label: '组织名称',
+        //   align: 'center',
+        //   showOverflowTooltip: true,
+        //   minWidth: 110
+        // },
         {
           prop: 'secretLevel',
           label: '密级',

+ 179 - 0
src/views/system/user/components/add.vue

@@ -0,0 +1,179 @@
+<!-- 用户编辑弹窗 -->
+<template>
+  <ele-modal
+    width="65vw"
+    :visible.sync="show"
+    :close-on-click-modal="false"
+    custom-class="ele-dialog-form"
+    append-to-body
+    @close="cancel"
+  >
+    <ele-split-layout
+      width="210px"
+      allow-collapse
+      :right-style="{ overflow: 'hidden' }"
+    >
+      <div>
+        <div class="ele-border-lighter sys-organization-list">
+          <el-tree
+            ref="tree"
+            :data="data"
+            highlight-current
+            node-key="id"
+            :props="{ label: 'name' }"
+            :expand-on-click-node="false"
+            :default-expand-all="true"
+            @node-click="onNodeClick"
+          /> </div
+        >.
+      </div>
+      <template v-slot:content>
+        <org-user-search @search="reload"> </org-user-search>
+        <ele-pro-table
+          ref="table"
+          :columns="columns"
+          :datasource="datasource"
+          tool-class="ele-toolbar-form"
+          :current.sync="current"
+          highlight-current-row
+        >
+        </ele-pro-table>
+      </template>
+    </ele-split-layout>
+    <template v-slot:footer>
+      <el-button @click="cancel">取消</el-button>
+      <el-button type="primary" @click="save"> 确认 </el-button>
+    </template>
+  </ele-modal>
+</template>
+
+<script>
+import { getUserPage } from '@/api/system/organization';
+import OrgUserSearch from '@/views/system/organization/components/org-user-search.vue';
+
+import { listOrganizations } from '@/api/system/organization';
+export default {
+  components:{
+    OrgUserSearch
+  },
+  data() {
+    return {
+      data: [],
+      show: false,
+      organizationId: '',
+      // 表格列配置
+      columns: [
+        {
+          columnKey: 'index',
+          type: 'index',
+          label: '序号',
+          width: 45,
+          align: 'center',
+          showOverflowTooltip: true,
+          fixed: 'left'
+        },
+        {
+          prop: 'name',
+          label: '姓名',
+          sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'jobNumber',
+          label: '工号',
+          sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'loginName',
+          label: '用户账号',
+          sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'sex',
+          label: '性别',
+          sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 80,
+          formatter: (_row, _column, cellValue) => {
+            return cellValue == 1 ? '男' : cellValue == 2 ? '女' : '';
+          }
+        }
+      ],
+      current: {}
+    };
+  },
+
+  created() {},
+  methods: {
+    /* 查询 */
+    query() {
+      listOrganizations()
+        .then((list) => {
+          let _list = list.filter((i) => i.name != '超级管理员');
+
+          this.data = this.$util.toTreeData({
+            data: _list,
+            idField: 'id',
+            parentIdField: 'parentId',
+          });
+
+          this.$nextTick(() => {
+            this.onNodeClick(this.data[0]);
+          });
+        })
+        .catch((e) => {
+          // this.$message.error(e.message);
+        });
+    },
+    async open() {
+      this.query();
+      this.show = true;
+    },
+    /* 表格数据源 */
+    async datasource({ page, limit, where, order }) {
+      let data = await getUserPage({
+        ...where,
+        ...order,
+        pageNum: page,
+        size: limit,
+        groupId: this.organizationId,
+        hasAccount:0
+
+      });
+
+      return data;
+    },
+    /* 保存编辑 */
+    save() {
+      let data = JSON.parse(JSON.stringify(this.current));
+      this.$emit('success', data);
+      this.show = false;
+    },
+    onNodeClick(val) {
+      this.organizationId = val.id;
+      this.reload();
+    },
+    /* 刷新表格 */
+    reload(where) {
+      this.$refs.table.reload({ pageNum: 1, where: where });
+    },
+    cancel() {
+      this.show = false;
+    }
+  }
+};
+</script>
+<style scoped lang="scss">
+:deep(.ele-split-panel-wrap) {
+  height: 50vh;
+  overflow-y: auto;
+}
+:deep(.el-checkbox__input.is-disabled .el-checkbox__inner) {
+  background-color: #f3f3f3;
+}
+</style>

+ 195 - 100
src/views/system/user/components/user-edit.vue

@@ -6,7 +6,7 @@
     :append-to-body="true"
     :close-on-click-modal="false"
     custom-class="ele-dialog-form"
-    :title="isUpdate ? '修改用户' : '添加用户'"
+    :title="isUpdate ? '修改用户' : '新建用户'"
     @update:visible="updateVisible"
   >
     <el-form ref="form" :model="form" :rules="rules" label-width="100px">
@@ -23,8 +23,13 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
-          <el-form-item label="用户角色:" prop="roleId">
-            <role-select v-model="form.roleId" />
+          <el-form-item label="员工姓名:" prop="name">
+            <el-input
+              :maxlength="20"
+              v-model="form.name"
+              @click.native="setUsers"
+              placeholder="选择人员"
+            />
           </el-form-item>
         </el-col>
         <el-col :span="12">
@@ -49,6 +54,40 @@
             </el-switch>
           </el-form-item>
         </el-col>
+        <el-col :span="24">
+          <el-table
+            :data="form.groupRolePOList"
+            style="width: 100%"
+            :border="true"
+          >
+            <el-table-column
+              prop="groupName"
+              label="组织机构"
+              align="center"
+              width="200"
+            >
+            </el-table-column>
+            <el-table-column prop="roleIds" label="角色" align="center">
+              <template slot-scope="scope">
+                <el-form-item label="角色:">
+                  <role-select v-model="scope.row.roleIds" />
+                </el-form-item>
+              </template>
+            </el-table-column>
+          </el-table>
+          <!-- <el-row>
+            <el-col :span="12">
+              <el-form-item label="部门:" prop="deptName">
+                <el-input v-model="form.deptName" disabled />
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="角色:" prop="roleId">
+                <role-select v-model="form.roleId" />
+              </el-form-item>
+            </el-col>
+          </el-row> -->
+        </el-col>
       </el-row>
     </el-form>
     <template v-slot:footer>
@@ -57,117 +96,173 @@
         保存
       </el-button>
     </template>
+    <add ref="addREf" @success="userBk"></add>
   </ele-modal>
 </template>
 
 <script>
-  // import { emailReg, phoneReg } from 'ele-admin';
-  import RoleSelect from './role-select.vue';
-  import { addUsers, putUsers } from '@/api/system/user';
+// import { emailReg, phoneReg } from 'ele-admin';
+import RoleSelect from './role-select.vue';
+import add from './add.vue';
+import { addUsers, putUsers, getById } from '@/api/system/user';
 
-  export default {
-    components: { RoleSelect },
-    props: {
-      // 弹窗是否打开
-      visible: Boolean,
-      // 修改回显的数据
-      data: Object
-    },
-    data() {
-      const defaultForm = {
-        id: null,
-        loginName: '',
-        roleId: [],
-        loginPwd: '',
-        enable: 1
-      };
-      return {
-        defaultForm,
-        // 表单数据
-        form: { ...defaultForm },
-        // 表单验证规则
-        rules: {
-          loginName: [
-            { required: true, message: '请输入用户账号', trigger: 'blur' }
-          ],
-          roleId: [
-            { required: true, message: '请选择角色', trigger: 'change' }
-          ],
-          loginPwd: [
-            {
-              required: true,
-              pattern: /^[\S]{5,18}$/,
-              message: '密码必须为5-18位非空白字符',
-              trigger: 'blur'
-            }
-          ]
-        },
-        // 提交状态
-        loading: false,
-        // 是否是修改
-        isUpdate: false
-      };
+export default {
+  components: { RoleSelect, add },
+  props: {
+    // 弹窗是否打开
+    visible: Boolean,
+    // 修改回显的数据
+    data: Object
+  },
+  data() {
+    const defaultForm = {
+      id: null,
+      loginName: '',
+      mainUserId: '',
+      name: '',
+      loginPwd: 123456,
+      enable: 1,
+      groupRolePOList: [],
+      jobNumber: '',
+      phone: ''
+    };
+    return {
+      defaultForm,
+      // 表单数据
+      form: { ...defaultForm },
+      // 表单验证规则
+      rules: {
+        loginName: [
+          { required: true, message: '请输入用户账号', trigger: 'blur' }
+        ],
+        name: [{ required: true, message: '请选择员工', trigger: 'change' }],
+        loginPwd: [
+          {
+            required: true,
+            pattern: /^[\S]{5,18}$/,
+            message: '密码必须为5-18位非空白字符',
+            trigger: 'blur'
+          }
+        ]
+      },
+      // 提交状态
+      loading: false,
+      // 是否是修改
+      isUpdate: false
+    };
+  },
+  computed: {
+    // 是否开启响应式布局
+    styleResponsive() {
+      return this.$store.state.theme.styleResponsive;
+    }
+  },
+  methods: {
+    setUsers() {
+      this.$refs.addREf.open();
     },
-    computed: {
-      // 是否开启响应式布局
-      styleResponsive() {
-        return this.$store.state.theme.styleResponsive;
+    userBk(data) {
+      this.form.groupRolePOList = [];
+      if (data && data.deptIds) {
+        this.form.name = data.name;
+        this.form.mainUserId = data.id;
+        this.form.jobNumber = data.jobNumber;
+        this.form.phone = data.phone;
+
+        const deptNames = data.deptName.split('/');
+        data.deptIds.forEach((item, index) => {
+          this.form.groupRolePOList.push({
+            groupName: deptNames[index],
+            groupId: item,
+            roleIds: []
+          });
+        });
       }
     },
-    methods: {
-      /* 保存编辑 */
-      save() {
-        this.$refs.form.validate((valid) => {
-          if (!valid) {
-            return false;
-          }
-          this.loading = true;
-          if (!this.isUpdate) {
-            delete this.form.id;
+    /* 保存编辑 */
+    save() {
+      this.$refs.form.validate((valid) => {
+        let isRole = true;
+        if (!valid) {
+          return false;
+        }
+        this.form.groupRolePOList.forEach((item) => {
+          if (item.roleIds.length == 0) {
+            isRole = false;
           }
-          const data = {
-            ...this.form
-            // roleId: this.form.roleIds.map((d) => {
-            //   return { roleId: d };
-            // })
-          };
-          const saveOrUpdate = this.isUpdate ? putUsers : addUsers;
-          saveOrUpdate(data)
-            .then((msg) => {
-              this.loading = false;
-              this.$message.success(msg);
-              this.updateVisible(false);
-              this.$emit('done');
-            })
-            .catch((e) => {
-              this.loading = false;
-              // this.$message.error(e.message);
-            });
         });
-      },
-      /* 更新visible */
-      updateVisible(value) {
-        this.$emit('update:visible', value);
-      }
+        if (!isRole) {
+          this.$message.warning('请选择角色!');
+
+          return;
+        }
+
+        this.loading = true;
+        if (!this.isUpdate) {
+          delete this.form.id;
+        }
+
+        const data = {
+          ...this.form
+          // roleId: this.form.roleIds.map((d) => {
+          //   return { roleId: d };
+          // })
+        };
+        const saveOrUpdate = this.isUpdate ? putUsers : addUsers;
+        saveOrUpdate(data)
+          .then((msg) => {
+            this.loading = false;
+            this.$message.success(msg);
+            this.updateVisible(false);
+            this.$emit('done');
+          })
+          .catch((e) => {
+            this.loading = false;
+            // this.$message.error(e.message);
+          });
+      });
     },
-    watch: {
-      visible(visible) {
-        if (visible) {
-          if (this.data) {
-            this.$util.assignObject(this.form, {
-              ...this.data,
-              roleId: this.data.roleList.map((d) => d.id),
-              loginPwd: ''
+    /* 更新visible */
+    updateVisible(value) {
+      this.$emit('update:visible', value);
+    }
+  },
+  watch: {
+    visible(visible) {
+      if (visible) {
+        if (this.data) {
+          getById(this.data.id).then((res) => {
+            console.log(res,'res')
+            this.form = res.data;
+            this.form.groupRolePOList = [];
+            res.data.groupRoleList.forEach((item) => {
+              this.form.groupRolePOList.push({
+                groupName: item.groupName,
+                groupId: item.groupId,
+                roleIds: item.roleVOList.map((ids) => ids.id)
+              });
             });
-            this.isUpdate = true;
-          } else {
-            this.isUpdate = false;
-          }
+          });
+
+          this.isUpdate = true;
         } else {
-          this.$refs.form.clearValidate();
-          this.form = { ...this.defaultForm };
+          this.isUpdate = false;
         }
+      } else {
+        this.$refs.form.clearValidate();
+        this.form = { ...this.defaultForm };
       }
     }
-  };
+  }
+};
 </script>
+<style lang="scss" scoped>
+:deep(.el-input--medium .el-input__inner) {
+  height: auto !important;
+}
+:deep(.el-table) {
+  .el-form-item {
+    margin-bottom: 0;
+  }
+}
+</style>

+ 54 - 10
src/views/system/user/components/user-search.vue

@@ -9,14 +9,55 @@
     <el-row :gutter="15">
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="用户账号:">
-          <el-input clearable v-model.trim="where.loginName" placeholder="请输入"/>
+          <el-input
+            clearable
+            v-model.trim="where.loginName"
+            placeholder="请输入"
+          />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="工号:">
+          <el-input
+            clearable
+            v-model.trim="where.jobNumber"
+            placeholder="请输入"
+          />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="姓名:">
+          <el-input
+            clearable
+            v-model.trim="where.name"
+            placeholder="请输入"
+          />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+        <el-form-item label="手机号:">
+          <el-input
+            clearable
+            v-model.trim="where.phone"
+            placeholder="请输入"
+          />
         </el-form-item>
       </el-col>
-
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="角色:">
-          <el-select v-model="where.roleIds" filterable multiple clearable style="width: 100%">
-            <el-option v-for="item in roleList" :value="item.id" :label="item.name" :key="item.id"></el-option>
+          <el-select
+            v-model="where.roleIds"
+            filterable
+            multiple
+            clearable
+            style="width: 100%"
+          >
+            <el-option
+              v-for="item in roleList"
+              :value="item.id"
+              :label="item.name"
+              :key="item.id"
+            ></el-option>
           </el-select>
         </el-form-item>
       </el-col>
@@ -57,20 +98,23 @@
 </template>
 
 <script>
-import {getRolesListAPI} from "@/api/system/role";
+import { getRolesListAPI } from '@/api/system/role';
 
 export default {
   data() {
     // 默认表单数据
     const defaultWhere = {
       loginName: '',
-      roleIds: []
+      roleIds: [],
+      jobNumber:'',
+      name:'',
+      phone:""
       // nickname: '',
       // sex: undefined
     };
     return {
       // 表单数据
-      where: {...defaultWhere},
+      where: { ...defaultWhere },
       roleList: []
     };
   },
@@ -81,11 +125,11 @@ export default {
     }
   },
   created() {
-    this.getRolesList()
+    this.getRolesList();
   },
   methods: {
     async getRolesList() {
-      this.roleList = await getRolesListAPI()
+      this.roleList = await getRolesListAPI();
     },
     /* 搜索 */
     search() {
@@ -93,7 +137,7 @@ export default {
     },
     /*  重置 */
     reset() {
-      this.where = {...this.defaultWhere};
+      this.where = { ...this.defaultWhere };
       this.search();
     }
   }

+ 221 - 192
src/views/system/user/index.vue

@@ -21,10 +21,10 @@
             icon="el-icon-plus"
             class="ele-btn-icon"
             @click="openEdit()"
-            v-if="$hasPermission('sys:account:add')"
           >
             新建
           </el-button>
+          <!-- v-if="$hasPermission('sys:account:add')" -->
           <el-button
             size="small"
             type="danger"
@@ -118,202 +118,231 @@
 </template>
 
 <script>
-  import UserSearch from './components/user-search.vue';
-  import UserEdit from './components/user-edit.vue';
-  import UserImport from './components/user-import.vue';
-  import {
-    pageUsers,
-    putUsers,
-    deleteUsers,
-    resetPassword
-  } from '@/api/system/user';
+import UserSearch from './components/user-search.vue';
+import UserEdit from './components/user-edit.vue';
+import UserImport from './components/user-import.vue';
+import {
+  pageUsers,
+  putUsers,
+  deleteUsers,
+  resetPassword
+} from '@/api/system/user';
 
-  export default {
-    name: 'SystemUser',
-    components: {
-      UserSearch,
-      UserEdit,
-      UserImport
-    },
-    data() {
-      return {
-        // 表格列配置
-        columns: [
-          {
-            columnKey: 'selection',
-            type: 'selection',
-            width: 45,
-            align: 'center',
-            fixed: 'left'
-          },
-          {
-            columnKey: 'index',
-            type: 'index',
-            width: 55,
-            align: 'center',
-            showOverflowTooltip: true,
-            fixed: 'left',
-            label: '序号'
-          },
-          {
-            prop: 'loginName',
-            label: '用户账号',
-            // sortable: 'custom',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            columnKey: 'roleList',
-            label: '角色',
-            showOverflowTooltip: true,
-            minWidth: 110,
-            slot: 'roleList'
-          },
-          {
-            prop: 'createTime',
-            label: '创建时间',
-            // sortable: 'custom',
-            showOverflowTooltip: true,
-            minWidth: 110,
-            formatter: (_row, _column, cellValue) => {
-              return this.$util.toDateString(cellValue);
-            }
-          },
-          {
-            prop: 'enable',
-            label: '状态',
-            align: 'center',
-            // sortable: 'custom',
-            width: 80,
-            resizable: false,
-            slot: 'enable',
-            showOverflowTooltip: true
-          },
-          {
-            columnKey: 'action',
-            label: '操作',
-            width: 220,
-            align: 'center',
-            resizable: false,
-            slot: 'action',
-            showOverflowTooltip: true
+export default {
+  name: 'SystemUser',
+  components: {
+    UserSearch,
+    UserEdit,
+    UserImport
+  },
+  data() {
+    return {
+      // 表格列配置
+      columns: [
+        {
+          columnKey: 'selection',
+          type: 'selection',
+          width: 45,
+          align: 'center',
+          fixed: 'left'
+        },
+        {
+          columnKey: 'index',
+          type: 'index',
+          width: 55,
+          align: 'center',
+          showOverflowTooltip: true,
+          fixed: 'left',
+          label: '序号'
+        },
+        {
+          prop: 'loginName',
+          label: '用户账号',
+          // sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'jobNumber',
+          label: '工号',
+          // sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'name',
+          label: '姓名',
+          // sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'phone',
+          label: '手机号',
+          // sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+
+        {
+          columnKey: 'groupRoleList',
+          label: '角色',
+          showOverflowTooltip: true,
+          minWidth: 110,
+          formatter: (_row, _column, cellValue) => {
+            let names=[]
+            _row.groupRoleList.forEach(item=>{
+              names.push(...item.roleVOList.map(val=>val.name))
+            })
+            console.log(cellValue,'cellValue')
+            return names.toString()
+          }
+        },
+        {
+          prop: 'createTime',
+          label: '创建时间',
+          // sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110,
+          formatter: (_row, _column, cellValue) => {
+            return this.$util.toDateString(cellValue);
           }
-        ],
-        // 表格选中数据
-        selection: [],
-        // 当前编辑数据
-        current: null,
-        // 是否显示编辑弹窗
-        showEdit: false,
-        // 是否显示导入弹窗
-        showImport: false
-      };
+        },
+        {
+          prop: 'enable',
+          label: '状态',
+          align: 'center',
+          // sortable: 'custom',
+          width: 80,
+          resizable: false,
+          slot: 'enable',
+          showOverflowTooltip: true
+        },
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 220,
+          align: 'center',
+          resizable: false,
+          slot: 'action',
+          showOverflowTooltip: true
+        }
+      ],
+      // 表格选中数据
+      selection: [],
+      // 当前编辑数据
+      current: null,
+      // 是否显示编辑弹窗
+      showEdit: false,
+      // 是否显示导入弹窗
+      showImport: false
+    };
+  },
+  methods: {
+    /* 表格数据源 */
+    datasource({ page, limit, where, order }) {
+      return pageUsers({ ...where, ...order, pageNum: page, size: limit });
+    },
+    async changeEnable(row) {
+      let params = { ...row };
+      params.roleId = row.roleList.map((d) => d.id);
+      delete params.roleList;
+      const res = await putUsers(params);
+      if (res.code == 0) {
+        this.$message({
+          type: 'success',
+          message: '修改成功',
+          customClass: 'ele-message-border'
+        });
+        this.reload();
+      }
+    },
+    /* 刷新表格 */
+    reload(where) {
+      this.$refs.table.reload({ page: 1, where: where });
+    },
+    /* 打开编辑弹窗 */
+    openEdit(row) {
+      this.current = row;
+      this.showEdit = true;
+      this.$refs.userEdit.$refs.form &&
+        this.$refs.userEdit.$refs.form.clearValidate();
+    },
+    /* 打开导入弹窗 */
+    openImport() {
+      this.showImport = true;
     },
-    methods: {
-      /* 表格数据源 */
-      datasource({ page, limit, where, order }) {
-        return pageUsers({ ...where, ...order, pageNum: page, size: limit });
-      },
-      async changeEnable(row) {
-        let params = { ...row };
-        params.roleId = row.roleList.map((d) => d.id);
-        delete params.roleList;
-        const res = await putUsers(params);
-        if (res.code == 0) {
-          this.$message({
-            type: 'success',
-            message: '修改成功',
-            customClass: 'ele-message-border'
-          });
+    /* 删除 */
+    remove(row) {
+      const loading = this.$loading({ lock: true });
+      deleteUsers([row.id])
+        .then((msg) => {
+          loading.close();
+          this.$message.success(msg);
           this.reload();
-        }
-      },
-      /* 刷新表格 */
-      reload(where) {
-        this.$refs.table.reload({ page: 1, where: where });
-      },
-      /* 打开编辑弹窗 */
-      openEdit(row) {
-        this.current = row;
-        this.showEdit = true;
-        this.$refs.userEdit.$refs.form &&
-          this.$refs.userEdit.$refs.form.clearValidate();
-      },
-      /* 打开导入弹窗 */
-      openImport() {
-        this.showImport = true;
-      },
-      /* 删除 */
-      remove(row) {
-        const loading = this.$loading({ lock: true });
-        deleteUsers([row.id])
-          .then((msg) => {
-            loading.close();
-            this.$message.success(msg);
-            this.reload();
-          })
-          .catch((e) => {
-            loading.close();
-            // this.$message.error(e.message);
-          });
-      },
-      /* 批量删除 */
-      removeBatch() {
-        if (!this.selection.length) {
-          this.$message.error('请至少选择一条数据');
-          return;
-        }
-        this.$confirm('确定要删除选中的用户吗?', '提示', {
-          type: 'warning'
-        })
-          .then(() => {
-            const loading = this.$loading({ lock: true });
-            deleteUsers(this.selection.map((d) => d.id))
-              .then((msg) => {
-                loading.close();
-                this.$message.success(msg);
-                this.reload();
-              })
-              .catch((e) => {
-                loading.close();
-                // this.$message.error(e.message);
-              });
-          })
-          .catch(() => {});
-      },
-      /* 重置用户密码 */
-      resetPsw(row) {
-        this.$confirm('确定要重置此用户的密码为"123456"吗?', '提示', {
-          type: 'warning'
         })
-          .then(() => {
-            const loading = this.$loading({ lock: true });
-            resetPassword(row.id)
-              .then((msg) => {
-                loading.close();
-                this.$message.success(msg);
-              })
-              .catch((e) => {
-                loading.close();
-                // this.$message.error(e.message);
-              });
-          })
-          .catch(() => {});
-      },
-      /* 更改状态 */
-      editStatus(row) {
-        const loading = this.$loading({ lock: true });
-        updateUserStatus(row.userId, row.status)
-          .then((msg) => {
-            loading.close();
-            this.$message.success(msg);
-          })
-          .catch((e) => {
-            loading.close();
-            row.status = !row.status ? 1 : 0;
-            // this.$message.error(e.message);
-          });
+        .catch((e) => {
+          loading.close();
+          // this.$message.error(e.message);
+        });
+    },
+    /* 批量删除 */
+    removeBatch() {
+      if (!this.selection.length) {
+        this.$message.error('请至少选择一条数据');
+        return;
       }
+      this.$confirm('确定要删除选中的用户吗?', '提示', {
+        type: 'warning'
+      })
+        .then(() => {
+          const loading = this.$loading({ lock: true });
+          deleteUsers(this.selection.map((d) => d.id))
+            .then((msg) => {
+              loading.close();
+              this.$message.success(msg);
+              this.reload();
+            })
+            .catch((e) => {
+              loading.close();
+              // this.$message.error(e.message);
+            });
+        })
+        .catch(() => {});
+    },
+    /* 重置用户密码 */
+    resetPsw(row) {
+      this.$confirm('确定要重置此用户的密码为"123456"吗?', '提示', {
+        type: 'warning'
+      })
+        .then(() => {
+          const loading = this.$loading({ lock: true });
+          resetPassword(row.id)
+            .then((msg) => {
+              loading.close();
+              this.$message.success(msg);
+            })
+            .catch((e) => {
+              loading.close();
+              // this.$message.error(e.message);
+            });
+        })
+        .catch(() => {});
+    },
+    /* 更改状态 */
+    editStatus(row) {
+      const loading = this.$loading({ lock: true });
+      updateUserStatus(row.userId, row.status)
+        .then((msg) => {
+          loading.close();
+          this.$message.success(msg);
+        })
+        .catch((e) => {
+          loading.close();
+          row.status = !row.status ? 1 : 0;
+          // this.$message.error(e.message);
+        });
     }
-  };
+  }
+};
 </script>