cloud-web-corejs 1.0.115 → 1.0.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/package.json +3 -1
  2. package/src/components/VabUpload/view.vue +135 -135
  3. package/src/components/errorMsg/mixins.js +7 -5
  4. package/src/components/excelExport/button.vue +57 -4
  5. package/src/components/excelExport/index.js +7 -6
  6. package/src/components/excelExport/index.vue +56 -2
  7. package/src/components/excelExport/mixins.js +1 -1
  8. package/src/components/formOplog/mixins.js +1 -1
  9. package/src/components/statusTag/mixins.js +1 -1
  10. package/src/components/table/index.js +1 -1
  11. package/src/components/table/util/index.js +1 -1
  12. package/src/components/tempStorage/index.vue +9 -6
  13. package/src/components/tempStorage/tempStorageDialog.vue +1 -1
  14. package/src/components/wf/content.vue +17 -1
  15. package/src/components/wf/mixins/setCandidateDialog.js +2 -1
  16. package/src/components/wf/setCandidateDialog.vue +9 -0
  17. package/src/components/wf/setCandidateDialog2.vue +320 -0
  18. package/src/components/wf/wf.js +1 -1
  19. package/src/components/wf/wfStartDialog.vue +70 -42
  20. package/src/components/wf/wfTaskUserRangeDialog.vue +131 -0
  21. package/src/components/wf/wfUtil.js +1 -1
  22. package/src/components/xform/form-designer/designer.js +1 -1
  23. package/src/components/xform/form-designer/form-widget/field-widget/checkbox-widget.vue +2 -2
  24. package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +1 -1
  25. package/src/components/xform/form-designer/form-widget/field-widget/radio-widget.vue +2 -2
  26. package/src/components/xform/form-designer/form-widget/field-widget/select-widget.vue +4 -4
  27. package/src/components/xform/form-designer/form-widget/field-widget/static-content-wrapper.vue +2 -1
  28. package/src/components/xform/form-designer/form-widget/field-widget/tempStorage-widget.vue +127 -0
  29. package/src/components/xform/form-designer/indexMixin.js +1 -1
  30. package/src/components/xform/form-designer/setting-panel/form-setting.vue +93 -5
  31. package/src/components/xform/form-designer/setting-panel/property-editor/field-button/search-dialog-event-editor.vue +18 -2
  32. package/src/components/xform/form-designer/setting-panel/property-editor/tempStorage-editor.vue +23 -0
  33. package/src/components/xform/form-designer/setting-panel/propertyRegister.js +1 -0
  34. package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +31 -0
  35. package/src/components/xform/form-render/container-item/data-table-mixin.js +1 -1
  36. package/src/components/xform/form-render/indexMixin.js +3 -1
  37. package/src/components/xform/lang/zh-CN.js +1 -0
  38. package/src/components/xform/mixins/defaultHandle.js +1 -1
  39. package/src/components/xform/utils/util.js +1451 -1
  40. package/src/utils/index.js +2 -5
  41. package/src/views/user/form/view/list.vue +18 -3
  42. package/src/views/user/user/edit.vue +1059 -1041
  43. package/src/views/user/user/list.vue +19 -0
  44. package/src/views/user/wf/wf_obj_config/itemEdit.vue +3 -3
  45. package/src/views/user/wf/wf_obj_config/list.vue +5 -5
