vap1 0.3.4 → 0.3.6

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.
@@ -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)];
@@ -245,9 +245,9 @@ var renderFormField = function (state, field, form, update, data) {
245
245
  if (field.help)
246
246
  itemProps.help = field.help;
247
247
  if (field.tip && !input.breakTitle) {
248
- itemProps.label = react_1.default.createElement("span", null,
249
- itemProps.label,
250
- react_1.default.createElement(Popover_1.Popover, { content: field.tip, placement: "top" },
248
+ itemProps.label = react_1.default.createElement(Popover_1.Popover, { content: field.tip, placement: "top" },
249
+ react_1.default.createElement("span", null,
250
+ itemProps.label,
251
251
  react_1.default.createElement(Icon_1.Icon, { type: "question-circle", style: { marginLeft: 4, cursor: 'pointer' } })));
252
252
  }
253
253
  // 消除非必填项认证
@@ -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
  }
@@ -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,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;
@@ -55,8 +55,7 @@ var lodash_1 = __importDefault(require("lodash"));
55
55
  ;
56
56
  var react_1 = require("react");
57
57
  var utils_1 = require("../utils");
58
- var _i18n_1 = require("../components/_i18n");
59
- var antd_1 = require("antd");
58
+ var tipResponse = utils_1.TipUtil.tipResponse, TIP_ACTION = utils_1.TipUtil.TIP_ACTION;
60
59
  var chean = function (param) {
61
60
  lodash_1.default.keys(param).map(function (key) {
62
61
  if (param[key] === undefined || param[key] === '' || param[key] === null) {
@@ -72,45 +71,10 @@ var effectKey = function (prevEffect, next, rowKey) {
72
71
  return next[rowKey];
73
72
  return '_' + next[rowKey];
74
73
  };
75
- var SHOWTIP = function (isSuccess, action, data, options) {
76
- var name = '';
77
- if (options.tipLabel)
78
- name = options.tipLabel;
79
- if (options.tipField && lodash_1.default.has(data, options.tipField))
80
- name += (' : ' + data[options.tipField]);
81
- name = lodash_1.default.trim(name);
82
- switch (action) {
83
- case 'ADD':
84
- if (isSuccess) {
85
- antd_1.message.success(utils_1.i18n.txt(name ? _i18n_1.V.ACT_ADD_SUCCESS_NAMED : _i18n_1.V.ACT_ADD_SUCCESS, name));
86
- }
87
- else {
88
- antd_1.message.error(utils_1.i18n.txt(name ? _i18n_1.V.ACT_ADD_FAIL_NAMED : _i18n_1.V.ACT_ADD_FAIL, name));
89
- }
90
- break;
91
- case 'UPDATE':
92
- if (isSuccess) {
93
- antd_1.message.success(utils_1.i18n.txt(name ? _i18n_1.V.ACT_UPDATE_SUCCESS_NAMED : _i18n_1.V.ACT_UPDATE_SUCCESS, name));
94
- }
95
- else {
96
- antd_1.message.error(utils_1.i18n.txt(name ? _i18n_1.V.ACT_UPDATE_FAIL_NAMED : _i18n_1.V.ACT_UPDATE_FAIL, name));
97
- }
98
- break;
99
- case 'DELETE':
100
- if (isSuccess) {
101
- antd_1.message.success(utils_1.i18n.txt(name ? _i18n_1.V.ACT_DELETE_SUCCESS_NAMED : _i18n_1.V.ACT_DELETE_SUCCESS, name));
102
- }
103
- else {
104
- antd_1.message.error(utils_1.i18n.txt(name ? _i18n_1.V.ACT_DELETE_FAIL_NAMED : _i18n_1.V.ACT_DELETE_FAIL, name));
105
- }
106
- break;
107
- default:
108
- break;
109
- }
110
- };
111
74
  var useApiBase = function (config, state, doLoad, mode) {
112
75
  if (mode === void 0) { mode = 'api'; }
113
76
  var list = state.list, effect = state.effect, pageNo = state.pageNo, pageSize = state.pageSize, total = state.total, totalAcc = state.totalAcc, isQuerying = state.isQuerying, param = state.param, cost = state.cost;
77
+ var tipOptions = (0, react_1.useMemo)(function () { return ({ field: config.tipField, label: config.tipLabel }); }, []);
114
78
  var rowKey = config.rowKey || 'id';
115
79
  var delKey = config.delKey || 'ids';
116
80
  var lastQuery = (0, react_1.useRef)(config.param || {});
@@ -243,7 +207,7 @@ var useApiBase = function (config, state, doLoad, mode) {
243
207
  case 1:
244
208
  response = _a.sent();
245
209
  if (TIP.ADD) {
246
- SHOWTIP(response.code == '0', 'ADD', data, config);
210
+ tipResponse(response, TIP_ACTION.ADD, data, tipOptions);
247
211
  }
248
212
  isSuccess = response.code == '0';
249
213
  if (AOP.afterAdd) {
@@ -273,7 +237,7 @@ var useApiBase = function (config, state, doLoad, mode) {
273
237
  case 1:
274
238
  response = _a.sent();
275
239
  if (TIP.UPDATE) {
276
- SHOWTIP(response.code == '0', 'UPDATE', param, config);
240
+ tipResponse(response, TIP_ACTION.UPDATE, data, tipOptions);
277
241
  }
278
242
  isSuccess = response.code == '0';
279
243
  if (AOP.afterUpdate) {
@@ -336,12 +300,7 @@ var useApiBase = function (config, state, doLoad, mode) {
336
300
  response = _b.sent();
337
301
  isSuccess = response.code == '0';
338
302
  if (TIP.DELETE) {
339
- if (isSuccess) {
340
- antd_1.message.success(utils_1.i18n.txt(_i18n_1.V.ACT_DELETE_SUCCESS_COUNT, keys.length + ''));
341
- }
342
- else {
343
- antd_1.message.error(utils_1.i18n.txt(_i18n_1.V.ACT_DELETE_FAIL_COUNT, keys.length + ''));
344
- }
303
+ tipResponse(response, TIP_ACTION.DELETE_BATCH, keys, tipOptions);
345
304
  }
346
305
  if (isSuccess)
347
306
  doDelete(arr);
@@ -373,7 +332,7 @@ var useApiBase = function (config, state, doLoad, mode) {
373
332
  else {
374
333
  obj = lodash_1.default.find(list, (_b = {}, _b[rowKey] = key, _b)) || {};
375
334
  }
376
- SHOWTIP(isSuccess, 'DELETE', obj, config);
335
+ tipResponse(response, TIP_ACTION.DELETE, obj, tipOptions);
377
336
  // let name;
378
337
  // if (config.tipField) {
379
338
  // if (_.isPlainObject(data)) {
package/index.d.ts CHANGED
@@ -153,7 +153,8 @@ export type { FTreeProps } from './components/Trees/FTree';
153
153
  export { Box } from './components/Box';
154
154
  export type { BoxProps } from './components/Box/Box';
155
155
  export { SearchBar, type SearchBarProps } from './components/SearchBar';
156
- export { Loading } from './components/_common/Loading';
156
+ export { Loading, type LoadingProps } from './components/_common/Loading';
157
+ export { UTitle, type UTitleProps } from './components/_common/UTitle';
157
158
  export { DateRange, type DateRangeProps } from './components/_common/DateRange';
158
159
  export { HighLight, type HighLightProps } from './components/_common/HighLight';
159
160
  export { CountUp, type CountUpProps } from './components/_common/CountUp';
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AutoComplete = exports.Rate = exports.Upload = exports.TimePicker = exports.DatePicker = exports.Switch = exports.Checkbox = exports.Pagination = exports.Timeline = exports.List = exports.Tree = exports.Descriptions = exports.Tag = exports.Alert = exports.Button = exports.Icon = exports.FloatButton = exports.Mentions = exports.Anchor = exports.Affix = exports.BackTop = exports.Avatar = exports.Badge = exports.Statistic = exports.Typography = exports.Progress = exports.Popover = exports.Popconfirm = exports.Tooltip = exports.Dropdown = exports.Drawer = exports.Modal = exports.Col = exports.Row = exports.Space = exports.Layout = exports.Skeleton = exports.Card = exports.Spin = exports.Result = exports.Empty = exports.Divider = exports.Collapse = exports.Tabs = exports.Menu = exports.Breadcrumb = exports.Steps = exports.notification = exports.ConfigProvider = exports.message = void 0;
4
- exports.PromiseLabel = exports.IAutoComplete = exports.Role = exports.I = exports.CountUp = exports.HighLight = exports.DateRange = exports.Loading = exports.SearchBar = exports.Box = exports.SList = exports.UploadModal = exports.UploadImage = exports.UploadFile = exports.FTree = exports.DTree = exports.STree = exports.TopTableModal = exports.TopTable = exports.STable = exports.ApiTableModal = exports.ApiTable = exports.VTable = exports.UDescriptions = exports.UModal = exports.UInfoModal = exports.UInfo = exports.UFormModal = exports.UForm = exports.UPagination = exports.ColorPicker = exports.Radio = exports.InputNumber = exports.Slider = exports.TreeSelect = exports.Select = exports.Input = exports.Table = exports.Form = exports.FTreeSelect = exports.DTreeSelect = exports.STreeSelect = exports.Calendar = exports.Carousel = exports.Transfer = exports.Cascader = void 0;
4
+ exports.PromiseLabel = exports.IAutoComplete = exports.Role = exports.I = exports.CountUp = exports.HighLight = exports.DateRange = exports.UTitle = exports.Loading = exports.SearchBar = exports.Box = exports.SList = exports.UploadModal = exports.UploadImage = exports.UploadFile = exports.FTree = exports.DTree = exports.STree = exports.TopTableModal = exports.TopTable = exports.STable = exports.ApiTableModal = exports.ApiTable = exports.VTable = exports.UDescriptions = exports.UModal = exports.UInfoModal = exports.UInfo = exports.UFormModal = exports.UForm = exports.UPagination = exports.ColorPicker = exports.Radio = exports.InputNumber = exports.Slider = exports.TreeSelect = exports.Select = exports.Input = exports.Table = exports.Form = exports.FTreeSelect = exports.DTreeSelect = exports.STreeSelect = exports.Calendar = exports.Carousel = exports.Transfer = exports.Cascader = void 0;
5
5
  /**
6
6
  * 基础
7
7
  */
@@ -171,6 +171,8 @@ var SearchBar_1 = require("./components/SearchBar");
171
171
  Object.defineProperty(exports, "SearchBar", { enumerable: true, get: function () { return SearchBar_1.SearchBar; } });
172
172
  var Loading_1 = require("./components/_common/Loading"); // 通用 Loading
173
173
  Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return Loading_1.Loading; } });
174
+ var UTitle_1 = require("./components/_common/UTitle"); // 通用 Title
175
+ Object.defineProperty(exports, "UTitle", { enumerable: true, get: function () { return UTitle_1.UTitle; } });
174
176
  var DateRange_1 = require("./components/_common/DateRange"); // 日期范围选择器
175
177
  Object.defineProperty(exports, "DateRange", { enumerable: true, get: function () { return DateRange_1.DateRange; } });
176
178
  var HighLight_1 = require("./components/_common/HighLight"); // 高亮
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.3.4","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
1
+ {"name":"vap1","version":"0.3.6","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
package/utils/Ajax.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { PlainObject } from '../basetype';
2
2
  import type { Result } from './_AjaxUtil';
3
- export { SESSION, CLEAR, WAIT } from './_AjaxUtil';
3
+ export { SESSION, SESSION_TIME, CLEAR, WAIT } from './_AjaxUtil';
4
4
  /**
5
5
  * CATCH 方法可以捕获通用的错误并,省去 try/catch 语法
6
6
  */
package/utils/Ajax.js CHANGED
@@ -66,13 +66,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
66
66
  return (mod && mod.__esModule) ? mod : { "default": mod };
67
67
  };
68
68
  Object.defineProperty(exports, "__esModule", { value: true });
69
- exports.WHEN = exports.PUT = exports.DELETE = exports.PATCH = exports.POST = exports.GET = exports.FETCH = exports.CATCH = exports.WAIT = exports.CLEAR = exports.SESSION = void 0;
69
+ exports.WHEN = exports.PUT = exports.DELETE = exports.PATCH = exports.POST = exports.GET = exports.FETCH = exports.CATCH = exports.WAIT = exports.CLEAR = exports.SESSION_TIME = exports.SESSION = void 0;
70
70
  var lodash_1 = __importDefault(require("lodash"));
71
71
  var Global_1 = require("./Global");
72
72
  var _Support_1 = require("./_Support");
73
73
  var _AjaxUtil_1 = require("./_AjaxUtil");
74
74
  var _AjaxUtil_2 = require("./_AjaxUtil");
75
75
  Object.defineProperty(exports, "SESSION", { enumerable: true, get: function () { return _AjaxUtil_2.SESSION; } });
76
+ Object.defineProperty(exports, "SESSION_TIME", { enumerable: true, get: function () { return _AjaxUtil_2.SESSION_TIME; } });
76
77
  Object.defineProperty(exports, "CLEAR", { enumerable: true, get: function () { return _AjaxUtil_2.CLEAR; } });
77
78
  Object.defineProperty(exports, "WAIT", { enumerable: true, get: function () { return _AjaxUtil_2.WAIT; } });
78
79
  var _a = (0, _Support_1.globalDefault)('NProgress', { start: function () { }, done: function () { } }), start = _a.start, done = _a.done;
@@ -147,20 +148,48 @@ var _FETCH = function (method, url, param, options) {
147
148
  }
148
149
  return (0, exports.FETCH)(_url, fetchOptions);
149
150
  };
151
+ var TIMER_SUFFIX = '_last';
150
152
  var GET = function (url, options) { return __awaiter(void 0, void 0, void 0, function () {
151
- var resp;
152
- return __generator(this, function (_a) {
153
- switch (_a.label) {
153
+ var _a, isCache, timer, useCache, last, lastTime, resp;
154
+ return __generator(this, function (_b) {
155
+ switch (_b.label) {
154
156
  case 0:
155
- if (!(_AjaxUtil_1.CACHE_URL.has(url) && sessionStorage.getItem(url))) return [3 /*break*/, 2];
157
+ _a = __read([_AjaxUtil_1.CACHE_URL.has(url), _AjaxUtil_1.CACHE_TIMER.get(url)], 2), isCache = _a[0], timer = _a[1];
158
+ useCache = false;
159
+ if (isCache && sessionStorage.getItem(url)) {
160
+ useCache = true;
161
+ if (timer) {
162
+ last = sessionStorage.getItem(url + TIMER_SUFFIX);
163
+ if (last == null) {
164
+ useCache = false;
165
+ }
166
+ else {
167
+ try {
168
+ lastTime = parseInt(last);
169
+ if ((Date.now() - lastTime) > timer) {
170
+ useCache = false;
171
+ }
172
+ else {
173
+ }
174
+ }
175
+ catch (_c) {
176
+ useCache = false;
177
+ }
178
+ }
179
+ }
180
+ }
181
+ if (!useCache) return [3 /*break*/, 2];
156
182
  return [4 /*yield*/, new Promise(function (r) { return r(JSON.parse(sessionStorage.getItem(url))); })];
157
- case 1: return [2 /*return*/, _a.sent()];
183
+ case 1: return [2 /*return*/, _b.sent()];
158
184
  case 2: return [4 /*yield*/, _FETCH('GET', url, {}, options)];
159
185
  case 3:
160
- resp = _a.sent();
186
+ resp = _b.sent();
161
187
  if (_AjaxUtil_1.CACHE_URL.has(url)) {
162
188
  if (lodash_1.default.has(resp, 'code') && resp.code == '0') {
163
189
  sessionStorage.setItem(url, JSON.stringify(resp));
190
+ if (timer) {
191
+ sessionStorage.setItem(url + TIMER_SUFFIX, Date.now() + '');
192
+ }
164
193
  }
165
194
  }
166
195
  return [2 /*return*/, resp];
package/utils/Global.d.ts CHANGED
@@ -24,6 +24,12 @@ export type GlobalSetting = {
24
24
  * 显示:回到首页,默认为 true
25
25
  */
26
26
  USER_MENU_HOMEPAGE: boolean;
27
+ /**
28
+ * 发生错误时,以显示 resp 里面的 `message` 显示
29
+ * 默认为 true
30
+ * 当项目接口不是很标准时,可以设置为false ,将会显示 抽象原因,如:添加失败,修改失败等。
31
+ */
32
+ TIP_ERROR: boolean;
27
33
  };
28
34
  /**
29
35
  * 基础API设置,
@@ -242,10 +248,15 @@ export type GlobalSetting = {
242
248
  TABLE: {
243
249
  SIZE: TableSize;
244
250
  /**
245
- * 当列表的项目被删除时,重新查询列表数据
246
- * 默认为false
251
+ * 当列表的项目被删除时,重新查询列表数据
252
+ * 默认为false
247
253
  */
248
- RE_QUERY_AT_DELETE: boolean;
254
+ REQUERY_ON_DELETE: boolean;
255
+ /**
256
+ * 当列表的项目被删除时,重新查询列表数据
257
+ * 默认为false
258
+ */
259
+ UNSELECT_ON_QUERY: boolean;
249
260
  };
250
261
  PAGINATION: {
251
262
  SIZE: 'default' | 'small';
package/utils/Global.js CHANGED
@@ -21,6 +21,7 @@ var DEFAULT = {
21
21
  APP: {
22
22
  LANG: _Support_1.Language.ZH_CN,
23
23
  USER_MENU_HOMEPAGE: true,
24
+ TIP_ERROR: true,
24
25
  },
25
26
  BASIC: {
26
27
  PREFIX: '/api-common',
@@ -78,7 +79,8 @@ var DEFAULT = {
78
79
  },
79
80
  TABLE: {
80
81
  SIZE: 'small',
81
- RE_QUERY_AT_DELETE: false
82
+ REQUERY_ON_DELETE: false,
83
+ UNSELECT_ON_QUERY: false,
82
84
  },
83
85
  DATE: {
84
86
  DATE_FORMAT: 'YYYY-MM-DD',
@@ -92,7 +92,7 @@ var isPhone = function (txt) { return (0, exports.isMobilePhone)(txt) || (0, exp
92
92
  exports.isPhone = isPhone;
93
93
  var isIP4 = function (str) { return exports.REG_IPV4.test(str); };
94
94
  exports.isIP4 = isIP4;
95
- var isIP6 = function (str) { return exports.REG_IPV4.test(str); };
95
+ var isIP6 = function (str) { return exports.REG_IPV6.test(str); };
96
96
  exports.isIP6 = isIP6;
97
97
  /**
98
98
  * 判断是否是一个 IP 地址,默认
@@ -0,0 +1,29 @@
1
+ import type { PlainObject } from '../basetype';
2
+ export type TipOption = {
3
+ /**
4
+ * namefield
5
+ */
6
+ field?: string;
7
+ /**
8
+ * namefield
9
+ */
10
+ label?: string;
11
+ };
12
+ export declare enum TIP_ACTION {
13
+ ADD = 0,
14
+ UPDATE = 1,
15
+ DELETE = 2,
16
+ DELETE_BATCH = 3
17
+ }
18
+ export declare enum TIP_ACTION_BATCH {
19
+ SORT = 0
20
+ }
21
+ /**
22
+ * 批量提示
23
+ */
24
+ export declare const tipResponseBatch: (responses: PlainObject[], action: TIP_ACTION_BATCH, data: PlainObject[], options: TipOption) => boolean;
25
+ export declare const tipError: (response: PlainObject) => boolean;
26
+ /**
27
+ * 单个提示
28
+ */
29
+ export declare const tipResponse: (response: PlainObject, action: TIP_ACTION, data: PlainObject | PlainObject[], options: TipOption) => boolean;
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.tipResponse = exports.tipError = exports.tipResponseBatch = exports.TIP_ACTION_BATCH = exports.TIP_ACTION = void 0;
18
+ var lodash_1 = __importDefault(require("lodash"));
19
+ var antd_1 = require("antd");
20
+ var i18n_1 = require("./i18n");
21
+ var _i18n_1 = require("../components/_i18n");
22
+ var Global_1 = require("./Global");
23
+ // 操作提示:单个
24
+ var TIP_ACTION;
25
+ (function (TIP_ACTION) {
26
+ TIP_ACTION[TIP_ACTION["ADD"] = 0] = "ADD";
27
+ TIP_ACTION[TIP_ACTION["UPDATE"] = 1] = "UPDATE";
28
+ TIP_ACTION[TIP_ACTION["DELETE"] = 2] = "DELETE";
29
+ TIP_ACTION[TIP_ACTION["DELETE_BATCH"] = 3] = "DELETE_BATCH";
30
+ })(TIP_ACTION || (exports.TIP_ACTION = TIP_ACTION = {}));
31
+ ;
32
+ // 操作提示:多个(排序)或(批量添加/修改(批量模式未激活时))
33
+ var TIP_ACTION_BATCH;
34
+ (function (TIP_ACTION_BATCH) {
35
+ TIP_ACTION_BATCH[TIP_ACTION_BATCH["SORT"] = 0] = "SORT";
36
+ })(TIP_ACTION_BATCH || (exports.TIP_ACTION_BATCH = TIP_ACTION_BATCH = {}));
37
+ ;
38
+ /**
39
+ * 内置错误
40
+ */
41
+ var NOT_TIP = new Set([
42
+ '后端内部服务异常,无法负载到后端服务!!',
43
+ '系统繁忙,请稍后再试',
44
+ '500_ERROR'
45
+ ]);
46
+ // const MessageFormat = () => {
47
+ // }
48
+ /**
49
+ * 批量提示
50
+ */
51
+ var tipResponseBatch = function (responses, action, data, options) {
52
+ var e_1, _a;
53
+ var isSuccess = true;
54
+ var msg;
55
+ try {
56
+ for (var responses_1 = __values(responses), responses_1_1 = responses_1.next(); !responses_1_1.done; responses_1_1 = responses_1.next()) {
57
+ var response = responses_1_1.value;
58
+ if (response.code != Global_1.CONFIG.RESULT.success) {
59
+ isSuccess = false;
60
+ msg = response.message;
61
+ break;
62
+ }
63
+ }
64
+ }
65
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
66
+ finally {
67
+ try {
68
+ if (responses_1_1 && !responses_1_1.done && (_a = responses_1.return)) _a.call(responses_1);
69
+ }
70
+ finally { if (e_1) throw e_1.error; }
71
+ }
72
+ switch (action) {
73
+ case TIP_ACTION_BATCH.SORT:
74
+ msg = isSuccess ? (0, i18n_1.txt)(_i18n_1.V.TREE_SORT_SUCCESS) : (0, i18n_1.txt)(_i18n_1.V.TREE_SORT_FAIL);
75
+ break;
76
+ default:
77
+ break;
78
+ }
79
+ if (msg) {
80
+ if (isSuccess) {
81
+ antd_1.message.success(msg);
82
+ }
83
+ else {
84
+ antd_1.message.error(msg);
85
+ }
86
+ }
87
+ return isSuccess;
88
+ };
89
+ exports.tipResponseBatch = tipResponseBatch;
90
+ var tipError = function (response) {
91
+ if (response.code == Global_1.CONFIG.RESULT.success)
92
+ return true;
93
+ if (response.message)
94
+ antd_1.message.error(response.message);
95
+ return false;
96
+ };
97
+ exports.tipError = tipError;
98
+ /**
99
+ * 单个提示
100
+ */
101
+ var tipResponse = function (response, action, data, options) {
102
+ var isSuccess = response.code == Global_1.CONFIG.RESULT.success;
103
+ if (!isSuccess) {
104
+ if (Global_1.CONFIG.APP.TIP_ERROR) {
105
+ if (response.message && !NOT_TIP.has(response.message)) {
106
+ antd_1.message.error(response.message);
107
+ return false;
108
+ }
109
+ }
110
+ }
111
+ // const info = _.assign({}, response.data, data);
112
+ var msg = '';
113
+ if (lodash_1.default.isObject(data)) {
114
+ var info = lodash_1.default.assign({}, data, response.data);
115
+ if (options.label)
116
+ msg = (0, i18n_1.hasKey)(options.label) ? (0, i18n_1.txt)(options.label) : options.label;
117
+ if (options.field && lodash_1.default.has(info, options.field))
118
+ msg += (' : ' + info[options.field]);
119
+ msg = lodash_1.default.trim(msg);
120
+ }
121
+ switch (action) {
122
+ case TIP_ACTION.ADD:
123
+ if (isSuccess) {
124
+ antd_1.message.success((0, i18n_1.txt)(msg ? _i18n_1.V.ACT_ADD_SUCCESS_NAMED : _i18n_1.V.ACT_ADD_SUCCESS, msg));
125
+ }
126
+ else {
127
+ antd_1.message.error((0, i18n_1.txt)(msg ? _i18n_1.V.ACT_ADD_FAIL_NAMED : _i18n_1.V.ACT_ADD_FAIL, msg));
128
+ }
129
+ break;
130
+ case TIP_ACTION.UPDATE:
131
+ if (isSuccess) {
132
+ antd_1.message.success((0, i18n_1.txt)(msg ? _i18n_1.V.ACT_UPDATE_SUCCESS_NAMED : _i18n_1.V.ACT_UPDATE_SUCCESS, msg));
133
+ }
134
+ else {
135
+ antd_1.message.error((0, i18n_1.txt)(msg ? _i18n_1.V.ACT_UPDATE_FAIL_NAMED : _i18n_1.V.ACT_UPDATE_FAIL, msg));
136
+ }
137
+ break;
138
+ case TIP_ACTION.DELETE:
139
+ if (isSuccess) {
140
+ antd_1.message.success((0, i18n_1.txt)(msg ? _i18n_1.V.ACT_DELETE_SUCCESS_NAMED : _i18n_1.V.ACT_DELETE_SUCCESS, msg));
141
+ }
142
+ else {
143
+ antd_1.message.error((0, i18n_1.txt)(msg ? _i18n_1.V.ACT_DELETE_FAIL_NAMED : _i18n_1.V.ACT_DELETE_FAIL, msg));
144
+ }
145
+ break;
146
+ case TIP_ACTION.DELETE_BATCH:
147
+ if (isSuccess) {
148
+ antd_1.message.success((0, i18n_1.txt)(_i18n_1.V.ACT_DELETE_SUCCESS_COUNT, data.length + ''));
149
+ }
150
+ else {
151
+ antd_1.message.error((0, i18n_1.txt)(_i18n_1.V.ACT_DELETE_FAIL_COUNT, data.length + ''));
152
+ }
153
+ default:
154
+ break;
155
+ }
156
+ return isSuccess;
157
+ };
158
+ exports.tipResponse = tipResponse;
@@ -1,5 +1,6 @@
1
1
  import type { PlainObject } from '../basetype';
2
2
  export declare const CACHE_URL: Set<string>;
3
+ export declare const CACHE_TIMER: Map<string, number>;
3
4
  /**
4
5
  * 构造一个等待 Promise ,用于部分场景,如:
5
6
  *
@@ -10,6 +11,11 @@ export declare const CACHE_URL: Set<string>;
10
11
  * ```
11
12
  */
12
13
  export declare const WAIT: (ms: number) => Promise<unknown>;
14
+ /**
15
+ * 和 SESSION 一致 ,缓存一个链接,
16
+ * 链接会在缓存过后一定时间(秒)后自动失效
17
+ */
18
+ export declare const SESSION_TIME: (url: string, second: number) => void;
13
19
  export declare const SESSION: (...urls: string[]) => Set<string>[];
14
20
  export declare const CLEAR: (...urls: string[]) => void[];
15
21
  export interface Result {
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AOP_BEFORE = exports.filterNull = exports.CLEAR = exports.SESSION = exports.WAIT = exports.CACHE_URL = void 0;
6
+ exports.AOP_BEFORE = exports.filterNull = exports.CLEAR = exports.SESSION = exports.SESSION_TIME = exports.WAIT = exports.CACHE_TIMER = exports.CACHE_URL = void 0;
7
7
  var lodash_1 = __importDefault(require("lodash"));
8
8
  var _Support_1 = require("./_Support");
9
9
  var Global_1 = require("./Global");
10
10
  exports.CACHE_URL = (0, _Support_1.globalDefault)('_INNER_CACHE', new Set());
11
+ exports.CACHE_TIMER = (0, _Support_1.globalDefault)('_INNER_CACHE_TIMER', new Map());
11
12
  /**
12
13
  * 构造一个等待 Promise ,用于部分场景,如:
13
14
  *
@@ -19,6 +20,15 @@ exports.CACHE_URL = (0, _Support_1.globalDefault)('_INNER_CACHE', new Set());
19
20
  */
20
21
  var WAIT = function (ms) { return new Promise(function (r) { return setTimeout(r, ms); }); };
21
22
  exports.WAIT = WAIT;
23
+ /**
24
+ * 和 SESSION 一致 ,缓存一个链接,
25
+ * 链接会在缓存过后一定时间(秒)后自动失效
26
+ */
27
+ var SESSION_TIME = function (url, second) {
28
+ exports.CACHE_URL.add(url);
29
+ exports.CACHE_TIMER.set(url, second * 1000);
30
+ };
31
+ exports.SESSION_TIME = SESSION_TIME;
22
32
  var SESSION = function () {
23
33
  var urls = [];
24
34
  for (var _i = 0; _i < arguments.length; _i++) {
package/utils/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * as PageUtil from './PageUtil';
4
4
  export * as ArrayUtil from './ArrayUtil';
5
5
  export * as EventUtil from './EventUtil';
6
6
  export * as CacheUtil from './CacheUtil';
7
+ export * as TipUtil from './TipUtil';
7
8
  export * as Format from './Format';
8
9
  export * as Ajax from './Ajax';
9
10
  export * as i18n from './i18n';
package/utils/index.js CHANGED
@@ -51,7 +51,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
51
  return (mod && mod.__esModule) ? mod : { "default": mod };
52
52
  };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.renderRoot = exports.registerRoute = exports.VAP = exports.Const = exports.Renders = exports.GLOBAL = exports.i18n = exports.Ajax = exports.Format = exports.CacheUtil = exports.EventUtil = exports.ArrayUtil = exports.PageUtil = exports.TreeUtil = exports.StringUtil = void 0;
54
+ exports.renderRoot = exports.registerRoute = exports.VAP = exports.Const = exports.Renders = exports.GLOBAL = exports.i18n = exports.Ajax = exports.Format = exports.TipUtil = exports.CacheUtil = exports.EventUtil = exports.ArrayUtil = exports.PageUtil = exports.TreeUtil = exports.StringUtil = void 0;
55
55
  var lodash_1 = __importDefault(require("lodash"));
56
56
  // 全局 UTILS 定义
57
57
  exports.StringUtil = __importStar(require("./StringUtil"));
@@ -60,6 +60,7 @@ exports.PageUtil = __importStar(require("./PageUtil"));
60
60
  exports.ArrayUtil = __importStar(require("./ArrayUtil"));
61
61
  exports.EventUtil = __importStar(require("./EventUtil"));
62
62
  exports.CacheUtil = __importStar(require("./CacheUtil"));
63
+ exports.TipUtil = __importStar(require("./TipUtil"));
63
64
  exports.Format = __importStar(require("./Format"));
64
65
  exports.Ajax = __importStar(require("./Ajax"));
65
66
  exports.i18n = __importStar(require("./i18n"));