@pisell/materials 3.3.67 → 3.3.69

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 (86) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +5 -5
  6. package/build/lowcode/preview.js +8 -8
  7. package/build/lowcode/render/default/view.js +16 -16
  8. package/build/lowcode/view.js +16 -16
  9. package/es/components/dataSourceComponents/dataSourceForm/BaseForm.js +68 -10
  10. package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +1 -0
  11. package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingProvider.js +5 -3
  12. package/es/components/dataSourceComponents/dataSourceForm/serve.d.ts +30 -0
  13. package/es/components/dataSourceComponents/dataSourceForm/serve.js +93 -0
  14. package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +66 -28
  15. package/es/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -0
  16. package/es/components/dataSourceComponents/dataSourceForm/urlUtils.d.ts +24 -0
  17. package/es/components/dataSourceComponents/dataSourceForm/urlUtils.js +76 -0
  18. package/es/components/dataSourceComponents/dataSourceForm/utils.js +3 -4
  19. package/es/components/dataSourceComponents/dataSourceTable/BaseTable.js +1 -0
  20. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  21. package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
  22. package/es/components/dataSourceComponents/fields/Switch/ReadPretty.d.ts +5 -0
  23. package/es/components/dataSourceComponents/fields/Switch/ReadPretty.js +16 -0
  24. package/es/components/dataSourceComponents/fields/Switch/ReadPretty.less +2 -0
  25. package/es/components/dataSourceComponents/fields/Switch/WithMode.d.ts +3 -0
  26. package/es/components/dataSourceComponents/fields/Switch/WithMode.js +5 -0
  27. package/es/components/dataSourceComponents/fields/Switch/index.d.ts +3 -0
  28. package/es/components/dataSourceComponents/fields/Switch/index.js +8 -0
  29. package/es/components/dataSourceComponents/fields/Switch/type.d.ts +16 -0
  30. package/es/components/dataSourceComponents/fields/Switch/type.js +1 -0
  31. package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
  32. package/es/components/dataSourceComponents/fields/index.d.ts +11 -11
  33. package/es/components/dataSourceComponents/hooks/useActions.js +20 -14
  34. package/es/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +1 -0
  35. package/es/components/productCard/components/Packages/utils.d.ts +1 -1
  36. package/es/components/table/Table/fields/index.d.ts +2 -2
  37. package/es/components/table/Table/index.js +7 -3
  38. package/es/components/table/Table/utils.d.ts +1 -1
  39. package/es/components/table/hooks/useTransColumns.d.ts +1 -1
  40. package/es/components/table/hooks/useTransColumns.js +1 -1
  41. package/es/components/table/index.js +3 -1
  42. package/es/index.d.ts +1 -0
  43. package/es/index.js +1 -0
  44. package/es/utils/platform.d.ts +1 -1
  45. package/lib/components/dataSourceComponents/dataSourceForm/BaseForm.js +37 -3
  46. package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +1 -0
  47. package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingProvider.js +5 -3
  48. package/lib/components/dataSourceComponents/dataSourceForm/serve.d.ts +30 -0
  49. package/lib/components/dataSourceComponents/dataSourceForm/serve.js +45 -2
  50. package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +23 -2
  51. package/lib/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -0
  52. package/lib/components/dataSourceComponents/dataSourceForm/urlUtils.d.ts +24 -0
  53. package/lib/components/dataSourceComponents/dataSourceForm/urlUtils.js +68 -0
  54. package/lib/components/dataSourceComponents/dataSourceForm/utils.js +3 -3
  55. package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +1 -0
  56. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  57. package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
  58. package/lib/components/dataSourceComponents/fields/Switch/ReadPretty.d.ts +5 -0
  59. package/lib/components/dataSourceComponents/fields/Switch/ReadPretty.js +52 -0
  60. package/lib/components/dataSourceComponents/fields/Switch/ReadPretty.less +2 -0
  61. package/lib/components/dataSourceComponents/fields/Switch/WithMode.d.ts +3 -0
  62. package/lib/components/dataSourceComponents/fields/Switch/WithMode.js +39 -0
  63. package/lib/components/dataSourceComponents/fields/Switch/index.d.ts +3 -0
  64. package/lib/components/dataSourceComponents/fields/Switch/index.js +42 -0
  65. package/lib/components/dataSourceComponents/fields/Switch/type.d.ts +16 -0
  66. package/lib/components/dataSourceComponents/fields/Switch/type.js +17 -0
  67. package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
  68. package/lib/components/dataSourceComponents/fields/index.d.ts +11 -11
  69. package/lib/components/dataSourceComponents/hooks/useActions.js +3 -0
  70. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +1 -0
  71. package/lib/components/productCard/components/Packages/utils.d.ts +1 -1
  72. package/lib/components/table/Table/fields/index.d.ts +2 -2
  73. package/lib/components/table/Table/index.js +8 -4
  74. package/lib/components/table/Table/utils.d.ts +1 -1
  75. package/lib/components/table/hooks/useTransColumns.d.ts +1 -1
  76. package/lib/components/table/hooks/useTransColumns.js +1 -1
  77. package/lib/components/table/index.js +3 -1
  78. package/lib/index.d.ts +1 -0
  79. package/lib/index.js +3 -0
  80. package/lib/utils/platform.d.ts +1 -1
  81. package/lowcode/data-source-form/constants.ts +3 -0
  82. package/lowcode/data-source-form/meta.ts +90 -31
  83. package/lowcode/data-source-form/utils.ts +132 -19
  84. package/lowcode/form-item-switch/meta.ts +145 -0
  85. package/lowcode/form-item-switch/snippets.ts +15 -0
  86. package/package.json +1 -1
