|
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="app-container">
|
|
|
3
|
+ <!-- 检索区 -->
|
|
|
4
|
+ <el-card shadow="never" class="search-card">
|
|
|
5
|
+ <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
|
|
|
6
|
+ <el-form-item label="员工名称" prop="employeeName">
|
|
|
7
|
+ <el-input v-model="queryParams.employeeName" placeholder="模糊检索" clearable style="width: 220px" @keyup.enter.native="handleQuery" />
|
|
|
8
|
+ </el-form-item>
|
|
|
9
|
+ <el-form-item>
|
|
|
10
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
11
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
12
|
+ </el-form-item>
|
|
|
13
|
+ </el-form>
|
|
|
14
|
+ </el-card>
|
|
|
15
|
+
|
|
|
16
|
+ <br/>
|
|
|
17
|
+
|
|
|
18
|
+ <!-- 列表区 -->
|
|
|
19
|
+ <el-card shadow="never" class="table-card">
|
|
|
20
|
+ <div slot="header" class="card-header">
|
|
|
21
|
+ <span>员工列表</span>
|
|
|
22
|
+ <span class="header-tip">当前店铺:{{ quota.shopName || currentShopName || '—' }}</span>
|
|
|
23
|
+ <span class="header-tip" v-if="quota.merchantName">商户:{{ quota.merchantName }}</span>
|
|
|
24
|
+ <span class="quota-tip">员工 {{ quota.usedCount != null ? quota.usedCount : '—' }}/{{ quota.maxCount != null ? quota.maxCount : '—' }}</span>
|
|
|
25
|
+ <el-select
|
|
|
26
|
+ v-if="shopSwitchable && shopOptions.length > 1"
|
|
|
27
|
+ v-model="currentShopId"
|
|
|
28
|
+ size="small"
|
|
|
29
|
+ placeholder="切换店铺"
|
|
|
30
|
+ style="width: 200px; margin-left: 12px"
|
|
|
31
|
+ @change="handleShopSwitch"
|
|
|
32
|
+ >
|
|
|
33
|
+ <el-option
|
|
|
34
|
+ v-for="item in shopOptions"
|
|
|
35
|
+ :key="item.shopId"
|
|
|
36
|
+ :label="item.shopName"
|
|
|
37
|
+ :value="item.shopId"
|
|
|
38
|
+ />
|
|
|
39
|
+ </el-select>
|
|
|
40
|
+ </div>
|
|
|
41
|
+
|
|
|
42
|
+ <el-row :gutter="10" class="mb8">
|
|
|
43
|
+ <el-col :span="1.5">
|
|
|
44
|
+ <el-button
|
|
|
45
|
+ type="primary"
|
|
|
46
|
+ plain
|
|
|
47
|
+ icon="el-icon-plus"
|
|
|
48
|
+ size="mini"
|
|
|
49
|
+ :disabled="quotaFull"
|
|
|
50
|
+ @click="handleAdd"
|
|
|
51
|
+ v-hasPermi="['agri:seller:employee:add']"
|
|
|
52
|
+ >创建员工</el-button>
|
|
|
53
|
+ </el-col>
|
|
|
54
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="refreshPage"></right-toolbar>
|
|
|
55
|
+ </el-row>
|
|
|
56
|
+
|
|
|
57
|
+ <el-alert v-if="quotaFull" title="子管理员人数已达上限,无法新建或启用员工,请联系平台调整店铺设置" type="warning" :closable="false" show-icon class="mb12" />
|
|
|
58
|
+
|
|
|
59
|
+ <el-table border v-loading="loading" :data="employeeList">
|
|
|
60
|
+ <el-table-column label="员工账号" align="center" prop="loginAccount" min-width="120" :show-overflow-tooltip="true" />
|
|
|
61
|
+ <el-table-column label="员工名称" align="center" prop="employeeName" min-width="110" :show-overflow-tooltip="true" />
|
|
|
62
|
+ <el-table-column label="手机号" align="center" prop="mobile" width="120" />
|
|
|
63
|
+ <el-table-column label="邮箱" align="center" prop="email" min-width="140" :show-overflow-tooltip="true">
|
|
|
64
|
+ <template slot-scope="scope">
|
|
|
65
|
+ <span>{{ scope.row.email || '—' }}</span>
|
|
|
66
|
+ </template>
|
|
|
67
|
+ </el-table-column>
|
|
|
68
|
+ <el-table-column label="状态" align="center" prop="status" width="90">
|
|
|
69
|
+ <template slot-scope="scope">
|
|
|
70
|
+ <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status" />
|
|
|
71
|
+ </template>
|
|
|
72
|
+ </el-table-column>
|
|
|
73
|
+ <el-table-column label="操作" align="center" width="280" fixed="right">
|
|
|
74
|
+ <template slot-scope="scope">
|
|
|
75
|
+ <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['agri:seller:employee:edit']">编辑</el-button>
|
|
|
76
|
+ <el-button size="mini" type="text" icon="el-icon-user" @click="handleEditProfile(scope.row)" v-hasPermi="['agri:seller:employee:edit']">修改账号</el-button>
|
|
|
77
|
+ <el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['agri:seller:employee:resetPwd']">修改密码</el-button>
|
|
|
78
|
+ <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['agri:seller:employee:remove']">删除</el-button>
|
|
|
79
|
+ </template>
|
|
|
80
|
+ </el-table-column>
|
|
|
81
|
+ </el-table>
|
|
|
82
|
+
|
|
|
83
|
+ <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
|
|
84
|
+ </el-card>
|
|
|
85
|
+
|
|
|
86
|
+ <!-- 创建/编辑员工弹窗 -->
|
|
|
87
|
+ <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body @close="cancelForm">
|
|
|
88
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
89
|
+ <el-form-item label="员工名称" prop="employeeName">
|
|
|
90
|
+ <el-input v-model="form.employeeName" placeholder="请输入员工名称" maxlength="30" />
|
|
|
91
|
+ </el-form-item>
|
|
|
92
|
+ <el-form-item label="手机号" prop="mobile">
|
|
|
93
|
+ <el-input v-model="form.mobile" placeholder="11位手机号,即登录账号" maxlength="11" :disabled="form.userId != null" />
|
|
|
94
|
+ </el-form-item>
|
|
|
95
|
+ <el-form-item v-if="form.userId == null" label="登录说明">
|
|
|
96
|
+ <span class="form-tip">手机号将作为员工登录账号;创建后须「修改密码」方可登录</span>
|
|
|
97
|
+ </el-form-item>
|
|
|
98
|
+ <el-form-item label="邮箱" prop="email">
|
|
|
99
|
+ <el-input v-model="form.email" placeholder="选填" maxlength="50" />
|
|
|
100
|
+ </el-form-item>
|
|
|
101
|
+ <el-form-item label="头像" prop="avatar">
|
|
|
102
|
+ <image-upload v-model="form.avatar" :limit="1" :file-size="5" :file-type="['png', 'jpg', 'jpeg']" />
|
|
|
103
|
+ </el-form-item>
|
|
|
104
|
+ <el-form-item label="状态" prop="status">
|
|
|
105
|
+ <el-radio-group v-model="form.status">
|
|
|
106
|
+ <el-radio
|
|
|
107
|
+ v-for="dict in dict.type.sys_normal_disable"
|
|
|
108
|
+ :key="dict.value"
|
|
|
109
|
+ :label="dict.value"
|
|
|
110
|
+ >{{ dict.label }}</el-radio>
|
|
|
111
|
+ </el-radio-group>
|
|
|
112
|
+ </el-form-item>
|
|
|
113
|
+ <el-form-item label="绑定角色" prop="roleIds">
|
|
|
114
|
+ <el-select v-model="form.roleIds" multiple placeholder="请至少选择一个角色" style="width: 100%">
|
|
|
115
|
+ <el-option
|
|
|
116
|
+ v-for="item in roleOptions"
|
|
|
117
|
+ :key="item.roleId"
|
|
|
118
|
+ :label="item.roleName"
|
|
|
119
|
+ :value="item.roleId"
|
|
|
120
|
+ />
|
|
|
121
|
+ </el-select>
|
|
|
122
|
+ </el-form-item>
|
|
|
123
|
+ </el-form>
|
|
|
124
|
+ <div slot="footer" class="dialog-footer">
|
|
|
125
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
126
|
+ <el-button @click="cancelForm">取 消</el-button>
|
|
|
127
|
+ </div>
|
|
|
128
|
+ </el-dialog>
|
|
|
129
|
+
|
|
|
130
|
+ <!-- 修改账号弹窗 -->
|
|
|
131
|
+ <el-dialog title="修改账号" :visible.sync="profileOpen" width="520px" append-to-body @close="cancelProfile">
|
|
|
132
|
+ <el-form ref="profileForm" :model="profileForm" :rules="profileRules" label-width="100px">
|
|
|
133
|
+ <el-form-item label="员工名称" prop="employeeName">
|
|
|
134
|
+ <el-input v-model="profileForm.employeeName" placeholder="请输入员工名称" maxlength="30" />
|
|
|
135
|
+ </el-form-item>
|
|
|
136
|
+ <el-form-item label="手机号" prop="mobile">
|
|
|
137
|
+ <el-input v-model="profileForm.mobile" placeholder="11位手机号" maxlength="11" />
|
|
|
138
|
+ </el-form-item>
|
|
|
139
|
+ <el-form-item label="邮箱" prop="email">
|
|
|
140
|
+ <el-input v-model="profileForm.email" placeholder="选填" maxlength="50" />
|
|
|
141
|
+ </el-form-item>
|
|
|
142
|
+ </el-form>
|
|
|
143
|
+ <div slot="footer" class="dialog-footer">
|
|
|
144
|
+ <el-button type="primary" @click="submitProfile">确 定</el-button>
|
|
|
145
|
+ <el-button @click="cancelProfile">取 消</el-button>
|
|
|
146
|
+ </div>
|
|
|
147
|
+ </el-dialog>
|
|
|
148
|
+
|
|
|
149
|
+ <!-- 修改密码弹窗 -->
|
|
|
150
|
+ <el-dialog title="修改密码" :visible.sync="pwdOpen" width="520px" append-to-body @close="cancelPwd">
|
|
|
151
|
+ <el-form ref="pwdForm" :model="pwdForm" :rules="pwdRules" label-width="100px">
|
|
|
152
|
+ <el-form-item label="员工名称">
|
|
|
153
|
+ <span class="readonly-text">{{ pwdForm.employeeName || '—' }}</span>
|
|
|
154
|
+ </el-form-item>
|
|
|
155
|
+ <el-form-item label="新密码" prop="password">
|
|
|
156
|
+ <el-input v-model="pwdForm.password" placeholder="请输入新密码" type="password" maxlength="20" show-password />
|
|
|
157
|
+ </el-form-item>
|
|
|
158
|
+ <el-form-item label="确认新密码" prop="confirmPassword">
|
|
|
159
|
+ <el-input v-model="pwdForm.confirmPassword" placeholder="请再次输入新密码" type="password" maxlength="20" show-password />
|
|
|
160
|
+ </el-form-item>
|
|
|
161
|
+ </el-form>
|
|
|
162
|
+ <div slot="footer" class="dialog-footer">
|
|
|
163
|
+ <el-button type="primary" @click="submitPwd">确 定</el-button>
|
|
|
164
|
+ <el-button @click="cancelPwd">取 消</el-button>
|
|
|
165
|
+ </div>
|
|
|
166
|
+ </el-dialog>
|
|
|
167
|
+ </div>
|
|
|
168
|
+</template>
|
|
|
169
|
+
|
|
|
170
|
+<script>
|
|
|
171
|
+import {
|
|
|
172
|
+ listSellerEmployee,
|
|
|
173
|
+ sellerEmployeeQuota,
|
|
|
174
|
+ sellerEmployeeRoleOptions,
|
|
|
175
|
+ getSellerEmployee,
|
|
|
176
|
+ addSellerEmployee,
|
|
|
177
|
+ updateSellerEmployee,
|
|
|
178
|
+ updateSellerEmployeeProfile,
|
|
|
179
|
+ resetSellerEmployeePassword,
|
|
|
180
|
+ delSellerEmployee
|
|
|
181
|
+} from "@/api/agri/seller/employee"
|
|
|
182
|
+import { getSellerContext, switchSellerShop } from "@/api/agri/seller/context"
|
|
|
183
|
+import { setSellerShopContext } from "@/utils/sellerShop"
|
|
|
184
|
+import passwordRule from "@/utils/passwordRule"
|
|
|
185
|
+
|
|
|
186
|
+export default {
|
|
|
187
|
+ name: "AgriSellerEmployee",
|
|
|
188
|
+ dicts: ['sys_normal_disable'],
|
|
|
189
|
+ mixins: [passwordRule],
|
|
|
190
|
+ data() {
|
|
|
191
|
+ const validateConfirmPassword = (rule, value, callback) => {
|
|
|
192
|
+ if (!value) {
|
|
|
193
|
+ callback(new Error("请再次输入新密码"))
|
|
|
194
|
+ return
|
|
|
195
|
+ }
|
|
|
196
|
+ if (value !== this.pwdForm.password) {
|
|
|
197
|
+ callback(new Error("两次输入的密码不一致"))
|
|
|
198
|
+ return
|
|
|
199
|
+ }
|
|
|
200
|
+ callback()
|
|
|
201
|
+ }
|
|
|
202
|
+ const validateRoleIds = (rule, value, callback) => {
|
|
|
203
|
+ if (!value || !value.length) {
|
|
|
204
|
+ callback(new Error("请至少选择一个角色"))
|
|
|
205
|
+ return
|
|
|
206
|
+ }
|
|
|
207
|
+ callback()
|
|
|
208
|
+ }
|
|
|
209
|
+ return {
|
|
|
210
|
+ loading: true,
|
|
|
211
|
+ showSearch: true,
|
|
|
212
|
+ total: 0,
|
|
|
213
|
+ employeeList: [],
|
|
|
214
|
+ title: "",
|
|
|
215
|
+ open: false,
|
|
|
216
|
+ profileOpen: false,
|
|
|
217
|
+ pwdOpen: false,
|
|
|
218
|
+ currentShopName: "",
|
|
|
219
|
+ currentShopId: undefined,
|
|
|
220
|
+ shopSwitchable: false,
|
|
|
221
|
+ shopOptions: [],
|
|
|
222
|
+ quota: {},
|
|
|
223
|
+ roleOptions: [],
|
|
|
224
|
+ queryParams: {
|
|
|
225
|
+ pageNum: 1,
|
|
|
226
|
+ pageSize: 10,
|
|
|
227
|
+ employeeName: undefined
|
|
|
228
|
+ },
|
|
|
229
|
+ form: {},
|
|
|
230
|
+ profileForm: {},
|
|
|
231
|
+ pwdForm: {},
|
|
|
232
|
+ rules: {
|
|
|
233
|
+ employeeName: [
|
|
|
234
|
+ { required: true, message: "员工名称不能为空", trigger: "blur" }
|
|
|
235
|
+ ],
|
|
|
236
|
+ mobile: [
|
|
|
237
|
+ { required: true, message: "手机号不能为空", trigger: "blur" },
|
|
|
238
|
+ { pattern: /^1[3-9]\d{9}$/, message: "请输入正确的11位手机号", trigger: "blur" }
|
|
|
239
|
+ ],
|
|
|
240
|
+ email: [
|
|
|
241
|
+ { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }
|
|
|
242
|
+ ],
|
|
|
243
|
+ status: [
|
|
|
244
|
+ { required: true, message: "请选择状态", trigger: "change" }
|
|
|
245
|
+ ],
|
|
|
246
|
+ roleIds: [
|
|
|
247
|
+ { required: true, validator: validateRoleIds, trigger: "change" }
|
|
|
248
|
+ ]
|
|
|
249
|
+ },
|
|
|
250
|
+ profileRules: {
|
|
|
251
|
+ employeeName: [
|
|
|
252
|
+ { required: true, message: "员工名称不能为空", trigger: "blur" }
|
|
|
253
|
+ ],
|
|
|
254
|
+ mobile: [
|
|
|
255
|
+ { required: true, message: "手机号不能为空", trigger: "blur" },
|
|
|
256
|
+ { pattern: /^1[3-9]\d{9}$/, message: "请输入正确的11位手机号", trigger: "blur" }
|
|
|
257
|
+ ],
|
|
|
258
|
+ email: [
|
|
|
259
|
+ { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }
|
|
|
260
|
+ ]
|
|
|
261
|
+ },
|
|
|
262
|
+ pwdRules: {
|
|
|
263
|
+ password: [
|
|
|
264
|
+ { required: true, message: "新密码不能为空", trigger: "blur" },
|
|
|
265
|
+ { min: 6, max: 20, message: "密码长度必须介于 6 和 20 之间", trigger: "blur" }
|
|
|
266
|
+ ],
|
|
|
267
|
+ confirmPassword: [
|
|
|
268
|
+ { required: true, validator: validateConfirmPassword, trigger: "blur" }
|
|
|
269
|
+ ]
|
|
|
270
|
+ }
|
|
|
271
|
+ }
|
|
|
272
|
+ },
|
|
|
273
|
+ computed: {
|
|
|
274
|
+ /** 配额已满时禁用创建 */
|
|
|
275
|
+ quotaFull() {
|
|
|
276
|
+ if (this.quota.usedCount == null || this.quota.maxCount == null) {
|
|
|
277
|
+ return false
|
|
|
278
|
+ }
|
|
|
279
|
+ return this.quota.usedCount >= this.quota.maxCount
|
|
|
280
|
+ }
|
|
|
281
|
+ },
|
|
|
282
|
+ created() {
|
|
|
283
|
+ this.pwdRules.password = this.pwdValidator
|
|
|
284
|
+ this.initPage()
|
|
|
285
|
+ },
|
|
|
286
|
+ methods: {
|
|
|
287
|
+ /** 初始化页面 */
|
|
|
288
|
+ initPage() {
|
|
|
289
|
+ this.loadShopContext().then(() => {
|
|
|
290
|
+ this.refreshPage()
|
|
|
291
|
+ }).catch(() => {
|
|
|
292
|
+ this.refreshPage()
|
|
|
293
|
+ })
|
|
|
294
|
+ },
|
|
|
295
|
+ /** 加载店铺上下文 */
|
|
|
296
|
+ loadShopContext() {
|
|
|
297
|
+ return getSellerContext().then(response => {
|
|
|
298
|
+ const data = response.data || {}
|
|
|
299
|
+ if (data.shopId != null) {
|
|
|
300
|
+ setSellerShopContext(data.shopId, data.shopName)
|
|
|
301
|
+ this.currentShopId = data.shopId
|
|
|
302
|
+ this.currentShopName = data.shopName || ""
|
|
|
303
|
+ this.shopSwitchable = data.switchable === true
|
|
|
304
|
+ this.shopOptions = data.shops || []
|
|
|
305
|
+ }
|
|
|
306
|
+ })
|
|
|
307
|
+ },
|
|
|
308
|
+ /** 切换店铺 */
|
|
|
309
|
+ handleShopSwitch(shopId) {
|
|
|
310
|
+ switchSellerShop({ shopId: shopId }).then(response => {
|
|
|
311
|
+ const data = response.data || {}
|
|
|
312
|
+ setSellerShopContext(data.shopId, data.shopName)
|
|
|
313
|
+ this.currentShopId = data.shopId
|
|
|
314
|
+ this.currentShopName = data.shopName || ""
|
|
|
315
|
+ this.queryParams.pageNum = 1
|
|
|
316
|
+ this.refreshPage()
|
|
|
317
|
+ })
|
|
|
318
|
+ },
|
|
|
319
|
+ /** 刷新列表与配额 */
|
|
|
320
|
+ refreshPage() {
|
|
|
321
|
+ this.loadQuota()
|
|
|
322
|
+ this.loadRoleOptions()
|
|
|
323
|
+ this.getList()
|
|
|
324
|
+ },
|
|
|
325
|
+ /** 加载配额 */
|
|
|
326
|
+ loadQuota() {
|
|
|
327
|
+ sellerEmployeeQuota().then(response => {
|
|
|
328
|
+ this.quota = response.data || {}
|
|
|
329
|
+ }).catch(() => {
|
|
|
330
|
+ this.quota = {}
|
|
|
331
|
+ })
|
|
|
332
|
+ },
|
|
|
333
|
+ /** 加载当前店铺可选角色 */
|
|
|
334
|
+ loadRoleOptions() {
|
|
|
335
|
+ sellerEmployeeRoleOptions().then(response => {
|
|
|
336
|
+ this.roleOptions = response.data || []
|
|
|
337
|
+ }).catch(() => {
|
|
|
338
|
+ this.roleOptions = []
|
|
|
339
|
+ })
|
|
|
340
|
+ },
|
|
|
341
|
+ /** 查询员工列表 */
|
|
|
342
|
+ getList() {
|
|
|
343
|
+ this.loading = true
|
|
|
344
|
+ listSellerEmployee(this.queryParams).then(response => {
|
|
|
345
|
+ this.employeeList = response.rows || []
|
|
|
346
|
+ this.total = response.total || 0
|
|
|
347
|
+ this.loading = false
|
|
|
348
|
+ }).catch(() => {
|
|
|
349
|
+ this.loading = false
|
|
|
350
|
+ })
|
|
|
351
|
+ },
|
|
|
352
|
+ handleQuery() {
|
|
|
353
|
+ this.queryParams.pageNum = 1
|
|
|
354
|
+ this.getList()
|
|
|
355
|
+ },
|
|
|
356
|
+ resetQuery() {
|
|
|
357
|
+ this.resetForm("queryForm")
|
|
|
358
|
+ this.handleQuery()
|
|
|
359
|
+ },
|
|
|
360
|
+ resetFormData() {
|
|
|
361
|
+ this.form = {
|
|
|
362
|
+ userId: undefined,
|
|
|
363
|
+ employeeName: undefined,
|
|
|
364
|
+ mobile: undefined,
|
|
|
365
|
+ email: undefined,
|
|
|
366
|
+ avatar: undefined,
|
|
|
367
|
+ status: "0",
|
|
|
368
|
+ roleIds: []
|
|
|
369
|
+ }
|
|
|
370
|
+ this.resetForm("form")
|
|
|
371
|
+ },
|
|
|
372
|
+ /** 打开创建员工 */
|
|
|
373
|
+ handleAdd() {
|
|
|
374
|
+ if (this.quotaFull) {
|
|
|
375
|
+ this.$modal.msgWarning("子管理员人数已达上限")
|
|
|
376
|
+ return
|
|
|
377
|
+ }
|
|
|
378
|
+ this.resetFormData()
|
|
|
379
|
+ this.open = true
|
|
|
380
|
+ this.title = "创建员工"
|
|
|
381
|
+ },
|
|
|
382
|
+ /** 打开编辑员工 */
|
|
|
383
|
+ handleUpdate(row) {
|
|
|
384
|
+ this.resetFormData()
|
|
|
385
|
+ getSellerEmployee(row.userId).then(response => {
|
|
|
386
|
+ const data = response.data || {}
|
|
|
387
|
+ this.form = {
|
|
|
388
|
+ userId: data.userId,
|
|
|
389
|
+ employeeName: data.employeeName,
|
|
|
390
|
+ mobile: data.mobile,
|
|
|
391
|
+ email: data.email,
|
|
|
392
|
+ avatar: data.avatar,
|
|
|
393
|
+ status: data.status != null ? data.status : "0",
|
|
|
394
|
+ roleIds: data.roleIds ? [].concat(data.roleIds) : []
|
|
|
395
|
+ }
|
|
|
396
|
+ this.open = true
|
|
|
397
|
+ this.title = "编辑员工"
|
|
|
398
|
+ })
|
|
|
399
|
+ },
|
|
|
400
|
+ cancelForm() {
|
|
|
401
|
+ this.open = false
|
|
|
402
|
+ this.resetFormData()
|
|
|
403
|
+ },
|
|
|
404
|
+ /** 提交创建或编辑 */
|
|
|
405
|
+ submitForm() {
|
|
|
406
|
+ this.$refs["form"].validate(valid => {
|
|
|
407
|
+ if (!valid) {
|
|
|
408
|
+ return
|
|
|
409
|
+ }
|
|
|
410
|
+ const payload = {
|
|
|
411
|
+ employeeName: this.form.employeeName,
|
|
|
412
|
+ mobile: this.form.mobile,
|
|
|
413
|
+ email: this.form.email,
|
|
|
414
|
+ avatar: this.form.avatar,
|
|
|
415
|
+ status: this.form.status,
|
|
|
416
|
+ roleIds: this.form.roleIds
|
|
|
417
|
+ }
|
|
|
418
|
+ if (this.form.userId != null) {
|
|
|
419
|
+ payload.userId = this.form.userId
|
|
|
420
|
+ updateSellerEmployee(payload).then(() => {
|
|
|
421
|
+ this.$modal.msgSuccess("修改成功")
|
|
|
422
|
+ this.open = false
|
|
|
423
|
+ this.refreshPage()
|
|
|
424
|
+ })
|
|
|
425
|
+ } else {
|
|
|
426
|
+ addSellerEmployee(payload).then(response => {
|
|
|
427
|
+ this.$modal.msgSuccess("创建成功,请为该员工设置登录密码")
|
|
|
428
|
+ this.open = false
|
|
|
429
|
+ this.refreshPage()
|
|
|
430
|
+ const userId = response.userId
|
|
|
431
|
+ if (userId) {
|
|
|
432
|
+ this.$modal.confirm("是否立即为该员工设置登录密码?").then(() => {
|
|
|
433
|
+ this.handleResetPwd({ userId: userId, employeeName: payload.employeeName })
|
|
|
434
|
+ }).catch(() => {})
|
|
|
435
|
+ }
|
|
|
436
|
+ })
|
|
|
437
|
+ }
|
|
|
438
|
+ })
|
|
|
439
|
+ },
|
|
|
440
|
+ /** 打开修改账号 */
|
|
|
441
|
+ handleEditProfile(row) {
|
|
|
442
|
+ getSellerEmployee(row.userId).then(response => {
|
|
|
443
|
+ const data = response.data || {}
|
|
|
444
|
+ this.profileForm = {
|
|
|
445
|
+ userId: data.userId,
|
|
|
446
|
+ employeeName: data.employeeName,
|
|
|
447
|
+ mobile: data.mobile,
|
|
|
448
|
+ email: data.email
|
|
|
449
|
+ }
|
|
|
450
|
+ this.profileOpen = true
|
|
|
451
|
+ })
|
|
|
452
|
+ },
|
|
|
453
|
+ cancelProfile() {
|
|
|
454
|
+ this.profileOpen = false
|
|
|
455
|
+ this.profileForm = {}
|
|
|
456
|
+ this.resetForm("profileForm")
|
|
|
457
|
+ },
|
|
|
458
|
+ submitProfile() {
|
|
|
459
|
+ this.$refs["profileForm"].validate(valid => {
|
|
|
460
|
+ if (!valid) {
|
|
|
461
|
+ return
|
|
|
462
|
+ }
|
|
|
463
|
+ updateSellerEmployeeProfile(this.profileForm).then(() => {
|
|
|
464
|
+ this.$modal.msgSuccess("修改成功")
|
|
|
465
|
+ this.profileOpen = false
|
|
|
466
|
+ this.getList()
|
|
|
467
|
+ })
|
|
|
468
|
+ })
|
|
|
469
|
+ },
|
|
|
470
|
+ /** 打开修改密码 */
|
|
|
471
|
+ handleResetPwd(row) {
|
|
|
472
|
+ this.pwdForm = {
|
|
|
473
|
+ userId: row.userId,
|
|
|
474
|
+ employeeName: row.employeeName,
|
|
|
475
|
+ password: undefined,
|
|
|
476
|
+ confirmPassword: undefined
|
|
|
477
|
+ }
|
|
|
478
|
+ this.pwdOpen = true
|
|
|
479
|
+ this.$nextTick(() => {
|
|
|
480
|
+ this.resetForm("pwdForm")
|
|
|
481
|
+ })
|
|
|
482
|
+ },
|
|
|
483
|
+ cancelPwd() {
|
|
|
484
|
+ this.pwdOpen = false
|
|
|
485
|
+ this.pwdForm = {}
|
|
|
486
|
+ this.resetForm("pwdForm")
|
|
|
487
|
+ },
|
|
|
488
|
+ submitPwd() {
|
|
|
489
|
+ this.$refs["pwdForm"].validate(valid => {
|
|
|
490
|
+ if (!valid) {
|
|
|
491
|
+ return
|
|
|
492
|
+ }
|
|
|
493
|
+ resetSellerEmployeePassword({
|
|
|
494
|
+ userId: this.pwdForm.userId,
|
|
|
495
|
+ password: this.pwdForm.password,
|
|
|
496
|
+ confirmPassword: this.pwdForm.confirmPassword
|
|
|
497
|
+ }).then(() => {
|
|
|
498
|
+ this.$modal.msgSuccess("修改成功,员工下次登录请使用新密码")
|
|
|
499
|
+ this.pwdOpen = false
|
|
|
500
|
+ })
|
|
|
501
|
+ })
|
|
|
502
|
+ },
|
|
|
503
|
+ /** 删除员工 */
|
|
|
504
|
+ handleDelete(row) {
|
|
|
505
|
+ this.$modal.confirm('是否确认删除员工「' + (row.employeeName || row.loginAccount) + '」?删除后将无法登录商家端。').then(() => {
|
|
|
506
|
+ return delSellerEmployee(row.userId)
|
|
|
507
|
+ }).then(() => {
|
|
|
508
|
+ this.$modal.msgSuccess("删除成功")
|
|
|
509
|
+ this.refreshPage()
|
|
|
510
|
+ }).catch(() => {})
|
|
|
511
|
+ }
|
|
|
512
|
+ }
|
|
|
513
|
+}
|
|
|
514
|
+</script>
|
|
|
515
|
+
|
|
|
516
|
+<style scoped>
|
|
|
517
|
+.search-card {
|
|
|
518
|
+ margin-bottom: 0;
|
|
|
519
|
+}
|
|
|
520
|
+.card-header {
|
|
|
521
|
+ display: flex;
|
|
|
522
|
+ align-items: center;
|
|
|
523
|
+ flex-wrap: wrap;
|
|
|
524
|
+ gap: 8px;
|
|
|
525
|
+}
|
|
|
526
|
+.header-tip {
|
|
|
527
|
+ color: #909399;
|
|
|
528
|
+ font-size: 13px;
|
|
|
529
|
+ font-weight: normal;
|
|
|
530
|
+}
|
|
|
531
|
+.quota-tip {
|
|
|
532
|
+ color: #606266;
|
|
|
533
|
+ font-size: 13px;
|
|
|
534
|
+ font-weight: normal;
|
|
|
535
|
+ margin-left: 4px;
|
|
|
536
|
+}
|
|
|
537
|
+.mb12 {
|
|
|
538
|
+ margin-bottom: 12px;
|
|
|
539
|
+}
|
|
|
540
|
+.form-tip {
|
|
|
541
|
+ color: #909399;
|
|
|
542
|
+ font-size: 12px;
|
|
|
543
|
+ line-height: 1.5;
|
|
|
544
|
+}
|
|
|
545
|
+.readonly-text {
|
|
|
546
|
+ color: #606266;
|
|
|
547
|
+}
|
|
|
548
|
+</style>
|