resolver-egretimp-plus 0.1.19 → 0.1.20

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.19",
3
+ "version": "0.1.20",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -0,0 +1,70 @@
1
+ <template>
2
+ <TabPane v-bind="{...attrs, ...tabPaneProps, ...polyProps}">
3
+ <template #label v-if="labelRenderContent || slotsPageMetalist.length">
4
+ <component :is="labelRenderContent" v-if="labelRenderContent"></component>
5
+ <Renderer v-else :config="slotsPageMetalist" v-model="props.refValue.value"></Renderer>
6
+ </template>
7
+ <ElRow>
8
+ <Renderer :config="(props.config.pmPageMetaList || []).filter(config => !config.collapseSlot)" v-model="props.refValue.value"></Renderer>
9
+ </ElRow>
10
+ <template v-for="(_, key) in slots" :key="key" v-slot:[key]="scope">
11
+ <slot :name="key" v-bind="scope"></slot>
12
+ </template>
13
+ </TabPane>
14
+ </template>
15
+ <script setup>
16
+ import { ElTabPane, ElRow } from 'element-plus'
17
+ import Renderer from '../../renderer.jsx'
18
+ import { computed, inject, useAttrs, useSlots } from 'vue'
19
+ import { commonPropsType } from '../../utils/index.js'
20
+ import { TabPane } from '../tabs'
21
+ import { h } from 'vue'
22
+
23
+ const slots = useSlots()
24
+ const props = defineProps({
25
+ ...commonPropsType,
26
+ ...TabPane.props,
27
+ hidden: [String, Boolean, Number],
28
+ activeNames: String,
29
+ })
30
+ const attrs = useAttrs()
31
+
32
+ const slotsPageMetalist = computed(() => {
33
+ return (props.config.pmPageMetaList || []).filter(config => config.collapseSlot)
34
+ })
35
+
36
+ const lang = inject('lang')
37
+ const polyProps = computed(() => {
38
+ return {
39
+ label: lang.value.indexOf('zh') > -1 ? props.config?.metaNameZh : props.config?.metaNameEn,
40
+ name: props.config?.metaCode
41
+ }
42
+ })
43
+ const tabPaneProps = computed(() => {
44
+ const ret = Object.keys(TabPane.props).reduce((ret, key) => {
45
+ ret[key] = props[key]
46
+ return ret
47
+ }, {})
48
+ if (typeof ret.hidden !== 'boolean') {
49
+ ret.hidden = ret.hidden == '1'
50
+ }
51
+ return ret
52
+ })
53
+
54
+ // 自定义渲染label方法
55
+ const labelRenderContent = computed(() => {
56
+ const context = props.config?.labelRender?.(getLableRenderParams())
57
+ if (typeof context === 'string') {
58
+ return h('span', context)
59
+ } else {
60
+ return context
61
+ }
62
+ })
63
+ function getLableRenderParams() {
64
+ return {
65
+ config: props.config,
66
+ tabPaneData: props.refValue.value,
67
+ isActive: props.activeNames === props.config?.metaCode,
68
+ }
69
+ }
70
+ </script>
@@ -1,70 +1,20 @@
1
1
  <template>
2
- <TabPane v-bind="{...attrs, ...tabPaneProps, ...polyProps}">
3
- <template #label v-if="labelRenderContent || slotsPageMetalist.length">
4
- <component :is="labelRenderContent" v-if="labelRenderContent"></component>
5
- <Renderer v-else :config="slotsPageMetalist" v-model="props.refValue.value"></Renderer>
6
- </template>
7
- <ElRow>
8
- <Renderer :config="(props.config.pmPageMetaList || []).filter(config => !config.collapseSlot)" v-model="props.refValue.value"></Renderer>
9
- </ElRow>
10
- <template v-for="(_, key) in slots" :key="key" v-slot:[key]="scope">
11
- <slot :name="key" v-bind="scope"></slot>
12
- </template>
13
- </TabPane>
2
+ <component :is="comp" v-bind="attrs"></component>
14
3
  </template>
15
4
  <script setup>
16
- import { ElTabPane, ElRow } from 'element-plus'
17
- import Renderer from '../../renderer.jsx'
18
- import { computed, inject, useAttrs, useSlots } from 'vue'
19
- import { commonPropsType } from '../../utils/index.js'
20
- import { TabPane } from '../tabs'
21
- import { h } from 'vue'
5
+ import { useAttrs } from 'vue'
6
+ import CustomComponentCycleTabPane from './CustomComponentCycleTabPane.vue'
7
+ import CustomComponentNativeTabPane from './CustomComponentNativeTabPane.vue'
8
+ import { computed } from 'vue'
22
9
 
