@kmkf-fe-packages/kmkf-work-order-service-component 2.2.1 → 2.2.3-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,7 @@ export var FLOW_STATUS_V2 = {
37
37
  RETURNING: '回退中'
38
38
  };
39
39
  //不能回填的组件type
40
- export var CANNOT_BACK_FILL = ['LOGISTICS_TRAJECTORY', 'LOGISTICS_TRAJECTORY_MORE', 'BUYER_MESSAGE_NOTICE', 'MSG_STATUS', 'NEW_PAYMENT_STATUS', 'REISSUE_STATUS', 'REISSUE_LOGISTICS', 'RETURN_GOODS_STATUS', 'RETURN_GOODS_TRADE_ID', 'ADJUST_WORK_ORDER_STATUS', 'INVOICE_STATUS', 'INVOICING_STATUS', 'EXCHANGE_STATUS', 'WAREHOUSING_STATUS', 'BS_E3_WAREHOUSING_STATUS', 'EXCHANGE_TRADE_ID', 'REISSUE_TRADE_ID', 'ERP_AFTER_SALE_TRADE_ID', 'LOGISTICS_INTERCEPTION', 'LOGISTICS_INTERCEPTION_MORE', 'ORDER_TYPE', 'REFUND_TYPE', 'RETURN_EXCHANGE_GOODS_REVIEW_STATUS', 'EXECUTE_ACTION_TYPE'];
40
+ export var CANNOT_BACK_FILL = ['LOGISTICS_TRAJECTORY', 'LOGISTICS_TRAJECTORY_MORE', 'BUYER_MESSAGE_NOTICE', 'MSG_STATUS', 'NEW_PAYMENT_STATUS', 'REISSUE_STATUS', 'REISSUE_LOGISTICS', 'RETURN_GOODS_STATUS', 'RETURN_GOODS_TRADE_ID', 'ADJUST_WORK_ORDER_STATUS', 'INVOICE_STATUS', 'INVOICING_STATUS', 'EXCHANGE_STATUS', 'WAREHOUSING_STATUS', 'BS_E3_WAREHOUSING_STATUS', 'WDT_WAREHOUSING_STATUS', 'EXCHANGE_TRADE_ID', 'REISSUE_TRADE_ID', 'ERP_AFTER_SALE_TRADE_ID', 'LOGISTICS_INTERCEPTION', 'LOGISTICS_INTERCEPTION_MORE', 'ORDER_TYPE', 'REFUND_TYPE', 'RETURN_EXCHANGE_GOODS_REVIEW_STATUS', 'EXECUTE_ACTION_TYPE'];
41
41
  export var verifyHandle = function verifyHandle(data, componentDtoList) {
42
42
  var _componentDtoList$fin, _componentDtoList$fin2, _data$paymentUniqueKe, _data$paymentUniqueKe2;
43
43
  var res = {
@@ -0,0 +1,75 @@
1
+ /**
2
+ * 组件显隐依赖关系查找器 - TypeScript ES Module版本
3
+ * 根据配置文件递归查找组件的所有依赖关系
4
+ */
5
+ import type { Config, DependencyGraph, CircularDependency, DependencyLevels, ComponentStat, DependencyOptions, DependencyAnalysis } from './types.js';
6
+ /**
7
+ * 查找组件的所有依赖关系(递归)
8
+ * @param componentKey - 要查找依赖的组件key
9
+ * @param config - 显隐配置对象
10
+ * @param visited - 已访问的组件集合,用于避免循环依赖
11
+ * @param dependencies - 依赖组件集合
12
+ * @param options - 查找选项
13
+ * @returns 所有依赖组件的key数组
14
+ */
15
+ export declare function findAllDependencies(componentKey: string, config: Config, visited?: Set<string>, dependencies?: Set<string>, options?: DependencyOptions): string[];
16
+ /**
17
+ * 获取组件的直接依赖
18
+ * @param componentKey - 组件key
19
+ * @param config - 显隐配置对象
20
+ * @returns 直接依赖的组件key数组
21
+ */
22
+ export declare function getDirectDependencies(componentKey: string, config: Config): string[];
23
+ /**
24
+ * 构建整个依赖关系图
25
+ * @param config - 显隐配置对象
26
+ * @returns 依赖关系图,格式:{ componentKey: [依赖的组件数组] }
27
+ */
28
+ export declare function buildDependencyGraph(config: Config): DependencyGraph;
29
+ /**
30
+ * 检测循环依赖
31
+ * @param config - 显隐配置对象
32
+ * @returns 包含循环依赖的组件组
33
+ */
34
+ export declare function detectCircularDependencies(config: Config): CircularDependency[];
35
+ /**
36
+ * 打印依赖关系树
37
+ * @param componentKey - 组件key
38
+ * @param config - 显隐配置对象
39
+ * @param level - 缩进级别
40
+ * @param visited - 已访问的组件集合
41
+ */
42
+ export declare function printDependencyTree(componentKey: string, config: Config, level?: number, visited?: Set<string>): void;
43
+ /**
44
+ * 获取组件的依赖层级
45
+ * @param componentKey - 组件key
46
+ * @param config - 显隐配置对象
47
+ * @returns 依赖层级对象
48
+ */
49
+ export declare function getDependencyLevels(componentKey: string, config: Config): DependencyLevels;
50
+ /**
51
+ * 分析组件的完整依赖信息
52
+ * @param componentKey - 组件key
53
+ * @param config - 显隐配置对象
54
+ * @returns 完整的依赖分析结果
55
+ */
56
+ export declare function analyzeDependency(componentKey: string, config: Config): DependencyAnalysis;
57
+ /**
58
+ * 获取依赖统计信息
59
+ * @param config - 显隐配置对象
60
+ * @param topN - 返回前N个结果
61
+ * @returns 组件统计信息数组
62
+ */
63
+ export declare function getDependencyStats(config: Config, topN?: number): {
64
+ mostDependencies: ComponentStat[];
65
+ mostDependedOn: ComponentStat[];
66
+ };
67
+ /**
68
+ * 验证配置文件格式
69
+ * @param config - 要验证的配置对象
70
+ * @returns 验证结果和错误信息
71
+ */
72
+ export declare function validateConfig(config: unknown): {
73
+ isValid: boolean;
74
+ errors: string[];
75
+ };
@@ -0,0 +1,328 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
5
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
+ /**
13
+ * 组件显隐依赖关系查找器 - TypeScript ES Module版本
14
+ * 根据配置文件递归查找组件的所有依赖关系
15
+ */
16
+
17
+ /**
18
+ * 查找组件的所有依赖关系(递归)
19
+ * @param componentKey - 要查找依赖的组件key
20
+ * @param config - 显隐配置对象
21
+ * @param visited - 已访问的组件集合,用于避免循环依赖
22
+ * @param dependencies - 依赖组件集合
23
+ * @param options - 查找选项
24
+ * @returns 所有依赖组件的key数组
25
+ */
26
+ export function findAllDependencies(componentKey, config) {
27
+ var visited = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
28
+ var dependencies = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
29
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
30
+ var _options$maxDepth = options.maxDepth,
31
+ maxDepth = _options$maxDepth === void 0 ? Infinity : _options$maxDepth;
32
+
33
+ // 如果已经访问过这个组件,直接返回(避免循环依赖)
34
+ if (visited.has(componentKey)) {
35
+ return Array.from(dependencies);
36
+ }
37
+
38
+ // 检查递归深度
39
+ if (visited.size >= maxDepth) {
40
+ return Array.from(dependencies);
41
+ }
42
+
43
+ // 标记当前组件为已访问
44
+ visited.add(componentKey);
45
+
46
+ // 获取当前组件的配置
47
+ var componentConfig = config[componentKey];
48
+
49
+ // 如果组件不存在配置,返回当前依赖列表
50
+ if (!componentConfig || !Array.isArray(componentConfig)) {
51
+ return Array.from(dependencies);
52
+ }
53
+
54
+ // 遍历组件的所有规则组
55
+ componentConfig.forEach(function (ruleGroup) {
56
+ if (ruleGroup.rules && Array.isArray(ruleGroup.rules)) {
57
+ // 遍历规则组中的所有规则
58
+ ruleGroup.rules.forEach(function (rule) {
59
+ if (rule.leftValue && typeof rule.leftValue === 'string') {
60
+ var dependencyKey = rule.leftValue;
61
+
62
+ // 添加直接依赖
63
+ dependencies.add(dependencyKey);
64
+
65
+ // 递归查找间接依赖
66
+ findAllDependencies(dependencyKey, config, visited, dependencies, options);
67
+ }
68
+ });
69
+ }
70
+ });
71
+ return Array.from(dependencies);
72
+ }
73
+
74
+ /**
75
+ * 获取组件的直接依赖
76
+ * @param componentKey - 组件key
77
+ * @param config - 显隐配置对象
78
+ * @returns 直接依赖的组件key数组
79
+ */
80
+ export function getDirectDependencies(componentKey, config) {
81
+ var componentConfig = config[componentKey];
82
+ var dependencies = new Set();
83
+ if (!componentConfig || !Array.isArray(componentConfig)) {
84
+ return [];
85
+ }
86
+ componentConfig.forEach(function (ruleGroup) {
87
+ if (ruleGroup.rules && Array.isArray(ruleGroup.rules)) {
88
+ ruleGroup.rules.forEach(function (rule) {
89
+ if (rule.leftValue && typeof rule.leftValue === 'string') {
90
+ dependencies.add(rule.leftValue);
91
+ }
92
+ });
93
+ }
94
+ });
95
+ return Array.from(dependencies);
96
+ }
97
+
98
+ /**
99
+ * 构建整个依赖关系图
100
+ * @param config - 显隐配置对象
101
+ * @returns 依赖关系图,格式:{ componentKey: [依赖的组件数组] }
102
+ */
103
+ export function buildDependencyGraph(config) {
104
+ var dependencyGraph = {};
105
+ Object.keys(config).forEach(function (componentKey) {
106
+ dependencyGraph[componentKey] = findAllDependencies(componentKey, config);
107
+ });
108
+ return dependencyGraph;
109
+ }
110
+
111
+ /**
112
+ * 检测循环依赖
113
+ * @param config - 显隐配置对象
114
+ * @returns 包含循环依赖的组件组
115
+ */
116
+ export function detectCircularDependencies(config) {
117
+ var circularDeps = [];
118
+ var visiting = new Set();
119
+ var visited = new Set();
120
+ function dfs(componentKey) {
121
+ var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
122
+ if (visiting.has(componentKey)) {
123
+ // 发现循环依赖
124
+ var cycleStart = path.indexOf(componentKey);
125
+ circularDeps.push(path.slice(cycleStart).concat(componentKey));
126
+ return;
127
+ }
128
+ if (visited.has(componentKey)) {
129
+ return;
130
+ }
131
+ visiting.add(componentKey);
132
+ path.push(componentKey);
133
+ var directDeps = getDirectDependencies(componentKey, config);
134
+ directDeps.forEach(function (dep) {
135
+ dfs(dep, _toConsumableArray(path));
136
+ });
137
+ visiting.delete(componentKey);
138
+ visited.add(componentKey);
139
+ }
140
+ Object.keys(config).forEach(function (componentKey) {
141
+ if (!visited.has(componentKey)) {
142
+ dfs(componentKey);
143
+ }
144
+ });
145
+ return circularDeps;
146
+ }
147
+
148
+ /**
149
+ * 打印依赖关系树
150
+ * @param componentKey - 组件key
151
+ * @param config - 显隐配置对象
152
+ * @param level - 缩进级别
153
+ * @param visited - 已访问的组件集合
154
+ */
155
+ export function printDependencyTree(componentKey, config) {
156
+ var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
157
+ var visited = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
158
+ var indent = ' '.repeat(level);
159
+ console.log("".concat(indent).concat(componentKey));
160
+ if (visited.has(componentKey)) {
161
+ console.log("".concat(indent, " [\u5FAA\u73AF\u4F9D\u8D56]"));
162
+ return;
163
+ }
164
+ visited.add(componentKey);
165
+ var directDeps = getDirectDependencies(componentKey, config);
166
+ directDeps.forEach(function (dep) {
167
+ printDependencyTree(dep, config, level + 1, new Set(visited));
168
+ });
169
+ }
170
+
171
+ /**
172
+ * 获取组件的依赖层级
173
+ * @param componentKey - 组件key
174
+ * @param config - 显隐配置对象
175
+ * @returns 依赖层级对象
176
+ */
177
+ export function getDependencyLevels(componentKey, config) {
178
+ var levels = {};
179
+ var queue = [{
180
+ key: componentKey,
181
+ level: 0
182
+ }];
183
+ var visited = new Set();
184
+ var _loop = function _loop() {
185
+ var current = queue.shift();
186
+ if (!current) return "break";
187
+ var key = current.key,
188
+ level = current.level;
189
+ if (visited.has(key)) return "continue";
190
+ visited.add(key);
191
+ if (level > 0) {
192
+ // 不包含自己
193
+ if (!levels[level]) levels[level] = [];
194
+ levels[level].push(key);
195
+ }
196
+ var directDeps = getDirectDependencies(key, config);
197
+ directDeps.forEach(function (dep) {
198
+ if (!visited.has(dep)) {
199
+ queue.push({
200
+ key: dep,
201
+ level: level + 1
202
+ });
203
+ }
204
+ });
205
+ };
206
+ while (queue.length > 0) {
207
+ var _ret = _loop();
208
+ if (_ret === "break") break;
209
+ if (_ret === "continue") continue;
210
+ }
211
+ return levels;
212
+ }
213
+
214
+ /**
215
+ * 分析组件的完整依赖信息
216
+ * @param componentKey - 组件key
217
+ * @param config - 显隐配置对象
218
+ * @returns 完整的依赖分析结果
219
+ */
220
+ export function analyzeDependency(componentKey, config) {
221
+ var directDependencies = getDirectDependencies(componentKey, config);
222
+ var allDependencies = findAllDependencies(componentKey, config);
223
+ var dependencyLevels = getDependencyLevels(componentKey, config);
224
+
225
+ // 检查是否有循环依赖
226
+ var circularDeps = detectCircularDependencies(config);
227
+ var hasCircularDependency = circularDeps.some(function (cycle) {
228
+ return cycle.includes(componentKey);
229
+ });
230
+ return {
231
+ componentKey: componentKey,
232
+ directDependencies: directDependencies,
233
+ allDependencies: allDependencies,
234
+ dependencyCount: allDependencies.length,
235
+ dependencyLevels: dependencyLevels,
236
+ hasCircularDependency: hasCircularDependency
237
+ };
238
+ }
239
+
240
+ /**
241
+ * 获取依赖统计信息
242
+ * @param config - 显隐配置对象
243
+ * @param topN - 返回前N个结果
244
+ * @returns 组件统计信息数组
245
+ */
246
+ export function getDependencyStats(config) {
247
+ var topN = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
248
+ var dependencyGraph = buildDependencyGraph(config);
249
+
250
+ // 统计依赖数量最多的组件
251
+ var mostDependencies = Object.entries(dependencyGraph).map(function (_ref) {
252
+ var _ref2 = _slicedToArray(_ref, 2),
253
+ key = _ref2[0],
254
+ deps = _ref2[1];
255
+ return {
256
+ key: key,
257
+ count: deps.length
258
+ };
259
+ }).sort(function (a, b) {
260
+ return b.count - a.count;
261
+ }).slice(0, topN);
262
+
263
+ // 统计被依赖最多的组件
264
+ var dependedOnCount = {};
265
+ Object.values(dependencyGraph).forEach(function (deps) {
266
+ deps.forEach(function (dep) {
267
+ dependedOnCount[dep] = (dependedOnCount[dep] || 0) + 1;
268
+ });
269
+ });
270
+ var mostDependedOn = Object.entries(dependedOnCount).map(function (_ref3) {
271
+ var _ref4 = _slicedToArray(_ref3, 2),
272
+ key = _ref4[0],
273
+ count = _ref4[1];
274
+ return {
275
+ key: key,
276
+ count: count
277
+ };
278
+ }).sort(function (a, b) {
279
+ return b.count - a.count;
280
+ }).slice(0, topN);
281
+ return {
282
+ mostDependencies: mostDependencies,
283
+ mostDependedOn: mostDependedOn
284
+ };
285
+ }
286
+
287
+ /**
288
+ * 验证配置文件格式
289
+ * @param config - 要验证的配置对象
290
+ * @returns 验证结果和错误信息
291
+ */
292
+ export function validateConfig(config) {
293
+ var errors = [];
294
+ if (!config || _typeof(config) !== 'object') {
295
+ errors.push('配置必须是一个对象');
296
+ return {
297
+ isValid: false,
298
+ errors: errors
299
+ };
300
+ }
301
+ var configObj = config;
302
+ Object.entries(configObj).forEach(function (_ref5) {
303
+ var _ref6 = _slicedToArray(_ref5, 2),
304
+ key = _ref6[0],
305
+ value = _ref6[1];
306
+ if (!Array.isArray(value)) {
307
+ errors.push("\u7EC4\u4EF6 ".concat(key, " \u7684\u914D\u7F6E\u5FC5\u987B\u662F\u6570\u7EC4"));
308
+ return;
309
+ }
310
+ value.forEach(function (ruleGroup, index) {
311
+ if (!ruleGroup || _typeof(ruleGroup) !== 'object') {
312
+ errors.push("\u7EC4\u4EF6 ".concat(key, " \u7684\u89C4\u5219\u7EC4 ").concat(index, " \u5FC5\u987B\u662F\u5BF9\u8C61"));
313
+ return;
314
+ }
315
+ var group = ruleGroup;
316
+ if (!group.linkCondition || !['some', 'every'].includes(group.linkCondition)) {
317
+ errors.push("\u7EC4\u4EF6 ".concat(key, " \u7684\u89C4\u5219\u7EC4 ").concat(index, " linkCondition \u5FC5\u987B\u662F 'some' \u6216 'every'"));
318
+ }
319
+ if (!Array.isArray(group.rules)) {
320
+ errors.push("\u7EC4\u4EF6 ".concat(key, " \u7684\u89C4\u5219\u7EC4 ").concat(index, " rules \u5FC5\u987B\u662F\u6570\u7EC4"));
321
+ }
322
+ });
323
+ });
324
+ return {
325
+ isValid: errors.length === 0,
326
+ errors: errors
327
+ };
328
+ }
@@ -25,7 +25,7 @@ import React, { useState, useRef, useEffect, useMemo, forwardRef, useImperativeH
25
25
  import { ConfigProvider, Form, Space, Tag } from 'antd';
26
26
  import { useWhyDidYouUpdate } from 'ahooks';
27
27
  import zhCN from 'antd/es/locale/zh_CN';
28
- import { get, some, set, every, cloneDeep, isEmpty, intersection, throttle, groupBy, find, isArray } from 'lodash';
28
+ import { get, some, set, every, cloneDeep, isEmpty, intersection, throttle, groupBy, find, isArray, debounce, isMatch, isEqual } from 'lodash';
29
29
  import 'moment/locale/zh-cn';
30
30
  import { calcWorkOrderList, orderBack, getReplaceWarnValues, COMPONENT_MAP_NAME, EXCLUDE_REPLACE_TOP_COMPONENT,
31
31
  // 重复检验不需要展示在顶部的
@@ -44,6 +44,8 @@ import { NEED_CLEAR_FIELDS_WHEN_SHOP_ID_CHANGE } from "../../constant";
44
44
  import { Context } from "../../context";
45
45
  import { orderBackKmAddress } from "./constants";
46
46
  import { onBlurExpressLogisticsCode, onBlurErpAfterSaleTradeId } from "./onBlur";
47
+ import { findAllDependencies } from "./component-dependency-finder";
48
+ import { findValueDependencies } from "./value-mapping-finder";
47
49
  // 记录显隐触发隐藏的组件。显示后,重新出发一遍映射规则
48
50
  // TODO: 用useState会有bug, 不确定是哪里导致的
49
51
  var hideByXYComponentsMap = {};
@@ -221,6 +223,9 @@ var FormRender = function FormRender(props, ref) {
221
223
  }
222
224
  });
223
225
  setReplaceValue(function (value) {
226
+ if (isMatch(value, obj)) {
227
+ return value;
228
+ }
224
229
  return _objectSpread(_objectSpread({}, value), obj);
225
230
  });
226
231
  };
@@ -278,6 +283,9 @@ var FormRender = function FormRender(props, ref) {
278
283
  return prv;
279
284
  }, {});