@@ -1,9 +1,14 @@
1
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
- var _excluded = ["title", "description", "dataSource", "showTitle", "showDescription", "groupInfoPosition", "variables", "renderMode", "children", "currentValue", "className", "onDataSourceFinish", "formatSubmitValues", "formatInitialValues", "customSubmit", "leaveConfirmConfig"];
2
+ var _excluded = ["title", "description", "dataSource", "showTitle", "showDescription", "groupInfoPosition", "variables", "renderMode", "children", "currentValue", "className", "onDataSourceFinish", "formatSubmitValues", "formatInitialValues", "customSubmit", "beforeSubmit", "leaveConfirmConfig"];
3
3
  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); }
4
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
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
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 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
+ 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; }
9
+ 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; }
10
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
11
+ 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); }
7
12
  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; }
8
13
  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; }
9
14
  import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
@@ -17,6 +22,8 @@ import Form from "../../form";
17
22
  import FormSettingProvider from "./provider/formSetting/FormSettingProvider";
18
23
  import PageHeader from "../../page-header";
19
24
  import { transformFormObjToArrayWithUntouched } from "./utils";
25
+ import { getFormSettingMetaData } from "./serve";
26
+ import { getFormSettingParams } from "./urlUtils";
20
27
  import "./index.less";
21
28
  /**
22
29
  * @title: 数据源表单组件
@@ -39,6 +46,7 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
39
46
  formatSubmitValues = props.formatSubmitValues,
40
47
  formatInitialValues = props.formatInitialValues,
41
48
  customSubmit = props.customSubmit,
49
+ beforeSubmit = props.beforeSubmit,
42
50
  leaveConfirmConfig = props.leaveConfirmConfig,
43
51
  others = _objectWithoutProperties(props, _excluded);
44
52
  var context = useEngineContext();
@@ -64,22 +72,71 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
64
72
  });
65
73
  useEffect(function () {
66
74
  if (['edit', 'view'].includes(renderMode || '') && dataSource) {
75
+ if (dataSource !== null && dataSource !== void 0 && dataSource.fromSettingMeta) {
76
+ var _dataSource$fields;
77
+ if (props.__designMode === 'design') return;
78
+ // 从URL获取参数
79
+ var _getFormSettingParams = getFormSettingParams(),
80
+ businessCode = _getFormSettingParams.businessCode,
81
+ channelCode = _getFormSettingParams.channelCode,
82
+ isBoard = _getFormSettingParams.isBoard;
83
+ var sectionCodes = Array.from(new Set(dataSource === null || dataSource === void 0 || (_dataSource$fields = dataSource.fields) === null || _dataSource$fields === void 0 ? void 0 : _dataSource$fields.map(function (field) {
84
+ return field.name.split('.').shift();
85
+ })));
86
+
87
+ // 使用API方法获取formSettingMeta数据(必须传入参数)
88
+ getFormSettingMetaData({
89
+ sectionCodes: sectionCodes,
90
+ businessCode: businessCode,
91
+ channelCode: channelCode,
92
+ isBoard: isBoard
93
+ }).then(function (res) {
94
+ var _dataSource$fields2, _formRef$current2;
95
+ var formattedValues = formatInitialValues ? formatInitialValues(res.data) : res.data || {};
96
+
97
+ // 根据 dataSource.fields 筛选 formattedValues
98
+ var fieldNames = new Set((dataSource === null || dataSource === void 0 || (_dataSource$fields2 = dataSource.fields) === null || _dataSource$fields2 === void 0 ? void 0 : _dataSource$fields2.map(function (field) {
99
+ return field.name;
100
+ })) || []);
101
+ var filteredValues = Object.keys(formattedValues).reduce(function (acc, key) {
102
+ if (fieldNames.has(key)) {
103
+ acc[key] = formattedValues[key];
104
+ }
105
+ return acc;
106
+ }, {});
107
+ (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setFields(transformFormObjToArrayWithUntouched(_objectSpread({}, filteredValues)));
108
+ }).catch(function (error) {
109
+ console.error('获取formSettingMeta数据失败:', error);
110
+ });
111
+ return;
112
+ }
67
113
  get === null || get === void 0 || get.runAsync().then(function (res) {
68
- var _formRef$current2;
114
+ var _dataSource$fields3, _formRef$current3;
69
115
  var formattedValues = formatInitialValues ? formatInitialValues(res) : res;
70
- (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setFields(transformFormObjToArrayWithUntouched(formattedValues));
116
+
117
+ // 根据 dataSource.fields 筛选 formattedValues
118
+ var fieldNames = new Set((dataSource === null || dataSource === void 0 || (_dataSource$fields3 = dataSource.fields) === null || _dataSource$fields3 === void 0 ? void 0 : _dataSource$fields3.map(function (field) {
119
+ return field.name;
120
+ })) || []);
121
+ var filteredValues = Object.keys(formattedValues).reduce(function (acc, key) {
122
+ if (fieldNames.has(key)) {
123
+ acc[key] = formattedValues[key];
124
+ }
125
+ return acc;
126
+ }, {});
127
+ (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 || _formRef$current3.setFields(transformFormObjToArrayWithUntouched(filteredValues));
71
128
  });
72
129
  }
73
130
  }, [renderMode, dataSource]);
74
131
 
75
132
  // 检查表单是否可以关闭
76
133
  var checkFormClose = useMemoizedFn( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
77
- var _formRef$current3;
134
+ var _formRef$current4;
78
135
  var isFormChanged;
79
136
  return _regeneratorRuntime().wrap(function _callee$(_context) {
80
137
  while (1) switch (_context.prev = _context.next) {
81
138
  case 0:
82
- isFormChanged = (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.isFieldsTouched();
139
+ isFormChanged = (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : _formRef$current4.isFieldsTouched();
83
140
  if (!isFormChanged) {
84
141
  _context.next = 3;
85
142
  break;
@@ -91,8 +148,8 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
91
148
  okText: leaveConfirmConfig === null || leaveConfirmConfig === void 0 ? void 0 : leaveConfirmConfig.okText,
92
149
  cancelText: leaveConfirmConfig === null || leaveConfirmConfig === void 0 ? void 0 : leaveConfirmConfig.cancelText,
93
150
  onOk: function onOk() {
94
- var _formRef$current4;
95
- (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 || _formRef$current4.resetFields();
151
+ var _formRef$current5;
152
+ (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 || _formRef$current5.resetFields();
96
153
  resolve(true);
97
154
  },
98
155
  onCancel: function onCancel() {
@@ -118,8 +175,8 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
118
175
  var _getApp;
119
176
  var history = getApp === null || getApp === void 0 || (_getApp = getApp()) === null || _getApp === void 0 || (_getApp = _getApp.history) === null || _getApp === void 0 ? void 0 : _getApp.instance;
120
177
  var unblock = history === null || history === void 0 ? void 0 : history.block(function (location, action) {
121
- var _formRef$current5;
122
- var isFormChanged = (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : _formRef$current5.isFieldsTouched();
178
+ var _formRef$current6;
179
+ var isFormChanged = (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : _formRef$current6.isFieldsTouched();
123
180
  if (isFormChanged) {
124
181
  PisellModal.confirm({
125
182
  title: leaveConfirmConfig.title,
@@ -155,7 +212,8 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
155
212
  onDataSourceFinish: onDataSourceFinish,
156
213
  formatSubmitValues: formatSubmitValues,
157
214
  formatInitialValues: formatInitialValues,
158
- customSubmit: customSubmit
215
+ customSubmit: customSubmit,
216
+ beforeSubmit: beforeSubmit
159
217
  }, /*#__PURE__*/React.createElement(Form, _extends({}, others, {
160
218
  className: classNames('pisell-lowcode-data-source-form', className),
161
219
  ref: formRef,
@@ -10,6 +10,7 @@ export interface FormSettingContextType {
10
10
  formatSubmitValues?: (values: Record<string, any>) => Record<string, any>;
11
11
  formatInitialValues?: (values: Record<string, any>) => Record<string, any>;
12
12
  customSubmit?: (values: Record<string, any>) => Promise<any>;
13
+ beforeSubmit?: (values: Record<string, any>) => Promise<boolean> | boolean;
13
14
  }
14
15
  export declare const FormSettingContext: import("react").Context<FormSettingContextType>;
15
16
  export default FormSettingContext;
@@ -14,7 +14,8 @@ var FormSettingProvider = function FormSettingProvider(props) {
14
14
  onDataSourceFinish = props.onDataSourceFinish,
15
15
  formatSubmitValues = props.formatSubmitValues,
16
16
  formatInitialValues = props.formatInitialValues,
17
- customSubmit = props.customSubmit;
17
+ customSubmit = props.customSubmit,
18
+ beforeSubmit = props.beforeSubmit;
18
19
  var value = React.useMemo(function () {
19
20
  return {
20
21
  renderMode: renderMode,
@@ -24,9 +25,10 @@ var FormSettingProvider = function FormSettingProvider(props) {
24
25
  onDataSourceFinish: onDataSourceFinish,
25
26
  formatSubmitValues: formatSubmitValues,
26
27
  formatInitialValues: formatInitialValues,
27
- customSubmit: customSubmit
28
+ customSubmit: customSubmit,
29
+ beforeSubmit: beforeSubmit
28
30
  };
29
- }, [renderMode, groupInfoPosition, currentValue, size]);
31
+ }, [renderMode, groupInfoPosition, currentValue, size, beforeSubmit]);
30
32
  return /*#__PURE__*/React.createElement(FormSettingContext.Provider, {
31
33
  value: value
32
34
  }, children);
@@ -146,4 +146,34 @@ export declare const getNocobaseDataList: (allParams: {
146
146
  * 删除nocobase数据
147
147
  */
148
148
  export declare const deleteNocobaseData: (key: string, id: string, headers?: any) => Promise<any>;
149
+ /**
150
+ * 获取formSettingMeta数据
151
+ * @param params 请求参数
152
+ * @param params.sectionCodes 配置段代码数组,如 ['payment']
153
+ * @param params.businessCode 业务代码
154
+ * @param params.channelCode 渠道代码
155
+ * @param params.isBoard 是否包含board_code参数
156
+ * @returns Promise<any> 返回设置元数据
157
+ */
158
+ export declare const getFormSettingMetaData: (params: {
159
+ sectionCodes: string[];
160
+ businessCode?: string | undefined;
161
+ channelCode?: string | undefined;
162
+ isBoard?: boolean | undefined;
163
+ }) => Promise<any>;
164
+ /**
165
+ * 更新租户设置数据
166
+ * @param params 请求参数
167
+ * @param params.businessCode 业务代码
168
+ * @param params.channelCode 渠道代码
169
+ * @param params.boardCode 板块代码
170
+ * @param params.data 要更新的数据对象,如 {"order.prefix":"","order.suffix":"","payment.number":""}
171
+ * @returns Promise<any> 返回更新结果
172
+ */
173
+ export declare const updateTenantSetting: (params: {
174
+ business_code?: string | undefined;
175
+ channel_code?: string | undefined;
176
+ board_code?: string | undefined;
177
+ data: Record<string, any>;
178
+ }) => Promise<any>;
149
179
  export {};
@@ -267,4 +267,97 @@ export var deleteNocobaseData = /*#__PURE__*/function () {
267
267
  return function deleteNocobaseData(_x8, _x9, _x10) {
268
268
  return _ref12.apply(this, arguments);
269
269
  };
270
+ }();
271
+
272
+ /**
273
+ * 获取formSettingMeta数据
274
+ * @param params 请求参数
275
+ * @param params.sectionCodes 配置段代码数组,如 ['payment']
276
+ * @param params.businessCode 业务代码
277
+ * @param params.channelCode 渠道代码
278
+ * @param params.isBoard 是否包含board_code参数
279
+ * @returns Promise<any> 返回设置元数据
280
+ */
281
+ export var getFormSettingMetaData = /*#__PURE__*/function () {
282
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
283
+ var sectionCodes, businessCode, channelCode, isBoard, queryParams, url;
284
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
285
+ while (1) switch (_context10.prev = _context10.next) {
286
+ case 0:
287
+ console.log('getFormSettingMetaData', params);
288
+ sectionCodes = params.sectionCodes, businessCode = params.businessCode, channelCode = params.channelCode, isBoard = params.isBoard; // 构建查询参数
289
+ queryParams = new URLSearchParams(); // 添加section_code参数(支持多个值)
290
+ sectionCodes.forEach(function (code) {
291
+ queryParams.append('section_code[]', code);
292
+ });
293
+
294
+ // 添加business_code参数
295
+ if (businessCode) {
296
+ queryParams.append('business_code', businessCode);
297
+ }
298
+
299
+ // 添加channel_code参数
300
+ if (channelCode) {
301
+ queryParams.append('channel_code', channelCode);
302
+ }
303
+
304
+ // 当需要包含board_code时,格式为 business_code+channel_code
305
+ if (isBoard && businessCode && channelCode) {
306
+ queryParams.append('board_code', "".concat(businessCode, "+").concat(channelCode));
307
+ }
308
+ url = "/tenant/setting?".concat(queryParams.toString());
309
+ return _context10.abrupt("return", request.getRequest().get(url, {}, {
310
+ headers: {
311
+ 'Content-Type': 'application/json'
312
+ }
313
+ }));
314
+ case 9:
315
+ case "end":
316
+ return _context10.stop();
317
+ }
318
+ }, _callee10);
319
+ }));
320
+ return function getFormSettingMetaData(_x11) {
321
+ return _ref13.apply(this, arguments);
322
+ };
323
+ }();
324
+
325
+ /**
326
+ * 更新租户设置数据
327
+ * @param params 请求参数
328
+ * @param params.businessCode 业务代码
329
+ * @param params.channelCode 渠道代码
330
+ * @param params.boardCode 板块代码
331
+ * @param params.data 要更新的数据对象,如 {"order.prefix":"","order.suffix":"","payment.number":""}
332
+ * @returns Promise<any> 返回更新结果
333
+ */
334
+ export var updateTenantSetting = /*#__PURE__*/function () {
335
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
336
+ var business_code, channel_code, board_code, data, requestBody, url;
337
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
338
+ while (1) switch (_context11.prev = _context11.next) {
339
+ case 0:
340
+ console.log('updateTenantSetting', params);
341
+ business_code = params.business_code, channel_code = params.channel_code, board_code = params.board_code, data = params.data; // 构建请求体,按照 curl 请求的格式
342
+ requestBody = {
343
+ business_code: business_code,
344
+ channel_code: channel_code,
345
+ board_code: board_code,
346
+ data: data
347
+ };
348
+ url = '/tenant/setting';
349
+ return _context11.abrupt("return", request.getRequest().post(url, requestBody, {
350
+ headers: {
351
+ 'Content-Type': 'application/json'
352
+ }
353
+ }));
354
+ case 5:
355
+ case "end":
356
+ return _context11.stop();
357
+ }
358
+ }, _callee11);
359
+ }));
360
+ return function updateTenantSetting(_x12) {
361
+ return _ref14.apply(this, arguments);
362
+ };
270
363
  }();
