From 91af330db5c5ab44e4b9b1adf0e1bd456b70dd57 Mon Sep 17 00:00:00 2001 From: khalil Date: Wed, 2 Apr 2025 11:47:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E5=8C=BA-=E5=85=AC=E5=85=B1=E7=BB=84?= =?UTF-8?q?=E4=BB=B6select-needAllPartition=E5=92=8CneedAll=E5=BC=80?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/common/partitionSelect.vue | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/views/common/partitionSelect.vue b/src/views/common/partitionSelect.vue index 150279c..d079789 100644 --- a/src/views/common/partitionSelect.vue +++ b/src/views/common/partitionSelect.vue @@ -29,7 +29,7 @@ export default { default: undefined, required: true, }, - needAll: { + needAllPartition: { type: Boolean, default: false, }, @@ -37,6 +37,10 @@ export default { type: Array, default: () => [], }, + needAll: { + type: Boolean, + default: false, + }, placeholder: { type: String, default: "请选择分区", @@ -53,7 +57,6 @@ export default { const partitionInfoList = ref(props.partitionInfos); // 定义响应式变量 internalValue 用于内部管理 partitionId 的值 const partitionIdValue = ref(props.partitionId); - const needAllValue = ref(props.needAll); const handleChangeFunc = ref(props.handleChange); // 监听外部传入的 partitionId 变化,并同步到 internalValue @@ -66,7 +69,7 @@ export default { // 在组件挂载时加载分区信息 onMounted(() => { - const listDateFunc = !needAllValue.value? getPartitionInfoList: listAll; + const listDateFunc = !props.needAllPartition? getPartitionInfoList: listAll; listDateFunc().then((res) => { setPartitionInfos(res.data) }); @@ -74,6 +77,14 @@ export default { const setPartitionInfos = (data) => { partitionInfoList.value = data; + + if (props.needAll){ + partitionInfoList.value.unshift({ + id: undefined, + desc: "全部" + }) + } + partitionIdValue.value = partitionInfoList.value? partitionInfoList.value[0].id: undefined; emit("update:partitionId", partitionIdValue.value);