resolver-egretimp-plus 0.1.8 → 0.1.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resolver-egretimp-plus",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -2,7 +2,7 @@ import { isArray, isHasVal, isNull, isUndefined } from "../../utils/is"
2
2
  import { DATA_VALID_RULE_EXECUTE } from "../../api/builtIn"
3
3
  import { getRelateConfigKeys } from "../../rules/ruleUtils"
4
4
  import { RESULT_CODE, resultToast } from "../../utils/respone"
5
- import { isPromise, parseExtendAttr, unionWith } from "../../utils/index"
5
+ import { isPromise, modelValueDeepMerge, parseExtendAttr, unionWith } from "../../utils/index"
6
6
  import { buildInRequest } from "../../utils/request"
7
7
 
8
8
  function getPathVal(obj = {}, path) {
@@ -119,10 +119,8 @@ export async function dispatchClickEvent(service, {
119
119
  reqResult = {
120
120
  }
121
121
  }
122
- reqResult = {
123
- ...reqResult,
124
- ...reqData
125
- }
122
+ const mergeObj = modelValueDeepMerge(reqResult, reqData)
123
+ reqResult = mergeObj
126
124
 
127
125
  let beforeRequestServiceRet = true
128
126
  if (normalBeforeRequestService) {
@@ -1,6 +1,6 @@
1
1
  import { ElSelect, ElOption } from 'element-plus'
2
2
  import { computed, inject, onMounted, watch} from 'vue'
3
- import { commonPropsType, isArray, isNumber, isPlainObject, isString } from '../../utils/index.js'
3
+ import { commonPropsType, isArray, isNumber, isPlainObject, isString, VALUE_TYPES } from '../../utils/index.js'
4
4
 
5
5
  export default {
6
6
  inheritAttrs: false,
@@ -20,11 +20,6 @@ export default {
20
20
  },
21
21
  emits: ['update:modelValue'],
22
22
  setup(props, { emit, attrs, expose, slots }) {
23
- const VALUE_TYPES = {
24
- LIST: 'list',
25
- OBJECT: 'object',
26
- STRING: 'string',
27
- }
28
23
  // 这个是真实的值
29
24
  const modelValue = computed({
30
25
  get() {
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable */
2
2
  import { hasOwn, isPlainObject } from "../utils"
3
+ import { formatSelectVal } from "../utils/defaultVal"
3
4
  import { MULTI_PAGE_META_LIST_TYPES, findComponent } from '../utils/index'
4
5
 
5
6
  const pmPageMetaListTypeList = ['setShow', 'setHidden']
@@ -45,6 +46,9 @@ export function setFormVal(pathStr, val) {
45
46
  const configs = getRelateConfigs.call(this, pathStr, config)
46
47
  configs.forEach(cg => {
47
48
  if (hasOwn(cg, 'refValue')) {
49
+ if (cg.metaType === 'ElSelect') {
50
+ val = formatSelectVal({config, val: val})
51
+ }
48
52
  cg.refValue = val
49
53
  } else {
50
54
  const { _mapComp } = this
@@ -9,6 +9,11 @@ export const ARG_FLAGS = {
9
9
  CURRENT_DATE: '_currentDate',
10
10
  REF_VAL: '_refVal'
11
11
  }
12
+ export const VALUE_TYPES = {
13
+ LIST: 'list',
14
+ OBJECT: 'object',
15
+ STRING: 'string',
16
+ }
12
17
  export const NOT_LOG_EFFECT_TYPE = ['CustomComponentTabs', 'CustomComponentTabPane', 'CustomComponentCycleTabPane', 'CustomComponentCollapse', 'CustomComponentTabPaneH5']
13
18
  export const FORM_META_TYPE = 'CustomComponentFormLayout'
14
19
  export const FORM_META_TYPE_H5 = 'CustomComponentFormLayoutH5'
@@ -1,6 +1,7 @@
1
1
  import { toRaw } from 'vue'
2
- import { formatDate } from './common'
3
- import { ARG_FLAGS } from './const'
2
+ import { formatDate, isPlainObject } from './common'
3
+ import { ARG_FLAGS, isHidden, VALUE_TYPES } from './const'
4
+ import { isArray, isNumber, isString } from './is'
4
5
 
5
6
  export default function defaultVal(config) {
6
7
  if ((config.defaultVal || config.defaultValue) && !config.bindValue && config.bindValue !== 0) {
@@ -29,10 +30,41 @@ export default function defaultVal(config) {
29
30
  } else {
30
31
  defaultVal = toRaw(configDefaultVal)
31
32
  }
33
+ if (config.metaType === 'ElSelect') {
34
+ defaultVal = formatSelectVal({config, val: defaultVal})
35
+ }
32
36
  console.log(`${config.dynamicHireRelat},${config.hireRelat} to set defaultValue, ${defaultVal}`)
33
37
  config.refValue = defaultVal
34
38
  } catch (error) {
35
39
  console.log('set default val fail, config', config, error)
36
40
  }
37
41
  }
42
+ }
43
+
44
+ export function formatSelectVal({
45
+ config,
46
+ val
47
+ }) {
48
+ let retValue = val
49
+ if (!isHidden({config})) {
50
+ const valueType = config?.valueType
51
+ const separator = config?.separator
52
+ if (valueType == VALUE_TYPES.STRING) {
53
+ if (isPlainObject(val) || isArray(val)) {
54
+ try {
55
+ retValue = Object.values(val).join(separator)
56
+ } catch (error) {
57
+ retValue = val
58
+ }
59
+ }
60
+ } else {
61
+ if ((val && isString(val)) || isNumber(val)) {
62
+ retValue = `${val}`?.split(separator)
63
+ if (valueType == VALUE_TYPES.OBJECT) {
64
+ retValue = val?.reduce((ret, item, idx) => {ret[idx] = item; return ret;}, {})
65
+ }
66
+ }
67
+ }
68
+ }
69
+ return val
38
70
  }