@@ -17,7 +17,9 @@ import useFormSetting from "../provider/hooks/useFormSetting";
17
17
  import useCtxActions from "../../hooks/useCtxActions";
18
18
  import useDataSource from "../../hooks/useDataSource";
19
19
  import { filterSystemFields, setFormFieldsUntouched } from "../utils";
20
+ import { getFormSettingParams } from "../urlUtils";
20
21
  import "./index.less";
22
+ import { updateTenantSetting } from "../serve";
21
23
  // 表单提交按钮
22
24
  var SubmitButton = function SubmitButton(props) {
23
25
  var children = props.children,
@@ -43,59 +45,80 @@ var SubmitButton = function SubmitButton(props) {
43
45
  renderMode = _useFormSetting.renderMode,
44
46
  onDataSourceFinish = _useFormSetting.onDataSourceFinish,
45
47
  formatSubmitValues = _useFormSetting.formatSubmitValues,
46
- customSubmit = _useFormSetting.customSubmit;
48
+ customSubmit = _useFormSetting.customSubmit,
49
+ beforeSubmit = _useFormSetting.beforeSubmit;
47
50
  var _useCtxActions = useCtxActions(),
48
51
  setVisible = _useCtxActions.setVisible,
49
52
  refreshTableData = _useCtxActions.refreshTableData;
50
53
  var _useDataSource = useDataSource(),
51
54
  create = _useDataSource.create,
52
- update = _useDataSource.update;
55
+ update = _useDataSource.update,
56
+ dataSource = _useDataSource.dataSource;
53
57
  var isDisabled = status === 'disabled';
54
58
  var onSubmit = /*#__PURE__*/function () {
55
59
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values) {
56
- var res;
60
+ var urlParams, business_code, channel_code, board_code, res;
57
61
  return _regeneratorRuntime().wrap(function _callee$(_context) {
58
62
  while (1) switch (_context.prev = _context.next) {
59
63
  case 0:
60
64
  setLoading(true);
61
65
  _context.prev = 1;
66
+ if (!(dataSource !== null && dataSource !== void 0 && dataSource.fromSettingMeta)) {
67
+ _context.next = 10;
68
+ break;
69
+ }
70
+ // 从URL查询字符串获取参数
71
+ urlParams = getFormSettingParams();
72
+ business_code = urlParams.businessCode;
73
+ channel_code = urlParams.channelCode; // 只有当isBoard参数为1时才设置boardCode
74
+ board_code = urlParams.isBoard && business_code && channel_code ? "".concat(business_code, "+").concat(channel_code) : undefined;
75
+ _context.next = 9;
76
+ return updateTenantSetting({
77
+ business_code: business_code,
78
+ channel_code: channel_code,
79
+ board_code: board_code,
80
+ data: values
81
+ });
82
+ case 9:
83
+ return _context.abrupt("return", _context.sent);
84
+ case 10:
62
85
  if (!customSubmit) {
63
- _context.next = 6;
86
+ _context.next = 14;
64
87
  break;
65
88
  }
66
- _context.next = 5;
89
+ _context.next = 13;
67
90
  return customSubmit(values);
68
- case 5:
91
+ case 13:
69
92
  return _context.abrupt("return", _context.sent);
70
- case 6:
93
+ case 14:
71
94
  if (!(renderMode === 'edit')) {
72
- _context.next = 12;
95
+ _context.next = 20;
73
96
  break;
74
97
  }
75
- _context.next = 9;
98
+ _context.next = 17;
76
99
  return update.runAsync(values);
77
- case 9:
100
+ case 17:
78
101
  return _context.abrupt("return", _context.sent);
79
- case 12:
102
+ case 20:
80
103
  if (!(renderMode === 'add')) {
81
- _context.next = 18;
104
+ _context.next = 26;
82
105
  break;
83
106
  }
84
- _context.next = 15;
107
+ _context.next = 23;
85
108
  return create.runAsync(values);
86
- case 15:
109
+ case 23:
87
110
  res = _context.sent;
88
111
  form === null || form === void 0 || form.resetFields();
89
112
  return _context.abrupt("return", res);
90
- case 18:
91
- _context.prev = 18;
113
+ case 26:
114
+ _context.prev = 26;
92
115
  setLoading(false);
93
- return _context.finish(18);
94
- case 21:
116
+ return _context.finish(26);
117
+ case 29:
95
118
  case "end":
96
119
  return _context.stop();
97
120
  }
98
- }, _callee, null, [[1,, 18, 21]]);
121
+ }, _callee, null, [[1,, 26, 29]]);
99
122
  }));
