br-dionysus 1.16.8 → 1.17.0

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.
Files changed (35) hide show
  1. package/README.md +50 -10
  2. package/attributes.json +1 -1
  3. package/build/doc.config.ts +1 -1
  4. package/build/lib.config.ts +1 -1
  5. package/dist/br-dionysus.es.js +8805 -8682
  6. package/dist/br-dionysus.umd.js +6 -30
  7. package/dist/index.css +1 -1
  8. package/dist/packages/MSelect/src/MSelect.vue.d.ts +3 -3
  9. package/dist/packages/MSelect/src/token.d.ts +1 -1
  10. package/dist/packages/MSelectTable/src/MSelectTable.vue.d.ts +25 -15
  11. package/dist/packages/MSelectTableV1/src/MSelectTableV1.vue.d.ts +1 -1
  12. package/dist/packages/MSelectV2/src/MSelectV2.vue.d.ts +3 -3
  13. package/dist/packages/MTable/src/MTable.vue.d.ts +1 -1
  14. package/dist/packages/MTableV2/src/MTableV2.vue.d.ts +1 -1
  15. package/dist/packages/Tool/uniqueByKey/uniqueByKey.d.ts +8 -0
  16. package/package.json +43 -43
  17. package/packages/MSelect/docs/demo.vue +2 -0
  18. package/packages/MSelect/src/MSelect.vue +12 -11
  19. package/packages/MSelect/src/token.ts +1 -1
  20. package/packages/MSelectTable/docs/DemoTest2.vue +1 -1
  21. package/packages/MSelectTable/docs/DemoTest3.vue +0 -2
  22. package/packages/MSelectTable/docs/DemoTest4.vue +0 -11
  23. package/packages/MSelectTable/docs/DemoTest5.vue +113 -0
  24. package/packages/MSelectTable/docs/DemoTest6.vue +102 -0
  25. package/packages/MSelectTable/docs/README.md +5 -5
  26. package/packages/MSelectTable/docs/demo.vue +6 -0
  27. package/packages/MSelectTable/src/MSelectTable.vue +262 -192
  28. package/packages/MSelectTableV1/src/MSelectTableV1.vue +2 -2
  29. package/packages/MSelectV2/src/MSelectV2.vue +1 -1
  30. package/packages/Tool/uniqueByKey/README.md +16 -0
  31. package/packages/Tool/uniqueByKey/uniqueByKey.ts +12 -0
  32. package/packages/typings/global.d.ts +17 -10
  33. package/tags.json +1 -1
  34. package/vite.config.ts +3 -1
  35. package/web-types.json +1 -1
@@ -1,137 +1,133 @@
1
1
  <template>
2
2
  <div class="g-box g-select-table-box">
3
- <ElSelect
4
- ref="selectRef"
5
- popperClass="m-select-table"
6
- :multiple="isElSelectMultiple"
3
+ <!--单选-->
4
+ <ElInput
5
+ v-if="!props.multiple"
6
+ v-model="selectModelValue"
7
+ v-bind="selectAttr"
8
+ :class="inputClass"
7
9
  :disabled="props.disabled"
8
10
  :placeholder="props.placeholder"
9
11
  :size="props.size"
10
12
  :valueKey="props.keywords.value"
11
- :remoteMethod="remoteMethodHandle"
12
13
  :filterMethod="props.remote ? null : filterMethodHandle"
13
14
  :filterable="props.filterable"
14
15
  :remote="props.remote"
15
16
  :remoteShowSuffix="props.remote"
16
- v-bind="selectAttr"
17
- v-model="selectModelValue"
18
- @visibleChange="visibleChange"
19
17
  @removeTag="removeTag"
20
18
  @clear="clear"
19
+ @blur="changeBlur"
21
20
  @focus="focus"
