ci-plus 1.3.6 → 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,818 @@
1
+ <template>
2
+ <el-input
3
+ v-if="isShowInput"
4
+ v-model="selectInputVal"
5
+ v-bind="{ clearable: true, ...inputAttr }"
6
+ @focus="() => emits('input-focus')"
7
+ @blur="() => emits('input-blur')"
8
+ @click="() => emits('input-click')"
9
+ @clear="() => emits('input-clear')"
10
+ :style="{ width: inputWidth ? `${inputWidth}px` : '100%' }"
11
+ >
12
+ <template v-for="(index, name) in slots" v-slot:[name]="data">
13
+ <slot :name="name" v-bind="data" />
14
+ </template>
15
+ </el-input>
16
+ <el-select
17
+ v-else
18
+ ref="selectRef"
19
+ :model-value="multiple ? state.defaultValue : selectDefaultLabel"
20
+ popper-class="t-select-table"
21
+ :style="{ width: selectWidth ? `${selectWidth}px` : '100%' }"
22
+ :multiple="multiple"
23
+ v-bind="selectAttr"
24
+ :value-key="keywords.value"
25
+ :filterable="filterable"
26
+ :filter-method="filterMethod || filterMethodHandle"
27
+ v-click-outside="closeBox"
28
+ @visible-change="visibleChange"
29
+ @remove-tag="removeTag"
30
+ @clear="clear"
31
+ @keyup="selectKeyup"
32
+ >
33
+ <template #empty>
34
+ <div
35
+ class="t-table-select__table"
36
+ :style="{ width: tableWidth ? `${tableWidth}px` : '100%' }"
37
+ >
38
+ <div class="table_query_condition" v-if="isShowQuery">
39
+ <t-query-condition
40
+ ref="tQueryConditionRef"
41
+ :boolEnter="false"
42
+ @handleEvent="handleEvent"
43
+ v-bind="$attrs"
44
+ >
45
+ <template v-for="(index, name) in slots" v-slot:[name]="data">
46
+ <slot :name="name" v-bind="data"></slot>
47
+ </template>
48
+ <template #querybar v-if="isShowBlurBtn">
49
+ <el-button v-bind="{ type: 'danger', ...btnBind }" @click="blur">{{
50
+ btnBind.btnTxt || '关闭下拉框'
51
+ }}</el-button>
52
+ <slot name="querybar"></slot>
53
+ </template>
54
+ </t-query-condition>
55
+ </div>
56
+ <slot name="toolbar"></slot>
57
+ <el-table
58
+ ref="selectTable"
59
+ :data="state.tableData"
60
+ :class="{
61
+ radioStyle: !multiple,
62
+ highlightCurrentRow: isRadio,
63
+ keyUpStyle: isKeyup
64
+ }"
65
+ highlight-current-row
66
+ border
67
+ :row-key="getRowKey"
68
+ @row-click="rowClick"
69
+ @cell-dblclick="cellDblclick"
70
+ @selection-change="handlesSelectionChange"
71
+ v-bind="$attrs"
72
+ >
73
+ <el-table-column
74
+ v-if="multiple"
75
+ type="selection"
76
+ width="55"
77
+ align="center"
78
+ :reserve-selection="reserveSelection"
79
+ fixed
80
+ ></el-table-column>
81
+ <el-table-column
82
+ type="radio"
83
+ width="55"
84
+ :label="radioTxt"
85
+ fixed
86
+ align="center"
87
+ v-if="!multiple && isShowFirstColumn"
88
+ >
89
+ <template #default="scope">
90
+ <el-radio
91
+ v-model="radioVal"
92
+ :label="scope.$index + 1"
93
+ @click.stop="radioChangeHandle($event, scope.row, scope.$index + 1)"
94
+ ></el-radio>
95
+ </template>
96
+ </el-table-column>
97
+ <el-table-column
98
+ v-for="(item, index) in columns"
99
+ :key="index + 'i'"
100
+ :type="item.type"
101
+ :label="item.label"
102
+ :prop="item.prop"
103
+ :min-width="item['min-width'] || item.minWidth"
104
+ :width="item.width"
105
+ :align="item.align || 'center'"
106
+ :fixed="item.fixed"
107
+ :show-overflow-tooltip="item.noShowTip"
108
+ v-bind="{ ...item.bind, ...$attrs }"
109
+ >
110
+ <template #default="scope">
111
+ <!-- render方式 -->
112
+ <template v-if="item.render">
113
+ <render-col
114
+ :column="item"
115
+ :row="scope.row"
116
+ :render="item.render"
117
+ :index="scope.$index"
118
+ />
119
+ </template>
120
+ <!-- 作用域插槽 -->
121
+ <template v-if="item.slotName">
122
+ <slot :name="item.slotName" :scope="scope"></slot>
123
+ </template>
124
+ <div v-if="!item.render && !item.slotName">
125
+ <span>{{ scope.row[item.prop] }}</span>
126
+ </div>
127
+ </template>
128
+ </el-table-column>
129
+ <slot></slot>
130
+ </el-table>
131
+ <slot name="footer"></slot>
132
+ <div class="t-table-select__page" v-if="isShowPagination">
133
+ <el-pagination
134
+ v-model:current-page="table.currentPage"
135
+ v-model:page-size="table.pageSize"
136
+ small
137
+ background
138
+ @current-change="handlesCurrentChange"
139
+ layout="total, prev, pager, next, jumper"
140
+ :pager-count="5"
141
+ :total="table.total"
142
+ v-bind="$attrs"
143
+ />
144
+ </div>
145
+ </div>
146
+ </template>
147
+ </el-select>
148
+ </template>
149
+
150
+ <script setup lang="ts" name="CiSelectTable">
151
+ import TQueryCondition from '../../queryCondition/src/index.vue'
152
+ import RenderCol from './renderCol.vue'
153
+ import { computed, useAttrs, useSlots, ref, watch, nextTick, reactive, onMounted } from 'vue'
154
+ import { ElMessage } from 'element-plus'
155
+ import ClickOutside from '../../utils/directives/click-outside/index'
156
+ const props = defineProps({
157
+ // input输入框的值(modelValue)
158
+ inputValue: {
159
+ type: [Array, String, Number, Boolean, Object],
160
+ default: undefined
161
+ },
162
+ modelValue: {
163
+ type: [Array, String, Number, Boolean, Object],
164
+ default: undefined
165
+ },
166
+ // 是否显示input框回显
167
+ isShowInput: {
168
+ type: Boolean,
169
+ default: false
170
+ },
171
+ // input框的宽度
172
+ inputWidth: {
173
+ type: [String, Number],
174
+ default: 550
175
+ },
176
+ // input属性
177
+ inputAttr: {
178
+ type: Object,
179
+ default: () => {
180
+ return {}
181
+ }
182
+ },
183
+ // 选择值
184
+ value: {
185
+ type: [String, Number, Array]
186
+ },
187
+ // table所需数据
188
+ table: {
189
+ type: Object,
190
+ default: () => {
191
+ return {}
192
+ }
193
+ },
194
+ // 表头数据
195
+ columns: {
196
+ type: Array as unknown as any[],
197
+ default: () => []
198
+ },
199
+ // 单选文案
200
+ radioTxt: {
201
+ type: String,
202
+ default: '单选'
203
+ },
204
+ // 是否显示搜索条件
205
+ isShowQuery: {
206
+ type: Boolean,
207
+ default: false
208
+ },
209
+ // 是否清空搜索条件
210
+ isClearQuery: {
211
+ type: Boolean,
212
+ default: false
213
+ },
214
+ // 是否显示隐藏下拉框按钮
215
+ isShowBlurBtn: {
216
+ type: Boolean,
217
+ default: false
218
+ },
219
+ // 显示隐藏下拉框按钮属性
220
+ btnBind: {
221
+ type: Object,
222
+ default: () => {
223
+ return {
224
+ btnTxt: '关闭下拉框'
225
+ }
226
+ }
227
+ },
228
+ // 单选框--是否开启点击整行选中
229
+ rowClickRadio: {
230
+ type: Boolean,
231
+ default: true
232
+ },
233
+ // 是否显示首列
234
+ isShowFirstColumn: {
235
+ type: Boolean,
236
+ default: true
237
+ },
238
+ // 是否过滤
239
+ filterable: {
240
+ type: Boolean,
241
+ default: true
242
+ },
243
+ // 是否支持翻页选中
244
+ reserveSelection: {
245
+ type: Boolean,
246
+ default: true
247
+ },
248
+ // 是否显示分页
249
+ isShowPagination: {
250
+ type: Boolean,
251
+ default: false
252
+ },
253
+ // 是否自定义过滤
254
+ filterMethod: {
255
+ type: Function
256
+ },
257
+ // 下拉数据指向的label/value
258
+ keywords: {
259
+ type: Object,
260
+ default: () => {
261
+ return {
262
+ label: 'label',
263
+ value: 'value'
264
+ }
265
+ }
266
+ },
267
+ // 单选是否开启键盘事件
268
+ isKeyup: {
269
+ type: Boolean,
270
+ default: false
271
+ },
272
+ // 多选
273
+ multiple: {
274
+ type: Boolean,
275
+ default: false
276
+ },
277
+ // select 宽度
278
+ selectWidth: {
279
+ type: [String, Number],
280
+ default: 550
281
+ },
282
+ // table宽度
283
+ tableWidth: {
284
+ type: [String, Number],
285
+ default: 550
286
+ },
287
+ // 是否始终显示下拉框
288
+ selfExpanded: {
289
+ type: Boolean,
290
+ default: false
291
+ },
292
+ // 显示下拉框
293
+ isExpanded: {
294
+ type: Boolean,
295
+ default: false
296
+ },
297
+ // 设置默认选中项--keywords.value值
298
+ defaultSelectVal: {
299
+ type: Array,
300
+ default: () => []
301
+ }
302
+ })
303
+ const selectAttr = computed(() => {
304
+ return {
305
+ clearable: true,
306
+ ...useAttrs()
307
+ }
308
+ })
309
+ // 自定义指令
310
+ const vClickOutside = ClickOutside
311
+ // 抛出事件
312
+ const emits = defineEmits([
313
+ 'page-change',
314
+ 'selectionChange',
315
+ 'radioChange',
316
+ 'update:inputValue',
317
+ 'input-focus',
318
+ 'input-blur',
319
+ 'input-clear',
320
+ 'input-click'
321
+ ])
322
+ const slots = useSlots()
323
+ const isDefaultSelectVal = ref(true) // 是否已经重新选择了
324
+ const forbidden = ref(true) // 判断单选选中及取消选中
325
+ const isRadio = ref(false)
326
+ const isQueryVisible = ref(false) // 查询条件是否显示隐藏下拉框
327
+ const isVisible = ref(false) // 是否显示隐藏下拉框
328
+ const radioVal = ref('')
329
+ const selectDefaultLabel: any = ref(props.modelValue) // 单选赋值
330
+ // input回显值
331
+ let selectInputVal: any = computed({
332
+ get() {
333
+ return props.inputValue
334
+ },
335
+ set(val) {
336
+ // console.log(777, val)
337
+ emits('update:inputValue', val)
338
+ }
339
+ })
340
+ const state: any = reactive({
341
+ defaultSelectValue: props.defaultSelectVal, // 默认选中
342
+ tableData: props.table.data, // table数据
343
+ defaultValue: props.value,
344
+ ids: [], // 多选id集合
345
+ tabularMap: {} // 存储下拉tale的所有name
346
+ })
347
+ // 获取ref
348
+ const selectRef: any = ref<HTMLElement | null>(null)
349
+ const selectTable: any = ref<HTMLElement | null>(null)
350
+ const tQueryConditionRef: any = ref<HTMLElement | null>(null)
351
+ const nowIndex = ref(-1)
352
+ watch(
353
+ () => props.table.data,
354
+ (val) => {
355
+ state.tableData = val
356
+ nextTick(() => {
357
+ state.tableData &&
358
+ state.tableData.length > 0 &&
359
+ state.tableData.forEach((item) => {
360
+ state.tabularMap[item[props.keywords.value]] = item[props.keywords.label]
361
+ })
362
+ })
363
+ },
364
+ { deep: true }
365
+ )
366
+ watch(
367
+ () => props.defaultSelectVal,
368
+ (val) => {
369
+ console.log('props.defaultSelectVal---watch', val, isDefaultSelectVal.value)
370
+ state.defaultSelectValue = val
371
+ if (val.length > 0 && isDefaultSelectVal.value) {
372
+ defaultSelect(val)
373
+ }
374
+ },
375
+ { deep: true }
376
+ )
377
+ onMounted(() => {
378
+ // 设置默认选中项(单选)
379
+ if (state.defaultSelectValue && state.defaultSelectValue.length > 0 && isDefaultSelectVal.value) {
380
+ defaultSelect(state.defaultSelectValue)
381
+ }
382
+ if (props.selfExpanded) {
383
+ selectRef.value.expanded = true
384
+ }
385
+ })
386
+ // 表格显示隐藏回调
387
+ const visibleChange = (visible) => {
388
+ // console.log('表格显示隐藏回调', visible)
389
+ isVisible.value = visible
390
+ if (isQueryVisible.value) {
391
+ selectRef.value.expanded = true
392
+ }
393
+ // console.log('表格显示隐藏回调--222', visible)
394
+ if (visible) {
395
+ if (
396
+ state.defaultSelectValue &&
397
+ state.defaultSelectValue.length > 0 &&
398
+ isDefaultSelectVal.value
399
+ ) {
400
+ defaultSelect(state.defaultSelectValue)
401
+ }
402
+ initTableData()
403
+ } else {
404
+ if (
405
+ tQueryConditionRef.value &&
406
+ props.isShowQuery &&
407
+ props.isClearQuery &&
408
+ !selectRef.value.expanded &&
409
+ !props.selfExpanded
410
+ ) {
411
+ tQueryConditionRef.value?.resetData()
412
+ }
413
+ findLabel()
414
+ filterMethodHandle('')
415
+ }
416
+ if (props.selfExpanded) {
417
+ selectRef.value.expanded = true
418
+ }
419
+ }
420
+ // 查询条件change事件触发
421
+ const handleEvent = () => {
422
+ // console.log('查询条件change事件触发')
423
+ selectRef.value.expanded = true
424
+ }
425
+ // 条件查询组件的visible-change事件
426
+ const queryVisibleChange = (val) => {
427
+ isQueryVisible.value = val
428
+ }
429
+ // el-select点击了空白区域
430
+ const closeBox = () => {
431
+ // console.log('select点击了空白区域', tQueryConditionRef.value)
432
+ // if(props.selfExpanded){
433
+ // selectRef.value.expanded = true
434
+ // }
435
+ // 获取查询条件组件的项
436
+ if (tQueryConditionRef.value && props.isShowQuery) {
437
+ selectRef.value.expanded = true
438
+ Object.values(tQueryConditionRef.value?.props?.opts).map((val: any) => {
439
+ if (val.comp.includes('select') || val.comp.includes('picker') || val.comp.includes('date')) {
440
+ val.eventHandle = {
441
+ 'visible-change': ($event) => queryVisibleChange($event)
442
+ }
443
+ // queryVisibleChange(true)
444
+ // isQueryVisible.value = true
445
+ selectRef.value.expanded = true
446
+ }
447
+ })
448
+ if (isVisible.value && props.isShowQuery) {
449
+ selectRef.value.expanded = true
450
+ } else {
451
+ selectRef.value.expanded = false
452
+ }
453
+ }
454
+ }
455
+ // 单选键盘事件
456
+ const selectKeyup = (e) => {
457
+ if (!props.multiple) {
458
+ if (!props.isKeyup) return
459
+ if (state.tableData.length === 0) return
460
+ switch (e.keyCode) {
461
+ case 40: // 下键
462
+ if (state.tableData[nowIndex.value * 1 + 1] !== undefined) {
463
+ selectTable.value.setCurrentRow(state.tableData[nowIndex.value * 1 + 1])
464
+ nowIndex.value = nowIndex.value * 1 + 1
465
+ } else {
466
+ nowIndex.value = 0
467
+ selectTable.value.setCurrentRow(state.tableData[0])
468
+ }
469
+ break
470
+ case 38: // 上键
471
+ if (state.tableData[nowIndex.value * 1 - 1] !== undefined && nowIndex.value > 0) {
472
+ selectTable.value.setCurrentRow(state.tableData[nowIndex.value * 1 - 1])
473
+ nowIndex.value = nowIndex.value * 1 - 1
474
+ } else {
475
+ nowIndex.value = 0
476
+ selectTable.value.setCurrentRow(state.tableData[0])
477
+ }
478
+ break
479
+ case 13: // 回车
480
+ rowClick(state.tableData[nowIndex.value])
481
+ break
482
+ }
483
+ }
484
+ }
485
+ // 赋值
486
+ const findLabel = () => {
487
+ nextTick(() => {
488
+ if (props.multiple) {
489
+ selectRef.value.selected?.forEach((item) => {
490
+ item.currentLabel = item.value
491
+ })
492
+ } else {
493
+ selectDefaultLabel.value =
494
+ (state.defaultValue && state.defaultValue[props.keywords.label]) || ''
495
+ }
496
+ })
497
+ }
498
+
499
+ // 当前页码
500
+ const handlesCurrentChange = (val) => {
501
+ if (props.multiple) {
502
+ if (!props.reserveSelection) {
503
+ clear()
504
+ }
505
+ } else {
506
+ clear()
507
+ }
508
+ emits('page-change', val)
509
+ }
510
+ // 默认选中(且只能默认选中第一页的数据)
511
+ const defaultSelect = (defaultSelectVal) => {
512
+ if (props.multiple) {
513
+ let multipleList: any = []
514
+ defaultSelectVal.map((val) => {
515
+ state.tableData.forEach((row: any) => {
516
+ if (val === row[props.keywords.value]) {
517
+ multipleList.push(row)
518
+ }
519
+ })
520
+ })
521
+ setTimeout(() => {
522
+ state.defaultValue = multipleList.map((item) => item[props.keywords.label])
523
+ multipleList.forEach((row) => {
524
+ const arr = state.tableData.filter(
525
+ (item) => item[props.keywords.value] === row[props.keywords.value]
526
+ )
527
+ if (arr.length > 0) {
528
+ selectTable.value.toggleRowSelection(arr[0], true)
529
+ }
530
+ })
531
+ selectRef.value?.selected?.forEach((item) => {
532
+ item.currentLabel = item.value
533
+ })
534
+ }, 0)
535
+ } else {
536
+ let row, index
537
+ state.tableData.map((val, i) => {
538
+ if (val[props.keywords.value] === defaultSelectVal[0]) {
539
+ row = val
540
+ index = i
541
+ }
542
+ })
543
+ radioVal.value = index + 1
544
+ state.defaultValue = row
545
+ setTimeout(() => {
546
+ selectDefaultLabel.value = row && row[props.keywords.label]
547
+ }, 0)
548
+ emits('radioChange', row, row && row[props.keywords.value])
549
+ }
550
+ }
551
+ // 复选框(多选)
552
+ const handlesSelectionChange = (val) => {
553
+ // console.log('复选框', val)
554
+ isDefaultSelectVal.value = false
555
+ state.defaultValue = val.map((item) => item[props.keywords.label])
556
+ state.ids = val.map((item) => item[props.keywords.value])
557
+ if (val.length === 0) {
558
+ isDefaultSelectVal.value = true
559
+ state.defaultSelectValue = []
560
+ }
561
+ emits('selectionChange', val, state.ids)
562
+ }
563
+ // 搜索后表格勾选不取消
564
+ const getRowKey = (row) => {
565
+ return row[props.keywords.value]
566
+ }
567
+ // 搜索过滤
568
+ const filterMethodHandle = (val) => {
569
+ if (!props.filterable) return
570
+ const tableData = JSON.parse(JSON.stringify(props.table?.data))
571
+ if (tableData && tableData.length > 0) {
572
+ if (!props.multiple) {
573
+ if (val) {
574
+ radioVal.value = ''
575
+ } else {
576
+ tableData.map((item, index) => {
577
+ if (
578
+ item[props.keywords.value] === selectDefaultLabel.value &&
579
+ selectDefaultLabel.value[props.keywords.value]
580
+ ) {
581
+ radioVal.value = index + 1
582
+ }
583
+ })
584
+ }
585
+ }
586
+ state.tableData = tableData.filter((item) => {
587
+ if (item[props.keywords.label].includes(val)) {
588
+ return item
589
+ }
590
+ })
591
+ }
592
+ }
593
+
594
+ // 获取表格数据
595
+ const initTableData = () => {
596
+ // 表格默认赋值
597
+ nextTick(() => {
598
+ if (props.multiple) {
599
+ state.defaultValue?.forEach((row) => {
600
+ const arr = state.tableData.filter(
601
+ (item) => item[props.keywords.value] === row[props.keywords.value]
602
+ )
603
+ if (arr.length > 0) {
604
+ selectTable.value.toggleRowSelection(arr[0], true)
605
+ }
606
+ })
607
+ } else {
608
+ const arr = state.tableData.filter(
609
+ (item) =>
610
+ item[props.keywords.value] === selectDefaultLabel.value &&
611
+ selectDefaultLabel.value[props.keywords.value]
612
+ )
613
+ selectTable.value.setCurrentRow(arr[0])
614
+ }
615
+ })
616
+ }
617
+ // 复制内容
618
+ const copyDomText = (val) => {
619
+ // 获取需要复制的元素以及元素内的文本内容
620
+ const text = val
621
+ // 添加一个input元素放置需要的文本内容
622
+ const input = document.createElement('input')
623
+ input.value = text
624
+ document.body.appendChild(input)
625
+ // 选中并复制文本到剪切板
626
+ input.select()
627
+ document.execCommand('copy')
628
+ // 移除input元素
629
+ document.body.removeChild(input)
630
+ }
631
+ // 双击复制单元格内容
632
+ const cellDblclick = (row, column) => {
633
+ try {
634
+ copyDomText(row[column.property])
635
+ ElMessage.success('复制成功')
636
+ } catch (e) {
637
+ ElMessage.error('复制失败')
638
+ }
639
+ }
640
+ // 点击单选框单元格触发事件
641
+ const radioChangeHandle = (event, row, index) => {
642
+ event.preventDefault()
643
+ isDefaultSelectVal.value = false
644
+ radioClick(row, index)
645
+ }
646
+ // forbidden取值
647
+ const isForbidden = () => {
648
+ forbidden.value = false
649
+ setTimeout(() => {
650
+ forbidden.value = true
651
+ }, 0)
652
+ }
653
+ // 单选抛出事件radioChange
654
+ const radioClick = (row, index) => {
655
+ forbidden.value = !!forbidden.value
656
+ if (radioVal.value) {
657
+ if (radioVal.value === index) {
658
+ radioVal.value = ''
659
+ isForbidden()
660
+ state.defaultValue = {}
661
+ state.defaultSelectValue = []
662
+ isDefaultSelectVal.value = true
663
+ emits('radioChange', {}, null) // 取消勾选就把回传数据清除
664
+ // blur()
665
+ } else {
666
+ isForbidden()
667
+ radioVal.value = index
668
+ state.defaultValue = row
669
+ emits('radioChange', row, row[props.keywords.value])
670
+ // blur()
671
+ }
672
+ } else {
673
+ isForbidden()
674
+ radioVal.value = index
675
+ state.defaultValue = row
676
+ emits('radioChange', row, row[props.keywords.value])
677
+ }
678
+ // 是否显示下拉框
679
+ if (props.isExpanded) {
680
+ selectDefaultLabel.value =
681
+ (state.defaultValue && state.defaultValue[props.keywords.label]) || ''
682
+ selectRef.value.expanded = true
683
+ } else {
684
+ blur()
685
+ }
686
+ }
687
+ // 单击行
688
+ const rowClick = async (row) => {
689
+ if (!props.rowClickRadio) return
690
+ if (!props.multiple) {
691
+ let rowIndex
692
+ // eslint-disable-next-line no-unused-expressions
693
+ props.table?.data.forEach((item, index) => {
694
+ if (item[props.keywords.value] === row[props.keywords.value]) {
695
+ // console.log('index', index)
696
+ rowIndex = index
697
+ }
698
+ })
699
+ // await this.radioClick(row, rowIndex + 1)
700
+ isDefaultSelectVal.value = false
701
+ await radioClick(row, rowIndex + 1)
702
+ if (radioVal.value) {
703
+ isRadio.value = true
704
+ } else {
705
+ isRadio.value = false
706
+ }
707
+ }
708
+ }
709
+ // tags删除后回调
710
+ const removeTag = (tag) => {
711
+ const row = state.tableData.find((item) => item[props.keywords.label] === tag)
712
+ console.log('tags删除后回调', row)
713
+ selectTable.value.toggleRowSelection(row, false)
714
+ isDefaultSelectVal.value = true
715
+ }
716
+ // 清空后的回调
717
+ const clear = () => {
718
+ if (props.multiple) {
719
+ selectTable.value.clearSelection()
720
+ isDefaultSelectVal.value = true
721
+ state.defaultSelectValue = []
722
+ state.defaultValue = []
723
+ } else {
724
+ // 取消高亮
725
+ selectTable.value.setCurrentRow(-1)
726
+ nowIndex.value = -1
727
+ radioVal.value = ''
728
+ isDefaultSelectVal.value = true
729
+ state.defaultSelectValue = []
730
+ forbidden.value = false
731
+ selectDefaultLabel.value = null
732
+ state.defaultValue = null
733
+ emits('radioChange', {}, null)
734
+ }
735
+ }
736
+ // 触发select隐藏
737
+ const blur = () => {
738
+ selectRef.value.blur()
739
+ }
740
+ // 触发select显示
741
+ const focus = () => {
742
+ selectRef.value.focus()
743
+ }
744
+ // 暴露方法出去
745
+ defineExpose({
746
+ focus,
747
+ blur,
748
+ clear,
749
+ props,
750
+ tQueryConditionRef,
751
+ selectRef,
752
+ selectTable
753
+ })
754
+ </script>
755
+
756
+ <style lang="scss">
757
+ .t-select-table {
758
+ // 单选样式
759
+ .radioStyle {
760
+ .el-radio {
761
+ .el-radio__label {
762
+ display: none;
763
+ }
764
+ &:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
765
+ box-shadow: none;
766
+ }
767
+ }
768
+ .el-table__row {
769
+ cursor: pointer;
770
+ }
771
+ }
772
+ // 键盘事件开启选择高亮
773
+ .keyUpStyle {
774
+ .el-table__body {
775
+ tbody {
776
+ .current-row {
777
+ color: var(--el-color-primary) !important;
778
+ cursor: pointer;
779
+ }
780
+ }
781
+ }
782
+ }
783
+ // 选中行样式
784
+ .highlightCurrentRow {
785
+ :deep(.current-row) {
786
+ color: var(--el-color-primary);
787
+ cursor: pointer;
788
+ }
789
+ }
790
+ .t-table-select__table {
791
+ padding: 10px;
792
+
793
+ .el-table__body,
794
+ .el-table__header {
795
+ margin: 0;
796
+ }
797
+ // 条件查询组件样式
798
+ .table_query_condition {
799
+ width: 100%;
800
+ overflow-x: auto;
801
+ overflow-y: hidden;
802
+ padding: 10px;
803
+ }
804
+ }
805
+
806
+ .t-table-select__page {
807
+ padding-top: 5px;
808
+ padding-right: 10px;
809
+ .el-pagination {
810
+ display: flex;
811
+ justify-content: flex-end;
812
+ align-items: center;
813
+ margin-right: calc(2% - 20px);
814
+ background-color: var(--el-table-tr-bg-color);
815
+ }
816
+ }
817
+ }
818
+ </style>