分区-公共组件select-needAllPartition和needAll开关
This commit is contained in:
@@ -29,7 +29,7 @@ export default {
|
|||||||
default: undefined,
|
default: undefined,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
needAll: {
|
needAllPartition: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
@@ -37,6 +37,10 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
needAll: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "请选择分区",
|
default: "请选择分区",
|
||||||
@@ -53,7 +57,6 @@ export default {
|
|||||||
const partitionInfoList = ref(props.partitionInfos);
|
const partitionInfoList = ref(props.partitionInfos);
|
||||||
// 定义响应式变量 internalValue 用于内部管理 partitionId 的值
|
// 定义响应式变量 internalValue 用于内部管理 partitionId 的值
|
||||||
const partitionIdValue = ref(props.partitionId);
|
const partitionIdValue = ref(props.partitionId);
|
||||||
const needAllValue = ref(props.needAll);
|
|
||||||
const handleChangeFunc = ref(props.handleChange);
|
const handleChangeFunc = ref(props.handleChange);
|
||||||
|
|
||||||
// 监听外部传入的 partitionId 变化,并同步到 internalValue
|
// 监听外部传入的 partitionId 变化,并同步到 internalValue
|
||||||
@@ -66,7 +69,7 @@ export default {
|
|||||||
|
|
||||||
// 在组件挂载时加载分区信息
|
// 在组件挂载时加载分区信息
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const listDateFunc = !needAllValue.value? getPartitionInfoList: listAll;
|
const listDateFunc = !props.needAllPartition? getPartitionInfoList: listAll;
|
||||||
listDateFunc().then((res) => {
|
listDateFunc().then((res) => {
|
||||||
setPartitionInfos(res.data)
|
setPartitionInfos(res.data)
|
||||||
});
|
});
|
||||||
@@ -74,6 +77,14 @@ export default {
|
|||||||
|
|
||||||
const setPartitionInfos = (data) => {
|
const setPartitionInfos = (data) => {
|
||||||
partitionInfoList.value = data;
|
partitionInfoList.value = data;
|
||||||
|
|
||||||
|
if (props.needAll){
|
||||||
|
partitionInfoList.value.unshift({
|
||||||
|
id: undefined,
|
||||||
|
desc: "全部"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
partitionIdValue.value = partitionInfoList.value? partitionInfoList.value[0].id: undefined;
|
partitionIdValue.value = partitionInfoList.value? partitionInfoList.value[0].id: undefined;
|
||||||
|
|
||||||
emit("update:partitionId", partitionIdValue.value);
|
emit("update:partitionId", partitionIdValue.value);
|
||||||
|
Reference in New Issue
Block a user