@kmkf-fe-packages/kmkf-work-order-service-component 2.2.5 → 2.3.0-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.
- package/dist/esm/CustomerServiceToDoList/index.d.ts +3 -0
- package/dist/esm/CustomerServiceToDoList/index.js +155 -0
- package/dist/esm/CustomerServiceToDoList/index.module.less +134 -0
- package/dist/esm/FlowTemplateDetailV2/common.js +1 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/component-dependency-finder.d.ts +75 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/component-dependency-finder.js +328 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/index.js +84 -36
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/types.d.ts +41 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/types.js +1 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/value-mapping-finder.d.ts +61 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/value-mapping-finder.js +292 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/value-mapping-types.d.ts +65 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/value-mapping-types.js +1 -0
- package/dist/esm/FlowTemplateDetailV2/index.js +12 -4
- package/dist/esm/WorkOrder/components/CustomerServiceToDoCard/index.d.ts +3 -0
- package/dist/esm/WorkOrder/components/CustomerServiceToDoCard/index.js +76 -0
- package/dist/esm/WorkOrder/components/CustomerServiceToDoCard/index.module.less +20 -0
- package/dist/esm/WorkOrder/components/WorkOrderList/components/CustomizeWorkOrderCard/index.js +6 -0
- package/dist/esm/WorkOrder/components/WorkOrderList/index.js +7 -2
- package/dist/esm/WorkOrder/components/WorkOrderList/index.less +4 -3
- package/dist/esm/WorkOrder/index.js +21 -1
- package/dist/esm/common/constant.d.ts +5 -0
- package/dist/esm/common/constant.js +3 -2
- package/dist/esm/common/imgs/ai.png +0 -0
- package/dist/esm/common/imgs/notification.png +0 -0
- package/dist/esm/common/utils/xzSDK.d.ts +2 -0
- package/dist/esm/common/utils/xzSDK.js +45 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/model/customizeWorkOrder/index.d.ts +1 -1
- package/dist/esm/model/customizeWorkOrder/index.js +17 -3
- package/dist/esm/model/customizeWorkOrder/types.d.ts +2 -0
- package/dist/esm/model/servers/api.d.ts +1 -0
- package/dist/esm/model/servers/api.js +9 -0
- package/package.json +5 -5
|
@@ -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, onBlurSkxOutboundNoticeNo } 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 =
|
|
653
|
+
_context2.next = 9;
|
|
640
654
|
break;
|
|
641
655
|
}
|
|
642
|
-
setLabelList(
|
|
643
|
-
|
|
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
|
|
646
|
-
_context2.next =
|
|
664
|
+
case 9:
|
|
665
|
+
_context2.next = 11;
|
|
647
666
|
return queryLabelByTradeId({
|
|
648
667
|
tid: tid,
|
|
649
668
|
shopId: shopId
|
|
650
669
|
});
|
|
651
|
-
case
|
|
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(
|
|
656
|
-
|
|
657
|
-
|
|
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 =
|
|
712
|
+
_context3.next = 8;
|
|
688
713
|
break;
|
|
689
714
|
}
|
|
690
|
-
|
|
715
|
+
if (oldMemberLevel.length !== 0) {
|
|
716
|
+
form.setFieldsValue(_defineProperty({}, "".concat(labelComponent.uniqueKey), []));
|
|
717
|
+
}
|
|
691
718
|
return _context3.abrupt("return", console.debug('查询标签缺少必要参数-tradeId'));
|
|
692
|
-
case
|
|
693
|
-
_context3.next =
|
|
719
|
+
case 8:
|
|
720
|
+
_context3.next = 10;
|
|
694
721
|
return queryMemberLevel({
|
|
695
722
|
tid: tid,
|
|
696
723
|
shopId: shopId
|
|
697
724
|
});
|
|
698
|
-
case
|
|
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
|
-
|
|
703
|
-
|
|
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
|
}
|
|
@@ -903,6 +932,9 @@ var FormRender = function FormRender(props, ref) {
|
|
|
903
932
|
break;
|
|
904
933
|
}
|
|
905
934
|
setReplaceValue(function (prev) {
|
|
935
|
+
if (isMatch(prev, _defineProperty({}, type, 0))) {
|
|
936
|
+
return prev;
|
|
937
|
+
}
|
|
906
938
|
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, type, 0));
|
|
907
939
|
});
|
|
908
940
|
replaceValueRef.current = _objectSpread(_objectSpread({}, replaceValue), {}, _defineProperty({}, type, 0));
|
|
@@ -1091,13 +1123,6 @@ var FormRender = function FormRender(props, ref) {
|
|
|
1091
1123
|
if (Reflect.has(currentComponentDisplayStatus.current, prefixId) && !currentComponentDisplayStatus.current[prefixId]) {
|
|
1092
1124
|
return false;
|
|
1093
1125
|
}
|
|
1094
|
-
// console.debug(
|
|
1095
|
-
// '显影计算',
|
|
1096
|
-
// dependenceDetail?.type,
|
|
1097
|
-
// leftValue,
|
|
1098
|
-
// item.compareSymbol?.toUpperCase(),
|
|
1099
|
-
// item.rightValue,
|
|
1100
|
-
// );
|
|
1101
1126
|
return getExpression((_item$compareSymbol = item.compareSymbol) === null || _item$compareSymbol === void 0 ? void 0 : _item$compareSymbol.toUpperCase(), leftValue, item.rightValue);
|
|
1102
1127
|
};
|
|
1103
1128
|
var getDisplayAndDisabledConfig = function getDisplayAndDisabledConfig(config) {
|
|
@@ -1184,12 +1209,23 @@ var FormRender = function FormRender(props, ref) {
|
|
|
1184
1209
|
currentTemplateAllComponentsDisplay.current[instance === null || instance === void 0 ? void 0 : instance.id] = true;
|
|
1185
1210
|
if (Reflect.has(idConditionListMap, instance.id)) {
|
|
1186
1211
|
var currentIdDependenceOtherFields = idConditionListMap[instance.id];
|
|
1212
|
+
// console.group('当前组件', instance.id, instance.name);
|
|
1213
|
+
var dependencies = findAllDependencies(instance.id, idConditionListMap);
|
|
1214
|
+
// console.log('当前组件所依赖项: ', dependencies);
|
|
1215
|
+
var currentDependenciesMappingComponent = _toConsumableArray(new Set(dependencies.concat(instance.id))).reduce(function (cur, nxt) {
|
|
1216
|
+
var _findValueDependencie, _findValueDependencie2;
|
|
1217
|
+
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) {
|
|
1218
|
+
return item.sourceComponent;
|
|
1219
|
+
});
|
|
1220
|
+
cur = cur.concat(mappingDependencies);
|
|
1221
|
+
return cur;
|
|
1222
|
+
}, []);
|
|
1223
|
+
// console.log('当前组件所依赖项+值映射依赖项: ', currentDependenciesMappingComponent);
|
|
1224
|
+
// console.groupEnd();
|
|
1187
1225
|
// 需要增加显隐处理逻辑
|
|
1188
1226
|
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
1189
1227
|
noStyle: true,
|
|
1190
|
-
|
|
1191
|
-
return true; // TODO: 修复重复依赖的问题 https://tb.raycloud.com/task/64e4491e0b8b5c001e1099b9
|
|
1192
|
-
}
|
|
1228
|
+
dependencies: _toConsumableArray(new Set(dependencies.concat(currentDependenciesMappingComponent)))
|
|
1193
1229
|
}, function (_ref8) {
|
|
1194
1230
|
var getFieldValue = _ref8.getFieldValue;
|
|
1195
1231
|
var show = currentIdDependenceOtherFields === null || currentIdDependenceOtherFields === void 0 ? void 0 : currentIdDependenceOtherFields.reduce(function (cur, nxt) {
|
|
@@ -1292,17 +1328,29 @@ var FormRender = function FormRender(props, ref) {
|
|
|
1292
1328
|
var handleWatchFormValueChange = function handleWatchFormValueChange(changedValues) {
|
|
1293
1329
|
var allValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1294
1330
|
var componentShowMap = currentTemplateAllComponentsDisplay.current;
|
|
1295
|
-
var formValue =
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1331
|
+
var formValue = {};
|
|
1332
|
+
// FIXME: 计算组件存在,此处还可能出现性能问题
|
|
1333
|
+
if (calculationTypeComponentList.length > 0) {
|
|
1334
|
+
formValue = getCalculationComponentValue({
|
|
1335
|
+
calculationTypeComponentList: calculationTypeComponentList,
|
|
1336
|
+
allValues: allValues,
|
|
1337
|
+
componentShowMap: componentShowMap
|
|
1338
|
+
});
|
|
1339
|
+
if (!isMatch(allValues, formValue)) {
|
|
1340
|
+
form.setFieldsValue(_objectSpread(_objectSpread({}, allValues), formValue));
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1301
1344
|
//缓存防止bs商品组件联动返填获取不到值
|
|
1302
1345
|
setTimeout(function () {
|
|
1303
1346
|
changeValuesCacheOrderInfo(_objectSpread(_objectSpread({}, form.getFieldsValue()), formValue), templateDetail === null || templateDetail === void 0 ? void 0 : templateDetail.componentDtoList);
|
|
1304
1347
|
});
|
|
1305
1348
|
};
|
|
1349
|
+
var debouncedHandleWatchFormValueChange = useMemo(function () {
|
|
1350
|
+
return debounce(handleWatchFormValueChange, 150);
|
|
1351
|
+
},
|
|
1352
|
+
// 150ms防抖
|
|
1353
|
+
[handleWatchFormValueChange]);
|
|
1306
1354
|
var changeValuesCacheOrderInfo = throttle(function (value, tempLateList) {
|
|
1307
1355
|
//如果店铺id不存在 不缓存
|
|
1308
1356
|
if (!(value !== null && value !== void 0 && value.shopId)) return;
|
|
@@ -1416,7 +1464,7 @@ var FormRender = function FormRender(props, ref) {
|
|
|
1416
1464
|
}, formProps), preNodeFormItems), /*#__PURE__*/React.createElement(Form, _extends({
|
|
1417
1465
|
form: form
|
|
1418
1466
|
}, formProps, {
|
|
1419
|
-
onValuesChange:
|
|
1467
|
+
onValuesChange: debouncedHandleWatchFormValueChange
|
|
1420
1468
|
}), /*#__PURE__*/React.createElement(ShopName, {
|
|
1421
1469
|
shopList: shopList,
|
|
1422
1470
|
handleChangeShopId: handleChangeShopId,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 组件显隐配置相关类型定义
|
|
3
|
+
*/
|
|
4
|
+
export declare type CompareSymbol = 'eq' | 'include' | 'ne' | 'gt' | 'lt' | 'gte' | 'lte';
|
|
5
|
+
export declare type LinkCondition = 'some' | 'every';
|
|
6
|
+
export interface Rule {
|
|
7
|
+
compareSymbol: CompareSymbol;
|
|
8
|
+
leftValue: string;
|
|
9
|
+
rightValue: string | string[] | number | boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface RuleGroup {
|
|
12
|
+
linkCondition: LinkCondition;
|
|
13
|
+
rules: Rule[];
|
|
14
|
+
}
|
|
15
|
+
export declare type ComponentConfig = RuleGroup[];
|
|
16
|
+
export interface Config {
|
|
17
|
+
[componentKey: string]: ComponentConfig;
|
|
18
|
+
}
|
|
19
|
+
export interface DependencyGraph {
|
|
20
|
+
[componentKey: string]: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare type CircularDependency = string[];
|
|
23
|
+
export interface DependencyLevels {
|
|
24
|
+
[level: number]: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface ComponentStat {
|
|
27
|
+
key: string;
|
|
28
|
+
count: number;
|
|
29
|
+
}
|
|
30
|
+
export interface DependencyOptions {
|
|
31
|
+
maxDepth?: number;
|
|
32
|
+
includeCircular?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface DependencyAnalysis {
|
|
35
|
+
componentKey: string;
|
|
36
|
+
directDependencies: string[];
|
|
37
|
+
allDependencies: string[];
|
|
38
|
+
dependencyCount: number;
|
|
39
|
+
dependencyLevels: DependencyLevels;
|
|
40
|
+
hasCircularDependency: boolean;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 组件值映射依赖关系查找器 - TypeScript ES Module版本
|
|
3
|
+
* 根据值映射配置查找组件之间的依赖关系
|
|
4
|
+
*/
|
|
5
|
+
import type { ValueMappingConfig, ValueDependencyResult } from './value-mapping-types.js';
|
|
6
|
+
/**
|
|
7
|
+
* 查找组件的所有反向依赖(哪些组件会影响当前组件的值)
|
|
8
|
+
* @param targetComponentKey - 目标组件key
|
|
9
|
+
* @param config - 值映射配置对象
|
|
10
|
+
* @returns 反向依赖关系结果
|
|
11
|
+
*/
|
|
12
|
+
export declare function findValueDependencies(targetComponentKey: string, config: ValueMappingConfig): ValueDependencyResult;
|
|
13
|
+
/**
|
|
14
|
+
* 查找所有组件的反向依赖关系
|
|
15
|
+
* @param config - 值映射配置对象
|
|
16
|
+
* @returns 所有组件的反向依赖关系图
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildValueDependencyGraph(config: ValueMappingConfig): Record<string, ValueDependencyResult>;
|
|
19
|
+
/**
|
|
20
|
+
* 查找特定源组件和值对目标组件的影响
|
|
21
|
+
* @param sourceComponentKey - 源组件key
|
|
22
|
+
* @param sourceValue - 源组件的值
|
|
23
|
+
* @param config - 值映射配置对象
|
|
24
|
+
* @returns 受影响的目标组件及其值
|
|
25
|
+
*/
|
|
26
|
+
export declare function findTargetsBySourceValue(sourceComponentKey: string, sourceValue: string, config: ValueMappingConfig): Array<{
|
|
27
|
+
targetComponent: string;
|
|
28
|
+
targetValue: string;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* 获取所有源组件的统计信息
|
|
32
|
+
* @param config - 值映射配置对象
|
|
33
|
+
* @returns 源组件统计信息
|
|
34
|
+
*/
|
|
35
|
+
export declare function getSourceComponentStats(config: ValueMappingConfig): Array<{
|
|
36
|
+
componentKey: string;
|
|
37
|
+
valueCount: number;
|
|
38
|
+
targetCount: number;
|
|
39
|
+
totalMappings: number;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* 查找值映射链(A影响B,B影响C的传递关系)
|
|
43
|
+
* @param startComponent - 起始组件
|
|
44
|
+
* @param config - 值映射配置对象
|
|
45
|
+
* @param maxDepth - 最大深度
|
|
46
|
+
* @returns 映射链
|
|
47
|
+
*/
|
|
48
|
+
export declare function findValueMappingChain(startComponent: string, config: ValueMappingConfig, maxDepth?: number): Array<{
|
|
49
|
+
chain: string[];
|
|
50
|
+
depth: number;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* 验证值映射配置的格式
|
|
54
|
+
* @param config - 要验证的配置对象
|
|
55
|
+
* @returns 验证结果
|
|
56
|
+
*/
|
|
57
|
+
export declare function validateValueMappingConfig(config: unknown): {
|
|
58
|
+
isValid: boolean;
|
|
59
|
+
errors: string[];
|
|
60
|
+
warnings: string[];
|
|
61
|
+
};
|