@tddc/assign-modal 3.0.4 → 3.0.5

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.
@@ -329,6 +329,7 @@ var AssignModal = function AssignModal(props) {
329
329
  );
330
330
  }
331
331
  }
332
+ console.log(initOrgs, 'initOrgs');
332
333
  setCheckedKeys(initOrgs);
333
334
  setAppKeys(initApps || []);
334
335
  setUserKeys(initAccounts || []);
@@ -1009,6 +1010,38 @@ var AssignModal = function AssignModal(props) {
1009
1010
  widthLimit: '100%',
1010
1011
  });
1011
1012
  };
1013
+ var canNotRemoveOrg = useMemo(
1014
+ function () {
1015
+ var _orgMapRef$current, _orgMapRef$current$ch;
1016
+ return (
1017
+ (checkedKeys === null || checkedKeys === void 0 ? void 0 : checkedKeys.length) === 1 &&
1018
+ ((_orgMapRef$current = orgMapRef.current) === null || _orgMapRef$current === void 0
1019
+ ? void 0
1020
+ : (_orgMapRef$current$ch = _orgMapRef$current[checkedKeys[0]]) === null ||
1021
+ _orgMapRef$current$ch === void 0
1022
+ ? void 0
1023
+ : _orgMapRef$current$ch.key) ===
1024
+ (rootNode === null || rootNode === void 0 ? void 0 : rootNode.key)
1025
+ );
1026
+ },
1027
+ [checkedKeys],
1028
+ );
1029
+ var canNotRemoveApp = useMemo(
1030
+ function () {
1031
+ var _appMapRef$current, _appMapRef$current$ap;
1032
+ return (
1033
+ (appKeys === null || appKeys === void 0 ? void 0 : appKeys.length) === 1 &&
1034
+ ((_appMapRef$current = appMapRef.current) === null || _appMapRef$current === void 0
1035
+ ? void 0
1036
+ : (_appMapRef$current$ap = _appMapRef$current[appKeys[0]]) === null ||
1037
+ _appMapRef$current$ap === void 0
1038
+ ? void 0
1039
+ : _appMapRef$current$ap.name) === appCode
1040
+ );
1041
+ },
1042
+ [appKeys],
1043
+ );
1044
+ console.log(canNotRemoveOrg, 'canNotRemove');
1012
1045
  return /*#__PURE__*/ React.createElement(
1013
1046
  React.Fragment,
1014
1047
  null,
@@ -1157,6 +1190,7 @@ var AssignModal = function AssignModal(props) {
1157
1190
  /*#__PURE__*/ React.createElement(
1158
1191
  'a',
1159
1192
  {
1193
+ className: canNotRemoveOrg ? 'disabeld' : '',
1160
1194
  onClick: function onClick() {
1161
1195
  return onRemoveAllOrg();
1162
1196
  },
@@ -1169,46 +1203,50 @@ var AssignModal = function AssignModal(props) {
1169
1203
  {
1170
1204
  className: 'select-menu-list',
1171
1205
  },
1172
- checkedKeys.map(function (item, index) {
1173
- var node = orgMapRef.current[item] || {};
1174
- var path = node.path,
1175
- name = node.name;
1176
- var pathDisplayName = getOrgPathDisplayName(path);
1177
- var disabled = rootNode.key === item;
1178
- return /*#__PURE__*/ React.createElement(
1179
- 'li',
1180
- {
1181
- key: item.value + index,
1182
- className: 'select-menu-list-item',
1183
- },
1184
- /*#__PURE__*/ React.createElement(
1185
- 'span',
1186
- {
1187
- className: 'org-name',
1188
- },
1189
- /*#__PURE__*/ React.createElement(_Ellipsis, {
1190
- title: name,
1191
- }),
1192
- ),
1193
- /*#__PURE__*/ React.createElement(
1194
- 'span',
1206
+ checkedKeys
1207
+ .filter(function (i) {
1208
+ return !!orgMapRef.current[i];
1209
+ })
1210
+ .map(function (item, index) {
1211
+ var node = orgMapRef.current[item] || {};
1212
+ var path = node.path,
1213
+ name = node.name;
1214
+ var pathDisplayName = getOrgPathDisplayName(path);
1215
+ var disabled = rootNode.key === item;
1216
+ return /*#__PURE__*/ React.createElement(
1217
+ 'li',
1195
1218
  {
1196
- className: 'path-name',
1219
+ key: item.value + index,
1220
+ className: 'select-menu-list-item',
1197
1221
  },
1198
- /*#__PURE__*/ React.createElement(_Ellipsis, {
1199
- title: pathDisplayName,
1200
- }),
1201
- ),
1202
- !disabled &&
1203
- /*#__PURE__*/ React.createElement(_Icon, {
1204
- type: 'close',
1205
- className: 'close-icon',
1206
- onClick: function onClick() {
1207
- return onRemoveSingleOrg(node);
1222
+ /*#__PURE__*/ React.createElement(
1223
+ 'span',
1224
+ {
1225
+ className: 'org-name',
1208
1226
  },
1209
- }),
1210
- );
1211
- }) || /*#__PURE__*/ React.createElement(_Empty, null),
1227
+ /*#__PURE__*/ React.createElement(_Ellipsis, {
1228
+ title: name,
1229
+ }),
1230
+ ),
1231
+ /*#__PURE__*/ React.createElement(
1232
+ 'span',
1233
+ {
1234
+ className: 'path-name',
1235
+ },
1236
+ /*#__PURE__*/ React.createElement(_Ellipsis, {
1237
+ title: pathDisplayName,
1238
+ }),
1239
+ ),
1240
+ !disabled &&
1241
+ /*#__PURE__*/ React.createElement(_Icon, {
1242
+ type: 'close',
1243
+ className: 'close-icon',
1244
+ onClick: function onClick() {
1245
+ return onRemoveSingleOrg(node);
1246
+ },
1247
+ }),
1248
+ );
1249
+ }) || /*#__PURE__*/ React.createElement(_Empty, null),
1212
1250
  ),
1213
1251
  ),
1214
1252
  ),
@@ -1311,6 +1349,7 @@ var AssignModal = function AssignModal(props) {
1311
1349
  /*#__PURE__*/ React.createElement(
1312
1350
  'a',
1313
1351
  {
1352
+ className: canNotRemoveApp ? 'disabeld' : '',
1314
1353
  onClick: function onClick() {
1315
1354
  return onRemoveAllApp();
1316
1355
  },
@@ -239,6 +239,41 @@ var AssignModal = function AssignModal(props) {
239
239
  // 渲染Org列表
240
240
  var orgListDomRender = useMemo(
241
241
  function () {
242
+ var renderOrgItem = function renderOrgItem(item, lang) {
243
+ console.log(item, 'item');
244
+ var mapResult = {
245
+ 1: {
246
+ cn: '职能部门',
247
+ en: 'Func. Dept.',
248
+ icon: 'crowd',
249
+ },
250
+ 2: {
251
+ icon: 'corporation',
252
+ },
253
+ };
254
+ var result = mapResult[item === null || item === void 0 ? void 0 : item.orgAttribute] || {};
255
+ return /*#__PURE__*/ React.createElement(
256
+ 'div',
257
+ {
258
+ className: 'org-item-wrapper',
259
+ style: {
260
+ width: '100%',
261
+ },
262
+ },
263
+ /*#__PURE__*/ React.createElement(_Ellipsis, {
264
+ title: item.name,
265
+ widthLimit: String(item.orgAttribute) === '1' ? 'calc(100% - 90px}' : '100%',
266
+ }),
267
+ String(item.orgAttribute) === '1' &&
268
+ /*#__PURE__*/ React.createElement(
269
+ 'span',
270
+ {
271
+ className: 'org-functional-departemt-marker',
272
+ },
273
+ result[lang] || '职能部门',
274
+ ),
275
+ );
276
+ };
242
277
  return (
243
278
  checkedKeys
244
279
  .filter(function (i) {
@@ -289,7 +324,10 @@ var AssignModal = function AssignModal(props) {
289
324
  className: 'org-name',
290
325
  },
291
326
  /*#__PURE__*/ React.createElement(_Ellipsis, {
292
- title: name,
327
+ title: renderOrgItem(
328
+ node,
329
+ props === null || props === void 0 ? void 0 : props.lang,
330
+ ),
293
331
  }),
294
332
  ),
295
333
  /*#__PURE__*/ React.createElement(
@@ -206,6 +206,11 @@
206
206
  content: '';
207
207
  }
208
208
  }
209
+
210
+ .disabeld {
211
+ color: rgba(0, 0, 0, 0.25);
212
+ cursor: not-allowed;
213
+ }
209
214
  }
210
215
 
211
216
  .assign-box-container.view-mode {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tddc/assign-modal",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "assign-modal",
5
5
  "author": "zj <jun.zhang002383@tongdun.net>",
6
6
  "license": "ISC",