vap1 0.2.2 → 0.2.4
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.
- package/components/Box/Box.js +75 -42
- package/components/Box/SelectBar.js +51 -24
- package/components/Box/_register.d.ts +4 -0
- package/components/Box/_register.js +10 -8
- package/components/Box/index.js +1 -1
- package/components/Lists/SList.js +76 -48
- package/components/SearchBar/ActionButtons.js +75 -42
- package/components/SearchBar/ByField.js +80 -52
- package/components/SearchBar/ByKeyword.js +44 -17
- package/components/SearchBar/SearchField.js +8 -8
- package/components/SearchBar/SearchTags.js +4 -4
- package/components/SearchBar/_register.js +9 -8
- package/components/SearchBar/index.js +22 -11
- package/components/Tables/ApiTable.d.ts +1 -1
- package/components/Tables/ApiTable.js +19 -8
- package/components/Tables/ApiTableModal.d.ts +1 -1
- package/components/Tables/ApiTableModal.js +40 -13
- package/components/Tables/Components/ActionBar.js +53 -26
- package/components/Tables/Components/Actions.js +40 -29
- package/components/Tables/Components/Summary.js +2 -2
- package/components/Tables/Components/index.js +3 -3
- package/components/Tables/STable.js +21 -10
- package/components/Tables/TopTable.d.ts +3 -2
- package/components/Tables/TopTable.js +64 -37
- package/components/Tables/TopTableModal.js +21 -10
- package/components/Tables/Util.d.ts +2 -2
- package/components/Tables/Util.js +11 -9
- package/components/Tables/VTable.d.ts +2 -2
- package/components/Tables/VTable.js +137 -65
- package/components/Tables/index.d.ts +7 -2
- package/components/Tables/index.js +5 -5
- package/components/TreeSelect/BaseTreeSelect.js +81 -45
- package/components/TreeSelect/DTreeSelect.js +191 -66
- package/components/TreeSelect/FTreeSelect.js +67 -20
- package/components/TreeSelect/STreeSelect.js +22 -11
- package/components/Trees/ActionTree.js +562 -431
- package/components/Trees/BaseTree.js +85 -38
- package/components/Trees/COTree/COButton.js +48 -21
- package/components/Trees/COTree/COSelect.js +31 -20
- package/components/Trees/COTree/COTree.js +223 -107
- package/components/Trees/COTree/COTreeUtil.js +160 -115
- package/components/Trees/DTree.js +139 -68
- package/components/Trees/FTree.js +76 -29
- package/components/Trees/STree.js +59 -23
- package/components/UForm/FormWrapper.js +70 -53
- package/components/UForm/UDescriptions.js +38 -38
- package/components/UForm/UForm.js +240 -135
- package/components/UForm/UFormModal.js +99 -44
- package/components/UForm/UInfo.js +33 -22
- package/components/UForm/UInfoModal.js +31 -20
- package/components/UForm/UModal.js +40 -13
- package/components/UForm/_FormUtils.js +29 -18
- package/components/UForm/_input.js +75 -39
- package/components/UForm/_register.js +11 -9
- package/components/Upload/UploadFile.js +38 -11
- package/components/Upload/UploadImage.js +50 -23
- package/components/Upload/UploadModal.js +149 -84
- package/components/Upload/useUpload.js +35 -19
- package/components/_RegisterUtil.js +20 -8
- package/components/_adapt/Alert.js +20 -9
- package/components/_adapt/Breadcrumb.js +18 -7
- package/components/_adapt/Button.js +24 -13
- package/components/_adapt/Col.js +34 -23
- package/components/_adapt/Collapse.js +21 -10
- package/components/_adapt/ColorPicker.js +55 -28
- package/components/_adapt/ConfigProvider.js +14 -3
- package/components/_adapt/Drawer.js +18 -7
- package/components/_adapt/Dropdown.js +23 -12
- package/components/_adapt/FloatButton.js +21 -10
- package/components/_adapt/Icon.js +18 -7
- package/components/_adapt/Input.js +17 -6
- package/components/_adapt/InputNumber.js +16 -5
- package/components/_adapt/Layout.js +84 -28
- package/components/_adapt/Menu.js +28 -17
- package/components/_adapt/Modal.js +72 -25
- package/components/_adapt/Pagination.js +14 -3
- package/components/_adapt/Popconfirm.js +17 -6
- package/components/_adapt/Popover.js +17 -6
- package/components/_adapt/Progress.js +42 -11
- package/components/_adapt/Radio.js +21 -10
- package/components/_adapt/Row.js +18 -7
- package/components/_adapt/Select.js +54 -43
- package/components/_adapt/Slider.js +1 -1
- package/components/_adapt/Space.js +2 -2
- package/components/_adapt/Table.js +16 -5
- package/components/_adapt/Tabs.js +17 -6
- package/components/_adapt/Tag.js +19 -8
- package/components/_adapt/Tooltip.js +15 -4
- package/components/_adapt/TreeSelect.js +18 -7
- package/components/_adapt/notification.js +1 -1
- package/components/_adapt/todo/Image.js +2 -2
- package/components/_adapt/todo/NotEffectOnV15.js +1 -1
- package/components/_adapt/todo/Segmented.js +2 -2
- package/components/_adapt/utils.js +28 -8
- package/components/_common/AutoComplete.js +101 -34
- package/components/_common/CountUp.js +30 -14
- package/components/_common/DateRange.d.ts +10 -2
- package/components/_common/DateRange.js +65 -69
- package/components/_common/HighLight.js +22 -6
- package/components/_common/I18N.js +27 -2
- package/components/_common/Loading.js +25 -9
- package/components/_common/MonthRange.js +26 -26
- package/components/_common/PromiseLabel.js +68 -15
- package/components/_common/Role.js +2 -2
- package/components/_common/Upagination.js +45 -34
- package/components/_setup/Const.js +2 -2
- package/components/_setup/I18N/enUS.js +2 -2
- package/components/_setup/I18N/zhCN.js +3 -3
- package/components/_setup/I18N/zhHK.js +2 -2
- package/components/_setup/ICON/IconTypes.js +2 -2
- package/components/_setup/SearchField/SearchFieldAdvance.js +22 -11
- package/components/_setup/SearchField/SearchFieldDate.js +116 -79
- package/components/_setup/SearchField/SearchFieldInput.js +21 -10
- package/components/_setup/SearchField/SearchFieldSelect.js +55 -44
- package/components/_setup/SearchField/SearchFieldTree.js +63 -52
- package/components/_setup/SelectBar/SelectList.js +21 -10
- package/components/_setup/SelectBar/SelectTree.js +17 -6
- package/components/_setup/UForm/UFormAdvanceInput.js +105 -78
- package/components/_setup/UForm/UFormCOTree.js +21 -10
- package/components/_setup/UForm/UFormCrontab.js +51 -35
- package/components/_setup/UForm/UFormDate.js +160 -124
- package/components/_setup/UForm/UFormInput.js +113 -72
- package/components/_setup/UForm/UFormJSON.js +95 -57
- package/components/_setup/UForm/UFormJSONTable.js +79 -41
- package/components/_setup/UForm/UFormOrg.js +112 -48
- package/components/_setup/UForm/UFormRole.js +31 -20
- package/components/_setup/UForm/UFormSelect.js +116 -86
- package/components/_setup/UForm/UFormTree.js +52 -41
- package/components/_setup/UForm/UFormUpload.js +62 -34
- package/components/_setup/UForm/_utils.js +9 -9
- package/deps/JsonView.js +18 -7
- package/deps/SpringBoot.js +1 -1
- package/deps/SpringCloud.js +4 -4
- package/deps/_editor/advance/_Image.js +33 -20
- package/deps/_editor/base/Element.js +28 -17
- package/deps/_editor/base/Leaf.js +18 -7
- package/deps/_editor/base/Support.js +4 -4
- package/deps/_editor/i18n.js +1 -1
- package/deps/_editor/tools/Button.js +31 -19
- package/deps/_editor/tools/ToolBar.js +3 -3
- package/deps/_editor/tools/_BlockButton.js +49 -27
- package/deps/_editor/tools/_InsertButton.js +32 -28
- package/deps/_editor/tools/_MarkButton.js +15 -14
- package/deps/_editor/tools/_TxtButton.js +90 -58
- package/deps/api-audit.js +1 -1
- package/deps/echarts.js +65 -18
- package/deps/editor.js +52 -26
- package/deps/registerEditor.js +18 -7
- package/hooks/_list.js +1 -1
- package/hooks/useAjax.js +43 -19
- package/hooks/useAjaxAction.js +57 -20
- package/hooks/useAjaxQuery.js +121 -51
- package/hooks/useApi.js +35 -8
- package/hooks/useApiBase.js +291 -184
- package/hooks/useApiGlobal.js +40 -13
- package/hooks/useApp.js +4 -4
- package/hooks/useArray.js +114 -52
- package/hooks/useDefault.js +19 -3
- package/hooks/useDoLoad.js +25 -9
- package/hooks/useEffectFunction.js +4 -3
- package/hooks/useEffectOnce.js +5 -5
- package/hooks/useError.js +21 -5
- package/hooks/useFirstMountState.js +3 -3
- package/hooks/useGenkey.js +7 -7
- package/hooks/useGetSet.js +9 -9
- package/hooks/useGlobal.js +58 -29
- package/hooks/useHover.js +25 -9
- package/hooks/useMemoPromise.js +62 -22
- package/hooks/useModals.js +71 -36
- package/hooks/useMountedState.js +6 -6
- package/hooks/useOpenState.js +26 -10
- package/hooks/usePromise.js +15 -13
- package/hooks/useQueue.js +35 -8
- package/hooks/useSetState.js +25 -8
- package/hooks/useStateList.js +30 -18
- package/hooks/useSyncExternalStore.js +31 -15
- package/hooks/useToggle.js +6 -3
- package/hooks/useUnmountPromise.js +11 -11
- package/hooks/useUpdate.js +20 -4
- package/hooks/useUpdateEffect.js +5 -5
- package/login/Base65.js +15 -14
- package/login/Password.js +91 -38
- package/login/SM4.js +50 -49
- package/login/cems/index.js +2 -2
- package/login/jit/index.js +16 -71
- package/login/jit/pnxclient.js +6 -4
- package/login/vap/index.js +1 -1
- package/login/xrtx/index.js +2 -2
- package/package.json +1 -1
- package/screen/Comment.js +16 -5
- package/screen/Page.js +14 -14
- package/screen/render.js +2 -2
- package/uform/FormEditor.js +43 -26
- package/uform/FormViewer.js +30 -19
- package/uform/hooks/useEditor.js +83 -47
- package/uform/hooks/useForm.js +2 -2
- package/uform/index.js +10 -10
- package/uform/inputs/_advance.js +12 -12
- package/uform/inputs/_date.js +63 -52
- package/uform/inputs/_input.js +49 -38
- package/uform/inputs/_select.js +53 -42
- package/uform/inputs/_specific.js +33 -22
- package/uform/inputs/index.js +5 -5
- package/uform/inputs/register.js +14 -14
- package/uform/panel/Editor/GroupEditor.js +31 -31
- package/uform/panel/Editor/ListEditor.js +22 -22
- package/uform/panel/Editor/_FieldItems.js +16 -16
- package/uform/panel/Editor/_GroupCollapse.js +9 -9
- package/uform/panel/Editor/_GroupDefault.js +9 -9
- package/uform/panel/Editor/_GroupStep.js +18 -18
- package/uform/panel/Editor/_GroupTab.js +16 -16
- package/uform/panel/Editor/index.js +17 -17
- package/uform/panel/Items/index.js +22 -11
- package/uform/panel/Propreties/CanvasProperties.js +14 -14
- package/uform/panel/Propreties/Component/FieldPlugin.js +5 -5
- package/uform/panel/Propreties/Component/LinkAsyncFunction.js +22 -47
- package/uform/panel/Propreties/Component/LinkSyncFunction.js +20 -43
- package/uform/panel/Propreties/Component/Links.js +40 -29
- package/uform/panel/Propreties/Component/OptionTable.js +97 -52
- package/uform/panel/Propreties/Component/RegexpModal.js +11 -11
- package/uform/panel/Propreties/Component/Validate.js +35 -24
- package/uform/panel/Propreties/Component/ValidateAsyncFunction.js +13 -24
- package/uform/panel/Propreties/Component/ValidateSyncFunction.js +15 -38
- package/uform/panel/Propreties/FieldOptions.js +78 -44
- package/uform/panel/Propreties/FieldProperties.js +47 -20
- package/uform/panel/Propreties/GroupProperties.js +9 -9
- package/uform/panel/Propreties/_ItemAdvance.js +37 -26
- package/uform/panel/Propreties/_ItemBase.js +30 -19
- package/uform/panel/Propreties/_ItemLink.js +20 -9
- package/uform/panel/Propreties/_ItemValidate.js +33 -22
- package/uform/plugins/index.js +7 -7
- package/uform/utils/Convert.js +137 -94
- package/uform/utils/SchemaConvert.js +43 -68
- package/uform/utils/arr.js +103 -75
- package/utils/Ajax.d.ts +1 -11
- package/utils/Ajax.js +154 -68
- package/utils/ArrayUtil.js +14 -12
- package/utils/CacheUtil.js +19 -13
- package/utils/Const.js +13 -13
- package/utils/CustomApp.js +15 -10
- package/utils/EventUtil.js +78 -14
- package/utils/Format.js +59 -38
- package/utils/Global.js +8 -8
- package/utils/Logger.js +56 -11
- package/utils/PageUtil.d.ts +12 -6
- package/utils/PageUtil.js +105 -35
- package/utils/Renders/ApiGetRender.js +187 -100
- package/utils/Renders/ApiPostRender.js +123 -69
- package/utils/Renders/DateRender.js +9 -9
- package/utils/Renders/DictRender.js +82 -55
- package/utils/Renders/FileRender.js +34 -12
- package/utils/Renders/ListRender.js +21 -21
- package/utils/Renders/NumberRender.js +14 -13
- package/utils/Renders/StatusRender.js +20 -20
- package/utils/Renders/StringRender.js +17 -17
- package/utils/Renders/_define.d.ts +2 -2
- package/utils/Renders/_define.js +7 -7
- package/utils/StringUtil.js +98 -67
- package/utils/TreeUtil.js +71 -20
- package/utils/VAP.js +14 -14
- package/utils/XHR.js +27 -11
- package/utils/_AjaxUtil.d.ts +10 -0
- package/utils/_AjaxUtil.js +35 -12
- package/utils/_Support.js +26 -26
- package/utils/i18n.js +78 -44
- package/utils/index.d.ts +9 -1
- package/utils/index.js +34 -5
- package/utils/screenful.js +82 -29
- package/widget/index.js +4 -4
package/uform/utils/arr.js
CHANGED
|
@@ -1,34 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
+
if (ar || !(i in from)) {
|
|
32
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
+
ar[i] = from[i];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
|
+
};
|
|
2
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
40
|
};
|
|
5
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
42
|
exports.setPropertiesInGroup = exports.setProperties = exports.sortListInGroup = exports.sortList = exports.insertInGroup = exports.insertInList = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
43
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
44
|
+
var inputs_1 = require("../inputs");
|
|
45
|
+
var antd_1 = require("antd");
|
|
46
|
+
var utils_1 = require("../../utils");
|
|
47
|
+
var insertFieldInList = function (field, list, pos) {
|
|
48
|
+
if (pos === void 0) { pos = null; }
|
|
12
49
|
if (pos == null) {
|
|
13
|
-
return [
|
|
50
|
+
return __spreadArray(__spreadArray([], __read(list), false), [field], false);
|
|
14
51
|
}
|
|
15
|
-
|
|
16
|
-
|
|
52
|
+
var id = pos.id, prev = pos.prev;
|
|
53
|
+
var idx = lodash_1.default.findIndex(list, { id: id });
|
|
17
54
|
if (idx < 0) {
|
|
18
|
-
return [
|
|
55
|
+
return __spreadArray(__spreadArray([], __read(list), false), [field], false);
|
|
19
56
|
}
|
|
20
|
-
|
|
21
|
-
return [
|
|
57
|
+
var inSertPos = prev ? idx : idx + 1;
|
|
58
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read(lodash_1.default.slice(list, 0, inSertPos)), false), [field], false), __read(lodash_1.default.slice(list, inSertPos)), false);
|
|
22
59
|
};
|
|
23
60
|
// 插入一个字段到列表指定位置
|
|
24
|
-
|
|
25
|
-
|
|
61
|
+
var insertInList = function (fieldType, list, pos) {
|
|
62
|
+
if (pos === void 0) { pos = null; }
|
|
63
|
+
var info = (0, inputs_1.getInput)(fieldType);
|
|
26
64
|
if (info == null) {
|
|
27
65
|
antd_1.message.error('无此类型');
|
|
28
66
|
return list;
|
|
29
67
|
}
|
|
30
|
-
|
|
31
|
-
|
|
68
|
+
var key = utils_1.StringUtil.genKey();
|
|
69
|
+
var field = { id: key, type: fieldType, title: info.title, field: key };
|
|
32
70
|
if (info.defaultProperties)
|
|
33
71
|
lodash_1.default.assign(field, info.defaultProperties);
|
|
34
72
|
if (info.defaultConfig)
|
|
@@ -47,48 +85,47 @@ const insertInList = (fieldType, list, pos = null) => {
|
|
|
47
85
|
};
|
|
48
86
|
exports.insertInList = insertInList;
|
|
49
87
|
// 插入一个字段到分组指定位置
|
|
50
|
-
|
|
51
|
-
|
|
88
|
+
var insertInGroup = function (fieldType, list, groupId, pos) {
|
|
89
|
+
if (pos === void 0) { pos = null; }
|
|
90
|
+
var idx = lodash_1.default.findIndex(list, { id: groupId });
|
|
52
91
|
if (idx < 0) {
|
|
53
92
|
return list;
|
|
54
93
|
}
|
|
55
|
-
|
|
56
|
-
return [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
...lodash_1.default.slice(list, idx + 1)
|
|
60
|
-
];
|
|
94
|
+
var group = list[idx];
|
|
95
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read(lodash_1.default.slice(list, 0, idx)), false), [
|
|
96
|
+
__assign(__assign({}, group), { fields: (0, exports.insertInList)(fieldType, group.fields, pos) })
|
|
97
|
+
], false), __read(lodash_1.default.slice(list, idx + 1)), false);
|
|
61
98
|
};
|
|
62
99
|
exports.insertInGroup = insertInGroup;
|
|
63
100
|
// 在列表内字段拖拽排序
|
|
64
|
-
|
|
101
|
+
var sortList = function (id, fields, pos) {
|
|
65
102
|
if (pos == null) {
|
|
66
103
|
return fields;
|
|
67
104
|
}
|
|
68
|
-
|
|
105
|
+
var idx = lodash_1.default.findIndex(fields, { id: id });
|
|
69
106
|
if (idx < 0) {
|
|
70
107
|
return fields;
|
|
71
108
|
}
|
|
72
|
-
|
|
109
|
+
var tdx = lodash_1.default.findIndex(fields, { id: pos.id });
|
|
73
110
|
if (tdx < 0 || tdx == idx) {
|
|
74
111
|
return fields;
|
|
75
112
|
}
|
|
76
113
|
if ((pos.prev && tdx - idx == 1) || (!pos.prev && idx - tdx == 1)) {
|
|
77
114
|
return fields;
|
|
78
115
|
}
|
|
79
|
-
|
|
116
|
+
var sorted = fields.filter(function (item) { return item.id != id; });
|
|
80
117
|
tdx = lodash_1.default.findIndex(sorted, { id: pos.id });
|
|
81
|
-
|
|
82
|
-
return [
|
|
118
|
+
var inSertPos = pos.prev ? tdx : tdx + 1;
|
|
119
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read(lodash_1.default.slice(sorted, 0, inSertPos)), false), [fields[idx]], false), __read(lodash_1.default.slice(sorted, inSertPos)), false);
|
|
83
120
|
};
|
|
84
121
|
exports.sortList = sortList;
|
|
85
122
|
// 字段排序, 在分组里面
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
for (
|
|
123
|
+
var sortListInGroup = function (id, fields, groupId, pos) {
|
|
124
|
+
var _a = __read([-1, -1], 2), gdx = _a[0], fdx = _a[1];
|
|
125
|
+
var group = null;
|
|
126
|
+
for (var i = 0; i < fields.length; i++) {
|
|
90
127
|
group = fields[i];
|
|
91
|
-
|
|
128
|
+
var j = lodash_1.default.findIndex(group.fields, { id: id });
|
|
92
129
|
if (j >= 0) {
|
|
93
130
|
gdx = i;
|
|
94
131
|
fdx = j;
|
|
@@ -100,76 +137,67 @@ const sortListInGroup = (id, fields, groupId, pos) => {
|
|
|
100
137
|
}
|
|
101
138
|
// case 1 : 组内移动
|
|
102
139
|
if (group.id == groupId) {
|
|
103
|
-
return [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
...lodash_1.default.slice(fields, gdx + 1),
|
|
107
|
-
];
|
|
140
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read(lodash_1.default.slice(fields, 0, gdx)), false), [
|
|
141
|
+
__assign(__assign({}, fields[gdx]), { fields: (0, exports.sortList)(id, fields[gdx].fields, pos) })
|
|
142
|
+
], false), __read(lodash_1.default.slice(fields, gdx + 1)), false);
|
|
108
143
|
}
|
|
109
|
-
|
|
144
|
+
var tdx = lodash_1.default.findIndex(fields, { id: groupId });
|
|
110
145
|
if (tdx < 0) {
|
|
111
146
|
return fields;
|
|
112
147
|
}
|
|
113
|
-
|
|
114
|
-
|
|
148
|
+
var sourceGroup = fields[gdx];
|
|
149
|
+
var targetGroup = fields[tdx];
|
|
115
150
|
if (tdx > gdx) {
|
|
116
151
|
// case 2 : 上移到下
|
|
117
|
-
return [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
...lodash_1.default.slice(fields, tdx + 1),
|
|
123
|
-
];
|
|
152
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(lodash_1.default.slice(fields, 0, gdx)), false), [
|
|
153
|
+
__assign(__assign({}, sourceGroup), { fields: lodash_1.default.filter(sourceGroup.fields, function (item) { return item.id != id; }) })
|
|
154
|
+
], false), __read(lodash_1.default.slice(fields, gdx + 1, tdx)), false), [
|
|
155
|
+
__assign(__assign({}, targetGroup), { fields: insertFieldInList(fields[gdx].fields[fdx], targetGroup.fields, pos) })
|
|
156
|
+
], false), __read(lodash_1.default.slice(fields, tdx + 1)), false);
|
|
124
157
|
}
|
|
125
158
|
else {
|
|
126
159
|
// case 3 : 下移到上
|
|
127
|
-
return [
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
...lodash_1.default.slice(fields, gdx + 1),
|
|
133
|
-
];
|
|
160
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(lodash_1.default.slice(fields, 0, tdx)), false), [
|
|
161
|
+
__assign(__assign({}, targetGroup), { fields: insertFieldInList(fields[gdx].fields[fdx], targetGroup.fields, pos) })
|
|
162
|
+
], false), __read(lodash_1.default.slice(fields, tdx + 1, gdx)), false), [
|
|
163
|
+
__assign(__assign({}, sourceGroup), { fields: lodash_1.default.filter(sourceGroup.fields, function (item) { return item.id != id; }) })
|
|
164
|
+
], false), __read(lodash_1.default.slice(fields, gdx + 1)), false);
|
|
134
165
|
}
|
|
135
166
|
};
|
|
136
167
|
exports.sortListInGroup = sortListInGroup;
|
|
137
|
-
|
|
138
|
-
|
|
168
|
+
var setProperties = function (fields, fieldId, property, value) {
|
|
169
|
+
var _a;
|
|
170
|
+
var idx = lodash_1.default.findIndex(fields, { id: fieldId });
|
|
139
171
|
if (idx < 0) {
|
|
140
172
|
return fields;
|
|
141
173
|
}
|
|
142
|
-
|
|
174
|
+
var info;
|
|
143
175
|
if (lodash_1.default.isString(property)) {
|
|
144
176
|
if (value === null) {
|
|
145
177
|
lodash_1.default.unset(info, property);
|
|
146
178
|
}
|
|
147
|
-
info =
|
|
179
|
+
info = __assign(__assign({}, fields[idx]), (_a = {}, _a[property] = value, _a));
|
|
148
180
|
}
|
|
149
181
|
else if (lodash_1.default.isPlainObject(property)) {
|
|
150
|
-
info =
|
|
182
|
+
info = __assign(__assign({}, fields[idx]), property);
|
|
151
183
|
}
|
|
152
|
-
return [
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
...(lodash_1.default.slice(fields, idx + 1))
|
|
156
|
-
];
|
|
184
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read((lodash_1.default.slice(fields, 0, idx))), false), [
|
|
185
|
+
info
|
|
186
|
+
], false), __read((lodash_1.default.slice(fields, idx + 1))), false);
|
|
157
187
|
};
|
|
158
188
|
exports.setProperties = setProperties;
|
|
159
|
-
|
|
160
|
-
|
|
189
|
+
var setPropertiesInGroup = function (fields, groupId, fieldId, property, value) {
|
|
190
|
+
var gdx = lodash_1.default.findIndex(fields, { id: groupId });
|
|
161
191
|
if (gdx < 0) {
|
|
162
192
|
return fields;
|
|
163
193
|
}
|
|
164
|
-
|
|
165
|
-
|
|
194
|
+
var group = fields[gdx];
|
|
195
|
+
var idx = lodash_1.default.findIndex(group.fields, { id: fieldId });
|
|
166
196
|
if (idx < 0) {
|
|
167
197
|
return fields;
|
|
168
198
|
}
|
|
169
|
-
return [
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
...(lodash_1.default.slice(fields, gdx + 1))
|
|
173
|
-
];
|
|
199
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read((lodash_1.default.slice(fields, 0, gdx))), false), [
|
|
200
|
+
__assign(__assign({}, group), { fields: (0, exports.setProperties)(group.fields, fieldId, property, value) })
|
|
201
|
+
], false), __read((lodash_1.default.slice(fields, gdx + 1))), false);
|
|
174
202
|
};
|
|
175
203
|
exports.setPropertiesInGroup = setPropertiesInGroup;
|
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, } from './_AjaxUtil';
|
|
3
|
+
export { SESSION, CLEAR, WAIT } from './_AjaxUtil';
|
|
4
4
|
/**
|
|
5
5
|
* CATCH 方法可以捕获通用的错误并,省去 try/catch 语法
|
|
6
6
|
*/
|
|
@@ -33,16 +33,6 @@ export declare const POST: (url: string, param: PlainObject, options?: AjaxOptio
|
|
|
33
33
|
export declare const PATCH: (url: string, param: PlainObject, options?: AjaxOptions) => Promise<Result>;
|
|
34
34
|
export declare const DELETE: (url: string, param: PlainObject, options?: AjaxOptions) => Promise<Result>;
|
|
35
35
|
export declare const PUT: (url: string, param: PlainObject, options?: AjaxOptions) => Promise<Result>;
|
|
36
|
-
/**
|
|
37
|
-
* 构造一个等待 Promise ,用于部分场景,如:
|
|
38
|
-
*
|
|
39
|
-
* ```typescript
|
|
40
|
-
* console.log(Date.now())
|
|
41
|
-
* await Ajax.WAIT(500); // 延时500ms 后再往下执行
|
|
42
|
-
* console.log(Date.now())
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export declare const WAIT: (ms: number) => Promise<unknown>;
|
|
46
36
|
/**
|
|
47
37
|
* 将所有请求一次性发出,用于一次发多个情求时,提升响应速度
|
|
48
38
|
*
|
package/utils/Ajax.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,102 +19,171 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
19
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
20
|
});
|
|
10
21
|
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
11
65
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
66
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
67
|
};
|
|
14
68
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.WHEN = exports.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
|
70
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
71
|
+
var Global_1 = require("./Global");
|
|
72
|
+
var _Support_1 = require("./_Support");
|
|
73
|
+
var _AjaxUtil_1 = require("./_AjaxUtil");
|
|
20
74
|
var _AjaxUtil_2 = require("./_AjaxUtil");
|
|
21
75
|
Object.defineProperty(exports, "SESSION", { enumerable: true, get: function () { return _AjaxUtil_2.SESSION; } });
|
|
22
76
|
Object.defineProperty(exports, "CLEAR", { enumerable: true, get: function () { return _AjaxUtil_2.CLEAR; } });
|
|
23
|
-
|
|
77
|
+
Object.defineProperty(exports, "WAIT", { enumerable: true, get: function () { return _AjaxUtil_2.WAIT; } });
|
|
78
|
+
var _a = (0, _Support_1.globalDefault)('NProgress', { start: function () { }, done: function () { } }), start = _a.start, done = _a.done;
|
|
24
79
|
/**
|
|
25
80
|
* CATCH 方法可以捕获通用的错误并,省去 try/catch 语法
|
|
26
81
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
82
|
+
var CATCH = function (fn) { return function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
+
var e_1;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
_a.trys.push([0, 2, , 3]);
|
|
88
|
+
return [4 /*yield*/, fn()];
|
|
89
|
+
case 1:
|
|
90
|
+
_a.sent();
|
|
91
|
+
return [3 /*break*/, 3];
|
|
92
|
+
case 2:
|
|
93
|
+
e_1 = _a.sent();
|
|
94
|
+
console.error(e_1);
|
|
95
|
+
return [3 /*break*/, 3];
|
|
96
|
+
case 3: return [2 /*return*/];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}); }; };
|
|
35
100
|
exports.CATCH = CATCH;
|
|
36
101
|
/**
|
|
37
102
|
* 建议使用 `GET` `POST` `PUT` `DELETE` `PATCH` 发送请求。
|
|
38
103
|
*
|
|
39
104
|
* 当满足不了需求时,可使用 `FETCH`,参考与标准 fetch 类似。
|
|
40
105
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
106
|
+
var FETCH = function (url, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var fetchOptions, response, result;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
if (options.process !== false)
|
|
112
|
+
start();
|
|
113
|
+
fetchOptions = lodash_1.default.merge({
|
|
114
|
+
method: 'GET',
|
|
115
|
+
headers: Global_1.CONFIG.AJAX.headers,
|
|
116
|
+
}, options);
|
|
117
|
+
if (fetchOptions.body && lodash_1.default.isPlainObject(fetchOptions.body)) {
|
|
118
|
+
fetchOptions.body = JSON.stringify(fetchOptions.body);
|
|
119
|
+
}
|
|
120
|
+
return [4 /*yield*/, fetch(url, fetchOptions)];
|
|
121
|
+
case 1:
|
|
122
|
+
response = _a.sent();
|
|
123
|
+
if (options.process !== false)
|
|
124
|
+
done();
|
|
125
|
+
if (response.redirected && lodash_1.default.isString(response.url) && response.url.indexOf('login') >= 0) {
|
|
126
|
+
if (window.location.href.indexOf('login') < 0) {
|
|
127
|
+
window.location.href = response.url;
|
|
128
|
+
return [2 /*return*/, new Promise(function (r) { return r({ code: '9999', message: '请先登录' }); })];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (!fetchOptions.text) return [3 /*break*/, 3];
|
|
132
|
+
return [4 /*yield*/, response.text()];
|
|
133
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
134
|
+
case 3: return [4 /*yield*/, response.json()];
|
|
135
|
+
case 4:
|
|
136
|
+
result = _a.sent();
|
|
137
|
+
return [2 /*return*/, result];
|
|
58
138
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return yield response.text();
|
|
62
|
-
}
|
|
63
|
-
let result = yield response.json();
|
|
64
|
-
return result;
|
|
65
|
-
});
|
|
139
|
+
});
|
|
140
|
+
}); };
|
|
66
141
|
exports.FETCH = FETCH;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
142
|
+
var _FETCH = function (method, url, param, options) {
|
|
143
|
+
var _a = __read((0, _AjaxUtil_1.AOP_BEFORE)(url, method, (options && options.headers) ? options.headers : {}, param), 4), _url = _a[0], _method = _a[1], _headers = _a[2], _data = _a[3];
|
|
144
|
+
var fetchOptions = __assign(__assign({}, options), { body: JSON.stringify(_data), headers: _headers, method: _method });
|
|
70
145
|
if (_method == 'GET') {
|
|
71
146
|
lodash_1.default.unset(fetchOptions, 'body');
|
|
72
147
|
}
|
|
73
148
|
return (0, exports.FETCH)(_url, fetchOptions);
|
|
74
149
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
150
|
+
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) {
|
|
154
|
+
case 0:
|
|
155
|
+
if (!(_AjaxUtil_1.CACHE_URL.has(url) && sessionStorage.getItem(url))) return [3 /*break*/, 2];
|
|
156
|
+
return [4 /*yield*/, new Promise(function (r) { return r(JSON.parse(sessionStorage.getItem(url))); })];
|
|
157
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
158
|
+
case 2: return [4 /*yield*/, _FETCH('GET', url, {}, options)];
|
|
159
|
+
case 3:
|
|
160
|
+
resp = _a.sent();
|
|
161
|
+
if (_AjaxUtil_1.CACHE_URL.has(url)) {
|
|
162
|
+
if (lodash_1.default.has(resp, 'code') && resp.code == '0') {
|
|
163
|
+
sessionStorage.setItem(url, JSON.stringify(resp));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return [2 /*return*/, resp];
|
|
83
167
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
});
|
|
168
|
+
});
|
|
169
|
+
}); };
|
|
87
170
|
exports.GET = GET;
|
|
88
|
-
|
|
171
|
+
var POST = function (url, param, options) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
172
|
+
return [2 /*return*/, _FETCH('POST', url, param, options)];
|
|
173
|
+
}); }); };
|
|
89
174
|
exports.POST = POST;
|
|
90
|
-
|
|
175
|
+
var PATCH = function (url, param, options) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
176
|
+
return [2 /*return*/, _FETCH('PATCH', url, param, options)];
|
|
177
|
+
}); }); };
|
|
91
178
|
exports.PATCH = PATCH;
|
|
92
|
-
|
|
179
|
+
var DELETE = function (url, param, options) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
180
|
+
return [2 /*return*/, _FETCH('DELETE', url, param, options)];
|
|
181
|
+
}); }); };
|
|
93
182
|
exports.DELETE = DELETE;
|
|
94
|
-
|
|
183
|
+
var PUT = function (url, param, options) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
184
|
+
return [2 /*return*/, _FETCH('PUT', url, param, options)];
|
|
185
|
+
}); }); };
|
|
95
186
|
exports.PUT = PUT;
|
|
96
|
-
/**
|
|
97
|
-
* 构造一个等待 Promise ,用于部分场景,如:
|
|
98
|
-
*
|
|
99
|
-
* ```typescript
|
|
100
|
-
* console.log(Date.now())
|
|
101
|
-
* await Ajax.WAIT(500); // 延时500ms 后再往下执行
|
|
102
|
-
* console.log(Date.now())
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
const WAIT = (ms) => new Promise(r => setTimeout(r, ms));
|
|
106
|
-
exports.WAIT = WAIT;
|
|
107
187
|
/**
|
|
108
188
|
* 将所有请求一次性发出,用于一次发多个情求时,提升响应速度
|
|
109
189
|
*
|
|
@@ -143,5 +223,11 @@ exports.WAIT = WAIT;
|
|
|
143
223
|
* }
|
|
144
224
|
* ```
|
|
145
225
|
*/
|
|
146
|
-
|
|
226
|
+
var WHEN = function () {
|
|
227
|
+
var pos = [];
|
|
228
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
229
|
+
pos[_i] = arguments[_i];
|
|
230
|
+
}
|
|
231
|
+
return Promise.all(pos);
|
|
232
|
+
};
|
|
147
233
|
exports.WHEN = WHEN;
|
package/utils/ArrayUtil.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.del = exports.add = exports.update = void 0;
|
|
7
|
-
|
|
7
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
/**
|
|
9
9
|
* 更新一个列表中的一个对象,并返回一个新的列表
|
|
10
10
|
* @param list 需要被修改的列表
|
|
@@ -12,13 +12,14 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
12
12
|
* @param rowKey 列表中数据的主键,如果不传,则为 `id`
|
|
13
13
|
* @return 一个新的列表
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
var update = function (list, data, rowKey) {
|
|
16
|
+
if (rowKey === void 0) { rowKey = 'id'; }
|
|
17
|
+
var arr = lodash_1.default.slice(list);
|
|
18
|
+
var param = {};
|
|
18
19
|
param[rowKey] = data[rowKey];
|
|
19
|
-
|
|
20
|
+
var index = lodash_1.default.findIndex(arr, param);
|
|
20
21
|
if (index >= 0) {
|
|
21
|
-
|
|
22
|
+
var obj = lodash_1.default.assign({}, data);
|
|
22
23
|
arr[index] = obj;
|
|
23
24
|
}
|
|
24
25
|
return arr;
|
|
@@ -29,8 +30,8 @@ exports.update = update;
|
|
|
29
30
|
* @param list 需要被插入的列表
|
|
30
31
|
* @param data 新的数据
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
var add = function (list, data) {
|
|
34
|
+
var arr = lodash_1.default.slice(list);
|
|
34
35
|
arr.unshift(data);
|
|
35
36
|
return arr;
|
|
36
37
|
};
|
|
@@ -41,9 +42,10 @@ exports.add = add;
|
|
|
41
42
|
* @param ids 需要删除的 id 列表
|
|
42
43
|
* @param rowKey 每条数据的识别的主键 默认为 'id'
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
|
+
var del = function (list, ids, rowKey) {
|
|
46
|
+
if (rowKey === void 0) { rowKey = 'id'; }
|
|
45
47
|
if (lodash_1.default.isArray(ids)) {
|
|
46
|
-
|
|
48
|
+
var toDelete_1 = new Set(ids.map(function (id) {
|
|
47
49
|
if (lodash_1.default.isPlainObject(id)) {
|
|
48
50
|
return id[rowKey] + '';
|
|
49
51
|
}
|
|
@@ -51,8 +53,8 @@ const del = (list, ids, rowKey = 'id') => {
|
|
|
51
53
|
return id + '';
|
|
52
54
|
}
|
|
53
55
|
}));
|
|
54
|
-
return lodash_1.default.filter(list, item
|
|
56
|
+
return lodash_1.default.filter(list, function (item) { return !toDelete_1.has(item[rowKey] + ''); });
|
|
55
57
|
}
|
|
56
|
-
return lodash_1.default.filter(list, item
|
|
58
|
+
return lodash_1.default.filter(list, function (item) { return ids != item[rowKey]; });
|
|
57
59
|
};
|
|
58
60
|
exports.del = del;
|