100
123
  return function onSubmit(_x) {
101
124
  return _ref.apply(this, arguments);
@@ -130,7 +153,7 @@ var SubmitButton = function SubmitButton(props) {
130
153
  // 验证表单并提交
131
154
  var handleValideFieldsSubmit = /*#__PURE__*/function () {
132
155
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(values) {
133
- var allValues, filteredValues, formattedValues, result, afterSubmitFunc;
156
+ var allValues, filteredValues, formattedValues, canSubmit, result, afterSubmitFunc;
134
157
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
135
158
  while (1) switch (_context2.prev = _context2.next) {
136
159
  case 0:
@@ -149,10 +172,24 @@ var SubmitButton = function SubmitButton(props) {
149
172
  });
150
173
  }
151
174
  filteredValues = filterSystemFields(allValues); // 格式化提交数据
152
- formattedValues = formatSubmitValues ? formatSubmitValues(filteredValues) : filteredValues;
153
- _context2.next = 10;
175
+ formattedValues = formatSubmitValues ? formatSubmitValues(filteredValues) : filteredValues; // 提交前校验
176
+ if (!beforeSubmit) {
177
+ _context2.next = 14;
178
+ break;
179
+ }
180
+ _context2.next = 11;
181
+ return beforeSubmit(formattedValues);
182
+ case 11:
183
+ canSubmit = _context2.sent;
184
+ if (canSubmit) {
185
+ _context2.next = 14;
186
+ break;
187
+ }
188
+ return _context2.abrupt("return");
189
+ case 14:
190
+ _context2.next = 16;
154
191
  return onSubmit(formattedValues);
155
- case 10:
192
+ case 16:
156
193
  result = _context2.sent;
157
194
  // 数据源提交成功
158
195
  if (onDataSourceFinish) {
@@ -173,19 +210,20 @@ var SubmitButton = function SubmitButton(props) {
173
210
  }
174
211
  }
175
212
  setFormFieldsUntouched(form);
176
- _context2.next = 21;
213
+ _context2.next = 28;
177
214
  break;
178
- case 18:
179
- _context2.prev = 18;
215
+ case 24:
216
+ _context2.prev = 24;
180
217
  _context2.t0 = _context2["catch"](0);
218
+ debugger;
181
219
  PisellToast({
182
220
  content: "".concat(_context2.t0.message)
183
221
  });
184
- case 21:
222
+ case 28:
185
223
  case "end":
186
224
  return _context2.stop();
187
225
  }
188
- }, _callee2, null, [[0, 18]]);
226
+ }, _callee2, null, [[0, 24]]);
189
227
  }));
