resolver-egretimp-plus 0.0.28 → 0.0.30

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.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -1,6 +1,4 @@
1
- import { ElMessage } from 'element-plus';
2
-
3
- export async function dispatchClickEvents ({serviceList = [], axiosInstance, reqData}) {
1
+ export async function dispatchClickEvents ({serviceList = [], axiosInstance, reqData, messageInstance}) {
4
2
  for (let i = 0; i < serviceList.length; i++) {
5
3
  const service = serviceList[i]
6
4
  const url = service.serviceCode
@@ -10,7 +8,7 @@ export async function dispatchClickEvents ({serviceList = [], axiosInstance, re
10
8
  data: reqData
11
9
  }))
12
10
  if (!ret?.data?.success) {
13
- ElMessage.error(ret?.data?.resultMessage || '')
11
+ messageInstance?.value?.error(ret?.data?.resultMessage || '')
14
12
  await Promise.reject()
15
13
  }
16
14
  }
@@ -0,0 +1,39 @@
1
+ export async function executeLoadServices(services = [], { axiosInstance, messageInstance, reqData, respCb }) {
2
+ const loadServices = services.filter(ser => ser.eventType == '1')
3
+ for (let i = 0; i < loadServices.length; i++) {
4
+ const service = loadServices[i]
5
+ const url = service.serviceCode
6
+ const ret = await (axiosInstance.value && axiosInstance.value({
7
+ url,
8
+ method: "post",
9
+ data: reqData
10
+ }))
11
+ // const ret = await (new Promise((res) => {
12
+ // setTimeout(() => {
13
+ // res({
14
+ // data: {
15
+ // success: true,
16
+ // result: {
17
+ // studentId: 121212
18
+ // }
19
+ // }
20
+ // })
21
+ // }, 3000);
22
+ // }))
23
+ if (!ret?.data?.success) {
24
+ messageInstance?.value?.error(ret?.data?.resultMessage || '')
25
+ await Promise.reject()
26
+ }
27
+ respCb && respCb(ret?.data?.result)
28
+ }
29
+ }
30
+
31
+ export function normalPageConfigs(pageConfig) {
32
+ const rootOptionComp = pageConfig?.pmPageMetaList?.find(item => item.metaCode === 'PC-root-panel')
33
+ if (rootOptionComp) {
34
+ pageConfig.pmPageMetaList = rootOptionComp.pmPageMetaList
35
+ delete rootOptionComp.pmPageMetaList
36
+ pageConfig.rootOptionComp = rootOptionComp
37
+ }
38
+ return pageConfig
39
+ }
@@ -2,7 +2,7 @@
2
2
  import { defineProps, inject, getCurrentInstance, computed, useAttrs } from 'vue'
3
3
  import { commonPropsType } from '../../utils/index.js'
4
4
  import { useRoute } from 'vue-router'
5
- import { dispatchClickEvents } from '../helper/button-H5.js';
5
+ import { dispatchClickEvents } from '../helper/button.js';
6
6
 
7
7
  const appContext = getCurrentInstance()?.appContext
8
8
 
@@ -41,6 +41,7 @@ const label = computed(() => {
41
41
  const route = useRoute()
42
42
  const buttonActions = inject('buttonActions', {})
43
43
 
44
+ const messageInstance = inject('_messageInstance')
44
45
  const dynamicMapComp = inject('dynamicMapComp')
45
46
  const hireRelatMapRules = inject('hireRelatMapRules')
46
47
  const components = inject('components')
@@ -71,7 +72,9 @@ const buttonAction = () => {
71
72
  if (PageServiceMapVOList?.length) {
72
73
  dispatchClickEvents({
73
74
  serviceList: PageServiceMapVOList,
74
- axiosInstance: _axiosInstance
75
+ axiosInstance: _axiosInstance,
76
+ reqData: rootValue?.value,
77
+ messageInstance
75
78
  })
76
79
  }
77
80
  }
@@ -28,8 +28,10 @@ const onChange = (e) => {
28
28
  </script>
29
29
 
30
30
  <template>
31
- <cmi-cell
32
- :value="modelValue" v-bind="{ ...attrs, ...calcProps}"
33
- @change="onChange"
34
- ></cmi-cell>
31
+ <cmi-cell-group>
32
+ <cmi-cell
33
+ :value="modelValue" v-bind="{ ...attrs, ...calcProps}"
34
+ @change="onChange"
35
+ ></cmi-cell>
36
+ </cmi-cell-group>
35
37
  </template>
@@ -53,6 +53,7 @@ const label = computed(() => {
53
53
  const route = useRoute()
54
54
  const buttonActions = inject('buttonActions', {})
55
55
 
56
+ const messageInstance = inject('_messageInstance')
56
57
  const dynamicMapComp = inject('dynamicMapComp')
57
58
  const hireRelatMapRules = inject('hireRelatMapRules')
58
59
  const components = inject('components')
@@ -83,7 +84,8 @@ const buttonAction = () => {
83
84
  dispatchClickEvents({
84
85
  serviceList: PageServiceMapVOList,
85
86
  axiosInstance: _axiosInstance,
86
- reqData: rootValue?.value
87
+ reqData: rootValue?.value,
88
+ messageInstance
87
89
  })
88
90
  }
89
91
  }
@@ -2,6 +2,7 @@ import { parsePageConfig } from "../utils"
2
2
  import { ref } from 'vue'
3
3
  import { buildInRequest } from "../utils/request"
4
4
  import { GET_SYS_PARAM_CACHE, QUERY_PAGE_CONFIG_DATA } from "../api/builtIn"
5
+ import { normalPageConfigs } from "../components/helper/resolver"
5
6
 
6
7
  export function usePageConfig() {
7
8
  const pageConfigRef = ref(null)
@@ -31,7 +32,7 @@ export function useBuildInData(messageTipInstance, loadingInstance) {
31
32
  }
32
33
  buildInRequest(QUERY_PAGE_CONFIG_DATA, reqData).then(ret => {
33
34
  if (ret.data.success) {
34
- pageConfig.value = ret.data.result
35
+ pageConfig.value = normalPageConfigs(ret.data.result)
35
36
  getSelects(ret.data.result?.pmBusinessIdentityVO?.tenantId)
36
37
  return
37
38
  }
@@ -44,7 +45,7 @@ export function useBuildInData(messageTipInstance, loadingInstance) {
44
45
  }
45
46
  })
46
47
  }
47
- const selects = ref([])
48
+ const selects = ref({})
48
49
  function getSelects(tenantId) {
49
50
  buildInRequest(GET_SYS_PARAM_CACHE, {
50
51
  tenantId
package/src/index.jsx CHANGED
@@ -5,6 +5,7 @@ import { useBuildInData, usePageConfig } from './hooks/pageConfig'
5
5
  import { toValidate } from './utils/valid.js'
6
6
  import { MODE } from "./utils/const.js"
7
7
  import { generateRequester } from "./utils/request.js"
8
+ import { executeLoadServices } from "./components/helper/resolver.js"
8
9
  export default {
9
10
  name: 'Resolver',
10
11
  props: {
@@ -73,8 +74,21 @@ export default {
73
74
  type: Function,
74
75
  default: () => ({composeComponents: {}})
75
76
  },
77
+ loadingInstance: {
78
+ type: [Object, Function],
79
+ default: () => null
80
+ },
81
+ messageInstance: {
82
+ type: [Object, Function],
83
+ default: () => null
84
+ },
85
+ loadEvnetsReq: {
86
+ type: Object,
87
+ default: () => ({})
88
+ }
76
89
  },
77
90
  setup(props, { emit, attrs, expose }) {
91
+ let nativeDataLoad = ref(false)
78
92
  let axiosInstance = ref(props.axiosInstance)
79
93
  watch(() => {
80
94
  return props.axiosConfig
@@ -87,14 +101,50 @@ export default {
87
101
  }, {
88
102
  immediate: true
89
103
  })
104
+
105
+
106
+ const dataLoad = computed(() => {
107
+ return props.dataLoad || nativeDataLoad.value
108
+ })
90
109
  const instance = getCurrentInstance()
91
110
  const { initPageConfig, pageConfigRef, mapCompRef, hireRelatMapRulesRef } = usePageConfig()
111
+
92
112
  initPageConfig(props.config, props.lang, props.polyfillConfigs, instance, props.isH5)
113
+ // 触发加载事件执行
114
+ executeLoadServices(
115
+ props.config?.pmPageServiceMapVOList || [],
116
+ {
117
+ messageInstance: toRef(props, 'messageInstance'),
118
+ axiosInstance,
119
+ reqData: props.loadEvnetsReq,
120
+ respCb: (result) => {
121
+ nativeDataLoad.value = true
122
+ emit('update:modelValue', result)
123
+ emit('loadEvnetsCompleted', result)
124
+ }
125
+ }
126
+ )
93
127
 
94
128
  watch(toRef(props, 'config'), () => {
95
129
  initPageConfig(props.config, props.lang, props.polyfillConfigs, instance, props.isH5)
130
+ executeLoadServices(
131
+ props.config?.pmPageServiceMapVOList || [],
132
+ {
133
+ messageInstance: toRef(props, 'messageInstance'),
134
+ axiosInstance,
135
+ reqData: props.loadEvnetsReq,
136
+ respCb: (result) => {
137
+ debugger
138
+ nativeDataLoad.value = true
139
+ emit('update:modelValue', result)
140
+ emit('loadEvnetsCompleted', result)
141
+ }
142
+ }
143
+ )
96
144
  })
97
145
 
146
+ provide('_messageInstance', toRef(props, 'messageInstance'))
147
+ provide('_loadingInstance', toRef(props, 'loadingInstance'))
98
148
  provide('_getNativeComps', props.getNativeComps)
99
149
  provide('pageConfig', pageConfigRef)
100
150
  const dynamicMapComp = reactive({})
@@ -108,7 +158,7 @@ export default {
108
158
  provide('selects', toRef(props, 'selects'))
109
159
  provide('rootValue', toRef(props, 'modelValue')) // 绑定进入的跟数据
110
160
  provide('lang', toRef(props, 'lang'))
111
- provide('dataLoad', toRef(props, 'dataLoad')) // 是否可以开始执行规则初始化
161
+ provide('dataLoad', dataLoad) // 是否可以开始执行规则初始化
112
162
  provide('dialogComponents', props.dialogComponents) // 是否可以开始执行规则初始化
113
163
  provide('_isH5', toRef(props, 'isH5')) // 是否是H5配置
114
164
 
@@ -14,11 +14,11 @@ const props = defineProps({
14
14
  default: () => ({composeComponents: {}})
15
15
  },
16
16
  loadingInstance: {
17
- type: Object,
17
+ type: [Object, Function],
18
18
  default: () => null
19
19
  },
20
20
  messageInstance: {
21
- type: Object,
21
+ type: [Object, Function],
22
22
  default: () => null
23
23
  },
24
24
  })
@@ -36,10 +36,10 @@ getPageConfig({
36
36
  const allSelects = computed(() => {
37
37
  return {
38
38
  ...props.selects,
39
- ...selects
39
+ ...selects.value
40
40
  }
41
41
  })
42
42
  </script>
43
43
  <template>
44
- <Resolver v-bind="attrs" :getNativeComps="props.getNativeComps" :config="pageConfig || null" :selects="allSelects"></Resolver>
44
+ <Resolver v-bind="attrs" :loadingInstance="props.loadingInstance" :messageInstance="props.messageInstance" :getNativeComps="props.getNativeComps" :config="pageConfig || null" :selects="allSelects"></Resolver>
45
45
  </template>
@@ -1,17 +0,0 @@
1
- // import { ElMessage } from 'element-plus';
2
-
3
- export async function dispatchClickEvents ({serviceList = [], axiosInstance, reqData}) {
4
- for (let i = 0; i < serviceList.length; i++) {
5
- const service = serviceList[i]
6
- const url = service.serviceCode
7
- const ret = await (axiosInstance.value && axiosInstance.value({
8
- url,
9
- method: "post",
10
- data: reqData
11
- }))
12
- if (!ret?.data?.success) {
13
- // ElMessage.error(ret?.data?.resultMessage || '')
14
- await Promise.reject()
15
- }
16
- }
17
- }