venus-design 1.1.21 → 1.1.24

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.
Files changed (33) hide show
  1. package/dist/Config/api.d.ts +6 -0
  2. package/dist/Config/api.js +154 -118
  3. package/dist/DataView/index.js +0 -1
  4. package/dist/DataView/resizable/index.js +14 -5
  5. package/dist/Drawer/index.js +6 -3
  6. package/dist/ProForm/index.d.ts +14 -2
  7. package/dist/ProForm/index.js +122 -35
  8. package/dist/RadioAndInput/index.js +1 -0
  9. package/dist/SelectCompoments/SelectUserOrDeptBySeclevel/selectPanel/dept.js +4 -4
  10. package/dist/SelectCompoments/SelectUserOrDeptBySeclevel/selectPanel/user.js +19 -15
  11. package/dist/SelectCompoments/SelectUserOrDeptBySeclevel/styles.less +1 -0
  12. package/dist/VenusAdjust/index.js +8 -4
  13. package/dist/VenusAdjust/interface.d.ts +10 -9
  14. package/dist/VenusDesignCom/components/Form.js +1 -1
  15. package/dist/VenusDetail/handleVenusDetailFunctions.js +6 -4
  16. package/dist/VenusDetail/staticAttr.js +74 -26
  17. package/dist/VenusForm/VenusFormScriptEngine.d.ts +96 -0
  18. package/dist/VenusForm/VenusFormScriptEngine.js +207 -0
  19. package/dist/VenusForm/VenusFormScriptUtils.d.ts +7 -0
  20. package/dist/VenusForm/VenusFormScriptUtils.js +190 -0
  21. package/dist/VenusForm/index.js +226 -37
  22. package/dist/VenusForm/interface.d.ts +4 -2
  23. package/dist/VenusForm/staticAttr.d.ts +1 -0
  24. package/dist/VenusForm/staticAttr.js +90 -62
  25. package/dist/VenusTable/components/filterDrawer/index.js +6 -3
  26. package/dist/VenusTable/components/filterDrawer/staticAttr.js +5 -4
  27. package/dist/VenusTable/index.js +46 -39
  28. package/dist/VenusTable/staticAttr.js +16 -10
  29. package/dist/VenusTable/style.css +2 -6
  30. package/dist/VenusUploadSecLevel/index.js +1 -0
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +1 -1
  33. package/package.json +1 -1
