Quellcode durchsuchen

人员管理修改

2213980799@qq.com vor 1 Jahr
Ursprung
Commit
b3a42a87f0

+ 26 - 22
src/views/system/organization/components/org-select.vue

@@ -10,33 +10,37 @@
     default-expand-all
     :placeholder="placeholder"
     @input="updateValue"
+    :disabled="disabled"
   />
 </template>
 
 <script>
-  export default {
-    props: {
-      // 选中的数据(v-model)
-      value: [Number,String],
-      // 提示信息
-      placeholder: {
-        type: String,
-        default: '请选择机构'
-      },
-      // 机构数据
-      data: Array
+export default {
+  props: {
+    // 选中的数据(v-model)
+    value: [Number, String],
+    disabled: {
+      type: Boolean,
+      default: false
     },
-    methods: {
-      /* 更新选中数据 */
-      updateValue(value) {
-        this.$emit('input', value);
-
-        let nodesInfo = []
-         nodesInfo = this.$refs['tree'].getHalfCheckedKeys()
-        nodesInfo.push(value)
-        this.$emit('checkedKeys', nodesInfo)
+    // 提示信息
+    placeholder: {
+      type: String,
+      default: '请选择机构'
+    },
+    // 机构数据
+    data: Array
+  },
+  methods: {
+    /* 更新选中数据 */
+    updateValue(value) {
+      this.$emit('input', value);
 
-      }
+      let nodesInfo = [];
+      nodesInfo = this.$refs['tree'].getHalfCheckedKeys();
+      nodesInfo.push(value);
+      this.$emit('checkedKeys', nodesInfo);
     }
-  };
+  }
+};
 </script>

Datei-Diff unterdrückt, da er zu groß ist
+ 415 - 222
src/views/system/organization/components/org-user-edit.vue


+ 326 - 179
src/views/system/organization/components/org-user-list.vue

@@ -22,7 +22,14 @@
           >
             添加
           </el-button>
-          <el-button type="primary" size="mini" icon="el-icon-upload2" plain @click="uploadFile">导入</el-button>
+          <el-button
+            type="primary"
+            size="mini"
+            icon="el-icon-upload2"
+            plain
+            @click="uploadFile"
+            >导入</el-button
+          >
         </org-user-search>
       </template>
       <!-- 角色列 -->
@@ -53,6 +60,7 @@
           :underline="false"
           icon="el-icon-edit"
           @click="openEdit(row)"
+          v-if="!row.loginName"
         >
           修改
         </el-link>
@@ -65,10 +73,20 @@
         >
           解绑
         </el-link>
+        <el-link
+          v-if="!row.loginName"
+          type="primary"
+          :underline="false"
+          icon="el-icon-add"
+          @click="addUsers(row)"
+        >
+          新建账号
+        </el-link>
         <el-popconfirm
           class="ele-action"
           title="确定要删除此用户吗?"
           @confirm="remove(row)"
+          v-if="!row.loginName"
         >
           <template v-slot:reference>
             <el-link type="danger" :underline="false" icon="el-icon-delete">
@@ -87,195 +105,324 @@
       :organization-id="organizationId"
       @done="reload"
     />
-
-    <importDialog :defModule="moudleName" ref="importDialogRef" @success="reload" />
+    <addUsers :visible.sync="showEdit1" :data="null" ref="userEdit" />
+    <importDialog
+      :defModule="moudleName"
+      ref="importDialogRef"
+      @success="reload"
+    />
+    <ele-modal
+      width="1000px"
+      :visible="userShow"
+      :close-on-click-modal="false"
+      custom-class="ele-dialog-form"
+    >
+      <!-- 数据表格 -->
+      <ele-pro-table
+        ref="table"
+        :columns="columns1"
+        :datasource="datasource1"
+        :current.sync="userRow"
+        highlight-current-row
+        row-key="id"
+      >
+     
+      </ele-pro-table>
+      <template v-slot:footer>
+          <el-button @click="userShow = false">取消</el-button>
+          <el-button type="primary" @click="getUser"> 确认 </el-button>
+        </template>
+    </ele-modal>
   </div>
 </template>
 
 <script>
-  import OrgUserSearch from './org-user-search.vue';
-  import OrgUserEdit from './org-user-edit.vue';
-  import importDialog from "@/components/upload/import-dialog.vue";
+import OrgUserSearch from './org-user-search.vue';
+import OrgUserEdit from './org-user-edit.vue';
+import importDialog from '@/components/upload/import-dialog.vue';
+import addUsers from '@/views/system/user/components/user-edit.vue';
+
+import {
+  getUserPage,
+  removePersonnel,
+  unbindLoginName
+} from '@/api/system/organization';
+import { pageUsers } from '@/api/system/user';
+export default {
+  components: { importDialog, OrgUserSearch, OrgUserEdit, addUsers },
+  props: {
+    // 机构id
+    organizationId: [Number, String],
+    // 全部机构
+    organizationList: Array,
+    institutionList: Array
+  },
+  data() {
+    return {
+      moudleName: 'mainUser',
+      showEdit1: false,
+      userShow:false,
+      userRow: null,
+      currentRow:null,
+      // 表格列配置
+      columns: [
+        {
+          columnKey: 'index',
+          type: 'index',
+          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 ? '女' : '';
+          }
+        },
+        {
+          prop: 'status',
+          label: '状态',
+          align: 'center',
+          sortable: 'custom',
+          width: 80,
+          formatter: (_row, _column, cellValue) => {
+            const dom = this.statusOptions.find((item) => {
+              return item.value == cellValue;
+            });
+            return dom ? dom.label : '';
+          }
+        },
+        {
+          prop: 'createTime',
+          label: '创建时间',
+          sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110,
+          formatter: (_row, _column, cellValue) => {
+            return this.$util.toDateString(cellValue);
+          }
+        },
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 200,
+          align: 'left',
+          resizable: false,
+          slot: 'action',
+          showOverflowTooltip: true
+        }
+      ],
+      // 表格列配置
+      columns1: [
+        {
+          columnKey: 'index',
+          type: 'index',
+          width: 55,
+          align: 'center',
+          showOverflowTooltip: true,
+          fixed: 'left',
+          label: '序号'
+        },
+        {
+          prop: 'loginName',
+          label: '用户账号',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'jobNumber',
+          label: '工号',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'name',
+          label: '姓名',
 
-  import {
-    getUserPage,
-    removePersonnel,
-    unbindLoginName
-  } from '@/api/system/organization';
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'phone',
+          label: '手机号',
 
-  export default {
-    components: {importDialog, OrgUserSearch, OrgUserEdit},
-    props: {
-      // 机构id
-      organizationId: [Number, String],
-      // 全部机构
-      organizationList: Array,
-      institutionList: Array,
-    },
-    data() {
-      return {
-        moudleName : "mainUser",
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
 
-        // 表格列配置
-        columns: [
-          {
-            columnKey: 'index',
-            type: 'index',
-            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 ? '女' : '';
-            }
-          },
-          {
-            prop: 'status',
-            label: '状态',
-            align: 'center',
-            sortable: 'custom',
-            width: 80,
-            formatter: (_row, _column, cellValue) => {
-              const dom = this.statusOptions.find((item) => {
-                return item.value == cellValue;
-              });
-              return dom ? dom.label : '';
-            }
-          },
-          {
-            prop: 'createTime',
-            label: '创建时间',
-            sortable: 'custom',
-            showOverflowTooltip: true,
-            minWidth: 110,
-            formatter: (_row, _column, cellValue) => {
-              return this.$util.toDateString(cellValue);
-            }
-          },
-          {
-            columnKey: 'action',
-            label: '操作',
-            width: 200,
-            align: 'left',
-            resizable: false,
-            slot: 'action',
-            showOverflowTooltip: true
+        {
+          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));
+            });
+            return names.toString();
+          }
+        },
+        {
+          prop: 'createTime',
+          label: '创建时间',
+          // sortable: 'custom',
+          showOverflowTooltip: true,
+          minWidth: 110,
+          formatter: (_row, _column, cellValue) => {
+            return this.$util.toDateString(cellValue);
           }
-        ],
-        // 当前编辑数据
-        current: null,
-        // 是否显示编辑弹窗
-        showEdit: false,
-        statusOptions: [
-          { value: 1, label: '全职' },
-          { value: 2, label: '兼职' },
-          { value: 3, label: '实习' },
-          { value: 4, label: '正式' },
-          { value: 5, label: '试用' },
-          { value: 6, label: '离职' }
-        ]
-      };
+        }
+      ],
+      // 当前编辑数据
+      current: null,
+      // 是否显示编辑弹窗
+      showEdit: false,
+      statusOptions: [
+        { value: 1, label: '全职' },
+        { value: 2, label: '兼职' },
+        { value: 3, label: '实习' },
+        { value: 4, label: '正式' },
+        { value: 5, label: '试用' },
+        { value: 6, label: '离职' }
+      ]
+    };
+  },
+  methods: {
+    async addUsers(row) {
+      this.userRow = null;
+      this.currentRow=row
+      const isBind = await this.isBind();
+      if (isBind) {
+        this.userShow = true;
+      } else {
+        this.showEdit1 = true;
+        this.$refs.userEdit.userBk(row);
+      }
+    },
+    getUser() {
+      if (!this.userRow) {
+        this.$message.warning('请选择一条数据!');
+        return;
+      }
+      this.userShow=false
+      this.showEdit1 = true;
+      this.$refs.userEdit.getByData(this.userRow,this.currentRow);
     },
-    methods: {
-      /* 表格数据源 */
-      datasource({ page, limit, where, order }) {
-        return getUserPage({
-          ...where,
-          ...order,
-          pageNum: page,
-          size: limit,
-          groupId: this.organizationId
+    async isBind() {
+      return this.$confirm('是否绑定已有用户?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      })
+        .then(() => {
+          return true;
+        })
+        .catch(() => {
+          return false;
         });
-      },
-      /* 刷新表格 */
-      reload(where) {
-        this.$refs.table.reload({ pageNum: 1, where: where });
-      },
-      /* 显示编辑 */
-      openEdit(row) {
-        this.current = row;
-        this.showEdit = true;
-      },
+    },
+    /* 表格数据源 */
+    datasource({ page, limit, where, order }) {
+      return getUserPage({
+        ...where,
+        ...order,
+        pageNum: page,
+        size: limit,
+        groupId: this.organizationId
+      });
+    },
+    /* 表格数据源 */
+    datasource1({ page, limit, where, order }) {
+      return pageUsers({ ...where, ...order, pageNum: page, size: limit });
+    },
+    /* 刷新表格 */
+    reload(where) {
+      this.$refs.table.reload({ pageNum: 1, where: where });
+    },
+    /* 显示编辑 */
+    openEdit(row) {
+      this.current = row;
+      this.showEdit = true;
+    },
 
-      // 解除绑定
-      toUnBind(row) {
-        const loading = this.$loading({ lock: true });
-        unbindLoginName(row.id)
-          .then((res) => {
-            loading.close();
-            this.$message.success('解绑成功');
-            this.reload();
-          })
-          .catch((e) => {
-            loading.close();
-            // this.$message.error(e.message);
-          });
-      },
-      /* 删除 */
-      remove(row) {
-        const loading = this.$loading({ lock: true });
-        removePersonnel([row.id])
-          .then((msg) => {
-            loading.close();
-            this.$message.success(msg);
-            this.reload();
-          })
-          .catch((e) => {
-            loading.close();
-            // this.$message.error(e.message);
-          });
-      },
-      /* 更改状态 */
-      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);
-          });
-      },
-      uploadFile () {
-        this.$refs.importDialogRef.open();
-      }
+    // 解除绑定
+    toUnBind(row) {
+      const loading = this.$loading({ lock: true });
+      unbindLoginName(row.id)
+        .then((res) => {
+          loading.close();
+          this.$message.success('解绑成功');
+          this.reload();
+        })
+        .catch((e) => {
+          loading.close();
+          // this.$message.error(e.message);
+        });
     },
-    watch: {
-      // 监听机构id变化
-      organizationId() {
-        this.reload();
-      }
+    /* 删除 */
+    remove(row) {
+      const loading = this.$loading({ lock: true });
+      removePersonnel([row.id])
+        .then((msg) => {
+          loading.close();
+          this.$message.success(msg);
+          this.reload();
+        })
+        .catch((e) => {
+          loading.close();
+          // this.$message.error(e.message);
+        });
+    },
+    /* 更改状态 */
+    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);
+        });
+    },
+    uploadFile() {
+      this.$refs.importDialogRef.open();
+    }
+  },
+  watch: {
+    // 监听机构id变化
+    organizationId() {
+      this.reload();
     }
-  };
+  }
+};
 </script>

+ 2 - 1
src/views/system/organization/index.vue

@@ -72,6 +72,7 @@
       :organization-list="data"
       @done="query"
     />
+   
   </div>
 </template>
 
@@ -85,7 +86,7 @@ import {
 
 export default {
   name: 'SystemOrganization',
-  components: {OrgUserList, OrgEdit},
+  components: {OrgUserList,OrgEdit},
   data() {
     return {
       // 加载状态

+ 19 - 13
src/views/system/user/components/user-edit.vue

@@ -234,25 +234,31 @@ export default {
     /* 更新visible */
     updateVisible(value) {
       this.$emit('update:visible', value);
+    },
+    getByData(userRow,currentRow) {
+      let id=this.data?.id||userRow?.id
+      getById(id).then((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)
+          });
+        });
+        if (currentRow) {
+          this.isUpdate=true
+          this.userBk(currentRow);
+        }
+      });
     }
   },
   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.getByData(this.data);
           this.isUpdate = true;
         } else {
           this.isUpdate = false;

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.