280
285
  setReplaceValue(function (prev) {
286
+ if (isMatch(prev, resultParams)) {
287
+ return prev;
288
+ }
281
289
  return _objectSpread(_objectSpread({}, prev), resultParams);
282
290
  });
283
291
  setReplaceConfig(function (prev) {
@@ -342,6 +350,11 @@ var FormRender = function FormRender(props, ref) {
342
350
  // 清空打款组件之前的重复校验
343
351
  if (!enterprisePaymentAlipayNo) {
344
352
  setReplaceValue(function (value) {
353
+ if (isMatch(value, {
354
+ enterprisePaymentAlipayNo: 0
355
+ })) {
356
+ return value;
357
+ }
345
358
  return _objectSpread(_objectSpread({}, value), {}, {
346
359
  enterprisePaymentAlipayNo: 0
347
360
  });
@@ -619,7 +632,7 @@ var FormRender = function FormRender(props, ref) {
619
632
  // 查询标签
620
633
  var queryLabels = /*#__PURE__*/function () {
621
634
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(tid, shopId) {
622
- var _yield$queryLabelByTr, _yield$queryLabelByTr2, data;
635
+ var oldLabelList, _yield$queryLabelByTr, _yield$queryLabelByTr2, data;
623
636
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
624
637
  while (1) switch (_context2.prev = _context2.next) {
625
638
  case 0:
@@ -635,26 +648,37 @@ var FormRender = function FormRender(props, ref) {
635
648
  }
636
649
  return _context2.abrupt("return", console.debug('查询标签缺少必要参数-shopId'));
637
650
  case 4:
651
+ oldLabelList = form.getFieldValue("".concat(labelComponent.uniqueKey));
638
652
  if (tid) {
639
- _context2.next = 8;
653
+ _context2.next = 9;
640
654
  break;
641
655
  }
642
- setLabelList([]);
643
- form.setFieldsValue(_defineProperty({}, "".concat(labelComponent.uniqueKey), []));
656
+ setLabelList(function (list) {
657
+ if (list.length === 0) return list;
658
+ return [];
659
+ });
660
+ if (oldLabelList.length !== 0) {
661
+ form.setFieldsValue(_defineProperty({}, "".concat(labelComponent.uniqueKey), []));
662
+ }
644
663
  return _context2.abrupt("return", console.debug('查询标签缺少必要参数-tradeId'));
645
- case 8:
646
- _context2.next = 10;
664
+ case 9:
665
+ _context2.next = 11;
647
666
  return queryLabelByTradeId({
648
667
  tid: tid,
649
668
  shopId: shopId
650
669
  });
651
- case 10:
670
+ case 11:
652
671
  _yield$queryLabelByTr = _context2.sent;
653
672
  _yield$queryLabelByTr2 = _yield$queryLabelByTr.data;
654
673
  data = _yield$queryLabelByTr2 === void 0 ? [] : _yield$queryLabelByTr2;
655
- setLabelList(data);
656
- form.setFieldsValue(_defineProperty({}, "".concat(labelComponent.uniqueKey), data));
657
- case 15:
674
+ setLabelList(function (list) {
675
+ if (isEqual(list, data)) return list;
676
+ return data;
677
+ });
678
+ if (!isEqual(oldLabelList, data)) {
679
+ form.setFieldsValue(_defineProperty({}, "".concat(labelComponent.uniqueKey), data));
680
+ }
681
+ case 16:
658
682
  case "end":
659
683
  return _context2.stop();
660
684
  }
@@ -667,7 +691,7 @@ var FormRender = function FormRender(props, ref) {
667
691
  // 查询会员等级
668
692
  var queryMemberLevels = /*#__PURE__*/function () {
669
693
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tid, shopId) {
670
- var _yield$queryMemberLev, _yield$queryMemberLev2, data;
694
+ var oldMemberLevel, _yield$queryMemberLev, _yield$queryMemberLev2, data;
671
695
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
672
696
  while (1) switch (_context3.prev = _context3.next) {
673
697
  case 0:
@@ -683,24 +707,29 @@ var FormRender = function FormRender(props, ref) {
683
707
  }
684
708
  return _context3.abrupt("return", console.debug('查询标签缺少必要参数-shopId'));
685
709
  case 4:
710
+ oldMemberLevel = form.getFieldValue("".concat(labelComponent.uniqueKey));
686
711
  if (tid) {
687
- _context3.next = 7;
712
+ _context3.next = 8;
688
713
  break;
689
714
  }
690
- form.setFieldsValue(_defineProperty({}, "".concat(memberLevelComponent.uniqueKey), []));
715
+ if (oldMemberLevel.length !== 0) {
716
+ form.setFieldsValue(_defineProperty({}, "".concat(labelComponent.uniqueKey), []));
717
+ }
691
718
  return _context3.abrupt("return", console.debug('查询标签缺少必要参数-tradeId'));
692
- case 7:
693
- _context3.next = 9;
719
+ case 8:
720
+ _context3.next = 10;
694
721
  return queryMemberLevel({
695
722
  tid: tid,
696
723
  shopId: shopId
697
724
  });
698
- case 9:
725
+ case 10:
699
726
  _yield$queryMemberLev = _context3.sent;
700
727
  _yield$queryMemberLev2 = _yield$queryMemberLev.data;
701
728
  data = _yield$queryMemberLev2 === void 0 ? [] : _yield$queryMemberLev2;
702
- form.setFieldsValue(_defineProperty({}, "".concat(memberLevelComponent.uniqueKey), data));
703
- case 13:
729
+ if (!isEqual(oldMemberLevel, data)) {
730
+ form.setFieldsValue(_defineProperty({}, "".concat(labelComponent.uniqueKey), data));
731
+ }
732
+ case 14:
704
733
  case "end":
705
734
  return _context3.stop();
706
735
  }
@@ -886,6 +915,9 @@ var FormRender = function FormRender(props, ref) {
886
915
  break;
887
916
  }
888
917
  setReplaceValue(function (prev) {
918
+ if (isMatch(prev, _defineProperty({}, type, 0))) {
919
+ return prev;
920
+ }
889
921
  return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, type, 0));
890
922
  });
891
923
  replaceValueRef.current = _objectSpread(_objectSpread({}, replaceValue), {}, _defineProperty({}, type, 0));
@@ -1073,13 +1105,6 @@ var FormRender = function FormRender(props, ref) {
1073
1105
  if (Reflect.has(currentComponentDisplayStatus.current, prefixId) && !currentComponentDisplayStatus.current[prefixId]) {
1074
1106
  return false;
1075
1107
  }
1076
- // console.debug(
1077
- // '显影计算',
1078
- // dependenceDetail?.type,
1079
- // leftValue,
1080
- // item.compareSymbol?.toUpperCase(),
1081
- // item.rightValue,
1082
- // );
1083
1108
  return getExpression((_item$compareSymbol = item.compareSymbol) === null || _item$compareSymbol === void 0 ? void 0 : _item$compareSymbol.toUpperCase(), leftValue, item.rightValue);
1084
1109
  };
1085
1110
  var getDisplayAndDisabledConfig = function getDisplayAndDisabledConfig(config) {
@@ -1166,12 +1191,23 @@ var FormRender = function FormRender(props, ref) {
1166
1191
  currentTemplateAllComponentsDisplay.current[instance === null || instance === void 0 ? void 0 : instance.id] = true;
1167
1192
  if (Reflect.has(idConditionListMap, instance.id)) {
1168
1193
  var currentIdDependenceOtherFields = idConditionListMap[instance.id];
1194
+ // console.group('当前组件', instance.id, instance.name);
1195
+ var dependencies = findAllDependencies(instance.id, idConditionListMap);
1196
+ // console.log('当前组件所依赖项: ', dependencies);
1197
+ var currentDependenciesMappingComponent = _toConsumableArray(new Set(dependencies.concat(instance.id))).reduce(function (cur, nxt) {
1198
+ var _findValueDependencie, _findValueDependencie2;
1199
+ var mappingDependencies = (_findValueDependencie = findValueDependencies(nxt, mappingConfig.config)) === null || _findValueDependencie === void 0 ? void 0 : (_findValueDependencie2 = _findValueDependencie.dependencies) === null || _findValueDependencie2 === void 0 ? void 0 : _findValueDependencie2.map(function (item) {
1200
+ return item.sourceComponent;
1201
+ });
1202
+ cur = cur.concat(mappingDependencies);
1203
+ return cur;
1204
+ }, []);
1205
+ // console.log('当前组件所依赖项+值映射依赖项: ', currentDependenciesMappingComponent);
1206
+ // console.groupEnd();
1169
1207
  // 需要增加显隐处理逻辑
1170
1208
  return /*#__PURE__*/React.createElement(Form.Item, {
1171
1209
  noStyle: true,
1172
- shouldUpdate: function shouldUpdate() {
1173
- return true; // TODO: 修复重复依赖的问题 https://tb.raycloud.com/task/64e4491e0b8b5c001e1099b9
1174
- }
1210
+ dependencies: _toConsumableArray(new Set(dependencies.concat(currentDependenciesMappingComponent)))
1175
1211
  }, function (_ref8) {
1176
1212
  var getFieldValue = _ref8.getFieldValue;
1177
1213
  var show = currentIdDependenceOtherFields === null || currentIdDependenceOtherFields === void 0 ? void 0 : currentIdDependenceOtherFields.reduce(function (cur, nxt) {
@@ -1274,17 +1310,29 @@ var FormRender = function FormRender(props, ref) {
1274
1310
  var handleWatchFormValueChange = function handleWatchFormValueChange(changedValues) {
1275
1311
  var allValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1276
1312
  var componentShowMap = currentTemplateAllComponentsDisplay.current;
1277
- var formValue = getCalculationComponentValue({
1278
- calculationTypeComponentList: calculationTypeComponentList,
1279
- allValues: allValues,
1280
- componentShowMap: componentShowMap
1281
- });
1282
- form.setFieldsValue(_objectSpread(_objectSpread({}, allValues), formValue));
1313
+ var formValue = {};
1314
+ // FIXME: 计算组件存在,此处还可能出现性能问题
1315
+ if (calculationTypeComponentList.length > 0) {
1316
+ formValue = getCalculationComponentValue({
1317
+ calculationTypeComponentList: calculationTypeComponentList,
1318
+ allValues: allValues,
1319
+ componentShowMap: componentShowMap
1320
+ });
1321
+ if (!isMatch(allValues, formValue)) {
1322
+ form.setFieldsValue(_objectSpread(_objectSpread({}, allValues), formValue));
1323
+ }
1324
+ }
1325
+
1283
1326
  //缓存防止bs商品组件联动返填获取不到值
1284
1327
  setTimeout(function () {
1285
1328
  changeValuesCacheOrderInfo(_objectSpread(_objectSpread({}, form.getFieldsValue()), formValue), templateDetail === null || templateDetail === void 0 ? void 0 : templateDetail.componentDtoList);
1286
1329
  });
1287
1330
  };
1331
+ var debouncedHandleWatchFormValueChange = useMemo(function () {
1332
+ return debounce(handleWatchFormValueChange, 150);
1333
+ },
1334
+ // 150ms防抖
1335
+ [handleWatchFormValueChange]);
1288
1336
  var changeValuesCacheOrderInfo = throttle(function (value, tempLateList) {
1289
1337
  //如果店铺id不存在 不缓存
1290
1338
  if (!(value !== null && value !== void 0 && value.shopId)) return;
@@ -1398,7 +1446,7 @@ var FormRender = function FormRender(props, ref) {
1398
1446
  }, formProps), preNodeFormItems), /*#__PURE__*/React.createElement(Form, _extends({
1399
1447
  form: form
1400
1448
  }, formProps, {
1401
- onValuesChange: handleWatchFormValueChange
1449
+ onValuesChange: debouncedHandleWatchFormValueChange
1402
1450
  }), /*#__PURE__*/React.createElement(ShopName, {
1403
1451
  shopList: shopList,
1404
1452
  handleChangeShopId: handleChangeShopId,