resolver-egretimp-plus 0.0.58 → 0.0.60

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.58",
3
+ "version": "0.0.60",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -48,6 +48,7 @@ export default {
48
48
  delete ret.onClick
49
49
  return ret
50
50
  })
51
+ const buttonActions = inject('buttonActions', {})
51
52
  const route = useRoute()
52
53
  const routeQuery= route?.query
53
54
  const hireRelatMapRules = inject('hireRelatMapRules')
@@ -188,12 +189,13 @@ export default {
188
189
  openChildDialog: openChildDialogInstance?.value,
189
190
  messageInstance: messageInstance?.value,
190
191
  messageCb,
192
+ buttonActions,
191
193
  lang: lang?.value,
192
194
  appContext
193
195
  })
194
196
  }
195
197
  return () => {
196
- const compProps = getRenderComponentProps({config: props.config, props, component: props.component, modelValue, selects})
198
+ const compProps = getRenderComponentProps({config: props.config, props, component: props.component, modelValue, selects, lang: lang.value})
197
199
  const compPropsOnClick = compProps?.onClick
198
200
  delete compProps.onClick
199
201
  const formItemPolyfill = generateFormItemPolyfill(props.config, lang.value, compProps, _isH5?.value, {
@@ -10,6 +10,7 @@ export function openChildDialog(options = {}, appContext) {
10
10
 
11
11
  instance.vm.exposed.dialogVisible.value = true
12
12
  })
13
+ instance?.vm?.exposed?.clearData()
13
14
  return instance.close
14
15
  }
15
16
  const container = document.createElement('div')
@@ -12,9 +12,14 @@ const props = defineProps({
12
12
  },
13
13
  // 请求方法的实列
14
14
  axiosInstance: {
15
- type: [Object, Function],
16
- default: () => null
17
- },
15
+ type: [Object, Function],
16
+ default: () => null
17
+ },
18
+ // 按钮的工作集合
19
+ buttonActions: {
20
+ type: Object,
21
+ default: () => ({})
22
+ },
18
23
  // config的额外属性配置
19
24
  polyfillConfigs: {
20
25
  type: Object,
@@ -59,7 +64,10 @@ function rootStoreChange(rootStore) {
59
64
 
60
65
 
61
66
  defineExpose({
62
- dialogVisible
67
+ dialogVisible,
68
+ clearData: () => {
69
+ formData.value = {}
70
+ }
63
71
  })
64
72
  </script>
65
73
  <template>
@@ -76,6 +84,7 @@ defineExpose({
76
84
  v-model="formData"
77
85
  :busiIdentityId="busiIdentityId"
78
86
  :lang="props.lang"
87
+ :buttonActions="props.buttonActions"
79
88
  :loadEvnetsReq="props.loadEvnetsReq"
80
89
  :polyfillConfigs="props.polyfillConfigs"
81
90
  :axiosInstance="props.axiosInstance"
@@ -1,6 +1,8 @@
1
+ import { isArray, isHasVal } from "../../utils/is"
1
2
  import { DATA_VALID_RULE_EXECUTE } from "../../api/builtIn"
2
3
  import { getRelateConfigKeys } from "../../rules/ruleUtils"
3
4
  import { RESULT_CODE, resultToast } from "../../utils/respone"
5
+ import { unionWith } from "../../utils/index"
4
6
 
5
7
  export async function dispatchClickEvents ({serviceList = [], axiosInstance, dynamicMapComp, rootValue, dynamicHireRelat, messageCb, compConfig, messageInstance}) {
6
8
  const dynamicMapCompKeys = Object.keys(dynamicMapComp)
@@ -43,7 +45,7 @@ export async function dispatchClickEvent(service, { dynamicMapComp, mixinService
43
45
  // ret.data = {result: {pageTotalCount: 100, result: [{},{},{},{},{}]}}
44
46
  initOutParamData(service.outParamMappingList, {dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat, outResult: ret.data})
45
47
  if (tableConfig?.vm) {
46
- const total = parseInt(ret.data?.result?.[service.pageTotalCount || 'pageTotalCount'])
48
+ const total = parseInt(ret.data?.result?.[service.pageTotalCount || 'pageCount'])
47
49
  tableConfig.vm.page.total = total
48
50
  // tableConfig.vm?.changePage(total, 'total')
49
51
  }
@@ -77,7 +79,7 @@ function getReqData(inParamMappingList = [], {dynamicMapComp, dynamicMapCompKeys
77
79
 
78
80
  function initOutParamData(outParamMappingList = [], { dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat, outResult = {} }) {
79
81
  outParamMappingList.forEach(params => {
80
- const { orignParam = '', destParam = '' } = params
82
+ const { orignParam = '', destParam = '', isList = false, primaryKeys = [] } = params
81
83
  const configCodes = getRelateConfigKeys(dynamicMapCompKeys, destParam, dynamicHireRelat)
82
84
  if (configCodes.length > 1) {
83
85
  console.error('search arg muti', params, configCodes)
@@ -87,10 +89,20 @@ function initOutParamData(outParamMappingList = [], { dynamicMapComp, dynamicMap
87
89
 
88
90
  if (compConfig) {
89
91
  const orignParamArr = orignParam ? orignParam?.split('.') : []
90
- const val = orignParamArr.reduce((ret, item) => {
92
+ let val = orignParamArr.reduce((ret, item) => {
91
93
  if (!ret) return
92
94
  return ret[item]
93
95
  }, outResult)
96
+ if (isList) {
97
+ if (!isArray(val)) {
98
+ val = isArray(compConfig.refValue) ? compConfig.refValue : []
99
+ } else if (isArray(compConfig.refValue) && isArray(val)) {
100
+ val = unionWith(compConfig.refValue, val, (arrVal, othVal) => {
101
+ const ret = (primaryKeys && primaryKeys.length) ? primaryKeys.map(key => ((isHasVal(arrVal[key]) || isHasVal(othVal[key])) && arrVal[key] == othVal[key]))?.every(item => item) : false
102
+ return ret
103
+ })
104
+ }
105
+ }
94
106
  compConfig.refValue = val
95
107
  }
96
108
  })
@@ -120,20 +132,47 @@ export function openDailg({
120
132
  dynamicMapComp,
121
133
  dynamicHireRelat,
122
134
  lang,
135
+ buttonActions,
123
136
  openChildDialog,
124
137
  appContext,
125
138
  }) {
126
139
  const busiIdentityId = pagePopupMap.popupBusiIdentityId
127
140
  const dynamicMapCompKeys = Object.keys(dynamicMapComp)
128
141
  const reqData = getReqData(pagePopupMap.inParamMappingList || [], {dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat})
129
-
130
- const outParamMappingList = pagePopupMap?.outParamMappingList?.map(item => {
142
+
143
+ let outParamMappingList = pagePopupMap?.outParamMappingList?.map(item => {
131
144
  const orignParamArr = item.orignParam ? item.orignParam.split('->') : []
132
145
  return {
133
146
  ...item,
134
147
  orignParam: item.orignParam ? orignParamArr[orignParamArr.length - 1] : ''
135
148
  }
136
149
  }) || []
150
+ let mapList = {}
151
+ // 是表格还是list
152
+ const isList = pagePopupMap?.objOrList == '1'
153
+ if (isList ) {
154
+ const primaryKeys = []
155
+ mapList = pagePopupMap?.outParamMappingList?.reduce((ret, item) => {
156
+ const { orignParam, destParam, primaryKeyFlag = '' } = item
157
+ const destParamArr = destParam ? destParam.split('->') : []
158
+ const transDestParam = destParam ? destParamArr[destParamArr.length - 1] : ''
159
+ ret[transDestParam] = orignParam
160
+ if (primaryKeyFlag == '1') {
161
+ primaryKeys.push(transDestParam)
162
+ }
163
+ return ret
164
+ }, {})
165
+
166
+ outParamMappingList = [
167
+ {
168
+ orignParam: '',
169
+ destParam: pagePopupMap.parentTable || '',
170
+ primaryKeys,
171
+ isList: true
172
+ }
173
+ ]
174
+ }
175
+
137
176
 
138
177
  let rootStore = {}
139
178
  let dialogClose = null
@@ -142,7 +181,18 @@ export function openDailg({
142
181
  polyfillConfigs[pagePopupMap.outDisplayTrigger] = (config) => {
143
182
  return {
144
183
  onClick() {
145
- initOutParamData(outParamMappingList, {dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat, outResult: rootStore.tableSelectedInfo})
184
+ const outResult = rootStore.tableSelectedInfo?.map(item => {
185
+ const retItem = {
186
+ ...item
187
+ }
188
+ Object.keys(mapList).forEach(key => {
189
+ if (mapList[key]) {
190
+ retItem[key] = item[mapList[key]]
191
+ }
192
+ })
193
+ return retItem
194
+ })
195
+ initOutParamData(outParamMappingList, {dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat, outResult})
146
196
  dialogClose?.()
147
197
  }
148
198
  }
@@ -158,6 +208,7 @@ export function openDailg({
158
208
  }
159
209
  }
160
210
  dialogClose = openChildDialog({
211
+ buttonActions,
161
212
  busiIdentityId,
162
213
  axiosInstance: axiosInstance,
163
214
  lang,
@@ -232,17 +283,20 @@ export async function executeDataValid(validConfig, { dynamicMapComp, mixinServi
232
283
  })
233
284
  }
234
285
 
235
- function closePage() {
236
- // window?.close()
237
- // window?.history?.back()
286
+ function closePage(lcpPageClosedMapVO) {
287
+ if (lcpPageClosedMapVO?.closedType == '1') {
288
+ const top = window.top
289
+ top?.close()
290
+ } else {
291
+ window?.history?.back()
292
+ }
238
293
  }
239
294
 
240
- export async function executeEventOrchestration({props, axiosInstance, rootValue, confirmInstance, dynamicMapComp, messageInstance, openChildDialog, messageCb, lang, appContext } = {}) {
295
+ export async function executeEventOrchestration({props, axiosInstance, buttonActions, rootValue, confirmInstance, dynamicMapComp, messageInstance, openChildDialog, messageCb, lang, appContext } = {}) {
241
296
  const lcpPageRuleVOLis = props.config?.lcpPageRuleVOList || []
242
297
  const PageServiceMapVOList = props.config.lcpPageServiceMapVOList || []
243
298
  const mixinServiceConfig = PageServiceMapVOList.find(service => service.serviceType === '1')
244
299
  if (lcpPageRuleVOLis?.length && mixinServiceConfig) {
245
- // for(let i = 0; i < lcpPageRuleVOLis.length; i++) {
246
300
  // 数据校验服务
247
301
  const validConfig = lcpPageRuleVOLis[0]
248
302
  const valid = await executeDataValid(validConfig, {
@@ -255,8 +309,8 @@ export async function executeEventOrchestration({props, axiosInstance, rootValue
255
309
  if (!valid) {
256
310
  return
257
311
  }
258
- // }
259
312
  }
313
+
260
314
  if (PageServiceMapVOList?.length) {
261
315
  const dynamicHireRelat = props.config?.dynamicHireRelat
262
316
  dispatchClickEvents({
@@ -281,7 +335,12 @@ export async function executeEventOrchestration({props, axiosInstance, rootValue
281
335
  appContext,
282
336
  lang,
283
337
  messageCb,
338
+ buttonActions,
284
339
  openChildDialog
285
340
  })
286
341
  }
342
+ const lcpPageClosedMapVO = props.config.lcpPageClosedMapVO
343
+ if (lcpPageClosedMapVO) {
344
+ closePage(lcpPageClosedMapVO)
345
+ }
287
346
  }
@@ -36,7 +36,7 @@ export default {
36
36
  emitKeys = Object.keys(emitKeys)
37
37
  }
38
38
  return emitKeys.reduce((ret, key) => {
39
- const eventKey = capitalize(camelize(eventKey))
39
+ const eventKey = `on${capitalize(camelize(key))}`
40
40
  if (hasOwn(attrs, eventKey)) {
41
41
  ret[eventKey] = attrs[eventKey]
42
42
  }
@@ -47,10 +47,16 @@ export default {
47
47
  const tableEvents = computed(() => {
48
48
  return getCompEvents(ElTable)
49
49
  })
50
+ const sliceTableEvents = computed(() => {
51
+ const ret = {
52
+ ...(tableEvents.value || {})
53
+ }
54
+ delete ret.onSortChange
55
+ return ret
56
+ })
50
57
  const pagenationEvents = computed(() => {
51
58
  return getCompEvents(ElPagination)
52
59
  })
53
-
54
60
  const rootStore = inject('_rootStore', {})
55
61
  const lang = inject('lang')
56
62
  const rootValue = inject('rootValue')
@@ -65,6 +71,34 @@ export default {
65
71
  return normalColumnConfig(config)
66
72
  })
67
73
  })
74
+ /** 自定义排序逻辑 ===start==== */
75
+ const sortObj = ref(null)
76
+ // "ascending", "descending", null
77
+ const onSortChange = ({ prop, order }) => {
78
+ tableEvents.value?.onSortChange?.(data)
79
+
80
+ sortObj.value = null
81
+ if (order) {
82
+ sortObj.value = {prop, order}
83
+ }
84
+ }
85
+ const sortTable = computed(() => {
86
+ if (!sortObj.value) {
87
+ return []
88
+ }
89
+ const sortList = [sortObj.value]
90
+ const ret = sortList.reduce((ret, item) => {
91
+ ret = ret.sort((a, b) => (a[item.prop] > b[item.prop] ? (item.order === 'descending' ? 1 : -1) : a[item.prop] === b[item.prop] ? 0 : (item.order === 'descending' ? -1 : 1)))
92
+ return ret
93
+ }, [...(props.refValue.value || [])])
94
+ return ret
95
+ })
96
+
97
+ const tableData = computed(() => {
98
+ return sortObj.value ? sortTable.value : (props.refValue.value || [])
99
+ })
100
+ /** 自定义排序逻辑 ===end==== */
101
+
68
102
 
69
103
  // 获取表格列的属性配置
70
104
  const getTableColumnProps = (config, idx) => {
@@ -114,9 +148,10 @@ export default {
114
148
  const metaTypeNotRender = TABLE_COLUMN_NOT_RENDER_META_TYPE.some(metaType => compareComponet(metaType, config.metaType)) || !config.metaType
115
149
  return !config.renderby && metaTypeNotRender
116
150
  }
151
+
117
152
 
118
153
  const getValue = (idx) => {
119
- return props.refValue.value?.[idx]
154
+ return tableData.value?.[idx]
120
155
  }
121
156
  const onUpdateModelValue = (val, idx) => {
122
157
  if (!props.refValue.value) {
@@ -136,11 +171,11 @@ export default {
136
171
  */
137
172
  const rowColumnConfgsMap = new Map()
138
173
  watch(() => {
139
- return props.refValue?.value?.length
174
+ return tableData?.value?.length
140
175
  }, (length) => {
141
176
  let list = []
142
177
  if (length) {
143
- const newVal = props.refValue?.value
178
+ const newVal = tableData?.value
144
179
  list = newVal.map((row, idx) => {
145
180
  const columnsCgs = rowColumnConfgsMap.get(row)
146
181
  if (columnsCgs) {
@@ -219,11 +254,11 @@ export default {
219
254
  return total + (numFlag ? Number(val) : val)
220
255
  }
221
256
  const totalRow = computed(() => {
222
- if (!props.refValue.value?.length || !totalMetaCodes.value.length || !normalTotalCodes.value.length) {
257
+ if (!tableData.value?.length || !totalMetaCodes.value.length || !normalTotalCodes.value.length) {
223
258
  return []
224
259
  }
225
260
  // 进行统计的计算
226
- const row = (props.refValue.value || []).reduce((total, row) => {
261
+ const row = (tableData.value || []).reduce((total, row) => {
227
262
  normalTotalCodes.value.forEach(codeInfo => {
228
263
  const { code, totalFn } = codeInfo
229
264
  total[code] = totalFn(total[code], row[code], row)
@@ -357,12 +392,13 @@ export default {
357
392
  return () => {
358
393
  return (
359
394
  <div class="custom-component-table">
360
- <ElTable {...tableProps.value} {...tableEvents}
395
+ <ElTable {...tableProps.value} {...sliceTableEvents.value}
361
396
  ref={(e) => {tableRef.value = e}}
362
397
  highlight-current-row={selectable.value || tableProps.value?.highlightCurrentRow ? true : false}
363
398
  onCurrentChange={selectable.value || tableProps.value?.highlightCurrentRow ? currentChange : () => {}}
364
- data={[...(props.refValue.value || []), ...totalRow.value]}
399
+ data={[...tableData.value, ...totalRow.value]}
365
400
  onSelectionChange={handleSelectionChange}
401
+ onSortChange={onSortChange}
366
402
  >
367
403
  {
368
404
  tableColumnConfigs.value.map((columnConfg, configIdx) => {
@@ -391,7 +427,7 @@ export default {
391
427
  const config = multiPmPageMetaList.value?.[$index]?.[configIdx]
392
428
  return (
393
429
  tableColumnNotRender(config) ? null :
394
- <Renderer key={`${config.columnId}-${config.rowIndex}`} class="error-tip-block" modelValue={getValue($index)} rowScope={{row, $index}} onUpdate:modelValue={(val) => { onUpdateModelValue(val, $index) }} config={config}></Renderer>
430
+ <Renderer key={`${config.columnId}-${config.rowIndex}`} class="error-tip-block" modelValue={getValue($index)} rowScope={{row, $index}} onUpdate:modelValue={(val) => { onUpdateModelValue(val, $index) }} config={config}></Renderer>
395
431
  )
396
432
  }
397
433
  }}
package/src/index.jsx CHANGED
@@ -133,7 +133,7 @@ export default {
133
133
  instance,
134
134
  isH5: props.isH5,
135
135
  rootValue: props.modelValue,
136
- axiosInstance,
136
+ axiosInstance: axiosInstance.value,
137
137
  messageInstance: props.messageInstance,
138
138
  messageCb: props.messageCb
139
139
  })
@@ -160,7 +160,7 @@ export default {
160
160
  instance,
161
161
  isH5: props.isH5,
162
162
  rootValue: props.modelValue,
163
- axiosInstance,
163
+ axiosInstance: axiosInstance.value,
164
164
  messageInstance: props.messageInstance,
165
165
  messageCb: props.messageCb
166
166
  })
@@ -2,7 +2,8 @@
2
2
  import { intersectionWith, isEqual, mergeWith, unionWith, isArray, cloneDeep } from 'lodash-es'
3
3
 
4
4
  export {
5
- cloneDeep
5
+ cloneDeep,
6
+ unionWith
6
7
  }
7
8
 
8
9
  function cached(fn) {
@@ -45,7 +45,8 @@ export const H5_PREFIX_FLAG = 'cmi-'
45
45
  export const H5_REPLACE_PREFIX_FLAG = 'H5-'
46
46
  export const DISPLAY_SHOW = '1'
47
47
  export const DISPLAY_HIDDEN = '0'
48
- export const PLAIN_TYPE_COLUMNS = ['ElText', 'ElInput', 'ElDatePicker', 'ElInputNumber']
48
+ export const PLAIN_TYPE_ALONG_COLUMNS = ['ElText']
49
+ export const PLAIN_TYPE_COLUMNS = ['ElInput', 'ElDatePicker', 'ElInputNumber']
49
50
  export const PLAIN_TYPE_OPTIONS_COLUMNS = ['ElSelect']
50
51
  export const MAIL_SEND_URL = '/gcweb/External_Mail'
51
52
  export const commonPropsType = {
@@ -160,7 +161,21 @@ export const commonPropsType = {
160
161
  const options = (selects?.value && selects?.value?.[selectKey]) || (selects?.value && selects?.value?.[`${config.metaCode}ListValue`]) || (selects?.value && selects?.value?.[referenceOptions]) || optionItemsList || []
161
162
  return options
162
163
  }
163
- }
164
+ },
165
+ placeholder: {
166
+ type: String,
167
+ default: () => [],
168
+ getValue(config, props, modelValue, selects, lang) {
169
+ return (lang?.indexOf('zh') > -1 ? config.defPlacehold : config.defPlaceholdEn) || ''
170
+ }
171
+ },
172
+ placeholderEn: {
173
+ type: String,
174
+ default: () => [],
175
+ getValue(config, props, modelValue, selects, lang) {
176
+ return config.defPlaceholdEn
177
+ }
178
+ },
164
179
  }
165
180
 
166
181
  export function calcDisable(config, mode) {
package/src/utils/is.js CHANGED
@@ -54,6 +54,10 @@ export function isWindow(val) {
54
54
  return typeof window !== 'undefined' && is(val, 'Window');
55
55
  }
56
56
 
57
+ export function isHasVal(val) {
58
+ return val !== null && val !== undefined
59
+ }
60
+
57
61
  export const isServer = typeof window === 'undefined';
58
62
 
59
63
  export const isClient = !isServer;
@@ -20,6 +20,7 @@ import {
20
20
  META_TYPE_MAP,
21
21
  H5_REPLACE_PREFIX_FLAG,
22
22
  H5_PREFIX_FLAG,
23
+ PLAIN_TYPE_ALONG_COLUMNS,
23
24
  } from './const.js'
24
25
  import { preserveCheck } from './preserveFunc.js'
25
26
  import { isArray, isFunction, isString } from './is.js'
@@ -289,7 +290,9 @@ function normalMetaType(metaType) {
289
290
 
290
291
  export function isPlainColumn(config, disabled) {
291
292
  // 表格中中的列,可以根据配置进行转换为普通形式,表格原生支持的tooltip
292
-
293
+ if (findComponent(PLAIN_TYPE_ALONG_COLUMNS, config.renderby || config.metaType) !== -1) {
294
+ return true
295
+ }
293
296
  if (config.isColumn && disabled) {
294
297
  if (config.plainColumn) {
295
298
  return true
@@ -350,7 +353,7 @@ export function getComponentForConfig({config, disabled, getNativeComps}) {
350
353
  }
351
354
 
352
355
  // 获取渲染组件的props配置数据
353
- export function getRenderComponentProps({ props, component, modelValue, selects }) {
356
+ export function getRenderComponentProps({ props, component, modelValue, selects, lang }) {
354
357
  if (!component) return {}
355
358
  let config = props.config
356
359
  if (findComponent(['CustomComponentTabs'], config.renderby || config.metaType) !== -1) {
@@ -373,7 +376,7 @@ export function getRenderComponentProps({ props, component, modelValue, selects
373
376
  }
374
377
  })
375
378
  }
376
- const commonProps = getCommonProps(config, props, modelValue, selects)
379
+ const commonProps = getCommonProps(config, props, modelValue, selects, lang)
377
380
  defprops.style = {
378
381
  ...config.style,
379
382
  ...getRenderCompMargins(config),
@@ -393,9 +396,9 @@ function getBuildCompDefaultWidth(config) {
393
396
  }
394
397
  }
395
398
  // 获取渲染组件开放的配置props,提供给所有自定义组件
396
- function getCommonProps(config, props, modelValue, selects) {
399
+ function getCommonProps(config, props, modelValue, selects, lang) {
397
400
  return Object.keys(commonPropsType).reduce((ret, key) => {
398
- ret[key] = commonPropsType[key].getValue(config, props, modelValue, selects)
401
+ ret[key] = commonPropsType[key].getValue(config, props, modelValue, selects, lang)
399
402
  return ret
400
403
  }, {})
401
404
  }