23
- const slots = useSlots()
24
- const props = defineProps({
25
- ...commonPropsType,
26
- ...TabPane.props,
27
- hidden: [String, Boolean, Number],
28
- activeNames: String,
29
- })
30
10
  const attrs = useAttrs()
31
-
32
- const slotsPageMetalist = computed(() => {
33
- return (props.config.pmPageMetaList || []).filter(config => config.collapseSlot)
34
- })
35
-
36
- const lang = inject('lang')
37
- const polyProps = computed(() => {
38
- return {
39
- label: lang.value.indexOf('zh') > -1 ? props.config?.metaNameZh : props.config?.metaNameEn,
40
- name: props.config?.metaCode
41
- }
42
- })
43
- const tabPaneProps = computed(() => {
44
- const ret = Object.keys(TabPane.props).reduce((ret, key) => {
45
- ret[key] = props[key]
46
- return ret
47
- }, {})
48
- if (typeof ret.hidden !== 'boolean') {
49
- ret.hidden = ret.hidden == '1'
11
+ const props = defineProps({
12
+ isCycle: {
13
+ type: [String, Number],
14
+ default: '0'
50
15
  }
51
- return ret
52
16
  })
53
-
54
- // 自定义渲染label方法
55
- const labelRenderContent = computed(() => {
56
- const context = props.config?.labelRender?.(getLableRenderParams())
57
- if (typeof context === 'string') {
58
- return h('span', context)
59
- } else {
60
- return context
61
- }
17
+ const comp = computed(() => {
18
+ return props.isCycle == '1' ? CustomComponentCycleTabPane : CustomComponentNativeTabPane
62
19
  })
63
- function getLableRenderParams() {
64
- return {
65
- config: props.config,
66
- tabPaneData: props.refValue.value,
67
- isActive: props.activeNames === props.config?.metaCode,
68
- }
69
- }
70
20
  </script>
@@ -41,13 +41,23 @@ const activeNames = computed({
41
41
  get() {
42
42
  const currentTab = tabpanes.value.find(tab => tab.defaultShowFlag == '1')
43
43
  const currentCycleTab = tabpanes.value.find(tab => tab.currentCode)
44
- return (currentTab && currentTab.metaCode)
45
- || (currentCycleTab && currentCycleTab.currentCode)
46
- || tabpanes.value[0] && ((assertMetaType(tabpanes.value[0], 'CustomComponentCycleTabPane') && `${tabpanes.value[0].metaCode}-0`) || (tabpanes.value[0].metaType === 'CustomComponentTabPane' && tabpanes.value[0].metaCode))
44
+ if (currentTab) {
45
+ return currentTab?.isCycle == '1' ? `${currentTab.metaCode}-0` : currentTab.metaCode
46
+ }
47
+ if (currentCycleTab) {
48
+ return currentCycleTab.currentCode
49
+ }
50
+ if (tabpanes.value[0]) {
51
+ if (assertMetaType(tabpanes.value[0], 'CustomComponentCycleTabPane') || tabpanes.value[0]?.isCycle == '1') {
52
+ return `${tabpanes.value[0].metaCode}-0`
53
+ } else {
54
+ return tabpanes.value[0].metaCode
55
+ }
56
+ }
47
57
  },
48
58
  set(val) {
49
59
  tabpanes.value.forEach(tab => {
50
- if (assertMetaType(tab, 'CustomComponentCycleTabPane')) {
60
+ if (assertMetaType(tab, 'CustomComponentCycleTabPane') || tab?.isCycle == '1') {
51
61
  if (/^cycleTabpane-(\d+)$/.test(val)) {
52
62
  tab.currentCode = val
53
63
  } else {
@@ -67,14 +67,14 @@ function validFail(config, cycleIdx) {
67
67
  if (tab.metaType === 'CustomComponentTabPane') {
68
68
  tab.defaultShowFlag = '0'
69
69
  }
70
- if (tab.metaType === 'CustomComponentCycleTabPane') {
70
+ if (tab.metaType === 'CustomComponentCycleTabPane' || tab?.isCycle == '1') {
71
71
  tab.currentCode = ''
72
72
  }
73
73
  })
74
- if (type === 'CustomComponentTabPane') {
74
+ if (type === 'CustomComponentTabPane' && config?.isCycle != '1') {
75
75
  config.defaultShowFlag = '1'
76
76
  }
77
- if (type === 'CustomComponentCycleTabPane') {
77
+ if (type === 'CustomComponentCycleTabPane' || config?.isCycle == '1') {
78
78
  config.currentCode = `${config.metaCode}-${cycleIdx}`
79
79
  }
80
80
  break