@teamias/rex-design 0.1.2 → 0.1.3

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.
@@ -38,7 +38,7 @@ export var Core = function Core(props) {
38
38
  dependenciesSearchCacheData = _useRef2.current;
39
39
  return /*#__PURE__*/_jsxs(_Fragment, {
40
40
  children: [/*#__PURE__*/_jsx(BaseFormStyle, {}), outFields === null || outFields === void 0 ? void 0 : outFields.map(function (item, index) {
41
- var _item$field;
41
+ var _item$field, _config$item$initialV, _config$item$params;
42
42
  var fields = Array.isArray(item.field) ? item.field : [(_item$field = item.field) !== null && _item$field !== void 0 ? _item$field : "custom-dynamic-".concat(index)];
43
43
  var keyStr = fields.join('-');
44
44
  var itemProps = outFieldProps === null || outFieldProps === void 0 ? void 0 : outFieldProps[fields.join('-')];
@@ -86,6 +86,12 @@ export var Core = function Core(props) {
86
86
  rawAllProps: rawAllProps,
87
87
  formatMessage: formatMessage
88
88
  });
89
+
90
+ // 统一字段
91
+ config.item.initialValue = (_config$item$initialV = config.item.initialValue) !== null && _config$item$initialV !== void 0 ? _config$item$initialV : config.item.defaultValue;
92
+ delete config.item.defaultValue;
93
+ config.item.params = (_config$item$params = config.item.params) !== null && _config$item$params !== void 0 ? _config$item$params : config.item.defaultParams;
94
+ delete config.item.defaultParams;
89
95
  if (mergeItem.hidden) return;
90
96
  if (operationPermission && !operationPermission(mergeItem.permissionKey)) return;
91
97
 
@@ -21,7 +21,7 @@ export default (function () {
21
21
  subItems: [{
22
22
  valueType: 'select',
23
23
  field: 'avg_cost',
24
- defaultValue: 'avg_cost',
24
+ initialValue: 'avg_cost',
25
25
  // "itemWidth": "150px",
26
26
  fieldProps: {
27
27
  allowClear: false,
@@ -48,7 +48,7 @@ export default (function () {
48
48
  field: 'multipleComponents-input',
49
49
  labelWidth: '100px',
50
50
  // itemWidth: '20%',
51
- defaultValue: '2025-05-05',
51
+ initialValue: '2025-05-05',
52
52
  formItemProps: {
53
53
  style: {
54
54
  background: '#000',
@@ -63,7 +63,7 @@ export default (function () {
63
63
  valueType: 'treeSelect',
64
64
  field: 'multipleComponents-treeSelect',
65
65
  // itemWidth: '80%',
66
- defaultValue: 'light',
66
+ initialValue: 'light',
67
67
  options: [{
68
68
  label: 'Light',
69
69
  value: 'light'
@@ -74,7 +74,7 @@ export default (function () {
74
74
  }, {
75
75
  valueType: 'datePicker',
76
76
  field: 'multipleComponents-datePicker',
77
- defaultValue: '2025-05-05'
77
+ initialValue: '2025-05-05'
78
78
  }, {
79
79
  valueType: 'treeSelect',
80
80
  field: 'multipleComponents-treeSelect2',
@@ -92,12 +92,12 @@ export default (function () {
92
92
  // {
93
93
  // valueType: 'inputNumberRangeV2',
94
94
  // field: ['multipleComponents-min', 'multipleComponents-max'],
95
- // defaultValue: [2, 5],
95
+ // initialValue: [2, 5],
96
96
  // },
97
97
  // {
98
98
  // valueType: 'select',
99
99
  // field: 'multipleComponents-select',
100
- // defaultValue: 'light',
100
+ // initialValue: 'light',
101
101
  // options: [
102
102
  // {label: 'Light', value: 'light'},
103
103
  // {label: 'Light2', value: 'light2'},
@@ -112,13 +112,13 @@ export default (function () {
112
112
  valueType: 'input',
113
113
  field: 'input',
114
114
  label: 'input',
115
- defaultValue: 'input',
115
+ initialValue: 'input',
116
116
  hidden: false
117
117
  }, {
118
118
  valueType: 'select',
119
119
  field: 'select',
120
120
  label: 'select',
121
- defaultValue: 'light',
121
+ initialValue: 'light',
122
122
  options: [{
123
123
  label: 'Light',
124
124
  value: 'light'
@@ -131,7 +131,7 @@ export default (function () {
131
131
  field: 'selectDim',
132
132
  label: 'selectDim',
133
133
  api: '/selectData',
134
- defaultParams: {
134
+ params: {
135
135
  a: 1,
136
136
  b: 2
137
137
  }
@@ -139,7 +139,7 @@ export default (function () {
139
139
  valueType: 'dateRangeV2',
140
140
  field: ['dateRangeV2-start', 'dateRangeV2-end'],
141
141
  label: 'dateRangeV2',
142
- defaultValue: -29,
142
+ initialValue: -29,
143
143
  required: true,
144
144
  fieldProps: {
145
145
  showTime: true,
@@ -174,7 +174,7 @@ export default (function () {
174
174
  valueType: 'checkbox',
175
175
  field: 'checkbox',
176
176
  label: 'checkbox',
177
- defaultValue: true
177
+ initialValue: true
178
178
  }, {
179
179
  valueType: 'checkboxGroup',
180
180
  field: 'checkboxGroup',
@@ -190,7 +190,7 @@ export default (function () {
190
190
  valueType: 'radioGroup',
191
191
  field: 'radioGroup',
192
192
  label: 'radioGroup',
193
- defaultValue: 'light',
193
+ initialValue: 'light',
194
194
  options: [{
195
195
  label: 'Light',
196
196
  value: 'light'
@@ -202,17 +202,17 @@ export default (function () {
202
202
  valueType: 'inputNumber',
203
203
  field: 'inputNumber',
204
204
  label: 'inputNumber',
205
- defaultValue: 2
205
+ initialValue: 2
206
206
  }, {
207
207
  valueType: 'inputNumberRangeV2',
208
208
  field: ['inputNumberRangeV2-min', 'inputNumberRangeV2-max'],
209
209
  label: 'inputNumberRangeV2',
210
- defaultValue: [2, 5]
210
+ initialValue: [2, 5]
211
211
  }, {
212
212
  valueType: 'textArea',
213
213
  field: 'textArea',
214
214
  label: 'textArea',
215
- defaultValue: 'qweqwe'
215
+ initialValue: 'qweqwe'
216
216
  }, {
217
217
  valueType: 'switch',
218
218
  field: 'switch',
@@ -221,7 +221,7 @@ export default (function () {
221
221
  valueType: 'datePicker',
222
222
  field: 'datePicker',
223
223
  label: 'datePicker',
224
- defaultValue: '2025-05-05'
224
+ initialValue: '2025-05-05'
225
225
  }];
226
226
  var initialValues = getFieldsDefaultValues(fields);
227
227
  // console.log(initialValues);
@@ -70,7 +70,7 @@ export default (function () {
70
70
  field: 'selectDim',
71
71
  label: 'selectDim',
72
72
  api: '/selectData',
73
- defaultValue: '2'
73
+ initialValue: '2'
74
74
  // 1 2 3 4
75
75
  }, {
76
76
  valueType: 'select',
@@ -98,7 +98,7 @@ export default (function () {
98
98
  valueType: 'dateRangeV2',
99
99
  field: ['start', 'end'],
100
100
  required: true
101
- // defaultValue: 1,
101
+ // initialValue: 1,
102
102
  }];
103
103
  var initialValues = dataToInitialValues({
104
104
  'select-false': '选项1',
@@ -30,7 +30,7 @@ export default (function () {
30
30
  subItems: [{
31
31
  valueType: 'select',
32
32
  field: 'avg_cost',
33
- defaultValue: 'avg_cost',
33
+ initialValue: 'avg_cost',
34
34
  itemWidth: '150px',
35
35
  fieldProps: {
36
36
  allowClear: false,
@@ -59,7 +59,7 @@ export default (function () {
59
59
  field: 'multipleComponents-input',
60
60
  labelWidth: '100px',
61
61
  // itemWidth: '20%',
62
- defaultValue: '2025-05-05',
62
+ initialValue: '2025-05-05',
63
63
  fieldProps: {
64
64
  prefix: /*#__PURE__*/_jsx(UserOutlined, {}),
65
65
  disabled: true
@@ -68,7 +68,7 @@ export default (function () {
68
68
  valueType: 'treeSelect',
69
69
  field: 'multipleComponents-treeSelect',
70
70
  // itemWidth: '80%',
71
- defaultValue: 'light',
71
+ initialValue: 'light',
72
72
  options: [{
73
73
  label: 'Light',
74
74
  value: 'light'
@@ -79,7 +79,7 @@ export default (function () {
79
79
  }, {
80
80
  valueType: 'datePicker',
81
81
  field: 'multipleComponents-datePicker',
82
- defaultValue: '2025-05-05',
82
+ initialValue: '2025-05-05',
83
83
  dependenciesV2: [{
84
84
  action: 'clear',
85
85
  field: 'multipleComponents-treeSelect'
@@ -101,12 +101,12 @@ export default (function () {
101
101
  // {
102
102
  // valueType: 'inputNumberRangeV2',
103
103
  // field: ['multipleComponents-min', 'multipleComponents-max'],
104
- // defaultValue: [2, 5],
104
+ // initialValue: [2, 5],
105
105
  // },
106
106
  // {
107
107
  // valueType: 'select',
108
108
  // field: 'multipleComponents-select',
109
- // defaultValue: 'light',
109
+ // initialValue: 'light',
110
110
  // options: [
111
111
  // {label: 'Light', value: 'light'},
112
112
  // {label: 'Light2', value: 'light2'},
@@ -122,7 +122,7 @@ export default (function () {
122
122
  valueType: 'input',
123
123
  field: 'input',
124
124
  label: 'input',
125
- defaultValue: 'input',
125
+ initialValue: 'input',
126
126
  hidden: false,
127
127
  rules: [{
128
128
  required: true,
@@ -132,7 +132,7 @@ export default (function () {
132
132
  valueType: 'select',
133
133
  field: 'select',
134
134
  label: 'select',
135
- defaultValue: 'light',
135
+ initialValue: 'light',
136
136
  options: [{
137
137
  label: 'Light',
138
138
  value: 'light'
@@ -145,7 +145,7 @@ export default (function () {
145
145
  field: 'selectDim',
146
146
  label: 'selectDim',
147
147
  api: '/selectData',
148
- defaultParams: {
148
+ params: {
149
149
  a: 1,
150
150
  b: 2
151
151
  }
@@ -153,7 +153,7 @@ export default (function () {
153
153
  valueType: 'dateRangeV2',
154
154
  field: ['dateRangeV2-start', 'dateRangeV2-end'],
155
155
  label: 'dateRangeV2',
156
- defaultValue: -29,
156
+ initialValue: -29,
157
157
  required: true,
158
158
  fieldProps: {
159
159
  showTime: true,
@@ -199,7 +199,7 @@ export default (function () {
199
199
  valueType: 'radioGroup',
200
200
  field: 'radioGroup',
201
201
  label: 'radioGroup',
202
- defaultValue: 'light',
202
+ initialValue: 'light',
203
203
  options: [{
204
204
  label: 'Light',
205
205
  value: 'light'
@@ -211,17 +211,17 @@ export default (function () {
211
211
  valueType: 'inputNumber',
212
212
  field: 'inputNumber',
213
213
  label: 'inputNumber',
214
- defaultValue: 2
214
+ initialValue: 2
215
215
  }, {
216
216
  valueType: 'inputNumberRangeV2',
217
217
  field: ['inputNumberRangeV2-min', 'inputNumberRangeV2-max'],
218
218
  label: 'inputNumberRangeV2',
219
- defaultValue: [2, 5]
219
+ initialValue: [2, 5]
220
220
  }, {
221
221
  valueType: 'textArea',
222
222
  field: 'textArea',
223
223
  label: 'textArea',
224
- defaultValue: 'qweqwe'
224
+ initialValue: 'qweqwe'
225
225
  }, {
226
226
  valueType: 'switch',
227
227
  field: 'switch',
@@ -230,7 +230,7 @@ export default (function () {
230
230
  valueType: 'datePicker',
231
231
  field: 'datePicker',
232
232
  label: 'datePicker',
233
- defaultValue: '2025-05-05',
233
+ initialValue: '2025-05-05',
234
234
  dependenciesV2: [{
235
235
  field: 'switch',
236
236
  action: 'show',
@@ -241,7 +241,7 @@ export default (function () {
241
241
  valueType: 'datePicker',
242
242
  field: 'datePicker2',
243
243
  label: 'datePicker2',
244
- defaultValue: '2025-05-05'
244
+ initialValue: '2025-05-05'
245
245
  // dependenciesV2: [
246
246
  // {
247
247
  // field: 'switch',
@@ -0,0 +1,2 @@
1
+ declare const _default: () => import("react/jsx-runtime").JSX.Element;
2
+ export default _default;
@@ -0,0 +1,253 @@
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
+ import { RexProConfigProvider } from "../../../context";
6
+ import { ProForm } from '@ant-design/pro-components';
7
+ import { BaseForm } from "../../..";
8
+ import { createIntl } from 'react-intl';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ var options = [{
11
+ label: '总裁办公室',
12
+ value: 'dept_001'
13
+ }, {
14
+ label: '人力资源部',
15
+ value: 'dept_002'
16
+ }, {
17
+ label: '财务部',
18
+ value: 'dept_003'
19
+ }, {
20
+ label: '市场营销部',
21
+ value: 'dept_004'
22
+ }, {
23
+ label: '销售一部',
24
+ value: 'dept_005'
25
+ }, {
26
+ label: '销售二部',
27
+ value: 'dept_006'
28
+ }, {
29
+ label: '销售三部',
30
+ value: 'dept_007'
31
+ }, {
32
+ label: '客户服务部',
33
+ value: 'dept_008'
34
+ }, {
35
+ label: '技术研发部',
36
+ value: 'dept_009'
37
+ }, {
38
+ label: '产品设计部',
39
+ value: 'dept_010'
40
+ }, {
41
+ label: '前端开发组',
42
+ value: 'dept_011'
43
+ }, {
44
+ label: '后端开发组',
45
+ value: 'dept_012'
46
+ }, {
47
+ label: '移动开发组',
48
+ value: 'dept_013'
49
+ }, {
50
+ label: '测试部',
51
+ value: 'dept_014'
52
+ }, {
53
+ label: '运维部',
54
+ value: 'dept_015'
55
+ }, {
56
+ label: '数据分析部',
57
+ value: 'dept_016'
58
+ }, {
59
+ label: '信息安全部',
60
+ value: 'dept_017'
61
+ }, {
62
+ label: '项目管理部',
63
+ value: 'dept_018'
64
+ }, {
65
+ label: '质量管理部',
66
+ value: 'dept_019'
67
+ }, {
68
+ label: '采购部',
69
+ value: 'dept_020'
70
+ }, {
71
+ label: '供应链管理部',
72
+ value: 'dept_021'
73
+ }, {
74
+ label: '仓储物流部',
75
+ value: 'dept_022'
76
+ }, {
77
+ label: '生产制造部',
78
+ value: 'dept_023'
79
+ }, {
80
+ label: '设备管理部',
81
+ value: 'dept_024'
82
+ }, {
83
+ label: '品牌策划部',
84
+ value: 'dept_025'
85
+ }, {
86
+ label: '公共关系部',
87
+ value: 'dept_026'
88
+ }, {
89
+ label: '法务部',
90
+ value: 'dept_027'
91
+ }, {
92
+ label: '审计部',
93
+ value: 'dept_028'
94
+ }, {
95
+ label: '行政部',
96
+ value: 'dept_029'
97
+ }, {
98
+ label: '后勤保障部',
99
+ value: 'dept_030'
100
+ }, {
101
+ label: '国际业务部',
102
+ value: 'dept_031'
103
+ }, {
104
+ label: '华东区分公司',
105
+ value: 'dept_032'
106
+ }, {
107
+ label: '华南区分公司',
108
+ value: 'dept_033'
109
+ }, {
110
+ label: '华北区分公司',
111
+ value: 'dept_034'
112
+ }, {
113
+ label: '西南区分公司',
114
+ value: 'dept_035'
115
+ }, {
116
+ label: '东北区分公司',
117
+ value: 'dept_036'
118
+ }, {
119
+ label: '战略发展部',
120
+ value: 'dept_037'
121
+ }, {
122
+ label: '投资并购部',
123
+ value: 'dept_038'
124
+ }, {
125
+ label: '企业文化部',
126
+ value: 'dept_039'
127
+ }, {
128
+ label: '培训发展部',
129
+ value: 'dept_040'
130
+ }, {
131
+ label: '招聘管理部',
132
+ value: 'dept_041'
133
+ }, {
134
+ label: '薪酬绩效部',
135
+ value: 'dept_042'
136
+ }, {
137
+ label: '员工关系部',
138
+ value: 'dept_043'
139
+ }, {
140
+ label: '电商运营部',
141
+ value: 'dept_044'
142
+ }, {
143
+ label: '新媒体运营部',
144
+ value: 'dept_045'
145
+ }, {
146
+ label: '用户增长部',
147
+ value: 'dept_046'
148
+ }, {
149
+ label: '商务拓展部',
150
+ value: 'dept_047'
151
+ }, {
152
+ label: '渠道管理部',
153
+ value: 'dept_048'
154
+ }, {
155
+ label: '售后服务部',
156
+ value: 'dept_049'
157
+ }, {
158
+ label: '技术支持部',
159
+ value: 'dept_050'
160
+ }];
161
+ export default (function () {
162
+ return /*#__PURE__*/_jsx(RexProConfigProvider, {
163
+ value: {
164
+ intl: createIntl({
165
+ locale: 'en-US',
166
+ messages: {},
167
+ onError: function onError() {}
168
+ }),
169
+ apiClient: function () {
170
+ var _apiClient = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, params) {
171
+ var _ref, keyWords, customKey, id, searchValue;
172
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
173
+ while (1) switch (_context.prev = _context.next) {
174
+ case 0:
175
+ _ref = params, keyWords = _ref.keyWords, customKey = _ref.customKey, id = _ref.id;
176
+ searchValue = keyWords !== null && keyWords !== void 0 ? keyWords : customKey;
177
+ fetch(api, {
178
+ method: 'post',
179
+ body: JSON.stringify(params)
180
+ });
181
+ if (!searchValue) {
182
+ _context.next = 5;
183
+ break;
184
+ }
185
+ return _context.abrupt("return", options.filter(function (ii) {
186
+ return ii.label.includes(searchValue) || ii.value.includes(searchValue);
187
+ }));
188
+ case 5:
189
+ if (!id) {
190
+ _context.next = 7;
191
+ break;
192
+ }
193
+ return _context.abrupt("return", options.filter(function (ii) {
194
+ return ii.value === id;
195
+ }));
196
+ case 7:
197
+ return _context.abrupt("return", options.slice(0, 10));
198
+ case 8:
199
+ case "end":
200
+ return _context.stop();
201
+ }
202
+ }, _callee);
203
+ }));
204
+ function apiClient(_x, _x2) {
205
+ return _apiClient.apply(this, arguments);
206
+ }
207
+ return apiClient;
208
+ }()
209
+ },
210
+ children: /*#__PURE__*/_jsx(ProForm
211
+ // initialValues={{}}
212
+ , {
213
+ layout: "horizontal",
214
+ onFinish: function onFinish(values) {
215
+ console.log(values);
216
+ },
217
+ children: /*#__PURE__*/_jsx(BaseForm, {
218
+ fields: [{
219
+ valueType: 'selectDim',
220
+ field: 'selectDim1',
221
+ label: '[模式 0]使用 selectDim1, keyWords 作为搜索条件key',
222
+ api: '/options-1'
223
+ // apiSearchKey: '',
224
+ // apiSearchValueKey: '',
225
+ }, {
226
+ valueType: 'selectDim',
227
+ field: 'selectDim2-1',
228
+ label: '[模式 1(apiSearchKey)]只使用 keyWords 作为搜索条件key',
229
+ api: '/options-2-1',
230
+ apiSearchKey: false
231
+ // apiSearchValueKey: '',
232
+ }, {
233
+ valueType: 'selectDim',
234
+ field: 'selectDim2-2',
235
+ label: '[模式 2(apiSearchKey)]使用 customKey, keyWords 作为搜索条件key',
236
+ api: '/options-2-2',
237
+ apiSearchKey: 'customKey'
238
+ // apiSearchValueKey: '',
239
+ }, {
240
+ valueType: 'selectDim',
241
+ field: 'selectDim3',
242
+ label: '用于数据回显, 使用 id 作为搜索条件key',
243
+ api: '/options-3',
244
+ params: {
245
+ otherData: '1231'
246
+ },
247
+ apiSearchValueKey: 'id',
248
+ initialValue: 'dept_044'
249
+ }]
250
+ })
251
+ })
252
+ });
253
+ });
@@ -1,5 +1,5 @@
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 = ["valueType", "label", "defaultValue", "childWidths", "fieldProps", "formItemProps", "params", "defaultParams"],
2
+ var _excluded = ["valueType", "label", "childWidths", "fieldProps", "formItemProps", "params"],
3
3
  _excluded2 = ["formItemProps", "fieldProps"],
4
4
  _excluded3 = ["formItemProps", "fieldProps", "name"],
5
5
  _excluded4 = ["formItemProps", "fieldProps"],
@@ -72,13 +72,11 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
72
72
  _outConfig$item = outConfig.item,
73
73
  valueType = _outConfig$item.valueType,
74
74
  label = _outConfig$item.label,
75
- defaultValue = _outConfig$item.defaultValue,
76
75
  _outConfig$item$child = _outConfig$item.childWidths,
77
76
  childWidths = _outConfig$item$child === void 0 ? [] : _outConfig$item$child,
78
77
  rawFieldProps = _outConfig$item.fieldProps,
79
78
  rawFormItemProps = _outConfig$item.formItemProps,
80
79
  params = _outConfig$item.params,
81
- defaultParams = _outConfig$item.defaultParams,
82
80
  otherProps = _objectWithoutProperties(_outConfig$item, _excluded),
83
81
  requestOptions = outConfig.requestOptions,
84
82
  itemWidth = outConfig.itemWidth,
@@ -305,26 +303,22 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
305
303
  {
306
304
  if (valueType === 'checkbox') {
307
305
  return dynamicCom(ProFormCheckbox, {
308
- name: splitKeyStr(keyStr),
309
- initialValue: defaultValue
306
+ name: splitKeyStr(keyStr)
310
307
  });
311
308
  }
312
309
  if (valueType === 'switch') {
313
310
  return dynamicCom(ProFormSwitch, {
314
- name: splitKeyStr(keyStr),
315
- initialValue: defaultValue
311
+ name: splitKeyStr(keyStr)
316
312
  });
317
313
  }
318
314
  if (valueType === 'datePicker') {
319
315
  return dynamicCom(ProFormDatePicker, {
320
- name: splitKeyStr(keyStr),
321
- initialValue: defaultValue
316
+ name: splitKeyStr(keyStr)
322
317
  });
323
318
  }
324
319
  if (valueType === 'input') {
325
320
  return dynamicCom(ProFormText, {
326
- name: splitKeyStr(keyStr),
327
- initialValue: defaultValue
321
+ name: splitKeyStr(keyStr)
328
322
  });
329
323
  }
330
324
  if (valueType === 'select') {
@@ -337,60 +331,71 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
337
331
  debounceTime: 300,
338
332
  name: splitKeyStr(keyStr),
339
333
  options: item.api ? undefined : item.options,
340
- params: item.api ? _objectSpread(_objectSpread(_objectSpread({}, values), item.params), item.defaultParams) : undefined,
341
- initialValue: defaultValue,
334
+ params: item.api ? _objectSpread(_objectSpread({}, values), item.params) : undefined,
342
335
  request: function () {
343
336
  if (!item.api) return undefined;
344
337
  var map = {};
345
- return /*#__PURE__*/function () {
346
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref4) {
347
- var keyWords, params, key, res;
348
- return _regeneratorRuntime().wrap(function _callee$(_context) {
349
- while (1) switch (_context.prev = _context.next) {
350
- case 0:
351
- keyWords = _ref4.keyWords, params = _objectWithoutProperties(_ref4, _excluded7);
352
- key = JSON.stringify(params || '');
353
- if (!map[key]) {
354
- _context.next = 4;
355
- break;
356
- }
357
- return _context.abrupt("return", map[key]);
358
- case 4:
359
- _context.next = 6;
360
- return requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, params, item);
361
- case 6:
362
- _context.t0 = _context.sent;
363
- if (_context.t0) {
364
- _context.next = 9;
365
- break;
366
- }
367
- _context.t0 = [];
368
- case 9:
369
- res = _context.t0;
370
- map[key] = res;
371
- return _context.abrupt("return", res);
372
- case 12:
373
- case "end":
374
- return _context.stop();
375
- }
376
- }, _callee);
377
- }));
378
- return function (_x) {
379
- return _ref5.apply(this, arguments);
380
- };
381
- }();
338
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
339
+ var _ref5,
340
+ keyWords,
341
+ params,
342
+ key,
343
+ res,
344
+ _args = arguments;
345
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
346
+ while (1) switch (_context.prev = _context.next) {
347
+ case 0:
348
+ _ref5 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, keyWords = _ref5.keyWords, params = _objectWithoutProperties(_ref5, _excluded7);
349
+ key = JSON.stringify(params);
350
+ if (!map[key]) {
351
+ _context.next = 4;
352
+ break;
353
+ }
354
+ return _context.abrupt("return", map[key]);
355
+ case 4:
356
+ _context.next = 6;
357
+ return requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, params, item);
358
+ case 6:
359
+ _context.t0 = _context.sent;
360
+ if (_context.t0) {
361
+ _context.next = 9;
362
+ break;
363
+ }
364
+ _context.t0 = [];
365
+ case 9:
366
+ res = _context.t0;
367
+ map[key] = res;
368
+ return _context.abrupt("return", res);
369
+ case 12:
370
+ case "end":
371
+ return _context.stop();
372
+ }
373
+ }, _callee);
374
+ }));
382
375
  }()
383
376
  });
384
377
  }
385
378
  if (valueType === 'selectDim') {
386
- var paramsProp = _objectSpread(_objectSpread(_objectSpread({}, values), item.params), item.defaultParams);
387
- // console.log(1111, params);
388
379
  var keys = Array.isArray(splitKeyStr(keyStr)) ? splitKeyStr(keyStr) : [splitKeyStr(keyStr)];
380
+ // 用于标记是否已经初始化过
381
+ var initialized = false;
389
382
  return /*#__PURE__*/_jsx(ProFormDependency, {
390
383
  name: keys,
391
384
  children: function children(dependData) {
392
385
  // console.log(2222, dependData);
393
386
 
387
+ var paramsProp = _objectSpread(_objectSpread({}, values), item.params);
388
+ // 如果配置了 apiSearchValueKey,则将依赖数据 dependData[keyStr] 赋值到对应参数
389
+ if (typeof item.apiSearchValueKey === 'string') {
390
+ var currentValue = dependData[keyStr];
391
+ // 首次渲染且值为空时,使用初始值;后续使用表单实际值
392
+ if (!initialized && currentValue === undefined) {
393
+ paramsProp[item.apiSearchValueKey] = item.initialValue;
394
+ } else {
395
+ paramsProp[item.apiSearchValueKey] = currentValue;
396
+ }
397
+ initialized = true;
398
+ }
394
399
  return dynamicCom(ProFormSelect, {
395
400
  showSearch: true,
396
401
  debounceTime: 300,
@@ -400,7 +405,6 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
400
405
  mode: item.multiple ? 'multiple' : 'single',
401
406
  params: paramsProp,
402
407
  name: keys,
403
- initialValue: defaultValue,
404
408
  request: function () {
405
409
  var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
406
410
  var _params$keyWords, keyWords, restParams, newParams;
@@ -409,12 +413,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
409
413
  case 0:
410
414
  // 拆分参数,keyWords 为搜索关键字,其余为接口参数
411
415
  _params$keyWords = params.keyWords, keyWords = _params$keyWords === void 0 ? '' : _params$keyWords, restParams = _objectWithoutProperties(params, _excluded8);
412
- newParams = restParams; // 如果配置了 apiSearchValueKey,则将依赖数据 dependData[keyStr] 赋值到对应参数
413
- if (typeof item.apiSearchValueKey === 'string') {
414
- newParams[item.apiSearchValueKey] = dependData[keyStr] || undefined;
415
- }
416
-
417
- // 处理搜索关键字参数的传递方式
416
+ newParams = restParams; // 处理搜索关键字参数的传递方式
418
417
  if (item.apiSearchKey === false) {
419
418
  // 配置为 false,默认传 keyWords 字段
420
419
  newParams.keyWords = keyWords || undefined;
@@ -429,13 +428,13 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
429
428
 
430
429
  // 发起接口请求,返回选项数据
431
430
  return _context2.abrupt("return", (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions(item.api, newParams, item)) || []);
432
- case 5:
431
+ case 4:
433
432
  case "end":
434
433
  return _context2.stop();
435
434
  }
436
435
  }, _callee2);
437
436
  }));
438
- function request(_x2) {
437
+ function request(_x) {
439
438
  return _request.apply(this, arguments);
440
439
  }
441
440
  return request;
@@ -472,8 +471,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
472
471
  }), formatMessage({
473
472
  id: 'rex.components.base-form.placeholder.date-range.end',
474
473
  defaultMessage: '结束时间'
475
- })],
476
- initialValue: defaultValue
474
+ })]
477
475
  });
478
476
  }
479
477
  if (valueType === 'cascader') {
@@ -489,8 +487,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
489
487
  children: 'children'
490
488
  }
491
489
  },
492
- initialValue: defaultValue,
493
- params: item.api ? _objectSpread(_objectSpread(_objectSpread({}, values), item.params), item.defaultParams) : undefined,
490
+ params: item.api ? _objectSpread(_objectSpread({}, values), item.params) : undefined,
494
491
  name: splitKeyStr(keyStr),
495
492
  request: item.api ? ( /*#__PURE__*/function () {
496
493
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
@@ -504,7 +501,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
504
501
  }
505
502
  }, _callee3);
506
503
  }));
507
- return function (_x3) {
504
+ return function (_x2) {
508
505
  return _ref7.apply(this, arguments);
509
506
  };
510
507
  }()) : undefined
@@ -525,8 +522,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
525
522
  },
526
523
  treeNodeFilterProp: 'label'
527
524
  },
528
- initialValue: defaultValue,
529
- params: item.api ? _objectSpread(_objectSpread(_objectSpread({}, values), item.params), item.defaultParams) : undefined,
525
+ params: item.api ? _objectSpread(_objectSpread({}, values), item.params) : undefined,
530
526
  name: splitKeyStr(keyStr),
531
527
  request: item.api ? ( /*#__PURE__*/function () {
532
528
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
@@ -540,7 +536,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
540
536
  }
541
537
  }, _callee4);
542
538
  }));
543
- return function (_x4) {
539
+ return function (_x3) {
544
540
  return _ref8.apply(this, arguments);
545
541
  };
546
542
  }()) : undefined
@@ -549,9 +545,8 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
549
545
  if (valueType === 'checkboxGroup') {
550
546
  return dynamicCom(ProFormCheckbox.Group, {
551
547
  options: item.api ? undefined : item.options,
552
- params: item.api ? _objectSpread(_objectSpread(_objectSpread({}, values), item.params), item.defaultParams) : undefined,
548
+ params: item.api ? _objectSpread(_objectSpread({}, values), item.params) : undefined,
553
549
  layout: 'horizontal',
554
- initialValue: defaultValue,
555
550
  name: splitKeyStr(keyStr),
556
551
  request: item.api ? ( /*#__PURE__*/function () {
557
552
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
@@ -565,7 +560,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
565
560
  }
566
561
  }, _callee5);
567
562
  }));
568
- return function (_x5) {
563
+ return function (_x4) {
569
564
  return _ref9.apply(this, arguments);
570
565
  };
571
566
  }()) : undefined
@@ -574,9 +569,8 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
574
569
  if (valueType === 'radioGroup') {
575
570
  return dynamicCom(ProFormRadio.Group, {
576
571
  options: item.api ? undefined : item.options,
577
- params: item.api ? _objectSpread(_objectSpread(_objectSpread({}, values), item.params), item.defaultParams) : undefined,
572
+ params: item.api ? _objectSpread(_objectSpread({}, values), item.params) : undefined,
578
573
  layout: 'horizontal',
579
- initialValue: defaultValue,
580
574
  name: splitKeyStr(keyStr),
581
575
  request: item.api ? ( /*#__PURE__*/function () {
582
576
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
@@ -590,7 +584,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
590
584
  }
591
585
  }, _callee6);
592
586
  }));
593
- return function (_x6) {
587
+ return function (_x5) {
594
588
  return _ref10.apply(this, arguments);
595
589
  };
596
590
  }()) : undefined
@@ -598,13 +592,11 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
598
592
  }
599
593
  if (valueType === 'inputNumber') {
600
594
  return dynamicCom(ProFormDigit, {
601
- initialValue: defaultValue,
602
595
  name: splitKeyStr(keyStr)
603
596
  });
604
597
  }
605
598
  if (valueType === 'inputNumberRange') {
606
599
  return dynamicCom(ProFormDigitRange, {
607
- initialValue: defaultValue,
608
600
  name: keyStr,
609
601
  transform: function transform(inrValues) {
610
602
  return _defineProperty(_defineProperty({}, fields[0], inrValues[0]), fields[1], inrValues[1]);
@@ -620,7 +612,6 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
620
612
  }
621
613
  if (valueType === 'inputNumberRangeV2') {
622
614
  return dynamicCom(ProFormDigitRangeV2, {
623
- initialValue: defaultValue,
624
615
  // name: keyStr as [string, string],
625
616
  name: [splitKeyStr(fields[0]), splitKeyStr(fields[1])],
626
617
  // transform: (inrValues: Array<number | undefined>) => ({
@@ -638,13 +629,11 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
638
629
  }
639
630
  if (valueType === 'textArea') {
640
631
  return dynamicCom(ProFormTextArea, {
641
- initialValue: defaultValue,
642
632
  name: splitKeyStr(keyStr)
643
633
  });
644
634
  }
645
635
  if (valueType === 'hidden') {
646
636
  return dynamicCom(ProFormText, {
647
- initialValue: defaultValue,
648
637
  name: splitKeyStr(keyStr),
649
638
  hidden: true
650
639
  });
@@ -124,9 +124,8 @@ export interface IBaseFormFieldItem<T extends TValueType = TValueType> {
124
124
  /** 提示信息 */
125
125
  tooltip?: string;
126
126
  /**
127
- * 字段对应默认值
128
- * - 需要手动调用函数提取,再设置
129
- * - 扩展,注入form.item 上
127
+ * @deprecated 字段对应默认值 * - 需要手动调用函数提取,再设置 * - 扩展,注入form.item 上
128
+ * - 推荐使用 form 的 initialValues 统一设置
130
129
  */
131
130
  defaultValue?: string | string[] | boolean | number | number[];
132
131
  /** 控制隐藏 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamias/rex-design",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",