@@ -1,1041 +1,1059 @@
1
- <template>
2
- <div class="detail-wrap">
3
- <el-form ref="editForm" :model="user">
4
- <div class="d-header clearfix">
5
- <div class="fl">
6
- <i class="el-icon-info"/>
7
- {{ dataId ? $t1('查看用户') : $t1('新增用户') }}
8
- </div>
9
- <div class="fr">
10
- <temp-storage-button :option="tempStorageOption" v-if="!dataId"></temp-storage-button>
11
- <base-input-export :option="exportOption" :parent-target="_self" v-if="dataId"/>
12
- <el-button type="primary" plain class="button-sty" icon="el-icon-unlock" @click="unlock" v-if="user.locked"
13
- v-hasPermi="'user:unlock'">{{ $t1('解锁') }}
14
- </el-button>
15
- <el-button type="primary" plain class="button-sty" @click="$baseReload()" icon="el-icon-refresh-right">
16
- {{ $t1('重置') }}
17
- </el-button>
18
- <el-button type="primary" class="button-sty" icon="el-icon-check" @click="saveData">{{ $t1('保存') }}
19
- </el-button>
20
- </div>
21
- </div>
22
- <baseTabs>
23
- <baseTabPane :label="$t1('基本信息')">
24
- <template #default>
25
- <table class="table-detail">
26
- <tbody>
27
- <tr>
28
- <th>
29
- <em class="f-red">*</em>
30
- {{ $t1('登录名') }}
31
- </th>
32
- <td colspan="3">
33
- <el-form-item prop="loginAccount" :rules="[{ required: true, trigger: 'blur' }]">
34
- <template v-if="dataId">
35
- <el-input size="small" v-model="user.loginAccount" maxlength="255" autocomplete="off"
36
- lay-verify="required" required="" :readonly="true"/>
37
- </template>
38
- <template v-else>
39
- <el-input size="small" v-model="user.loginAccount" maxlength="255" autocomplete="off"
40
- lay-verify="required" required="" clearable/>
41
- </template>
42
- </el-form-item>
43
- </td>
44
-
45
- <th>
46
- <em class="f-red">*</em>
47
- {{ $t1('姓名') }}
48
- </th>
49
- <td colspan="3">
50
- <el-form-item prop="nickName" :rules="[{ required: true, trigger: 'blur' }]">
51
- <el-input size="small" v-model="user.nickName" maxlength="200" lay-verify="required" required=""
52
- clearable/>
53
- </el-form-item>
54
- </td>
55
- </tr>
56
- <tr>
57
-
58
- <th>
59
- <em class="f-red" v-if="!dataId">*</em>
60
- {{ $t1('密码') }}
61
- </th>
62
- <td>
63
- <el-form-item prop="password" :rules="passRules">
64
- <el-input size="small" type="password" v-model="user.password" show-password maxlength="255"
65
- autocomplete="off" auto-complete="new-password" clearable/>
66
- </el-form-item>
67
- </td>
68
- <th>
69
- <em class="f-red" v-if="!dataId">*</em>
70
- {{ $t1('确认密码') }}
71
- </th>
72
- <td>
73
- <el-form-item prop="rePassword" :rules="pass2Rules">
74
- <el-input
75
- size="small"
76
- type="password"
77
- v-model="user.rePassword"
78
- show-password
79
- maxlength="255"
80
- autocomplete="off"
81
- auto-complete="new-password"
82
- lay-verify="confirmPass"
83
- clearable
84
- />
85
- </el-form-item>
86
- </td>
87
-
88
-
89
- <th>{{ $t1('性别') }}</th>
90
- <td>
91
- <el-radio-group v-model="user.gender">
92
- <el-radio :label="1">{{ $t1('男') }}</el-radio>
93
- <el-radio :label="2">{{ $t1('女') }}</el-radio>
94
- </el-radio-group>
95
- </td>
96
- <th>
97
- {{ $t1('员工编码') }}
98
- </th>
99
- <td>
100
- <el-form-item prop="empNo" :rules="[{ required: false, trigger: 'blur' }]">
101
- <el-input size="small" v-model="user.empNo" maxlength="200" clearable/>
102
- </el-form-item>
103
- </td>
104
- </tr>
105
-
106
- <tr>
107
- <th>{{ $t1('出生日期') }}</th>
108
- <td>
109
- <el-date-picker size="small" v-model="user.birth" type="date" :placeholder="$t1('选择日期')"
110
- value-format="yyyy-MM-dd" clearable/>
111
- </td>
112
- <th>{{ $t1('邮编') }}</th>
113
- <td>
114
- <el-input size="small" v-model="user.zipCode" maxlength="255" clearable/>
115
- </td>
116
- <th>{{ $t1('手机') }}</th>
117
- <td>
118
- <el-form-item prop="mobile" :rules="[{ required: false, trigger: 'blur' }]">
119
- <el-input size="small" v-model="user.mobile" type="text" maxlength="255" autocomplete="off"
120
- lay-verify="required|phone" clearable/>
121
- </el-form-item>
122
- </td>
123
- <th>{{ $t1('设置') }}</th>
124
- <td>
125
- <el-checkbox :label="$t1('是否启用')" v-model="user.enabled"></el-checkbox>
126
- </td>
127
-
128
- </tr>
129
-
130
- <tr>
131
- <th>
132
- {{ $t1('邮箱') }}
133
- </th>
134
- <td>
135
- <el-form-item prop="email" :rules="[{ required: false, trigger: 'blur' }]">
136
- <el-input size="small" v-model="user.email" maxlength="200" clearable/>
137
- </el-form-item>
138
- </td>
139
- <!-- <th v-if="flag!=='2'">
140
- GUID
141
- </th>
142
- <td v-if="flag!=='2'">
143
- <el-form-item prop="guid" :rules="[{ required: false, trigger: 'blur' }]">
144
- <el-input size="small" v-model="user.guid" maxlength="200" clearable/>
145
- </el-form-item>
146
- </td>-->
147
- <th>{{ $t1('地址') }}</th>
148
- <td colspan="3">
149
- <el-input size="small" v-model="user.address" class="b" maxlength="255" clearable/>
150
- </td>
151
-
152
- </tr>
153
- <tr>
154
- <th>
155
- {{ $t1('国家') }}
156
- </th>
157
- <td colspan="3">
158
- <el-form-item prop="countryName" :rules="[{ required: false, trigger: 'blur' }]">
159
- <el-input
160
- class="search-input"
161
- v-model="user.countryName"
162
- clearable
163
- @clear="
164
- user.countryName = null;
165
- user.countryCode = null;
166
- "
167
- v-el-readonly
168
- >
169
- <i slot="suffix" class="el-input__icon el-icon-search"
170
- @click="showCountryDialog=true"></i>
171
- </el-input>
172
- </el-form-item>
173
- </td>
174
- <th>
175
- {{ $t1('是否锁定') }}
176
- </th>
177
- <td>
178
- {{ user.locked ? $t1('是') : $t1('否') }}
179
- </td>
180
- </tr>
181
- <tr>
182
- <th>{{ $t1('头像') }}</th>
183
- <td colspan="7">
184
- <baseUpload :limit="1" accept="image/png, image/jpeg" multi="false" :file.sync="user.headPhotoUrl"
185
- dataType="medium"></baseUpload>
186
- </td>
187
- </tr>
188
- <tr>
189
- <th>{{ $t1('创建人') }}</th>
190
- <td>{{ user.createBy }}</td>
191
- <th>{{ $t1('创建时间') }}</th>
192
- <td>{{ user.createDate }}</td>
193
- <th>{{ $t1('更新人') }}</th>
194
- <td>{{ user.modifyBy }}</td>
195
- <th>{{ $t1('更新时间') }}</th>
196
- <td>{{ user.modifyDate }}</td>
197
- </tr>
198
- </tbody>
199
- </table>
200
- </template>
201
- </baseTabPane>
202
- <baseTabPane :label="$t1('组织信息')">
203
- <template #button>
204
- <el-button class="button-sty" @click="addCurrentCompany()" icon="el-icon-search" v-if="!hasCurrentCompany">
205
- {{ $t1('新增组织权限') }}
206
- </el-button>
207
- </template>
208
- <template #default>
209
- <div class="style1">
210
- <div class="d-item" v-for="(item,index1) in user.userCompanyInfoDTOs" :key="index1">
211
- <div class="title">
212
- <b>{{ item.companyName }}</b>
213
- <el-button class="button-sty" icon="el-icon-delete" v-if="isCurrentCompany(item.companyCode)"
214
- @click="deleteCompany(item,index1)">{{ $t1('删除') }}
215
- </el-button>
216
- </div>
217
- <div class="title-form">
218
- <span>
219
- <el-form-item label="GUID" :prop="'userCompanyInfoDTOs.'+index1+'.guid'"
220
- :rules="[{ required: false, trigger: 'blur' }]">
221
- <el-input size="small" v-model="item.guid" maxlength="200" clearable/>
222
- </el-form-item>
223
- </span>
224
- <span>
225
- <el-form-item label="是否默认组织" :prop="'userCompanyInfoDTOs.'+index1+'.defaults'"
226
- :rules="[{ required: false, trigger: 'blur' }]">
227
- <el-checkbox v-model="item.defaults"
228
- @change="changeCompanyDefault(item)"></el-checkbox>
229
- </el-form-item>
230
- </span>
231
- </div>
232
- <div class="m-2">
233
- <div class="d-item" style="width: 65%;">
234
- <div class="title">
235
- <b>{{ $t1('机构信息') }}</b>
236
- <el-button class="button-sty" icon="el-icon-search" @click="showSaleOrgDialog = true"
237
- v-if="isCurrentCompany(item.companyCode)">{{ $t1('选择机构') }}
238
- </el-button>
239
- </div>
240
- <div class="grid-h">
241
- <vxe-grid
242
- :ref="'saleOrgGrid-'+item.companyCode"
243
- :data="gridSaleOrgDataMap[item.companyCode]"
244
- v-bind="vxeOptionMap['saleOrgGridOption-'+item.companyCode]"
245
- @resizable-change="$vxeTableUtil.onColumnWitchChange"
246
- @custom="$vxeTableUtil.customHandle">
247
- <template #position="{row,rowIndex,$table}">
248
- <el-input
249
- class="search-input"
250
- :value="getSelectPositionName(row)"
251
- clearable
252
- @clear="
253
- row.userSaleOrgPositionDTOs = [];
254
- $forceUpdate();
255
- "
256
- v-el-readonly
257
- v-if="companyInfo.companyCode == row.companyCode"
258
- >
259
- <i slot="suffix" class="el-input__icon el-icon-search"
260
- @click="openSelectPositionDialog(row, rowIndex, $table)"></i>
261
- </el-input>
262
- <template v-else>
263
- {{ getSelectPositionName(row) }}
264
- </template>
265
- </template>
266
- </vxe-grid>
267
- </div>
268
- </div>
269
- <div class="d-item" style="width: 35%;">
270
- <div class="title">
271
- <b>{{ $t1('角色信息') }}</b>
272
- <el-button class="button-sty" icon="el-icon-search" @click="showRoleDialog = true"
273
- v-if="isCurrentCompany(item.companyCode)">{{ $t1('选择角色') }}
274
- </el-button>
275
- </div>
276
- <div class="grid-h">
277
- <vxe-grid
278
- :ref="'userRoleGrid-'+item.companyCode"
279
- :data="gridRoleDataMap[item.companyCode]"
280
- v-bind="vxeOptionMap['userRoleGridOption-'+item.companyCode]"
281
- @resizable-change="$vxeTableUtil.onColumnWitchChange"
282
- @custom="$vxeTableUtil.customHandle"
283
- ></vxe-grid>
284
- </div>
285
- </div>
286
- </div>
287
- </div>
288
- </div>
289
- </template>
290
- </baseTabPane>
291
- </baseTabs>
292
- </el-form>
293
- <roleDialog v-if="showRoleDialog" :visiable.sync="showRoleDialog" @confirm="confirmRole"
294
- :param="roleDialogParam"/>
295
- <companyDialog v-if="showCompanyDialog" :visiable.sync="showCompanyDialog" @confirm="confirmInsertCompany"/>
296
- <saleOrgDialog v-if="showSaleOrgDialog" :visiable.sync="showSaleOrgDialog" @confirm="confirmInsertSaleOrg"
297
- :param="{ queryAll: true }"/>
298
- <positionDialog v-if="showPositionDialog" :visiable.sync="showPositionDialog" :rows="positionDialogDatas"
299
- @confirm="confirmInsertPosition" :param="{ queryAll: true }"/>
300
- <countryDialog v-if="showCountryDialog" :visiable.sync="showCountryDialog"
301
- @confirm="confirmCountry" multi="false"/>
302
- </div>
303
- </template>
304
-
305
- <script>
306
- import xeUtils from "xe-utils";
307
- import tempStorageButton from "@base/components/tempStorage/index.vue";
308
-
309
-
310
- export default {
311
- name: 'UserEdit',
312
- components: {
313
- roleDialog: () => import('../../../views/user/role/dialog.vue'),
314
- companyDialog: () => import('../../../views/user/company_info/dialog.vue'),
315
- saleOrgDialog: () => import('../../../views/user/sale_org/dialog.vue'),
316
- positionDialog: () => import('../../../views/user/position/dialog.vue'),
317
- countryDialog: () => import('../../../views/user/country/dialog.vue'),
318
- tempStorageButton
319
- },
320
- props: ['_dataId', 'userType', 'flag'],
321
- data() {
322
- var validatePass = (rule, value, callback) => {
323
- const isPassRequired = !this.dataId;
324
- if (isPassRequired && (value == '' || value == undefined)) {
325
- callback(new Error(this.$t1('密码不能为空')));
326
- } else {
327
- callback();
328
- }
329
- this.$refs.editForm.validateField('rePassword');
330
- };
331
- var validatePass2 = (rule, value, callback) => {
332
- const isPassRequired = !this.dataId;
333
- const rePassword = value != undefined ? value : '';
334
- const password = this.user.password != undefined ? this.user.password : '';
335
-
336
- if (isPassRequired && rePassword == '') {
337
- callback(new Error(this.$t1('确认密码不能为空')));
338
- } else if (rePassword != password) {
339
- callback(new Error(this.$t1('两次输入密码不一致!')));
340
- } else {
341
- callback();
342
- }
343
- };
344
-
345
- return {
346
- dataId: '',
347
- hBtn: true,
348
- user: {
349
- userCompanyInfoDTOs: [],
350
- userSaleOrgDTOs: [],
351
- userRoleDTOs: [],
352
- gender: null,
353
- enabled: true,
354
- userType: null,
355
- countryName: null,
356
- countryCode: null
357
- },
358
- vxeOption: {},
359
- companyInfoOption: {},
360
- userRoleOption: {},
361
- showRoleDialog: false,
362
- showCompanyDialog: false,
363
- showSaleOrgDialog: false,
364
- showPositionDialog: false,
365
- saleOrgPositionIndex: 0,
366
- passRules: [{validator: validatePass, trigger: 'blur', required: false}],
367
- pass2Rules: [{validator: validatePass2, trigger: 'blur', required: false}],
368
- activeName: 'first',
369
- userCustomerListDTO: {
370
- userCustomerDTOs: []
371
- },
372
- customerOption: {},
373
- showCustomerDialog: false,
374
- exportOption: {
375
- prefix: USER_PREFIX,
376
- title: this.$t1('用户'),
377
- codes: ["USEREXCEL", "USERPDF", "USERPRINT", "USERHIPRINT"],
378
- param: () => {
379
- return [{id: this.dataId}];
380
- }
381
- },
382
- showExtendedProperties: false,
383
- radio1: '0',
384
- companyInfo: {},
385
- vxeOptionMap: {},
386
- gridRoleDataMap: {},
387
- gridSaleOrgDataMap: {},
388
- distributorCode: 'distributor',
389
- distributorRole: null,
390
- outUserCodes: [],
391
- roleDialogParam: {queryAll: true},
392
- tempStorageOption: {
393
- storageType: "user",
394
- data: () => {
395
- this.handleData();
396
- return this.user;
397
- },
398
- chooseConfirm: (tempStorageData) => {
399
- this.user = tempStorageData;
400
- this.gridSaleOrgDataMap = xeUtils.groupBy(this.user.userSaleOrgDTOs, 'companyCode');
401
- this.gridRoleDataMap = xeUtils.groupBy(this.user.userRoleDTOs, 'companyCode');
402
- },
403
- saveConfirm: () => {
404
- }
405
- },
406
- showCountryDialog: false
407
- };
408
- },
409
- computed: {
410
- hasCurrentCompany() {
411
- return this.user.userCompanyInfoDTOs.find(item => item.companyCode == this.companyInfo.companyCode) != null;
412
- }
413
- },
414
- created() {
415
- if (this._dataId && !isNaN(this._dataId)) this.dataId = this._dataId;
416
- },
417
- async mounted() {
418
-
419
- // this.getEainsGroupDTO();
420
- await this.initOutUserRoleCode();
421
- await this.initDistributorRole();
422
- this.getData();
423
- this.getConpanyInfo()
424
- },
425
- methods: {
426
- getData() {
427
- if (this.dataId && !isNaN(this.dataId)) {
428
- this.isEdit = true;
429
- this.$commonHttp({
430
- url: USER_PREFIX + `/user/get`,
431
- method: `post`,
432
- data: {
433
- id: this.dataId
434
- },
435
- isLoading: true,
436
- modalStrictly: true,
437
- success: res => {
438
- let user = res.objx || {};
439
- user.userCompanyInfoDTOs = this.user.userCompanyInfoDTOs;
440
- user.userSaleOrgDTOs = this.user.userSaleOrgDTOs;
441
- user.userRoleDTOs = this.user.userRoleDTOs;
442
- this.user = user;
443
- this.user.password = '';
444
-
445
- this.showExtendedProperties = true;
446
- }
447
- });
448
- } else {
449
- this.user.gender = 1;
450
- this.isEdit = false;
451
- this.showExtendedProperties = true;
452
- }
453
- },
454
- saveData() {
455
- let companyCode = this.companyInfo.companyCode;
456
- this.handleData();
457
- if (this.userType == 2) {
458
- //外部用户
459
- let currentUserCompanyInfo = this.user.userCompanyInfoDTOs.find(item => item.companyCode == companyCode)
460
- if (currentUserCompanyInfo) {
461
- let rows = this.user.userRoleDTOs.filter(item => item.companyCode == companyCode);
462
- if (!rows.length) {
463
- this.$baseAlert(this.$t1('请维护角色'));
464
- return
465
- }
466
- }
467
-
468
- }
469
- this.$refs.editForm.$baseValidate(valid => {
470
- if (valid) {
471
- this.$baseConfirm(this.$t1('您确定要保存吗?')).then(() => {
472
- var url = USER_PREFIX + (this.isEdit ? '/user/update' : '/user/save');
473
- this.$http({
474
- url: url,
475
- method: `post`,
476
- data: this.user,
477
- isLoading: true,
478
- success: res => {
479
- this.$message({
480
- message: res.content,
481
- type: 'success',
482
- duration: 500,
483
- onClose: t => {
484
- if (this.isEdit) {
485
- this.$baseReload();
486
- } else {
487
- this.$baseReload({
488
- updateParam: {
489
- _dataId: res.objx
490
- }
491
- });
492
- }
493
- }
494
- });
495
- }
496
- });
497
- });
498
- }
499
- });
500
- },
501
- getSaleOrgData() {
502
- if (this.dataId) {
503
- this.$http({
504
- url: USER_PREFIX + '/user/getUserSaleOrg',
505
- method: `post`,
506
- data: {id: this.dataId},
507
- isLoading: true,
508
- modalStrictly: true,
509
- success: res => {
510
- // this.$refs.saleOrgGrid.loadData(res.objx || []);
511
- let rows = res.objx || [];
512
- if (rows.length) {
513
- // this.gridSaleOrgDataMap = xeUtils.groupBy(rows, 'companyCode');
514
- Object.assign(this.gridSaleOrgDataMap, xeUtils.groupBy(rows, 'companyCode'));
515
- }
516
- this.user.userSaleOrgDTOs = rows;
517
- }
518
- });
519
- }
520
- },
521
- getUserRoleData() {
522
- if (this.dataId) {
523
- this.$http({
524
- url: USER_PREFIX + '/user/getUserRole',
525
- method: `post`,
526
- data: {id: this.dataId},
527
- isLoading: true,
528
- modalStrictly: true,
529
- success: res => {
530
- let rows = res.objx || [];
531
- if (rows.length) {
532
- // this.gridRoleDataMap = xeUtils.groupBy(rows, 'companyCode');
533
- Object.assign(this.gridRoleDataMap, xeUtils.groupBy(rows, 'companyCode'));
534
- }
535
- this.user.userRoleDTOs = rows;
536
- }
537
- });
538
- }
539
- },
540
- deleteSaleOrgItem(row, index, $table) {
541
- $table.remove(row);
542
- this.gridSaleOrgDataMap[row.companyCode].splice(index, 1);
543
- },
544
- getCompanyInfoData(callback) {
545
- if (this.dataId) {
546
- this.$http({
547
- url: USER_PREFIX + '/user/getUserCompanyInfo',
548
- method: `post`,
549
- data: {id: this.dataId},
550
- isLoading: true,
551
- modalStrictly: true,
552
- success: res => {
553
- let rows = res.objx || [];
554
- rows.forEach(row => {
555
- this.gridRoleDataMap[row.companyCode] = [];
556
- this.gridSaleOrgDataMap[row.companyCode] = [];
557
- })
558
- this.user.userCompanyInfoDTOs = rows;
559
- callback && callback();
560
- }
561
- });
562
- }
563
- },
564
- initSaleOrg(companyCode) {
565
- if (this.vxeOptionMap['saleOrgGridOption-' + companyCode]) {
566
- return;
567
- }
568
- let tableRef = 'saleOrgGrid-' + companyCode;
569
- const tableOption = {
570
- vue: this,
571
- tableRef: tableRef,
572
- tableName: 'editUser-saleOrgGrid-' + companyCode,
573
- columns: [
574
- {type: 'checkbox', fixed: 'left', width: 48, resizable: false},
575
- {title: this.$t1('机构名称'), field: 'saleOrgName', width: 200},
576
- {title: this.$t1('机构编码'), field: 'sn', width: 200},
577
- {title: this.$t1('上级机构'), field: 'treePathName', width: 200},
578
- {
579
- title: this.$t1('岗位'),
580
- field: 'position',
581
- width: 150,
582
- slots: {
583
- default: 'position'
584
- }
585
- },
586
- {
587
- title: this.$t1('是否默认'),
588
- field: 'defaults',
589
- width: 120,
590
- slots: {
591
- default: ({row, $table, rowIndex}) => {
592
- var isDefault = row.defaults || false;
593
- let disabled = this.companyInfo.companyCode != row.companyCode;
594
- return [
595
- <el-checkbox
596
- v-model={isDefault}
597
- disabled={disabled}
598
- onchange={() => {
599
- this.gridSaleOrgDataMap[row.companyCode].forEach((item, index) => {
600
- if (index !== rowIndex) {
601
- item.defaults = false;
602
- }
603
- });
604
- this.$nextTick(()=>{
605
- row.defaults = true;
606
- })
607
- }}
608
- />
609
- ];
610
- }
611
- }
612
- },
613
- {
614
- width: 47,
615
- fixed: 'right',
616
- title: '',
617
- sortable: false,
618
- slots: {
619
- default: ({row, rowIndex, $table}) => {
620
- if (this.companyInfo.companyCode == row.companyCode) {
621
- return [
622
- <a
623
- href="javascript:void(0);"
624
- class="a-link"
625
- onclick={() => {
626
- this.deleteSaleOrgItem(row, rowIndex, $table);
627
- }}
628
- >
629
- <el-tooltip enterable={false} effect="dark" content={this.$t1('删除')} placement="top"
630
- popper-class="tooltip-skin">
631
- <i class="el-icon-delete"/>
632
- </el-tooltip>
633
- </a>
634
- ];
635
- }
636
- }
637
- }
638
- }
639
- ]
640
- };
641
- this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
642
- // this.vxeOptionMap['saleOrgGridOption-'+companyCode] = opts;
643
- this.$set(this.vxeOptionMap, 'saleOrgGridOption-' + companyCode, opts);
644
- });
645
-
646
- },
647
- initUserRole(companyCode) {
648
- if (this.vxeOptionMap['userRoleGridOption-' + companyCode]) {
649
- return;
650
- }
651
- let userType = this.userType;
652
- const tableOption = {
653
- vue: this,
654
- tableRef: 'userRoleGrid-' + companyCode,
655
- tableName: 'editUser-userRoleGrid-' + companyCode,
656
- columns: [
657
- {type: 'checkbox', fixed: 'left', width: 48, resizable: false},
658
- {
659
- title: this.$t1('角色名称'),
660
- field: 'name',
661
- width: 200,
662
- slots: {
663
- default: ({row}) => {
664
- if (!row.isAdd) {
665
- return row.roleName;
666
- } else {
667
- return row.name;
668
- }
669
- }
670
- }
671
- },
672
- {
673
- width: 47,
674
- fixed: 'right',
675
- title: '',
676
- sortable: false,
677
- slots: {
678
- default: ({row, rowIndex, $table}) => {
679
- if (this.companyInfo.companyCode == row.companyCode) {
680
- return [
681
- <a
682
- href="javascript:void(0);"
683
- class="a-link"
684
- onclick={() => {
685
- this.deleteRoleItem(row, rowIndex, $table);
686
- }}
687
- >
688
- <el-tooltip enterable={false} effect="dark" content={this.$t1('删除')} placement="top"
689
- popper-class="tooltip-skin">
690
- <i class="el-icon-delete"/>
691
- </el-tooltip>
692
- </a>
693
- ];
694
- }
695
- }
696
- }
697
- }
698
- ]
699
- };
700
- this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
701
- // this.vxeOptionMap['userRoleGridOption-'+companyCode] = opts;
702
- this.$set(this.vxeOptionMap, 'userRoleGridOption-' + companyCode, opts);
703
- });
704
- },
705
- confirmRole(rows) {
706
- if (rows.length > 0) {
707
- let outUserCodes = this.outUserCodes;
708
- if (this.userType === 1) {
709
- //组织用户
710
- rows = rows.filter(row => !outUserCodes.includes(row.code));
711
- } else if (this.userType === 2) {
712
- //外部用户
713
- rows = rows.filter(row => outUserCodes.includes(row.code));
714
- }
715
- let companyCode = this.companyInfo.companyCode;
716
- const $grid = this.$refs['userRoleGrid-' + companyCode][0];
717
- const tableData = this.gridRoleDataMap[companyCode];
718
- const map = {};
719
- tableData.forEach(function (item) {
720
- map[item.roleId] = 1;
721
- });
722
- var items = [];
723
- rows.forEach(row => {
724
- const item = {
725
- roleId: row.id,
726
- roleName: row.name,
727
- companyCode: companyCode,
728
- companyName: row.companyName
729
- };
730
- if (!map[item.roleId]) {
731
- items.push(item);
732
- }
733
- });
734
- // $grid.insertAt(items, -1);
735
- // this.user.userRoleDTOs = this.user.userRoleDTOs.concat(items);
736
- this.gridRoleDataMap[companyCode] = tableData.concat(items)
737
- $grid.loadData(this.gridRoleDataMap[companyCode])
738
- }
739
- },
740
- deleteRole(tableRef) {
741
- this.$baseConfirm(this.$t1('您确定要删除吗?')).then(() => {
742
- /*const $grid = this.$refs.userRoleGrid;
743
- $grid.removeCheckboxRow();
744
- this.user.userRoleDTOs = $grid.getTableData().fullData;*/
745
- let companyCode = this.companyInfo.companyCode;
746
- const $grid = this.$refs[tableRef][0];
747
- $grid.removeCheckboxRow();
748
- this.gridRoleDataMap[companyCode] = $grid.getTableData().fullData;
749
-
750
- });
751
- },
752
- deleteRoleItem(row, index, $table) {
753
- $table.remove(row);
754
- this.gridRoleDataMap[row.companyCode].splice(index, 1);
755
- },
756
- confirmInsertCompany(rows, callback) {
757
- if (rows.length > 0) {
758
- const tableData = this.user.userCompanyInfoDTOs;
759
- const map = {};
760
- tableData.forEach(function (item) {
761
- map[item.companyCode] = 1;
762
- });
763
- var items = [];
764
- rows.forEach(row => {
765
- const item = {companyCode: row.companyCode, companyName: row.companyName, guid: null, defaults: false};
766
- if (!map[item.companyCode]) {
767
- items.push(item);
768
- }
769
- this.gridRoleDataMap[item.companyCode] = []
770
- this.gridSaleOrgDataMap[item.companyCode] = []
771
- });
772
- // $grid.insertAt(items, -1);
773
- this.user.userCompanyInfoDTOs.splice(0, 0, ...items);
774
- if (this.user.userCompanyInfoDTOs.length == 1) {
775
- this.user.userCompanyInfoDTOs[0].defaults = true
776
- }
777
- // this.user.userCompanyInfoDTOs = this.user.userCompanyInfoDTOs.concat(items);
778
- }
779
- callback && callback();
780
- },
781
- deleteCompany(row, index) {
782
- let companyCode = row.companyCode;
783
- this.user.userCompanyInfoDTOs.splice(index, 1);
784
- this.gridSaleOrgDataMap[row.companyCode] = [];
785
- this.gridRoleDataMap[row.companyCode] = [];
786
- this.user.userSaleOrgDTOs = this.user.userSaleOrgDTOs.filter(item => item.companyCode != companyCode);
787
- this.user.userRoleDTOs = this.user.userRoleDTOs.filter(item => item.companyCode != companyCode);
788
- },
789
- confirmInsertSaleOrg(rows) {
790
- if (rows.length > 0) {
791
- let companyCode = this.companyInfo.companyCode;
792
- const $grid = this.$refs['saleOrgGrid-' + companyCode][0];
793
- const tableData = this.gridSaleOrgDataMap[companyCode] || [];
794
- const map = {};
795
- tableData.forEach(function (item) {
796
- map[item.saleOrgId] = 1;
797
- });
798
-
799
- let roleMap = {};
800
- let newUserRoleDTOs = [];
801
- var items = [];
802
-
803
- rows.forEach((row, index) => {
804
- const item = {
805
- companyCode: companyCode,
806
- companyName: row.companyName,
807
- defaults: false,
808
- saleOrgName: row.name,
809
- treePathName: row.treePathName,
810
- userSaleOrgPositionDTOs: [],
811
- saleOrgId: row.id,
812
- sn: row.sn
813
- };
814
-
815
- if (!map[item.saleOrgId]) {
816
- items.push(item);
817
- if (row.roleId && !roleMap[row.roleId]) {
818
- const roleItem = {
819
- id: row.roleId,
820
- name: row.roleName,
821
- companyCode: companyCode,
822
- companyName: row.companyName
823
- };
824
- roleMap[row.roleId] = true;
825
- newUserRoleDTOs.push(roleItem);
826
- }
827
- }
828
- });
829
- if (items.length > 0 && tableData.length == 0) {
830
- items[0].defaults = true;
831
- }
832
- // this.user.userSaleOrgDTOs.push(...items);
833
- this.gridSaleOrgDataMap[companyCode] = tableData.concat(items)
834
- $grid.loadData(this.gridSaleOrgDataMap[companyCode])
835
- this.confirmRole(newUserRoleDTOs);
836
- }
837
- },
838
- openSelectPositionDialog(row, rowIndex, $table) {
839
- const userSaleOrgPositionDTOs = row.userSaleOrgPositionDTOs || [];
840
- const items = [];
841
- userSaleOrgPositionDTOs.forEach(userSaleOrgPositionDTO => {
842
- const item = {
843
- companyCode: userSaleOrgPositionDTO.companyCode,
844
- companyName: userSaleOrgPositionDTO.companyName,
845
- name: userSaleOrgPositionDTO.positionName,
846
- code: userSaleOrgPositionDTO.code,
847
- id: userSaleOrgPositionDTO.positionId
848
- };
849
- items.push(item);
850
- });
851
-
852
- this.positionDialogDatas = items;
853
- this.saleOrgPositionIndex = rowIndex;
854
- this.showPositionDialog = true;
855
- },
856
- confirmInsertPosition(rows) {
857
- let companyCode = this.companyInfo.companyCode;
858
- const saleOrgPositionIndex = this.saleOrgPositionIndex;
859
- const tableData = this.gridSaleOrgDataMap[companyCode];
860
- if (rows.length > 0) {
861
- const oldPositions = tableData[saleOrgPositionIndex].userSaleOrgPositionDTOs || [];
862
- const map = {};
863
- oldPositions.forEach(function (item) {
864
- map[item.positionId] = item;
865
- });
866
- var oItems = [];
867
- var items = [];
868
- rows.forEach(row => {
869
- const item = {
870
- companyCode: row.companyCode,
871
- companyName: row.companyName,
872
- positionName: row.name,
873
- code: row.code,
874
- positionId: row.id
875
- };
876
-
877
- if (!map[item.positionId]) {
878
- items.push(item);
879
- } else {
880
- oItems.push(map[item.positionId]);
881
- }
882
- });
883
- tableData[saleOrgPositionIndex].userSaleOrgPositionDTOs = oItems.concat(items);
884
- } else {
885
- tableData[saleOrgPositionIndex].userSaleOrgPositionDTOs = [];
886
- }
887
- this.$forceUpdate();
888
- },
889
- getSelectPositionName(row) {
890
- var userSaleOrgPositions = row.userSaleOrgPositionDTOs || [];
891
- var allName = '';
892
- userSaleOrgPositions.forEach(function (pItem, pIndex) {
893
- allName = allName + ',' + pItem.positionName;
894
- });
895
- if (allName) {
896
- allName = allName.substr(1);
897
- }
898
- return allName;
899
- },
900
- getConpanyInfo() {
901
- this.$http({
902
- url: USER_PREFIX + '/company_info/getCurrent',
903
- method: `post`,
904
- isLoading: true,
905
- success: res => {
906
- this.companyInfo = res.objx || {};
907
- let companyCode = this.companyInfo.companyCode;
908
- if (!this.isEdit) {
909
- this.addCurrentCompany();
910
- } else {
911
- this.getCompanyInfoData(() => {
912
- this.getUserRoleData();
913
- this.getSaleOrgData();
914
- setTimeout(() => {
915
- this.user.userCompanyInfoDTOs.forEach(userCompanyInfoDTO => {
916
- this.initSaleOrg(userCompanyInfoDTO.companyCode);
917
- this.initUserRole(userCompanyInfoDTO.companyCode);
918
- })
919
- }, 100)
920
- });
921
- }
922
- }
923
- });
924
- },
925
- isCurrentCompany(companyCode) {
926
- return this.companyInfo.companyCode == companyCode;
927
- },
928
- addCurrentCompany(callback) {
929
- this.confirmInsertCompany([this.companyInfo], callback);
930
- setTimeout(() => {
931
- this.initSaleOrg(this.companyInfo.companyCode);
932
- this.initUserRole(this.companyInfo.companyCode);
933
- setTimeout(() => {
934
- if (this.userType === 2) {
935
- //经销商
936
- if (this.distributorRole) {
937
- this.confirmRole([this.distributorRole]);
938
- }
939
- }
940
- }, 100)
941
- }, 100)
942
-
943
-
944
- },
945
- handleData() {
946
- let saleOrgs = [];
947
- Object.keys(this.gridSaleOrgDataMap).forEach(companyCode => {
948
- saleOrgs.push(...this.gridSaleOrgDataMap[companyCode])
949
- });
950
- let roles = [];
951
- Object.keys(this.gridRoleDataMap).forEach(companyCode => {
952
- roles.push(...this.gridRoleDataMap[companyCode])
953
- });
954
- this.user.userRoleDTOs = roles;
955
- this.user.userSaleOrgDTOs = saleOrgs
956
- },
957
- initDistributorRole() {
958
- if (this.outUserCodes && this.outUserCodes.length == 1) {
959
- return this.$http({
960
- url: USER_PREFIX + '/role/list',
961
- method: 'post',
962
- success: res => {
963
- let roleList = res.objx || [];
964
- let distributorCode = this.outUserCodes[0];
965
- this.distributorRole = roleList.find(item => item.code == distributorCode);
966
- }
967
- });
968
- }
969
- },
970
- async initOutUserRoleCode() {
971
- //初始化外部用户编码
972
- return this.$http({
973
- url: USER_PREFIX + '/system_parameter/getByCode',
974
- method: 'post',
975
- data: {"code": "outUserRoleCode"},
976
- success: res => {
977
- let value = (!res.objx || !res.objx.value) ? "distributor" : res.objx.value;
978
- let codes = value.split(',');
979
- this.outUserCodes = codes;//外部用户编码
980
- this.initRoleDialogParam();//初始化角色弹框的查询参数
981
- }
982
- });
983
- },
984
- initRoleDialogParam() {
985
- //初始化角色弹框的查询参数
986
- if (this.userType == 1) {
987
- //组织用户
988
- this.roleDialogParam = {
989
- queryAll: true,
990
- neCodes: [...this.outUserCodes]
991
- };
992
- } else if (this.userType == 2) {
993
- //外部用户
994
- this.roleDialogParam = {
995
- queryAll: true,
996
- eqCodes: [...this.outUserCodes]
997
- };
998
- }
999
- },
1000
- unlock() {
1001
- this.$baseConfirm(this.$t1('您确定要解锁吗?')).then(() => {
1002
- var url = USER_PREFIX + '/user/unlockLoginAccount';
1003
- this.$http({
1004
- url: url,
1005
- method: `post`,
1006
- data: {
1007
- id: this.user.id
1008
- },
1009
- isLoading: true,
1010
- success: res => {
1011
- this.$message({
1012
- message: res.content,
1013
- type: 'success',
1014
- duration: 500,
1015
- onClose: t => {
1016
- this.$baseReload();
1017
- }
1018
- });
1019
- }
1020
- });
1021
- });
1022
- },
1023
- confirmCountry(rows) {
1024
- if (rows.length) {
1025
- let row = rows[0];
1026
- this.user.countryName = row.countryName;
1027
- this.user.countryCode = row.countryCode;
1028
- }
1029
- },
1030
- changeCompanyDefault(item) {
1031
- let companyCode = item.companyCode
1032
- if (item.defaults) {
1033
- this.user.userCompanyInfoDTOs.forEach(row => {
1034
- row.defaults = row.companyCode == companyCode;
1035
- })
1036
- }
1037
-
1038
- }
1039
- }
1040
- };
1041
- </script>
1
+ <template>
2
+ <div class="detail-wrap">
3
+ <el-form ref="editForm" :model="user">
4
+ <div class="d-header clearfix">
5
+ <div class="fl">
6
+ <i class="el-icon-info"/>
7
+ {{ dataId ? $t1('查看用户') : $t1('新增用户') }}
8
+ </div>
9
+ <div class="fr">
10
+ <temp-storage-button :option="tempStorageOption" v-if="!dataId"></temp-storage-button>
11
+ <base-input-export :option="exportOption" :parent-target="_self" v-if="dataId"/>
12
+ <el-button type="primary" plain class="button-sty" icon="el-icon-unlock" @click="unlock" v-if="user.locked"
13
+ v-hasPermi="'user:unlock'">{{ $t1('解锁') }}
14
+ </el-button>
15
+ <el-button type="primary" plain class="button-sty" @click="$baseReload()" icon="el-icon-refresh-right">
16
+ {{ $t1('重置') }}
17
+ </el-button>
18
+ <el-button type="primary" class="button-sty" icon="el-icon-check" @click="saveData">{{ $t1('保存') }}
19
+ </el-button>
20
+ </div>
21
+ </div>
22
+ <baseTabs>
23
+ <baseTabPane :label="$t1('基本信息')">
24
+ <template #default>
25
+ <table class="table-detail">
26
+ <tbody>
27
+ <tr>
28
+ <th>
29
+ <em class="f-red">*</em>
30
+ {{ $t1('登录名') }}
31
+ </th>
32
+ <td colspan="3">
33
+ <el-form-item prop="loginAccount" :rules="[{ required: true, trigger: 'blur' }]">
34
+ <template v-if="dataId">
35
+ <el-input size="small" v-model="user.loginAccount" maxlength="255" autocomplete="off"
36
+ lay-verify="required" required="" :readonly="true"/>
37
+ </template>
38
+ <template v-else>
39
+ <el-input size="small" v-model="user.loginAccount" maxlength="255" autocomplete="off"
40
+ lay-verify="required" required="" clearable/>
41
+ </template>
42
+ </el-form-item>
43
+ </td>
44
+
45
+ <th>
46
+ <em class="f-red">*</em>
47
+ {{ $t1('姓名') }}
48
+ </th>
49
+ <td colspan="3">
50
+ <el-form-item prop="nickName" :rules="[{ required: true, trigger: 'blur' }]">
51
+ <el-input size="small" v-model="user.nickName" maxlength="200" lay-verify="required" required=""
52
+ clearable/>
53
+ </el-form-item>
54
+ </td>
55
+ </tr>
56
+ <tr>
57
+
58
+ <th>
59
+ <em class="f-red" v-if="!dataId">*</em>
60
+ {{ $t1('密码') }}
61
+ </th>
62
+ <td>
63
+ <el-form-item prop="password" :rules="passRules">
64
+ <el-input size="small" type="password" v-model="user.password" show-password maxlength="255"
65
+ autocomplete="off" auto-complete="new-password" clearable/>
66
+ </el-form-item>
67
+ </td>
68
+ <th>
69
+ <em class="f-red" v-if="!dataId">*</em>
70
+ {{ $t1('确认密码') }}
71
+ </th>
72
+ <td>
73
+ <el-form-item prop="rePassword" :rules="pass2Rules">
74
+ <el-input
75
+ size="small"
76
+ type="password"
77
+ v-model="user.rePassword"
78
+ show-password
79
+ maxlength="255"
80
+ autocomplete="off"
81
+ auto-complete="new-password"
82
+ lay-verify="confirmPass"
83
+ clearable
84
+ />
85
+ </el-form-item>
86
+ </td>
87
+
88
+
89
+ <th>{{ $t1('性别') }}</th>
90
+ <td>
91
+ <el-radio-group v-model="user.gender">
92
+ <el-radio :label="1">{{ $t1('男') }}</el-radio>
93
+ <el-radio :label="2">{{ $t1('女') }}</el-radio>
94
+ </el-radio-group>
95
+ </td>
96
+ <th>
97
+ {{ $t1('员工编码') }}
98
+ </th>
99
+ <td>
100
+ <el-form-item prop="empNo" :rules="[{ required: false, trigger: 'blur' }]">
101
+ <el-input size="small" v-model="user.empNo" maxlength="200" clearable/>
102
+ </el-form-item>
103
+ </td>
104
+ </tr>
105
+
106
+ <tr>
107
+ <th>{{ $t1('出生日期') }}</th>
108
+ <td>
109
+ <el-date-picker size="small" v-model="user.birth" type="date" :placeholder="$t1('选择日期')"
110
+ value-format="yyyy-MM-dd" clearable/>
111
+ </td>
112
+ <th>{{ $t1('邮编') }}</th>
113
+ <td>
114
+ <el-input size="small" v-model="user.zipCode" maxlength="255" clearable/>
115
+ </td>
116
+ <th>{{ $t1('手机') }}</th>
117
+ <td>
118
+ <el-form-item prop="mobile" :rules="[{ required: false, trigger: 'blur' }]">
119
+ <el-input size="small" v-model="user.mobile" type="text" maxlength="255" autocomplete="off"
120
+ lay-verify="required|phone" clearable/>
121
+ </el-form-item>
122
+ </td>
123
+ <th>{{ $t1('设置') }}</th>
124
+ <td>
125
+ <el-checkbox :label="$t1('是否启用')" v-model="user.enabled"></el-checkbox>
126
+ </td>
127
+
128
+ </tr>
129
+
130
+ <tr>
131
+ <th>
132
+ {{ $t1('邮箱') }}
133
+ </th>
134
+ <td>
135
+ <el-form-item prop="email" :rules="[{ required: false, trigger: 'blur' }]">
136
+ <el-input size="small" v-model="user.email" maxlength="200" clearable/>
137
+ </el-form-item>
138
+ </td>
139
+ <!-- <th v-if="flag!=='2'">
140
+ GUID
141
+ </th>
142
+ <td v-if="flag!=='2'">
143
+ <el-form-item prop="guid" :rules="[{ required: false, trigger: 'blur' }]">
144
+ <el-input size="small" v-model="user.guid" maxlength="200" clearable/>
145
+ </el-form-item>
146
+ </td>-->
147
+ <th>{{ $t1('地址') }}</th>
148
+ <td colspan="3">
149
+ <el-input size="small" v-model="user.address" class="b" maxlength="255" clearable/>
150
+ </td>
151
+
152
+ </tr>
153
+ <tr>
154
+ <th>
155
+ {{ $t1('国家') }}
156
+ </th>
157
+ <td colspan="3">
158
+ <el-form-item prop="countryName" :rules="[{ required: false, trigger: 'blur' }]">
159
+ <el-input
160
+ class="search-input"
161
+ v-model="user.countryName"
162
+ clearable
163
+ @clear="
164
+ user.countryName = null;
165
+ user.countryCode = null;
166
+ "
167
+ v-el-readonly
168
+ >
169
+ <i slot="suffix" class="el-input__icon el-icon-search"
170
+ @click="showCountryDialog=true"></i>
171
+ </el-input>
172
+ </el-form-item>
173
+ </td>
174
+ <th>
175
+ {{ $t1('是否锁定') }}
176
+ </th>
177
+ <td>
178
+ {{ user.locked ? $t1('是') : $t1('否') }}
179
+ </td>
180
+ </tr>
181
+ <tr v-if="userType==2">
182
+ <th>
183
+ {{ $t1('签约人') }}
184
+ </th>
185
+ <td>
186
+ <el-form-item prop="signatoryName" :rules="[{ required: false, trigger: 'blur' }]">
187
+ <el-input size="small" v-model="user.signatoryName" maxlength="200" clearable/>
188
+ </el-form-item>
189
+ </td>
190
+ <th>
191
+ {{ $t1('签约人电话') }}
192
+ </th>
193
+ <td>
194
+ <el-form-item prop="signatoryMobile" :rules="[{ required: false, trigger: 'blur' }]">
195
+ <el-input size="small" v-model="user.signatoryMobile" maxlength="200" clearable/>
196
+ </el-form-item>
197
+ </td>
198
+ </tr>
199
+ <tr>
200
+ <th>{{ $t1('头像') }}</th>
201
+ <td colspan="7">
202
+ <baseUpload :limit="1" accept="image/png, image/jpeg" multi="false" :file.sync="user.headPhotoUrl"
203
+ dataType="medium"></baseUpload>
204
+ </td>
205
+ </tr>
206
+ <tr>
207
+ <th>{{ $t1('创建人') }}</th>
208
+ <td>{{ user.createBy }}</td>
209
+ <th>{{ $t1('创建时间') }}</th>
210
+ <td>{{ user.createDate }}</td>
211
+ <th>{{ $t1('更新人') }}</th>
212
+ <td>{{ user.modifyBy }}</td>
213
+ <th>{{ $t1('更新时间') }}</th>
214
+ <td>{{ user.modifyDate }}</td>
215
+ </tr>
216
+ </tbody>
217
+ </table>
218
+ </template>
219
+ </baseTabPane>
220
+ <baseTabPane :label="$t1('组织信息')">
221
+ <template #button>
222
+ <el-button class="button-sty" @click="addCurrentCompany()" icon="el-icon-search" v-if="!hasCurrentCompany">
223
+ {{ $t1('新增组织权限') }}
224
+ </el-button>
225
+ </template>
226
+ <template #default>
227
+ <div class="style1">
228
+ <div class="d-item" v-for="(item,index1) in user.userCompanyInfoDTOs" :key="index1">
229
+ <div class="title">
230
+ <b>{{ item.companyName }}</b>
231
+ <el-button class="button-sty" icon="el-icon-delete" v-if="isCurrentCompany(item.companyCode)"
232
+ @click="deleteCompany(item,index1)">{{ $t1('删除') }}
233
+ </el-button>
234
+ </div>
235
+ <div class="title-form">
236
+ <span>
237
+ <el-form-item label="GUID" :prop="'userCompanyInfoDTOs.'+index1+'.guid'"
238
+ :rules="[{ required: false, trigger: 'blur' }]">
239
+ <el-input size="small" v-model="item.guid" maxlength="200" clearable/>
240
+ </el-form-item>
241
+ </span>
242
+ <span>
243
+ <el-form-item label="是否默认组织" :prop="'userCompanyInfoDTOs.'+index1+'.defaults'"
244
+ :rules="[{ required: false, trigger: 'blur' }]">
245
+ <el-checkbox v-model="item.defaults"
246
+ @change="changeCompanyDefault(item)"></el-checkbox>
247
+ </el-form-item>
248
+ </span>
249
+ </div>
250
+ <div class="m-2">
251
+ <div class="d-item" style="width: 65%;">
252
+ <div class="title">
253
+ <b>{{ $t1('机构信息') }}</b>
254
+ <el-button class="button-sty" icon="el-icon-search" @click="showSaleOrgDialog = true"
255
+ v-if="isCurrentCompany(item.companyCode)">{{ $t1('选择机构') }}
256
+ </el-button>
257
+ </div>
258
+ <div class="grid-h">
259
+ <vxe-grid
260
+ :ref="'saleOrgGrid-'+item.companyCode"
261
+ :data="gridSaleOrgDataMap[item.companyCode]"
262
+ v-bind="vxeOptionMap['saleOrgGridOption-'+item.companyCode]"
263
+ @resizable-change="$vxeTableUtil.onColumnWitchChange"
264
+ @custom="$vxeTableUtil.customHandle">
265
+ <template #position="{row,rowIndex,$table}">
266
+ <el-input
267
+ class="search-input"
268
+ :value="getSelectPositionName(row)"
269
+ clearable
270
+ @clear="
271
+ row.userSaleOrgPositionDTOs = [];
272
+ $forceUpdate();
273
+ "
274
+ v-el-readonly
275
+ v-if="companyInfo.companyCode == row.companyCode"
276
+ >
277
+ <i slot="suffix" class="el-input__icon el-icon-search"
278
+ @click="openSelectPositionDialog(row, rowIndex, $table)"></i>
279
+ </el-input>
280
+ <template v-else>
281
+ {{ getSelectPositionName(row) }}
282
+ </template>
283
+ </template>
284
+ </vxe-grid>
285
+ </div>
286
+ </div>
287
+ <div class="d-item" style="width: 35%;">
288
+ <div class="title">
289
+ <b>{{ $t1('角色信息') }}</b>
290
+ <el-button class="button-sty" icon="el-icon-search" @click="showRoleDialog = true"
291
+ v-if="isCurrentCompany(item.companyCode)">{{ $t1('选择角色') }}
292
+ </el-button>
293
+ </div>
294
+ <div class="grid-h">
295
+ <vxe-grid
296
+ :ref="'userRoleGrid-'+item.companyCode"
297
+ :data="gridRoleDataMap[item.companyCode]"
298
+ v-bind="vxeOptionMap['userRoleGridOption-'+item.companyCode]"
299
+ @resizable-change="$vxeTableUtil.onColumnWitchChange"
300
+ @custom="$vxeTableUtil.customHandle"
301
+ ></vxe-grid>
302
+ </div>
303
+ </div>
304
+ </div>
305
+ </div>
306
+ </div>
307
+ </template>
308
+ </baseTabPane>
309
+ </baseTabs>
310
+ </el-form>
311
+ <roleDialog v-if="showRoleDialog" :visiable.sync="showRoleDialog" @confirm="confirmRole"
312
+ :param="roleDialogParam"/>
313
+ <companyDialog v-if="showCompanyDialog" :visiable.sync="showCompanyDialog" @confirm="confirmInsertCompany"/>
314
+ <saleOrgDialog v-if="showSaleOrgDialog" :visiable.sync="showSaleOrgDialog" @confirm="confirmInsertSaleOrg"
315
+ :param="{ queryAll: true }"/>
316
+ <positionDialog v-if="showPositionDialog" :visiable.sync="showPositionDialog" :rows="positionDialogDatas"
317
+ @confirm="confirmInsertPosition" :param="{ queryAll: true }"/>
318
+ <countryDialog v-if="showCountryDialog" :visiable.sync="showCountryDialog"
319
+ @confirm="confirmCountry" multi="false"/>
320
+ </div>
321
+ </template>
322
+
323
+ <script>
324
+ import xeUtils from "xe-utils";
325
+ import tempStorageButton from "@base/components/tempStorage/index.vue";
326
+
327
+
328
+ export default {
329
+ name: 'UserEdit',
330
+ components: {
331
+ roleDialog: () => import('../../../views/user/role/dialog.vue'),
332
+ companyDialog: () => import('../../../views/user/company_info/dialog.vue'),
333
+ saleOrgDialog: () => import('../../../views/user/sale_org/dialog.vue'),
334
+ positionDialog: () => import('../../../views/user/position/dialog.vue'),
335
+ countryDialog: () => import('../../../views/user/country/dialog.vue'),
336
+ tempStorageButton
337
+ },
338
+ props: ['_dataId', 'userType', 'flag'],
339
+ data() {
340
+ var validatePass = (rule, value, callback) => {
341
+ const isPassRequired = !this.dataId;
342
+ if (isPassRequired && (value == '' || value == undefined)) {
343
+ callback(new Error(this.$t1('密码不能为空')));
344
+ } else {
345
+ callback();
346
+ }
347
+ this.$refs.editForm.validateField('rePassword');
348
+ };
349
+ var validatePass2 = (rule, value, callback) => {
350
+ const isPassRequired = !this.dataId;
351
+ const rePassword = value != undefined ? value : '';
352
+ const password = this.user.password != undefined ? this.user.password : '';
353
+
354
+ if (isPassRequired && rePassword == '') {
355
+ callback(new Error(this.$t1('确认密码不能为空')));
356
+ } else if (rePassword != password) {
357
+ callback(new Error(this.$t1('两次输入密码不一致!')));
358
+ } else {
359
+ callback();
360
+ }
361
+ };
362
+
363
+ return {
364
+ dataId: '',
365
+ hBtn: true,
366
+ user: {
367
+ userCompanyInfoDTOs: [],
368
+ userSaleOrgDTOs: [],
369
+ userRoleDTOs: [],
370
+ gender: null,
371
+ enabled: true,
372
+ userType: null,
373
+ countryName: null,
374
+ countryCode: null
375
+ },
376
+ vxeOption: {},
377
+ companyInfoOption: {},
378
+ userRoleOption: {},
379
+ showRoleDialog: false,
380
+ showCompanyDialog: false,
381
+ showSaleOrgDialog: false,
382
+ showPositionDialog: false,
383
+ saleOrgPositionIndex: 0,
384
+ passRules: [{validator: validatePass, trigger: 'blur', required: false}],
385
+ pass2Rules: [{validator: validatePass2, trigger: 'blur', required: false}],
386
+ activeName: 'first',
387
+ userCustomerListDTO: {
388
+ userCustomerDTOs: []
389
+ },
390
+ customerOption: {},
391
+ showCustomerDialog: false,
392
+ exportOption: {
393
+ prefix: USER_PREFIX,
394
+ title: this.$t1('用户'),
395
+ codes: ["USEREXCEL", "USERPDF", "USERPRINT", "USERHIPRINT"],
396
+ param: () => {
397
+ return [{id: this.dataId}];
398
+ }
399
+ },
400
+ showExtendedProperties: false,
401
+ radio1: '0',
402
+ companyInfo: {},
403
+ vxeOptionMap: {},
404
+ gridRoleDataMap: {},
405
+ gridSaleOrgDataMap: {},
406
+ distributorCode: 'distributor',
407
+ distributorRole: null,
408
+ outUserCodes: [],
409
+ roleDialogParam: {queryAll: true},
410
+ tempStorageOption: {
411
+ storageType: "user",
412
+ data: () => {
413
+ this.handleData();
414
+ return this.user;
415
+ },
416
+ chooseConfirm: (tempStorageData) => {
417
+ this.user = tempStorageData;
418
+ this.gridSaleOrgDataMap = xeUtils.groupBy(this.user.userSaleOrgDTOs, 'companyCode');
419
+ this.gridRoleDataMap = xeUtils.groupBy(this.user.userRoleDTOs, 'companyCode');
420
+ },
421
+ saveConfirm: () => {
422
+ }
423
+ },
424
+ showCountryDialog: false
425
+ };
426
+ },
427
+ computed: {
428
+ hasCurrentCompany() {
429
+ return this.user.userCompanyInfoDTOs.find(item => item.companyCode == this.companyInfo.companyCode) != null;
430
+ }
431
+ },
432
+ created() {
433
+ if (this._dataId && !isNaN(this._dataId)) this.dataId = this._dataId;
434
+ },
435
+ async mounted() {
436
+
437
+ // this.getEainsGroupDTO();
438
+ await this.initOutUserRoleCode();
439
+ await this.initDistributorRole();
440
+ this.getData();
441
+ this.getConpanyInfo()
442
+ },
443
+ methods: {
444
+ getData() {
445
+ if (this.dataId && !isNaN(this.dataId)) {
446
+ this.isEdit = true;
447
+ this.$commonHttp({
448
+ url: USER_PREFIX + `/user/get`,
449
+ method: `post`,
450
+ data: {
451
+ id: this.dataId
452
+ },
453
+ isLoading: true,
454
+ modalStrictly: true,
455
+ success: res => {
456
+ let user = res.objx || {};
457
+ user.userCompanyInfoDTOs = this.user.userCompanyInfoDTOs;
458
+ user.userSaleOrgDTOs = this.user.userSaleOrgDTOs;
459
+ user.userRoleDTOs = this.user.userRoleDTOs;
460
+ this.user = user;
461
+ this.user.password = '';
462
+
463
+ this.showExtendedProperties = true;
464
+ }
465
+ });
466
+ } else {
467
+ this.user.gender = 1;
468
+ this.isEdit = false;
469
+ this.showExtendedProperties = true;
470
+ }
471
+ },
472
+ saveData() {
473
+ let companyCode = this.companyInfo.companyCode;
474
+ this.handleData();
475
+ if (this.userType == 2) {
476
+ //外部用户
477
+ let currentUserCompanyInfo = this.user.userCompanyInfoDTOs.find(item => item.companyCode == companyCode)
478
+ if (currentUserCompanyInfo) {
479
+ let rows = this.user.userRoleDTOs.filter(item => item.companyCode == companyCode);
480
+ if (!rows.length) {
481
+ this.$baseAlert(this.$t1('请维护角色'));
482
+ return
483
+ }
484
+ }
485
+
486
+ }
487
+ this.$refs.editForm.$baseValidate(valid => {
488
+ if (valid) {
489
+ this.$baseConfirm(this.$t1('您确定要保存吗?')).then(() => {
490
+ var url = USER_PREFIX + (this.isEdit ? '/user/update' : '/user/save');
491
+ this.$http({
492
+ url: url,
493
+ method: `post`,
494
+ data: this.user,
495
+ isLoading: true,
496
+ success: res => {
497
+ this.$message({
498
+ message: res.content,
499
+ type: 'success',
500
+ duration: 500,
501
+ onClose: t => {
502
+ if (this.isEdit) {
503
+ this.$baseReload();
504
+ } else {
505
+ this.$baseReload({
506
+ updateParam: {
507
+ _dataId: res.objx
508
+ }
509
+ });
510
+ }
511
+ }
512
+ });
513
+ }
514
+ });
515
+ });
516
+ }
517
+ });
518
+ },
519
+ getSaleOrgData() {
520
+ if (this.dataId) {
521
+ this.$http({
522
+ url: USER_PREFIX + '/user/getUserSaleOrg',
523
+ method: `post`,
524
+ data: {id: this.dataId},
525
+ isLoading: true,
526
+ modalStrictly: true,
527
+ success: res => {
528
+ // this.$refs.saleOrgGrid.loadData(res.objx || []);
529
+ let rows = res.objx || [];
530
+ if (rows.length) {
531
+ // this.gridSaleOrgDataMap = xeUtils.groupBy(rows, 'companyCode');
532
+ Object.assign(this.gridSaleOrgDataMap, xeUtils.groupBy(rows, 'companyCode'));
533
+ }
534
+ this.user.userSaleOrgDTOs = rows;
535
+ }
536
+ });
537
+ }
538
+ },
539
+ getUserRoleData() {
540
+ if (this.dataId) {
541
+ this.$http({
542
+ url: USER_PREFIX + '/user/getUserRole',
543
+ method: `post`,
544
+ data: {id: this.dataId},
545
+ isLoading: true,
546
+ modalStrictly: true,
547
+ success: res => {
548
+ let rows = res.objx || [];
549
+ if (rows.length) {
550
+ // this.gridRoleDataMap = xeUtils.groupBy(rows, 'companyCode');
551
+ Object.assign(this.gridRoleDataMap, xeUtils.groupBy(rows, 'companyCode'));
552
+ }
553
+ this.user.userRoleDTOs = rows;
554
+ }
555
+ });
556
+ }
557
+ },
558
+ deleteSaleOrgItem(row, index, $table) {
559
+ $table.remove(row);
560
+ this.gridSaleOrgDataMap[row.companyCode].splice(index, 1);
561
+ },
562
+ getCompanyInfoData(callback) {
563
+ if (this.dataId) {
564
+ this.$http({
565
+ url: USER_PREFIX + '/user/getUserCompanyInfo',
566
+ method: `post`,
567
+ data: {id: this.dataId},
568
+ isLoading: true,
569
+ modalStrictly: true,
570
+ success: res => {
571
+ let rows = res.objx || [];
572
+ rows.forEach(row => {
573
+ this.gridRoleDataMap[row.companyCode] = [];
574
+ this.gridSaleOrgDataMap[row.companyCode] = [];
575
+ })
576
+ this.user.userCompanyInfoDTOs = rows;
577
+ callback && callback();
578
+ }
579
+ });
580
+ }
581
+ },
582
+ initSaleOrg(companyCode) {
583
+ if (this.vxeOptionMap['saleOrgGridOption-' + companyCode]) {
584
+ return;
585
+ }
586
+ let tableRef = 'saleOrgGrid-' + companyCode;
587
+ const tableOption = {
588
+ vue: this,
589
+ tableRef: tableRef,
590
+ tableName: 'editUser-saleOrgGrid-' + companyCode,
591
+ columns: [
592
+ {type: 'checkbox', fixed: 'left', width: 48, resizable: false},
593
+ {title: this.$t1('机构名称'), field: 'saleOrgName', width: 200},
594
+ {title: this.$t1('机构编码'), field: 'sn', width: 200},
595
+ {title: this.$t1('上级机构'), field: 'treePathName', width: 200},
596
+ {
597
+ title: this.$t1('岗位'),
598
+ field: 'position',
599
+ width: 150,
600
+ slots: {
601
+ default: 'position'
602
+ }
603
+ },
604
+ {
605
+ title: this.$t1('是否默认'),
606
+ field: 'defaults',
607
+ width: 120,
608
+ slots: {
609
+ default: ({row, $table, rowIndex}) => {
610
+ var isDefault = row.defaults || false;
611
+ let disabled = this.companyInfo.companyCode != row.companyCode;
612
+ return [
613
+ <el-checkbox
614
+ v-model={isDefault}
615
+ disabled={disabled}
616
+ onchange={() => {
617
+ this.gridSaleOrgDataMap[row.companyCode].forEach((item, index) => {
618
+ if (index !== rowIndex) {
619
+ item.defaults = false;
620
+ }
621
+ });
622
+ this.$nextTick(()=>{
623
+ row.defaults = true;
624
+ })
625
+ }}
626
+ />
627
+ ];
628
+ }
629
+ }
630
+ },
631
+ {
632
+ width: 47,
633
+ fixed: 'right',
634
+ title: '',
635
+ sortable: false,
636
+ slots: {
637
+ default: ({row, rowIndex, $table}) => {
638
+ if (this.companyInfo.companyCode == row.companyCode) {
639
+ return [
640
+ <a
641
+ href="javascript:void(0);"
642
+ class="a-link"
643
+ onclick={() => {
644
+ this.deleteSaleOrgItem(row, rowIndex, $table);
645
+ }}
646
+ >
647
+ <el-tooltip enterable={false} effect="dark" content={this.$t1('删除')} placement="top"
648
+ popper-class="tooltip-skin">
649
+ <i class="el-icon-delete"/>
650
+ </el-tooltip>
651
+ </a>
652
+ ];
653
+ }
654
+ }
655
+ }
656
+ }
657
+ ]
658
+ };
659
+ this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
660
+ // this.vxeOptionMap['saleOrgGridOption-'+companyCode] = opts;
661
+ this.$set(this.vxeOptionMap, 'saleOrgGridOption-' + companyCode, opts);
662
+ });
663
+
664
+ },
665
+ initUserRole(companyCode) {
666
+ if (this.vxeOptionMap['userRoleGridOption-' + companyCode]) {
667
+ return;
668
+ }
669
+ let userType = this.userType;
670
+ const tableOption = {
671
+ vue: this,
672
+ tableRef: 'userRoleGrid-' + companyCode,
673
+ tableName: 'editUser-userRoleGrid-' + companyCode,
674
+ columns: [
675
+ {type: 'checkbox', fixed: 'left', width: 48, resizable: false},
676
+ {
677
+ title: this.$t1('角色名称'),
678
+ field: 'name',
679
+ width: 200,
680
+ slots: {
681
+ default: ({row}) => {
682
+ if (!row.isAdd) {
683
+ return row.roleName;
684
+ } else {
685
+ return row.name;
686
+ }
687
+ }
688
+ }
689
+ },
690
+ {
691
+ width: 47,
692
+ fixed: 'right',
693
+ title: '',
694
+ sortable: false,
695
+ slots: {
696
+ default: ({row, rowIndex, $table}) => {
697
+ if (this.companyInfo.companyCode == row.companyCode) {
698
+ return [
699
+ <a
700
+ href="javascript:void(0);"
701
+ class="a-link"
702
+ onclick={() => {
703
+ this.deleteRoleItem(row, rowIndex, $table);
704
+ }}
705
+ >
706
+ <el-tooltip enterable={false} effect="dark" content={this.$t1('删除')} placement="top"
707
+ popper-class="tooltip-skin">
708
+ <i class="el-icon-delete"/>
709
+ </el-tooltip>
710
+ </a>
711
+ ];
712
+ }
713
+ }
714
+ }
715
+ }
716
+ ]
717
+ };
718
+ this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
719
+ // this.vxeOptionMap['userRoleGridOption-'+companyCode] = opts;
720
+ this.$set(this.vxeOptionMap, 'userRoleGridOption-' + companyCode, opts);
721
+ });
722
+ },
723
+ confirmRole(rows) {
724
+ if (rows.length > 0) {
725
+ let outUserCodes = this.outUserCodes;
726
+ if (this.userType === 1) {
727
+ //组织用户
728
+ rows = rows.filter(row => !outUserCodes.includes(row.code));
729
+ } else if (this.userType === 2) {
730
+ //外部用户
731
+ rows = rows.filter(row => outUserCodes.includes(row.code));
732
+ }
733
+ let companyCode = this.companyInfo.companyCode;
734
+ const $grid = this.$refs['userRoleGrid-' + companyCode][0];
735
+ const tableData = this.gridRoleDataMap[companyCode];
736
+ const map = {};
737
+ tableData.forEach(function (item) {
738
+ map[item.roleId] = 1;
739
+ });
740
+ var items = [];
741
+ rows.forEach(row => {
742
+ const item = {
743
+ roleId: row.id,
744
+ roleName: row.name,
745
+ companyCode: companyCode,
746
+ companyName: row.companyName
747
+ };
748
+ if (!map[item.roleId]) {
749
+ items.push(item);
750
+ }
751
+ });
752
+ // $grid.insertAt(items, -1);
753
+ // this.user.userRoleDTOs = this.user.userRoleDTOs.concat(items);
754
+ this.gridRoleDataMap[companyCode] = tableData.concat(items)
755
+ $grid.loadData(this.gridRoleDataMap[companyCode])
756
+ }
757
+ },
758
+ deleteRole(tableRef) {
759
+ this.$baseConfirm(this.$t1('您确定要删除吗?')).then(() => {
760
+ /*const $grid = this.$refs.userRoleGrid;
761
+ $grid.removeCheckboxRow();
762
+ this.user.userRoleDTOs = $grid.getTableData().fullData;*/
763
+ let companyCode = this.companyInfo.companyCode;
764
+ const $grid = this.$refs[tableRef][0];
765
+ $grid.removeCheckboxRow();
766
+ this.gridRoleDataMap[companyCode] = $grid.getTableData().fullData;
767
+
768
+ });
769
+ },
770
+ deleteRoleItem(row, index, $table) {
771
+ $table.remove(row);
772
+ this.gridRoleDataMap[row.companyCode].splice(index, 1);
773
+ },
774
+ confirmInsertCompany(rows, callback) {
775
+ if (rows.length > 0) {
776
+ const tableData = this.user.userCompanyInfoDTOs;
777
+ const map = {};
778
+ tableData.forEach(function (item) {
779
+ map[item.companyCode] = 1;
780
+ });
781
+ var items = [];
782
+ rows.forEach(row => {
783
+ const item = {companyCode: row.companyCode, companyName: row.companyName, guid: null, defaults: false};
784
+ if (!map[item.companyCode]) {
785
+ items.push(item);
786
+ }
787
+ this.gridRoleDataMap[item.companyCode] = []
788
+ this.gridSaleOrgDataMap[item.companyCode] = []
789
+ });
790
+ // $grid.insertAt(items, -1);
791
+ this.user.userCompanyInfoDTOs.splice(0, 0, ...items);
792
+ if (this.user.userCompanyInfoDTOs.length == 1) {
793
+ this.user.userCompanyInfoDTOs[0].defaults = true
794
+ }
795
+ // this.user.userCompanyInfoDTOs = this.user.userCompanyInfoDTOs.concat(items);
796
+ }
797
+ callback && callback();
798
+ },
799
+ deleteCompany(row, index) {
800
+ let companyCode = row.companyCode;
801
+ this.user.userCompanyInfoDTOs.splice(index, 1);
802
+ this.gridSaleOrgDataMap[row.companyCode] = [];
803
+ this.gridRoleDataMap[row.companyCode] = [];
804
+ this.user.userSaleOrgDTOs = this.user.userSaleOrgDTOs.filter(item => item.companyCode != companyCode);
805
+ this.user.userRoleDTOs = this.user.userRoleDTOs.filter(item => item.companyCode != companyCode);
806
+ },
807
+ confirmInsertSaleOrg(rows) {
808
+ if (rows.length > 0) {
809
+ let companyCode = this.companyInfo.companyCode;
810
+ const $grid = this.$refs['saleOrgGrid-' + companyCode][0];
811
+ const tableData = this.gridSaleOrgDataMap[companyCode] || [];
812
+ const map = {};
813
+ tableData.forEach(function (item) {
814
+ map[item.saleOrgId] = 1;
815
+ });
816
+
817
+ let roleMap = {};
818
+ let newUserRoleDTOs = [];
819
+ var items = [];
820
+
821
+ rows.forEach((row, index) => {
822
+ const item = {
823
+ companyCode: companyCode,
824
+ companyName: row.companyName,
825
+ defaults: false,
826
+ saleOrgName: row.name,
827
+ treePathName: row.treePathName,
828
+ userSaleOrgPositionDTOs: [],
829
+ saleOrgId: row.id,
830
+ sn: row.sn
831
+ };
832
+
833
+ if (!map[item.saleOrgId]) {
834
+ items.push(item);
835
+ if (row.roleId && !roleMap[row.roleId]) {
836
+ const roleItem = {
837
+ id: row.roleId,
838
+ name: row.roleName,
839
+ companyCode: companyCode,
840
+ companyName: row.companyName
841
+ };
842
+ roleMap[row.roleId] = true;
843
+ newUserRoleDTOs.push(roleItem);
844
+ }
845
+ }
846
+ });
847
+ if (items.length > 0 && tableData.length == 0) {
848
+ items[0].defaults = true;
849
+ }
850
+ // this.user.userSaleOrgDTOs.push(...items);
851
+ this.gridSaleOrgDataMap[companyCode] = tableData.concat(items)
852
+ $grid.loadData(this.gridSaleOrgDataMap[companyCode])
853
+ this.confirmRole(newUserRoleDTOs);
854
+ }
855
+ },
856
+ openSelectPositionDialog(row, rowIndex, $table) {
857
+ const userSaleOrgPositionDTOs = row.userSaleOrgPositionDTOs || [];
858
+ const items = [];
859
+ userSaleOrgPositionDTOs.forEach(userSaleOrgPositionDTO => {
860
+ const item = {
861
+ companyCode: userSaleOrgPositionDTO.companyCode,
862
+ companyName: userSaleOrgPositionDTO.companyName,
863
+ name: userSaleOrgPositionDTO.positionName,
864
+ code: userSaleOrgPositionDTO.code,
865
+ id: userSaleOrgPositionDTO.positionId
866
+ };
867
+ items.push(item);
868
+ });
869
+
870
+ this.positionDialogDatas = items;
871
+ this.saleOrgPositionIndex = rowIndex;
872
+ this.showPositionDialog = true;
873
+ },
874
+ confirmInsertPosition(rows) {
875
+ let companyCode = this.companyInfo.companyCode;
876
+ const saleOrgPositionIndex = this.saleOrgPositionIndex;
877
+ const tableData = this.gridSaleOrgDataMap[companyCode];
878
+ if (rows.length > 0) {
879
+ const oldPositions = tableData[saleOrgPositionIndex].userSaleOrgPositionDTOs || [];
880
+ const map = {};
881
+ oldPositions.forEach(function (item) {
882
+ map[item.positionId] = item;
883
+ });
884
+ var oItems = [];
885
+ var items = [];
886
+ rows.forEach(row => {
887
+ const item = {
888
+ companyCode: row.companyCode,
889
+ companyName: row.companyName,
890
+ positionName: row.name,
891
+ code: row.code,
892
+ positionId: row.id
893
+ };
894
+
895
+ if (!map[item.positionId]) {
896
+ items.push(item);
897
+ } else {
898
+ oItems.push(map[item.positionId]);
899
+ }
900
+ });
901
+ tableData[saleOrgPositionIndex].userSaleOrgPositionDTOs = oItems.concat(items);
902
+ } else {
903
+ tableData[saleOrgPositionIndex].userSaleOrgPositionDTOs = [];
904
+ }
905
+ this.$forceUpdate();
906
+ },
907
+ getSelectPositionName(row) {
908
+ var userSaleOrgPositions = row.userSaleOrgPositionDTOs || [];
909
+ var allName = '';
910
+ userSaleOrgPositions.forEach(function (pItem, pIndex) {
911
+ allName = allName + ',' + pItem.positionName;
912
+ });
913
+ if (allName) {
914
+ allName = allName.substr(1);
915
+ }
916
+ return allName;
917
+ },
918
+ getConpanyInfo() {
919
+ this.$http({
920
+ url: USER_PREFIX + '/company_info/getCurrent',
921
+ method: `post`,
922
+ isLoading: true,
923
+ success: res => {
924
+ this.companyInfo = res.objx || {};
925
+ let companyCode = this.companyInfo.companyCode;
926
+ if (!this.isEdit) {
927
+ this.addCurrentCompany();
928
+ } else {
929
+ this.getCompanyInfoData(() => {
930
+ this.getUserRoleData();
931
+ this.getSaleOrgData();
932
+ setTimeout(() => {
933
+ this.user.userCompanyInfoDTOs.forEach(userCompanyInfoDTO => {
934
+ this.initSaleOrg(userCompanyInfoDTO.companyCode);
935
+ this.initUserRole(userCompanyInfoDTO.companyCode);
936
+ })
937
+ }, 100)
938
+ });
939
+ }
940
+ }
941
+ });
942
+ },
943
+ isCurrentCompany(companyCode) {
944
+ return this.companyInfo.companyCode == companyCode;
945
+ },
946
+ addCurrentCompany(callback) {
947
+ this.confirmInsertCompany([this.companyInfo], callback);
948
+ setTimeout(() => {
949
+ this.initSaleOrg(this.companyInfo.companyCode);
950
+ this.initUserRole(this.companyInfo.companyCode);
951
+ setTimeout(() => {
952
+ if (this.userType === 2) {
953
+ //经销商
954
+ if (this.distributorRole) {
955
+ this.confirmRole([this.distributorRole]);
956
+ }
957
+ }
958
+ }, 100)
959
+ }, 100)
960
+
961
+
962
+ },
963
+ handleData() {
964
+ let saleOrgs = [];
965
+ Object.keys(this.gridSaleOrgDataMap).forEach(companyCode => {
966
+ saleOrgs.push(...this.gridSaleOrgDataMap[companyCode])
967
+ });
968
+ let roles = [];
969
+ Object.keys(this.gridRoleDataMap).forEach(companyCode => {
970
+ roles.push(...this.gridRoleDataMap[companyCode])
971
+ });
972
+ this.user.userRoleDTOs = roles;
973
+ this.user.userSaleOrgDTOs = saleOrgs
974
+ },
975
+ initDistributorRole() {
976
+ if (this.outUserCodes && this.outUserCodes.length == 1) {
977
+ return this.$http({
978
+ url: USER_PREFIX + '/role/list',
979
+ method: 'post',
980
+ success: res => {
981
+ let roleList = res.objx || [];
982
+ let distributorCode = this.outUserCodes[0];
983
+ this.distributorRole = roleList.find(item => item.code == distributorCode);
984
+ }
985
+ });
986
+ }
987
+ },
988
+ async initOutUserRoleCode() {
989
+ //初始化外部用户编码
990
+ return this.$http({
991
+ url: USER_PREFIX + '/system_parameter/getByCode',
992
+ method: 'post',
993
+ data: {"code": "outUserRoleCode"},
994
+ success: res => {
995
+ let value = (!res.objx || !res.objx.value) ? "distributor" : res.objx.value;
996
+ let codes = value.split(',');
997
+ this.outUserCodes = codes;//外部用户编码
998
+ this.initRoleDialogParam();//初始化角色弹框的查询参数
999
+ }
1000
+ });
1001
+ },
1002
+ initRoleDialogParam() {
1003
+ //初始化角色弹框的查询参数
1004
+ if (this.userType == 1) {
1005
+ //组织用户
1006
+ this.roleDialogParam = {
1007
+ queryAll: true,
1008
+ neCodes: [...this.outUserCodes]
1009
+ };
1010
+ } else if (this.userType == 2) {
1011
+ //外部用户
1012
+ this.roleDialogParam = {
1013
+ queryAll: true,
1014
+ eqCodes: [...this.outUserCodes]
1015
+ };
1016
+ }
1017
+ },
1018
+ unlock() {
1019
+ this.$baseConfirm(this.$t1('您确定要解锁吗?')).then(() => {
1020
+ var url = USER_PREFIX + '/user/unlockLoginAccount';
1021
+ this.$http({
1022
+ url: url,
1023
+ method: `post`,
1024
+ data: {
1025
+ id: this.user.id
1026
+ },
1027
+ isLoading: true,
1028
+ success: res => {
1029
+ this.$message({
1030
+ message: res.content,
1031
+ type: 'success',
1032
+ duration: 500,
1033
+ onClose: t => {
1034
+ this.$baseReload();
1035
+ }
1036
+ });
1037
+ }
1038
+ });
1039
+ });
1040
+ },
1041
+ confirmCountry(rows) {
1042
+ if (rows.length) {
1043
+ let row = rows[0];
1044
+ this.user.countryName = row.countryName;
1045
+ this.user.countryCode = row.countryCode;
1046
+ }
1047
+ },
1048
+ changeCompanyDefault(item) {
1049
+ let companyCode = item.companyCode
1050
+ if (item.defaults) {
1051
+ this.user.userCompanyInfoDTOs.forEach(row => {
1052
+ row.defaults = row.companyCode == companyCode;
1053
+ })
1054
+ }
1055
+
1056
+ }
1057
+ }
1058
+ };
1059
+ </script>