@bit-sun/business-component 2.4.29 → 2.4.31-alpha.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.
@@ -0,0 +1,336 @@
1
+ // expression规则集合
2
+ //{
3
+ // complex,
4
+ // dataTypeCode,
5
+ // elementId,
6
+ // elementName,
7
+ // metaObjectCode,
8
+ // operationCode,
9
+ // operationType,
10
+ // paramNames: [],
11
+ // params: [],
12
+ // propertyPath,
13
+ // subExpression: [
14
+ // complex,
15
+ // dataTypeCode,
16
+ // elementId,
17
+ // elementName,
18
+ // metaObjectCode,
19
+ // operationCode,
20
+ // operationType,
21
+ // paramNames: [],
22
+ // params: [],
23
+ // propertyPath,
24
+ // subExpression: [.....] // 继续嵌套
25
+ // ]
26
+ // }
27
+ // result 执行返回值/执行动作
28
+ //{
29
+ // "return": {
30
+ // "enable": true,
31
+ // "value": "ticketId"
32
+ // },
33
+ // "execute": [
34
+ // {
35
+ // "priority": 1,
36
+ // "code": "functionCode",
37
+ // "properties": {
38
+ // "${logisticsNum}": "dasdadasdadas"
39
+ // }
40
+ // },
41
+ // {
42
+ // "priority": 2,
43
+ // "code": "",
44
+ // "properties": {
45
+ // "${detailList.skuCode}": "ccxcx",
46
+ // "${logisticsNum}": "cxcxcx"
47
+ // }
48
+ // }
49
+ // ]
50
+ // }
51
+ export const formatOperationList = (data: any) => {
52
+ let result = data||[];
53
+ result = result.concat([{
54
+ code: 32,
55
+ name: 'dateTime',
56
+ operationList: result.find((s: any)=> s.code ==41)?.operationList || []
57
+ }])
58
+ // 新版基础中对象字段编码valueType和旧版中valueType枚举不一致,如果没有取到符号值--需要排查数据后端是否做了映射转化; 按照oldValueType进行匹配符号和第三个参数框的
59
+ // const oldValueType = Object.freeze({
60
+ // 10: '对象',
61
+ // 21: '字符串',
62
+ // 23: '长整数',
63
+ // 22: '小数',
64
+ // 41: '日期',
65
+ // 40: '时间',
66
+ // 30: '数组',
67
+ // 24: '布尔值',
68
+ // });
69
+ // const newValueType = {
70
+ // 10: '字符串',
71
+ // 20: '短整数',
72
+ // 21: '长整数',
73
+ // 22: '小数',
74
+ // 40: '数组',
75
+ // 41: '布尔值',
76
+ // 12: '富文本',
77
+ // 30: '日期',
78
+ // 31: '时间',
79
+ // 32: '日期时间',
80
+ // }
81
+ return result;
82
+ };
83
+
84
+ export const formatRegularList = (data: any) => {
85
+ let result = data;
86
+ return result;
87
+ };
88
+
89
+ // 回显规则处理数据
90
+ export const handleRuleShowBack = (data: any, functionRuleList: any) => {
91
+ let result = data?.map((item: any, index: number) => {
92
+ const handleResult = {
93
+ response: {
94
+ inputType: item?.result?.response?.inputType,
95
+ formulaName: item?.result?.response?.formulaName,
96
+ enable: item?.result?.response?.enable !== false,
97
+ value: item?.result?.response?.value || '',
98
+ },
99
+ execute:
100
+ (functionRuleList?.length &&
101
+ functionRuleList.map((s: any, index: number) => {
102
+ const Item = (item?.result?.execute || []).find(
103
+ (u: any) => u.code === s.code,
104
+ );
105
+ if (Item) {
106
+ return {
107
+ ...Item,
108
+ properties: Item?.frontendProperties || Item?.properties,
109
+ isSelected: true,
110
+ };
111
+ }
112
+ return {
113
+ priority: index + 1,
114
+ code: s.code,
115
+ properties: {
116
+ configPropertyCode: 'configPropertyValue',
117
+ },
118
+ };
119
+ })) ||
120
+ [],
121
+ };
122
+ const restObject = {
123
+ extraInfo: handleResult,
124
+ id: item.id,
125
+ ruleId: item.ruleId,
126
+ priority: item.priority,
127
+ status: item.status,
128
+ extStrField01: item?.extStrField01,
129
+ name: item?.name,
130
+ };
131
+ if (item?.expression) {
132
+ return {
133
+ ruleName: item.ruleName || `规则${index + 1}`,
134
+ subExpression: item.expression,
135
+ ...restObject,
136
+ };
137
+ } else {
138
+ return {
139
+ ruleName: `规则${index + 1}`,
140
+ subExpression: {
141
+ expressionType: 'relation',
142
+ operationType: 'relation',
143
+ propertyPath: '',
144
+ params: [],
145
+ paramNames: [],
146
+ },
147
+ ...restObject,
148
+ };
149
+ }
150
+ });
151
+ return result;
152
+ };
153
+
154
+ const isNoEmpty = (data: any) =>
155
+ (Array.isArray(data) && data.length > 0) ||
156
+ !(data == null || data == undefined || String(data).trim() == '');
157
+
158
+ // 校验执行动作必填数据
159
+ export const handleRuleRequireCheck = (saveData: any, ruleActionData: any) => {
160
+ let checkResult = false; // 默认通过校验
161
+ const checkInfo: any = []; // 没有选必填执行动作(暂不考虑);执行动作下的对象未选
162
+ if (Array.isArray(ruleActionData) && ruleActionData?.length && Array.isArray(saveData) && saveData.length) {
163
+ let requireList: any = [];
164
+ ruleActionData.forEach((s: any) => {
165
+ s.valueList.forEach((n: any) => {
166
+ if (n.required) {
167
+ if (requireList.some((m: any) => m.functionCode === s.code)) {
168
+ requireList = requireList.map((k: any) => {
169
+ if (k.functionCode === s.code) {
170
+ k.propertiesCode = [...k.propertiesCode, ...n.code];
171
+ }
172
+ return k;
173
+ });
174
+ } else {
175
+ requireList.push({
176
+ functionCode: s.code,
177
+ functionName: s.functionName,
178
+ propertiesCode: [n.code],
179
+ });
180
+ }
181
+ }
182
+ });
183
+ });
184
+
185
+ requireList?.length &&
186
+ saveData.forEach((s: any, index: number) => {
187
+ s.result.execute.length &&
188
+ s.result.execute.forEach((e: any) => {
189
+ if (requireList.some((r: any) => r.functionCode === e.code)) {
190
+ const currentRequireList = requireList.find(
191
+ (r: any) => r.functionCode === e.code,
192
+ );
193
+ const currentPropertiesCode = currentRequireList.propertiesCode;
194
+ const isComplete = currentPropertiesCode.every((c: any) =>
195
+ Object.keys(e.properties).some(
196
+ (p: any) => p === c && isNoEmpty(e.properties[p]),
197
+ ),
198
+ );
199
+ if (!isComplete) {
200
+ checkResult = true;
201
+ checkInfo.push(
202
+ `规则${index + 1}: 执行动作【${
203
+ currentRequireList.functionName
204
+ }】信息填写不完整`,
205
+ );
206
+ }
207
+ }
208
+ });
209
+ });
210
+ }
211
+ return { checkResult, checkInfo };
212
+ };
213
+
214
+ function isObj(object: any) {
215
+ return (
216
+ object &&
217
+ typeof object == 'object' &&
218
+ Object.prototype.toString.call(object).toLowerCase() == '[object object]'
219
+ );
220
+ }
221
+
222
+ // 保存规则处理数据
223
+ export const handleRuleResultList = (data: any, ruleTypeData: any) => {
224
+ let result = data || [];
225
+ if (Array.isArray(result) && result?.length) {
226
+ result = result.map((i: any) => {
227
+ return {
228
+ expression: i?.subExpression, // 左侧规则
229
+ result: {
230
+ ...i?.extraInfo,
231
+ ...(i?.extraInfo.execute
232
+ ? {
233
+ execute: i?.extraInfo.execute
234
+ .filter((s: any) => s.isSelected)
235
+ ?.map((s: any) => {
236
+ const saveP = s.properties;
237
+ // 处理在执行动作配置中设置了默认值的
238
+ const ruleValueList = ruleTypeData.find(
239
+ (r: any) => r.code === s.code,
240
+ )?.valueList;
241
+ if (ruleValueList?.length) {
242
+ ruleValueList.forEach((r: any) => {
243
+ if (
244
+ r.defaultValue &&
245
+ r?.inputType === 10 &&
246
+ r?.valueType === 21 &&
247
+ saveP[r.code] === undefined
248
+ ) {
249
+ saveP[r.code] = ' ';
250
+ } else if (r.defaultValue && !saveP[r.code]) {
251
+ saveP[r.code] = r.defaultValue;
252
+ }
253
+ });
254
+ }
255
+
256
+ delete saveP.configPropertyCode;
257
+ // 前端所需回显数据
258
+ s.frontendProperties = { ...s.properties };
259
+ // 格式化后端需要的数据
260
+ Object.keys(s.properties).forEach((p: any) => {
261
+ const v = s.properties[p];
262
+ if (Array.isArray(v)) {
263
+ s.properties = {
264
+ ...s.properties,
265
+ [p]: v.map((m: any) => m.value || m).join(','),
266
+ };
267
+ }
268
+ if (isObj(v)) {
269
+ s.properties = {
270
+ ...s.properties,
271
+ [p]: v.value || v.PCDCode?.join('/'),
272
+ };
273
+ }
274
+ });
275
+ return s;
276
+ }),
277
+ }
278
+ : {}),
279
+ }, // 右侧信息
280
+ ruleName: i.ruleName,
281
+ ruleId: i.ruleId,
282
+ id: i.id,
283
+ priority: i.priority,
284
+ status: i.status,
285
+ extStrField01: i?.extStrField01,
286
+ name: i?.name,
287
+ };
288
+ });
289
+ }
290
+ return result;
291
+ };
292
+
293
+ export const getInitClassData = (ruleTypeData: any) => {
294
+ const initClassData = [
295
+ {
296
+ ruleName: `规则1`,
297
+ subExpression: {
298
+ // "expressionType": "relation",
299
+ operationType: 'relation',
300
+ propertyPath: '',
301
+ params: [],
302
+ paramNames: [],
303
+ },
304
+ extraInfo: {
305
+ response: {
306
+ enable: false,
307
+ value: '',
308
+ },
309
+ execute: ruleTypeData?.map((s: any) => {
310
+ return {
311
+ priority: 1,
312
+ code: s.code,
313
+ properties: {
314
+ configPropertyCode: 'configPropertyValue',
315
+ },
316
+ };
317
+ }),
318
+ },
319
+ },
320
+ ];
321
+ return initClassData;
322
+ };
323
+
324
+ export const formatGroupOtherPriorityList = (data: any, templateId: string) => {
325
+ const result = data.filter((i: any) => i.templateId !== templateId);
326
+ return result;
327
+ };
328
+ export const formatOtherPriorityList = (
329
+ data: any,
330
+ templateId: string,
331
+ extStr: string,
332
+ ) => {
333
+ return data.filter(
334
+ (i: any) => i.templateId != templateId || i.extStrField01 != extStr,
335
+ );
336
+ };
@@ -0,0 +1,221 @@
1
+ .goBack_btn_content {
2
+ position: relative;
3
+ overflow: auto;
4
+ .goback_btn {
5
+ float: right;
6
+ }
7
+ }
8
+ .base_rule {
9
+ p {
10
+ margin: 0;
11
+ }
12
+
13
+ .base_rule_content {
14
+ margin-bottom: 20px;
15
+ }
16
+
17
+ .base_rule_line_title {
18
+ position: relative;
19
+ margin-bottom: 20px;
20
+ .rule_title {
21
+ height: 35px;
22
+ padding: 0 10px;
23
+ font-weight: bold;
24
+ font-size: 16px;
25
+ line-height: 35px;
26
+ }
27
+ .base_rule_btn_style {
28
+ position: absolute;
29
+ right: 0px;
30
+ }
31
+ //:global {
32
+ // .ant-btn-link {
33
+ // color: #008FE0;
34
+ // border: 0px !important;
35
+ // font-weight: bold;
36
+ // }
37
+ //
38
+ // .ant-btn-link:hover, .ant-btn-link:focus {
39
+ // color: #008FE0;
40
+ // background-color: transparent;
41
+ // border-color: #008FE0;
42
+ // border: 0px;
43
+ // }
44
+ //
45
+ // .ant-btn:not(.ant-btn-primary .ant-btn-danger):hover,
46
+ // .ant-btn:not(.ant-btn-primary .ant-btn-danger):active,
47
+ // .ant-btn:not(.ant-btn-primary .ant-btn-danger):focus {
48
+ // color: #008FE0;
49
+ // }
50
+ //}
51
+ }
52
+
53
+ .base_rule_line_content {
54
+ display: flex;
55
+ padding: 14px 10px 10px;
56
+ .base_rule_icon_btn {
57
+ margin-right: 10px;
58
+ color: #89b9cf;
59
+ font-size: 20px;
60
+ }
61
+
62
+ .base_rule_icon_btn:hover {
63
+ cursor: pointer;
64
+ }
65
+
66
+ .base_rule_item_desc_content {
67
+ height: 45px;
68
+ line-height: 45px;
69
+ }
70
+
71
+ .base_rule_item_desc {
72
+ margin-right: 15px;
73
+ }
74
+
75
+ .base_rule_item1 {
76
+ align-items: center;
77
+ width: 120px;
78
+ color: #f8ab3c;
79
+ font-size: 16px;
80
+ }
81
+
82
+ .base_rule_item2 {
83
+ width: 1200px;
84
+ }
85
+
86
+ .base_rule_item3 {
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: space-around;
90
+ width: calc(100% - 600px);
91
+ }
92
+
93
+ .line_color_red {
94
+ color: #ed869b;
95
+ }
96
+
97
+ .base_rule_item4 {
98
+ width: 80px;
99
+ }
100
+ }
101
+
102
+ .footer_line {
103
+ & > span {
104
+ color: #008fe0;
105
+ font-weight: bold;
106
+ font-size: 16px;
107
+ }
108
+ }
109
+ }
110
+
111
+ .rule_name_title {
112
+ display: inline-block;
113
+ height: 30px;
114
+ margin-right: 10px;
115
+ margin-bottom: 10px;
116
+ padding-left: 10px;
117
+ color: #f8ab3c;
118
+ font-size: 16px;
119
+ line-height: 30px;
120
+ }
121
+
122
+ .logical_operate_content {
123
+ position: relative;
124
+ .top_line {
125
+ position: absolute;
126
+ top: 0;
127
+ left: 50%;
128
+ z-index: 999;
129
+ width: 15px;
130
+ height: 2px;
131
+ background-color: #d6efe8;
132
+ }
133
+ .bottom_line {
134
+ position: absolute;
135
+ bottom: 0;
136
+ left: 50%;
137
+ z-index: 999;
138
+ width: 15px;
139
+ height: 2px;
140
+ background-color: #d6efe8;
141
+ }
142
+ }
143
+
144
+ .logical_operate_content::before {
145
+ position: absolute;
146
+ top: 0;
147
+ left: 50%;
148
+ z-index: 998;
149
+ width: 2px;
150
+ height: 100%;
151
+ overflow: hidden;
152
+ background: #d6efe8;
153
+ content: ' ';
154
+ }
155
+
156
+ .logical_item_btn {
157
+ position: absolute;
158
+ top: 50%;
159
+ left: 50%;
160
+ z-index: 999;
161
+ display: flex;
162
+ align-items: center;
163
+ width: 50px;
164
+ height: 30px;
165
+ margin-top: -15px;
166
+ margin-left: -25px;
167
+ padding: 0px;
168
+ color: #008fe0;
169
+ line-height: 30px;
170
+ text-align: center;
171
+ background-color: #ffffff;
172
+ cursor: pointer;
173
+ }
174
+
175
+ .logical_item_btn1 {
176
+ position: absolute;
177
+ bottom: 0;
178
+ left: 50%;
179
+ z-index: 999;
180
+ display: inline-block;
181
+ width: 30px;
182
+ height: 30px;
183
+ margin-left: -15px;
184
+ color: #008fe0;
185
+ line-height: 30px;
186
+ text-align: center;
187
+ background-color: #ffffff;
188
+ cursor: pointer;
189
+ }
190
+
191
+ .rule_field_style {
192
+ display: inline-block;
193
+ }
194
+
195
+ .icon_btn_style {
196
+ margin-right: 10px;
197
+ font-size: 20px;
198
+ }
199
+
200
+ .choose_logical_type {
201
+ height: 25px;
202
+ margin: 0px;
203
+ padding: 0 10px;
204
+ line-height: 25px;
205
+ cursor: pointer;
206
+ }
207
+
208
+ .choose_logical_type:first-child {
209
+ border-bottom: 1px solid #d9d9d9;
210
+ }
211
+
212
+ .choose_logical_type:hover {
213
+ color: white;
214
+ background-color: #008fe0;
215
+ }
216
+
217
+ // :global {
218
+ // .ant-popover-inner-content {
219
+ // padding: 0px;
220
+ // }
221
+ // }