resolver-egretimp-plus 0.1.115 → 0.1.116

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,257 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * rule
4
+ * {
5
+ "eventId": "0",
6
+ "relId": "100000000000006",
7
+ "targetEventId": "0",
8
+ "targetObj": "--",
9
+ "targetObjVal": null,
10
+ "updateTime": "2023-04-13 20:14:13",
11
+ "updateOperId": "72523",
12
+ "targetMsg": null,
13
+ "eventRefValue": null,
14
+ "createTime": "2023-04-13 20:14:13",
15
+ "targetMsgEn": null,
16
+ "state": "0",
17
+ "ruleId": "100000000000006",
18
+ "createOperId": "72523",
19
+ "eventCode": null,
20
+ "eventName": null,
21
+ "remark": null,
22
+ "id": null,
23
+ "ruleType": "1",
24
+ "eventExpress": "{\"relation\":1,\"conditions\":[{\"refCode\":\"xiangmuxinxi->CustomerName\",\"refName\":\"项目信息->客户名称\",\"refNameEn\":\"xiangmuxinxi->Customer Name\",\"symbol\":1,\"type\":1,\"targetValue\":\"xiangmuxinxi->Businesstype\",\"targetName\":\"项目信息->业务类型\",\"targetNameEn\":\"xiangmuxinxi->Business type\"}]}",
25
+ "eventType": null,
26
+ "pmRuleTargetEventVoList": [
27
+ {
28
+ "targetEventId": "1002",
29
+ "relId": "100000000000006",
30
+ "eventId": "0",
31
+ "eventCode": null,
32
+ "actionType": "0",
33
+ "targetObj": "xiangmuxinxi->dutyparagraph",
34
+ "targetObjVal": null,
35
+ "targetMsg": null,
36
+ "targetMsgEn": null,
37
+ "state": "1",
38
+ "createTime": "2023-04-13 20:14:13",
39
+ "createOperId": "72523",
40
+ "updateTime": "2023-04-13 20:14:13",
41
+ "updateOperId": "72523"
42
+ }
43
+ ]
44
+ }
45
+
46
+ eventExpress
47
+ * {
48
+ relation: 1, // 1: 与;2: 或
49
+ conditions: [
50
+ {
51
+ refCode: '', // 这个表格引用的字段,这边是使用->连接code
52
+ refName: 'aa', // 这边表示引用的字段描述,主要是配置化工具那边的展示
53
+ symbol: 1, // 1: >;2: >=; 3: <;4: <=;5: ==;6: !=;
54
+ type: 1, // 1: 组件;2: 系统参数; 3: 手动输入
55
+ targetValue: 'bb', // 这边是对比的值,可以跟refCode一样的值,也可以是具体的值,根据type进行生效
56
+ targetName: 'cc' // 这边在targetValue跟refcode一样时,跟refName一样的效果
57
+ targetName_en: 'cc' // // 这边在targetValue跟refcode一样时,跟refName一样的效果
58
+ },
59
+ {
60
+ refCode: '',
61
+ refName: '22',
62
+ symbol: 1, // 1: >;2: >=; 3: <;4: <=;5: ==;6: !=; 7: include; 8: no include
63
+ type: 3, // 1: 组件;2: 系统参数; 3: 手动输入
64
+ targetValue: '33',
65
+ targetName: 'c44c'
66
+ targetName_en: 'c44c'
67
+ }
68
+ ]
69
+ }
70
+ */
71
+ import { getConfigValue, getCurrentComp, parseRules } from './ruleUtils'
72
+ import {formatDate, isArray} from '../utils/index'
73
+
74
+ export const rulesTypes = {
75
+ constrast: '1',
76
+ nonNull: '2',
77
+ regular: '3',
78
+ enumeration: '4',
79
+ event: '5'
80
+ }
81
+ export const conditionType = {
82
+ COMPONENT: 1, // 1: 组件
83
+ SYSTEM: 2, // 2: 系统参数
84
+ SELF: 3, // 3: 手动输入
85
+ COMPONENT_ENMU: 4, // 组件枚举
86
+ NULL: 5 // 空
87
+ }
88
+
89
+ const calcConditionValue = {
90
+ [conditionType.COMPONENT]({rootValue, currentPath, value}) {
91
+ let refVal = getConfigValue(rootValue, value, currentPath)
92
+ return refVal
93
+ },
94
+ [conditionType.SYSTEM]: ({value}) => {
95
+ return getSystemArgVal(value)
96
+ },
97
+ [conditionType.SELF]: ({value}) => {
98
+ return value
99
+ },
100
+ [conditionType.COMPONENT_ENMU]: ({value}) => {
101
+ return value
102
+ },
103
+ [conditionType.NULL]: () => {
104
+ return null
105
+ }
106
+ }
107
+
108
+ export function parseCondition({
109
+ rule,
110
+ rootValue,
111
+ currentPath
112
+ }) {
113
+ debugger
114
+ const { eventExpress } = rule || {}
115
+ if (!eventExpress) return false
116
+
117
+ const expressObj = JSON.parse(eventExpress)
118
+ const { relation, conditions } = expressObj
119
+
120
+ const conditionsRet = conditions.map(condition => {
121
+ const { refType, refValue, targetType, targetValue } = condition
122
+
123
+ if (!calcConditionValue[refType]) return false
124
+ let refVal = calcConditionValue[refType]({rootValue, currentPath, value: refValue})
125
+
126
+ if (!calcConditionValue[targetType]) return false
127
+ let targetVal = calcConditionValue[targetType]({rootValue, currentPath, value: targetValue})
128
+
129
+ refVal = (refVal === undefined || refVal === null) ? '' : refVal
130
+ targetVal = (targetVal === undefined || targetVal === null) ? '' : targetVal
131
+
132
+ let formatRefVal = refVal
133
+ let formatTargetVal = targetVal
134
+ if (refVal == Number(refVal) && targetVal == Number(targetVal)) {
135
+ formatRefVal = Number(refVal)
136
+ formatTargetVal = Number(targetVal)
137
+ }
138
+ switch (condition.symbol) {
139
+ case 1:
140
+ return formatRefVal > formatTargetVal
141
+ case 2:
142
+ return formatRefVal >= formatTargetVal
143
+ case 3:
144
+ return formatRefVal < formatTargetVal
145
+ case 4:
146
+ return formatRefVal <= formatTargetVal
147
+ case 5:
148
+ return refVal == targetVal || (!targetVal && isArray(refVal) && !refVal.length)
149
+ case 6:
150
+ return refVal != targetVal
151
+ case 7:
152
+ if (typeof refVal === 'number') refVal = `${refVal}`
153
+ if (Array.isArray(refVal) || typeof refVal === 'string') {
154
+ return refVal.indexOf(targetVal) > -1
155
+ }
156
+ return false
157
+ case 8:
158
+ if (['string', 'number'].includes(typeof targetVal)) {
159
+ const reg = new RegExp(targetVal)
160
+ return reg.test(refVal)
161
+ }
162
+ return false
163
+ default:
164
+ return false
165
+ }
166
+ })
167
+ const ret = conditionsRet[relation == 1 ? 'every' : 'some'](item => item)
168
+ return ret
169
+ }
170
+
171
+ export function getCodeMapRules(config) {
172
+ const rules = parseRules(config)
173
+ return codeMapRules(rules)
174
+ }
175
+
176
+ export function codeMapRules(rules = []) {
177
+ const mapObj = {}
178
+ rules.forEach(rule => {
179
+ const keyEvents = parseRuleForRefCodeAndEvents(rule)
180
+ if (keyEvents && keyEvents.length) {
181
+ keyEvents.forEach(keyEvent => {
182
+ const { key = '', rules = [] } = keyEvent
183
+ if (mapObj[key]) {
184
+ rules.forEach(rule => {
185
+ if (!mapObj[key]?.some(itemR => itemR?.relId === rule?.relId)) {
186
+ mapObj[key].push(rule)
187
+ }
188
+ })
189
+ } else {
190
+ mapObj[key] = rules
191
+ }
192
+ })
193
+ }
194
+ })
195
+ return mapObj
196
+ }
197
+
198
+ export function parseRuleForRefCodeAndEvents(rule) {
199
+ const codeRules = []
200
+ const { eventExpress, pmRuleTargetEventVoList: eventList, tabpanelCode } = rule || {}
201
+ if (!eventExpress) return false
202
+ const expressObj = JSON.parse(eventExpress)
203
+ const { conditions = [] } = expressObj
204
+ conditions.forEach(condition => {
205
+ if (condition.refType == conditionType.COMPONENT || condition.targetType == conditionType.COMPONENT) {
206
+ if (condition.refType == conditionType.COMPONENT) {
207
+ codeRules.push({
208
+ key: tabpanelCode ? `${tabpanelCode}->${condition.refCode || condition.refValue}` : condition.refCode || condition.refValue,
209
+ rules: [rule]
210
+ })
211
+ }
212
+ if (condition.targetType == conditionType.COMPONENT) {
213
+ codeRules.push({
214
+ key: tabpanelCode ? `${tabpanelCode}->${condition.targetValue}` : condition.targetValue,
215
+ rules: [rule]
216
+ })
217
+ }
218
+ } else {
219
+
220
+ }
221
+ });
222
+ return codeRules
223
+ }
224
+
225
+ const systemFlag = {
226
+ currentDate: '1', // 获取当前日期
227
+ currentTimestamp: '2', // 获取当前时间戳
228
+ CurrentYear: '3', // 当前年
229
+ CurrentMonth: '4', // 当前月
230
+ CurrentDay: '5', // 当前日
231
+ CurrentAfter30Day: '6', // 当前后30天
232
+ CurrentBefore30Day: '7' // 当前前30天
233
+ }
234
+
235
+ function getSystemArgVal(flag) {
236
+ const now = new Date()
237
+ switch (flag) {
238
+ case systemFlag.currentDate:
239
+ return formatDate(new Date(),"yyyy-MM-dd")
240
+ case systemFlag.currentTimestamp:
241
+ return new Date().getTime()
242
+ case systemFlag.CurrentYear:
243
+ return formatDate(new Date(),"yyyy")
244
+ case systemFlag.CurrentMonth:
245
+ return formatDate(new Date(),"MM")
246
+ case systemFlag.CurrentDay:
247
+ return formatDate(new Date(),"dd")
248
+ case systemFlag.CurrentAfter30Day:
249
+ now.setDate(now.getDate() + 30);
250
+ return formatDate(now, "yyyy-MM-dd")
251
+ case systemFlag.CurrentBefore30Day:
252
+ now.setDate(now.getDate() - 30);
253
+ return formatDate(now, "yyyy-MM-dd")
254
+ default:
255
+ return flag
256
+ }
257
+ }
@@ -0,0 +1,343 @@
1
+ /* eslint-disable */
2
+ import { assignmentPathVal, getPathVal, hasOwn, isCycleConfig, isPlainObject } from "../utils"
3
+ import { formatSelectVal } from "../utils/defaultVal"
4
+ import { MULTI_PAGE_META_LIST_TYPES, findComponent } from '../utils/index'
5
+
6
+ const pmPageMetaListTypeList = ['setShow', 'setHidden']
7
+ // 这边是一些组件在执行规则的时候,如果还没有加载出来,规则会走不动,这边就是存储没走通的规则,等组件加载完之后,再去执行
8
+ export const penddingRules = {}
9
+
10
+ export function getConfigValue(rootValue, path, relatePath) {
11
+ if (path === relatePath) {
12
+ return getPathVal(rootValue, path, '->')
13
+ }
14
+
15
+ // 这边逻辑目前主要是为了兼容日志的时候,也可以正常使用规则========start=====
16
+ let normalRelatePath = relatePath
17
+ let preFlagStr = ''
18
+ // 这个规则是因为在日志直接拷贝配置的时候,在analysisComponent组件中会在前面额外加上 这个 标识 所以需要转换一下
19
+ const preFlagStrReg = /(__@__[^(->)]*__)$/
20
+ const preFlagStrMatchs = relatePath?.match(preFlagStrReg)
21
+ if (preFlagStrMatchs) {
22
+ preFlagStr = preFlagStrMatchs[1]
23
+ normalRelatePath = normalRelatePath?.replace(preFlagStrReg, '')
24
+ }
25
+ // 这边逻辑目前主要是为了兼容日志的时候,也可以正常使用规则========end=====
26
+
27
+ const relatePathArr = normalRelatePath ? normalRelatePath.split('->') : []
28
+ const pathArr = path ? path.split('->') : []
29
+ let diffIdx = -1 // 此标识表示,是从那个所以开始,code不一样了
30
+ let currentIdx = 0
31
+ while(diffIdx === -1 && currentIdx < pathArr.length && currentIdx < relatePathArr.length) {
32
+ const pathCode = pathArr[currentIdx]
33
+ const pathCodeReg = new RegExp(`^${pathCode}(\\[\\d+\\])?$`)
34
+ const relateCode = relatePathArr[currentIdx]
35
+ if (pathCodeReg.test(relateCode)) {
36
+ pathArr.splice(currentIdx, 1, relateCode)
37
+ currentIdx++
38
+ } else {
39
+ diffIdx = currentIdx
40
+ }
41
+ }
42
+ const getValPath = pathArr.join('->')
43
+ return getPathVal(rootValue, getValPath, '->')
44
+ }
45
+ // 设置对应的值
46
+ export function setFormVal(pathStr, val, mapComp, rootValue, currentPath) {
47
+ if (!pathStr) {
48
+ return
49
+ }
50
+ let difComps = null
51
+ let comps = []
52
+ let key = pathStr
53
+ while (key) {
54
+ const comp = mapComp[key]
55
+ if (comp) {
56
+ comps.unshift(comp)
57
+ const convertkey = key.replace(/->\w*$/, '')
58
+ if (convertkey === key) {
59
+ key = ''
60
+ } else {
61
+ key = convertkey
62
+ }
63
+ } else {
64
+ comps = []
65
+ key = ''
66
+ }
67
+ }
68
+ if (!comps || !comps.length) {
69
+ return
70
+ }
71
+
72
+ const relatePathArr = currentPath ? currentPath.split('->') : []
73
+ const pathArr = pathStr ? pathStr.split('->') : []
74
+ let diffIdx = -1 // 此标识表示,是从那个所以开始,code不一样了
75
+ let currentIdx = 0
76
+ while(diffIdx === -1 && currentIdx < pathArr.length && currentIdx < relatePathArr.length) {
77
+ const pathCode = pathArr[currentIdx]
78
+ const pathCodeReg = new RegExp(`^${pathCode}(\\[\\d+\\])?$`)
79
+ const relateCode = relatePathArr[currentIdx]
80
+ if (pathCodeReg.test(relateCode)) {
81
+ pathArr.splice(currentIdx, 1, relateCode)
82
+ currentIdx++
83
+ } else {
84
+ diffIdx = currentIdx
85
+ }
86
+ }
87
+ let sssignPath = null
88
+ if (diffIdx !== -1) {
89
+ difComps = comps.slice(diffIdx)
90
+ const prefix = comps.slice(0, diffIdx).join('->')
91
+ sssignPath = calcAssignPath(difComps, 0, prefix)
92
+ } else {
93
+ sssignPath = pathArr.join('->')
94
+ }
95
+
96
+ assignmentPathVal(rootValue, sssignPath, val, '->')
97
+
98
+
99
+ // const { config } = this
100
+ // const configs = getRelateConfigs.call(this, pathStr, config)
101
+ // configs.forEach(cg => {
102
+ // if (hasOwn(cg, 'refValue')) {
103
+ // if (cg.metaType === 'ElSelect') {
104
+ // val = formatSelectVal({config: cg, val: val, isActive: true})
105
+ // }
106
+ // cg.refValue = val
107
+ // } else {
108
+ // const { _mapComp } = this
109
+ // if (_mapComp?.value?.[cg.hireRelat]) {
110
+ // if (!penddingRules[cg.hireRelat]) {
111
+ // penddingRules[cg.hireRelat] = []
112
+ // }
113
+ // if (!penddingRules[cg.hireRelat].some((item) => item?.rules === this?.rules && item?.config === this?.config)) {
114
+ // penddingRules[cg.hireRelat].push(this)
115
+ // }
116
+ // }
117
+ // }
118
+ // })
119
+ }
120
+
121
+ function calcAssignPath(comps, idx = 0, prefix = '') {
122
+ if (comps && comps.length) {
123
+ return []
124
+ }
125
+ const comp = comps[idx]
126
+ prefix += prefix ? `->${comp.metaCode}` : comp.metaCode
127
+ if (comps.length === idx + 1) {
128
+ return prefix
129
+ } else {
130
+ let nextPrefix = prefix
131
+ nextPrefix = `${prefix}[%all]`
132
+ idx++
133
+ return calcAssignPath(comps, idx, nextPrefix)
134
+ }
135
+ }
136
+
137
+ function getRelateConfigs(codesStr, config, type) {
138
+ const { dynamicHireRelat = '' } = config
139
+ // 这边逻辑目前主要是为了兼容日志的时候,也可以正常使用规则========start=====
140
+ let normalDynamicHireRelat = dynamicHireRelat
141
+ let preFlagStr = ''
142
+ // 这个规则是因为在日志直接拷贝配置的时候,在analysisComponent组件中会在前面额外加上 这个 标识 所以需要转换一下
143
+ const preFlagStrReg = /(__@__[^(->)]*__)$/
144
+ const preFlagStrMatchs = dynamicHireRelat?.match(preFlagStrReg)
145
+ if (preFlagStrMatchs) {
146
+ preFlagStr = preFlagStrMatchs[1]
147
+ normalDynamicHireRelat = normalDynamicHireRelat?.replace(preFlagStrReg, '')
148
+ }
149
+ // 这边逻辑目前主要是为了兼容日志的时候,也可以正常使用规则========end=====
150
+
151
+ // 组装成此数据结果,用于后续的获取对应字段=====start====
152
+ const dynamicCodeInfos = normalDynamicHireRelat.split('->').map(code => {
153
+ const matchs = code?.match(/^(\w+)\[(\d+)\]$/)
154
+ if (matchs) {
155
+ return {
156
+ idx: parseInt(matchs[2]),
157
+ code: matchs[1]
158
+ }
159
+ } else {
160
+ return {
161
+ idx: -1,
162
+ code,
163
+ }
164
+ }
165
+ })
166
+ // 组装成此数据结果,用于后续的获取对应字段=====end====
167
+
168
+ let diffIdx = -1 // 次标识表示,是从那个所以开始,code不一样了
169
+ const codes = codesStr.split('->')
170
+
171
+ for (let i = 0; i < codes.length; i ++) {
172
+ const code = codes[i]
173
+ const dynamicCodeInfo = dynamicCodeInfos[i]
174
+ if (dynamicCodeInfo.code !== code) {
175
+ diffIdx = i
176
+ break
177
+ }
178
+ }
179
+
180
+ const diffCodes = codes.slice(diffIdx)
181
+ const sameCodesStr = dynamicCodeInfos.slice(0, diffIdx).map(({idx, code}) => {
182
+ return idx !== -1 ? `${code}[${idx}]` : code
183
+ }).join('->')
184
+ let sameStr = sameCodesStr
185
+ let sameIdx = null
186
+ const sameMatchs = sameCodesStr.match(/^([\w\W]*)\[(\d*)\]$/)
187
+ // 这边是在出现a->c->c[0]这种情况的时候,可以正常获取的组件config
188
+ if (sameMatchs) {
189
+ sameStr = sameMatchs[1]
190
+ sameIdx = sameMatchs[2]
191
+ }
192
+ const { dynamicMapComp, _mapComp } = this
193
+ let retConfigs = []
194
+ if (sameStr) {
195
+ retConfigs = [dynamicMapComp[`${sameStr}${preFlagStr}`]]
196
+ } else {
197
+ const code = diffCodes.shift()
198
+ retConfigs = [dynamicMapComp[`${code}${preFlagStr}`]]
199
+ }
200
+ while (diffCodes.length) {
201
+ const code = diffCodes.shift()
202
+ const list = []
203
+ retConfigs.forEach(cg => {
204
+ // multiPmPageMetaList有值,表示为数据循环渲染子组件
205
+ if (cg.multiPmPageMetaList) {
206
+ if (sameIdx !== null) {
207
+ const childCgList = cg.multiPmPageMetaList[sameIdx]
208
+ const fincCg = childCgList && childCgList.find(childCg => childCg.metaCode === code)
209
+ if (!fincCg) return
210
+ list.push(fincCg)
211
+ sameIdx = null
212
+ } else {
213
+ if (pmPageMetaListTypeList.includes(type)) {
214
+ const fincCg = cg?.pmPageMetaList?.find(childCg => childCg.metaCode === code)
215
+ if (!fincCg) return
216
+ list.push(fincCg)
217
+ }
218
+ cg.multiPmPageMetaList.forEach(childCgList => {
219
+ const fincCg = childCgList.find(childCg => childCg.metaCode === code)
220
+ if (!fincCg) return
221
+ list.push(fincCg)
222
+ })
223
+ }
224
+ } else {
225
+ const fincCg = cg?.pmPageMetaList?.find(childCg => childCg.metaCode === code)
226
+ if (!fincCg) return
227
+ list.push(fincCg)
228
+ }
229
+ })
230
+ retConfigs = list
231
+ }
232
+ if (_mapComp?.value?.[codesStr] && !retConfigs.length) {
233
+ if (!penddingRules[codesStr]) {
234
+ penddingRules[codesStr] = []
235
+ }
236
+ if (!penddingRules[codesStr].some((item) => item?.rules === this?.rules && item?.config === this?.config)) {
237
+ penddingRules[codesStr].push(this)
238
+ }
239
+ }
240
+ return retConfigs
241
+ }
242
+
243
+ export function greaterThan(val, targ) {
244
+ const valCanTran = canTransNumber(val)
245
+ const tragCanTran = canTransNumber(targ)
246
+ if (valCanTran && tragCanTran) {
247
+ return Number(val) > Number(targ)
248
+ } else {
249
+ return val + '' > targ + ''
250
+ }
251
+ }
252
+
253
+ export function lessThan(val, targ) {
254
+ const valCanTran = canTransNumber(val)
255
+ const tragCanTran = canTransNumber(targ)
256
+ if (valCanTran && tragCanTran) {
257
+ return Number(val) < Number(targ)
258
+ } else {
259
+ return val + '' < targ + ''
260
+ }
261
+ }
262
+
263
+ export function canTransNumber(val) {
264
+ return !isNaN(Number(val))
265
+ }
266
+
267
+ /**
268
+ * 根据code path 获取到对应的组件或者label
269
+ */
270
+ export function getCurrentComp(codesStr, type) {
271
+ if (!codesStr) return null
272
+ const { config } = this
273
+ return getRelateConfigs.call(this, codesStr, config, type)
274
+ }
275
+
276
+ export function parseRules(config) {
277
+ if (!config) return []
278
+ const retRules = []
279
+ const { pmRuleDefVoList, pmRuleDefVOList } = config
280
+ const ruleDefVoList = (pmRuleDefVoList || pmRuleDefVOList?.filter(item => item?.ruleType == '1') || [])
281
+ ruleDefVoList.forEach(ruleTypeItem => {
282
+ const pmRuleEventRelVoList = ruleTypeItem.pmRuleEventRelVOList || ruleTypeItem.pmRuleEventRelVoList || []
283
+ const itemRulesFlat = pmRuleEventRelVoList.map(item => ({
284
+ ...item,
285
+ ruleType: ruleTypeItem.ruleType
286
+ }))
287
+ retRules.push(...itemRulesFlat)
288
+ })
289
+ return retRules
290
+ }
291
+
292
+ // 解析最原始的配置数据,生成Code链对应的配置信息
293
+ export function generateConfigsHireRelat(configs, hireRelat = '', retObj = {}) {
294
+ if (!configs) return
295
+ const list = Array.isArray(configs) ? configs : [configs]
296
+ list.forEach(config => {
297
+ let currentHireRelat = hireRelat
298
+ if (hasOwn(config, 'pmTabpanelInfoVoList')) {
299
+ currentHireRelat = ''
300
+ generateConfigsHireRelat(config.pmTabpanelInfoVoList, currentHireRelat, retObj)
301
+ } else if (hasOwn(config, 'pmComponentInfoVoList')) {
302
+ currentHireRelat += currentHireRelat ? `->${config.tabpanelCode}` : config.tabpanelCode
303
+ generateConfigsHireRelat(config.pmComponentInfoVoList, currentHireRelat, retObj)
304
+ } else if (hasOwn(config, 'pmLabelInfoVoList') || hasOwn(config, 'subComponentInfoVo')) {
305
+ currentHireRelat += currentHireRelat ? `->${config.componentCode}` : config.componentCode
306
+ generateConfigsHireRelat(config.pmLabelInfoVoList, currentHireRelat, retObj)
307
+ generateConfigsHireRelat(config.subComponentInfoVo, currentHireRelat, retObj)
308
+ } else {
309
+ currentHireRelat += currentHireRelat ? `->${config.labelCode}` : config.labelCode
310
+ }
311
+ if (currentHireRelat) {
312
+ config.nativeHireRelat = currentHireRelat
313
+ retObj[currentHireRelat] = config
314
+ }
315
+ })
316
+ return retObj
317
+ }
318
+
319
+ export function getRelateConfigKeys(keys = [], path = '', relatePath = '') {
320
+ const pathArr = path ? path.split('->') : []
321
+ const relatePathArr = relatePath ? relatePath.split('->') : []
322
+ let diffIdx = -1 // 此标识表示,是从那个所以开始,code不一样了
323
+ let currentIdx = 0
324
+ while(diffIdx === -1 && currentIdx < pathArr.length && currentIdx < relatePathArr.length) {
325
+ const pathCode = pathArr[currentIdx]
326
+ const pathCodeReg = new RegExp(`^${pathCode}(\\[\\d+\\])?$`)
327
+ const relateCode = relatePathArr[currentIdx]
328
+ if (pathCodeReg.test(relateCode)) {
329
+ pathArr.splice(currentIdx, 1, relateCode)
330
+ currentIdx++
331
+ } else {
332
+ diffIdx = currentIdx
333
+ }
334
+ }
335
+ const normalPath = pathArr.reduce((ret, pathCode) => {
336
+ const noramlPathCode = pathCode.replace(/([\[\]]{1})/g, (_,b) => {return `\\${b}`})
337
+ return ret + (ret ? `->${noramlPathCode}(\\[\\d+\\])?` : `${noramlPathCode}(\\[\\d+\\])?`)
338
+ }, '')
339
+ const normalPathReg = new RegExp(`^${normalPath}$`)
340
+ return keys.filter(code => {
341
+ return normalPathReg.test(code)
342
+ })
343
+ }
@@ -0,0 +1,67 @@
1
+ /* eslint-disable */
2
+ import { parseCondition } from './parseCondition'
3
+ import { runEvent } from './eventsSupplement'
4
+ import { unref } from 'vue'
5
+
6
+ const recoverCb = {}
7
+ const recoverCbTimer = {}
8
+
9
+ export default function({
10
+ mapComp,
11
+ rules,
12
+ rootValue,
13
+ route, lang,
14
+ isInit,
15
+ currentPath
16
+ }) {
17
+ rules = rules || []
18
+
19
+ // this.rules = rules
20
+
21
+ if (rules && rules.length) {
22
+ rules.forEach(rule => {
23
+ if (!rule) return
24
+ const { pmRuleTargetEventVoList, pmRuleTargetEventVOList, relId } = rule
25
+ const relIdKey = `${relId}__${currentPath}`
26
+ if (parseCondition({rule, rootValue: unref(rootValue), currentPath})) {
27
+ const recovers = runEvent({events: pmRuleTargetEventVoList || pmRuleTargetEventVOList, rootValue, route, lang, mapComp, isInit, rule})
28
+ recoverCb[relIdKey] = recovers
29
+ } else {
30
+ recoverCb[relIdKey] && recoverCb[relIdKey].forEach(recover => {
31
+ if (recover) {
32
+ recover()
33
+ }
34
+ })
35
+ delete recoverCb[relIdKey]
36
+ }
37
+ })
38
+ }
39
+ }
40
+
41
+ function splitRelat(relat) {
42
+ // const rowCodes = []
43
+ let nativeRelat = ''
44
+ const codes = relat.split('->').map(code => {
45
+ const matchs = code?.match(/^(\w+)\[(\d+)\]$/)
46
+ if (matchs) {
47
+ nativeRelat += nativeRelat ? `->${matchs[1]}` : matchs[1]
48
+ return {
49
+ idx: parseInt(matchs[2]),
50
+ code: matchs[1]
51
+ }
52
+ } else {
53
+ nativeRelat += nativeRelat ? `->${code}` : code
54
+ return {
55
+ idx: -1,
56
+ code,
57
+ }
58
+ }
59
+ })
60
+ return {
61
+ nativeRelat,
62
+ codes
63
+ }
64
+ }
65
+
66
+ export { generateConfigsHireRelat } from './ruleUtils'
67
+ export { getCodeMapRules } from './parseCondition.js'