resolver-egretimp-plus 0.0.132 → 0.0.134
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/const/index.js +1 -1
- package/dist/h5/index.js +2 -2
- package/dist/web/index.js +2 -2
- package/package.json +1 -1
- package/src/components/packages-web/CustomComponentPlain.vue +6 -2
- package/src/hooks/index.js +37 -25
- package/src/index.jsx +2 -0
- package/src/renderer.jsx +1 -0
- package/src/utils/common.js +67 -0
package/package.json
CHANGED
|
@@ -73,12 +73,16 @@ const clickAction = () => {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function selectFormat(value) {
|
|
76
|
-
let valList = value
|
|
76
|
+
let valList = `${value}`
|
|
77
77
|
const multiple = props?.config?.multiple == '1'
|
|
78
78
|
const isStrVal = props.config?.valueType !== 'list'
|
|
79
79
|
// 在满足多选,并且不是str格式的时候,就表示value为数组类型,取反就表示不满足的时候,需要转换成数组格式进行计算
|
|
80
80
|
if (!(multiple && !isStrVal)) {
|
|
81
|
-
|
|
81
|
+
try {
|
|
82
|
+
valList = valList ? (valList?.split(',') || []) : []
|
|
83
|
+
} catch (error) {
|
|
84
|
+
debugger
|
|
85
|
+
}
|
|
82
86
|
}
|
|
83
87
|
return valList?.reduce((ret, val) => {
|
|
84
88
|
const str = props?.options?.find(item => item.columnValue == val)?.[lang?.value?.indexOf('zh') > -1 ? 'columnDesc_zh' : 'columnDesc'] || ''
|
package/src/hooks/index.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { computed, inject, nextTick, reactive } from "vue"
|
|
2
2
|
import rulesDriver from '../rules/rulesDriver'
|
|
3
3
|
import defaultVal from '../utils/defaultVal.js'
|
|
4
|
-
import { isNonRefType } from "../utils"
|
|
4
|
+
import { getValueDeep, isNonRefType, setValueDeep } from "../utils"
|
|
5
5
|
// import { deepMerge } from '../utils'
|
|
6
6
|
|
|
7
7
|
export function useVModel(config, props, emit, modelKey = 'update:modelValue') {
|
|
8
|
-
// const hireRelatMapRules = inject('hireRelatMapRules')
|
|
9
|
-
// const dataLoad = inject('dataLoad')
|
|
10
|
-
// const dynamicMapComp = inject('dynamicMapComp')
|
|
11
|
-
// const lang = inject('lang')
|
|
12
8
|
const { hireRelatMapRules, messageInstance, rootValue, ruleExecuter, dataLoad, dynamicMapComp, lang, _mapComp } = this
|
|
13
9
|
const currentRules = hireRelatMapRules.value[config.hireRelat]
|
|
14
10
|
let metaCodeKey = config.metaCode
|
|
@@ -21,9 +17,16 @@ export function useVModel(config, props, emit, modelKey = 'update:modelValue') {
|
|
|
21
17
|
const dynamicMapKey = config.dynamicHireRelat.replace(/->\w+$/, `->${metaCodeKey}`)
|
|
22
18
|
config = dynamicMapComp[dynamicMapKey]
|
|
23
19
|
}
|
|
24
|
-
|
|
20
|
+
const retModelVale = computed({
|
|
25
21
|
get() {
|
|
26
|
-
|
|
22
|
+
if (!config) {
|
|
23
|
+
// 如果使用v-model:[]方式绑定非modelValue,可能会出现没有对应的config
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
const dynamicHireRelat = config.dynamicHireRelat
|
|
27
|
+
const val = getValueDeep(rootValue.value, dynamicHireRelat)
|
|
28
|
+
|
|
29
|
+
// const val = (metaCodeKey ? props.modelValue?.[metaCodeKey] : props.modelValue) ?? null
|
|
27
30
|
if (modelKey === 'update:modelValue' && !val) {
|
|
28
31
|
setTimeout(() => {
|
|
29
32
|
defaultVal(config)
|
|
@@ -58,25 +61,33 @@ export function useVModel(config, props, emit, modelKey = 'update:modelValue') {
|
|
|
58
61
|
return val
|
|
59
62
|
},
|
|
60
63
|
set(val) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!metaCode) return
|
|
64
|
-
if (!modelValue) {
|
|
65
|
-
emit('update:modelValue', {
|
|
66
|
-
[metaCode]: val
|
|
67
|
-
})
|
|
68
|
-
} else {
|
|
69
|
-
// if (modelValue?.[metaCode]) {
|
|
70
|
-
// if (typeof modelValue?.[metaCode] === 'object' || typeof val === 'object') {
|
|
71
|
-
// val = deepMerge(val, modelValue?.[metaCode], 'union')
|
|
72
|
-
// }
|
|
73
|
-
// }
|
|
74
|
-
if (isNonRefType(modelValue[metaCode]) && isNonRefType(val) && modelValue[metaCode] === val) {
|
|
75
|
-
// 这边的值没有变,就不用出触发下面的其他动作了
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
modelValue[metaCode] = val
|
|
64
|
+
if (!config) {
|
|
65
|
+
return
|
|
79
66
|
}
|
|
67
|
+
const dynamicHireRelat = config.dynamicHireRelat
|
|
68
|
+
if (!setValueDeep(rootValue, dynamicHireRelat, val)) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// const modelValue = props.modelValue
|
|
73
|
+
// const metaCode = metaCodeKey
|
|
74
|
+
// if (!metaCode) return
|
|
75
|
+
// if (!modelValue) {
|
|
76
|
+
// emit('update:modelValue', {
|
|
77
|
+
// [metaCode]: val
|
|
78
|
+
// })
|
|
79
|
+
// } else {
|
|
80
|
+
// // if (modelValue?.[metaCode]) {
|
|
81
|
+
// // if (typeof modelValue?.[metaCode] === 'object' || typeof val === 'object') {
|
|
82
|
+
// // val = deepMerge(val, modelValue?.[metaCode], 'union')
|
|
83
|
+
// // }
|
|
84
|
+
// // }
|
|
85
|
+
// if (isNonRefType(modelValue[metaCode]) && isNonRefType(val) && modelValue[metaCode] === val) {
|
|
86
|
+
// // 这边的值没有变,就不用出触发下面的其他动作了
|
|
87
|
+
// return
|
|
88
|
+
// }
|
|
89
|
+
// props.modelValue[metaCode] = val
|
|
90
|
+
// }
|
|
80
91
|
if (config) {
|
|
81
92
|
setTimeout(() => {
|
|
82
93
|
ruleExecuter?.run({
|
|
@@ -99,6 +110,7 @@ export function useVModel(config, props, emit, modelKey = 'update:modelValue') {
|
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
112
|
})
|
|
113
|
+
return retModelVale
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
export function useVmodels(props, emit) {
|
package/src/index.jsx
CHANGED
|
@@ -128,6 +128,7 @@ export default {
|
|
|
128
128
|
type: String,
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
|
+
emits: ['update:modelValue'],
|
|
131
132
|
setup(props, { emit, attrs, expose }) {
|
|
132
133
|
const ruleExecuter = null
|
|
133
134
|
// const ruleExecuter = new RuleExecuter()
|
|
@@ -268,6 +269,7 @@ export default {
|
|
|
268
269
|
return props.modelValue
|
|
269
270
|
},
|
|
270
271
|
set(val) {
|
|
272
|
+
debugger
|
|
271
273
|
emit('update:modelValue', val)
|
|
272
274
|
}
|
|
273
275
|
})
|
package/src/renderer.jsx
CHANGED
package/src/utils/common.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { intersectionWith, isEqual, mergeWith, unionWith, isArray, cloneDeep } from 'lodash-es'
|
|
3
3
|
import { isDate } from './is'
|
|
4
|
+
import { isRef } from 'vue'
|
|
4
5
|
export {
|
|
5
6
|
cloneDeep,
|
|
6
7
|
unionWith
|
|
@@ -303,3 +304,69 @@ export function definePrivatelyProp(obj, key, value, options) {
|
|
|
303
304
|
...op
|
|
304
305
|
})
|
|
305
306
|
}
|
|
307
|
+
|
|
308
|
+
export function setValueDeep(obj, key = '', val) {
|
|
309
|
+
let isChange = false
|
|
310
|
+
if (key && obj) {
|
|
311
|
+
let beginObj = obj
|
|
312
|
+
if (isRef(obj)) {
|
|
313
|
+
beginObj = obj.value
|
|
314
|
+
}
|
|
315
|
+
const keyArr = key.split('->')
|
|
316
|
+
keyArr.reduce((ret, code, idx) => {
|
|
317
|
+
if (idx === keyArr.length - 1) {
|
|
318
|
+
const matchs = code.match(/(.+)\[(\d+)\]/)
|
|
319
|
+
if (matchs) {
|
|
320
|
+
const cod = matchs[1]
|
|
321
|
+
const idx = matchs[2]
|
|
322
|
+
!ret[cod] && (ret[cod] = [])
|
|
323
|
+
|
|
324
|
+
if (!(isNonRefType(ret[cod][idx]) && isNonRefType(val) && ret[cod][idx] === val)) {
|
|
325
|
+
isChange = true
|
|
326
|
+
ret[cod][idx] = val
|
|
327
|
+
}
|
|
328
|
+
} else {
|
|
329
|
+
if (!(isNonRefType(ret[code]) && isNonRefType(val) && ret[code] === val)) {
|
|
330
|
+
isChange = true
|
|
331
|
+
ret[code] = val
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
const matchs = code.match(/(.+)\[(\d+)\]/)
|
|
336
|
+
if (matchs) {
|
|
337
|
+
const cod = matchs[1]
|
|
338
|
+
const idx = matchs[2]
|
|
339
|
+
!ret[cod] && (ret[cod] = [])
|
|
340
|
+
!ret[cod][idx] && (ret[cod][idx] = {})
|
|
341
|
+
return ret[cod][idx]
|
|
342
|
+
} else {
|
|
343
|
+
!ret[code] && (ret[code] = {})
|
|
344
|
+
return ret[code]
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}, beginObj)
|
|
348
|
+
if (isRef(obj)) {
|
|
349
|
+
obj.value = beginObj
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return isChange
|
|
353
|
+
}
|
|
354
|
+
export function getValueDeep(obj, key) {
|
|
355
|
+
if (!key) {
|
|
356
|
+
return obj
|
|
357
|
+
}
|
|
358
|
+
const keyArr = key.split('->') || []
|
|
359
|
+
return keyArr.reduce((ret, code) => {
|
|
360
|
+
if (!ret) {
|
|
361
|
+
return ret
|
|
362
|
+
}
|
|
363
|
+
const matchs = code.match(/(.+)\[(\d+)\]/)
|
|
364
|
+
if (matchs) {
|
|
365
|
+
const cod = matchs[1]
|
|
366
|
+
const idx = matchs[2]
|
|
367
|
+
return ret?.[cod]?.[idx]
|
|
368
|
+
} else {
|
|
369
|
+
return ret[code]
|
|
370
|
+
}
|
|
371
|
+
}, obj)
|
|
372
|
+
}
|