@@ -0,0 +1,190 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import "antd/es/modal/style";
3
+ import _Modal from "antd/es/modal";
4
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
5
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ 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); }
13
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15
+ 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; }
16
+ import { deepClone, dfs } from "./..";
17
+
18
+ /**
19
+ * 创建脚本工具方法实例
20
+ */
21
+ export var createScriptUtils = function createScriptUtils(form, formDataConfig, setFormDataConfig, messageApi) {
22
+ // 获取所有字段的扁平列表
23
+ var getAllFields = function getAllFields() {
24
+ var fields = [];
25
+ formDataConfig.forEach(function (group) {
26
+ if (group.attributeList) {
27
+ fields.push.apply(fields, _toConsumableArray(group.attributeList));
28
+ }
29
+ });
30
+ return fields;
31
+ };
32
+
33
+ // 修改表单配置并触发重新渲染
34
+ var modifyConfig = function modifyConfig(modifier) {
35
+ var clone = deepClone(formDataConfig);
36
+ dfs(clone, function (node) {
37
+ modifier(node);
38
+ });
39
+ setFormDataConfig(clone);
40
+ };
41
+ return {
42
+ // 获取字段值
43
+ getValue: function getValue(fieldId) {
44
+ return form.getFieldValue(fieldId);
45
+ },
46
+ // 设置字段值
47
+ setValue: function setValue(fieldId, value) {
48
+ console.log("setValue", fieldId, value);
49
+ form.setFieldsValue(_defineProperty({}, fieldId, value));
50
+ },
51
+ // 设置多个字段值
52
+ setValues: function setValues(values) {
53
+ form.setFieldsValue(values);
54
+ },
55
+ // 显示/隐藏字段
56
+ setVisible: function setVisible(fieldId, visible) {
57
+ modifyConfig(function (node) {
58
+ if (node.fieldId === fieldId) {
59
+ node.formShowFlag = visible ? 0 : 1; // 0显示 1隐藏
60
+ }
61
+ });
62
+ },
63
+ // 启用/禁用字段
64
+ setDisabled: function setDisabled(fieldId, disabled) {
65
+ modifyConfig(function (node) {
66
+ if (node.fieldId === fieldId) {
67
+ //@ts-ignore
68
+ node.nonEditableScene = disabled ? 'EDIT' : null;
69
+ }
70
+ });
71
+ },
72
+ // 设置必填/非必填
73
+ setRequired: function setRequired(fieldId, required) {
74
+ modifyConfig(function (node) {
75
+ if (node.fieldId === fieldId) {
76
+ node.formRequiredFlag = required ? 1 : 0;
77
+ }
78
+ });
79
+ },
80
+ // 设置字段选项
81
+ setOptions: function setOptions(fieldId, options) {
82
+ modifyConfig(function (node) {
83
+ if (node.fieldId === fieldId) {
84
+ node.selectSource = options.map(function (opt) {
85
+ return {
86
+ innerId: opt.value,
87
+ parentId: '',
88
+ type: '',
89
+ value: opt.value,
90
+ label: opt.label,
91
+ children: []
92
+ };
93
+ });
94
+ }
95
+ });
96
+ },
97
+ // 获取字段配置
98
+ getField: function getField(fieldId) {
99
+ return getAllFields().find(function (f) {
100
+ return f.fieldId === fieldId;
101
+ });
102
+ },
103
+ // 消息提示
104
+ message: {
105
+ success: function success(msg) {
106
+ return messageApi.success(msg);
107
+ },
108
+ error: function error(msg) {
109
+ return messageApi.error(msg);
110
+ },
111
+ warning: function warning(msg) {
112
+ return messageApi.warning(msg);
113
+ },
114
+ info: function info(msg) {
115
+ return messageApi.info(msg);
116
+ }
117
+ },
118
+ // 确认对话框
119
+ confirm: function confirm(title, content) {
120
+ return new Promise(function (resolve) {
121
+ _Modal.confirm({
122
+ title: title,
123
+ content: content,
124
+ onOk: function onOk() {
125
+ return resolve(true);
126
+ },
127
+ onCancel: function onCancel() {
128
+ return resolve(false);
129
+ }
130
+ });
131
+ });
132
+ },
133
+ // 延时
134
+ sleep: function sleep(ms) {
135
+ return new Promise(function (resolve) {
136
+ return setTimeout(resolve, ms);
137
+ });
138
+ },
139
+ // 发送请求
140
+ request: function () {
141
+ var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
142
+ var options,
143
+ response,
144
+ _args = arguments;
145
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
146
+ while (1) switch (_context.prev = _context.next) {
147
+ case 0:
148
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
149
+ _context.next = 3;
150
+ return fetch(url, options);
151
+ case 3:
152
+ response = _context.sent;
153
+ return _context.abrupt("return", response.json());
154
+ case 5:
155
+ case "end":
156
+ return _context.stop();
157
+ }
158
+ }, _callee);
159
+ }));
160
+ function request(_x) {
161
+ return _request.apply(this, arguments);
162
+ }
163
+ return request;
164
+ }(),
165
+ // 控制台(带前缀,方便调试)
166
+ console: {
167
+ log: function log() {
168
+ var _console;
169
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
170
+ args[_key] = arguments[_key];
171
+ }
172
+ return (_console = console).log.apply(_console, ['[表单脚本]'].concat(args));
173
+ },
174
+ error: function error() {
175
+ var _console2;
176
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
177
+ args[_key2] = arguments[_key2];
178
+ }
179
+ return (_console2 = console).error.apply(_console2, ['[表单脚本]'].concat(args));
180
+ },
181
+ warn: function warn() {
182
+ var _console3;
183
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
184
+ args[_key3] = arguments[_key3];
185
+ }
186
+ return (_console3 = console).warn.apply(_console3, ['[表单脚本]'].concat(args));
187
+ }
188
+ }
189
+ };
190
+ };
@@ -1,8 +1,15 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
1
  import "antd/es/button/style";
