resolver-egretimp-plus 0.0.278 → 0.0.280

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.278",
3
+ "version": "0.0.280",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -91,9 +91,13 @@ export default {
91
91
  return normalColumnConfig(config)
92
92
  })
93
93
  })
94
+ let pageSize = 5
95
+ if (props.config?.pageSize) {
96
+ pageSize = parseInt(props.config.pageSize) || 5
97
+ }
94
98
  const page = reactive({
95
99
  pageNum: 1,
96
- pageSize: 5,
100
+ pageSize,
97
101
  total: 0,
98
102
  })
99
103
  const isFrontPage = computed(() => {
@@ -135,21 +135,27 @@ export default {
135
135
  modelValue.value = ''
136
136
  }
137
137
 
138
+ const getRenderSlots = function () {
139
+ return {
140
+ ...slots,
141
+ default: () => options.value?.map(option => {
142
+ return (
143
+ <ElOption
144
+ key={option.columnValue}
145
+ label={lang?.value?.indexOf('zh') > -1 ? option.columnDesc_zh : option.columnDesc}
146
+ value={option.columnValue}
147
+ disabled={option.columnStatus == '0' || option.columnStatus == '2'}
148
+ />
149
+ )
150
+ })
151
+ }
152
+ }
153
+
138
154
  return () => {
139
155
  return (
140
156
  <ElSelect class="custom-self-select" { ...{...attrs, ...selectProps.value }} v-model={value.value} onClear={clear}>
141
157
  {
142
- {
143
- default: () => options.value?.map(option => (
144
- <ElOption
145
- key={option.columnValue}
146
- label={lang?.value?.indexOf('zh') > -1 ? option.columnDesc_zh : option.columnDesc}
147
- value={option.columnValue}
148
- disabled={option.columnStatus == '0' || option.columnStatus == '2'}
149
- />
150
- )),
151
- ...slots
152
- }
158
+ getRenderSlots()
153
159
  }
154
160
  </ElSelect>
155
161
  )
@@ -0,0 +1,155 @@
1
+ <template>
2
+ <ElSelect class="custom-self-select" v-bind="{...attrs, ...selectProps }" v-model="value" @clear="clear">
3
+ <ElOption v-for="option in options"
4
+ :key="option.columnValue"
5
+ :label="lang.indexOf('zh') > -1 ? option.columnDesc_zh : option.columnDesc"
6
+ :value="option.columnValue"
7
+ :disabled="option.columnStatus == '0' || option.columnStatus == '2'"
8
+ >
9
+ <template v-for="(_, key) in optionsSlots" :key="key" v-slot:[key]="scope">
10
+ <slot :name="key" v-bind="scope"></slot>
11
+ </template>
12
+ </ElOption>
13
+ <template v-for="(_, key) in slots" :key="key" v-slot:[key]="scope">
14
+ <slot :name="key" v-bind="scope"></slot>
15
+ </template>
16
+ </ElSelect>
17
+ </template>
18
+ <script setup>
19
+ import { ElSelect, ElOption } from 'element-plus'
20
+ import { computed, defineProps, inject, useAttrs, useSlots } from 'vue'
21
+ import { commonPropsType, getComponentSolt } from '../../utils/index.js'
22
+
23
+ const VALUE_TYPES = {
24
+ LIST: 'list',
25
+ OBJECT: 'object',
26
+ STRING: 'string',
27
+ }
28
+ const slots = useSlots()
29
+ const optionsSlots = computed(() => {
30
+ return getComponentSolt({
31
+ config: props.config,
32
+ slotKey: 'optionsSlots'
33
+ }) || {}
34
+ })
35
+ const modelValue = defineModel()
36
+ const props = defineProps({
37
+ ...ElSelect.props,
38
+ ...commonPropsType,
39
+ multiple: [String, Boolean],
40
+ filterable: [String, Boolean],
41
+ multipleLimit: [String, Number],
42
+ rangeOptions: Array,
43
+ excludeOptions: Array,
44
+ // 多选的分割符号
45
+ separator: {
46
+ type: [String],
47
+ default: ','
48
+ }
49
+ })
50
+ const attrs = useAttrs()
51
+ const separator = computed(() => {
52
+ return props.separator
53
+ })
54
+ const valueTypes = computed(() => {
55
+ return props.config?.valueType
56
+ })
57
+ // 值是list 还是,连起来的string
58
+ const isStrVal = computed(() => {
59
+ // valueType 值为 list 或者 string
60
+ return valueTypes.value !== VALUE_TYPES.LIST && valueTypes.value !== VALUE_TYPES.OBJECT
61
+ })
62
+ const isObject = computed(() => {
63
+ return valueTypes.value === VALUE_TYPES.OBJECT
64
+ })
65
+
66
+ // 是否为多选
67
+ const isMutiple = computed(() => {
68
+ return props.multiple == '1'
69
+ })
70
+
71
+ const options = computed(() => {
72
+ let list = props.options
73
+ if (props.rangeOptions && props.rangeOptions.length) {
74
+ list = list?.filter?.(item => props.rangeOptions?.some(subValue => subValue == item.columnValue))
75
+ }
76
+ if (props.excludeOptions && props.excludeOptions.length) {
77
+ list = list?.filter?.(item => !(props.excludeOptions?.some(subValue => subValue == item.columnValue)))
78
+ }
79
+ return list
80
+ })
81
+
82
+ const value = computed({
83
+ get() {
84
+ if (isMutiple.value) {
85
+ const val = modelValue.value || ''
86
+ return val ?
87
+ (
88
+ isStrVal.value ?
89
+ val.split(separator.value) :
90
+ (
91
+ isObject.value ?
92
+ Object.values(val || {}) :
93
+ val
94
+ )
95
+ ) :
96
+ []
97
+ } else {
98
+ if (modelValue.value !== null && modelValue.value !== undefined) {
99
+ if (options.value?.some(item => item.columnValue == modelValue.value)) {
100
+ props.config.isMatch = true
101
+ return `${modelValue.value}`
102
+ } else {
103
+ props.config.isMatch = false
104
+ return ''
105
+ }
106
+ } else {
107
+ return ''
108
+ }
109
+ }
110
+ },
111
+ set(val) {
112
+ if (isMutiple.value) {
113
+ modelValue.value = isStrVal.value ?
114
+ val.join(separator.value) :
115
+ (
116
+ isObject.value ?
117
+ val?.reduce((ret, item, idx) => {ret[idx] = item; return ret;}, {}) :
118
+ val
119
+ )
120
+ } else {
121
+ modelValue.value = val
122
+ }
123
+ }
124
+ })
125
+
126
+ const selectProps = computed(() => {
127
+ const attrs = Object.keys(ElSelect.props).reduce((ret, key) => {
128
+ ret[key] = props[key]
129
+ return ret
130
+ }, {})
131
+ if (attrs.placeholder === null || attrs.placeholder === undefined) {
132
+ attrs.placeholder = ''
133
+ }
134
+ if (typeof attrs.filterable === 'string') {
135
+ attrs.filterable = attrs.filterable == '1'
136
+ }
137
+ if (typeof attrs.multiple === 'string') {
138
+ attrs.multiple = attrs.multiple == '1'
139
+ }
140
+ if (!attrs['suffix-icon'] && !attrs.suffixIcon) {
141
+ delete attrs.suffixIcon
142
+ delete attrs['suffix-icon']
143
+ }
144
+ attrs.multipleLimit = Number(parseInt(attrs.multipleLimit || 0))
145
+ return attrs
146
+ })
147
+ const lang = inject('lang')
148
+ const clear = () => {
149
+ modelValue.value = ''
150
+ }
151
+ </script>
152
+ <style lang="scss">
153
+ .custom-self-select {
154
+ }
155
+ </style>