resolver-egretimp-plus 0.0.29 → 0.0.31

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.
@@ -2,13 +2,29 @@ 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"
6
+ import mock from "./mock"
5
7
 
6
8
  export function usePageConfig() {
7
9
  const pageConfigRef = ref(null)
8
10
  const hireRelatMapRulesRef = ref(null)
9
11
  const mapCompRef = ref(null)
10
- function initPageConfig(config, lang, polyfillConfigs, instance, isH5) {
11
- const { pageConfig, mapComp, hireRelatMapRules } = parsePageConfig(config, lang, polyfillConfigs, instance, isH5)
12
+ function initPageConfig({
13
+ config,
14
+ lang,
15
+ polyfillConfigs,
16
+ instance,
17
+ isH5,
18
+ rootValue,
19
+ axiosInstance,
20
+ messageInstance
21
+ }) {
22
+ const { pageConfig, mapComp, hireRelatMapRules } = parsePageConfig({
23
+ config, lang, polyfillConfigs, instance, isH5,
24
+ rootValue,
25
+ axiosInstance,
26
+ messageInstance
27
+ })
12
28
  pageConfigRef.value = pageConfig
13
29
  hireRelatMapRulesRef.value = hireRelatMapRules
14
30
  mapCompRef.value = mapComp
@@ -31,7 +47,8 @@ export function useBuildInData(messageTipInstance, loadingInstance) {
31
47
  }
32
48
  buildInRequest(QUERY_PAGE_CONFIG_DATA, reqData).then(ret => {
33
49
  if (ret.data.success) {
34
- pageConfig.value = ret.data.result
50
+ pageConfig.value = normalPageConfigs(mock)
51
+ // pageConfig.value = normalPageConfigs(ret.data.result)
35
52
  getSelects(ret.data.result?.pmBusinessIdentityVO?.tenantId)
36
53
  return
37
54
  }
package/src/index.jsx CHANGED
@@ -75,11 +75,11 @@ export default {
75
75
  default: () => ({composeComponents: {}})
76
76
  },
77
77
  loadingInstance: {
78
- type: Object,
78
+ type: [Object, Function],
79
79
  default: () => null
80
80
  },
81
81
  messageInstance: {
82
- type: Object,
82
+ type: [Object, Function],
83
83
  default: () => null
84
84
  },
85
85
  loadEvnetsReq: {
@@ -109,7 +109,16 @@ export default {
109
109
  const instance = getCurrentInstance()
110
110
  const { initPageConfig, pageConfigRef, mapCompRef, hireRelatMapRulesRef } = usePageConfig()
111
111
 
112
- initPageConfig(props.config, props.lang, props.polyfillConfigs, instance, props.isH5)
112
+ initPageConfig({
113
+ config: props.config,
114
+ lang: props.lang,
115
+ polyfillConfigs: props.polyfillConfigs,
116
+ instance,
117
+ isH5: props.isH5,
118
+ rootValue: props.modelValue,
119
+ axiosInstance,
120
+ messageInstance: props.messageInstance
121
+ })
113
122
  // 触发加载事件执行
114
123
  executeLoadServices(
115
124
  props.config?.pmPageServiceMapVOList || [],
@@ -126,7 +135,16 @@ export default {
126
135
  )
127
136
 
128
137
  watch(toRef(props, 'config'), () => {
129
- initPageConfig(props.config, props.lang, props.polyfillConfigs, instance, props.isH5)
138
+ initPageConfig({
139
+ config: props.config,
140
+ lang: props.lang,
141
+ polyfillConfigs: props.polyfillConfigs,
142
+ instance,
143
+ isH5: props.isH5,
144
+ rootValue: props.modelValue,
145
+ axiosInstance,
146
+ messageInstance: props.messageInstance
147
+ })
130
148
  executeLoadServices(
131
149
  props.config?.pmPageServiceMapVOList || [],
132
150
  {
@@ -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
  })
@@ -205,4 +205,30 @@ export function generateConfigsHireRelat(configs, hireRelat = '', retObj = {}) {
205
205
  }
206
206
  })
207
207
  return retObj
208
+ }
209
+
210
+ export function getRelateConfigKeys(keys = [], path = '', relatePath = '') {
211
+ const pathArr = path ? path.split('->') : []
212
+ const relatePathArr = relatePath ? relatePath.split('->') : []
213
+ let diffIdx = -1 // 此标识表示,是从那个所以开始,code不一样了
214
+ let currentIdx = 0
215
+ while(diffIdx === -1 && currentIdx < pathArr.length && currentIdx < relatePathArr.length) {
216
+ const pathCode = pathArr[currentIdx]
217
+ const pathCodeReg = new RegExp(`^${pathCode}(\\[\\d+\\])?$`)
218
+ const relateCode = relatePathArr[currentIdx]
219
+ if (pathCodeReg.test(relateCode)) {
220
+ pathArr.splice(currentIdx, 1, relateCode)
221
+ currentIdx++
222
+ } else {
223
+ diffIdx = currentIdx
224
+ }
225
+ }
226
+ const normalPath = pathArr.reduce((ret, pathCode) => {
227
+ const noramlPathCode = pathCode.replace(/([\[\]]{1})/g, (_,b) => {return `\\${b}`})
228
+ return ret + (ret ? `->${noramlPathCode}(\\[\\d+\\])?` : `${noramlPathCode}(\\[\\d+\\])?`)
229
+ }, '')
230
+ const normalPathReg = new RegExp(`^${normalPath}$`)
231
+ return keys.filter(code => {
232
+ return normalPathReg.test(code)
233
+ })
208
234
  }
@@ -25,6 +25,7 @@ import { preserveCheck } from './preserveFunc.js'
25
25
  import { isArray, isFunction, isString } from './is.js'
26
26
  import CustomComponentPlain from '../components/packages-web/CustomComponentPlain.vue'
27
27
  import QuestionFilled from '../components/icons/question-filled.vue'
28
+ import { dispatchClickEvent, dispatchClickEvents, getTableConfig } from '../components/helper/button.js'
28
29
 
29
30
  // 解析配置中的defStyle属性
30
31
  export function parseDefStyle(defStyle) {
@@ -100,12 +101,28 @@ function generateFormConfig(lang = 'zh', isH5) {
100
101
  *
101
102
  * @param {*} config 通过接口获取的配置对象
102
103
  */
103
- export function parsePageConfig(config, lang, polyfillConfigs, instance, isH5) {
104
+ export function parsePageConfig({
105
+ config, lang, polyfillConfigs, instance, isH5,
106
+ rootValue,
107
+ axiosInstance,
108
+ messageInstance
109
+ }) {
104
110
  if (!config) return {}
105
111
  const formConfig = generateFormConfig(lang, isH5)
106
112
  const hireRelatMapRules = getCodeMapRules(config)
107
113
  formConfig.pmPageMetaList = config.pmPageMetaList
108
- let { pageConfig, mapComp } = normalConfig({ polyfillConfigs, instance }, formConfig)
114
+ const cbs = []
115
+ let { pageConfig, mapComp } = normalConfig({
116
+ polyfillConfigs,
117
+ instance,
118
+ cbs,
119
+ rootValue,
120
+ axiosInstance,
121
+ messageInstance
122
+ }, formConfig)
123
+ cbs.forEach((cb) => {
124
+ cb()
125
+ })
109
126
  return {
110
127
  pageConfig,
111
128
  mapComp,
@@ -119,7 +136,14 @@ export function parsePageConfig(config, lang, polyfillConfigs, instance, isH5) {
119
136
  * }
120
137
  * @param {*} config
121
138
  */
122
- export function normalConfig({ polyfillConfigs, instance }, config, hireRelat = '', mapComp = {}, needformItem = false) {
139
+ export function normalConfig({
140
+ polyfillConfigs,
141
+ instance,
142
+ cbs = [],
143
+ rootValue,
144
+ axiosInstance,
145
+ messageInstance
146
+ }, config, hireRelat = '', mapComp = {}, needformItem = false) {
123
147
  const metaCode = config.metaCode || ''
124
148
  hireRelat += hireRelat ? `->${metaCode}` : metaCode
125
149
 
@@ -153,7 +177,14 @@ export function normalConfig({ polyfillConfigs, instance }, config, hireRelat =
153
177
  // 如果有子项,需要进行递归遍历
154
178
  if (config.pmPageMetaList && config.pmPageMetaList.length) {
155
179
  config.pmPageMetaList = config.pmPageMetaList.map(metaItem => {
156
- const { pageConfig } = normalConfig({ polyfillConfigs, instance }, metaItem, hireRelat, mapComp, needformItem || [FORM_META_TYPE].includes(metaType))
180
+ const { pageConfig } = normalConfig({
181
+ cbs,
182
+ polyfillConfigs,
183
+ instance,
184
+ rootValue,
185
+ axiosInstance,
186
+ messageInstance
187
+ }, metaItem, hireRelat, mapComp, needformItem || [FORM_META_TYPE].includes(metaType))
157
188
  return pageConfig
158
189
  })?.sort((a, b) => a.seqNo - b.seqNo)
159
190
  }
@@ -177,12 +208,53 @@ export function normalConfig({ polyfillConfigs, instance }, config, hireRelat =
177
208
  }
178
209
  mapComp[hireRelat] = pageConfig
179
210
  parsePolyfillConfigs({ polyfillConfigs, instance }, pageConfig)
211
+ if(pageConfig.lcpPageServiceMapVOList?.length) {
212
+ cbs.push(() => {
213
+ const tabsServices = getTableServices(pageConfig.lcpPageServiceMapVOList, {dynamicMapComp: mapComp, dynamicMapCompKeys: Object.keys(mapComp), hireRelat})
214
+ tabsServices.forEach((({tableConfig, service}) => {
215
+ tableConfig.currentChange = (val, props, page) => {
216
+ setTimeout(() => {
217
+ debugger
218
+ const dynamicMapComp = props.config.dynamicMapComp
219
+ const dynamicMapCompKeys = Object.keys(dynamicMapComp)
220
+ const dynamicHireRelat = props.config.dynamicHireRelat
221
+ dispatchClickEvent(service, { dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat, rootValue, axiosInstance, messageInstance })
222
+ }, 0);
223
+ }
224
+ tableConfig.sizeChange = (val, props, page) => {
225
+ setTimeout(() => {
226
+ const dynamicMapComp = props.config.dynamicMapComp
227
+ const dynamicMapCompKeys = Object.keys(dynamicMapComp)
228
+ const dynamicHireRelat = props.config.dynamicHireRelat
229
+ dispatchClickEvent(service, { dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat, rootValue, axiosInstance, messageInstance })
230
+ }, 0);
231
+ }
232
+ }))
233
+ })
234
+ }
180
235
  return {
181
236
  mapComp,
182
237
  pageConfig
183
238
  }
184
239
  }
185
240
 
241
+ // 从按钮的服务编排中,获取到按钮中配置的表格中的config,并且绑定表格的分页
242
+ function getTableServices(lcpPageServiceMapVOList = [], { dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat }) {
243
+ const searchServices = lcpPageServiceMapVOList.filter(service => service.transactionType == '1')
244
+ if (searchServices.length) {
245
+ return searchServices.map(service => {
246
+ const tableConfig = getTableConfig(service?.outParamMappingList, { dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat })
247
+ if (tableConfig) {
248
+ return {
249
+ tableConfig,
250
+ service
251
+ }
252
+ }
253
+ }).filter(item => !!item)
254
+ }
255
+ return []
256
+ }
257
+
186
258
  function parsePolyfillConfigs({ polyfillConfigs, instance }, config) {
187
259
  const hireRelat = config.hireRelat
188
260
  const findKeys = Object.keys(polyfillConfigs).filter(key => hireRelat.endsWith(key))