3
2
  import _Button from "antd/es/button";
3
+ import "antd/es/message/style";
4
+ import _message from "antd/es/message";
4
5
  var _excluded = ["dataSource", "form", "onSetDataAfter", "closeParentEdit"];
5
6
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
9
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
13
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
7
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -11,17 +18,27 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
11
18
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
19
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
20
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
14
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
21
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
22
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
18
23
  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); }
19
24
  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; }
20
25
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
21
26
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
- import React, { useEffect, forwardRef, useImperativeHandle, useState, useRef } from 'react';
23
- import { ProForm, getFormData, getVenusFormFormate, handleFormItems, setVenusFormFormate, deepClone, dfs } from "./..";
27
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
28
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
+ import React, { useEffect, forwardRef, useImperativeHandle, useState, useRef, useCallback } from 'react';
30
+ import { ProForm, getFormData, getFormScripts, getVenusFormFormate, handleFormItems, setVenusFormFormate, deepClone, dfs } from "./..";
24
31
  import "./style.less";
32
+ import { VenusFormScriptEngine } from "./VenusFormScriptEngine";
33
+ import { createScriptUtils } from "./VenusFormScriptUtils";
34
+
35
+ // 脚本引擎实例(单例)
36
+ var scriptEngine = new VenusFormScriptEngine({
37
+ debug: true,
38
+ timeout: 10000
39
+ });
40
+
41
+ // 脚本类型定义
25
42
 
26
43
  /**
27
44
  * 表单组件
@@ -30,34 +47,31 @@ import "./style.less";
30
47
  */
31
48
 
32
49
  var VenusForm = /*#__PURE__*/forwardRef(function (props, ref) {
50
+ var dataSource = props.dataSource,
51
+ form = props.form,
52
+ onSetDataAfter = props.onSetDataAfter,
53
+ closeParentEdit = props.closeParentEdit,
54
+ restProps = _objectWithoutProperties(props, _excluded);
33
55
  //@ts-ignore
34
56
  var _useState = useState([]),
35
57
  _useState2 = _slicedToArray(_useState, 2),
36
58
  formData = _useState2[0],
37
59
  setFormData = _useState2[1]; //表单属性
38
60
  var isEdit = props.isEdit; //是否为编辑
39
- var _useState3 = useState(false),
61
+ var _useState3 = useState(dataSource || {}),
40
62
  _useState4 = _slicedToArray(_useState3, 2),
41
- isSetData = _useState4[0],
42
- setSetData = _useState4[1];
43
- var _useState5 = useState({}),
63
+ formWatchData = _useState4[0],
64
+ setWatchData = _useState4[1];
65
+ var _useState5 = useState([]),
44
66
  _useState6 = _slicedToArray(_useState5, 2),
45
- formWatchData = _useState6[0],
46
- setWatchData = _useState6[1];
47
- var _useState7 = useState(false),
48
- _useState8 = _slicedToArray(_useState7, 2),
49
- didNotify = _useState8[0],
50
- setDidNotify = _useState8[1]; // 新增标记
67
+ scripts = _useState6[0],
68
+ setScripts = _useState6[1];
51
69
 
52
70
  //监听场景标识变化
53
71
  useEffect(function () {
72
+ loadScripts();
54
73
  getFormDataLoad(); //查询显示列
55
74
  }, [props.dataSceneIid, props.formData]);
56
- var dataSource = props.dataSource,
57
- form = props.form,
58
- onSetDataAfter = props.onSetDataAfter,
59
- closeParentEdit = props.closeParentEdit,
60
- restProps = _objectWithoutProperties(props, _excluded);
61
75
  var hasSetFields = useRef(false); // 只用来标记,不触发重渲染
62
76
  var hasCallbackTriggered = useRef(false); // 只用来标记,不触发重渲染
63
77
  useEffect(function () {
@@ -141,7 +155,134 @@ var VenusForm = /*#__PURE__*/forwardRef(function (props, ref) {
141
155
  return _ref.apply(this, arguments);
142
156
  };
143
157
  }();
158
+ /**
159
+ * 加载表单脚本
160
+ */
161
+ var loadScripts = /*#__PURE__*/function () {
162
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
163
+ var res;
164
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
165
+ while (1) switch (_context2.prev = _context2.next) {
166
+ case 0:
167
+ _context2.prev = 0;
168
+ if (!props.scripts) {
169
+ _context2.next = 4;
170
+ break;
171
+ }
172
+ setScripts(props.scripts);
173
+ return _context2.abrupt("return");
174
+ case 4:
175
+ _context2.next = 6;
176
+ return getFormScripts({
177
+ dataViewId: props.dataViewIid || '-1',
178
+ dataSceneId: props.dataSceneIid || '-1'
179
+ });
180
+ case 6:
181
+ res = _context2.sent;
182
+ if (res !== null && res !== void 0 && res.success) {
183
+ setScripts(res.data || []);
184
+ }
185
+ _context2.next = 13;
186
+ break;
187
+ case 10:
188
+ _context2.prev = 10;
189
+ _context2.t0 = _context2["catch"](0);
190
+ console.log('加载脚本失败:', _context2.t0);
191
+ case 13:
192
+ case "end":
193
+ return _context2.stop();
194
+ }
195
+ }, _callee2, null, [[0, 10]]);
196
+ }));
197
+ return function loadScripts() {
198
+ return _ref2.apply(this, arguments);
199
+ };
200
+ }();
144
201
 