21
+ @input="remoteMethodHandle"
22
+ ></ElInput>
23
+ <!--多选-->
24
+ <ElInputTag
25
+ v-if="props.multiple"
26
+ v-model="selectModelValue"
27
+ v-bind="selectAttr"
28
+ :class="inputClass"
29
+ :disabled="props.disabled"
30
+ :placeholder="props.placeholder"
31
+ :size="props.size"
32
+ :valueKey="props.keywords.value"
33
+ :filterMethod="props.remote ? null : filterMethodHandle"
34
+ :filterable="props.filterable"
35
+ :remote="props.remote"
36
+ :remoteShowSuffix="props.remote"
37
+ :saveOnBlur="false"
38
+ @removeTag="removeTag"
39
+ @clear="clear"
22
40
  @blur="changeBlur"
23
- @change="change"
24
- >
25
- <template #empty>
26
- <div
27
- class="m-table-select"
28
- :style="`width: ${typeof props.popupWidth === 'number' ? props.popupWidth + 'px' : props.popupWidth}`"
29
- >
30
- <div class="head-box">
31
- <slot name="auxiliary"></slot>
32
- <div
33
- class="btn-box"
34
- v-if="props.multiple && isAffirmBtn"
41
+ @focus="focus"
42
+ @input="remoteMethodHandle"
43
+ @addTag="addTag"
44
+ ></ElInputTag>
45
+
46
+ <Teleport to="body">
47
+ <div
48
+ class="br-m-table-box"
49
+ v-show="isVisible"
50
+ :style="{ ...mTableBoxStyle, ...boxStyle }"
51
+ >
52
+ <div class="head-box">
53
+ <slot name="auxiliary"></slot>
54
+ <div
55
+ class="btn-box"
56
+ v-if="props.multiple && isAffirmBtn"
57
+ >
58
+ <el-button
59
+ @click="selectMultiple"
60
+ size="small"
35
61
  >
36
- <el-button
37
- @click="selectMultiple"
38
- size="small"
39
- >
40
- 确认
41
- </el-button>
42
- </div>
62
+ 确认
63
+ </el-button>
43
64
  </div>
44
- <ElTable
45
- ref="selectTableRef"
46
- :scrollbarAlwaysOn="props.scrollbarAlwaysOn"
47
- :size="props.size"
48
- :data="tabDataMap"
49
- :rowKey="props.keywords.value"
50
- highlightCurrentRow
51
- @rowClick="rowClick"
52
- @selectionChange="selectionChange"
53
- :height="props.tableHeight"
54
- :border="props.border"
65
+ </div>
66
+ <ElTable
67
+ ref="selectTableRef"
68
+ highlightCurrentRow
69
+ :scrollbarAlwaysOn="props.scrollbarAlwaysOn"
70
+ :size="props.size"
71
+ :data="tabDataMap"
72
+ :rowKey="props.keywords.value"
73
+ :height="props.tableHeight"
74
+ :border="props.border"
75
+ @rowClick="rowClick"
76
+ @selectionChange="selectionChange"
77
+ >
78
+ <el-table-column
79
+ v-if="props.multiple"
80
+ type="selection"
81
+ :reserveSelection="reserveSelection"
82
+ width="55"
83
+ />
84
+ <el-table-column
85
+ showOverflowTooltip
86
+ v-for="item in tableTitle"
87
+ :key="item.prop"
88
+ :prop="item.prop"
89
+ :label="item.label"
90
+ :minWidth="item.minWidth"
91
+ :filters="item.filters"
92
+ :headerAlign="item.headerAlign"
55
93
  >
