a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
1
2
|
<!-- components/staff/editStaff.vue -->
<template>
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
3
|
<el-dialog :title="$t('staff.modifyStaff')" :visible.sync="visible" width="50%" @close="handleClose">
|
ebc1053d
wuxw
加入运营员工详情功能
|
4
5
6
7
|
<el-form ref="form" :model="editStaffInfo" label-width="120px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item :label="$t('staff.name')" prop="username">
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
8
|
<el-input v-model="editStaffInfo.username" :placeholder="$t('staff.requiredName')" />
|
ebc1053d
wuxw
加入运营员工详情功能
|
9
10
|
</el-form-item>
<el-form-item :label="$t('email')" prop="email">
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
11
|
<el-input v-model="editStaffInfo.email" :placeholder="$t('staff.optionalEmail')" />
|
ebc1053d
wuxw
加入运营员工详情功能
|
12
13
|
</el-form-item>
<el-form-item :label="$t('staff.phone')" prop="tel">
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
14
|
<el-input v-model="editStaffInfo.tel" :placeholder="$t('staff.requiredPhone')" />
|
ebc1053d
wuxw
加入运营员工详情功能
|
15
16
|
</el-form-item>
<el-form-item :label="$t('staff.gender')" prop="sex">
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
17
18
19
20
21
22
23
24
25
|
<el-select v-model="editStaffInfo.sex" :placeholder="$t('staff.requiredGender')" style="width: 100%">
<el-option value="0" :label="$t('staff.male')" />
<el-option value="1" :label="$t('staff.female')" />
</el-select>
</el-form-item>
<el-form-item :label="$t('staff.relCd')" prop="relCd">
<el-select v-model="editStaffInfo.relCd" :placeholder="$t('staff.relCdPlaceholder')" style="width: 100%">
<el-option v-for="(item,index) in editStaffInfo.relCds" :key="index" :label="item.name"
:value="item.statusCd" />
|
ebc1053d
wuxw
加入运营员工详情功能
|
26
27
28
|
</el-select>
</el-form-item>
<el-form-item :label="$t('staff.address')" prop="address">
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
29
|
<el-input v-model="editStaffInfo.address" :placeholder="$t('staff.requiredAddress')" />
|
ebc1053d
wuxw
加入运营员工详情功能
|
30
31
32
|
</el-form-item>
</el-col>
<el-col :span="12" style="text-align: center">
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
33
|
<el-image style="width: 200px; height: 200px" :src="editStaffInfo.photoUrl" fit="cover">
|
ebc1053d
wuxw
加入运营员工详情功能
|
34
35
|
<div slot="error" class="image-slot">
<i class="el-icon-picture-outline"></i>
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
36
|
</div>
|
ebc1053d
wuxw
加入运营员工详情功能
|
37
38
|
</el-image>
<div style="margin-top: 20px">
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
39
|
<el-upload action="" :auto-upload="false" :show-file-list="false" :on-change="handlePhotoChange">
|
ebc1053d
wuxw
加入运营员工详情功能
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<el-button type="primary">{{ $t('staff.uploadPhoto') }}</el-button>
</el-upload>
</div>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">{{ $t('staff.cancel') }}</el-button>
<el-button type="primary" @click="editStaffSubmit">{{ $t('staff.edit') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { modifyStaff } from '@/api/staff/staffApi'
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
55
|
import { getDict } from '../../api/community/communityApi'
|
ebc1053d
wuxw
加入运营员工详情功能
|
56
57
58
59
|
export default {
name: 'EditStaff',
props: {
|
ebc1053d
wuxw
加入运营员工详情功能
|
60
61
62
63
64
65
66
|
staffInfo: {
type: Object,
default: () => ({})
}
},
data() {
return {
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
67
|
visible: false,
|
ebc1053d
wuxw
加入运营员工详情功能
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
loading: false,
editStaffInfo: {
userId: '',
username: '',
email: '',
tel: '',
sex: '',
address: '',
photo: '',
photoUrl: '',
relCd: '',
relCds: [],
branchOrgs: [],
departmentOrgs: [],
parentOrgId: '',
parentOrgName: '',
parentTwoOrgId: '',
orgNewName: '',
orgId: ''
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
87
|
}
|
ebc1053d
wuxw
加入运营员工详情功能
|
88
89
90
91
92
93
94
95
96
97
98
|
}
},
watch: {
staffInfo: {
immediate: true,
handler(val) {
if (val) {
this.editStaffInfo = {
...val,
username: val.name,
photoUrl: val.faceUrl || '/img/noPhoto.jpg'
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
99
100
101
|
}
}
}
|
ebc1053d
wuxw
加入运营员工详情功能
|
102
103
104
|
}
},
methods: {
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
105
|
open(row) {
|
ebc1053d
wuxw
加入运营员工详情功能
|
106
|
this.editStaffInfo = {
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
107
108
109
110
111
|
...row,
username: row.name,
photoUrl: row.faceUrl || '/img/noPhoto.jpg'
}
this.getRelCd()
|
ebc1053d
wuxw
加入运营员工详情功能
|
112
|
this.visible = true
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
113
114
115
116
117
118
|
},
async getRelCd() {
const data = await getDict('u_org_staff_rel', "rel_cd")
this.editStaffInfo.relCds = data
this.$forceUpdate()
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
119
|
},
|
ebc1053d
wuxw
加入运营员工详情功能
|
120
|
handleClose() {
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
121
|
this.visible = false
|
ebc1053d
wuxw
加入运营员工详情功能
|
122
123
124
125
126
127
|
},
handlePhotoChange(file) {
if (file.size > 2 * 1024 * 1024) {
this.$message.error(this.$t('staff.photoSizeLimit'))
return false
}
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
128
|
|
ebc1053d
wuxw
加入运营员工详情功能
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
const reader = new FileReader()
reader.onload = (e) => {
this.editStaffInfo.photoUrl = e.target.result
// Here you would typically upload the file to server
// and set editStaffInfo.photo to the returned file ID
this.editStaffInfo.photo = file.uid // Temporary, replace with actual file ID
}
reader.readAsDataURL(file.raw)
},
validateForm() {
if (!this.editStaffInfo.username) {
this.$message.error(this.$t('staff.requiredName'))
return false
}
if (!this.editStaffInfo.tel) {
this.$message.error(this.$t('staff.requiredPhone'))
return false
}
if (this.editStaffInfo.sex === '') {
this.$message.error(this.$t('staff.requiredGender'))
return false
}
if (!this.editStaffInfo.address) {
this.$message.error(this.$t('staff.requiredAddress'))
return false
}
return true
},
async editStaffSubmit() {
if (!this.validateForm()) return
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
159
|
|
ebc1053d
wuxw
加入运营员工详情功能
|
160
161
162
163
164
165
|
try {
this.loading = true
const data = {
...this.editStaffInfo,
name: this.editStaffInfo.username,
staffId: this.editStaffInfo.userId
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
166
|
}
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
167
|
|
ebc1053d
wuxw
加入运营员工详情功能
|
168
|
await modifyStaff(data)
|
702baeae
wuxw
v1.9 优化员工没有岗位问题
|
169
170
|
this.visible = false
this.$message.success(this.$t('common.submitSuccess'))
|
ebc1053d
wuxw
加入运营员工详情功能
|
171
172
173
174
175
176
|
this.$emit('success')
this.handleClose()
} catch (error) {
this.$message.error(error.message)
} finally {
this.loading = false
|
a42b3256
wuxw
HC小区管理系统前段vue版正在开发中
|
177
178
179
|
}
}
}
|
ebc1053d
wuxw
加入运营员工详情功能
|
180
181
|
}
</script>
|