resolver-egretimp-plus 0.0.163 → 0.0.165

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.163",
3
+ "version": "0.0.165",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -543,6 +543,8 @@ function closePage(lcpPageClosedMapVO) {
543
543
  }
544
544
 
545
545
  export async function executeEventOrchestration({
546
+ beforeDataValidRequestService,
547
+ afterDataValidRequestService,
546
548
  beforeRequestService,
547
549
  afterRequestService,
548
550
  beforeOpenDialog,
@@ -601,24 +603,51 @@ export async function executeEventOrchestration({
601
603
  }
602
604
  }
603
605
  if (lcpPageRuleVOLis?.length) {
604
- // 数据校验服务
605
- const validConfig = lcpPageRuleVOLis[0]
606
- const valid = await executeDataValid(validConfig, {
607
- dynamicMapComp,
608
- requestTraceId,
609
- rootValue,
610
- axiosInstance,
611
- mixinServiceConfig,
612
- compConfig: props.config,
613
- confirmInstance,
614
- builtPolyfillReq,
615
- beforeRequestService: normalBeforeRequestService,
616
- afterRequestService: normalAfterRequestService,
617
- lang
618
- })
619
- if (!valid) {
620
- return
606
+ let normalBeforeDataValidRequestService
607
+ let normalAfterDataValidRequestService
608
+ const configBeforeDataValidRequestService = props.config?.beforeDataValidRequestService
609
+ if (configBeforeDataValidRequestService || beforeDataValidRequestService) {
610
+ normalBeforeDataValidRequestService = async (...arg) => {
611
+ let beforeRequestServiceRet = true
612
+ if (beforeDataValidRequestService) {
613
+ beforeRequestServiceRet = beforeDataValidRequestService?.(...arg)
614
+ }
615
+ const beforeRequestServiceRetValid = await beforeRequestServiceRet
616
+ if (beforeRequestServiceRetValid === false) {
617
+ return false
618
+ }
619
+ if (configBeforeDataValidRequestService) {
620
+ return configBeforeDataValidRequestService?.(...arg)
621
+ } else {
622
+ return true
623
+ }
621
624
  }
625
+ }
626
+ const configAfterDataValidRequestService = props.config?.afterDataValidRequestService
627
+ if (configAfterDataValidRequestService || afterDataValidRequestService) {
628
+ normalAfterDataValidRequestService = (...arg) => {
629
+ afterDataValidRequestService?.(...arg)
630
+ configAfterDataValidRequestService?.(...arg)
631
+ }
632
+ }
633
+ // 数据校验服务
634
+ const validConfig = lcpPageRuleVOLis[0]
635
+ const valid = await executeDataValid(validConfig, {
636
+ dynamicMapComp,
637
+ requestTraceId,
638
+ rootValue,
639
+ axiosInstance,
640
+ mixinServiceConfig,
641
+ compConfig: props.config,
642
+ confirmInstance,
643
+ builtPolyfillReq,
644
+ beforeRequestService: normalBeforeDataValidRequestService,
645
+ afterRequestService: normalAfterDataValidRequestService,
646
+ lang
647
+ })
648
+ if (!valid) {
649
+ return
650
+ }
622
651
  }
623
652
 
624
653
  if (PageServiceMapVOList?.length) {
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { commonPropsType, formatDate, formatAmount, getConfigOptions, hasOwn } from '../../utils/index.js'
2
+ import { commonPropsType, formatDate, formatAmount, getConfigOptions, hasOwn, isPlainObject } from '../../utils/index.js'
3
3
  import { computed, inject, onMounted, reactive, ref, useAttrs, watch } from 'vue'
4
4
 
5
5
  const attrs = useAttrs()
@@ -79,6 +79,11 @@ const tableEvents = computed(() => {
79
79
  if (attrs.onRowclick) {
80
80
  attrs.onRowclick?.(e)
81
81
  }
82
+ },
83
+ onTogglelandscape: (e) => {
84
+ if (attrs.onTogglelandscape) {
85
+ attrs.onTogglelandscape?.(e)
86
+ }
82
87
  }
83
88
  }
84
89
  return ret
@@ -146,6 +151,80 @@ const tableKey = computed(() => {
146
151
  return `${tableProps.value.card}${tableProps.value.display}${!tableProps.value.card ? page.pageNum : 0}`
147
152
  })
148
153
 
154
+ // 统计行定义 ====start======
155
+ const totalMetaCodes = computed(() => {
156
+ return props.config?.totalMetaCodes || []
157
+ })
158
+ const normalTotalCodes = computed(() => {
159
+ return totalMetaCodes.value.map(code => {
160
+ if (typeof code === 'string') {
161
+ return {
162
+ code,
163
+ totalFn: defaultTotalFn,
164
+ totalFormatter: defaultTotalFormatter
165
+ }
166
+ } else {
167
+ if (isPlainObject(code) && hasOwn(code, 'code')) {
168
+ code.totalFn = typeof code.totalFn === 'function' ? code.totalFn : defaultTotalFn
169
+ code.totalFormatter = typeof code.totalFormatter === 'function' ? code.totalFormatter : defaultTotalFormatter
170
+ return code
171
+ }
172
+ return null
173
+ }
174
+ }).filter(codeInfo => !!codeInfo)
175
+ })
176
+ const totalCodeFormatters = (row) => {
177
+ if (!row?.length) {
178
+ return []
179
+ }
180
+ const totalObj = {
181
+ [pmPageMetaList.value?.[0]?.metaCode]: lang.value.indexOf('zh') > -1 ? '总计' : 'Total',
182
+ ...row[0]
183
+ }
184
+ normalTotalCodes.value.map((codeInfo) => {
185
+ const { code, totalFormatter } = codeInfo
186
+ if (totalFormatter && typeof totalFormatter === 'function') {
187
+ totalObj[code] = totalFormatter(totalObj[code], totalObj, code)
188
+ }
189
+ })
190
+ return [totalObj]
191
+ }
192
+ const defaultTotalFormatter = (val, total, code) => {
193
+ let codeConfig = pmPageMetaList.value?.find(item => item.metaCode == code)
194
+ if (codeConfig) {
195
+ normalResult(total, codeConfig)
196
+ return total[code]
197
+ }
198
+ return val
199
+ }
200
+ const defaultTotalFn = (total, val, row) => {
201
+ if (val === undefined || val === null) {
202
+ val = !isNaN(Number(val)) ? 0 : ''
203
+ } else {
204
+ val = val.toString().replace(/[^\d\.\-]/g, '')
205
+ }
206
+ const numFlag = !isNaN(Number(val))
207
+ if (total === null || total === undefined) {
208
+ total = numFlag ? 0 : ''
209
+ }
210
+ return total + (numFlag ? Number(val) : val)
211
+ }
212
+ const totalRow = computed(() => {
213
+ if (!normalTableData.value?.length || !totalMetaCodes.value.length || !normalTotalCodes.value.length) {
214
+ return []
215
+ }
216
+ // 进行统计的计算
217
+ const row = (normalTableData.value || []).reduce((total, row) => {
218
+ normalTotalCodes.value.forEach(codeInfo => {
219
+ const { code, totalFn } = codeInfo
220
+ total[code] = totalFn(total[code], row[code], row)
221
+ })
222
+ return total
223
+ }, { totalFlag: true })
224
+ return [row]
225
+ })
226
+ // 统计行定义 ====end======
227
+
149
228
  onMounted(() => {
150
229
  watch(() => {
151
230
  return {
@@ -161,7 +240,7 @@ onMounted(() => {
161
240
  setTimeout(() => {
162
241
  try {
163
242
  // 这边有的时候会报错
164
- tableRef.value?.setTableData(val)
243
+ tableRef.value?.setTableData([...val,...totalCodeFormatters(totalRow.value)])
165
244
  } catch (error) {
166
245
  }
167
246
  }, 100);
@@ -192,28 +271,31 @@ function normalVal(val, options) {
192
271
  return val
193
272
  }
194
273
 
274
+ function normalResult(ret, config) {
275
+ ret[config.metaCode] = normalVal(ret[config.metaCode], getOptions(config))
276
+ if (config?.dateFormat) {
277
+ ret[config.metaCode] = formatDate(ret[config.metaCode], config.dateFormat)
278
+ }
279
+ if (config?.amountFormat) {
280
+ ret[config.metaCode] = formatAmount(ret[config.metaCode], config.amountFormat)
281
+ }
282
+ if (typeof config?.formatter === "function") {
283
+ ret[config.metaCode] = config.formatter(ret[config.metaCode], config, props)
284
+ }
285
+ }
195
286
 
196
287
  function normalTableRowValue(row) {
197
288
  const ret = {
198
289
  ...row
199
290
  }
200
291
  pmPageMetaList.value.forEach(config => {
201
- ret[config.metaCode] = normalVal(ret[config.metaCode], getOptions(config))
202
- if (config?.dateFormat) {
203
- ret[config.metaCode] = formatDate(ret[config.metaCode], config.dateFormat)
204
- }
205
- if (config?.amountFormat) {
206
- ret[config.metaCode] = formatAmount(ret[config.metaCode], config.amountFormat)
207
- }
208
- if (typeof config?.formatter === "function") {
209
- ret[config.metaCode] = config.formatter(ret[config.metaCode], config, props)
210
- }
292
+ normalResult(ret, config)
211
293
  })
212
294
  return ret
213
295
  }
214
296
  </script>
215
297
  <template>
216
- <cmi-table ref="tableRef" :key="tableKey" v-bind="tableProps" @rowclick="tableEvents.onRowclick">
298
+ <cmi-table ref="tableRef" :key="tableKey" v-bind="tableProps" @rowclick="tableEvents.onRowclick" @togglelandscape="tableEvents.onTogglelandscape">
217
299
  <cmi-table-column
218
300
  v-for="column in pmPageMetaList" :key="column.metaCode"
219
301
  v-bind="{