Skip to content

Commit

Permalink
select 支持批量模糊粘贴
Browse files Browse the repository at this point in the history
  • Loading branch information
blryli committed May 20, 2024
1 parent 254a7c8 commit 658f259
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dk-vui",
"version": "0.1.20",
"version": "0.1.21",
"description": "dk-vui",
"private": false,
"author": "blryli",
Expand Down
7 changes: 5 additions & 2 deletions packages/components/Select/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const props = defineProps({
multiple: Boolean,
select: { type: Boolean, default: false }, // 是否使用el-select组件渲染
paste: { type: [Boolean, String], default: false }, // 粘贴功能,存在则开启粘贴功能,粘贴弹窗的标题默认使用传入的placeholder,如果类型为字符串则会作为弹窗的标题
confusedPaste: Boolean,
})
const attrs = useAttrs()
// 插槽处理
Expand Down Expand Up @@ -81,13 +82,15 @@ const visibleChange = val => {
}
const pasteChange = (pastes) => {
const pastesValue = opts.value.reduce((acc, cur) => pastes.includes(cur.label) ? acc.concat(cur.value) : acc, [])
const pastesValue = opts.value.reduce((acc, cur) => {
return (props.confusedPaste && pastes.some(d => cur.label.indexOf(d) > -1) || pastes.includes(cur.label)) ? acc.concat(cur.value) : acc
}, [])
selectValue.value = [...new Set((selectValue.value || []).concat(pastesValue))]
}
</script>
<template>
<VGroup v-if="paste && multiple">
<VGroup v-if="(paste || confusedPaste) && multiple">
<el-select v-if="select" v-model="selectValue" v-bind="$attrs" :filterable="filterable" :clearable="clearable"
:multiple="multiple" collapse-tags-tooltip @change="handleChange" @visible-change="visibleChange">
<el-option v-for="(d, i) in opts" :key="i" :label="d.label" :value="d.value"></el-option>
Expand Down
5 changes: 5 additions & 0 deletions src/views/components/select/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const options = [
<VSelect v-model="form.field2" placeholder="店铺" multiple collapse-tags paste :options="options" class="w-400" />
<Md v-model="paste" view />

<h2>confusedPaste 模糊粘贴</h2>
<p>multiple 多选模式下,可以使用 confusedPaste 模糊粘贴功能快速追加选项</p>
<VSelect v-model="form.field2" placeholder="店铺" multiple collapse-tags confusedPaste :options="options" class="w-400" />
<Md v-model="paste" view />

<h2>配置选项</h2>
<p>
使用 types 定义配置,结合 type 参数来使用
Expand Down
4 changes: 4 additions & 0 deletions src/views/index/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## 版本升级

- 2024-5-20 v0.1.21
1. 下拉框组件增加 confusedPaste 参数,支持模糊粘贴选项
2. 修复表格组件搜索参数的问题

- 2024-5-16 v0.1.18
1. 表格组件增加 initColumn 方法,在调用vxe-table的 loadColumn及reloadColumn 方法时需要用这个方法初始化参数 columns

Expand Down

0 comments on commit 658f259

Please sign in to comment.