Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-ui
Commits
db1c71b2
提交
db1c71b2
authored
1月 16, 2025
作者:
lidongxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(xlselect): 封装带全选功能的下拉菜单
同上
上级
5e4df757
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
57 行增加
和
43 行删除
+57
-43
index.vue
src/components/XLSelect/index.vue
+53
-35
index.vue
src/views/bi/finance/index.vue
+4
-8
没有找到文件。
src/components/XLSelect/index.vue
浏览文件 @
db1c71b2
...
...
@@ -2,57 +2,75 @@
<el-select
v-bind=
"$attrs"
v-model=
"selectedOptions"
@
change=
"handleChange"
>
<el-option
v-if=
"allOption"
:key=
"allSelectLabel"
:label=
"allSelectLabel"
:value=
"allSelectValue"
></el-option>
<slot></slot>
<li
class=
"el-select-dropdown__item all_item "
:class=
"
{ 'is-selected': isAll }"
@click="selectAll">
<span>
全选
</span>
</li>
<el-option
v-for=
"str in options"
:label=
"str"
:value=
"str"
>
</el-option>
</el-select>
</
template
>
<
script
setup
>
const
selectedOptions
=
ref
([])
const
selectedOptions
=
ref
([])
// 当前选中的值集合
const
isAll
=
ref
(
false
)
// 全选状态
const
emits
=
defineEmits
([
'update:modelValue'
]);
const
props
=
defineProps
({
allOption
:
{
// 开启全选选项
type
:
Boolean
,
default
:
false
,
},
allSelectLabel
:
{
// 全选文案
type
:
String
,
default
:
'全选'
,
},
allSelectValue
:
{
// 全选绑定值
type
:
[
String
,
Number
],
default
:
'ALL'
,
options
:
{
type
:
Array
,
default
:
()
=>
[],
},
allSingleValue
:
{
// 全选模式(false:返回 option 组,true:返回 allSelectValue 值)
type
:
Boolean
,
default
:
false
,
},
modelValue
:
[
String
,
Object
,
Array
]
});
modelValue
:
{
type
:
Array
,
default
:
()
=>
[]
}
})
watch
(()
=>
props
.
modelValue
,
val
=>
{
// if (props.allOption) {
// // 判断不是数组则转成数组
// if (!Array.isArray(val)) {
// emits('update:modelValue', [val]);
// selectedOptions.value = [val];
// }
// }
selectedOptions
.
value
=
val
;
isAll
.
value
=
val
.
length
===
props
.
options
.
length
},
{
deep
:
true
,
immediate
:
true
})
const
handleChange
=
(
val
)
=>
{
if
(
val
.
includes
(
props
.
allSelectValue
))
{
selectedOptions
.
value
=
[
props
.
allSelectValue
];
// 全选点击
const
selectAll
=
()
=>
{
isAll
.
value
=
!
isAll
.
value
if
(
isAll
.
value
)
{
selectedOptions
.
value
=
[...
props
.
options
];
emits
(
'update:modelValue'
,
selectedOptions
.
value
);
}
else
{
selectedOptions
.
value
=
val
;
selectedOptions
.
value
=
[];
emits
(
'update:modelValue'
,
selectedOptions
.
value
);
}
// emit('update:modelValue', selectedOptions.value);
}
const
handleChange
=
(
val
)
=>
{
isAll
.
value
=
val
.
length
===
props
.
options
.
length
emits
(
'update:modelValue'
,
val
)
}
</
script
>
<
style
scoped
lang=
"scss"
>
.all_item
{
cursor
:
pointer
;
}
.all_item
:hover
{
background-color
:
var
(
--
el-fill-color-light
);
}
.all_item
:hover
+
.is-hovering
{
background-color
:
transparent
;
}
</
style
>
src/views/bi/finance/index.vue
浏览文件 @
db1c71b2
...
...
@@ -6,18 +6,14 @@
label-position=
"right"
label-width=
"68px"
inline
>
<el-form-item
label=
"直播间"
>
<el-form-item
label=
"直播间"
ref=
"ab"
>
<xl-select
v-model=
"queryParams.brand"
allOption
:options=
"brandList"
multiple
clearable
collapse-tags
collapse-tags-tooltip
@
change=
"getList"
>
<el-option
v-for=
"str in brandList"
:label=
"str"
:value=
"str"
>
</el-option>
</xl-select>
</el-form-item>
<el-form-item
label=
"口味"
>
...
...
@@ -131,7 +127,7 @@ const goodsList = ref([]) // 商品
const
data
=
reactive
({
queryParams
:
{
brand
:
'a'
,
// 直播间
brand
:
[
'a'
,
'b'
,
'c'
]
,
// 直播间
taste
:
''
,
// 口味
spec
:
''
,
// 规格
series
:
''
,
// 系列
...
...
@@ -277,7 +273,7 @@ const detailColumns = ref([
prop
:
''
}
])
const
ab
=
ref
(
null
)
</
script
>
<
style
scoped
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论