@tddc/assign-modal 1.0.8 → 1.0.9

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.
@@ -68,6 +68,10 @@ var AssignModal = function AssignModal(props) {
68
68
  orgCodes = _dataItem$orgCodes === void 0 ? [] : _dataItem$orgCodes,
69
69
  orgCode = dataItem.orgCode,
70
70
  appCode = dataItem.appCode;
71
+ var allOrg = (0, _utils.preorder)(orgList[0]);
72
+ var allApp = appList.map(function (item) {
73
+ return item.value;
74
+ });
71
75
 
72
76
  var _useState = (0, _react.useState)([]),
73
77
  _useState2 = _slicedToArray(_useState, 2),
@@ -96,20 +100,18 @@ var AssignModal = function AssignModal(props) {
96
100
  (0, _react.useEffect)(function () {
97
101
  // path 和 allOrgList 赋值
98
102
  path = (0, _utils.findSameCodePath)(orgList[0], orgCode);
99
- var allOrg = (0, _utils.preorder)(orgList[0]);
100
- var allApp = appList.map(function (item) {
101
- return item.name;
102
- }) || [];
103
103
  var initOrgs = [];
104
104
  var initApps = [];
105
105
 
106
106
  if (orgCodes.includes('all')) {
107
+ setAllOrgChecked(orgCodes.includes('all'));
107
108
  initOrgs = allOrg;
108
109
  } else {
109
110
  initOrgs = Array.from(new Set([].concat(_toConsumableArray(orgCodes || []), _toConsumableArray(path))));
110
111
  }
111
112
 
112
113
  if (appCodes.includes('all')) {
114
+ setAllAppChecked(appCodes.includes('all'));
113
115
  initApps = allApp;
114
116
  } else {
115
117
  initApps = appCodes;
@@ -118,38 +120,6 @@ var AssignModal = function AssignModal(props) {
118
120
  setCheckedKeys(initOrgs);
119
121
  setAppKeys(initApps || []);
120
122
  }, [dataItem]);
121
- (0, _react.useEffect)(function () {
122
- // 机构和应用 全选
123
- var allOrg = (0, _utils.preorder)(orgList[0]);
124
-
125
- if (appList.length > 0) {
126
- var allApp = appList.map(function (item) {
127
- return item.value;
128
- }); // 判断当前用户是否具有 该机构或应用 权限
129
-
130
- var app = appKeys.filter(function (item) {
131
- return allApp.includes(item);
132
- });
133
- var org = checkedKeys.filter(function (item) {
134
- return allOrg.includes(item);
135
- });
136
-
137
- if (app.length === appList.length || org.length === allOrg.length) {}
138
-
139
- onChange && onChange({
140
- appKeys: app.length === appList.length ? ['all'] : appKeys,
141
- checkedKeys: org.length === allOrg.length ? ['all'] : checkedKeys,
142
- appCheckAll: app.length === allApp.length,
143
- orgCheckAll: org.length === allOrg.length,
144
- checkData: {
145
- apps: app.length === allApp.length ? allApp : appKeys,
146
- orgs: org.length === allOrg.length ? allOrg : checkedKeys
147
- }
148
- });
149
- setAllAppChecked(app.length === appList.length);
150
- setAllOrgChecked(org.length === allOrg.length);
151
- }
152
- }, [checkedKeys, appKeys, appList]);
153
123
 
154
124
  var loopTreeNodes = function loopTreeNodes(data) {
155
125
  var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
@@ -212,6 +182,16 @@ var AssignModal = function AssignModal(props) {
212
182
  }
213
183
 
214
184
  setCheckedKeys(checked);
185
+ onChange({
186
+ appKeys: appKeys,
187
+ checkedKeys: checked,
188
+ appCheckAll: appKeys.length === allApp.length,
189
+ orgCheckAll: checked.length === allOrg.length,
190
+ checkData: {
191
+ apps: appKeys,
192
+ orgs: checked
193
+ }
194
+ });
215
195
  };
216
196
 
217
197
  var assignApp = function assignApp(e) {
@@ -221,7 +201,6 @@ var AssignModal = function AssignModal(props) {
221
201
  if (e.target.checked) {
222
202
  value = e.target.value;
223
203
  newAppKeys = [].concat(_toConsumableArray(appKeys), [value]);
224
- setAppKeys(newAppKeys);
225
204
  } else {
226
205
  value = e.target.value;
227
206
  newAppKeys = (0, _lodash.cloneDeep)(appKeys);
@@ -230,33 +209,88 @@ var AssignModal = function AssignModal(props) {
230
209
  newAppKeys.splice(index, 1);
231
210
  }
232
211
  });
233
- setAppKeys(newAppKeys);
234
212
  }
235
- };
213
+
214
+ setAppKeys(newAppKeys);
215
+ onChange({
216
+ appKeys: newAppKeys,
217
+ checkedKeys: checkedKeys,
218
+ appCheckAll: newAppKeys.length === allApp.length,
219
+ orgCheckAll: checkedKeys.length === allOrg.length,
220
+ checkData: {
221
+ apps: appKeys,
222
+ orgs: newAppKeys
223
+ }
224
+ });
225
+ }; // org全局授权
226
+
236
227
 
237
228
  var checkAllOrg = function checkAllOrg(e) {
238
- var orgKeys = [];
229
+ var orgChecks = [];
239
230
 
240
231
  if (e.target.checked) {
241
- orgKeys = (0, _utils.preorder)(orgList[0]);
242
- setCheckedKeys(orgKeys);
232
+ setAllOrgChecked(true);
233
+ orgChecks = (0, _utils.preorder)(orgList[0]);
234
+ setCheckedKeys(orgChecks);
235
+ onChange({
236
+ appKeys: appKeys,
237
+ checkedKeys: ['all'],
238
+ appCheckAll: appKeys.length === allApp.length,
239
+ orgCheckAll: true,
240
+ checkData: {
241
+ apps: appKeys,
242
+ orgs: orgChecks
243
+ }
244
+ });
243
245
  } else {
244
- orgKeys = _toConsumableArray(path);
245
- setCheckedKeys(orgKeys);
246
+ setAllOrgChecked(false);
247
+ orgChecks = _toConsumableArray(path);
248
+ setCheckedKeys(orgChecks);
249
+ onChange({
250
+ appKeys: appKeys,
251
+ checkedKeys: orgChecks,
252
+ appCheckAll: checkedKeys.length === allOrg.length,
253
+ orgCheckAll: false,
254
+ checkData: {
255
+ apps: appKeys,
256
+ orgs: orgChecks
257
+ }
258
+ });
246
259
  }
247
- };
260
+ }; // app全局授权
261
+
248
262
 
249
263
  var checkedAllApp = function checkedAllApp(e) {
250
- var appKeys = [];
264
+ var appChecks = [];
251
265
 
252
266
  if (e.target.checked) {
253
- appKeys = appList.map(function (item) {
267
+ setAllAppChecked(true);
268
+ appChecks = appList.map(function (item) {
254
269
  return item.value;
255
270
  });
256
- setAppKeys(appKeys);
271
+ setAppKeys(appChecks);
272
+ onChange({
273
+ appKeys: ['all'],
274
+ checkedKeys: checkedKeys,
275
+ appCheckAll: true,
276
+ orgCheckAll: checkedKeys.length === allOrg.length,
277
+ checkData: {
278
+ apps: appChecks,
279
+ orgs: checkedKeys
280
+ }
281
+ });
257
282
  } else {
258
- appKeys = [appCode];
259
- setAppKeys(appKeys);
283
+ setAllAppChecked(false);
284
+ onChange({
285
+ appKeys: appChecks,
286
+ checkedKeys: checkedKeys,
287
+ appCheckAll: false,
288
+ orgCheckAll: checkedKeys.length === allOrg.length,
289
+ checkData: {
290
+ apps: appChecks,
291
+ orgs: checkedKeys
292
+ }
293
+ });
260
294
  }
261
295
  };
262
296
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tddc/assign-modal",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Layout",
5
5
  "author": "zj <jun.zhang002383@tongdun.net>",
6
6
  "license": "ISC",
@@ -18,5 +18,5 @@
18
18
  "dependencies": {
19
19
  "jsencrypt": "^3.2.1"
20
20
  },
21
- "gitHead": "acab77ece0b40c408f124f815c484de792ee45d0"
21
+ "gitHead": "330d083d35237ef27b2187046c167e7e29ee25a4"
22
22
  }