190
228
  return function handleValideFieldsSubmit(_x2) {
191
229
  return _ref2.apply(this, arguments);
@@ -20,6 +20,7 @@ export interface DataSourceFormProps {
20
20
  formatSubmitValues?: (values: Record<string, any>) => Record<string, any>;
21
21
  formatInitialValues?: (values: Record<string, any>) => Record<string, any>;
22
22
  customSubmit?: (values: Record<string, any>) => Promise<any>;
23
+ beforeSubmit?: (values: Record<string, any>) => Promise<boolean> | boolean;
23
24
  leaveConfirmConfig?: {
24
25
  enable: boolean;
25
26
  title: string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * URL参数处理工具方法
3
+ */
4
+ /**
5
+ * 从浏览器URL获取查询参数
6
+ * @returns Record<string, string> URL查询参数对象
7
+ */
8
+ export declare const getUrlParams: () => Record<string, string>;
9
+ /**
10
+ * 从URL参数中提取formSettingMeta相关的参数
11
+ * @param urlParams URL查询参数对象,如果不传则自动从浏览器获取
12
+ * @returns 包含business_code、channel_code和isBoard参数的对象
13
+ */
14
+ export declare const getFormSettingParams: (urlParams?: Record<string, string>) => {
15
+ businessCode: string;
16
+ channelCode: string;
17
+ isBoard: boolean;
18
+ };
19
+ /**
20
+ * 根据URL参数更新租户设置数据
21
+ * @param data 要更新的数据对象,如 {"order.prefix":"","order.suffix":"","payment.number":""}
22
+ * @returns Promise<any> 返回更新结果
23
+ */
24
+ export declare const updateTenantSettingFromUrl: (data: Record<string, any>) => Promise<any>;
@@ -0,0 +1,76 @@
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
+ 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; }
3
+ 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); } }
4
+ 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); }); }; }
5
+ /**
6
+ * URL参数处理工具方法
7
+ */
8
+
9
+ import { request } from "../../table/utils";
10
+
11
+ /**
12
+ * 从浏览器URL获取查询参数
13
+ * @returns Record<string, string> URL查询参数对象
14
+ */
15
+ export var getUrlParams = function getUrlParams() {
16
+ var urlSearchParams = new URLSearchParams(window.location.search);
17
+ var urlParams = {};
18
+ urlSearchParams.forEach(function (value, key) {
19
+ urlParams[key] = value;
20
+ });
21
+ return urlParams;
22
+ };
23
+
24
+ /**
25
+ * 从URL参数中提取formSettingMeta相关的参数
26
+ * @param urlParams URL查询参数对象,如果不传则自动从浏览器获取
27
+ * @returns 包含business_code、channel_code和isBoard参数的对象
28
+ */
29
+ export var getFormSettingParams = function getFormSettingParams(urlParams) {
30
+ var params = urlParams || getUrlParams();
31
+ return {
32
+ businessCode: params.businessCode || params.business_code,
33
+ channelCode: params.channelCode || params.channel_code,
34
+ isBoard: params.is_board === '1'
35
+ };
36
+ };
37
+
38
+ /**
39
+ * 根据URL参数更新租户设置数据
40
+ * @param data 要更新的数据对象,如 {"order.prefix":"","order.suffix":"","payment.number":""}
41
+ * @returns Promise<any> 返回更新结果
42
+ */
43
+ export var updateTenantSettingFromUrl = /*#__PURE__*/function () {
44
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
45
+ var urlParams, businessCode, channelCode, boardCode, requestBody, url;
46
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
47
+ while (1) switch (_context.prev = _context.next) {
48
+ case 0:
49
+ // 从URL获取参数
50
+ debugger;
51
+ urlParams = getFormSettingParams();
52
+ businessCode = urlParams.businessCode;
53
+ channelCode = urlParams.channelCode;
54
+ boardCode = urlParams.isBoard && businessCode && channelCode ? "".concat(businessCode, "+").concat(channelCode) : undefined; // 构建请求体,按照 curl 请求的格式
55
+ requestBody = {
56
+ business_code: businessCode || '',
57
+ channel_code: channelCode || '',
58
+ board_code: boardCode || '',
59
+ data: data
60
+ };
61
+ url = '/tenant/setting';
62
+ return _context.abrupt("return", request.getRequest().post(url, requestBody, {
63
+ headers: {
64
+ 'Content-Type': 'application/json'
65
+ }
66
+ }));
67
+ case 8:
68
+ case "end":
69
+ return _context.stop();
70
+ }
71
+ }, _callee);
72
+ }));
73
+ return function updateTenantSettingFromUrl(_x) {
74
+ return _ref.apply(this, arguments);
75
+ };
76
+ }();