Commit 702baeaeafbb5ad32b2a9f92b49d47a8b799bdcb
1 parent
8edcdb99
v1.9 优化员工没有岗位问题
Showing
6 changed files
with
69 additions
and
63 deletions
src/components/staff/editStaff.vue
| 1 | 1 | <!-- components/staff/editStaff.vue --> |
| 2 | 2 | <template> |
| 3 | - <el-dialog | |
| 4 | - :title="$t('staff.modifyStaff')" | |
| 5 | - :visible.sync="visible" | |
| 6 | - width="50%" | |
| 7 | - @close="handleClose" | |
| 8 | - > | |
| 3 | + <el-dialog :title="$t('staff.modifyStaff')" :visible.sync="visible" width="50%" @close="handleClose"> | |
| 9 | 4 | <el-form ref="form" :model="editStaffInfo" label-width="120px"> |
| 10 | 5 | <el-row :gutter="20"> |
| 11 | 6 | <el-col :span="12"> |
| 12 | 7 | <el-form-item :label="$t('staff.name')" prop="username"> |
| 13 | - <el-input | |
| 14 | - v-model="editStaffInfo.username" | |
| 15 | - :placeholder="$t('staff.requiredName')" | |
| 16 | - /> | |
| 8 | + <el-input v-model="editStaffInfo.username" :placeholder="$t('staff.requiredName')" /> | |
| 17 | 9 | </el-form-item> |
| 18 | 10 | <el-form-item :label="$t('email')" prop="email"> |
| 19 | - <el-input | |
| 20 | - v-model="editStaffInfo.email" | |
| 21 | - :placeholder="$t('staff.optionalEmail')" | |
| 22 | - /> | |
| 11 | + <el-input v-model="editStaffInfo.email" :placeholder="$t('staff.optionalEmail')" /> | |
| 23 | 12 | </el-form-item> |
| 24 | 13 | <el-form-item :label="$t('staff.phone')" prop="tel"> |
| 25 | - <el-input | |
| 26 | - v-model="editStaffInfo.tel" | |
| 27 | - :placeholder="$t('staff.requiredPhone')" | |
| 28 | - /> | |
| 14 | + <el-input v-model="editStaffInfo.tel" :placeholder="$t('staff.requiredPhone')" /> | |
| 29 | 15 | </el-form-item> |
| 30 | 16 | <el-form-item :label="$t('staff.gender')" prop="sex"> |
| 31 | - <el-select | |
| 32 | - v-model="editStaffInfo.sex" | |
| 33 | - :placeholder="$t('staff.requiredGender')" | |
| 34 | - style="width: 100%" | |
| 35 | - > | |
| 36 | - <el-option :value="0" :label="$t('staff.male')" /> | |
| 37 | - <el-option :value="1" :label="$t('staff.female')" /> | |
| 17 | + <el-select v-model="editStaffInfo.sex" :placeholder="$t('staff.requiredGender')" style="width: 100%"> | |
| 18 | + <el-option value="0" :label="$t('staff.male')" /> | |
| 19 | + <el-option value="1" :label="$t('staff.female')" /> | |
| 20 | + </el-select> | |
| 21 | + </el-form-item> | |
| 22 | + <el-form-item :label="$t('staff.relCd')" prop="relCd"> | |
| 23 | + <el-select v-model="editStaffInfo.relCd" :placeholder="$t('staff.relCdPlaceholder')" style="width: 100%"> | |
| 24 | + <el-option v-for="(item,index) in editStaffInfo.relCds" :key="index" :label="item.name" | |
| 25 | + :value="item.statusCd" /> | |
| 38 | 26 | </el-select> |
| 39 | 27 | </el-form-item> |
| 40 | 28 | <el-form-item :label="$t('staff.address')" prop="address"> |
| 41 | - <el-input | |
| 42 | - v-model="editStaffInfo.address" | |
| 43 | - :placeholder="$t('staff.requiredAddress')" | |
| 44 | - /> | |
| 29 | + <el-input v-model="editStaffInfo.address" :placeholder="$t('staff.requiredAddress')" /> | |
| 45 | 30 | </el-form-item> |
| 46 | 31 | </el-col> |
| 47 | 32 | <el-col :span="12" style="text-align: center"> |
| 48 | - <el-image | |
| 49 | - style="width: 200px; height: 200px" | |
| 50 | - :src="editStaffInfo.photoUrl" | |
| 51 | - fit="cover" | |
| 52 | - > | |
| 33 | + <el-image style="width: 200px; height: 200px" :src="editStaffInfo.photoUrl" fit="cover"> | |
| 53 | 34 | <div slot="error" class="image-slot"> |
| 54 | 35 | <i class="el-icon-picture-outline"></i> |
| 55 | 36 | </div> |
| 56 | 37 | </el-image> |
| 57 | 38 | <div style="margin-top: 20px"> |
| 58 | - <el-upload | |
| 59 | - action="" | |
| 60 | - :auto-upload="false" | |
| 61 | - :show-file-list="false" | |
| 62 | - :on-change="handlePhotoChange" | |
| 63 | - > | |
| 39 | + <el-upload action="" :auto-upload="false" :show-file-list="false" :on-change="handlePhotoChange"> | |
| 64 | 40 | <el-button type="primary">{{ $t('staff.uploadPhoto') }}</el-button> |
| 65 | 41 | </el-upload> |
| 66 | 42 | </div> |
| ... | ... | @@ -76,14 +52,11 @@ |
| 76 | 52 | |
| 77 | 53 | <script> |
| 78 | 54 | import { modifyStaff } from '@/api/staff/staffApi' |
| 55 | +import { getDict } from '../../api/community/communityApi' | |
| 79 | 56 | |
| 80 | 57 | export default { |
| 81 | 58 | name: 'EditStaff', |
| 82 | 59 | props: { |
| 83 | - visible: { | |
| 84 | - type: Boolean, | |
| 85 | - default: false | |
| 86 | - }, | |
| 87 | 60 | staffInfo: { |
| 88 | 61 | type: Object, |
| 89 | 62 | default: () => ({}) |
| ... | ... | @@ -91,6 +64,7 @@ export default { |
| 91 | 64 | }, |
| 92 | 65 | data() { |
| 93 | 66 | return { |
| 67 | + visible: false, | |
| 94 | 68 | loading: false, |
| 95 | 69 | editStaffInfo: { |
| 96 | 70 | userId: '', |
| ... | ... | @@ -128,23 +102,30 @@ export default { |
| 128 | 102 | } |
| 129 | 103 | }, |
| 130 | 104 | methods: { |
| 131 | - open(row){ | |
| 105 | + open(row) { | |
| 132 | 106 | this.editStaffInfo = { |
| 133 | - ...row, | |
| 134 | - username: row.name, | |
| 135 | - photoUrl: row.faceUrl || '/img/noPhoto.jpg' | |
| 136 | - } | |
| 107 | + ...row, | |
| 108 | + username: row.name, | |
| 109 | + photoUrl: row.faceUrl || '/img/noPhoto.jpg' | |
| 110 | + } | |
| 111 | + this.getRelCd() | |
| 137 | 112 | this.visible = true |
| 113 | + | |
| 114 | + }, | |
| 115 | + async getRelCd() { | |
| 116 | + const data = await getDict('u_org_staff_rel', "rel_cd") | |
| 117 | + this.editStaffInfo.relCds = data | |
| 118 | + this.$forceUpdate() | |
| 138 | 119 | }, |
| 139 | 120 | handleClose() { |
| 140 | - this.$emit('update:visible', false) | |
| 121 | + this.visible = false | |
| 141 | 122 | }, |
| 142 | 123 | handlePhotoChange(file) { |
| 143 | 124 | if (file.size > 2 * 1024 * 1024) { |
| 144 | 125 | this.$message.error(this.$t('staff.photoSizeLimit')) |
| 145 | 126 | return false |
| 146 | 127 | } |
| 147 | - | |
| 128 | + | |
| 148 | 129 | const reader = new FileReader() |
| 149 | 130 | reader.onload = (e) => { |
| 150 | 131 | this.editStaffInfo.photoUrl = e.target.result |
| ... | ... | @@ -175,7 +156,7 @@ export default { |
| 175 | 156 | }, |
| 176 | 157 | async editStaffSubmit() { |
| 177 | 158 | if (!this.validateForm()) return |
| 178 | - | |
| 159 | + | |
| 179 | 160 | try { |
| 180 | 161 | this.loading = true |
| 181 | 162 | const data = { |
| ... | ... | @@ -183,10 +164,10 @@ export default { |
| 183 | 164 | name: this.editStaffInfo.username, |
| 184 | 165 | staffId: this.editStaffInfo.userId |
| 185 | 166 | } |
| 186 | - | |
| 167 | + | |
| 187 | 168 | await modifyStaff(data) |
| 188 | - this.visible =false | |
| 189 | - this.$message.success(this.$t('staff.modifySuccess')) | |
| 169 | + this.visible = false | |
| 170 | + this.$message.success(this.$t('common.submitSuccess')) | |
| 190 | 171 | this.$emit('success') |
| 191 | 172 | this.handleClose() |
| 192 | 173 | } catch (error) { | ... | ... |
src/i18n/commonLang.js
| ... | ... | @@ -64,7 +64,8 @@ export const messages = { |
| 64 | 64 | hide:'Hide', |
| 65 | 65 | viewDetail:'View Detail', |
| 66 | 66 | yuan:'yuan', |
| 67 | - process:'Process' | |
| 67 | + process:'Process', | |
| 68 | + | |
| 68 | 69 | } |
| 69 | 70 | }, |
| 70 | 71 | zh: { |
| ... | ... | @@ -132,7 +133,8 @@ export const messages = { |
| 132 | 133 | hide:'隐藏', |
| 133 | 134 | viewDetail:'查看详情', |
| 134 | 135 | yuan:'元', |
| 135 | - process:'处理' | |
| 136 | + process:'处理', | |
| 137 | + | |
| 136 | 138 | } |
| 137 | 139 | } |
| 138 | 140 | } |
| 139 | 141 | \ No newline at end of file | ... | ... |
src/views/staff/addStaff.vue
| ... | ... | @@ -19,6 +19,12 @@ |
| 19 | 19 | <el-option :label="$t('addStaff.female')" value="1" /> |
| 20 | 20 | </el-select> |
| 21 | 21 | </el-form-item> |
| 22 | + <el-form-item :label="$t('addStaff.relCd')"> | |
| 23 | + <el-select v-model="addStaffInfo.relCd" :placeholder="$t('addStaff.relCdPlaceholder')" | |
| 24 | + style="width: 100%"> | |
| 25 | + <el-option v-for="item in addStaffInfo.relCds" :key="item.value" :label="item.name" :value="item.statusCd" /> | |
| 26 | + </el-select> | |
| 27 | + </el-form-item> | |
| 22 | 28 | <el-form-item :label="$t('addStaff.phone')"> |
| 23 | 29 | <el-input v-model="addStaffInfo.tel" :placeholder="$t('addStaff.phonePlaceholder')" maxlength="11" /> |
| 24 | 30 | </el-form-item> |
| ... | ... | @@ -59,6 +65,7 @@ |
| 59 | 65 | import { addStaff } from '@/api/staff/addStaffApi' |
| 60 | 66 | import UploadImageUrl from '@/components/upload/UploadImageUrl' |
| 61 | 67 | import ChooseOrgTree from '@/components/org/ChooseOrgTree' |
| 68 | +import {getDict} from '@/api/community/communityApi' | |
| 62 | 69 | |
| 63 | 70 | export default { |
| 64 | 71 | name: 'AddStaff', |
| ... | ... | @@ -78,11 +85,19 @@ export default { |
| 78 | 85 | tel: '', |
| 79 | 86 | address: '', |
| 80 | 87 | photo: '', |
| 81 | - adminFlag: 'N' | |
| 88 | + adminFlag: 'N', | |
| 89 | + relCds:[] | |
| 82 | 90 | } |
| 83 | 91 | } |
| 84 | 92 | }, |
| 93 | + mounted() { | |
| 94 | + this.getRelCd() | |
| 95 | + }, | |
| 85 | 96 | methods: { |
| 97 | + async getRelCd() { | |
| 98 | + const data = await getDict('u_org_staff_rel', "rel_cd") | |
| 99 | + this.addStaffInfo.relCds = data | |
| 100 | + }, | |
| 86 | 101 | handleUploadImage(data) { |
| 87 | 102 | if (data.length > 0) { |
| 88 | 103 | this.addStaffInfo.photo = data[0].fileId | ... | ... |
src/views/staff/addStaffLang.js
| ... | ... | @@ -23,7 +23,9 @@ export const messages = { |
| 23 | 23 | save: 'Save', |
| 24 | 24 | cancel: 'Cancel', |
| 25 | 25 | chooseOrg: 'Choose Organization', |
| 26 | - confirm: 'Confirm' | |
| 26 | + confirm: 'Confirm', | |
| 27 | + relCd: 'Relationship', | |
| 28 | + relCdPlaceholder: 'Please select relationship' | |
| 27 | 29 | } |
| 28 | 30 | }, |
| 29 | 31 | zh: { |
| ... | ... | @@ -49,7 +51,9 @@ export const messages = { |
| 49 | 51 | save: '保存', |
| 50 | 52 | cancel: '取消', |
| 51 | 53 | chooseOrg: '选择组织', |
| 52 | - confirm: '确认' | |
| 54 | + confirm: '确认', | |
| 55 | + relCd: '岗位', | |
| 56 | + relCdPlaceholder: '请选择岗位' | |
| 53 | 57 | } |
| 54 | 58 | } |
| 55 | 59 | } |
| 56 | 60 | \ No newline at end of file | ... | ... |
src/views/staff/staffLang.js
| ... | ... | @@ -40,7 +40,8 @@ export const messages = { |
| 40 | 40 | uploadPhoto: 'Upload Photo', |
| 41 | 41 | cancel: 'Cancel', |
| 42 | 42 | confirmDelete: 'Are you sure to delete? Before deleting staff, please confirm that the staff has completed the relevant approval process. After deletion, the relevant process will not be able to continue. Please operate carefully!', |
| 43 | - confirmDeleteAction: 'Confirm Delete' | |
| 43 | + confirmDeleteAction: 'Confirm Delete', | |
| 44 | + relCd: 'Relationship' | |
| 44 | 45 | }, |
| 45 | 46 | selectStaff: { |
| 46 | 47 | title: 'Select Staff', |
| ... | ... | @@ -91,7 +92,8 @@ export const messages = { |
| 91 | 92 | uploadPhoto: '上传照片', |
| 92 | 93 | cancel: '取消', |
| 93 | 94 | confirmDelete: '确认是否删除,删除员工前请确认员工已完成相关审批流程,删除后相关流程将无法继续进行,请慎重操作!', |
| 94 | - confirmDeleteAction: '确认删除' | |
| 95 | + confirmDeleteAction: '确认删除', | |
| 96 | + relCd: '岗位' | |
| 95 | 97 | }, |
| 96 | 98 | selectStaff: { |
| 97 | 99 | title: '选择员工', | ... | ... |
src/views/staff/staffList.vue
| ... | ... | @@ -49,6 +49,7 @@ |
| 49 | 49 | <el-table-column prop="orgName" :label="$t('staff.relatedOrg')" align="center" /> |
| 50 | 50 | <el-table-column prop="email" :label="$t('staff.email')" align="center" /> |
| 51 | 51 | <el-table-column prop="address" :label="$t('staff.address')" align="center" /> |
| 52 | + <el-table-column prop="relCdName" :label="$t('staff.relCd')" align="center" /> | |
| 52 | 53 | <el-table-column prop="sex" :label="$t('staff.gender')" align="center"> |
| 53 | 54 | <template slot-scope="scope"> |
| 54 | 55 | {{ scope.row.sex == 0 ? $t('staff.male') : $t('staff.female') }} |
| ... | ... | @@ -84,7 +85,7 @@ |
| 84 | 85 | |
| 85 | 86 | <reset-staff-pwd :visible.sync="resetPwdVisible" :staff-info="currentStaff" @success="handleSuccess" /> |
| 86 | 87 | |
| 87 | - <edit-staff :visible.sync="editStaffVisible" :staff-info="currentStaff" @success="handleSuccess" /> | |
| 88 | + <edit-staff ref="editStaff" :staff-info="currentStaff" @success="handleSuccess" /> | |
| 88 | 89 | |
| 89 | 90 | <delete-staff :visible.sync="deleteStaffVisible" :staff-info="currentStaff" @success="handleSuccess" /> |
| 90 | 91 | </div> |
| ... | ... | @@ -181,6 +182,7 @@ export default { |
| 181 | 182 | openEditStaff(staff) { |
| 182 | 183 | this.currentStaff = { ...staff } |
| 183 | 184 | this.editStaffVisible = true |
| 185 | + this.$refs.editStaff.open(staff) | |
| 184 | 186 | }, |
| 185 | 187 | openDeleteStaff(staff) { |
| 186 | 188 | this.currentStaff = { ...staff } | ... | ... |