ci-plus 1.3.7 → 1.3.8

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.
@@ -0,0 +1,177 @@
1
+ <template>
2
+ <component
3
+ :is="!useVirtual ? 'el-select' : 'el-select-v2'"
4
+ popper-class="t_select"
5
+ v-model="childSelectedValue"
6
+ :options="!useVirtual ? null : optionSource"
7
+ :style="{ width: width || '100%' }"
8
+ @change="handlesChange"
9
+ v-bind="{
10
+ clearable: true,
11
+ filterable: true,
12
+ multiple: multiple,
13
+ ...$attrs
14
+ }"
15
+ >
16
+ <template v-for="(index, name) in slots" v-slot:[name]="data">
17
+ <slot :name="name" v-bind="data" />
18
+ </template>
19
+ <template v-if="!useVirtual">
20
+ <el-checkbox
21
+ v-if="multiple && !isShowPagination"
22
+ v-model="selectChecked"
23
+ @change="selectAll"
24
+ class="all_checkbox"
25
+ >全选</el-checkbox
26
+ >
27
+ <el-option
28
+ v-for="(item, index) in optionSource"
29
+ :key="index + 'i'"
30
+ :label="customLabel ? customLabelHandler(item) : item[labelCustom]"
31
+ :value="item[valueCustom]"
32
+ :disabled="item.disabled"
33
+ >
34
+ <template v-for="(index, name) in slots" v-slot:[name]="data">
35
+ <slot :name="name" v-bind="data" />
36
+ </template>
37
+ </el-option>
38
+ <div class="t_select__pagination" v-if="isShowPagination">
39
+ <el-pagination
40
+ v-model:current-page="paginationOption.currentPage"
41
+ v-model:page-size="paginationOption.pageSize"
42
+ :layout="paginationOption.layout || 'total, prev, pager, next, jumper'"
43
+ :pager-count="paginationOption.pagerCount"
44
+ :total="paginationOption.total"
45
+ v-bind="{
46
+ small: true,
47
+ background: true,
48
+ ...$attrs,
49
+ ...paginationOption.bind
50
+ }"
51
+ />
52
+ </div>
53
+ </template>
54
+ </component>
55
+ </template>
56
+
57
+ <script setup lang="ts" name="CiSelect">
58
+ import { computed, useSlots } from 'vue'
59
+ const props: any = defineProps({
60
+ modelValue: {
61
+ type: [String, Number, Array]
62
+ },
63
+ // 是否多选
64
+ multiple: {
65
+ type: Boolean,
66
+ default: false
67
+ },
68
+ // 选择框宽度
69
+ width: {
70
+ type: String
71
+ },
72
+ // 传入的option数组中,要作为最终选择项的键值key
73
+ valueCustom: {
74
+ type: String,
75
+ default: 'key'
76
+ },
77
+ // 传入的option数组中,要作为显示项的键值名称
78
+ labelCustom: {
79
+ type: String,
80
+ default: 'label'
81
+ },
82
+ // 是否自定义设置下拉label
83
+ customLabel: {
84
+ type: String
85
+ },
86
+ // 下拉框组件数据源
87
+ optionSource: {
88
+ type: Array as unknown as any[],
89
+ default: () => []
90
+ },
91
+ // 是否显示分页
92
+ isShowPagination: {
93
+ type: Boolean,
94
+ default: false
95
+ },
96
+ // 分页配置
97
+ paginationOption: {
98
+ type: Object,
99
+ default: () => {
100
+ return {
101
+ pageSize: 6, // 每页显示条数
102
+ currentPage: 1, // 当前页
103
+ pagerCount: 5, // 按钮数,超过时会折叠
104
+ total: 0 // 总条数
105
+ }
106
+ }
107
+ },
108
+ // 是否开启虚拟列表
109
+ useVirtual: {
110
+ type: Boolean,
111
+ default: false
112
+ }
113
+ })
114
+ const slots = useSlots()
115
+ // 抛出事件
116
+ const emits = defineEmits(['update:modelValue', 'change'])
117
+ // vue3 v-model简写
118
+ let childSelectedValue: any = computed({
119
+ get() {
120
+ return props.modelValue
121
+ },
122
+ set(val) {
123
+ // console.log(777, val)
124
+ emits('update:modelValue', val)
125
+ }
126
+ })
127
+ const handlesChange = (val: any) => {
128
+ // console.log(val)
129
+ emits('change', val)
130
+ }
131
+ // 设置全选
132
+ const selectChecked = computed({
133
+ get() {
134
+ const _deval: any = props.modelValue
135
+ const list = props.optionSource.filter((item) => {
136
+ return !item.disabled
137
+ })
138
+ return _deval?.length === list.length
139
+ },
140
+ set(val: any) {
141
+ const list = props.optionSource.filter((item) => {
142
+ return !item.disabled
143
+ })
144
+ return val?.length === list.length
145
+ }
146
+ })
147
+ // 点击全选
148
+ const selectAll = (val: any) => {
149
+ let options = JSON.parse(JSON.stringify(props.optionSource))
150
+ // 数据源过滤禁用选项
151
+ options = options.filter((item) => {
152
+ return !item.disabled
153
+ })
154
+ if (val) {
155
+ const selectedAllValue = options.map((item) => {
156
+ return item[props.valueCustom]
157
+ })
158
+ emits('update:modelValue', selectedAllValue)
159
+ } else {
160
+ emits('update:modelValue', null)
161
+ }
162
+ }
163
+ // 自定义label显示
164
+ const customLabelHandler = (item) => {
165
+ // console.log('customLabelHandler', item)
166
+ return eval(props.customLabel)
167
+ }
168
+ </script>
169
+ <style lang="scss" scoped>
170
+ .t_select {
171
+ .el-select-dropdown {
172
+ .all_checkbox {
173
+ margin-left: 20px;
174
+ }
175
+ }
176
+ }
177
+ </style>
@@ -0,0 +1,4 @@
1
+ import _SelectTable from './src/index.vue'
2
+ import { withInstall } from '../utils/index';
3
+ export const CiSelectTable = withInstall(_SelectTable)
4
+ export default CiSelectTable