@zhubangyun/lowcode-core 1.1.0
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/es/components/layout/index.d.ts +34 -0
- package/es/components/layout/index.js +63 -0
- package/es/components/layout/index.less +20 -0
- package/es/components/schema-render/components/assets.d.ts +32 -0
- package/es/components/schema-render/components/assets.js +53 -0
- package/es/components/schema-render/components/demo-schema.d.ts +85 -0
- package/es/components/schema-render/components/demo-schema.js +107 -0
- package/es/components/schema-render/components/schema-render-base.d.ts +43 -0
- package/es/components/schema-render/components/schema-render-base.js +142 -0
- package/es/components/schema-render/components/schema-render-layout.d.ts +6 -0
- package/es/components/schema-render/components/schema-render-layout.js +46 -0
- package/es/components/schema-render/index.d.ts +31 -0
- package/es/components/schema-render/index.js +46 -0
- package/es/components/typing.d.ts +3 -0
- package/es/components/typing.js +12 -0
- package/es/index.d.ts +7 -0
- package/es/index.js +7 -0
- package/es/pages/data/assets.d.ts +32 -0
- package/es/pages/data/assets.js +53 -0
- package/es/pages/data/schema.d.ts +50 -0
- package/es/pages/data/schema.js +49 -0
- package/es/pages/index.d.ts +1 -0
- package/es/pages/index.js +31 -0
- package/es/pages/index.less +0 -0
- package/es/style.js +6 -0
- package/es/utils/api/index.d.ts +1 -0
- package/es/utils/api/index.js +12 -0
- package/es/utils/common/ClientCache.d.ts +36 -0
- package/es/utils/common/ClientCache.js +120 -0
- package/es/utils/common/FormDataHandler.d.ts +45 -0
- package/es/utils/common/FormDataHandler.js +410 -0
- package/es/utils/common/LoadPlugins.d.ts +1 -0
- package/es/utils/common/LoadPlugins.js +158 -0
- package/es/utils/common/ProcessHandler.d.ts +30 -0
- package/es/utils/common/ProcessHandler.js +303 -0
- package/es/utils/common/Request.d.ts +2 -0
- package/es/utils/common/Request.js +20 -0
- package/es/utils/common/RestApi.d.ts +80 -0
- package/es/utils/common/RestApi.js +226 -0
- package/es/utils/common/RestFormApi.d.ts +12 -0
- package/es/utils/common/RestFormApi.js +158 -0
- package/es/utils/common/SubFormInstance.d.ts +26 -0
- package/es/utils/common/SubFormInstance.js +100 -0
- package/es/utils/common/UserInfo.d.ts +9 -0
- package/es/utils/common/UserInfo.js +19 -0
- package/es/utils/common/index.d.ts +7 -0
- package/es/utils/common/index.js +39 -0
- package/es/utils/index.d.ts +17 -0
- package/es/utils/index.js +11 -0
- package/es/utils/lowcode/index.d.ts +1 -0
- package/es/utils/lowcode/index.js +1 -0
- package/es/utils/lowcode/parseAssets.d.ts +3 -0
- package/es/utils/lowcode/parseAssets.js +185 -0
- package/lib/components/layout/index.d.ts +34 -0
- package/lib/components/layout/index.js +69 -0
- package/lib/components/layout/index.less +20 -0
- package/lib/components/schema-render/components/assets.d.ts +32 -0
- package/lib/components/schema-render/components/assets.js +57 -0
- package/lib/components/schema-render/components/demo-schema.d.ts +85 -0
- package/lib/components/schema-render/components/demo-schema.js +111 -0
- package/lib/components/schema-render/components/schema-render-base.d.ts +43 -0
- package/lib/components/schema-render/components/schema-render-base.js +149 -0
- package/lib/components/schema-render/components/schema-render-layout.d.ts +6 -0
- package/lib/components/schema-render/components/schema-render-layout.js +51 -0
- package/lib/components/schema-render/index.d.ts +31 -0
- package/lib/components/schema-render/index.js +53 -0
- package/lib/components/typing.d.ts +3 -0
- package/lib/components/typing.js +17 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +15 -0
- package/lib/pages/data/assets.d.ts +32 -0
- package/lib/pages/data/assets.js +57 -0
- package/lib/pages/data/schema.d.ts +50 -0
- package/lib/pages/data/schema.js +53 -0
- package/lib/pages/index.d.ts +1 -0
- package/lib/pages/index.js +34 -0
- package/lib/pages/index.less +0 -0
- package/lib/style.js +6 -0
- package/lib/utils/api/index.d.ts +1 -0
- package/lib/utils/api/index.js +17 -0
- package/lib/utils/common/ClientCache.d.ts +36 -0
- package/lib/utils/common/ClientCache.js +125 -0
- package/lib/utils/common/FormDataHandler.d.ts +45 -0
- package/lib/utils/common/FormDataHandler.js +416 -0
- package/lib/utils/common/LoadPlugins.d.ts +1 -0
- package/lib/utils/common/LoadPlugins.js +163 -0
- package/lib/utils/common/ProcessHandler.d.ts +30 -0
- package/lib/utils/common/ProcessHandler.js +308 -0
- package/lib/utils/common/Request.d.ts +2 -0
- package/lib/utils/common/Request.js +25 -0
- package/lib/utils/common/RestApi.d.ts +80 -0
- package/lib/utils/common/RestApi.js +230 -0
- package/lib/utils/common/RestFormApi.d.ts +12 -0
- package/lib/utils/common/RestFormApi.js +163 -0
- package/lib/utils/common/SubFormInstance.d.ts +26 -0
- package/lib/utils/common/SubFormInstance.js +105 -0
- package/lib/utils/common/UserInfo.d.ts +9 -0
- package/lib/utils/common/UserInfo.js +24 -0
- package/lib/utils/common/index.d.ts +7 -0
- package/lib/utils/common/index.js +48 -0
- package/lib/utils/index.d.ts +17 -0
- package/lib/utils/index.js +34 -0
- package/lib/utils/lowcode/index.d.ts +1 -0
- package/lib/utils/lowcode/index.js +6 -0
- package/lib/utils/lowcode/parseAssets.d.ts +3 -0
- package/lib/utils/lowcode/parseAssets.js +192 -0
- package/package.json +65 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import _message from "antd/es/message";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
import { exeProcessScript } from "./ProcessHandler";
|
|
8
|
+
import dayjs, { isDayjs } from "dayjs";
|
|
9
|
+
import { SubFormInstance } from "./SubFormInstance";
|
|
10
|
+
var FormDataHandler = /*#__PURE__*/function () {
|
|
11
|
+
function FormDataHandler(schema) {
|
|
12
|
+
this.schema = void 0;
|
|
13
|
+
this.name = void 0;
|
|
14
|
+
this.fields = [];
|
|
15
|
+
this.scripts = void 0;
|
|
16
|
+
this.subFormHandlers = [];
|
|
17
|
+
this.schema = schema;
|
|
18
|
+
this.name = schema.props.name;
|
|
19
|
+
this.scripts = schema.props.scripts || [];
|
|
20
|
+
var fields = this.fields,
|
|
21
|
+
subFormHandlers = this.subFormHandlers;
|
|
22
|
+
function loopEach(item) {
|
|
23
|
+
if (Array.isArray(item === null || item === void 0 ? void 0 : item.children)) {
|
|
24
|
+
for (var _iterator = _createForOfIteratorHelperLoose(item.children), _step; !(_step = _iterator()).done;) {
|
|
25
|
+
var child = _step.value;
|
|
26
|
+
fields.push(child);
|
|
27
|
+
if (child.componentName == "TableField") {
|
|
28
|
+
subFormHandlers.push(new FormDataHandler(child));
|
|
29
|
+
} else {
|
|
30
|
+
loopEach(child);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
loopEach(schema);
|
|
36
|
+
}
|
|
37
|
+
var _proto = FormDataHandler.prototype;
|
|
38
|
+
_proto.onValuesChange = /*#__PURE__*/function () {
|
|
39
|
+
var _onValuesChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
40
|
+
var form, changeValues, _options$depth, depth, isChange, _iterator2, _step2, script, _iterator3, _step3, handler, index, _iterator4, _step4, subChangeValues, subForm;
|
|
41
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
42
|
+
while (1) switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
form = options.form, changeValues = options.changeValues, _options$depth = options.depth, depth = _options$depth === void 0 ? 1 : _options$depth;
|
|
45
|
+
if (!(depth > 5)) {
|
|
46
|
+
_context.next = 3;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
return _context.abrupt("return");
|
|
50
|
+
case 3:
|
|
51
|
+
if (changeValues) {
|
|
52
|
+
_context.next = 5;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return _context.abrupt("return");
|
|
56
|
+
case 5:
|
|
57
|
+
isChange = Object.keys(changeValues).length == 1;
|
|
58
|
+
if (!isChange) {
|
|
59
|
+
_context.next = 21;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
_context.next = 9;
|
|
63
|
+
return this.handleLinkage(options);
|
|
64
|
+
case 9:
|
|
65
|
+
_context.next = 11;
|
|
66
|
+
return this.handleFieldValue(options);
|
|
67
|
+
case 11:
|
|
68
|
+
_context.next = 13;
|
|
69
|
+
return this.handleFillTableValues(options);
|
|
70
|
+
case 13:
|
|
71
|
+
_iterator2 = _createForOfIteratorHelperLoose(this.scripts);
|
|
72
|
+
case 14:
|
|
73
|
+
if ((_step2 = _iterator2()).done) {
|
|
74
|
+
_context.next = 21;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
script = _step2.value;
|
|
78
|
+
if (!(script.timing == "change")) {
|
|
79
|
+
_context.next = 19;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
_context.next = 19;
|
|
83
|
+
return exeProcessScript(options, script);
|
|
84
|
+
case 19:
|
|
85
|
+
_context.next = 14;
|
|
86
|
+
break;
|
|
87
|
+
case 21:
|
|
88
|
+
_iterator3 = _createForOfIteratorHelperLoose(this.subFormHandlers);
|
|
89
|
+
case 22:
|
|
90
|
+
if ((_step3 = _iterator3()).done) {
|
|
91
|
+
_context.next = 42;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
handler = _step3.value;
|
|
95
|
+
if (handler.name in changeValues) {
|
|
96
|
+
_context.next = 26;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
return _context.abrupt("continue", 40);
|
|
100
|
+
case 26:
|
|
101
|
+
if (Array.isArray(changeValues[handler.name])) {
|
|
102
|
+
_context.next = 28;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
return _context.abrupt("continue", 40);
|
|
106
|
+
case 28:
|
|
107
|
+
index = -1;
|
|
108
|
+
_iterator4 = _createForOfIteratorHelperLoose(changeValues[handler.name]);
|
|
109
|
+
case 30:
|
|
110
|
+
if ((_step4 = _iterator4()).done) {
|
|
111
|
+
_context.next = 40;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
subChangeValues = _step4.value;
|
|
115
|
+
index++;
|
|
116
|
+
if (subChangeValues) {
|
|
117
|
+
_context.next = 35;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
return _context.abrupt("continue", 38);
|
|
121
|
+
case 35:
|
|
122
|
+
subForm = new SubFormInstance(form, [handler.name, index]);
|
|
123
|
+
_context.next = 38;
|
|
124
|
+
return handler.onValuesChange({
|
|
125
|
+
depth: depth + 1,
|
|
126
|
+
form: subForm,
|
|
127
|
+
changeValues: subChangeValues
|
|
128
|
+
});
|
|
129
|
+
case 38:
|
|
130
|
+
_context.next = 30;
|
|
131
|
+
break;
|
|
132
|
+
case 40:
|
|
133
|
+
_context.next = 22;
|
|
134
|
+
break;
|
|
135
|
+
case 42:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context.stop();
|
|
138
|
+
}
|
|
139
|
+
}, _callee, this);
|
|
140
|
+
}));
|
|
141
|
+
function onValuesChange(_x) {
|
|
142
|
+
return _onValuesChange.apply(this, arguments);
|
|
143
|
+
}
|
|
144
|
+
return onValuesChange;
|
|
145
|
+
}()
|
|
146
|
+
/**
|
|
147
|
+
* 处理联动数据
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
;
|
|
151
|
+
_proto.handleLinkage =
|
|
152
|
+
/*#__PURE__*/
|
|
153
|
+
function () {
|
|
154
|
+
var _handleLinkage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
155
|
+
var _iterator5, _step5, field, _field$props, name, label, format, _field$props$defaultV, type, custom, shortcut, formula, linkage;
|
|
156
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
157
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
158
|
+
case 0:
|
|
159
|
+
_iterator5 = _createForOfIteratorHelperLoose(this.fields);
|
|
160
|
+
case 1:
|
|
161
|
+
if ((_step5 = _iterator5()).done) {
|
|
162
|
+
_context2.next = 13;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
field = _step5.value;
|
|
166
|
+
if (field.props.defaultValue) {
|
|
167
|
+
_context2.next = 5;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
return _context2.abrupt("continue", 11);
|
|
171
|
+
case 5:
|
|
172
|
+
if (!(field.componentName === "TableField")) {
|
|
173
|
+
_context2.next = 7;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
return _context2.abrupt("continue", 11);
|
|
177
|
+
case 7:
|
|
178
|
+
_field$props = field.props, name = _field$props.name, label = _field$props.label, format = _field$props.format;
|
|
179
|
+
_field$props$defaultV = field.props.defaultValue, type = _field$props$defaultV.type, custom = _field$props$defaultV.custom, shortcut = _field$props$defaultV.shortcut, formula = _field$props$defaultV.formula, linkage = _field$props$defaultV.linkage;
|
|
180
|
+
if (!(type != "linkage")) {
|
|
181
|
+
_context2.next = 11;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
return _context2.abrupt("continue", 11);
|
|
185
|
+
case 11:
|
|
186
|
+
_context2.next = 1;
|
|
187
|
+
break;
|
|
188
|
+
case 13:
|
|
189
|
+
case "end":
|
|
190
|
+
return _context2.stop();
|
|
191
|
+
}
|
|
192
|
+
}, _callee2, this);
|
|
193
|
+
}));
|
|
194
|
+
function handleLinkage(_x2) {
|
|
195
|
+
return _handleLinkage.apply(this, arguments);
|
|
196
|
+
}
|
|
197
|
+
return handleLinkage;
|
|
198
|
+
}();
|
|
199
|
+
_proto.handleFieldValue = /*#__PURE__*/function () {
|
|
200
|
+
var _handleFieldValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
|
|
201
|
+
var form, _iterator6, _step6, field, _field$props2, formula, name, label, trim, value, formulaValue;
|
|
202
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
203
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
204
|
+
case 0:
|
|
205
|
+
form = options.form;
|
|
206
|
+
_iterator6 = _createForOfIteratorHelperLoose(this.fields);
|
|
207
|
+
case 2:
|
|
208
|
+
if ((_step6 = _iterator6()).done) {
|
|
209
|
+
_context3.next = 12;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
field = _step6.value;
|
|
213
|
+
if (!isTableField(field)) {
|
|
214
|
+
_context3.next = 6;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
return _context3.abrupt("continue", 10);
|
|
218
|
+
case 6:
|
|
219
|
+
_field$props2 = field.props, formula = _field$props2.formula, name = _field$props2.name, label = _field$props2.label, trim = _field$props2.trim;
|
|
220
|
+
value = form.getFieldValue(name);
|
|
221
|
+
if (formula) {
|
|
222
|
+
try {
|
|
223
|
+
formulaValue = eval(formula);
|
|
224
|
+
form.setFieldValue(name, formulaValue);
|
|
225
|
+
} catch (e) {
|
|
226
|
+
console.log("\u6267\u884C'" + label + "'\u8BA1\u7B97\u516C\u5F0F\u5931\u8D25!", formula, e);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (trim) {
|
|
230
|
+
if (value && typeof value == "string") {
|
|
231
|
+
form.setFieldValue(name, value.trim());
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
case 10:
|
|
235
|
+
_context3.next = 2;
|
|
236
|
+
break;
|
|
237
|
+
case 12:
|
|
238
|
+
case "end":
|
|
239
|
+
return _context3.stop();
|
|
240
|
+
}
|
|
241
|
+
}, _callee3, this);
|
|
242
|
+
}));
|
|
243
|
+
function handleFieldValue(_x3) {
|
|
244
|
+
return _handleFieldValue.apply(this, arguments);
|
|
245
|
+
}
|
|
246
|
+
return handleFieldValue;
|
|
247
|
+
}()
|
|
248
|
+
/**
|
|
249
|
+
* 处理填充子表
|
|
250
|
+
*/
|
|
251
|
+
;
|
|
252
|
+
_proto.handleFillTableValues =
|
|
253
|
+
/*#__PURE__*/
|
|
254
|
+
function () {
|
|
255
|
+
var _handleFillTableValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(options) {
|
|
256
|
+
var form, _loop, _iterator7, _step7;
|
|
257
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context5) {
|
|
258
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
259
|
+
case 0:
|
|
260
|
+
form = options.form;
|
|
261
|
+
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
262
|
+
var _fillTableValues$forE;
|
|
263
|
+
var field, _field$props3, name, fillTableValues;
|
|
264
|
+
return _regeneratorRuntime.wrap(function _loop$(_context4) {
|
|
265
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
266
|
+
case 0:
|
|
267
|
+
field = _step7.value;
|
|
268
|
+
if (!isTableField(field)) {
|
|
269
|
+
_context4.next = 3;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
return _context4.abrupt("return", 1);
|
|
273
|
+
case 3:
|
|
274
|
+
_field$props3 = field.props, name = _field$props3.name, fillTableValues = _field$props3.fillTableValues;
|
|
275
|
+
fillTableValues === null || fillTableValues === void 0 ? void 0 : (_fillTableValues$forE = fillTableValues.forEach) === null || _fillTableValues$forE === void 0 ? void 0 : _fillTableValues$forE.call(fillTableValues, function (cfg) {
|
|
276
|
+
var table = cfg.split(".")[0];
|
|
277
|
+
var tableField = cfg.split(".")[1];
|
|
278
|
+
if (table && tableField) {
|
|
279
|
+
var _values$table, _values$table$forEach;
|
|
280
|
+
var values = form.getFieldsValue();
|
|
281
|
+
var value = form.getFieldValue(name);
|
|
282
|
+
(_values$table = values[table]) === null || _values$table === void 0 ? void 0 : (_values$table$forEach = _values$table.forEach) === null || _values$table$forEach === void 0 ? void 0 : _values$table$forEach.call(_values$table, function (item, index) {
|
|
283
|
+
form.setFieldValue([table, index, tableField], value);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
case 5:
|
|
288
|
+
case "end":
|
|
289
|
+
return _context4.stop();
|
|
290
|
+
}
|
|
291
|
+
}, _loop);
|
|
292
|
+
});
|
|
293
|
+
_iterator7 = _createForOfIteratorHelperLoose(this.fields);
|
|
294
|
+
case 3:
|
|
295
|
+
if ((_step7 = _iterator7()).done) {
|
|
296
|
+
_context5.next = 9;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
return _context5.delegateYield(_loop(), "t0", 5);
|
|
300
|
+
case 5:
|
|
301
|
+
if (!_context5.t0) {
|
|
302
|
+
_context5.next = 7;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
return _context5.abrupt("continue", 7);
|
|
306
|
+
case 7:
|
|
307
|
+
_context5.next = 3;
|
|
308
|
+
break;
|
|
309
|
+
case 9:
|
|
310
|
+
case "end":
|
|
311
|
+
return _context5.stop();
|
|
312
|
+
}
|
|
313
|
+
}, _callee4, this);
|
|
314
|
+
}));
|
|
315
|
+
function handleFillTableValues(_x4) {
|
|
316
|
+
return _handleFillTableValues.apply(this, arguments);
|
|
317
|
+
}
|
|
318
|
+
return handleFillTableValues;
|
|
319
|
+
}()
|
|
320
|
+
/***
|
|
321
|
+
* 创建初期值
|
|
322
|
+
* @private
|
|
323
|
+
*/
|
|
324
|
+
;
|
|
325
|
+
_proto.createInitValues =
|
|
326
|
+
/*#__PURE__*/
|
|
327
|
+
function () {
|
|
328
|
+
var _createInitValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
329
|
+
var values;
|
|
330
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context6) {
|
|
331
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
332
|
+
case 0:
|
|
333
|
+
values = {
|
|
334
|
+
initial: true,
|
|
335
|
+
createdAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
|
336
|
+
};
|
|
337
|
+
this.fields.forEach(function (field) {
|
|
338
|
+
//没有配置初始值 直接返回
|
|
339
|
+
if (!field.props.defaultValue) return;
|
|
340
|
+
//子表不处理
|
|
341
|
+
if (field.componentName === "TableField") return;
|
|
342
|
+
var _field$props4 = field.props,
|
|
343
|
+
name = _field$props4.name,
|
|
344
|
+
label = _field$props4.label,
|
|
345
|
+
format = _field$props4.format;
|
|
346
|
+
var _field$props$defaultV2 = field.props.defaultValue,
|
|
347
|
+
type = _field$props$defaultV2.type,
|
|
348
|
+
custom = _field$props$defaultV2.custom,
|
|
349
|
+
shortcut = _field$props$defaultV2.shortcut,
|
|
350
|
+
formula = _field$props$defaultV2.formula,
|
|
351
|
+
linkage = _field$props$defaultV2.linkage;
|
|
352
|
+
var initValue;
|
|
353
|
+
switch (type) {
|
|
354
|
+
//关联值
|
|
355
|
+
case "linkage":
|
|
356
|
+
break;
|
|
357
|
+
//自定义
|
|
358
|
+
case "custom":
|
|
359
|
+
initValue = custom;
|
|
360
|
+
break;
|
|
361
|
+
//公式
|
|
362
|
+
case "formula":
|
|
363
|
+
try {
|
|
364
|
+
initValue = eval(formula);
|
|
365
|
+
} catch (e) {
|
|
366
|
+
_message.error("\u8BBE\u7F6E" + label + "\u521D\u59CB\u503C\u5931\u8D25!" + (e === null || e === void 0 ? void 0 : e.message)).then();
|
|
367
|
+
}
|
|
368
|
+
break;
|
|
369
|
+
//快捷方式
|
|
370
|
+
case "shortcut":
|
|
371
|
+
try {
|
|
372
|
+
initValue = eval(shortcut);
|
|
373
|
+
} catch (e) {
|
|
374
|
+
_message.error("\u8BBE\u7F6E" + label + "\u521D\u59CB\u503C\u5931\u8D25!" + (e === null || e === void 0 ? void 0 : e.message)).then();
|
|
375
|
+
}
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
values[name] = handleValue(initValue, format);
|
|
379
|
+
});
|
|
380
|
+
return _context6.abrupt("return", values);
|
|
381
|
+
case 3:
|
|
382
|
+
case "end":
|
|
383
|
+
return _context6.stop();
|
|
384
|
+
}
|
|
385
|
+
}, _callee5, this);
|
|
386
|
+
}));
|
|
387
|
+
function createInitValues() {
|
|
388
|
+
return _createInitValues.apply(this, arguments);
|
|
389
|
+
}
|
|
390
|
+
return createInitValues;
|
|
391
|
+
}();
|
|
392
|
+
return FormDataHandler;
|
|
393
|
+
}();
|
|
394
|
+
export { FormDataHandler as default };
|
|
395
|
+
function handleValue(value, format) {
|
|
396
|
+
if (!format) return value;
|
|
397
|
+
if (!value) return value;
|
|
398
|
+
if (Array.isArray(value)) {
|
|
399
|
+
return value.map(function (v) {
|
|
400
|
+
return handleValue(v, format);
|
|
401
|
+
});
|
|
402
|
+
} else if (isDayjs(value)) {
|
|
403
|
+
return value.format(format);
|
|
404
|
+
} else {
|
|
405
|
+
return value;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function isTableField(field) {
|
|
409
|
+
return field.componentName === "TableField";
|
|
410
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadPlugins(plugins: string[]): Promise<void>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
var doc = document;
|
|
7
|
+
export function loadPlugins(_x) {
|
|
8
|
+
return _loadPlugins.apply(this, arguments);
|
|
9
|
+
}
|
|
10
|
+
function _loadPlugins() {
|
|
11
|
+
_loadPlugins = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(plugins) {
|
|
12
|
+
var _iterator, _step, plugin, _iterator2, _step2, _plugin;
|
|
13
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
14
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15
|
+
case 0:
|
|
16
|
+
_iterator = _createForOfIteratorHelperLoose(plugins);
|
|
17
|
+
case 1:
|
|
18
|
+
if ((_step = _iterator()).done) {
|
|
19
|
+
_context.next = 7;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
plugin = _step.value;
|
|
23
|
+
_context.next = 5;
|
|
24
|
+
return loadStyle(plugin);
|
|
25
|
+
case 5:
|
|
26
|
+
_context.next = 1;
|
|
27
|
+
break;
|
|
28
|
+
case 7:
|
|
29
|
+
_iterator2 = _createForOfIteratorHelperLoose(plugins);
|
|
30
|
+
case 8:
|
|
31
|
+
if ((_step2 = _iterator2()).done) {
|
|
32
|
+
_context.next = 14;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
_plugin = _step2.value;
|
|
36
|
+
_context.next = 12;
|
|
37
|
+
return loadScript(_plugin);
|
|
38
|
+
case 12:
|
|
39
|
+
_context.next = 8;
|
|
40
|
+
break;
|
|
41
|
+
case 14:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}, _callee);
|
|
46
|
+
}));
|
|
47
|
+
return _loadPlugins.apply(this, arguments);
|
|
48
|
+
}
|
|
49
|
+
function loadStyle(_x2) {
|
|
50
|
+
return _loadStyle.apply(this, arguments);
|
|
51
|
+
}
|
|
52
|
+
function _loadStyle() {
|
|
53
|
+
_loadStyle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(src) {
|
|
54
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
55
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
if (src.endsWith("css")) {
|
|
58
|
+
_context3.next = 2;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
return _context3.abrupt("return", true);
|
|
62
|
+
case 2:
|
|
63
|
+
return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
64
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve) {
|
|
65
|
+
var target;
|
|
66
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
67
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
//加载式样
|
|
70
|
+
target = doc.querySelector("link[href='" + src + "']");
|
|
71
|
+
if (!target) {
|
|
72
|
+
target = doc.createElement("link");
|
|
73
|
+
target.href = src;
|
|
74
|
+
target.rel = "stylesheet";
|
|
75
|
+
target.onload = function () {
|
|
76
|
+
return resolve(true);
|
|
77
|
+
};
|
|
78
|
+
target.onerror = function () {
|
|
79
|
+
return resolve(false);
|
|
80
|
+
};
|
|
81
|
+
doc.head.appendChild(target);
|
|
82
|
+
} else {
|
|
83
|
+
resolve(true);
|
|
84
|
+
}
|
|
85
|
+
case 2:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context2.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee2);
|
|
90
|
+
}));
|
|
91
|
+
return function (_x4) {
|
|
92
|
+
return _ref.apply(this, arguments);
|
|
93
|
+
};
|
|
94
|
+
}()));
|
|
95
|
+
case 3:
|
|
96
|
+
case "end":
|
|
97
|
+
return _context3.stop();
|
|
98
|
+
}
|
|
99
|
+
}, _callee3);
|
|
100
|
+
}));
|
|
101
|
+
return _loadStyle.apply(this, arguments);
|
|
102
|
+
}
|
|
103
|
+
function loadScript(_x3) {
|
|
104
|
+
return _loadScript.apply(this, arguments);
|
|
105
|
+
}
|
|
106
|
+
function _loadScript() {
|
|
107
|
+
_loadScript = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(src) {
|
|
108
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
109
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
110
|
+
case 0:
|
|
111
|
+
if (src.endsWith("js")) {
|
|
112
|
+
_context5.next = 2;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context5.abrupt("return", true);
|
|
116
|
+
case 2:
|
|
117
|
+
return _context5.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
118
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(resolve, reject) {
|
|
119
|
+
var target;
|
|
120
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
121
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
122
|
+
case 0:
|
|
123
|
+
//加载脚本
|
|
124
|
+
target = doc.querySelector("script[src='" + src + "']");
|
|
125
|
+
if (!target) {
|
|
126
|
+
target = doc.createElement("script");
|
|
127
|
+
if (src.endsWith("mjs")) {
|
|
128
|
+
target.type = "module";
|
|
129
|
+
}
|
|
130
|
+
target.src = src;
|
|
131
|
+
target.onload = function () {
|
|
132
|
+
return resolve(true);
|
|
133
|
+
};
|
|
134
|
+
target.onerror = function () {
|
|
135
|
+
return resolve(false);
|
|
136
|
+
};
|
|
137
|
+
doc.body.appendChild(target);
|
|
138
|
+
} else {
|
|
139
|
+
resolve(true);
|
|
140
|
+
}
|
|
141
|
+
case 2:
|
|
142
|
+
case "end":
|
|
143
|
+
return _context4.stop();
|
|
144
|
+
}
|
|
145
|
+
}, _callee4);
|
|
146
|
+
}));
|
|
147
|
+
return function (_x5, _x6) {
|
|
148
|
+
return _ref2.apply(this, arguments);
|
|
149
|
+
};
|
|
150
|
+
}()));
|
|
151
|
+
case 3:
|
|
152
|
+
case "end":
|
|
153
|
+
return _context5.stop();
|
|
154
|
+
}
|
|
155
|
+
}, _callee5);
|
|
156
|
+
}));
|
|
157
|
+
return _loadScript.apply(this, arguments);
|
|
158
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FormInstance } from "antd/lib";
|
|
2
|
+
export declare type ProcessScriptOptions = {
|
|
3
|
+
depth: number;
|
|
4
|
+
form: FormInstance;
|
|
5
|
+
changeValues: any;
|
|
6
|
+
};
|
|
7
|
+
export declare type ProcessScriptType = {
|
|
8
|
+
timing: "change" | "submit";
|
|
9
|
+
script: string;
|
|
10
|
+
nodeTitle: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function exeProcessScript(options: ProcessScriptOptions, scriptType: ProcessScriptType): Promise<void>;
|
|
13
|
+
export declare type ProcessNodeProps = {
|
|
14
|
+
type: any;
|
|
15
|
+
branchType: "condition" | "parallel";
|
|
16
|
+
nodeTitle: string;
|
|
17
|
+
message: string;
|
|
18
|
+
notFoundDataAction: "ctn" | "ins";
|
|
19
|
+
actionType?: "direct" | "business";
|
|
20
|
+
breakType: "continue" | "break" | "return" | "exception";
|
|
21
|
+
nodeId?: string;
|
|
22
|
+
formId: string;
|
|
23
|
+
events?: ("ins" | "upd" | "del")[];
|
|
24
|
+
timing?: "bef" | "aft";
|
|
25
|
+
conditions: any[];
|
|
26
|
+
assignments: any[];
|
|
27
|
+
filters: any[];
|
|
28
|
+
sorts: any[];
|
|
29
|
+
pageSize: number;
|
|
30
|
+
};
|