@teamias/rex-design 0.1.26 → 0.1.27

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.
@@ -237,9 +237,22 @@ export var Core = function Core(props) {
237
237
  }
238
238
 
239
239
  // updateData: 满足一条 updateData 规则则缓存依赖数据
240
- dependenciesSearchCacheData[keyStr] = updateData.some(function (ii) {
240
+ // 当配置了 mappedField 时, 将原始 field key 映射为 mappedField key 作为 request 入参
241
+ if (updateData.some(function (ii) {
241
242
  return ii;
242
- }) ? data : undefined;
243
+ })) {
244
+ var mapped = _objectSpread({}, data);
245
+ Object.values(dependMap).forEach(function (dep) {
246
+ if (dep.action === 'updateData' && dep.mappedField && dep.field in mapped) {
247
+ var sourceValue = mapped;
248
+ sourceValue[dep.mappedField] = sourceValue[dep.field];
249
+ delete sourceValue[dep.field];
250
+ }
251
+ });
252
+ dependenciesSearchCacheData[keyStr] = mapped;
253
+ } else {
254
+ dependenciesSearchCacheData[keyStr] = undefined;
255
+ }
243
256
 
244
257
  // syncValue: 满足一条 syncValue 规则则同步指定字段的值
245
258
  if (syncValue.some(function (ii) {
@@ -17,11 +17,13 @@ export default (function () {
17
17
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18
18
  while (1) switch (_context.prev = _context.next) {
19
19
  case 0:
20
- _context.next = 2;
20
+ // 模拟接口请求
21
+ console.log('mockRequest params:', params);
22
+ _context.next = 3;
21
23
  return sleep(500);
22
- case 2:
24
+ case 3:
23
25
  if (!(params.category === 'fruit')) {
24
- _context.next = 4;
26
+ _context.next = 5;
25
27
  break;
26
28
  }
27
29
  return _context.abrupt("return", [{
@@ -34,7 +36,19 @@ export default (function () {
34
36
  label: '橙子',
35
37
  value: 'orange'
36
38
  }]);
37
- case 4:
39
+ case 5:
40
+ if (!params.dept_id) {
41
+ _context.next = 7;
42
+ break;
43
+ }
44
+ return _context.abrupt("return", [{
45
+ label: "\u5C97\u4F4DA\uFF08dept_id=".concat(params.dept_id, "\uFF09"),
46
+ value: 'job_a'
47
+ }, {
48
+ label: "\u5C97\u4F4DB\uFF08dept_id=".concat(params.dept_id, "\uFF09"),
49
+ value: 'job_b'
50
+ }]);
51
+ case 7:
38
52
  return _context.abrupt("return", [{
39
53
  label: '白菜',
40
54
  value: 'cabbage'
@@ -45,7 +59,7 @@ export default (function () {
45
59
  label: '土豆',
46
60
  value: 'potato'
47
61
  }]);
48
- case 5:
62
+ case 8:
49
63
  case "end":
50
64
  return _context.stop();
51
65
  }
@@ -144,6 +158,38 @@ export default (function () {
144
158
  field: 'category',
145
159
  action: 'clear'
146
160
  }]
161
+ }, {
162
+ valueType: 'select',
163
+ field: 'org_id',
164
+ label: '部门',
165
+ options: [{
166
+ label: '研发部',
167
+ value: 'dev'
168
+ }, {
169
+ label: '产品部',
170
+ value: 'product'
171
+ }, {
172
+ label: '设计部',
173
+ value: 'design'
174
+ }]
175
+ }, {
176
+ valueType: 'select',
177
+ field: 'job_id',
178
+ label: '岗位(mappedField)',
179
+ tooltip: '依赖 org_id,但通过 mappedField 将请求入参 key 从 org_id 映射为 dept_id',
180
+ api: '/jobs',
181
+ dependenciesV2: [{
182
+ field: 'org_id',
183
+ action: 'updateData',
184
+ mappedField: 'dept_id'
185
+ }, {
186
+ field: 'org_id',
187
+ action: 'clear'
188
+ }, {
189
+ field: 'org_id',
190
+ action: 'show',
191
+ op: 'notEmpty'
192
+ }]
147
193
  }];
148
194
  return /*#__PURE__*/_jsx(RexProConfigProvider, {
149
195
  value: {},
@@ -74,7 +74,7 @@ var areDependenciesReady = function areDependenciesReady(dependenciesRequest, de
74
74
  var updateDataFields = dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(function (dep) {
75
75
  return dep.action === 'updateData';
76
76
  }).map(function (dep) {
77
- return dep.field;
77
+ return dep.mappedField || dep.field;
78
78
  });
79
79
  if (updateDataFields !== null && updateDataFields !== void 0 && updateDataFields.length) {
80
80
  return updateDataFields.every(function (k) {
@@ -148,7 +148,7 @@ type TOption = {
148
148
  children?: TOption[];
149
149
  };
150
150
  /** 统一排除属性 */
151
- type TOmitComponentItemType = 'width';
151
+ type TOmitComponentItemType = 'width' | 'name';
152
152
  /** 依赖项 */
153
153
  export interface IDependenciesV2 extends Partial<Omit<TButtonFilterItem, 'original'>> {
154
154
  /** 依赖字段 */
@@ -165,5 +165,9 @@ export interface IDependenciesV2 extends Partial<Omit<TButtonFilterItem, 'origin
165
165
  * - false 类型: updateData disabled hidden show syncValue
166
166
  */
167
167
  isTouched?: boolean;
168
+ /**
169
+ * 针对于 action: updateData 的时候, 需要提供新的字段,作为更新数据的依据
170
+ */
171
+ mappedField?: string;
168
172
  }
169
173
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamias/rex-design",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",