From 8869eeb87fa90cf81ccdf6d141291f63a45c1c6b Mon Sep 17 00:00:00 2001 From: xiao-fajia <1665375861@qq.com> Date: Wed, 14 Aug 2024 20:02:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=98=E5=B7=A5=E5=8A=A0=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/company/staff/index.js | 8 ++++ src/views/company/staff/form/StaffForm.vue | 55 ++++++++++++++++------ src/views/company/staff/index.vue | 43 ++++++++++++++--- 3 files changed, 84 insertions(+), 22 deletions(-) diff --git a/src/api/company/staff/index.js b/src/api/company/staff/index.js index 4819d96..d8977eb 100644 --- a/src/api/company/staff/index.js +++ b/src/api/company/staff/index.js @@ -84,3 +84,11 @@ export function resetPassword(data){ data }) } + +// 获取角色列表 +export function getRoleList(){ + return request({ + url: '/company/staff/roleList', + method: 'get' + }) +} diff --git a/src/views/company/staff/form/StaffForm.vue b/src/views/company/staff/form/StaffForm.vue index 5ea6868..cdc309f 100644 --- a/src/views/company/staff/form/StaffForm.vue +++ b/src/views/company/staff/form/StaffForm.vue @@ -65,12 +65,12 @@ - + - + @@ -85,6 +85,22 @@ + + + + + + @@ -157,7 +173,7 @@ export default { workNo: undefined, name: undefined, tel: undefined, - sex: "1", + sex: '1', address: undefined, workDate: undefined, workYear: undefined, @@ -169,7 +185,8 @@ export default { fileUrls: undefined, loginAccount: undefined, password: undefined, - labelsArray: undefined + labelsArray: undefined, + roleIds: undefined }, // 表单校验 formRules: { @@ -193,11 +210,11 @@ export default { education: [{ required: true, message: '学历不能为空', trigger: 'blur' }], loginAccount: [ { required: true, message: '登录账号不能为空', trigger: 'blur' }, - { min: 6, max: 20, message: '登录账号长度在6~20个字符', trigger: 'blur'} + { min: 6, max: 20, message: '登录账号长度在6~20个字符', trigger: 'blur' } ], password: [ { required: true, message: '登录密码不能为空', trigger: 'blur' }, - { min: 6, max: 20, message: "登录密码长度在6~20个字符", trigger: 'blur'}, + { min: 6, max: 20, message: '登录密码长度在6~20个字符', trigger: 'blur' }, { pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+{}\[\]:;<>,.?~\\-])\S{6,}$/, message: '登录密码必须由大小写字母、数字、特殊字符组成', @@ -208,10 +225,16 @@ export default { joinedDate: [{ required: true, message: '入职日期不能为空', trigger: 'blur' }] }, labelOptions: [], - nowDate: new Date() + nowDate: new Date(), + roleList: [] } }, methods: { + // 获取角色列表 + async listRoles() { + const res = await StaffApi.getRoleList() + this.roleList = res.data + }, /** 获取标签 */ async listLabels() { try { @@ -227,10 +250,11 @@ export default { this.dialogVisible = true this.dialogTitle = id ? '修改员工信息' : '新增员工信息' await this.listLabels() + await this.listRoles() this.reset() // 修改时,设置数据 if (id) { - this.formData.id = id; + this.formData.id = id this.formLoading = true try { const res = await StaffApi.getStaff(id) @@ -278,7 +302,7 @@ export default { workNo: undefined, name: undefined, tel: undefined, - sex: "1", + sex: '1', address: undefined, workDate: undefined, workYear: undefined, @@ -289,17 +313,18 @@ export default { uniqueCode: undefined, fileIds: undefined, loginAccount: undefined, - password: undefined + password: undefined, + roleIds: undefined } this.resetForm('formRef') }, // 获取工龄 - getWorkYear(){ - this.formData.workYear = this.getYearsByDate(this.formData.workDate); + getWorkYear() { + this.formData.workYear = this.getYearsByDate(this.formData.workDate) }, // 获取司龄 - getJoinedYear(){ - this.formData.joinedYear = this.getYearsByDate(this.formData.joinedDate); + getJoinedYear() { + this.formData.joinedYear = this.getYearsByDate(this.formData.joinedDate) }, // 计算输入日期至今隔了多少年 getYearsByDate(date) { @@ -315,7 +340,7 @@ export default { years-- } return years >= 0 ? years : '0' - }, + } } } diff --git a/src/views/company/staff/index.vue b/src/views/company/staff/index.vue index 6f044d7..c88fda8 100644 --- a/src/views/company/staff/index.vue +++ b/src/views/company/staff/index.vue @@ -21,8 +21,31 @@ /> - - + + + + + + + + + + @@ -30,9 +53,6 @@ - - - +