分区-公共组件select-needAllPartition和needAll开关
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user