vap1 0.2.3 → 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.js +36 -20
- 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 +114 -77
- 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 +158 -122
- package/components/_setup/UForm/UFormInput.js +110 -73
- 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 +106 -79
- 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 +58 -17
- 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,42 +1,53 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.default = (props)
|
|
17
|
+
var react_1 = __importDefault(require("react"));
|
|
18
|
+
var index_1 = require("../../../index");
|
|
19
|
+
var hooks_1 = require("../../../hooks");
|
|
20
|
+
var RegexpModal_1 = require("./Component/RegexpModal");
|
|
21
|
+
var FieldPlugin_1 = require("./Component/FieldPlugin");
|
|
22
|
+
var Validate_1 = require("./Component/Validate");
|
|
23
|
+
var Const_1 = require("../../utils/Const");
|
|
24
|
+
var plugins_1 = require("../../plugins");
|
|
25
|
+
exports.default = (function (props) {
|
|
15
26
|
// alert(1)
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
var setFieldProperties = props.setFieldProperties, field = props.field, input = props.input;
|
|
28
|
+
var regexpState = (0, hooks_1.useOpenState)();
|
|
18
29
|
return react_1.default.createElement(react_1.default.Fragment, null,
|
|
19
30
|
react_1.default.createElement(index_1.Form.Item, { label: "\u662F\u5426\u5FC5\u586B" },
|
|
20
|
-
react_1.default.createElement(index_1.Switch, { size: 'small', checked: field.required, onChange: (required)
|
|
31
|
+
react_1.default.createElement(index_1.Switch, { size: 'small', checked: field.required, onChange: function (required) { return setFieldProperties('required', required); }, checkedChildren: "\u662F", unCheckedChildren: "\u5426" })),
|
|
21
32
|
Const_1.LEN.has(field.type) && react_1.default.createElement(index_1.Form.Item, { label: "\u6700\u77ED\u957F\u5EA6" },
|
|
22
|
-
react_1.default.createElement(index_1.InputNumber, { value: field._min, size: 'small', onChange: (val)
|
|
33
|
+
react_1.default.createElement(index_1.InputNumber, { value: field._min, size: 'small', onChange: function (val) { return setFieldProperties('_min', val === 0 ? null : val); } })),
|
|
23
34
|
Const_1.LEN.has(field.type) && react_1.default.createElement(index_1.Form.Item, { label: "\u6700\u957F\u957F\u5EA6" },
|
|
24
|
-
react_1.default.createElement(index_1.InputNumber, { value: field._max, size: 'small', onChange: (val)
|
|
35
|
+
react_1.default.createElement(index_1.InputNumber, { value: field._max, size: 'small', onChange: function (val) { return setFieldProperties('_max', val === 0 ? null : val); } })),
|
|
25
36
|
Const_1.NUMBER.has(field.type) && react_1.default.createElement(index_1.Form.Item, { label: "\u6700\u5C0F\u503C" },
|
|
26
|
-
react_1.default.createElement(index_1.InputNumber, { size: 'small', value: field._min, onChange: (val)
|
|
37
|
+
react_1.default.createElement(index_1.InputNumber, { size: 'small', value: field._min, onChange: function (val) { return setFieldProperties('_min', val === 0 ? null : val); } })),
|
|
27
38
|
Const_1.NUMBER.has(field.type) && react_1.default.createElement(index_1.Form.Item, { label: "\u6700\u5927\u503C" },
|
|
28
|
-
react_1.default.createElement(index_1.InputNumber, { size: 'small', value: field._max, onChange: (val)
|
|
39
|
+
react_1.default.createElement(index_1.InputNumber, { size: 'small', value: field._max, onChange: function (val) { return setFieldProperties('_max', val === 0 ? null : val); } })),
|
|
29
40
|
Const_1.TEXT.has(field.type) && react_1.default.createElement(index_1.Form.Item, { label: "\u7CFB\u7EDF\u9A8C\u8BC1" },
|
|
30
|
-
react_1.default.createElement(index_1.Checkbox, { checked: field.ignore, onChange: (evt)
|
|
41
|
+
react_1.default.createElement(index_1.Checkbox, { checked: field.ignore, onChange: function (evt) { return setFieldProperties('ignore', evt.target.checked ? true : null); } }, "\u4E0D\u542F\u7528 \u6700\u5927\u957F\u5EA6 \u53CA \u7279\u6B8A\u5B57\u7B26\u9A8C\u8BC1")),
|
|
31
42
|
Const_1.TEXT.has(field.type) && react_1.default.createElement(index_1.Form.Item, { label: "\u6B63\u5219\u9A8C\u8BC1" },
|
|
32
|
-
field._pattern ? react_1.default.createElement(index_1.Button, { type: "primary", onClick: ()
|
|
33
|
-
react_1.default.createElement(RegexpModal_1.RegexpModal, { open: regexpState.open, onCancel: regexpState.hide, data: field._pattern, onOk: (_pattern)
|
|
43
|
+
field._pattern ? react_1.default.createElement(index_1.Button, { type: "primary", onClick: function () { return regexpState.show(field._pattern); }, size: "small" }, "\u5DF2\u8BBE\u7F6E\uFF0C\u70B9\u51FB\u67E5\u770B") : react_1.default.createElement(index_1.Button, { onClick: function () { return regexpState.show(null); }, size: "small" }, "\u70B9\u51FB\u8F93\u5165\u8868\u8FBE\u5F0F"),
|
|
44
|
+
react_1.default.createElement(RegexpModal_1.RegexpModal, { open: regexpState.open, onCancel: regexpState.hide, data: field._pattern, onOk: function (_pattern) {
|
|
34
45
|
regexpState.hide();
|
|
35
46
|
setFieldProperties('_pattern', _pattern);
|
|
36
47
|
} })),
|
|
37
|
-
react_1.default.createElement(Validate_1.Validates,
|
|
38
|
-
react_1.default.createElement(FieldPlugin_1.FieldPlugin,
|
|
39
|
-
};
|
|
48
|
+
react_1.default.createElement(Validate_1.Validates, __assign({}, props)),
|
|
49
|
+
react_1.default.createElement(FieldPlugin_1.FieldPlugin, __assign({}, props, { slot: plugins_1.PluginSlot.FIELD_VALIDATE })));
|
|
50
|
+
});
|
|
40
51
|
{ /* <Form.Item label="权限编码">
|
|
41
52
|
<Input
|
|
42
53
|
size='small'
|
package/uform/plugins/index.js
CHANGED
|
@@ -19,28 +19,28 @@ var PluginSlot;
|
|
|
19
19
|
PluginSlot[PluginSlot["FIELD_ADVANCE"] = 6] = "FIELD_ADVANCE";
|
|
20
20
|
})(PluginSlot || (exports.PluginSlot = PluginSlot = {}));
|
|
21
21
|
// const FiledPlugins = new Map()
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
var FieldPlugins = new Map();
|
|
23
|
+
var registerFieldPlugin = function (slot, type) {
|
|
24
24
|
return [];
|
|
25
25
|
};
|
|
26
26
|
exports.registerFieldPlugin = registerFieldPlugin;
|
|
27
|
-
|
|
27
|
+
var getFieldPlugin = function (type, slot) {
|
|
28
28
|
return [];
|
|
29
29
|
};
|
|
30
30
|
exports.getFieldPlugin = getFieldPlugin;
|
|
31
|
-
|
|
31
|
+
var registerGroupPlugin = function (type, slot) {
|
|
32
32
|
return [];
|
|
33
33
|
};
|
|
34
34
|
exports.registerGroupPlugin = registerGroupPlugin;
|
|
35
|
-
|
|
35
|
+
var getGroupPlugin = function (type, slot) {
|
|
36
36
|
return [];
|
|
37
37
|
};
|
|
38
38
|
exports.getGroupPlugin = getGroupPlugin;
|
|
39
|
-
|
|
39
|
+
var registerEditorPlugin = function (type, slot) {
|
|
40
40
|
return [];
|
|
41
41
|
};
|
|
42
42
|
exports.registerEditorPlugin = registerEditorPlugin;
|
|
43
|
-
|
|
43
|
+
var getEditorPlugin = function (type, slot) {
|
|
44
44
|
return [];
|
|
45
45
|
};
|
|
46
46
|
exports.getEditorPlugin = getEditorPlugin;
|
package/uform/utils/Convert.js
CHANGED
|
@@ -8,34 +8,59 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
11
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
40
|
};
|
|
14
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
42
|
exports.schemaToForm = void 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
var react_1 = __importDefault(require("react"));
|
|
44
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
45
|
+
var dayjs_1 = __importDefault(require("dayjs"));
|
|
46
|
+
var index_1 = require("../../index");
|
|
47
|
+
var utils_1 = require("../../utils");
|
|
48
|
+
var Const_1 = require("./Const");
|
|
49
|
+
var converUrl = function (url, data) {
|
|
50
|
+
var fn = lodash_1.default.template(url, { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
24
51
|
return fn(data);
|
|
25
52
|
};
|
|
26
|
-
|
|
27
|
-
|
|
53
|
+
var convertParam = function (param, data) {
|
|
54
|
+
var fn = lodash_1.default.template(param, { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
28
55
|
return JSON.parse(fn(data));
|
|
29
56
|
};
|
|
30
|
-
|
|
31
|
-
var fn = lodash_1.default.template(
|
|
32
|
-
${rule.code}
|
|
33
|
-
%>`, { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
57
|
+
var syncValidator = function (rule) {
|
|
58
|
+
var fn = lodash_1.default.template("<% \n ".concat(rule.code, "\n %>"), { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
34
59
|
return {
|
|
35
60
|
message: rule.message,
|
|
36
|
-
validator: (r, value, callback)
|
|
61
|
+
validator: function (r, value, callback) {
|
|
37
62
|
try {
|
|
38
|
-
|
|
63
|
+
var result = fn({ value: value });
|
|
39
64
|
if (!Const_1.BOOLEAN_VALUE.has(result)) {
|
|
40
65
|
console.error('代码执行有误,请检查,:必须print(true/false)');
|
|
41
66
|
return;
|
|
@@ -54,49 +79,57 @@ const syncValidator = (rule) => {
|
|
|
54
79
|
}
|
|
55
80
|
};
|
|
56
81
|
};
|
|
57
|
-
|
|
58
|
-
var fn = lodash_1.default.template(
|
|
59
|
-
${rule.code}
|
|
60
|
-
%>`, { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
82
|
+
var asyncValidator = function (rule) {
|
|
83
|
+
var fn = lodash_1.default.template("<% \n ".concat(rule.code, "\n %>"), { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
61
84
|
return {
|
|
62
85
|
message: null,
|
|
63
|
-
validator: (r, value)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
validator: function (r, value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
+
var response, url, param, e_1;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
url = converUrl(rule.url, { value: value });
|
|
92
|
+
if (!(rule.method == 'POST')) return [3 /*break*/, 5];
|
|
93
|
+
_a.label = 1;
|
|
94
|
+
case 1:
|
|
95
|
+
_a.trys.push([1, 3, , 4]);
|
|
96
|
+
param = convertParam(rule.param, { value: value });
|
|
97
|
+
return [4 /*yield*/, utils_1.Ajax.POST(url, param)];
|
|
98
|
+
case 2:
|
|
99
|
+
response = _a.sent();
|
|
100
|
+
return [3 /*break*/, 4];
|
|
101
|
+
case 3:
|
|
102
|
+
e_1 = _a.sent();
|
|
103
|
+
console.error(e_1);
|
|
104
|
+
throw '验证失败';
|
|
105
|
+
case 4: return [3 /*break*/, 7];
|
|
106
|
+
case 5: return [4 /*yield*/, utils_1.Ajax.GET(url)];
|
|
107
|
+
case 6:
|
|
108
|
+
response = _a.sent();
|
|
109
|
+
_a.label = 7;
|
|
110
|
+
case 7:
|
|
111
|
+
try {
|
|
112
|
+
fn({ response: response, value: value });
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
throw e;
|
|
116
|
+
}
|
|
117
|
+
return [2 /*return*/];
|
|
74
118
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
response = yield utils_1.Ajax.GET(url);
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
fn({ response, value });
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
throw e;
|
|
84
|
-
}
|
|
85
|
-
})
|
|
119
|
+
});
|
|
120
|
+
}); }
|
|
86
121
|
};
|
|
87
122
|
};
|
|
88
|
-
|
|
89
|
-
var fn = lodash_1.default.template(
|
|
90
|
-
${link.code}
|
|
91
|
-
%>`, { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
123
|
+
var syncLink = function (link) {
|
|
124
|
+
var fn = lodash_1.default.template("<% \n ".concat(link.code, "\n %>"), { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
92
125
|
return {
|
|
93
126
|
field: link.field,
|
|
94
|
-
call: (value, form, extra)
|
|
95
|
-
|
|
127
|
+
call: function (value, form, extra) {
|
|
128
|
+
var result = fn({ value: value, form: form, extra: extra });
|
|
96
129
|
if (result == '')
|
|
97
130
|
return result;
|
|
98
131
|
try {
|
|
99
|
-
|
|
132
|
+
var json = JSON.parse(result);
|
|
100
133
|
if (lodash_1.default.isPlainObject(json))
|
|
101
134
|
return json;
|
|
102
135
|
throw (new Error());
|
|
@@ -107,45 +140,55 @@ const syncLink = (link) => {
|
|
|
107
140
|
}
|
|
108
141
|
};
|
|
109
142
|
};
|
|
110
|
-
|
|
111
|
-
var fn = lodash_1.default.template(
|
|
112
|
-
${link.code}
|
|
113
|
-
%>`, { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
143
|
+
var asyncLink = function (link) {
|
|
144
|
+
var fn = lodash_1.default.template("<% \n ".concat(link.code, "\n %>"), { imports: { _: lodash_1.default, dayjs: dayjs_1.default } });
|
|
114
145
|
return {
|
|
115
146
|
field: link.field,
|
|
116
|
-
call: (value, form, extra)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
147
|
+
call: function (value, form, extra) { return __awaiter(void 0, void 0, void 0, function () {
|
|
148
|
+
var response, url, param, e_2, result, json;
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
switch (_a.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
url = converUrl(link.url, { value: value, form: form, extra: extra });
|
|
153
|
+
if (!(link.method == 'POST')) return [3 /*break*/, 5];
|
|
154
|
+
_a.label = 1;
|
|
155
|
+
case 1:
|
|
156
|
+
_a.trys.push([1, 3, , 4]);
|
|
157
|
+
param = convertParam(link.param, { value: value, form: form, extra: extra });
|
|
158
|
+
return [4 /*yield*/, utils_1.Ajax.POST(url, param)];
|
|
159
|
+
case 2:
|
|
160
|
+
response = _a.sent();
|
|
161
|
+
return [3 /*break*/, 4];
|
|
162
|
+
case 3:
|
|
163
|
+
e_2 = _a.sent();
|
|
164
|
+
console.error(e_2);
|
|
165
|
+
return [3 /*break*/, 4];
|
|
166
|
+
case 4: return [3 /*break*/, 7];
|
|
167
|
+
case 5: return [4 /*yield*/, utils_1.Ajax.GET(url)];
|
|
168
|
+
case 6:
|
|
169
|
+
response = _a.sent();
|
|
170
|
+
_a.label = 7;
|
|
171
|
+
case 7:
|
|
172
|
+
result = fn({ value: value, form: form, extra: extra, response: response });
|
|
173
|
+
if (result == '')
|
|
174
|
+
return [2 /*return*/, result];
|
|
175
|
+
try {
|
|
176
|
+
json = JSON.parse(result);
|
|
177
|
+
if (lodash_1.default.isPlainObject(json))
|
|
178
|
+
return [2 /*return*/, json];
|
|
179
|
+
throw (new Error());
|
|
180
|
+
}
|
|
181
|
+
catch (_b) {
|
|
182
|
+
return [2 /*return*/, result];
|
|
183
|
+
}
|
|
184
|
+
return [2 /*return*/];
|
|
127
185
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
response = yield utils_1.Ajax.GET(url);
|
|
131
|
-
}
|
|
132
|
-
const result = fn({ value, form, extra, response });
|
|
133
|
-
if (result == '')
|
|
134
|
-
return result;
|
|
135
|
-
try {
|
|
136
|
-
let json = JSON.parse(result);
|
|
137
|
-
if (lodash_1.default.isPlainObject(json))
|
|
138
|
-
return json;
|
|
139
|
-
throw (new Error());
|
|
140
|
-
}
|
|
141
|
-
catch (_a) {
|
|
142
|
-
return result;
|
|
143
|
-
}
|
|
144
|
-
})
|
|
186
|
+
});
|
|
187
|
+
}); }
|
|
145
188
|
};
|
|
146
189
|
};
|
|
147
|
-
|
|
148
|
-
|
|
190
|
+
var convertFields = function (fields, def) { return fields.map(function (item) {
|
|
191
|
+
var field = { field: item.field, title: item.title, type: item.type };
|
|
149
192
|
if (lodash_1.default.has(item, '_default')) {
|
|
150
193
|
if (Const_1.NUMBER.has(item.type) || item._isNumber) {
|
|
151
194
|
if (!isNaN(item._default)) {
|
|
@@ -189,8 +232,8 @@ const convertFields = (fields, def) => fields.map(item => {
|
|
|
189
232
|
if (lodash_1.default.has(item, '_min') && lodash_1.default.isNumber(item._min)) {
|
|
190
233
|
if (Const_1.LEN.has(item.type)) {
|
|
191
234
|
field.rules.push({
|
|
192
|
-
message:
|
|
193
|
-
validator: (rule, value, callback)
|
|
235
|
+
message: "".concat(item.title, " \u4E0D\u5F97\u5C0F\u4E8E ").concat(item._min, " \u4E2A\u5B57\u7B26"),
|
|
236
|
+
validator: function (rule, value, callback) {
|
|
194
237
|
if ((value + '').length < item._min) {
|
|
195
238
|
callback('error');
|
|
196
239
|
}
|
|
@@ -208,8 +251,8 @@ const convertFields = (fields, def) => fields.map(item => {
|
|
|
208
251
|
if (Const_1.LEN.has(item.type)) {
|
|
209
252
|
field.config.maxLength = item._max;
|
|
210
253
|
field.rules.push({
|
|
211
|
-
message:
|
|
212
|
-
validator: (rule, value, callback)
|
|
254
|
+
message: "".concat(item.title, " \u4E0D\u5F97\u5927\u4E8E ").concat(item._max, " \u4E2A\u5B57\u7B26"),
|
|
255
|
+
validator: function (rule, value, callback) {
|
|
213
256
|
if ((value + '').length > item._max) {
|
|
214
257
|
callback('error');
|
|
215
258
|
}
|
|
@@ -223,7 +266,7 @@ const convertFields = (fields, def) => fields.map(item => {
|
|
|
223
266
|
field.config.max = item._max;
|
|
224
267
|
}
|
|
225
268
|
}
|
|
226
|
-
(item._rules || []).map(rule
|
|
269
|
+
(item._rules || []).map(function (rule) {
|
|
227
270
|
if (rule.async) {
|
|
228
271
|
field.rules.push(asyncValidator(rule));
|
|
229
272
|
}
|
|
@@ -232,7 +275,7 @@ const convertFields = (fields, def) => fields.map(item => {
|
|
|
232
275
|
}
|
|
233
276
|
});
|
|
234
277
|
field.link = [];
|
|
235
|
-
(item._links || []).map(link
|
|
278
|
+
(item._links || []).map(function (link) {
|
|
236
279
|
if (link.async) {
|
|
237
280
|
field.link.push(asyncLink(link));
|
|
238
281
|
}
|
|
@@ -242,10 +285,10 @@ const convertFields = (fields, def) => fields.map(item => {
|
|
|
242
285
|
});
|
|
243
286
|
// TODO PLUGINS
|
|
244
287
|
return field;
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
288
|
+
}); };
|
|
289
|
+
var convertGroups = function (groups, def) { return groups.map(function (group) { return ({ title: group.title, fields: convertFields(group.fields, def) }); }); };
|
|
290
|
+
var schemaToForm = function (schema) {
|
|
291
|
+
var uformProps = {
|
|
249
292
|
fields: [],
|
|
250
293
|
};
|
|
251
294
|
if (schema.tip && schema.tip.text) {
|
|
@@ -256,7 +299,7 @@ const schemaToForm = (schema) => {
|
|
|
256
299
|
}
|
|
257
300
|
if (schema.layout)
|
|
258
301
|
uformProps.layout = schema.layout;
|
|
259
|
-
|
|
302
|
+
var def = {};
|
|
260
303
|
if (schema.isGroup) {
|
|
261
304
|
if (schema.groupType)
|
|
262
305
|
uformProps.groupType = schema.groupType;
|
|
@@ -5,20 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.loadFormJSON = exports.saveCEMS = exports.saveUForm = exports.saveSchema = exports.save = void 0;
|
|
7
7
|
// 将 schame 转换为 UForm 接收的参数
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
var react_1 = __importDefault(require("react"));
|
|
9
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
var utils_1 = require("../../utils");
|
|
11
|
+
var antd_1 = require("antd");
|
|
12
|
+
var cleanId = function (schema) {
|
|
13
|
+
var obj = lodash_1.default.cloneDeep(schema);
|
|
14
14
|
if (obj.isGroup) {
|
|
15
|
-
obj.fields.map(group
|
|
15
|
+
obj.fields.map(function (group) {
|
|
16
16
|
lodash_1.default.unset(group, 'id');
|
|
17
|
-
group.fields.map(field
|
|
17
|
+
group.fields.map(function (field) { return lodash_1.default.unset(field, 'id'); });
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
obj.fields.map(group
|
|
21
|
+
obj.fields.map(function (group) {
|
|
22
22
|
lodash_1.default.unset(group, 'id');
|
|
23
23
|
});
|
|
24
24
|
}
|
|
@@ -28,38 +28,38 @@ const cleanId = (schema) => {
|
|
|
28
28
|
if (obj.tip && obj.tip.text == '') {
|
|
29
29
|
lodash_1.default.unset(obj, 'tip');
|
|
30
30
|
}
|
|
31
|
-
lodash_1.default.keys(obj).map(key
|
|
31
|
+
lodash_1.default.keys(obj).map(function (key) {
|
|
32
32
|
if (obj[key] === '') {
|
|
33
33
|
lodash_1.default.unset(obj, key);
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
return obj;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
obj.fields.map(group
|
|
38
|
+
var setId = function (schema) {
|
|
39
|
+
var obj = lodash_1.default.cloneDeep(schema);
|
|
40
|
+
obj.fields.map(function (group) {
|
|
41
41
|
lodash_1.default.set(group, 'id', utils_1.StringUtil.genKey());
|
|
42
42
|
if (lodash_1.default.isArray(group.fields) && group.fields.length) {
|
|
43
|
-
group.fields.map(field
|
|
43
|
+
group.fields.map(function (field) { return lodash_1.default.set(field, 'id', utils_1.StringUtil.genKey()); });
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
if (lodash_1.default.isArray(obj.options) && obj.options.length) {
|
|
47
|
-
obj.options.map(item
|
|
47
|
+
obj.options.map(function (item) { return lodash_1.default.set(item, 'id', utils_1.StringUtil.genKey()); });
|
|
48
48
|
}
|
|
49
49
|
return obj;
|
|
50
50
|
};
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
var save = function (schema) {
|
|
52
|
+
var obj = cleanId(schema);
|
|
53
53
|
antd_1.notification.success({ message: react_1.default.createElement("pre", { dangerouslySetInnerHTML: { __html: JSON.stringify(obj, null, 2) } }) });
|
|
54
54
|
};
|
|
55
55
|
exports.save = save;
|
|
56
|
-
|
|
56
|
+
var saveSchema = function (schema) {
|
|
57
57
|
if (schema.fields.length <= 0) {
|
|
58
58
|
antd_1.message.error('表单最少要有一个字段');
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
var obj = cleanId(schema);
|
|
62
|
+
var fileName = (schema.title ? schema.title : '表单') + ".json";
|
|
63
63
|
var file = new File([JSON.stringify(obj, null, 4)], fileName, { type: "application/json;charset=utf-8" });
|
|
64
64
|
var a = document.createElement('a');
|
|
65
65
|
a.href = URL.createObjectURL(file);
|
|
@@ -68,60 +68,51 @@ const saveSchema = (schema) => {
|
|
|
68
68
|
};
|
|
69
69
|
exports.saveSchema = saveSchema;
|
|
70
70
|
// var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
|
|
71
|
-
|
|
72
|
-
_title: (title)
|
|
71
|
+
var FORMATS = {
|
|
72
|
+
_title: function (title) {
|
|
73
73
|
if (title) {
|
|
74
|
-
return
|
|
74
|
+
return "\n title=\"".concat(title, "\"");
|
|
75
75
|
}
|
|
76
76
|
return '';
|
|
77
77
|
},
|
|
78
|
-
_layout: (layout)
|
|
78
|
+
_layout: function (layout) {
|
|
79
79
|
if (layout == 'common' || layout == 'simple' || layout == 'compress') {
|
|
80
|
-
return
|
|
80
|
+
return "\n layout=\"".concat(layout, "\"");
|
|
81
81
|
}
|
|
82
82
|
return '';
|
|
83
83
|
},
|
|
84
|
-
_tip: (tip)
|
|
84
|
+
_tip: function (tip) {
|
|
85
85
|
if (tip && tip.text) {
|
|
86
|
-
return
|
|
86
|
+
return "\n tip={<Alert type=\"".concat(tip.type, "\" message=\"").concat(tip.text, "\"/>}");
|
|
87
87
|
}
|
|
88
88
|
return '';
|
|
89
89
|
},
|
|
90
|
-
_group: (group)
|
|
91
|
-
return
|
|
92
|
-
${group.fields.map(item => FORMATS._field(item)).join('\n')}
|
|
93
|
-
]},`;
|
|
90
|
+
_group: function (group) {
|
|
91
|
+
return "{ title: \"".concat(group.title, "\", fields: [\n").concat(group.fields.map(function (item) { return FORMATS._field(item); }).join('\n'), "\n ]},");
|
|
94
92
|
},
|
|
95
|
-
_field: (field)
|
|
93
|
+
_field: function (field) {
|
|
96
94
|
var rule = '';
|
|
97
95
|
var config = '';
|
|
98
96
|
var options = '';
|
|
99
97
|
if (field.options) {
|
|
100
|
-
options =
|
|
101
|
-
${field.options.map(item => ` { label:"${item.label}", value: "${item.value}"}`).join(',\n')}
|
|
102
|
-
]`;
|
|
98
|
+
options = " , options: [\n".concat(field.options.map(function (item) { return " { label:\"".concat(item.label, "\", value: \"").concat(item.value, "\"}"); }).join(',\n'), "\n ]");
|
|
103
99
|
}
|
|
104
100
|
if (field.required) {
|
|
105
|
-
rule =
|
|
106
|
-
{ required: true, },
|
|
107
|
-
]`;
|
|
101
|
+
rule = " ,rule: [\n { required: true, },\n ]";
|
|
108
102
|
}
|
|
109
103
|
if (field.config) {
|
|
110
104
|
}
|
|
111
|
-
return
|
|
105
|
+
return "\n {field:\"".concat(field.field, "\", type: \"").concat(field.type, "\", label:\"").concat(field.title, "\"").concat(rule).concat(config).concat(options, "}");
|
|
112
106
|
}
|
|
113
107
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
]}
|
|
117
|
-
/>`, { imports: FORMATS, variable: 'data' });
|
|
118
|
-
const saveUForm = (schema) => {
|
|
108
|
+
var UFormCode = lodash_1.default.template("<UModal<%= _title(data.title) %><%= _layout(data.layout) %><%= _tip(data.tip) %>\n fields={[<% _.forEach(data.fields, function(field) { %><%= data.isGroup?_group(field):_field(field) %><% }); %>\n ]}\n/>", { imports: FORMATS, variable: 'data' });
|
|
109
|
+
var saveUForm = function (schema) {
|
|
119
110
|
if (schema.fields.length <= 0) {
|
|
120
111
|
antd_1.message.error('表单最少要有一个字段');
|
|
121
112
|
return;
|
|
122
113
|
}
|
|
123
|
-
|
|
124
|
-
|
|
114
|
+
var codeText = UFormCode(schema);
|
|
115
|
+
var fileName = (schema.title ? schema.title : '代码') + ".tsx";
|
|
125
116
|
var file = new File([codeText], fileName, { type: "text/plain;charset=utf-8" });
|
|
126
117
|
var a = document.createElement('a');
|
|
127
118
|
a.href = URL.createObjectURL(file);
|
|
@@ -129,25 +120,9 @@ const saveUForm = (schema) => {
|
|
|
129
120
|
a.click();
|
|
130
121
|
};
|
|
131
122
|
exports.saveUForm = saveUForm;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
name="防网络入侵策略"
|
|
136
|
-
type="2"
|
|
137
|
-
priority="2"
|
|
138
|
-
pid="d82b9e291e3445fdbabab18278caca35"
|
|
139
|
-
crc=""
|
|
140
|
-
level="1"
|
|
141
|
-
orgLevel=""
|
|
142
|
-
updateTime=""
|
|
143
|
-
executelogic="8"
|
|
144
|
-
description="防网络入侵策略模板"
|
|
145
|
-
version="8.1.1709.2218"
|
|
146
|
-
supportAgentType="1"
|
|
147
|
-
UseAgenttype="1"
|
|
148
|
-
></policy>`;
|
|
149
|
-
const saveCEMS = (schema) => {
|
|
150
|
-
let fileName = (schema.policy || schema.title || 'policy') + ".xml";
|
|
123
|
+
var CEMS = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<policy id=\"\" \n\toriginalId=\"00010094\" \n\tname=\"\u9632\u7F51\u7EDC\u5165\u4FB5\u7B56\u7565\" \n\ttype=\"2\" \n\tpriority=\"2\" \n\tpid=\"d82b9e291e3445fdbabab18278caca35\" \n\tcrc=\"\" \n\tlevel=\"1\" \n\torgLevel=\"\" \n\tupdateTime=\"\" \n\texecutelogic=\"8\" \n\tdescription=\"\u9632\u7F51\u7EDC\u5165\u4FB5\u7B56\u7565\u6A21\u677F\" \n\tversion=\"8.1.1709.2218\" \n\tsupportAgentType=\"1\" \n\tUseAgenttype=\"1\"\n></policy>";
|
|
124
|
+
var saveCEMS = function (schema) {
|
|
125
|
+
var fileName = (schema.policy || schema.title || 'policy') + ".xml";
|
|
151
126
|
var file = new File([CEMS], ".xml", { type: "text/plain;charset=utf-8" });
|
|
152
127
|
var a = document.createElement('a');
|
|
153
128
|
a.href = URL.createObjectURL(file);
|
|
@@ -155,10 +130,10 @@ const saveCEMS = (schema) => {
|
|
|
155
130
|
a.click();
|
|
156
131
|
};
|
|
157
132
|
exports.saveCEMS = saveCEMS;
|
|
158
|
-
|
|
133
|
+
var loadFormJSON = function (text) {
|
|
159
134
|
try {
|
|
160
|
-
|
|
161
|
-
|
|
135
|
+
var info = JSON.parse(text);
|
|
136
|
+
var p = setId(info);
|
|
162
137
|
// notification.success({ message: <pre dangerouslySetInnerHTML={{ __html: JSON.stringify(p, null, 2) }}></pre> })
|
|
163
138
|
return p;
|
|
164
139
|
}
|