56
- <el-table-column
57
- v-if="props.multiple"
58
- type="selection"
59
- :reserveSelection="reserveSelection"
60
- width="55"
61
- />
62
- <el-table-column
63
- showOverflowTooltip
64
- v-for="item in tableTitle"
65
- :key="item.prop"
66
- :prop="item.prop"
67
- :label="item.label"
68
- :minWidth="item.minWidth"
69
- :filters="item.filters"
70
- :headerAlign="item.headerAlign"
71
- >
72
- <template #default="scope">
73
- <!-- {{scope}} -->
74
- {{ tabDataMap[scope.$index][item.prop as string] || '-' }}
75
- </template>
76
- </el-table-column>
77
- <template #empty>
78
- <img
79
- class="u-img"
80
- src="@/assets/empty.png"
81
- />
94
+ <template #default="scope">
95
+ {{ tabDataMap[scope.$index][item.prop as string] || '-' }}
82
96
  </template>
83
- </ElTable>
84
- <!--分页-->
85
- <div
86
- class="m-page"
87
- v-if="props.total"
88
- >
89
- <el-pagination
90
- v-model:currentPage="page.currentPage"
91
- v-model:pageSize="page.pageSize"
92
- hideOnSinglePage
93
- :small="props.size === 'small'"
94
- :pageSizes="page.pageSizesOptions"
95
- :pagerCount="5"
96
- layout="total, prev, pager, next, sizes"
97
- :total="page.total"
98
- @currentChange="toPage"
99
- @sizeChange="toPage(page.currentPage, $event)"
97
+ </el-table-column>
98
+ <template #empty>
99
+ <img
100
+ class="u-img"
101
+ src="@/assets/empty.png"
100
102
  />
101
- </div>
103
+ </template>
104
+ </ElTable>
105
+ <!--分页-->
106
+ <div
107
+ class="m-page"
108
+ v-if="props.total"
109
+ >
110
+ <el-pagination
111
+ v-model:currentPage="page.currentPage"
112
+ v-model:pageSize="page.pageSize"
113
+ hideOnSinglePage
114
+ :size="props.size"
115
+ :pageSizes="page.pageSizesOptions"
116
+ :pagerCount="5"
117
+ layout="total, prev, pager, next, sizes"
118
+ :total="page.total"
119
+ @currentChange="toPage"
120
+ @sizeChange="toPage(page.currentPage, $event)"
121
+ />
102
122
  </div>
103
- </template>
104
- </ElSelect>
105
-
106
- <!--<ElInput-->
107
- <!-- class="u-input"-->
108
- <!-- :multiple="isElSelectMultiple"-->
109
- <!-- :disabled="props.disabled"-->
110
- <!-- :placeholder="props.placeholder"-->
111
- <!-- :size="props.size"-->
112
- <!-- :valueKey="props.keywords.value"-->
113
- <!-- :remoteMethod="remoteMethodHandle"-->
114
- <!-- :filterMethod="props.remote ? null : filterMethodHandle"-->
115
- <!-- :filterable="props.filterable"-->
116
- <!-- :remote="props.remote"-->
117
- <!-- :remoteShowSuffix="props.remote"-->
118
- <!-- v-bind="selectAttr"-->
119
- <!-- v-model="selectModelValue"-->
120
- <!-- @visibleChange="visibleChange"-->
121
- <!-- @removeTag="removeTag"-->
122
- <!-- @clear="clear"-->
123
- <!-- @click="focus"-->
124
- <!-- @blur="changeBlur"-->
125
- <!-- @change="change"-->
126
- <!--&gt;</ElInput>-->
127
-
128
- <!--<Teleport to="body">-->
129
- <!-- <div-->
130
- <!-- class="m-table-box"-->
131
- <!-- v-show="showPanel"-->
132
- <!-- :style="{ ...mTableBoxStyle, ...boxStyle }"-->
133
- <!-- ></div>-->
134
- <!--</Teleport>-->
123
+ </div>
124
+ </Teleport>
125
+
126
+ <div
127
+ v-show="isVisible"
128
+ :style="mMarkStyle as any"
129
+ @click="clickOutside"
130
+ />
135
131
  </div>
136
132
  </template>
137
133
 
@@ -145,8 +141,9 @@ import {
145
141
  onMounted,
146
142
  nextTick
147
143
  } from 'vue'
