vap1 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/components/Box/SelectBar.d.ts +4 -0
  2. package/components/Box/SelectBar.js +1 -1
  3. package/components/Tables/VTable.js +8 -0
  4. package/components/TreeSelect/index.d.ts +1 -1
  5. package/components/Trees/ActionTree.d.ts +1 -1
  6. package/components/Trees/ActionTree.js +40 -50
  7. package/components/Trees/BaseTree.js +0 -1
  8. package/components/Trees/DTree.js +3 -4
  9. package/components/UForm/UForm.js +1 -1
  10. package/components/UForm/_input.js +3 -3
  11. package/components/UForm/index.d.ts +1 -1
  12. package/components/_adapt/Col.d.ts +3 -2
  13. package/components/_adapt/Col.js +2 -27
  14. package/components/_adapt/Icon.js +6 -0
  15. package/components/_common/CountUp.d.ts +3 -1
  16. package/components/_common/CountUp.js +5 -1
  17. package/components/_common/Loading.d.ts +1 -2
  18. package/components/_common/UTitle.d.ts +27 -0
  19. package/components/_common/UTitle.js +39 -0
  20. package/deps/app-audit/ESTable.d.ts +0 -0
  21. package/deps/app-audit/ESTable.js +1 -0
  22. package/deps/app-audit/LookUp.d.ts +27 -0
  23. package/deps/app-audit/LookUp.js +324 -0
  24. package/deps/app-audit/index.d.ts +1 -0
  25. package/deps/app-audit/index.js +7 -0
  26. package/hooks/_list.d.ts +2 -1
  27. package/hooks/useAjaxQuery.d.ts +7 -3
  28. package/hooks/useAjaxQuery.js +46 -25
  29. package/hooks/useApiBase.js +31 -73
  30. package/index.d.ts +3 -1
  31. package/index.js +3 -1
  32. package/package.json +1 -1
  33. package/uform/FormViewer.d.ts +6 -6
  34. package/utils/Ajax.d.ts +1 -1
  35. package/utils/Ajax.js +36 -7
  36. package/utils/Format.d.ts +8 -1
  37. package/utils/Format.js +10 -2
  38. package/utils/Global.d.ts +14 -3
  39. package/utils/Global.js +3 -1
  40. package/utils/StringUtil.js +1 -1
  41. package/utils/TipUtil.d.ts +33 -0
  42. package/utils/TipUtil.js +160 -0
  43. package/utils/_AjaxUtil.d.ts +6 -0
  44. package/utils/_AjaxUtil.js +11 -1
  45. package/utils/index.d.ts +1 -0
  46. package/utils/index.js +2 -1