202
+ /**
203
+ * 构建脚本执行上下文
204
+ */
205
+ var buildScriptContext = useCallback(function (changedField, changedValue) {
206
+ // 收集所有字段
207
+ var allFields = [];
208
+ formData.forEach(function (group) {
209
+ if (group.attributeList) {
210
+ allFields.push.apply(allFields, _toConsumableArray(group.attributeList));
211
+ }
212
+ });
213
+ return {
214
+ form: props.form,
215
+ formData: props.form.getFieldsValue(true),
216
+ changedField: changedField,
217
+ changedValue: changedValue,
218
+ fields: allFields,
219
+ utils: createScriptUtils(props.form, formData, setFormData, _message)
220
+ };
221
+ }, [formData, props.form]);
222
+
223
+ /**
224
+ * 执行指定事件的脚本
225
+ */
226
+ var executeScripts = /*#__PURE__*/function () {
227
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(eventType, changedField, changedValue) {
228
+ var context, eventScripts, _iterator, _step, script, result;
229
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
230
+ while (1) switch (_context3.prev = _context3.next) {
231
+ case 0:
232
+ if (scripts.length) {
233
+ _context3.next = 2;
234
+ break;
235
+ }
236
+ return _context3.abrupt("return");
237
+ case 2:
238
+ context = buildScriptContext(changedField, changedValue);
239
+ eventScripts = scripts.filter(function (s) {
240
+ return s.eventType === eventType && s.enabled;
241
+ });
242
+ _iterator = _createForOfIteratorHelper(eventScripts.sort(function (a, b) {
243
+ return a.sortOrder - b.sortOrder;
244
+ }));
245
+ _context3.prev = 5;
246
+ _iterator.s();
247
+ case 7:
248
+ if ((_step = _iterator.n()).done) {
249
+ _context3.next = 15;
250
+ break;
251
+ }
252
+ script = _step.value;
253
+ _context3.next = 11;
254
+ return scriptEngine.execute(script.scriptContent, context, script.id);
255
+ case 11:
256
+ result = _context3.sent;
257
+ if (!result.success) {
258
+ _message.error("\u811A\u672C [".concat(script.scriptName, "] \u6267\u884C\u5931\u8D25: ").concat(result.error));
259
+ // 可以选择是否中断后续脚本
260
+ // break;
261
+ }
262
+ case 13:
263
+ _context3.next = 7;
264
+ break;
265
+ case 15:
266
+ _context3.next = 20;
267
+ break;
268
+ case 17:
269
+ _context3.prev = 17;
270
+ _context3.t0 = _context3["catch"](5);
271
+ _iterator.e(_context3.t0);
272
+ case 20:
273
+ _context3.prev = 20;
274
+ _iterator.f();
275
+ return _context3.finish(20);
276
+ case 23:
277
+ case "end":
278
+ return _context3.stop();
279
+ }
280
+ }, _callee3, null, [[5, 17, 20, 23]]);
281
+ }));
282
+ return function executeScripts(_x, _x2, _x3) {
283
+ return _ref3.apply(this, arguments);
284
+ };
285
+ }();
145
286
  /**
146
287
  * 新增或者编辑时的数据
147
288
  */