148
- import { ElSelect, ElTable } from 'element-plus'
144
+ import { ElTable, ElInputTag, ElInput } from 'element-plus'
149
145
  import { Page } from './../../typings/class'
146
+ import createHash from './../../Tool/createHash/createHash'
150
147
 
151
148
  const props = withDefaults(defineProps<{
152
149
  modelValue?: string | number | Array<number | string>,
@@ -170,7 +167,7 @@ const props = withDefaults(defineProps<{
170
167
  /** 是否多选 */
171
168
  multiple?: boolean,
172
169
  /** 定义默认的 label 和value */
173
- keywords?: Option,
170
+ keywords?: { label: string, value: string },
174
171
  /** 是否开启翻页多选 */
175
172
  reserveSelection?: boolean,
176
173
  tableHeight?: string | number,
@@ -208,44 +205,78 @@ const props = withDefaults(defineProps<{
208
205
  popupWidth: 500
209
206
  })
210
207
 
211
- const isElSelectMultiple = computed(() => {
212
- if (Array.isArray(props.name)) return true
213
- if (props.name || props.name === 0) return false
214
- return props.multiple
215
- })
216
-
217
208
  const modelValue = ref<string | number | Array<number | string>>(props.modelValue)
218
209
  watch(
219
210
  () => props.modelValue,
220
211
  () => {
221
- // if (props.multiple && !checkType.isArray(props.modelValue)) return console.error('multiple为true时,modelValue必须为数组格式')
222
- // if (!props.multiple && (checkType.isArray(props.modelValue) || checkType.isObject(props.modelValue))) return console.error('multiple为false时,modelValue必须为基础类型')
223
212
  modelValue.value = props.modelValue
224
213
  }
225
214
  )
226
215
 
227
- const selectModelValue = ref<string | number | Array<number | string>>(props.multiple ? [] : '')
216
+ /** 是否显示下拉框 */
217
+ const isVisible = ref<boolean>(false)
218
+ const mTableBoxStyle = ref<Record<string, any>>({
219
+ position: 'fixed',
220
+ opacity: 0,
221
+ zIndex: 9000,
222
+ padding: '8px',
223
+ width: '500px',
224
+ border: '1px solid var(--el-border-color-lighter, #ebeef5)',
225
+ boxShadow: '0 2px 12px 0 rgba(0,0,0,.1)',
226
+ background: 'var(--el-bg-color, #fff)',
227
+ borderRadius: '4px'
228
+ })
229
+ const inputClass = 'j-' + createHash()
230
+ const boxStyle = ref<Record<string, any>>({})
228
231
  watch(
229
- () => props.name,
232
+ () => isVisible.value,
230
233
  () => {
231
- if (props.name === '' || props.name === null || props.name === undefined) return false
232
- selectModelValue.value = props.name
234
+ const style = {}
235
+ if (isVisible.value) {
236
+ const element = document.querySelector('.' + inputClass)
237
+ if (!element) return
238
+ const rect = element.getBoundingClientRect()
239
+ if (!rect) return
240
+ const bottom = window.innerHeight - rect.top - rect.height
241
+ const right = window.innerWidth - rect.left - rect.width
242
+ if (bottom < 250) {
243
+ Object.assign(style, { bottom: (bottom + rect.height) + 'px' })
244
+ Object.assign(style, { transform: 'translateY(-10px)' })
245
+ } else {
246
+ Object.assign(style, { top: (rect.top + rect.height) + 'px' })
247
+ Object.assign(style, { transform: 'translateY(10px)' })
248
+ }
249
+ if ((window.innerWidth - rect.left) < 550) {
250
+ Object.assign(style, { right: right + 'px' })
251
+ } else {
252
+ Object.assign(style, { left: rect.left + 'px' })
253
+ }
254
+
255
+ Object.assign(style, { opacity: 1 })
256
+ }
257
+ if (!isVisible.value) {
258
+ Object.assign(style, { opacity: 0 })
259
+ }
260
+
261
+ nextTick(() => {
262
+ boxStyle.value = style
263
+ })
233
264
  }
234
265
  )
235
- if (props.name || props.name === 0) {
236
- selectModelValue.value = props.name
266
+
267
+ const mMarkStyle = {
268
+ position: 'fixed',
269
+ top: 0,
270
+ left: 0,
271
+ zIndex: 8,
272
+ width: '100%',
273
+ height: '100%'
237
274
  }
238
275
 
239
- // 获取ref
240
- const selectRef = ref<InstanceType<typeof ElSelect> | null>(null)
241
- onMounted(() => {
242
- if (!selectRef.value) return false
243
- selectRef.value.toggleMenu = () => {}
244
- })
276
+ /** 表格组件对象 */
245
277
  const selectTableRef = ref<InstanceType<typeof ElTable> | null>(null)
246
278
 
247
279
  // 组件内使用自定义
248
- const isVisible = ref(false) // 是否显示隐藏下拉框
249
280
  const state = reactive<{
250
281
  tabData: Option[],
251
282
  ids: string | number | Array<string | number>,
@@ -259,35 +290,44 @@ const state = reactive<{
259
290
  })
260
291
  // 抛出事件
261
292
  const emit = defineEmits<{
293
+ 'update:modelValue': [value: string | number | boolean | Array<string | number | boolean>];
262
294
  /** 单选或多选之后的回调 */
263
- selected: [values: string | number | Array<string | number>, rows: Option[] | Option];
295
+ selected: [values: string | number | boolean | Array<string | number | boolean>, rows: Option[] | Option];
264
296
  /** 多选确认按钮时的回调 配合isAffirmBtn使用 */
265
297
  selectMultiple: [values: Array<string | number>, rows: Option[]];
266
298
  /** 当没有使用filterMethod时候才会有回调否则没有 */
267
299
  toPage: [page: Page, query?: string | number | Array<string | number>];
268
300
  /** 勾选数据change事件,选中值不发生变化 */
269
301
  selectChange: [values: string | number | Array<string | number>];
270
- 'update:modelValue': [value: string | number | Array<string | number>];
271
302
  /** 用户点击清空按钮时触发 */
272
303
  clear: [];
273
304
  /** 多选模式下移除tag时触发(标记,待处理) */
274
- removeTag: [tag: any];
305
+ removeTag: [value: any, index: number];
306
+ // /** 值变化事件 */
307
+ // change: [value: any];
275
308
  }>()
276
309
 
310
+ /** 额外创建的行 */
277
311
  const allowCreateRow = computed(() => {
278
312
  if (!props.allowCreate) return []
279
313
  const modelValue: Array<string | number> = props.multiple && Array.isArray(props.modelValue) ? props.modelValue : []
280
- const value = [...modelValue, state.searchValue].filter(item => item)
314
+ const value = [
315
+ ...modelValue,
316
+ ...(modelValue.includes(state.searchValue) ? [] : [state.searchValue])
317
+ ].filter(item => item)
281
318
  return value
282
- .filter(item => !props.options.some(node => node[props.keywords.value] === item))
319
+ .filter(item => !state.tabData.some(node => node[props.keywords.value] === item))
283
320
  .map(item => ({
321
+ value: item,
322
+ label: item,
284
323
  [props.keywords.label]: item,
285
324
  [props.keywords.value]: item,
286
325
  isAllowCreateRow: true
287
- }))
326
+ })) as Option[]
288
327
  })
289
328
 
290
- const tabDataMap = ref<Record<string, any>[]>([])
329
+ // 表格数据源 包含创建的行
330
+ const tabDataMap = ref<Option[]>([])
291
331
  watch(
292
332
  () => state.tabData,
293
333
  () => {
@@ -313,17 +353,33 @@ watch(
313
353
  })
314
354
  }
315
355
  )
356
+ const addTag = () => {
357
+ selectionChange(tabDataMap.value.filter(item => (selectModelValue.value as string[]).includes(item[props.keywords.value])))
358
+ setTimeout(() => {
359
+ defaultBackFillValue()
360
+ })
361
+ }
316
362
 
363
+ // 直接跟输入框绑定
364
+ const selectModelValue = ref<string | number | Array<number | string>>(props.multiple ? [] : '')
365
+ watch(
366
+ () => props.name,
367
+ () => {
368
+ if (props.name === '' || props.name === null || props.name === undefined) return false
369
+ selectModelValue.value = props.name
370
+ },
371
+ { immediate: true }
372
+ )
373
+ // 更新select显示值
317
374
  const upSelectModelValue = () => {
318
375
  if (props.name || props.name === 0) return false
319
376
  // 多选
320
377
  if (props.multiple) {
321
378
  const _value: Array<string | number> = Array.isArray(modelValue.value) ? modelValue.value : [modelValue.value].filter(item => item !== '')
322
- const data: Array<string | number> = _value.map(item => {
379
+ selectModelValue.value = _value.map(item => {
323
380
  const row: any = props.options.find(node => node[props.keywords.value as any] === item) || {}
324
381
  return row[props.keywords.label] || item
325
382
  })
326
- selectModelValue.value = data
327
383
  }
328
384
  // 单选
329
385
  if (!props.multiple) {
@@ -333,7 +389,7 @@ const upSelectModelValue = () => {
333
389
  }
334
390
  upSelectModelValue()
335
391
  watch(
336
- () => modelValue.value,
392
+ () => [modelValue.value],
337
393
  () => {
338
394
  upSelectModelValue()
339
395
  }
@@ -358,24 +414,26 @@ const rowClick = (row: Option) => {
358
414
  const val = tabDataMap.value.find(item => row[props.keywords.value] === item[props.keywords.value])
359
415
  if (!val) return false
360
416
  modelValue.value = val[props.keywords.value]
361
- blur()
417
+ state.searchValue = val[props.keywords.label]
362
418
 
363
419
  emit('selected', val[props.keywords.value], {
420
+ ...val,
364
421
  label: val[props.keywords.label],
365
- value: val[props.keywords.value],
366
- ...val
367
- })
422
+ value: val[props.keywords.value]
423
+ } as Option)
424
+ close()
368
425
  }
369
426
 
370
427
  // 确认的回调
371
428
  const selectMultiple = () => {
372
- blur()
429
+ // blur()
373
430
  emit('selectMultiple', state.ids as Array<string | number>, state.selectRowS)
374
431
  }
375
432
 
376
433
  // 多选事件
377
434
  const selectionChange = (selection: Option[]) => {
378
- const select = selection.map((item) => item[props.keywords.value])
435
+ if (isBackFill.value) return
436
+ const select = selection.map(item => item[props.keywords.value])
379
437
  emit('selectChange', select)
380
438
  const _value: Array<string | number> = Array.isArray(modelValue.value) ? modelValue.value : [modelValue.value].filter(item => item !== '')
381
439
  // 是否为删除
@@ -388,23 +446,28 @@ const selectionChange = (selection: Option[]) => {
388
446
  emit('selected', state.ids as Array<string | number>, state.selectRowS)
389
447
  }
390
448
  // tags删除后回调
391
- const removeTag = (tag: any) => {
392
- const row = state.tabData.find((item) => item[props.keywords.label] === tag)
393
- selectTableRef.value.toggleRowSelection(row, false)
394
- emit('removeTag', tag)
395
- }
396
- const change = (value: string | number | Array<string | number>) => {
397
- if (props.multiple && Array.isArray(value) && Array.isArray(modelValue.value)) {
398
- const removeValue = modelValue.value
399
- .filter(item => !(value as Array<string | number>).includes(item))
400
- removeValue.forEach(item => {
401
- const row = tabDataMap.value.find(node => node[props.keywords.value] === item)
402
- selectTableRef.value.toggleRowSelection(row, false)
403
- })
404
- }
405
- modelValue.value = value
406
- // emit('selectChange', modelValue.value)
449
+ const removeTag = (value: string, index: number) => {
450
+ if (!Array.isArray(modelValue.value)) return
451
+ const removeValue = modelValue.value[index]
452
+ const row = tabDataMap.value.find(node => node[props.keywords.value] === removeValue)
453
+ if (row) selectTableRef.value.toggleRowSelection(row, false)
454
+ emit('removeTag', value, index)
455
+
456
+ modelValue.value = modelValue.value.filter(item => item !== removeValue)
407
457
  }
458
+ // 多选的值发生变化
459
+ // const multipleChange = (value: string | number | Array<string | number>) => {
460
+ // // if (!props.multiple || !Array.isArray(value) || !Array.isArray(modelValue.value)) return
461
+ //
462
+ // // const removeValue = modelValue.value.filter(item => !(value as Array<string | number>).includes(item))
463
+ // // removeValue.forEach(item => {
464
+ // // const row = tabDataMap.value.find(node => node[props.keywords.value] === item)
465
+ // // if (!row) return
466
+ // // selectTableRef.value.toggleRowSelection(row, false)
467
+ // // })
468
+ //
469
+ // // modelValue.value = value
470
+ // }
408
471
 
409
472
  // 是反填中状态
410
473
  const isBackFill = ref<boolean>(false)
@@ -413,17 +476,17 @@ const defaultBackFillValue = () => {
413
476
  isBackFill.value = true
414
477
  if (props.multiple) {
415
478
  const modelArray: Array<string | number> = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue]
416
- const newArr = (state.tabData as Option[]).filter(item => modelArray.includes(item[props.keywords.value as keyof typeof item]))
479
+ const newArr = (tabDataMap.value as Option[]).filter(item => modelArray.includes(item[props.keywords.value as keyof typeof item]))
417
480
  nextTick(() => {
418
481
  newArr.forEach((row) => {
419
- const arr = state.tabData.filter(item => item[props.keywords.value] === row[props.keywords.value])
482
+ const arr = tabDataMap.value.filter(item => item[props.keywords.value] === row[props.keywords.value])
420
483
  if (!arr.length) return false
421
484
  selectTableRef.value.toggleRowSelection(arr[0], true)
422
485
  })
423
486
  isBackFill.value = false
424
487
  })
425
488
  } else {
426
- const item = state.tabData.find(item => props.modelValue === item[props.keywords.value])
489
+ const item = tabDataMap.value.find(item => props.modelValue === item[props.keywords.value])
427
490
  if (!item) return false
428
491
  nextTick(() => {
429
492
  selectTableRef.value.setCurrentRow(item, true)
@@ -443,6 +506,7 @@ const debounce = (func: Function, wait: number) => {
443
506
  }, wait)
444
507
  }
445
508
  }
509
+ /** 默认反填(显示当前表格选中状态)防抖封装 */
446
510
  const debounceDefaultBackFillValue = debounce(() => defaultBackFillValue(), 100)
447
511
  watch(
448
512
  () => props.options,
@@ -452,7 +516,8 @@ watch(
452
516
  if (check) return
453
517
  state.tabData = val
454
518
  debounceDefaultBackFillValue()
455
- }, { deep: true }
519
+ },
520
+ { deep: true }
456
521
  )
457
522
  watch(
458
523
  () => props.modelValue,
@@ -477,13 +542,8 @@ const remoteMethodHandle = (query: string = '') => {
477
542
  state.searchValue = query.trim()
478
543
  if (!props.remote) return false
479
544
 
480
- selectRef?.value?.tooltipRef?.onOpen()
481
545
  page.currentPage = 1
482
- return props.remoteMethod(query, page)
483
- }
484
- // 表格显示隐藏回调
485
- const visibleChange = (visible: boolean) => {
486
- isVisible.value = visible
546
+ return props.remoteMethod(state.searchValue, page)
487
547
  }
488
548
  // 清空后的回调
489
549
  const clear = () => {
@@ -515,11 +575,9 @@ const page = reactive<Page>(new Page({
515
575
  const toPage = (currentPage: number = 1, pageSize: number = page.pageSize) => {
516
576
  page.currentPage = currentPage
517
577
  page.pageSize = pageSize
518
- if (!props.multiple || (props.multiple && !props.reserveSelection)) clear()
519
- selectRef.value.expanded = true
520
- props.remoteMethod(state.searchValue, page)
578
+ // if (!props.multiple || (props.multiple && !props.reserveSelection)) clear()
521
579
  if (props.filterable) {
522
- emit('toPage', page, selectRef.value.inputRef.value)
580
+ emit('toPage', page, modelValue.value)
523
581
  } else {
524
582
  emit('toPage', page)
525
583
  }
@@ -527,18 +585,31 @@ const toPage = (currentPage: number = 1, pageSize: number = page.pageSize) => {
527
585
  // 触发select显示
528
586
  const focus = () => {
529
587
  if (props.disabled) return
530
- selectRef.value.focus()
531
- selectRef.value.expanded = true
588
+
589
+ remoteMethodHandle(state.searchValue)
590
+ setTimeout(() => {
591
+ isVisible.value = true
592
+ }, 150)
532
593
  }
533
594
  const changeBlur = () => {
534
- selectRef?.value?.tooltipRef?.onClose()
535
595
  }
536
596
  // 触发select隐藏
537
- const blur = () => {
538
- selectRef.value.blur()
539
- selectRef?.value?.tooltipRef?.onClose()
597
+ // const blur = () => {
598
+ // }
599
+ /** 关闭 */
600
+ const close = () => {
601
+ if (!isVisible.value) return
602
+ nextTick(() => {
603
+ isVisible.value = false
604
+ })
540
605
  }
541
- defineExpose({ defaultBackFillValue, clear, focus })
606
+
607
+ const clickOutside = () => {
608
+ if (!isVisible.value) return false
609
+ isVisible.value = false
610
+ }
611
+
612
+ defineExpose({ defaultBackFillValue, clear, focus, close })
542
613
  </script>
543
614
 
544
615
  <style lang="scss">
@@ -550,8 +621,7 @@ defineExpose({ defaultBackFillValue, clear, focus })
550
621
  width: 80px;
551
622
  }
552
623
 
553
- .m-select-table {
554
-
624
+ .m-select-table, .br-m-table-box {
555
625
  .el-table {
556
626
  --el-table-header-bg-color: var(--m-list-el-table-header-bg-color, #f5f5f5);
557
627
  }
@@ -144,9 +144,9 @@ const props = withDefaults(defineProps<{
144
144
  })
145
145
 
146
146
  const _this = reactive<{
147
- vValue: string | number,
147
+ vValue: string | number | boolean,
148
148
  vLabel: string | number,
149
- oValue: string | number,
149
+ oValue: string | number | boolean,
150
150
  inputClass: string,
151
151
  masterPieceLoading: boolean,
152
152
  showPanel: boolean, // 显示面板
@@ -55,7 +55,7 @@ const props = withDefaults(defineProps<{
55
55
 
56
56
  const attrs = useAttrs()
57
57
 
58
- type ValueType = string | number | Array<string | number>
58
+ type ValueType = string | number | boolean | Array<string | number | boolean>
59
59
  const modelValue = ref<ValueType>(props.modelValue as ValueType)
60
60
  watch(
61
61
  () => props.modelValue,