CommonJurisdictionNewEvent.js
33.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
/* eslint-disable array-callback-return,no-undef,prefer-destructuring */
import React, { Component } from 'react';
import { Modal, message } from 'antd';
import * as commonConfig from '../../utils/config';
import * as commonBusiness from './commonBusiness'; /* 单据业务功能 */
import * as commonUtils from '../../utils/utils'; /* 通用方法 */
import * as commonServices from './../../services/services';
import * as commonFunc from './commonFunc'; /* 服务类 */
const { confirm } = Modal;
export default (ChildComponent) => {
return class extends Component {
constructor(props) {
super(props);
this.state = {};
this.form = {};
/* 表单对象 */
}
componentWillReceiveProps(nextProps) {
const {
formData, currentId, groupConfig, treeData, formRoute,
} = nextProps;
let { bReceived } = nextProps;
const sId = currentId !== undefined ? currentId : '';
if (commonUtils.isEmptyObject(groupConfig) && bReceived === undefined) {
const masterConfig = formData.filter(item => !item.bGrd)[0];
this.handleGetChangeData({ name: 'tree' }, 'SysjurisdictionTree');
bReceived = true;
const group = this.initColumnConfig('group', [
this.imitateTableColumn('序号', 'iOrder', 'iOrder', 60),
this.imitateTableColumn('权限组', 'sName', 'sId', 350)]);
const userGroup = this.initColumnConfig('userGroup', [
this.imitateTableColumn('序号', 'iOrder', 'iOrder', 60),
this.imitateTableColumn('组成员', 'sUserName', 'sUsersId', 350)]);
const user = this.initColumnConfig('userView', [
this.imitateTableColumn('序号', 'iOrder', 'iOrder', 60),
this.imitateTableColumn('用户', 'sUserName', 'sId', 120),
this.imitateTableColumn('权限组', 'sGroupName', 'sGroupName', 350)]);
const groupUser = this.imitateTableColumnConfig('groupUser', [this.imitateTableColumn('所属分组', 'sGroupName', 'sGroupsId')]);
const checkedNodes = this.imitateTableColumnConfig('checkedNodes', [this.imitateTableColumn('名称', 'showName', 'sId')]);
const tree = this.imitateTableColumnConfig('tree', [this.imitateTableColumn('名称', 'showName', 'key')]);
const search = this.imitateTableColumnConfig('search', [this.imitateTableColumn('名称', 'showName', 'sAllId', 300)]);
let treeKeyName = 'key';
if (formRoute === '/indexPage/systemPermission') {
treeKeyName = 'sId';
}
this.props.onSaveState({
masterConfig,
sId,
bReceived,
treeKeyName,
showLine: false,
// pageLoading: false,
...tree,
...group,
...user,
...userGroup,
...groupUser,
...checkedNodes,
...search,
});
}
if (commonUtils.isNotEmptyArr(treeData) && bReceived) {
this.handleGetChangeData({ name: 'group' }, 'GroupData');
this.handleGetChangeData({ name: 'userView' }, 'UserData');
this.props.onSaveState({
bReceived: false,
pageLoading: false,
});
}
}
shouldComponentUpdate(nextProps, nextState) {
let flag = true;
/* 追加弹出框数值回填放行判断ppopupPane */
if (nextProps.sTabId === nextProps.app.currentPane.key || ((nextProps.app.ppopupPane !== undefined
&& nextProps.app.ppopupPane.mainConfig !== undefined)
? nextProps.sTabId === nextProps.app.ppopupPane.mainConfig.key : false)) {
if (nextState.disabled !== this.state.disabled) {
return true;
}
flag = true;
} else {
flag = false;
}
return flag;
}
componentWillUpdate(nextProps) {
const { masterData, sModelsType, elemachineData } = nextProps;
if (sModelsType === 'element/teamInfo' && masterData !== undefined) {
if (commonUtils.isNotEmptyObject(elemachineData)) {
elemachineData.forEach((row, index) => {
if (row.sMachineId === masterData.sMachineId) {
elemachineData[index].bDefault = true;
} else {
elemachineData[index].bDefault = false;
}
});
}
}
}
/** 表单回带 */
handleForm = (form) => {
this.form = form;
};
/** 主表控件是否全部显示 */
handleToggle = () => {
const { expand } = this.props;
this.props.onSaveState({ expand: !expand });
};
handleValidateSave = async () => {
const {
token, sModelsId, sJurisdictionClassifyId, sUserId, treeAllNodes, treeCheckedKeys = [], treeAllCheckKeys,
app,
} = this.props;
const value = {};
if ((commonUtils.isEmptyArr(sJurisdictionClassifyId) && commonUtils.isEmptyArr(sUserId))) {
message.warn(commonFunc.showMessage(app.commonConst, 'NotEmptyJurisdictionGroup'));/* 组员,所属或权限组不能为空! */
this.props.onSaveState({
loading: false,
});
return;
}
if (commonUtils.isNotEmptyArr(sJurisdictionClassifyId) && commonUtils.isEmptyArr(sUserId)) {
value.sJurisdictionClassifyId = sJurisdictionClassifyId[0];
} else if (commonUtils.isNotEmptyArr(sUserId) && commonUtils.isEmptyArr(sJurisdictionClassifyId)) {
value.sUserId = sUserId[0];
} else {
message.warn(commonFunc.showMessage(app.commonConst, 'NotEmptyGroup'));/* 组或者组员不能为空 */
this.props.onSaveState({
loading: false,
});
return;
}
/*
if (commonUtils.isNotEmptyArr(treeCheckedKeys) && treeCheckedKeys.length === treeAllCheckKeys.length) {
message.warn('请选择不需要的权限!');
return;
}
*/
const newCheckedKeys = []; /* 所有选中节点 */
const saveData = [];
// 取 选中数据 用-分割后的最后一个值
const treeCheckedKeysNew = treeCheckedKeys.map((item) => {
const list = item.split('-');
return list[list.length - 1];
});
treeAllCheckKeys.forEach((key) => {
const iIndex = treeCheckedKeysNew.indexOf(key);
if (iIndex > -1) {
newCheckedKeys.push(key);
}
});
newCheckedKeys.forEach((key) => {
const nodes = treeAllNodes.get(key);
saveData.push({
sId: nodes.sId,
sParentId: nodes.sParentId,
// sKey: nodes[`${skeyName}`],
sKey: nodes.key,
sName: commonUtils.isNotEmptyObject(nodes) && commonUtils.isNotEmptyObject(nodes.sName) ? nodes.sName : '',
sAction: commonUtils.isNotEmptyObject(nodes) && commonUtils.isNotEmptyObject(nodes.sAction) ? nodes.sAction : '',
showName: nodes.showName,
});
});
value.data = saveData;
value.sTreeAllKet = treeAllCheckKeys;
const dataUrl = `${commonConfig.server_host}/sysjurisdictionNew/addSysjurisdictionNew?sModelsId=${sModelsId}`;
const dataReturn = (await commonServices.postValueService(token, value, dataUrl)).data;
/* 成功的话返回数据 */
if (dataReturn.code === 1) { /* 成功 */
message.success(dataReturn.msg);
this.props.onSaveState({ enabled: false, loading: false });
return dataReturn;
} else { /* 失败 */
this.props.getServiceError(dataReturn);
this.props.onSaveState({
loading: false,
});
return false;
}
}
/** 点击修改按钮操作 */
handleEdit = () => {
this.props.onSaveState({ enabled: true, loading: false });
}
handleCancel = (obj) => {
// const { groupUserData } = this.props;
// const onGetChangeData = this.handleGetChangeData;
const onSaveStateOk = this.props.onSaveState;
confirm({
title: obj.title,
onOk() {
// const sId = commonUtils.isNotEmptyArr(groupUserData) && groupUserData.length > 0 ? groupUserData[0].sId : '';
onSaveStateOk({ enabled: false });
// onGetChangeData({ name: 'authority', sId }, 'GroupAuthority');
},
onCancel() {
},
});
}
handleGetSisformulaData = (masterConfig) => {
this.handleGetSlaveData('One', null, masterConfig);
}
handleGetSlaveData = (getType, sName, currConfig) => {
const { currentId } = this.props;
/* 当前页签数据 */
const sId = currentId !== undefined ? currentId : '';
if (getType === 'One') {
this.props.handleGetDataOne({
name: 'master', configData: currConfig, condition: { sId, pageSize: '', pageNum: '' },
});
}
if (getType === 'Set') {
this.props.handleGetDataSet({
name: sName, configData: currConfig, condition: { sSqlCondition: { sParentId: sId } },
});
}
}
/* 获取分组列表
yw_权限分配
获取分组列表
获取人员列表
qx_获取权限树
qx_根据组sId获取已选择权限
qx_根据人sId获取已选择权限
qx_根据组sId获取组人员
根据人员sId获取所属分组
保存组已选权限
* */
handleGetChangeData = async (params, urlKey) => {
const { app, sModelsId } = this.props;
const { token } = app;
const { name, sId, treeComponentName } = params; // name,
let dataUrl = '';
if (urlKey === 'SysjurisdictionTree') { // 树结构
dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getSysjurisdictionTreeNew?sModelsId=${sModelsId}`;
} else if (urlKey === 'GroupData') { // 组
dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getGroupDataNew?sModelsId=${sModelsId}`;
} else if (urlKey === 'UserData') { // 用户
dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getUserDataNew?sModelsId=${sModelsId}`;
} else if (urlKey === 'UserGroupId') { // 组成员
if (commonUtils.isNotEmptyObject(sId)) {
dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getsUserGroupIdNew/${sId}?sModelsId=${sModelsId}`;
}
} else if (urlKey === 'GroupAuthority') { // 组权限
if (commonUtils.isNotEmptyObject(sId)) {
dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getHaveAuthorityGroupIdNew/${sId}?sModelsId=${sModelsId}`;
}
} else if (urlKey === 'UserAuthority') { // 用户所有权限查询 :用户权限,组权限
if (commonUtils.isNotEmptyObject(sId)) {
dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getHaveAuthorityUserIdNew/${sId}?sModelsId=${sModelsId}`;
}
}
if (commonUtils.isNotEmptyObject(dataUrl)) {
const dataReturn = (await commonServices.getService(token, dataUrl)).data;
if (commonUtils.isNotEmptyObject(dataReturn) && dataReturn.code === 1) {
const returnData = dataReturn.dataset.rows;
let addState = {};
if (urlKey === 'SysjurisdictionTree') { // 树结构
const allInitArr = [];
const allInitMap = new Map();
this.handleAllCheckKeys(allInitArr, allInitMap, returnData);
this.props.onSaveState({ [`${name}Data`]: returnData, treeAllCheckKeys: allInitArr, treeAllNodes: allInitMap });
} else if (urlKey === 'GroupData') { // 获取组后默认查询组权限,以及组成员
this.props.onSaveState({ [`${name}Data`]: returnData });
if (commonUtils.isNotEmptyArr(returnData)) {
this.handleTableSelectRowChange('group', [returnData[0].sId]); // 查询第一组成员
}
} else if (urlKey === 'UserData') { // 获取成员后默认 成员自己的权限,以及成员所属组
this.props.onSaveState({ [`${name}Data`]: returnData });
// if (commonUtils.isNotEmptyArr(returnData)) {
// this.handleGetChangeData({ name: 'groupUser', sId: returnData[0].sId }, 'GroupUserId'); // 查询第一个成员归属组
// }
} else if (urlKey === 'GroupAuthority' || urlKey === 'UserAuthority') {
let groupAuth = '';
let groupAuthData = [];
if (commonUtils.isNotEmptyArr(returnData)) {
if (commonUtils.isNotEmptyObject(returnData[0])) {
groupAuth = commonUtils.isNotEmptyObject(returnData[0]) ? returnData[0].sKeys : [];
groupAuthData = commonUtils.isNotEmptyObject(groupAuth) ? groupAuth.split(',') : [];
}
}
addState = this.handleCheckedNodeForFunction(treeComponentName, groupAuthData);
this.props.onSaveState({
[`${name}Data`]: returnData, userAuth: undefined, sJurisdictionClassifyId: sId, sUserId: undefined, ...addState,
});
} else if (false && urlKey === 'UserAuthority') {
let gAuth = '';
let groupAuthData = [];
let uAuth = '';
let userAuthData = [];
if (commonUtils.isNotEmptyArr(returnData)) {
if (commonUtils.isNotEmptyObject(returnData[0])) {
const { groupAuth, userAuth } = returnData[0];
if (commonUtils.isNotEmptyObject(groupAuth)) {
gAuth = groupAuth.sKeys;
groupAuthData = gAuth.split(',');
}
if (commonUtils.isNotEmptyObject(userAuth)) {
uAuth = userAuth.sKeys;
userAuthData = uAuth.split(',');
}
}
}
addState = this.handleGroupForFunction(treeComponentName, groupAuthData, userAuthData);
this.props.onSaveState({
[`${name}Data`]: returnData, userAuthData, sJurisdictionClassifyId: undefined, sUserId: sId, ...addState,
});
} else {
this.props.onSaveState({ [`${name}Data`]: returnData });
}
} else {
this.props.getServiceError(dataReturn);
}
}
}
// 模拟 列
imitateTableColumn = (title, dataIndex, key, width) => {
return {
title, dataIndex, key, width,
};
}
// 模拟config的 gdsconfigformslave 配置
imitateTableConfig = (title, dataIndex, width) => {
return {
bCanInput: false,
bFilter: false,
bFind: false,
bFirstEmpty: false,
bIsOther: false,
bNewRecord: false,
bNotEmpty: false,
bNotRepeat: false,
bReadonly: true,
bSum: false,
bTree: false,
bVisible: true,
iColValue: 1,
iFitWidth: width,
sBrandsId: '1111111111',
sChinese: title,
sChineseDropDown: '',
sControlName: 'BtnLast',
sId: commonUtils.createSid(),
sParentId: '11811781131121915102156308120',
sSubsidiaryId: '1111111111',
showName: title,
sName: dataIndex,
};
}
// 根据模拟列,模拟列配置
imitateTableColumnConfig = (name, columns) => {
const gdsconfigformslave = [];
columns.forEach((itmes) => {
gdsconfigformslave.push(this.imitateTableConfig(itmes.title, itmes.dataIndex, itmes.width));
});
const config = { bGrd: true, gdsconfigformslave };
return { [`${name}Column`]: columns, [`${name}Config`]: config };
}
initColumnConfig = (name, columns) => {
const gdsconfigformslave = [];
columns.forEach((itmes) => {
gdsconfigformslave.push(this.imitateTableConfig(itmes.title, itmes.dataIndex, itmes.width));
});
const config = { bGrd: true, gdsconfigformslave };
const newColumns = commonFunc.getHeaderConfig(config);
return { [`${name}Column`]: newColumns, [`${name}Config`]: config };
}
/** 处理选择行发生改变 */
handleTableSelectRowChange = (name, selectedRowKeys) => {
const addState = {};
if (name === 'group') {
this.handleGetChangeData({ name: 'userGroup', sId: selectedRowKeys }, 'UserGroupId');
this.handleGetChangeData({ name: 'master', sId: selectedRowKeys, treeComponentName: 'tree' }, 'GroupAuthority');
addState.groupSelectedRowKeys = selectedRowKeys;
} else if (name === 'userView') {
// this.handleGetChangeData({ name: 'groupUser', sId: selectedRowKeys }, 'GroupUserId');
this.handleGetChangeData({ name: 'master', sId: selectedRowKeys, treeComponentName: 'tree' }, 'UserAuthority');
addState.userViewSelectedRowKeys = selectedRowKeys;
} else if (name === 'userGroup') {
this.handleGetChangeData({ name: 'master', sId: selectedRowKeys, treeComponentName: 'tree' }, 'UserAuthority');
addState.userGroupSelectedRowKeys = selectedRowKeys;
} else if (name === 'groupUser') {
this.handleGetChangeData({ name: 'master', sId: selectedRowKeys, treeComponentName: 'tree' }, 'GroupAuthority');
addState.groupUserSelectedRowKeys = selectedRowKeys;
}
this.props.onSaveState({ ...addState });
}
handleCheckBoxCheck = (componentName, checkedKeys) => {
this.handleCheckedForFunction(componentName, checkedKeys);
}
/* 选择权限同时处理保存的数据以及将要展现的已选择权限 */
handleCheckedForFunction = (componentName, checkedKeys) => {
const {
treeAllNodes,
} = this.props;
const data = [];
const checkedData = [];
if (commonUtils.isNotEmptyArr(treeAllNodes) && treeAllNodes.size > 0) {
const newCheckedKeys = [];
if (commonUtils.isNotEmptyArr(checkedKeys) && checkedKeys[0] !== null) {
checkedKeys.forEach((key, i) => {
if (checkedKeys.indexOf(key) === i) {
newCheckedKeys.push(key);
}
});
newCheckedKeys.forEach((key) => {
const nodes = treeAllNodes.get(key);
if (commonUtils.isNotEmptyObject(nodes)) {
checkedData.push({ sId: nodes.sId, showName: nodes.showName });
}
});
}
this.props.onSaveState({
[`${componentName}CheckedKeys`]: newCheckedKeys,
treeSaveParams: data,
checkedNodesData: checkedData,
});
}
}
/* 拿接口返回的节点进行选中 */
handleCheckedNodeForFunction = (componentName, haveCheckedKeys) => {
// eslint-disable-next-line no-unused-vars
const { treeAllNodes, treeAllCheckKeys } = this.props;
const addState = {};
const checkedData = [];
let checkKeys = [];
checkKeys = haveCheckedKeys;
// if (commonUtils.isNotEmptyArr(unCheckedKeys)) {
// for (const checkId of unCheckedKeys) {
// treeAllCheckKeys.forEach((key) => {
// if (checkId.includes(key)) {
// checkKeys.forEach((item, index) => {
// if (item === key) {
// checkKeys.splice(index, 1);
// }
// });
// }
// });
// }
// }
checkKeys.forEach((key) => {
const nodes = treeAllNodes.get(key);
if (commonUtils.isNotEmptyObject(nodes)) {
checkedData.push({ sId: nodes.sId, showName: nodes.showName });
}
});
addState[`${componentName}CheckedKeys`] = checkKeys;
addState.checkedNodesData = checkedData;
addState.disabledCheckedKeys = [];
return addState;
}
handleUnCheckedForFunction = (componentName, unCheckedKeys) => {
const { treeAllNodes, treeAllCheckKeys } = this.props;
const addState = {};
const checkedData = [];
let checkKeys = [];
checkKeys = checkKeys.concat(treeAllCheckKeys);
if (commonUtils.isNotEmptyArr(unCheckedKeys)) {
for (const checkId of unCheckedKeys) {
treeAllCheckKeys.forEach((key) => {
if (checkId.includes(key)) {
checkKeys.forEach((item, index) => {
if (item === key) {
checkKeys.splice(index, 1);
}
});
}
});
}
}
checkKeys.forEach((key) => {
const nodes = treeAllNodes.get(key);
if (commonUtils.isNotEmptyObject(nodes)) {
checkedData.push({ sId: nodes.sId, showName: nodes.showName });
}
});
addState[`${componentName}CheckedKeys`] = checkKeys;
addState.checkedNodesData = checkedData;
addState.disabledCheckedKeys = [];
return addState;
}
handleGroupForFunction = (treeComponentName, groupAuthData, userAuthData) => {
const { treeAllNodes, treeAllCheckKeys } = this.props;
const addState = {};
const checkedData = [];
let checkKeys = [];
let userAuthDataNew = [];
checkKeys = checkKeys.concat(treeAllCheckKeys);
if (commonUtils.isEmptyArr(userAuthData)) { /* 只有组权限 没有用户权限时 */
userAuthDataNew = JSON.parse(JSON.stringify(groupAuthData)); /* 深拷贝 */
userAuthData = userAuthDataNew;
}
if (commonUtils.isNotEmptyArr(userAuthData)) {
treeAllCheckKeys.forEach((key) => {
for (const checkId of userAuthData) {
if (checkId.includes(key)) {
checkKeys.forEach((item, index) => {
if (item === key) {
checkKeys.splice(index, 1);
}
});
}
}
});
checkKeys.forEach((key) => {
const nodes = treeAllNodes.get(key);
if (commonUtils.isNotEmptyObject(nodes)) {
checkedData.push({ sId: nodes.sId, showName: nodes.showName });
}
});
}
let groupCheckKeys = [];
if (commonUtils.isNotEmptyArr(groupAuthData)) {
groupCheckKeys = groupCheckKeys.concat(treeAllCheckKeys);
treeAllCheckKeys.forEach((key) => {
for (const checkId of groupAuthData) {
if (checkId === key) {
groupCheckKeys.splice(groupCheckKeys.indexOf(key), 1);
}
}
});
} else {
groupCheckKeys = treeAllCheckKeys; /* 组权限没有 */
}
addState[`${treeComponentName}CheckedKeys`] = checkKeys.concat(groupCheckKeys);
addState.checkedNodesData = checkedData;
addState.disabledCheckedKeys = groupCheckKeys;
return addState;
};
handleAllCheckKeys = (arrObj, mapObj, returnData) => {
const { treeKeyName } = this.props;
returnData.forEach((item) => {
if (commonUtils.isNotEmptyArr(item.children) && item.children.length > 0) {
arrObj.push(item[`${treeKeyName}`]);
mapObj.set(item[`${treeKeyName}`], item);
this.handleAllCheckKeys(arrObj, mapObj, item.children);
} else {
arrObj.push(item[`${treeKeyName}`]);
mapObj.set(item[`${treeKeyName}`], item);
}
});
};
handleRefresh = () => {
this.handleGetChangeData({ name: 'tree' }, 'SysjurisdictionTree');
this.handleGetChangeData({ name: 'group' }, 'GroupData');
this.handleGetChangeData({ name: 'user' }, 'UserData');
this.props.onSaveState({
treeAllCheckKeys: undefined,
treeAllNodes: undefined,
});
}
handleSearch = async (sSearchValue) => {
const { sModelsId } = this.props;
const url = `${commonConfig.server_host}gdsmodule/getGdsmoduleList?sModelsId=${sModelsId}&sName=${sSearchValue}`;
const dataReturn = (await commonServices.getService(this.props.app.token, url)).data;
if (dataReturn.code === 1) {
/* 数据查询成功 */
this.props.onSaveState({ searchData: dataReturn.dataset.rows });
} else { /* 失败 */
this.props.getServiceError(dataReturn);
}
}
handleSetTreeOptionData = (name, optionName, value) => {
this.props.onSaveState({ [`${name}${optionName}Keys`]: value });
}
handleSearchTable = async (searchValue, type) => {
const { token, sModelsId } = this.props;
let dataUrl = '';
if (commonUtils.isNotEmptyObject(type)) {
if (type === 'group') {
/* 组权限 */
dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getGroupDataNew?sSearchName=${searchValue}&sModelsId=${sModelsId}`;
} else if (type === 'userView') { /* 用户权限 */
dataUrl = `${commonConfig.server_host}sysjurisdictionNew/getUserDataNew?sSearchName=${searchValue}&sModelsId=${sModelsId}`;
}
if (commonUtils.isNotEmptyObject(dataUrl)) {
const dataReturn = (await commonServices.getService(token, dataUrl)).data;
if (dataReturn.code === 1) {
const returnData = dataReturn.dataset.rows;
if (commonUtils.isNotEmptyArr(type)) {
this.props.onSaveState({ [`${type}Data`]: returnData });
}
}
}
}
}
/* 查询组权限 */
handleSearchGroup = async (searchValue) => {
this.handleSearchTable(searchValue, 'group');
}
/* 查询用户权限 */
handleSearchUser = async (searchValue) => {
this.handleSearchTable(searchValue, 'userView');
}
/** 按钮操作事件 */
handleButtonClick = (name, isFresh) => {
if (name.includes('BtnRepairGroup')) {
const { sJurisdictionClassifyId } = this.props;
if (commonUtils.isNotEmptyArr(sJurisdictionClassifyId)) {
const filterData = this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name));
const btnConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : {};// sButtonEnabled sButtonParam
console.log(333, btnConfig);
if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
/* 找到组配置 */
const sToGroupConfig = this.props.masterConfig.gdsconfigformslave.filter(item => item.sName === 'sCopyToGroupName');
console.log(332, sToGroupConfig);
if (commonUtils.isNotEmptyArr(sToGroupConfig)) {
this.props.onSaveState({ groupModalVisible: true, sToGroupConfig, sGroupId: sJurisdictionClassifyId }); /* 打开复制从窗体sJurisdictionClassifyId */
}
}
} else {
message.error('请选择组权限');
}
} else if (name.includes('BtnRepairUser')) {
const { userViewSelectedRowKeys } = this.props;
if (commonUtils.isNotEmptyArr(userViewSelectedRowKeys)) {
const filterData = this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name));
const btnConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : {};// sButtonEnabled sButtonParam
console.log(filterData, filterData);
if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
/* 找到组配置 */
const sToUserConfig = this.props.masterConfig.gdsconfigformslave.filter(item => item.sName === 'sCopyToUserName');
console.log(332, sToUserConfig);
if (commonUtils.isNotEmptyArr(sToUserConfig)) {
this.props.onSaveState({ userModalVisible: true, sToUserConfig });
}
}
} else {
message.error('请选择用户权限');
}
} else if (name === 'BtnOut') {
this.handleOut();
} else if (name === 'BtnDesignFunction') {
this.handleDesignFunction();
} else if (name === 'BtnRefresh') {
const {
slaveConfig, slavePagination, slaveFilterCondition, slaveOrderBy,
} = this.props;
this.props.onSaveState({
clearArray: [], searchText: '', slaveSelectedRowKeys: [], slaveSelectedData: [], slaveInfoSelectedRowKeys: [], slaveInfoSelectedData: [], treeSelectedKeys: [], treeFilterCondition: [], loading: false, pageLoading: true, isFresh,
});
if (slavePagination === undefined) return;
this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy, true); /* 刷新方法 */
// if (formRoute === '/indexPage/materialRequirementsPlanning') {
// if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
// this.handleGetDataInfo(slaveInfoConfig, slaveFilterCondition, 1);
// }
// }
/* 判断是否要加载过滤树数据 */
const filterTreeConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.bTree);
if (commonUtils.isNotEmptyArr(filterTreeConfigArr)) {
const filterTreeConfig = filterTreeConfigArr[0];
this.handleGetFilterTreeData(filterTreeConfig, slaveFilterCondition, 1);
}
const { clearArray } = this.props;
if (!commonUtils.isEmpty(clearArray)) {
for (const item of clearArray) {
const { confirm, clearFilters } = item;
confirm();
clearFilters();
}
}
} else if (name === 'BtnOutJurisdiction') {
const { activeKey, app, sModelsId } = this.props;
const { userinfo, token } = app;
const { sBrandsId, sSubsidiaryId } = userinfo;
const sType = activeKey === '3' ? 'user' : 'group';
const url = `${commonConfig.server_host}sysjurisdictionNew/exportSysjurisdiction/${sBrandsId}/${sSubsidiaryId}/${sType}?sModelsId=${sModelsId}&token=${token}`;
window.open(url);
}
};
handleProcedureCall = async (btnConfig, proName, proInParam, other) => {
const { app, sModelsId } = this.props;
const value = { sProName: proName, sProInParam: proInParam };
if (other?.iFlag === 1) {
value.iFlag = 1;
}
const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
const returnData = (await commonServices.postValueService(app.token, value, url)).data;
if (returnData.code === 1) {
message.success(returnData.msg);
// this.props.onButtonClick('BtnRefresh');
// this.handleRefresh();
this.handleGetChangeData({ name: 'group' }, 'GroupData');
this.handleGetChangeData({ name: 'userView' }, 'UserData');
this.props.onSaveState({ groupModalVisible: false, userModalVisible: false });
} else {
this.props.getServiceError({ ...returnData, fn: () => this.handleProcedureCall(btnConfig, proName, proInParam, { iFlag: 1 }) });
}
this.props.onSaveState({ loading: false });
}
handleCopyGroupModalOk =() => {
const { sJurisdictionClassifyId, masterData } = this.props;
const filterData = this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName === 'BtnRepairGroup'));
const btnConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : {};// sButtonEnabled sButtonParam
if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
const inParams = [];
const addState = {};
addState.key = 'group';
const val = [{
sGroupId: commonUtils.isNotEmptyArr(sJurisdictionClassifyId) ? sJurisdictionClassifyId[0] : '',
sToGroupId: commonUtils.isNotEmptyObject(masterData) && masterData.sCopyToGroupId,
}];
addState.value = val;
inParams.push({ ...addState });
this.handleProcedureCall(btnConfig, 'Sp_BtnEventCopyGroupJurisdiction', JSON.stringify({ params: inParams, changeValue: 'group' }));
}
};
handleCopyUserModalOk =() => {
const { userViewSelectedRowKeys, masterData } = this.props;
const filterData = this.props.masterConfig.gdsconfigformslave.filter(item => (item.sControlName === 'BtnRepairUser'));
const btnConfig = commonUtils.isNotEmptyArr(filterData) ? filterData[0] : {};// sButtonEnabled sButtonParam
if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
const inParams = [];
const addState = {};
addState.key = 'user';
const val = [{
sUserId: commonUtils.isNotEmptyArr(userViewSelectedRowKeys) ? userViewSelectedRowKeys[0] : '',
sToUserId: commonUtils.isNotEmptyObject(masterData) && masterData.sCopyToUserId,
}];
addState.value = val;
inParams.push({ ...addState });
this.handleProcedureCall(btnConfig, 'Sp_BtnEventCopyUserJurisdiction', JSON.stringify({ params: inParams, changeValue: 'user' }));
}
};
handleModalCancel = (modelVisible) => {
this.props.onSaveState({
[modelVisible]: false,
});
};
render() {
const { masterData } = this.props;
const imgSrc = commonBusiness.handleAddIcon(masterData);
return (
<ChildComponent
{...this.props}
{...this.state}
onReturnForm={this.handleForm}
onSubmit={this.handleValidateSave.bind(this, 'tree')}
onEdit={this.handleEdit}
onTableSelectRowChange={this.handleTableSelectRowChange}
onCancel={this.handleCancel}
imgSrc={imgSrc}
onToggle={this.handleToggle}
onTreeCheck={this.handleCheckBoxCheck}
onRefresh={this.handleRefresh}
onSearch={this.handleSearch}
onDoubleClick={this.handleDoubleClick}
onSetTreeOptionKeys={this.handleSetTreeOptionData}
onSearchTable={this.handleSearchTable}
onSearchGroup={this.handleSearchGroup}
onSearchUser={this.handleSearchUser}
onButtonClick={this.handleButtonClick}
onCopyGroupModalOk={this.handleCopyGroupModalOk}
onCopyUserModalOk={this.handleCopyUserModalOk}
onModalCance={this.handleModalCancel}
/>
);
}
};
};