@@ -160,37 +301,37 @@ var VenusForm = /*#__PURE__*/forwardRef(function (props, ref) {
160
301
  * 根据场景标识查询表单对象
161
302
  */
162
303
  var getFormDataLoad = /*#__PURE__*/function () {
163
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
304
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
164
305
  var res;
165
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
166
- while (1) switch (_context2.prev = _context2.next) {
306
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
307
+ while (1) switch (_context4.prev = _context4.next) {
167
308
  case 0:
168
309
  if (!(props.formData !== undefined && props.formData !== null && props.formData.length > 0)) {
169
- _context2.next = 4;
310
+ _context4.next = 4;
170
311
  break;
171
312
  }
172
313
  setFormData(props.formData);
173
- _context2.next = 8;
314
+ _context4.next = 8;
174
315
  break;
175
316
  case 4:
176
- _context2.next = 6;
317
+ _context4.next = 6;
177
318
  return getFormData({
178
319
  dataViewId: props.dataViewIid || "-1",
179
320
  dataSceneId: props.dataSceneIid || "-1"
180
321
  });
181
322
  case 6:
182
- res = _context2.sent;
323
+ res = _context4.sent;
183
324
  if (res && res.success) {
184
325
  setFormData(res.data || []);
185
326
  }
186
327
  case 8:
187
328
  case "end":
188
- return _context2.stop();
329
+ return _context4.stop();
189
330
  }
190
- }, _callee2);
331
+ }, _callee4);
191
332
  }));
192
333
  return function getFormDataLoad() {
193
- return _ref2.apply(this, arguments);
334
+ return _ref4.apply(this, arguments);
194
335
  };
195
336
  }();
196
337
 
@@ -220,6 +361,18 @@ var VenusForm = /*#__PURE__*/forwardRef(function (props, ref) {
220
361
  props.onValuesChange(changedValues, allValues);
221
362
  }
222
363
  setWatchData(allValues);
364
+ // 获取变化的字段名 - 处理嵌套对象情况
365
+ var changedFields = Object.keys(changedValues);
366
+ if (changedFields.length === 0) return;
367
+
368
+ // 遍历所有变化的字段(可能有多个同时变化)
369
+ changedFields.forEach(function (changedField) {
370
+ var changedValue = changedValues[changedField];
371
+ console.log("[onValuesChange] \u5B57\u6BB5: ".concat(changedField, ", \u503C:"), changedValue, '类型:', _typeof(changedValue));
372
+
373
+ // 执行 onChange 脚本
374
+ executeScripts('onChange', changedField, changedValue);
375
+ });
223
376
  };
224
377
 
225
378
  /* ---------- 暴露给父组件的方法 ---------- */
@@ -307,6 +460,46 @@ var VenusForm = /*#__PURE__*/forwardRef(function (props, ref) {
307
460
  }
308
461
  };
309
462
  });
