feat: 快速预定的处理
This commit is contained in:
@@ -61,8 +61,12 @@ const tabList = ref([]);
|
|||||||
|
|
||||||
// 处理Tab点击
|
// 处理Tab点击
|
||||||
const handleTabClick = (index) => {
|
const handleTabClick = (index) => {
|
||||||
if (activeIndex.value === index) return;
|
changeTabItem(index);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 支持 force 参数,强制触发(即使 index 与当前相同)
|
||||||
|
const changeTabItem = (index, force = false) => {
|
||||||
|
if (!force && activeIndex.value === index) return;
|
||||||
activeIndex.value = index;
|
activeIndex.value = index;
|
||||||
|
|
||||||
emit("change", {
|
emit("change", {
|
||||||
@@ -70,7 +74,8 @@ const handleTabClick = (index) => {
|
|||||||
item: tabList.value[index],
|
item: tabList.value[index],
|
||||||
});
|
});
|
||||||
emit("update:modelValue", index);
|
emit("update:modelValue", index);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
// 监听tabs变化
|
// 监听tabs变化
|
||||||
watch(
|
watch(
|
||||||
@@ -114,6 +119,12 @@ const getCommodityTypePageList = async () => {
|
|||||||
} else {
|
} else {
|
||||||
tabList.value = props.tabs;
|
tabList.value = props.tabs;
|
||||||
}
|
}
|
||||||
|
// 加载完成后强制选中第一个项并通知外部
|
||||||
|
if (tabList.value && tabList.value.length > 0) {
|
||||||
|
changeTabItem(0, true);
|
||||||
|
} else {
|
||||||
|
changeTabItem(props.defaultActive, true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<Tabs @change="handleTabChange"/>
|
<Tabs @change="handleTabChange"/>
|
||||||
|
|
||||||
<!-- 选择入住、离店日期 0:是酒店 -->
|
<!-- 选择入住、离店日期 0:是酒店 -->
|
||||||
<view v-if="currentType === '0' && dataList.length > 0" class="bg-white border-box flex flex-items-center p-12">
|
<view v-if="didSelectedTabItem && didSelectedTabItem.orderType === 0" class="bg-white border-box flex flex-items-center p-12">
|
||||||
<view class="in flex flex-items-center">
|
<view class="in flex flex-items-center">
|
||||||
<text class="font-size-11 font-500 color-99A0AE mr-4">入住</text>
|
<text class="font-size-11 font-500 color-99A0AE mr-4">入住</text>
|
||||||
<text class="font-size-14 font-500 color-171717">
|
<text class="font-size-14 font-500 color-171717">
|
||||||
@@ -57,17 +57,22 @@ const selectedDate = ref({
|
|||||||
});
|
});
|
||||||
const dataList = ref([]);
|
const dataList = ref([]);
|
||||||
const paging = ref(null);
|
const paging = ref(null);
|
||||||
const currentType = ref("0"); // 当前选中类型
|
// 当前选中项
|
||||||
|
const didSelectedTabItem = ref(null);
|
||||||
|
|
||||||
const queryList = async (pageNum = 1, pageSize = 10) => {
|
const queryList = async (pageNum = 1, pageSize = 10) => {
|
||||||
|
if (!didSelectedTabItem.value) {
|
||||||
|
paging.value.complete([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
commodityTypeCode: currentType.value,
|
commodityTypeCode: didSelectedTabItem.value.typeCode,
|
||||||
size: pageSize,
|
size: pageSize,
|
||||||
current: pageNum,
|
current: pageNum,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (currentType.value === "0") {
|
if (didSelectedTabItem.value.orderType === 0) {
|
||||||
params.checkInDate = selectedDate.value.startDate;
|
params.checkInDate = selectedDate.value.startDate;
|
||||||
params.checkOutDate = selectedDate.value.endDate;
|
params.checkOutDate = selectedDate.value.endDate;
|
||||||
}
|
}
|
||||||
@@ -92,12 +97,8 @@ const queryList = async (pageNum = 1, pageSize = 10) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleTabChange = ({ item }) => {
|
const handleTabChange = ({ item }) => {
|
||||||
console.log("item typeCode: ", item.typeCode);
|
console.log("选中的tab item: ", item);
|
||||||
currentType.value = item.typeCode;
|
didSelectedTabItem.value = item;
|
||||||
|
|
||||||
if (currentType.value === "0") {
|
|
||||||
}
|
|
||||||
|
|
||||||
paging.value.reload();
|
paging.value.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user