cloud-web-corejs 1.0.96 → 1.0.98

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.
@@ -1,1041 +1,1041 @@
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>
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>