@@ -52,6 +52,10 @@ type _BoxSelectBarProps = BaseItem & {
52
52
  * 操作区域
53
53
  */
54
54
  actions?: SelectBarAction[];
55
+ /**
56
+ * 初始为收起状态,默认不收起
57
+ */
58
+ defaultCollapse?: boolean;
55
59
  /**
56
60
  * 边栏状态变更触发
57
61
  */
@@ -64,7 +64,7 @@ var _i18n_1 = require("../_i18n");
64
64
  var Icon_1 = require("../_adapt/Icon");
65
65
  exports.SelectBar = (0, react_1.forwardRef)(function (props, ref) {
66
66
  var _a = __read((0, react_1.useState)(null), 2), keyword = _a[0], setKeyword = _a[1];
67
- var _b = __read((0, hooks_1.useToggle)(false), 2), collapsed = _b[0], setCollapsed = _b[1];
67
+ var _b = __read((0, hooks_1.useToggle)(props.defaultCollapse || false), 2), collapsed = _b[0], setCollapsed = _b[1];
68
68
  // const setKeyword = _.debounce(_setKeyword, 100);
69
69
  var component = (0, _register_1.getSelectBar)(props.type);
70
70
  (0, react_1.useLayoutEffect)(function () {
@@ -129,6 +129,14 @@ var _VTable = (0, react_1.forwardRef)(function (props, ref) {
129
129
  ref.current.onSelected();
130
130
  }
131
131
  }, [list]);
132
+ (0, react_1.useLayoutEffect)(function () {
133
+ if (!isQuerying || !utils_1.GLOBAL.CONFIG.TABLE.UNSELECT_ON_QUERY)
134
+ return;
135
+ if (ref.current.selected[0].length > 0) {
136
+ ref.current.selected = [[], []];
137
+ ref.current.onSelected();
138
+ }
139
+ }, [isQuerying]);
132
140
  // 初始选中
133
141
  var isFristMounted = (0, hooks_1.useFirstMountState)();
134
142
  (0, react_1.useLayoutEffect)(function () {
@@ -29,7 +29,7 @@ type TreeValue = Single | Multi;
29
29
  /**
30
30
  * 基础参数
31
31
  */
32
- export type BaseTreeSelectProps = BaseTreeOpts & TreeValue & Pick<TreeSelectProps<any>, 'className' | 'style' | 'placeholder' | 'treeDefaultExpandAll' | 'allowClear' | 'disabled' | 'showSearch' | 'maxTagCount'> & {
32
+ export type BaseTreeSelectProps = BaseTreeOpts & TreeValue & Pick<TreeSelectProps<any>, 'className' | 'dropdownClassName' | 'style' | 'placeholder' | 'treeDefaultExpandAll' | 'allowClear' | 'disabled' | 'showSearch' | 'maxTagCount'> & {
33
33
  /**
34
34
  * 树显示Icon字段 ,默认为空,传入后,以此字段显示图标
35
35
  */
@@ -17,7 +17,7 @@ export type CacheTree = {
17
17
  */
18
18
  clearCache: Function;
19
19
  /**
20
- *
20
+ * 获取子节点方法
21
21
  */
22
22
  getChildren?: Function;
23
23
  };
@@ -121,6 +121,7 @@ var INSER_POS;
121
121
  })(INSER_POS || (INSER_POS = {}));
122
122
  ;
123
123
  var txt = utils_1.i18n.txt;
124
+ var tipResponse = utils_1.TipUtil.tipResponse, tipResponseBatch = utils_1.TipUtil.tipResponseBatch, TIP_ACTION = utils_1.TipUtil.TIP_ACTION, TIP_ACTION_BATCH = utils_1.TipUtil.TIP_ACTION_BATCH;
124
125
  var ActionTreeContext = (0, react_1.createContext)(null);
125
126
  var useActionTree = function () { return (0, react_1.useContext)(ActionTreeContext); };
126
127
  exports.useActionTree = useActionTree;
@@ -151,6 +152,7 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
151
152
  if (props.notCache)
152
153
  action.notCache = true;
153
154
  action.objectName = utils_1.i18n.getText(props.ik, props.objectName, _i18n_1.V.TREE_NODE);
155
+ var tipOptions = (0, react_1.useMemo)(function () { return ({ label: action.objectName, field: treeState.titleField }); }, []);
154
156
  if (props.api) {
155
157
  action.api = props.api;
156
158
  if (props.canAdd) {
@@ -181,7 +183,8 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
181
183
  var treeData = treeState.treeData;
182
184
  var node = lodash_1.default.get(treeData, nodePath);
183
185
  if (node == null) {
184
- antd_1.message.error('No parent found');
186
+ // message.error('No parent found')
187
+ return;
185
188
  }
186
189
  add(data, { pos: INSER_POS.INNER, node: node, position: position });
187
190
  }
@@ -208,7 +211,7 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
208
211
  var showEdit = function (node, position) { return modals.showEdit(node, { position: position }); };
209
212
  // ref.
210
213
  var addRoot = function (data, extra) { return __awaiter(void 0, void 0, void 0, function () {
211
- var pos, position, parentField, titleField, sortField, rootCode, treeData, child, api, objectName, sort, param, result, tree;
214
+ var pos, position, parentField, titleField, sortField, rootCode, treeData, child, api, sort, param, response, isSuccess, tree;
212
215
  var _a;
213
216
  return __generator(this, function (_b) {
214
217
  switch (_b.label) {
@@ -233,7 +236,7 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
233
236
  }
234
237
  return [2 /*return*/];
235
238
  }
236
- api = action.api, objectName = action.objectName;
239
+ api = action.api;
237
240
  sort = 0;
238
241
  if (treeData.length) {
239
242
  if (pos == INSER_POS.TOP) {
@@ -246,21 +249,19 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
246
249
  param = __assign(__assign({}, data), (_a = {}, _a[parentField] = rootCode, _a.sort = sort, _a));
247
250
  return [4 /*yield*/, utils_1.Ajax.PUT(api, param)];
248
251
  case 1:
249
- result = _b.sent();
250
- if (result.code != '0') {
251
- antd_1.message.error(txt(_i18n_1.V.ACT_ADD_FAIL_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
252
+ response = _b.sent();
253
+ isSuccess = tipResponse(response, TIP_ACTION.ADD, param, tipOptions);
254
+ if (!isSuccess)
252
255
  return [2 /*return*/];
253
- }
254
- antd_1.message.success(txt(_i18n_1.V.ACT_ADD_SUCCESS_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
255
256
  props.clearCache(rootCode);
256
- tree = utils_1.ArrayUtil.add(treeData, result.data);
257
+ tree = utils_1.ArrayUtil.add(treeData, response.data);
257
258
  setTreeData(tree);
258
259
  return [2 /*return*/];
259
260
  }
260
261
  });
261
262
  }); };
262
263
  var addInner = function (data, extra) { return __awaiter(void 0, void 0, void 0, function () {
263
- var node, position, api, objectName, canSort, parentField, titleField, sortField, keyField, treeData, root, nodePath, rootPath, tree, arr, param, sort, resp;
264
+ var node, position, api, objectName, canSort, parentField, titleField, sortField, keyField, treeData, root, nodePath, rootPath, tree, arr, param, sort, response, isSuccess;
264
265
  var _a;
265
266
  return __generator(this, function (_b) {
266
267
  switch (_b.label) {
@@ -292,13 +293,11 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
292
293
  _b.label = 3;
293
294
  case 3: return [4 /*yield*/, utils_1.Ajax.PUT(api, param)];
294
295
  case 4:
295
- resp = _b.sent();
296
- if (resp.code != '0') {
297
- antd_1.message.error(txt(_i18n_1.V.ACT_ADD_FAIL_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
296
+ response = _b.sent();
297
+ isSuccess = tipResponse(response, TIP_ACTION.ADD, param, tipOptions);
298
+ if (!isSuccess)
298
299
  return [2 /*return*/];
299
- }
300
- antd_1.message.success(txt(_i18n_1.V.ACT_ADD_SUCCESS_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
301
- arr.push(resp.data);
300
+ arr.push(response.data);
302
301
  props.clearCache(node[keyField]);
303
302
  lodash_1.default.set(tree, rootPath, arr);
304
303
  setTreeData(tree);
@@ -307,7 +306,7 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
307
306
  });
308
307
  }); };
309
308
  var add = function (data, extra) { return __awaiter(void 0, void 0, void 0, function () {
310
- var pos, position, root, idForApiField, api, objectName, canSort, parentField, titleField, sortField, keyField, treeData, idField, tree, idx, nodePath, arr, obj, promises, needLoop, lastSort, dataDefault, diff, i, item, len, diff, i, item, resps, resp;
309
+ var pos, position, root, idForApiField, api, objectName, canSort, parentField, titleField, sortField, keyField, treeData, idField, tree, idx, nodePath, arr, obj, promises, needLoop, lastSort, dataDefault, diff, i, item, len, diff, i, item, resps, response, isSuccess;
311
310
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
312
311
  return __generator(this, function (_m) {
313
312
  switch (_m.label) {
@@ -413,13 +412,11 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
413
412
  return [4 /*yield*/, utils_1.Ajax.WHEN.apply(utils_1.Ajax, __spreadArray([], __read(promises), false))];
414
413
  case 1:
415
414
  resps = _m.sent();
416
- resp = resps[0];
417
- if (resp.code != '0') {
418
- antd_1.message.error(txt(_i18n_1.V.ACT_ADD_FAIL_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
415
+ response = resps[0];
416
+ isSuccess = tipResponse(response, TIP_ACTION.ADD, data, tipOptions);
417
+ if (!isSuccess)
419
418
  return [2 /*return*/];
420
- }
421
- antd_1.message.success(txt(_i18n_1.V.ACT_ADD_SUCCESS_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
422
- arr = utils_1.ArrayUtil.add(arr, resp.data);
419
+ arr = utils_1.ArrayUtil.add(arr, response.data);
423
420
  if (canSort) {
424
421
  arr = lodash_1.default.orderBy(arr, sortField, 'asc');
425
422
  }
@@ -453,21 +450,20 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
453
450
  setTreeData(tree);
454
451
  }, [treeState.treeData]);
455
452
  var update = (0, react_1.useCallback)(function (data, position) { return __awaiter(void 0, void 0, void 0, function () {
456
- var api, objectName, parentField, titleField, treeData, resp, root, tree, idx, rootPath, nodePath, node;
453
+ var api, parentField, treeData, resp, isSuccess, root, tree, idx, rootPath, nodePath, node;
457
454
  return __generator(this, function (_a) {
458
455
  switch (_a.label) {
459
456
  case 0:
460
457
  if (position.length == 0)
461
458
  return [2 /*return*/];
462
- api = action.api, objectName = action.objectName;
463
- parentField = treeState.parentField, titleField = treeState.titleField, treeData = treeState.treeData;
459
+ api = action.api;
460
+ parentField = treeState.parentField, treeData = treeState.treeData;
464
461
  return [4 /*yield*/, utils_1.Ajax.PATCH(api, data)];
465
462
  case 1:
466
463
  resp = _a.sent();
467
- if (resp.code != '0') {
468
- antd_1.message.error(txt(_i18n_1.V.ACT_UPDATE_FAIL_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
464
+ isSuccess = tipResponse(resp, TIP_ACTION.UPDATE, data, tipOptions);
465
+ if (!isSuccess)
469
466
  return [2 /*return*/];
470
- }
471
467
  root = lodash_1.default.concat([], position);
472
468
  tree = lodash_1.default.concat([], treeData);
473
469
  idx = root.pop();
@@ -476,15 +472,15 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
476
472
  nodePath = root.map(function (i) { return "[".concat(i, "]"); }).join('.children');
477
473
  rootPath = nodePath + '.children';
478
474
  }
479
- antd_1.message.success(txt(_i18n_1.V.ACT_UPDATE_SUCCESS_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
480
475
  node = lodash_1.default.get(tree, "".concat(rootPath, "[").concat(idx, "]"));
481
476
  if (node) {
482
477
  props.clearCache(lodash_1.default.get(node, parentField));
483
- // if (node && node.children) {
484
- // _.set(tree, rootPath + `[${idx}]`, { ...data, children: node.children });
485
- // } else {
486
- lodash_1.default.set(tree, rootPath + "[".concat(idx, "]"), data);
487
- // }
478
+ if (node && node.children) {
479
+ lodash_1.default.set(tree, rootPath + "[".concat(idx, "]"), __assign(__assign({}, data), { children: node.children }));
480
+ }
481
+ else {
482
+ lodash_1.default.set(tree, rootPath + "[".concat(idx, "]"), data);
483
+ }
488
484
  setTreeData(tree);
489
485
  }
490
486
  return [2 /*return*/];
@@ -492,7 +488,7 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
492
488
  });
493
489
  }); }, [treeState.treeData]);
494
490
  var del = (0, react_1.useCallback)(function (node, position) { return __awaiter(void 0, void 0, void 0, function () {
495
- var root, rootPath, arr, idForApiField, keyField, parentField, titleField, treeData, api, objectName, nodePath, resp, tree;
491
+ var root, rootPath, arr, idForApiField, keyField, parentField, titleField, treeData, api, objectName, nodePath, resp, isSuccess, tree;
496
492
  return __generator(this, function (_a) {
497
493
  switch (_a.label) {
498
494
  case 0:
@@ -515,10 +511,9 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
515
511
  return [4 /*yield*/, utils_1.Ajax.DELETE(api, { ids: node[idForApiField || keyField] })];
516
512
  case 1:
517
513
  resp = _a.sent();
518
- if (resp.code != '0') {
519
- antd_1.message.error(txt(_i18n_1.V.ACT_DELETE_FAIL_NAMED, "".concat(objectName, " : ").concat(node[titleField])));
514
+ isSuccess = tipResponse(resp, TIP_ACTION.DELETE, node, tipOptions);
515
+ if (!isSuccess)
520
516
  return [2 /*return*/];
521
- }
522
517
  props.clearCache(node[parentField]);
523
518
  tree = lodash_1.default.concat([], treeData);
524
519
  if (rootPath) {
@@ -528,13 +523,12 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
528
523
  tree = utils_1.ArrayUtil.del(tree, node[keyField], keyField);
529
524
  }
530
525
  setTreeData(tree);
531
- antd_1.message.success(txt(_i18n_1.V.ACT_DELETE_SUCCESS_NAMED, "".concat(objectName, " : ").concat(node[titleField])));
532
526
  return [2 /*return*/];
533
527
  }
534
528
  });
535
529
  }); }, [treeState]);
536
530
  var up = function (node, position) { return __awaiter(void 0, void 0, void 0, function () {
537
- var root, parentField, keyField, sortField, treeData, api, idForApiField, idField, idx, rootPath, arr, nodePath, current, swap, tree, resp;
531
+ var root, parentField, keyField, sortField, treeData, api, idForApiField, idField, idx, rootPath, arr, nodePath, current, swap, tree, resp, isSuccess;
538
532
  var _a, _b;
539
533
  return __generator(this, function (_c) {
540
534
  switch (_c.label) {
@@ -565,10 +559,9 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
565
559
  return [4 /*yield*/, utils_1.Ajax.WHEN(utils_1.Ajax.PATCH(api, (_a = {}, _a[idField] = arr[idx][idField], _a[sortField] = swap, _a)), utils_1.Ajax.PATCH(api, (_b = {}, _b[idField] = arr[idx - 1][idField], _b[sortField] = current, _b)))];
566
560
  case 1:
567
561
  resp = _c.sent();
568
- if (resp[0].code != '0' || resp[1].code != '0') {
569
- antd_1.message.error(txt(_i18n_1.V.TREE_SORT_FAIL));
562
+ isSuccess = tipResponseBatch(resp, TIP_ACTION_BATCH.SORT, [arr[idx - 1], arr[idx]], tipOptions);
563
+ if (!isSuccess)
570
564
  return [2 /*return*/];
571
- }
572
565
  props.clearCache(node[parentField]);
573
566
  if (rootPath) {
574
567
  lodash_1.default.set(tree, rootPath, lodash_1.default.orderBy(arr, sortField, 'asc'));
@@ -577,13 +570,12 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
577
570
  tree = lodash_1.default.orderBy(tree, sortField, 'asc');
578
571
  }
579
572
  setTreeData(tree);
580
- antd_1.message.success(txt(_i18n_1.V.TREE_SORT_SUCCESS));
581
573
  return [2 /*return*/];
582
574
  }
583
575
  });
584
576
  }); };
585
577
  var down = function (node, position) { return __awaiter(void 0, void 0, void 0, function () {
586
- var parentField, keyField, sortField, treeData, api, idForApiField, idField, root, idx, rootPath, arr, nodePath, current, swap, tree, resp;
578
+ var parentField, keyField, sortField, treeData, api, idForApiField, idField, root, idx, rootPath, arr, nodePath, current, swap, tree, resp, isSuccess;
587
579
  var _a, _b;
588
580
  return __generator(this, function (_c) {
589
581
  switch (_c.label) {
@@ -614,10 +606,9 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
614
606
  return [4 /*yield*/, utils_1.Ajax.WHEN(utils_1.Ajax.PATCH(api, (_a = {}, _a[idField] = arr[idx][idField], _a[sortField] = swap, _a)), utils_1.Ajax.PATCH(api, (_b = {}, _b[idField] = arr[idx + 1][idField], _b[sortField] = current, _b)))];
615
607
  case 1:
616
608
  resp = _c.sent();
617
- if (resp[0].code != '0' || resp[1].code != '0') {
618
- antd_1.message.error(txt(_i18n_1.V.TREE_SORT_FAIL));
609
+ isSuccess = tipResponseBatch(resp, TIP_ACTION_BATCH.SORT, [arr[idx + 1], arr[idx]], tipOptions);
610
+ if (!isSuccess)
619
611
  return [2 /*return*/];
620
- }
621
612
  props.clearCache(node[parentField]);
622
613
  if (rootPath) {
623
614
  lodash_1.default.set(tree, rootPath, lodash_1.default.orderBy(arr, sortField, 'asc'));
@@ -626,7 +617,6 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
626
617
  tree = lodash_1.default.orderBy(tree, sortField, 'asc');
627
618
  }
628
619
  setTreeData(tree);
629
- antd_1.message.success(txt(_i18n_1.V.TREE_SORT_SUCCESS));
630
620
  return [2 /*return*/];
631
621
  }
632
622
  });
@@ -70,7 +70,6 @@ var HighLight_1 = require("../_common/HighLight");
70
70
  var Icon_1 = require("../_adapt/Icon");
71
71
  var hooks_1 = require("../../hooks");
72
72
  var _Support_1 = require("../../utils/_Support");
73
- "";
74
73
  // 搜索事件延时
75
74
  var SEARCH_DELAY = 200;
76
75
  var BaseTreeContext = (0, react_1.createContext)(null);
@@ -129,7 +129,7 @@ var _Dtree = function (props) {
129
129
  var actionContext = (0, ActionTree_1.useActionTree)();
130
130
  var rootApi = props.rootApi, notCache = props.notCache;
131
131
  (0, hooks_1.useEffectFunction)(function () { return __awaiter(void 0, void 0, void 0, function () {
132
- var tree, rootResp, _a;
132
+ var tree, rootResp, isSuccess, _a;
133
133
  return __generator(this, function (_b) {
134
134
  switch (_b.label) {
135
135
  case 0:
@@ -140,10 +140,9 @@ var _Dtree = function (props) {
140
140
  return [4 /*yield*/, utils_1.Ajax.GET(rootApi)];
141
141
  case 1:
142
142
  rootResp = _b.sent();
143
- if (rootResp.code != '0') {
144
- antd_1.message.error(rootResp.message);
143
+ isSuccess = utils_1.TipUtil.tipError(rootResp);
144
+ if (!isSuccess)
145
145
  return [2 /*return*/];
146
- }
147
146
  tree = (0, ActionTree_1.getResponseList)(rootResp, treeState.sortField);
148
147
  return [3 /*break*/, 4];
149
148
  case 2: return [4 /*yield*/, props.getChildren(treeState.rootCode)];
@@ -248,7 +248,7 @@ var renderFormField = function (state, field, form, update, data) {
248
248
  itemProps.label = react_1.default.createElement(Popover_1.Popover, { content: field.tip, placement: "top" },
249
249
  react_1.default.createElement("span", null,
250
250
  itemProps.label,
251
- react_1.default.createElement(Icon_1.Icon, { type: "question-circle", style: { marginLeft: 4, cursor: 'pointer' }, evt: true })));
251
+ react_1.default.createElement(Icon_1.Icon, { type: "question-circle", style: { marginLeft: 4, cursor: 'pointer' } })));
252
252
  }
253
253
  // 消除非必填项认证
254
254
  var ignoreRule = disableFields.current.has(field.field);
@@ -91,7 +91,7 @@ exports.copyMultiValue = copyMultiValue;
91
91
  var getMultiFieldValues = function (field, value) {
92
92
  var fields = field.field.split(',').map(lodash_1.default.trim);
93
93
  if (fields.length == 1)
94
- return [fields, [value || undefined]];
94
+ return [fields, [(typeof value == 'object' && value != null) ? value[fields[0]] : value]];
95
95
  if (value) {
96
96
  return [fields, fields.map(function (field) { return (value || {})[field]; })];
97
97
  }
@@ -142,9 +142,9 @@ var builderApiTableSerletor = function (options, nameIdx) { return function (pro
142
142
  };
143
143
  return react_1.default.createElement(react_1.default.Fragment, null,
144
144
  values[0] != undefined ? react_1.default.createElement(Button_1.Button, __assign({}, params, { onClick: function () { return setOpen(true); } }), getTip(values)) : react_1.default.createElement(Button_1.Button, __assign({}, params, { icon: 'select', onClick: function () { return setOpen(true); } }), (0, exports.getPlaceholder)(field, true)),
145
- react_1.default.createElement(Tables_1.ApiTableModal, { title: options.title, api: options.api, width: options.width || 720, columns: __spreadArray(__spreadArray([], __read(options.columns), false), [
145
+ react_1.default.createElement(Tables_1.ApiTableModal, __assign({ title: options.title, searchBar: options.searchBar, width: options.width || 720 }, field.config, { api: options.api, columns: __spreadArray(__spreadArray([], __read(options.columns), false), [
146
146
  Tables_1.ApiTable.COL_OPERACTION({ render: function (data) { return react_1.default.createElement(Tables_1.ApiTable.ACTION, { title: "\u9009\u62E9", icon: "select", onClick: function () { return onSelect(data); } }); } })
147
- ], false), searchBar: options.searchBar, open: open, onCancel: function () { return setOpen(false); } }));
147
+ ], false), open: open, onCancel: function () { return setOpen(false); } })));
148
148
  }; };
149
149
  /**
150
150
  * 快速注册 一个 弹出ApiTable 的选择组件
@@ -321,7 +321,7 @@ export type UModalProps = UFromProps & Omit<ModalProps, 'children'> & {
321
321
  * 传 字串 string : 传数据字名称字段
322
322
  * 传 { field: string, label: string } : 以 label: data[field] 展示
323
323
  */
324
- autoTitle?: true | string | {
324
+ autoTitle?: string | {
325
325
  field: string;
326
326
  label: string;
327
327
  };
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import { ColProps as AntdColprops } from 'antd/es/grid/col';
3
3
  import type { ActButton } from '../SearchBar/ActionButtons';
4
- export interface ColProps extends Omit<AntdColprops, 'title'> {
4
+ import type { UTitleProps } from '../_common/UTitle';
5
+ export type ColProps = Omit<AntdColprops, 'title'> & UTitleProps & {
5
6
  /**
6
7
  * 面板标题前的 ICON
7
8
  */
@@ -49,5 +50,5 @@ export interface ColProps extends Omit<AntdColprops, 'title'> {
49
50
  width?: number;
50
51
  height?: number;
51
52
  bodySytle?: React.CSSProperties;
52
- }
53
+ };
53
54
  export declare const Col: React.FC<ColProps>;
@@ -19,33 +19,8 @@ var react_1 = __importDefault(require("react"));
19
19
  var lodash_1 = __importDefault(require("lodash"));
20
20
  var antd_1 = require("antd");
21
21
  var Loading_1 = require("../_common/Loading");
22
- var Icon_1 = require("./Icon");
23
- var utils_1 = require("../../utils");
24
- var ActionButtons_1 = require("../SearchBar/ActionButtons");
22
+ var UTitle_1 = require("../_common/UTitle");
25
23
  var PANEL_PROPERTIES = ['icon', 'title', 'titleSub', 'noBg', 'loading', 'actions', 'empty', 'width', 'height', 'bodySytle'];
26
- var ColHead = function (props) {
27
- var elAction = '';
28
- var actions = [];
29
- if ((lodash_1.default.isArray(props.actions) && props.actions.length)) {
30
- props.actions.map(function (item) {
31
- if (item.roleCode == null || utils_1.PageUtil.hasRole(item.roleCode)) {
32
- actions.push(item);
33
- }
34
- });
35
- elAction = react_1.default.createElement(ActionButtons_1.ActionButtons, { size: 'small', buttons: actions });
36
- }
37
- else if (lodash_1.default.isObject(props.actions) && react_1.default.isValidElement(props.actions)) {
38
- elAction = props.actions;
39
- }
40
- if (props.title == null && actions.length == 0)
41
- return utils_1.Const.NONE;
42
- return react_1.default.createElement("div", { className: 'v-col-head' },
43
- react_1.default.createElement("div", { className: 'c-col-title' },
44
- props.icon && react_1.default.createElement(Icon_1.Icon, { type: props.icon, className: 'c-col-title-icon' }),
45
- react_1.default.createElement("span", { className: 'c-col-title-text' }, props.title),
46
- props.titleSub && react_1.default.createElement("span", { className: 'c-col-title-sub' }, props.titleSub)),
47
- react_1.default.createElement("div", { className: 'c-col-actions' }, elAction));
48
- };
49
24
  var Col = function (props) {
50
25
  var clazz = ['v-col'];
51
26
  if (props.className) {
@@ -97,7 +72,7 @@ var Col = function (props) {
97
72
  }
98
73
  return react_1.default.createElement(antd_1.Col, __assign({}, colProps, { className: clazz.join(' '), style: style }),
99
74
  react_1.default.createElement("div", { className: 'v-col-content' },
100
- react_1.default.createElement(ColHead, __assign({}, props)),
75
+ react_1.default.createElement(UTitle_1.UTitle, __assign({}, lodash_1.default.omit(props, ['className', 'style']))),
101
76
  react_1.default.createElement("div", { className: 'v-col-body', style: props.bodySytle }, isLoading ? react_1.default.createElement(Loading_1.Loading, null) : (isEmpty ? react_1.default.createElement(antd_1.Empty, null) : props.children))));
102
77
  };
103
78
  exports.Col = Col;
@@ -16,6 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Icon = void 0;
18
18
  var react_1 = __importDefault(require("react"));
19
+ var lodash_1 = __importDefault(require("lodash"));
19
20
  var utils_1 = require("../../utils");
20
21
  var Icon = function (props) {
21
22
  if (props.type == null || props.type == '')
@@ -40,6 +41,11 @@ var Icon = function (props) {
40
41
  };
41
42
  }
42
43
  spanProps.className = clazz.join(' ');
44
+ if (lodash_1.default.startsWith(props.type, '/')
45
+ || lodash_1.default.startsWith(props.type, 'https://')
46
+ || lodash_1.default.startsWith(props.type, 'https://')) {
47
+ return react_1.default.createElement("img", __assign({}, spanProps, { src: props.type }));
48
+ }
43
49
  return react_1.default.createElement("span", __assign({}, spanProps));
44
50
  };
45
51
  exports.Icon = Icon;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { NumberFormat, FractionDigits } from '../../utils/Format';
3
+ type FormatFunction = (number: any) => string;
3
4
  export type CountUpProps = {
4
5
  /**
5
6
  * 自定义样式
@@ -20,7 +21,7 @@ export type CountUpProps = {
20
21
  /**
21
22
  * 样式
22
23
  */
23
- format?: NumberFormat;
24
+ format?: NumberFormat | FormatFunction;
24
25
  /**
25
26
  * pos 仅在 int-fixed 与 digtal 模式下有效
26
27
  * int-fixed
@@ -36,3 +37,4 @@ export type CountUpProps = {
36
37
  * 数据变化组件
37
38
  */
38
39
  export declare const CountUp: React.FC<CountUpProps>;
40
+ export {};
@@ -62,7 +62,11 @@ var loop = function (from, to, el, format, startTime, ms) {
62
62
  var CountUp = function (props) {
63
63
  var el = (0, react_1.useRef)(null);
64
64
  var ms = lodash_1.default.isNumber(props.ms) ? props.ms : 800;
65
- var format = (0, Format_1.getFormater)(props.format, props.pos);
65
+ var format = (0, react_1.useMemo)(function () {
66
+ if (lodash_1.default.isFunction(props.format))
67
+ return props.format;
68
+ return (0, Format_1.getFormater)(props.format, props.pos);
69
+ }, [props.format]);
66
70
  var _a = __read((0, react_1.useState)({ lastTime: Date.now(), lastValue: props.initValue || 0 }), 2), state = _a[0], setState = _a[1];
67
71
  var start = function (from, to) {
68
72
  setState({ lastTime: Date.now(), lastValue: to });
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
- type LoadingProps = {
2
+ export type LoadingProps = {
3
3
  title?: React.ReactNode;
4
4
  };
5
5
  /**
6
6
  * 通用 Loading ,用于数据请求中的效果
7
7
  */
8
8
  export declare const Loading: React.FC<LoadingProps>;
9
- export {};
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import type { ActButton } from '../SearchBar/ActionButtons';
3
+ export type UTitleProps = {
4
+ className?: string;
5
+ style?: React.CSSProperties;
6
+ /**
7
+ * 面板标题前的 ICON
8
+ */
9
+ icon?: string;
10
+ /**
11
+ * 面板标题
12
+ */
13
+ title?: React.ReactNode;
14
+ /**
15
+ * 标题下标额外内容(以 small小一号)展示
16
+ */
17
+ titleSub?: React.ReactNode;
18
+ /**
19
+ * 标题后面的帮助文案
20
+ */
21
+ help?: React.ReactNode;
22
+ /**
23
+ * 右上角按钮
24
+ */
25
+ actions?: ActButton[] | React.ReactNode;
26
+ };
27
+ export declare const UTitle: (props: UTitleProps) => React.JSX.Element;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UTitle = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var lodash_1 = __importDefault(require("lodash"));
9
+ var utils_1 = require("../../utils");
10
+ var Popover_1 = require("../_adapt/Popover");
11
+ var Icon_1 = require("../_adapt/Icon");
12
+ var ActionButtons_1 = require("../SearchBar/ActionButtons");
13
+ var UTitle = function (props) {
14
+ var elAction = '';
15
+ var actions = [];
16
+ if ((lodash_1.default.isArray(props.actions) && props.actions.length)) {
17
+ props.actions.map(function (item) {
18
+ if (item.roleCode == null || utils_1.PageUtil.hasRole(item.roleCode)) {
19
+ actions.push(item);
20
+ }
21
+ });
22
+ elAction = react_1.default.createElement(ActionButtons_1.ActionButtons, { size: 'small', buttons: actions });
23
+ }
24
+ else if (lodash_1.default.isObject(props.actions) && react_1.default.isValidElement(props.actions)) {
25
+ elAction = props.actions;
26
+ }
27
+ if (props.title == null && actions.length == 0)
28
+ return utils_1.Const.NONE;
29
+ return react_1.default.createElement("div", { className: utils_1.StringUtil.className(['v-col-head', 'c-title'], props.className), style: props.style },
30
+ react_1.default.createElement("div", { className: 'c-col-title c-title-content' },
31
+ props.icon && react_1.default.createElement(Icon_1.Icon, { type: props.icon, className: 'c-col-title-icon c-title-icon' }),
32
+ react_1.default.createElement("span", { className: 'c-col-title-text c-title-text' },
33
+ props.title,
34
+ props.help && react_1.default.createElement(Popover_1.Popover, { content: props.help },
35
+ react_1.default.createElement("span", { className: "vicon vicon-question-circle" }))),
36
+ props.titleSub && react_1.default.createElement("span", { className: 'c-col-title-sub c-title-sub' }, props.titleSub)),
37
+ react_1.default.createElement("div", { className: 'c-col-actions c-title-action' }, elAction));
38
+ };
39
+ exports.UTitle = UTitle;
File without changes
@@ -0,0 +1 @@
1
+ //
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import type { PlainObject, UFormField } from "../../index";
3
+ type LookUp = {
4
+ title: string;
5
+ id: number;
6
+ type: string;
7
+ code: string;
8
+ value: string;
9
+ description: string;
10
+ };
11
+ export declare const useLookup: () => {
12
+ lookupLoading: boolean;
13
+ update: (data: PlainObject) => Promise<void>;
14
+ getLookups: (codes: string[]) => LookUp[];
15
+ getLookupsByType: (type: string) => LookUp[];
16
+ getLookupData: (fields: UFormField[]) => PlainObject;
17
+ changeSaveData: (data: any) => {};
18
+ };
19
+ type LookUpModalProps = {
20
+ title?: string;
21
+ open: boolean;
22
+ fields: UFormField[];
23
+ onCancel: () => void;
24
+ };
25
+ export declare const LookUpInfo: React.FC<LookUpModalProps>;
26
+ export declare const LookUpModal: React.FC<LookUpModalProps>;
27
+ export {};