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
|
@@ -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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -31,23 +42,75 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
42
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
43
|
});
|
|
33
44
|
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
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;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
73
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
74
|
+
if (!m) return o;
|
|
75
|
+
var i = m.call(o), r, ar = [], e;
|
|
76
|
+
try {
|
|
77
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
78
|
+
}
|
|
79
|
+
catch (error) { e = { error: error }; }
|
|
80
|
+
finally {
|
|
81
|
+
try {
|
|
82
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
83
|
+
}
|
|
84
|
+
finally { if (e) throw e.error; }
|
|
85
|
+
}
|
|
86
|
+
return ar;
|
|
87
|
+
};
|
|
88
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
89
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
90
|
+
if (ar || !(i in from)) {
|
|
91
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
92
|
+
ar[i] = from[i];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
96
|
+
};
|
|
34
97
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
98
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
99
|
};
|
|
37
100
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
101
|
exports.getResponseList = exports.renderRoot = exports.ActionTree = exports.useActionTree = void 0;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
102
|
+
var react_1 = __importStar(require("react"));
|
|
103
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
104
|
+
var antd_1 = require("antd");
|
|
105
|
+
var Popconfirm_1 = require("../_adapt/Popconfirm");
|
|
106
|
+
var Dropdown_1 = require("../_adapt/Dropdown");
|
|
107
|
+
var BaseTree_1 = require("./BaseTree");
|
|
108
|
+
var Icon_1 = require("../_adapt/Icon");
|
|
109
|
+
var UFormModal_1 = require("../UForm/UFormModal");
|
|
110
|
+
var utils_1 = require("../../utils");
|
|
111
|
+
var Const_1 = require("../_setup/Const");
|
|
112
|
+
var useModals_1 = require("../../hooks/useModals");
|
|
113
|
+
var STEP = 16;
|
|
51
114
|
var INSER_POS;
|
|
52
115
|
(function (INSER_POS) {
|
|
53
116
|
INSER_POS[INSER_POS["BEFORE"] = 0] = "BEFORE";
|
|
@@ -57,15 +120,15 @@ var INSER_POS;
|
|
|
57
120
|
INSER_POS[INSER_POS["BOTTOM"] = 4] = "BOTTOM";
|
|
58
121
|
})(INSER_POS || (INSER_POS = {}));
|
|
59
122
|
;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
123
|
+
var txt = utils_1.i18n.txt;
|
|
124
|
+
var ActionTreeContext = (0, react_1.createContext)(null);
|
|
125
|
+
var useActionTree = function () { return (0, react_1.useContext)(ActionTreeContext); };
|
|
63
126
|
exports.useActionTree = useActionTree;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
127
|
+
var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
|
|
128
|
+
var _a = (0, BaseTree_1.useBaseTree)(), treeState = _a.treeState, setTreeData = _a.setTreeData;
|
|
129
|
+
var modals = (0, useModals_1.useModals)();
|
|
130
|
+
var FIELDS = (0, react_1.useRef)([]);
|
|
131
|
+
var getDefault = (0, react_1.useCallback)(function () {
|
|
69
132
|
if (props.formDefault == null)
|
|
70
133
|
return {};
|
|
71
134
|
if (lodash_1.default.isPlainObject(props.formDefault))
|
|
@@ -74,7 +137,7 @@ const _Actiontree = (0, react_1.forwardRef)((props, ref) => {
|
|
|
74
137
|
return props.formDefault(treeState.selectedNode);
|
|
75
138
|
return {};
|
|
76
139
|
}, [treeState.selectedNode]);
|
|
77
|
-
|
|
140
|
+
var action = {
|
|
78
141
|
objectName: '',
|
|
79
142
|
canAdd: false,
|
|
80
143
|
canAddRoot: false,
|
|
@@ -108,26 +171,30 @@ const _Actiontree = (0, react_1.forwardRef)((props, ref) => {
|
|
|
108
171
|
if (props.canSort && treeState.sortField)
|
|
109
172
|
action.canSort = true;
|
|
110
173
|
}
|
|
111
|
-
(0, react_1.useImperativeHandle)(ref, ()
|
|
112
|
-
updateData
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
174
|
+
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
175
|
+
updateData: updateData,
|
|
176
|
+
update: update,
|
|
177
|
+
del: del,
|
|
178
|
+
add: function (data, position) {
|
|
179
|
+
var nodePath = position.map(function (i) { return "[".concat(i, "]"); }).join('.children');
|
|
180
|
+
var treeData = treeState.treeData;
|
|
181
|
+
var node = lodash_1.default.get(treeData, nodePath);
|
|
116
182
|
if (node == null) {
|
|
117
183
|
antd_1.message.error('No parent found');
|
|
118
184
|
}
|
|
119
|
-
add(data, { pos: INSER_POS.INNER, node, position });
|
|
185
|
+
add(data, { pos: INSER_POS.INNER, node: node, position: position });
|
|
120
186
|
}
|
|
121
|
-
}), [treeState.treeData]);
|
|
122
|
-
(0, react_1.useLayoutEffect)(()
|
|
187
|
+
}); }, [treeState.treeData]);
|
|
188
|
+
(0, react_1.useLayoutEffect)(function () {
|
|
123
189
|
if (props.formFields) {
|
|
124
190
|
FIELDS.current = props.formFields;
|
|
125
191
|
return;
|
|
126
192
|
}
|
|
127
|
-
|
|
193
|
+
var fields = [];
|
|
128
194
|
if (treeState.langs) {
|
|
129
|
-
treeState.langs.map((
|
|
130
|
-
|
|
195
|
+
treeState.langs.map(function (_a) {
|
|
196
|
+
var lang = _a.lang, field = _a.field;
|
|
197
|
+
fields.push({ title: "".concat(action.objectName, "(").concat(lang, ")"), field: field });
|
|
131
198
|
});
|
|
132
199
|
}
|
|
133
200
|
else {
|
|
@@ -136,371 +203,435 @@ const _Actiontree = (0, react_1.forwardRef)((props, ref) => {
|
|
|
136
203
|
FIELDS.current = fields;
|
|
137
204
|
// ref.current
|
|
138
205
|
}, []);
|
|
139
|
-
|
|
140
|
-
|
|
206
|
+
var showAdd = function (pos, node, position) { return modals.showAdd({ pos: pos, node: node, position: position }); };
|
|
207
|
+
var showEdit = function (node, position) { return modals.showEdit(node, { position: position }); };
|
|
141
208
|
// ref.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
let rootPath = nodePath + '.children';
|
|
192
|
-
var tree = lodash_1.default.concat([], treeData);
|
|
193
|
-
let arr = lodash_1.default.get(tree, rootPath);
|
|
194
|
-
if (arr == null)
|
|
195
|
-
arr = [];
|
|
196
|
-
var param = Object.assign(Object.assign({}, data), { [parentField]: node[keyField] });
|
|
197
|
-
if (canSort) {
|
|
198
|
-
let sort = STEP;
|
|
199
|
-
if (arr == null) {
|
|
200
|
-
if (lodash_1.default.isFunction(props.getChildren)) {
|
|
201
|
-
arr = yield props.getChildren(node[keyField]);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (arr && arr.length) {
|
|
205
|
-
sort = arr[arr.length - 1][sortField] + STEP;
|
|
206
|
-
}
|
|
207
|
-
param[sortField] = sort;
|
|
208
|
-
}
|
|
209
|
-
const resp = yield utils_1.Ajax.PUT(api, param);
|
|
210
|
-
if (resp.code != '0') {
|
|
211
|
-
antd_1.message.error(txt(Const_1.V.ACT_ADD_FAIL_NAMED, `${objectName} : ${data[titleField]}`));
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
antd_1.message.success(txt(Const_1.V.ACT_ADD_SUCCESS_NAMED, `${objectName} : ${data[titleField]}`));
|
|
215
|
-
arr.push(resp.data);
|
|
216
|
-
props.clearCache(node[keyField]);
|
|
217
|
-
lodash_1.default.set(tree, rootPath, arr);
|
|
218
|
-
setTreeData(tree);
|
|
219
|
-
});
|
|
220
|
-
const add = (data, extra) => __awaiter(void 0, void 0, void 0, function* () {
|
|
221
|
-
const { pos, position } = extra;
|
|
222
|
-
if (position.length <= 0)
|
|
223
|
-
return;
|
|
224
|
-
if (pos == INSER_POS.TOP || pos == INSER_POS.BOTTOM) {
|
|
225
|
-
addRoot(data, extra);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
let root = lodash_1.default.concat([], position);
|
|
229
|
-
if (pos == INSER_POS.INNER) {
|
|
230
|
-
addInner(data, extra);
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
const { idForApiField } = props;
|
|
234
|
-
const { api, objectName, canSort } = action;
|
|
235
|
-
const { parentField, titleField, sortField, keyField, treeData } = treeState;
|
|
236
|
-
const idField = idForApiField || keyField;
|
|
237
|
-
var tree = lodash_1.default.concat([], treeData);
|
|
238
|
-
let idx = root.pop();
|
|
239
|
-
let nodePath;
|
|
240
|
-
let arr;
|
|
241
|
-
if (root.length == 0) {
|
|
242
|
-
arr = tree;
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
nodePath = root.map(i => `[${i}].children`).join('');
|
|
246
|
-
arr = lodash_1.default.get(tree, nodePath);
|
|
247
|
-
}
|
|
248
|
-
const obj = arr[idx];
|
|
249
|
-
let promises = [];
|
|
250
|
-
let needLoop = false;
|
|
251
|
-
let lastSort = STEP;
|
|
252
|
-
let dataDefault = getDefault();
|
|
253
|
-
if (!canSort) {
|
|
254
|
-
promises.push(utils_1.Ajax.PUT(api, Object.assign(Object.assign(Object.assign({}, dataDefault), data), { [parentField]: obj[parentField] })));
|
|
255
|
-
}
|
|
256
|
-
else if (pos == INSER_POS.BEFORE) {
|
|
257
|
-
try {
|
|
258
|
-
lastSort = parseInt(obj[sortField]);
|
|
259
|
-
}
|
|
260
|
-
catch (_a) {
|
|
209
|
+
var addRoot = function (data, extra) { return __awaiter(void 0, void 0, void 0, function () {
|
|
210
|
+
var pos, position, parentField, titleField, sortField, rootCode, treeData, child, api, objectName, sort, param, result, tree;
|
|
211
|
+
var _a;
|
|
212
|
+
return __generator(this, function (_b) {
|
|
213
|
+
switch (_b.label) {
|
|
214
|
+
case 0:
|
|
215
|
+
pos = extra.pos, position = extra.position;
|
|
216
|
+
parentField = treeState.parentField, titleField = treeState.titleField, sortField = treeState.sortField, rootCode = treeState.rootCode, treeData = treeState.treeData;
|
|
217
|
+
if (position.length > 2)
|
|
218
|
+
return [2 /*return*/];
|
|
219
|
+
if (position.length == 2) {
|
|
220
|
+
if (treeData.length != 1)
|
|
221
|
+
return [2 /*return*/];
|
|
222
|
+
child = treeData[0].children || [];
|
|
223
|
+
if (child.length == 0) {
|
|
224
|
+
addInner(data, { pos: INSER_POS.INNER, node: treeData[0], position: [0] });
|
|
225
|
+
return [2 /*return*/];
|
|
226
|
+
}
|
|
227
|
+
if (pos == INSER_POS.TOP) {
|
|
228
|
+
add(data, { pos: INSER_POS.BEFORE, node: child[0], position: [0, 0] });
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
add(data, { pos: INSER_POS.AFTER, node: child[child.length - 1], position: [0, child.length - 1] });
|
|
232
|
+
}
|
|
233
|
+
return [2 /*return*/];
|
|
234
|
+
}
|
|
235
|
+
api = action.api, objectName = action.objectName;
|
|
236
|
+
sort = 0;
|
|
237
|
+
if (treeData.length) {
|
|
238
|
+
if (pos == INSER_POS.TOP) {
|
|
239
|
+
sort = treeData[0][sortField] - STEP;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
sort = treeData[treeData.length - 1][sortField] + STEP;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
param = __assign(__assign({}, data), (_a = {}, _a[parentField] = rootCode, _a.sort = sort, _a));
|
|
246
|
+
return [4 /*yield*/, utils_1.Ajax.PUT(api, param)];
|
|
247
|
+
case 1:
|
|
248
|
+
result = _b.sent();
|
|
249
|
+
if (result.code != '0') {
|
|
250
|
+
antd_1.message.error(txt(Const_1.V.ACT_ADD_FAIL_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
|
|
251
|
+
return [2 /*return*/];
|
|
252
|
+
}
|
|
253
|
+
antd_1.message.success(txt(Const_1.V.ACT_ADD_SUCCESS_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
|
|
254
|
+
props.clearCache(rootCode);
|
|
255
|
+
tree = utils_1.ArrayUtil.add(treeData, result.data);
|
|
256
|
+
setTreeData(tree);
|
|
257
|
+
return [2 /*return*/];
|
|
261
258
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
259
|
+
});
|
|
260
|
+
}); };
|
|
261
|
+
var addInner = function (data, extra) { return __awaiter(void 0, void 0, void 0, function () {
|
|
262
|
+
var node, position, api, objectName, canSort, parentField, titleField, sortField, keyField, treeData, root, nodePath, rootPath, tree, arr, param, sort, resp;
|
|
263
|
+
var _a;
|
|
264
|
+
return __generator(this, function (_b) {
|
|
265
|
+
switch (_b.label) {
|
|
266
|
+
case 0:
|
|
267
|
+
node = extra.node, position = extra.position;
|
|
268
|
+
api = action.api, objectName = action.objectName, canSort = action.canSort;
|
|
269
|
+
parentField = treeState.parentField, titleField = treeState.titleField, sortField = treeState.sortField, keyField = treeState.keyField, treeData = treeState.treeData;
|
|
270
|
+
root = lodash_1.default.concat([], position);
|
|
271
|
+
nodePath = root.map(function (i) { return "[".concat(i, "]"); }).join('.children');
|
|
272
|
+
rootPath = nodePath + '.children';
|
|
273
|
+
tree = lodash_1.default.concat([], treeData);
|
|
274
|
+
arr = lodash_1.default.get(tree, rootPath);
|
|
275
|
+
if (arr == null)
|
|
276
|
+
arr = [];
|
|
277
|
+
param = __assign(__assign({}, data), (_a = {}, _a[parentField] = node[keyField], _a));
|
|
278
|
+
if (!canSort) return [3 /*break*/, 3];
|
|
279
|
+
sort = STEP;
|
|
280
|
+
if (!(arr == null)) return [3 /*break*/, 2];
|
|
281
|
+
if (!lodash_1.default.isFunction(props.getChildren)) return [3 /*break*/, 2];
|
|
282
|
+
return [4 /*yield*/, props.getChildren(node[keyField])];
|
|
283
|
+
case 1:
|
|
284
|
+
arr = _b.sent();
|
|
285
|
+
_b.label = 2;
|
|
286
|
+
case 2:
|
|
287
|
+
if (arr && arr.length) {
|
|
288
|
+
sort = arr[arr.length - 1][sortField] + STEP;
|
|
289
|
+
}
|
|
290
|
+
param[sortField] = sort;
|
|
291
|
+
_b.label = 3;
|
|
292
|
+
case 3: return [4 /*yield*/, utils_1.Ajax.PUT(api, param)];
|
|
293
|
+
case 4:
|
|
294
|
+
resp = _b.sent();
|
|
295
|
+
if (resp.code != '0') {
|
|
296
|
+
antd_1.message.error(txt(Const_1.V.ACT_ADD_FAIL_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
|
|
297
|
+
return [2 /*return*/];
|
|
298
|
+
}
|
|
299
|
+
antd_1.message.success(txt(Const_1.V.ACT_ADD_SUCCESS_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
|
|
300
|
+
arr.push(resp.data);
|
|
301
|
+
props.clearCache(node[keyField]);
|
|
302
|
+
lodash_1.default.set(tree, rootPath, arr);
|
|
303
|
+
setTreeData(tree);
|
|
304
|
+
return [2 /*return*/];
|
|
308
305
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
306
|
+
});
|
|
307
|
+
}); };
|
|
308
|
+
var add = function (data, extra) { return __awaiter(void 0, void 0, void 0, function () {
|
|
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, resp;
|
|
310
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
311
|
+
return __generator(this, function (_m) {
|
|
312
|
+
switch (_m.label) {
|
|
313
|
+
case 0:
|
|
314
|
+
pos = extra.pos, position = extra.position;
|
|
315
|
+
if (position.length <= 0)
|
|
316
|
+
return [2 /*return*/];
|
|
317
|
+
if (pos == INSER_POS.TOP || pos == INSER_POS.BOTTOM) {
|
|
318
|
+
addRoot(data, extra);
|
|
319
|
+
return [2 /*return*/];
|
|
320
|
+
}
|
|
321
|
+
root = lodash_1.default.concat([], position);
|
|
322
|
+
if (pos == INSER_POS.INNER) {
|
|
323
|
+
addInner(data, extra);
|
|
324
|
+
return [2 /*return*/];
|
|
325
|
+
}
|
|
326
|
+
idForApiField = props.idForApiField;
|
|
327
|
+
api = action.api, objectName = action.objectName, canSort = action.canSort;
|
|
328
|
+
parentField = treeState.parentField, titleField = treeState.titleField, sortField = treeState.sortField, keyField = treeState.keyField, treeData = treeState.treeData;
|
|
329
|
+
idField = idForApiField || keyField;
|
|
330
|
+
tree = lodash_1.default.concat([], treeData);
|
|
331
|
+
idx = root.pop();
|
|
332
|
+
if (root.length == 0) {
|
|
333
|
+
arr = tree;
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
nodePath = root.map(function (i) { return "[".concat(i, "].children"); }).join('');
|
|
337
|
+
arr = lodash_1.default.get(tree, nodePath);
|
|
338
|
+
}
|
|
339
|
+
obj = arr[idx];
|
|
340
|
+
promises = [];
|
|
341
|
+
needLoop = false;
|
|
342
|
+
lastSort = STEP;
|
|
343
|
+
dataDefault = getDefault();
|
|
344
|
+
if (!canSort) {
|
|
345
|
+
promises.push(utils_1.Ajax.PUT(api, __assign(__assign(__assign({}, dataDefault), data), (_a = {}, _a[parentField] = obj[parentField], _a))));
|
|
346
|
+
}
|
|
347
|
+
else if (pos == INSER_POS.BEFORE) {
|
|
348
|
+
try {
|
|
349
|
+
lastSort = parseInt(obj[sortField]);
|
|
350
|
+
}
|
|
351
|
+
catch (_o) {
|
|
352
|
+
}
|
|
353
|
+
if (idx == 0) {
|
|
354
|
+
promises.push(utils_1.Ajax.PUT(api, __assign(__assign(__assign({}, dataDefault), data), (_b = {}, _b[sortField] = lastSort - STEP, _b[parentField] = obj[parentField], _b))));
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
diff = Math.floor((lastSort - arr[idx - 1][sortField]) / 2);
|
|
358
|
+
if (diff > 0) {
|
|
359
|
+
promises.push(utils_1.Ajax.PUT(api, __assign(__assign(__assign({}, dataDefault), data), (_c = {}, _c[sortField] = lastSort - diff, _c[parentField] = obj[parentField], _c))));
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
promises.push(utils_1.Ajax.PUT(api, __assign(__assign(__assign({}, dataDefault), data), (_d = {}, _d[sortField] = lastSort - STEP, _d[parentField] = obj[parentField], _d))));
|
|
363
|
+
needLoop = true;
|
|
364
|
+
lastSort = lastSort - STEP;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (needLoop) {
|
|
368
|
+
for (i = idx - 1; i >= 0; i--) {
|
|
369
|
+
item = arr[i];
|
|
370
|
+
lastSort = lastSort - STEP;
|
|
371
|
+
promises.push(utils_1.Ajax.PATCH(api, (_e = {},
|
|
372
|
+
_e[idField] = item[idField],
|
|
373
|
+
_e[sortField] = lastSort,
|
|
374
|
+
_e)));
|
|
375
|
+
arr = utils_1.ArrayUtil.update(arr, __assign(__assign({}, item), (_f = {}, _f[sortField] = lastSort, _f)), keyField);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
try {
|
|
381
|
+
lastSort = parseInt(obj[sortField]);
|
|
382
|
+
}
|
|
383
|
+
catch (_p) {
|
|
384
|
+
}
|
|
385
|
+
len = arr.length;
|
|
386
|
+
if (idx == len - 1) {
|
|
387
|
+
promises.push(utils_1.Ajax.PUT(api, __assign(__assign(__assign({}, dataDefault), data), (_g = {}, _g[sortField] = lastSort + STEP, _g[parentField] = obj[parentField], _g))));
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
diff = Math.floor((arr[idx + 1][sortField] - lastSort) / 2);
|
|
391
|
+
if (diff > 0) {
|
|
392
|
+
promises.push(utils_1.Ajax.PUT(api, __assign(__assign(__assign({}, dataDefault), data), (_h = {}, _h[sortField] = lastSort + diff, _h[parentField] = obj[parentField], _h))));
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
promises.push(utils_1.Ajax.PUT(api, __assign(__assign(__assign({}, dataDefault), data), (_j = {}, _j[sortField] = lastSort + STEP, _j[parentField] = obj[parentField], _j))));
|
|
396
|
+
needLoop = true;
|
|
397
|
+
lastSort = lastSort + STEP;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (needLoop) {
|
|
401
|
+
for (i = idx + 1; i < len; i++) {
|
|
402
|
+
item = arr[i];
|
|
403
|
+
lastSort = lastSort + STEP;
|
|
404
|
+
promises.push(utils_1.Ajax.PATCH(api, (_k = {},
|
|
405
|
+
_k[keyField] = item[keyField],
|
|
406
|
+
_k[sortField] = lastSort,
|
|
407
|
+
_k)));
|
|
408
|
+
arr = utils_1.ArrayUtil.update(arr, __assign(__assign({}, item), (_l = {}, _l[sortField] = lastSort, _l)), keyField);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return [4 /*yield*/, utils_1.Ajax.WHEN.apply(utils_1.Ajax, __spreadArray([], __read(promises), false))];
|
|
413
|
+
case 1:
|
|
414
|
+
resps = _m.sent();
|
|
415
|
+
resp = resps[0];
|
|
416
|
+
if (resp.code != '0') {
|
|
417
|
+
antd_1.message.error(txt(Const_1.V.ACT_ADD_FAIL_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
|
|
418
|
+
return [2 /*return*/];
|
|
419
|
+
}
|
|
420
|
+
antd_1.message.success(txt(Const_1.V.ACT_ADD_SUCCESS_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
|
|
421
|
+
arr = utils_1.ArrayUtil.add(arr, resp.data);
|
|
422
|
+
if (canSort) {
|
|
423
|
+
arr = lodash_1.default.orderBy(arr, sortField, 'asc');
|
|
424
|
+
}
|
|
425
|
+
if (nodePath) {
|
|
426
|
+
lodash_1.default.set(tree, nodePath, arr);
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
tree = arr;
|
|
430
|
+
}
|
|
431
|
+
props.clearCache(obj[keyField]);
|
|
432
|
+
setTreeData(tree);
|
|
433
|
+
return [2 /*return*/];
|
|
319
434
|
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (resp.code != '0') {
|
|
324
|
-
antd_1.message.error(txt(Const_1.V.ACT_ADD_FAIL_NAMED, `${objectName} : ${data[titleField]}`));
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
antd_1.message.success(txt(Const_1.V.ACT_ADD_SUCCESS_NAMED, `${objectName} : ${data[titleField]}`));
|
|
328
|
-
arr = utils_1.ArrayUtil.add(arr, resp.data);
|
|
329
|
-
if (canSort) {
|
|
330
|
-
arr = lodash_1.default.orderBy(arr, sortField, 'asc');
|
|
331
|
-
}
|
|
332
|
-
if (nodePath) {
|
|
333
|
-
lodash_1.default.set(tree, nodePath, arr);
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
tree = arr;
|
|
337
|
-
}
|
|
338
|
-
props.clearCache(obj[keyField]);
|
|
339
|
-
setTreeData(tree);
|
|
340
|
-
});
|
|
341
|
-
const updateData = (0, react_1.useCallback)((data, position) => {
|
|
435
|
+
});
|
|
436
|
+
}); };
|
|
437
|
+
var updateData = (0, react_1.useCallback)(function (data, position) {
|
|
342
438
|
if (position.length == 0)
|
|
343
439
|
return;
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
440
|
+
var parentField = treeState.parentField, treeData = treeState.treeData;
|
|
441
|
+
var root = lodash_1.default.concat([], position);
|
|
442
|
+
var tree = lodash_1.default.concat([], treeData);
|
|
443
|
+
var idx = root.pop();
|
|
444
|
+
var rootPath = '';
|
|
349
445
|
if (root.length > 0) {
|
|
350
|
-
|
|
446
|
+
var nodePath = root.map(function (i) { return "[".concat(i, "]"); }).join('.children');
|
|
351
447
|
rootPath = nodePath + '.children';
|
|
352
448
|
}
|
|
353
|
-
|
|
449
|
+
var node = lodash_1.default.get(tree, "".concat(rootPath, "[").concat(idx, "]"));
|
|
354
450
|
props.clearCache(lodash_1.default.get(node, parentField));
|
|
355
|
-
lodash_1.default.set(tree, rootPath +
|
|
451
|
+
lodash_1.default.set(tree, rootPath + "[".concat(idx, "]"), data);
|
|
356
452
|
setTreeData(tree);
|
|
357
453
|
}, [treeState.treeData]);
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
454
|
+
var update = (0, react_1.useCallback)(function (data, position) { return __awaiter(void 0, void 0, void 0, function () {
|
|
455
|
+
var api, objectName, parentField, titleField, treeData, resp, root, tree, idx, rootPath, nodePath, node;
|
|
456
|
+
return __generator(this, function (_a) {
|
|
457
|
+
switch (_a.label) {
|
|
458
|
+
case 0:
|
|
459
|
+
if (position.length == 0)
|
|
460
|
+
return [2 /*return*/];
|
|
461
|
+
api = action.api, objectName = action.objectName;
|
|
462
|
+
parentField = treeState.parentField, titleField = treeState.titleField, treeData = treeState.treeData;
|
|
463
|
+
return [4 /*yield*/, utils_1.Ajax.PATCH(api, data)];
|
|
464
|
+
case 1:
|
|
465
|
+
resp = _a.sent();
|
|
466
|
+
if (resp.code != '0') {
|
|
467
|
+
antd_1.message.error(txt(Const_1.V.ACT_UPDATE_FAIL_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
|
|
468
|
+
return [2 /*return*/];
|
|
469
|
+
}
|
|
470
|
+
root = lodash_1.default.concat([], position);
|
|
471
|
+
tree = lodash_1.default.concat([], treeData);
|
|
472
|
+
idx = root.pop();
|
|
473
|
+
rootPath = '';
|
|
474
|
+
if (root.length > 0) {
|
|
475
|
+
nodePath = root.map(function (i) { return "[".concat(i, "]"); }).join('.children');
|
|
476
|
+
rootPath = nodePath + '.children';
|
|
477
|
+
}
|
|
478
|
+
antd_1.message.success(txt(Const_1.V.ACT_UPDATE_SUCCESS_NAMED, "".concat(objectName, " : ").concat(data[titleField])));
|
|
479
|
+
node = lodash_1.default.get(tree, "".concat(rootPath, "[").concat(idx, "]"));
|
|
480
|
+
if (node) {
|
|
481
|
+
props.clearCache(lodash_1.default.get(node, parentField));
|
|
482
|
+
// if (node && node.children) {
|
|
483
|
+
// _.set(tree, rootPath + `[${idx}]`, { ...data, children: node.children });
|
|
484
|
+
// } else {
|
|
485
|
+
lodash_1.default.set(tree, rootPath + "[".concat(idx, "]"), data);
|
|
486
|
+
// }
|
|
487
|
+
setTreeData(tree);
|
|
488
|
+
}
|
|
489
|
+
return [2 /*return*/];
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
}); }, [treeState.treeData]);
|
|
493
|
+
var del = (0, react_1.useCallback)(function (node, position) { return __awaiter(void 0, void 0, void 0, function () {
|
|
494
|
+
var root, rootPath, arr, idForApiField, keyField, parentField, titleField, treeData, api, objectName, nodePath, resp, tree;
|
|
495
|
+
return __generator(this, function (_a) {
|
|
496
|
+
switch (_a.label) {
|
|
497
|
+
case 0:
|
|
498
|
+
if (position.length <= 0)
|
|
499
|
+
return [2 /*return*/];
|
|
500
|
+
root = lodash_1.default.concat([], position);
|
|
501
|
+
root.pop();
|
|
502
|
+
rootPath = '';
|
|
503
|
+
idForApiField = props.idForApiField;
|
|
504
|
+
keyField = treeState.keyField, parentField = treeState.parentField, titleField = treeState.titleField, treeData = treeState.treeData;
|
|
505
|
+
api = action.api, objectName = action.objectName;
|
|
506
|
+
if (root.length == 0) {
|
|
507
|
+
arr = lodash_1.default.concat([], treeData);
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
nodePath = root.map(function (i) { return "[".concat(i, "]"); }).join('.children');
|
|
511
|
+
rootPath = nodePath + '.children';
|
|
512
|
+
arr = lodash_1.default.concat([], lodash_1.default.get(treeData, rootPath));
|
|
513
|
+
}
|
|
514
|
+
return [4 /*yield*/, utils_1.Ajax.DELETE(api, { ids: node[idForApiField || keyField] })];
|
|
515
|
+
case 1:
|
|
516
|
+
resp = _a.sent();
|
|
517
|
+
if (resp.code != '0') {
|
|
518
|
+
antd_1.message.error(txt(Const_1.V.ACT_DELETE_FAIL_NAMED, "".concat(objectName, " : ").concat(node[titleField])));
|
|
519
|
+
return [2 /*return*/];
|
|
520
|
+
}
|
|
521
|
+
props.clearCache(node[parentField]);
|
|
522
|
+
tree = lodash_1.default.concat([], treeData);
|
|
523
|
+
if (rootPath) {
|
|
524
|
+
lodash_1.default.set(tree, rootPath, utils_1.ArrayUtil.del(lodash_1.default.get(tree, rootPath), node[keyField], keyField));
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
tree = utils_1.ArrayUtil.del(tree, node[keyField], keyField);
|
|
528
|
+
}
|
|
529
|
+
setTreeData(tree);
|
|
530
|
+
antd_1.message.success(txt(Const_1.V.ACT_DELETE_SUCCESS_NAMED, "".concat(objectName, " : ").concat(node[titleField])));
|
|
531
|
+
return [2 /*return*/];
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}); }, [treeState]);
|
|
535
|
+
var up = function (node, position) { return __awaiter(void 0, void 0, void 0, function () {
|
|
536
|
+
var root, parentField, keyField, sortField, treeData, api, idForApiField, idField, idx, rootPath, arr, nodePath, current, swap, tree, resp;
|
|
537
|
+
var _a, _b;
|
|
538
|
+
return __generator(this, function (_c) {
|
|
539
|
+
switch (_c.label) {
|
|
540
|
+
case 0:
|
|
541
|
+
if (position.length <= 0)
|
|
542
|
+
return [2 /*return*/];
|
|
543
|
+
root = lodash_1.default.concat([], position);
|
|
544
|
+
parentField = treeState.parentField, keyField = treeState.keyField, sortField = treeState.sortField, treeData = treeState.treeData;
|
|
545
|
+
api = props.api, idForApiField = props.idForApiField;
|
|
546
|
+
idField = idForApiField || keyField;
|
|
547
|
+
idx = root.pop();
|
|
548
|
+
if (idx <= 0)
|
|
549
|
+
return [2 /*return*/];
|
|
550
|
+
rootPath = '';
|
|
551
|
+
if (root.length == 0) {
|
|
552
|
+
arr = lodash_1.default.concat([], treeData);
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
nodePath = root.map(function (i) { return "[".concat(i, "]"); }).join('.children');
|
|
556
|
+
rootPath = nodePath + '.children';
|
|
557
|
+
arr = lodash_1.default.concat([], lodash_1.default.get(treeData, rootPath));
|
|
558
|
+
}
|
|
559
|
+
current = arr[idx][sortField];
|
|
560
|
+
swap = arr[idx - 1][sortField];
|
|
561
|
+
arr[idx][sortField] = swap;
|
|
562
|
+
arr[idx - 1][sortField] = current;
|
|
563
|
+
tree = lodash_1.default.concat([], treeData);
|
|
564
|
+
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)))];
|
|
565
|
+
case 1:
|
|
566
|
+
resp = _c.sent();
|
|
567
|
+
if (resp[0].code != '0' || resp[1].code != '0') {
|
|
568
|
+
antd_1.message.error(txt(Const_1.V.TREE_SORT_FAIL));
|
|
569
|
+
return [2 /*return*/];
|
|
570
|
+
}
|
|
571
|
+
props.clearCache(node[parentField]);
|
|
572
|
+
if (rootPath) {
|
|
573
|
+
lodash_1.default.set(tree, rootPath, lodash_1.default.orderBy(arr, sortField, 'asc'));
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
tree = lodash_1.default.orderBy(tree, sortField, 'asc');
|
|
577
|
+
}
|
|
578
|
+
setTreeData(tree);
|
|
579
|
+
antd_1.message.success(txt(Const_1.V.TREE_SORT_SUCCESS));
|
|
580
|
+
return [2 /*return*/];
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
}); };
|
|
584
|
+
var down = function (node, position) { return __awaiter(void 0, void 0, void 0, function () {
|
|
585
|
+
var parentField, keyField, sortField, treeData, api, idForApiField, idField, root, idx, rootPath, arr, nodePath, current, swap, tree, resp;
|
|
586
|
+
var _a, _b;
|
|
587
|
+
return __generator(this, function (_c) {
|
|
588
|
+
switch (_c.label) {
|
|
589
|
+
case 0:
|
|
590
|
+
if (position.length <= 0)
|
|
591
|
+
return [2 /*return*/];
|
|
592
|
+
parentField = treeState.parentField, keyField = treeState.keyField, sortField = treeState.sortField, treeData = treeState.treeData;
|
|
593
|
+
api = props.api, idForApiField = props.idForApiField;
|
|
594
|
+
idField = idForApiField || keyField;
|
|
595
|
+
root = lodash_1.default.concat([], position);
|
|
596
|
+
idx = root.pop();
|
|
597
|
+
rootPath = '';
|
|
598
|
+
if (root.length == 0) {
|
|
599
|
+
arr = lodash_1.default.concat([], treeData);
|
|
600
|
+
}
|
|
601
|
+
else {
|
|
602
|
+
nodePath = root.map(function (i) { return "[".concat(i, "]"); }).join('.children');
|
|
603
|
+
rootPath = nodePath + '.children';
|
|
604
|
+
arr = lodash_1.default.concat([], lodash_1.default.get(treeData, rootPath));
|
|
605
|
+
}
|
|
606
|
+
if (idx >= arr.length - 1)
|
|
607
|
+
return [2 /*return*/];
|
|
608
|
+
current = arr[idx][sortField];
|
|
609
|
+
swap = arr[idx + 1][sortField];
|
|
610
|
+
arr[idx][sortField] = swap;
|
|
611
|
+
arr[idx + 1][sortField] = current;
|
|
612
|
+
tree = lodash_1.default.concat([], treeData);
|
|
613
|
+
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)))];
|
|
614
|
+
case 1:
|
|
615
|
+
resp = _c.sent();
|
|
616
|
+
if (resp[0].code != '0' || resp[1].code != '0') {
|
|
617
|
+
antd_1.message.error(txt(Const_1.V.TREE_SORT_FAIL));
|
|
618
|
+
return [2 /*return*/];
|
|
619
|
+
}
|
|
620
|
+
props.clearCache(node[parentField]);
|
|
621
|
+
if (rootPath) {
|
|
622
|
+
lodash_1.default.set(tree, rootPath, lodash_1.default.orderBy(arr, sortField, 'asc'));
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
tree = lodash_1.default.orderBy(tree, sortField, 'asc');
|
|
626
|
+
}
|
|
627
|
+
setTreeData(tree);
|
|
628
|
+
antd_1.message.success(txt(Const_1.V.TREE_SORT_SUCCESS));
|
|
629
|
+
return [2 /*return*/];
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
}); };
|
|
633
|
+
var ADD_TITLE = function () {
|
|
634
|
+
var _a = modals.modalState.extra || {}, pos = _a.pos, node = _a.node;
|
|
504
635
|
if (!action.canSort) {
|
|
505
636
|
if (pos == INSER_POS.INNER) {
|
|
506
637
|
return react_1.default.createElement("span", null,
|
|
@@ -548,14 +679,14 @@ const _Actiontree = (0, react_1.forwardRef)((props, ref) => {
|
|
|
548
679
|
react_1.default.createElement("b", null, action.objectName));
|
|
549
680
|
}
|
|
550
681
|
};
|
|
551
|
-
return react_1.default.createElement(ActionTreeContext.Provider, { value: { action, showAdd, showEdit, del, up, down, } },
|
|
682
|
+
return react_1.default.createElement(ActionTreeContext.Provider, { value: { action: action, showAdd: showAdd, showEdit: showEdit, del: del, up: up, down: down, } },
|
|
552
683
|
props.children,
|
|
553
|
-
react_1.default.createElement(UFormModal_1.UFormModal,
|
|
684
|
+
react_1.default.createElement(UFormModal_1.UFormModal, __assign({ title: modals.modalState.isEdit ? react_1.default.createElement("span", null,
|
|
554
685
|
" ",
|
|
555
686
|
txt(Const_1.V.ACT_UPDATE),
|
|
556
687
|
action.objectName,
|
|
557
688
|
" : ",
|
|
558
|
-
react_1.default.createElement("b", null, treeState.titleField)) : ADD_TITLE() }, modals.modalState.modalProps, { fields: FIELDS.current, default: getDefault(), onOk: data
|
|
689
|
+
react_1.default.createElement("b", null, treeState.titleField)) : ADD_TITLE() }, modals.modalState.modalProps, { fields: FIELDS.current, default: getDefault(), onOk: function (data) {
|
|
559
690
|
modals.hide();
|
|
560
691
|
if (modals.modalState.isEdit) {
|
|
561
692
|
update(data, modals.modalState.extra.position);
|
|
@@ -568,53 +699,53 @@ const _Actiontree = (0, react_1.forwardRef)((props, ref) => {
|
|
|
568
699
|
/**
|
|
569
700
|
* ActionTree 可让一个树具备CRUD的能力
|
|
570
701
|
*/
|
|
571
|
-
exports.ActionTree = (0, react_1.forwardRef)((props, ref)
|
|
572
|
-
react_1.default.createElement(_Actiontree,
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
702
|
+
exports.ActionTree = (0, react_1.forwardRef)(function (props, ref) { return react_1.default.createElement(BaseTree_1.BaseTree, __assign({}, props),
|
|
703
|
+
react_1.default.createElement(_Actiontree, __assign({}, props, { ref: ref }))); });
|
|
704
|
+
var getActionParam = function (node, position, state, search, disabledNode, folderChecker, context, parentLen) {
|
|
705
|
+
var param = (0, BaseTree_1.getNodeParam)(node, position, state, search, disabledNode, folderChecker);
|
|
706
|
+
var isRoot = position.length == 1;
|
|
576
707
|
if (param.disabled)
|
|
577
708
|
return param;
|
|
578
|
-
|
|
709
|
+
var _a = context.action, canAdd = _a.canAdd, canAddRoot = _a.canAddRoot, canUpdate = _a.canUpdate, canUpdateRoot = _a.canUpdateRoot, canDelete = _a.canDelete, canDeleteRoot = _a.canDeleteRoot, canSort = _a.canSort;
|
|
579
710
|
if (param.selectable === false && (canAdd || canDelete || canSort || canUpdate)) {
|
|
580
711
|
param.selectable = true;
|
|
581
712
|
}
|
|
582
|
-
|
|
713
|
+
var actions = [];
|
|
583
714
|
if (canAdd && (!lodash_1.default.isFunction(folderChecker) || folderChecker(node))) {
|
|
584
715
|
if (!canSort || !canAddRoot && isRoot) {
|
|
585
716
|
actions.push(react_1.default.createElement(Dropdown_1.Dropdown, { trigger: ["click"], menu: {
|
|
586
717
|
items: [
|
|
587
|
-
{ label: txt(Const_1.V.TREE_INSERT_INNER), onClick: (evt)
|
|
718
|
+
{ label: txt(Const_1.V.TREE_INSERT_INNER), onClick: function (evt) { return utils_1.PageUtil.stopEvent(evt.domEvent, function () { return context.showAdd(INSER_POS.INNER, node, position); }); }, key: 'addInner' },
|
|
588
719
|
]
|
|
589
720
|
} },
|
|
590
|
-
react_1.default.createElement("span", { onClick: (e)
|
|
721
|
+
react_1.default.createElement("span", { onClick: function (e) { return utils_1.PageUtil.stopEvent(e); }, className: "vicon vicon-plus vicon-clickable", title: txt(Const_1.V.ACT_ADD) + ' ' + txt(Const_1.V.TREE_NODE) })));
|
|
591
722
|
}
|
|
592
723
|
else {
|
|
593
724
|
actions.push(react_1.default.createElement(Dropdown_1.Dropdown, { trigger: ["click"], menu: {
|
|
594
725
|
items: [
|
|
595
|
-
{ label: txt(Const_1.V.TREE_INSERT_INNER), onClick: (evt)
|
|
596
|
-
{ label: txt(Const_1.V.TREE_INSERT_BEFORE), onClick: (evt)
|
|
597
|
-
{ label: txt(Const_1.V.TREE_INSERT_AFTER), onClick: (evt)
|
|
726
|
+
{ label: txt(Const_1.V.TREE_INSERT_INNER), onClick: function (evt) { return utils_1.PageUtil.stopEvent(evt.domEvent, function () { return context.showAdd(INSER_POS.INNER, node, position); }); }, key: 'addInner' },
|
|
727
|
+
{ label: txt(Const_1.V.TREE_INSERT_BEFORE), onClick: function (evt) { return utils_1.PageUtil.stopEvent(evt.domEvent, function () { return context.showAdd(INSER_POS.BEFORE, node, position); }); }, key: 'addBefore' },
|
|
728
|
+
{ label: txt(Const_1.V.TREE_INSERT_AFTER), onClick: function (evt) { return utils_1.PageUtil.stopEvent(evt.domEvent, function () { return context.showAdd(INSER_POS.AFTER, node, position); }); }, key: 'addAfter' },
|
|
598
729
|
]
|
|
599
730
|
} },
|
|
600
|
-
react_1.default.createElement("span", { onClick: (e)
|
|
731
|
+
react_1.default.createElement("span", { onClick: function (e) { return utils_1.PageUtil.stopEvent(e); }, className: "vicon vicon-plus vicon-clickable", title: txt(Const_1.V.ACT_ADD) + ' ' + txt(Const_1.V.TREE_NODE) })));
|
|
601
732
|
}
|
|
602
733
|
}
|
|
603
734
|
if (canUpdateRoot || (canUpdate && !isRoot)) {
|
|
604
|
-
actions.push(react_1.default.createElement(Icon_1.Icon, { type: "edit", title: txt(Const_1.V.ACT_UPDATE_TITLE_NAMED, node[state.titleField]), onClick: ()
|
|
735
|
+
actions.push(react_1.default.createElement(Icon_1.Icon, { type: "edit", title: txt(Const_1.V.ACT_UPDATE_TITLE_NAMED, node[state.titleField]), onClick: function () { return context.showEdit(node, position); } }));
|
|
605
736
|
}
|
|
606
737
|
if (canSort) {
|
|
607
|
-
|
|
738
|
+
var idx = position[position.length - 1];
|
|
608
739
|
if (idx > 0) {
|
|
609
|
-
actions.push(react_1.default.createElement(Icon_1.Icon, { type: "arrow-up", title: txt(Const_1.V.ACT_UPDATE_TITLE_NAMED, node[state.titleField]), onClick: ()
|
|
740
|
+
actions.push(react_1.default.createElement(Icon_1.Icon, { type: "arrow-up", title: txt(Const_1.V.ACT_UPDATE_TITLE_NAMED, node[state.titleField]), onClick: function () { return context.up(node, position); } }));
|
|
610
741
|
}
|
|
611
742
|
if (idx < (parentLen - 1)) {
|
|
612
|
-
actions.push(react_1.default.createElement(Icon_1.Icon, { type: "arrow-down", title: txt(Const_1.V.ACT_UPDATE_TITLE_NAMED, node[state.titleField]), onClick: ()
|
|
743
|
+
actions.push(react_1.default.createElement(Icon_1.Icon, { type: "arrow-down", title: txt(Const_1.V.ACT_UPDATE_TITLE_NAMED, node[state.titleField]), onClick: function () { return context.down(node, position); } }));
|
|
613
744
|
}
|
|
614
745
|
}
|
|
615
746
|
if (canDelete && (!isRoot || canDeleteRoot)) {
|
|
616
|
-
actions.push(react_1.default.createElement(Popconfirm_1.Popconfirm, { onConfirm: ()
|
|
617
|
-
react_1.default.createElement("span", { onClick: (e)
|
|
747
|
+
actions.push(react_1.default.createElement(Popconfirm_1.Popconfirm, { onConfirm: function () { return context.del(node, position); }, title: txt(Const_1.V.ACT_DELETE_CONFIRM, node[state.titleField]) },
|
|
748
|
+
react_1.default.createElement("span", { onClick: function (e) { return utils_1.PageUtil.stopEvent(e); }, className: "vicon vicon-delete vicon-clickable", title: txt(Const_1.V.ACT_DELETE) + ' ' + node[state.titleField] })));
|
|
618
749
|
}
|
|
619
750
|
if (actions.length) {
|
|
620
751
|
param.title = [param.title, react_1.default.createElement("div", { className: 'c-tree-actions' },
|
|
@@ -624,71 +755,71 @@ const getActionParam = (node, position, state, search, disabledNode, folderCheck
|
|
|
624
755
|
}
|
|
625
756
|
return param;
|
|
626
757
|
};
|
|
627
|
-
|
|
758
|
+
var renderNode = function (props, node, position, state, search, context, parentLen) {
|
|
628
759
|
if (search.keyword && !search.match.has(position.join('-')))
|
|
629
760
|
return utils_1.Const.NONE;
|
|
630
|
-
|
|
761
|
+
var param = getActionParam(node, position, state, search, props.disabledNode, props.folderChecker, context, parentLen);
|
|
631
762
|
if (lodash_1.default.isArray(node.children) && node.children.length) {
|
|
632
|
-
return react_1.default.createElement(antd_1.Tree.TreeNode,
|
|
763
|
+
return react_1.default.createElement(antd_1.Tree.TreeNode, __assign({ isLeaf: false }, param), renderNodes(props, state, node.children, position, search, context));
|
|
633
764
|
}
|
|
634
765
|
// @ts-ignore
|
|
635
|
-
|
|
766
|
+
var checkField = props.checkField;
|
|
636
767
|
if (lodash_1.default.isString(checkField)) {
|
|
637
768
|
if (!node[checkField]) {
|
|
638
769
|
param.isLeaf = true;
|
|
639
770
|
}
|
|
640
771
|
}
|
|
641
|
-
return react_1.default.createElement(antd_1.Tree.TreeNode,
|
|
772
|
+
return react_1.default.createElement(antd_1.Tree.TreeNode, __assign({}, param));
|
|
642
773
|
};
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
774
|
+
var renderNodes = function (props, state, data, position, search, context) { return data.map(function (item, idx) { return renderNode(props, item, __spreadArray(__spreadArray([], __read(position), false), [idx], false), state, search, context, data.length); }); };
|
|
775
|
+
var renderRoot = function (props, state, context) {
|
|
776
|
+
var search = state.search, treeData = state.treeData;
|
|
646
777
|
if (search.keyword) {
|
|
647
778
|
if (search.match.size == 0)
|
|
648
779
|
return react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, title: react_1.default.createElement(antd_1.Empty, { description: txt(Const_1.V.TXT_FIND_NULL, search.word) }), selectable: false, className: "c-tree-empty" });
|
|
649
780
|
return renderNodes(props, state, treeData, [], search, context);
|
|
650
781
|
}
|
|
651
|
-
|
|
782
|
+
var _a = context.action, canAddRoot = _a.canAddRoot, canAdd = _a.canAdd, canSort = _a.canSort, objectName = _a.objectName;
|
|
652
783
|
if (canAddRoot) {
|
|
653
784
|
return react_1.default.createElement(react_1.Fragment, null,
|
|
654
|
-
react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, checkable: false, selected: false, title: react_1.default.createElement("a", { onClick: evt
|
|
785
|
+
react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, checkable: false, selected: false, title: react_1.default.createElement("a", { onClick: function (evt) {
|
|
655
786
|
utils_1.PageUtil.stopEvent(evt);
|
|
656
787
|
context.showAdd(INSER_POS.TOP, null, [0]);
|
|
657
788
|
} },
|
|
658
789
|
react_1.default.createElement(Icon_1.Icon, { type: 'plus' }),
|
|
659
|
-
canSort ? txt(Const_1.V.TREE_INSERT_TOP, objectName) :
|
|
790
|
+
canSort ? txt(Const_1.V.TREE_INSERT_TOP, objectName) : "".concat(txt(Const_1.V.ACT_ADD), " ").concat(objectName)) }),
|
|
660
791
|
renderNodes(props, state, treeData, [], search, context),
|
|
661
|
-
canSort && treeData.length > 0 && react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, selected: false, checkable: false, expanded: true, title: react_1.default.createElement("a", { onClick: evt
|
|
792
|
+
canSort && treeData.length > 0 && react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, selected: false, checkable: false, expanded: true, title: react_1.default.createElement("a", { onClick: function (evt) {
|
|
662
793
|
utils_1.PageUtil.stopEvent(evt);
|
|
663
794
|
context.showAdd(INSER_POS.BOTTOM, null, [0]);
|
|
664
795
|
} },
|
|
665
796
|
react_1.default.createElement(Icon_1.Icon, { type: 'plus' }),
|
|
666
|
-
canSort ? txt(Const_1.V.TREE_INSERT_BOTTOM, objectName) :
|
|
797
|
+
canSort ? txt(Const_1.V.TREE_INSERT_BOTTOM, objectName) : "".concat(txt(Const_1.V.ACT_ADD), " ").concat(objectName)) }));
|
|
667
798
|
}
|
|
668
799
|
else if (canAdd && treeData.length == 1) {
|
|
669
800
|
// 说明 兼容树业务:有些项目技术上使用一个根节点,
|
|
670
801
|
// 当根节点只有一个时,则在业务上认为此节点为固定根节点
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
return react_1.default.createElement(antd_1.Tree.TreeNode,
|
|
674
|
-
react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, checkable: false, selected: false, title: react_1.default.createElement("a", { onClick: evt
|
|
802
|
+
var param = getActionParam(treeData[0], [0], state, search, props.disabledNode, props.folderChecker, context, 1);
|
|
803
|
+
var childs_1 = (treeData[0].children || []);
|
|
804
|
+
return react_1.default.createElement(antd_1.Tree.TreeNode, __assign({}, param),
|
|
805
|
+
react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, checkable: false, selected: false, title: react_1.default.createElement("a", { onClick: function (evt) {
|
|
675
806
|
utils_1.PageUtil.stopEvent(evt);
|
|
676
807
|
context.showAdd(INSER_POS.TOP, null, [0, 0]);
|
|
677
808
|
} },
|
|
678
809
|
react_1.default.createElement(Icon_1.Icon, { type: 'plus' }),
|
|
679
810
|
" ",
|
|
680
|
-
(canSort &&
|
|
681
|
-
renderNodes(props, state,
|
|
682
|
-
canSort &&
|
|
811
|
+
(canSort && childs_1.length > 0) ? txt(Const_1.V.TREE_INSERT_TOP, objectName) : "".concat(txt(Const_1.V.ACT_ADD), " ").concat(objectName)) }),
|
|
812
|
+
renderNodes(props, state, childs_1, [0], search, context),
|
|
813
|
+
canSort && childs_1.length > 0 && react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, selected: false, checkable: false, expanded: true, title: react_1.default.createElement("a", { onClick: function (evt) {
|
|
683
814
|
utils_1.PageUtil.stopEvent(evt);
|
|
684
|
-
context.showAdd(INSER_POS.BOTTOM, null, [0,
|
|
685
|
-
} }, canSort ? txt(Const_1.V.TREE_INSERT_BOTTOM, objectName) :
|
|
815
|
+
context.showAdd(INSER_POS.BOTTOM, null, [0, childs_1.length - 1]);
|
|
816
|
+
} }, canSort ? txt(Const_1.V.TREE_INSERT_BOTTOM, objectName) : "".concat(txt(Const_1.V.ACT_ADD), " ").concat(objectName)) }));
|
|
686
817
|
}
|
|
687
818
|
return renderNodes(props, state, treeData, [], search, context);
|
|
688
819
|
};
|
|
689
820
|
exports.renderRoot = renderRoot;
|
|
690
|
-
|
|
691
|
-
|
|
821
|
+
var getResponseList = function (resp, sortField) {
|
|
822
|
+
var data;
|
|
692
823
|
if (lodash_1.default.has(resp, 'data')) {
|
|
693
824
|
data = resp.data;
|
|
694
825
|
}
|