463
+
464
+ /**
465
+ * 表单提交处理(集成 onSubmit 脚本)
466
+ */
467
+ var handleFinish = /*#__PURE__*/function () {
468
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(formDataValue) {
469
+ var _props$onFinish;
470
+ var validateResults, hasError, dataForm;
471
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
472
+ while (1) switch (_context5.prev = _context5.next) {
473
+ case 0:
474
+ _context5.next = 2;
475
+ return executeScripts('onValidate');
476
+ case 2:
477
+ validateResults = _context5.sent;
478
+ //@ts-ignore
479
+ hasError = validateResults === null || validateResults === void 0 ? void 0 : validateResults.some(function (r) {
480
+ return !r.success;
481
+ });
482
+ if (!hasError) {
483
+ _context5.next = 6;
484
+ break;
485
+ }
486
+ return _context5.abrupt("return");
487
+ case 6:
488
+ _context5.next = 8;
489
+ return executeScripts('onSubmit');
490
+ case 8:
491
+ dataForm = addOrEditValue(formDataValue);
492
+ (_props$onFinish = props.onFinish) === null || _props$onFinish === void 0 || _props$onFinish.call(props, _objectSpread({}, dataForm));
493
+ case 10:
494
+ case "end":
495
+ return _context5.stop();
496
+ }
497
+ }, _callee5);
498
+ }));
499
+ return function handleFinish(_x4) {
500
+ return _ref5.apply(this, arguments);
501
+ };
502
+ }();
310
503
  return formData != null ? /*#__PURE__*/React.createElement(ProForm, _extends({
311
504
  onValuesChange: onValuesChange //表单数据变化时
312
505
  }, restProps, {
@@ -315,11 +508,7 @@ var VenusForm = /*#__PURE__*/forwardRef(function (props, ref) {
315
508
  /**
316
509
  * 表单提交事件
317
510
  */,
318
- onFinish: function onFinish(formDataValue) {
319
- var dataForm = addOrEditValue(formDataValue);
320
- //@ts-ignore
321
- props.onFinish(_objectSpread({}, dataForm));
322
- },
511
+ onFinish: handleFinish,
323
512
  submitter: false //关闭原本的提交和取消按钮(重新添加)
324
513
  ,
325
514
  size: props.size || "middle" //表单大小
@@ -348,7 +537,7 @@ var VenusForm = /*#__PURE__*/forwardRef(function (props, ref) {
348
537
  onClick: function onClick() {
349
538
  defaultHandleSave();
350
539
  }
351
- }, "\u4FDD\u5B58"), /*#__PURE__*/React.createElement(React.Fragment, null, !props.tjflag && /*#__PURE__*/React.createElement(_Button, {
540
+ }, "\u4FDD\u5B58"), /*#__PURE__*/React.createElement(React.Fragment, null, !props.submitflag && /*#__PURE__*/React.createElement(_Button, {
352
541
  type: "primary",
353
542
  key: "submit",
354
543
  size: "large",
@@ -357,7 +546,7 @@ var VenusForm = /*#__PURE__*/forwardRef(function (props, ref) {
357
546
  onClick: function onClick() {
358
547
  return props.form.submit();
359
548
  }
360
- }, !props.tjTitle ? '提交' : props.tjTitle)), /*#__PURE__*/React.createElement(_Button, {
549
+ }, !props.submitTitle ? '提交' : props.submitTitle)), /*#__PURE__*/React.createElement(_Button, {
361
550
  key: "onCancel",
362
551
  size: "large",
363
552
  className: "VenusForm_formFooterButton",
@@ -85,10 +85,12 @@ export interface VenusFormRadioType {
85
85
  name: string;
86
86
  }
87
87
  export interface VenusFormType {
88
- tjTitle?: any;
88
+ submitTitle?: any;
89
89
  formData?: any;
90
90
  initParams?: {};
91
- tjflag?: any;
91
+ submitflag?: any;
92
+ scripts?: any[];
93
+ scriptDebug?: boolean;
92
94
  form: any;
93
95
  rules?: any[];
94
96
  dataViewIid?: String;
@@ -30,6 +30,7 @@ export declare const VENUS_FORM_PLACHOLDER_TYPE: {
30
30
  Slider: string;
31
31
  segmented: string;
32
32
  money: string;
33
+ CustomComponent: string;
33
34
  };
34
35
  /**
35
36
  * 保存时表单项值的处理