<template>
|
<ProCategory ref="categoryRef" :category="category" @change="change" class="category-page-inner">
|
<nut-category-pane :categoryChild="data.categoryChild" @onChange="onChange">
|
</nut-category-pane>
|
</ProCategory>
|
</template>
|
|
<script setup lang="ts">
|
import Taro from '@tarojs/taro';
|
import { useDictionaryDataSelect, useStandardServiceList } from '@12333/hooks';
|
import { CategoryCode, EnumStandardServiceReleaseStatus, PositionCodeEnum } from '@12333/constants';
|
import { setOSSLink } from '@12333/utils';
|
import { ProCategory } from '@12333/components';
|
import { useSystemStore } from '@/stores/modules/system';
|
|
defineOptions({
|
name: 'InnerPage',
|
});
|
|
const router = Taro.useRouter();
|
const systemStore = useSystemStore();
|
const { servicePageJobCode } = storeToRefs(systemStore);
|
|
const categoryRef = ref();
|
|
const data = reactive({
|
category: [],
|
categoryChild: [],
|
});
|
|
const { dictionaryDataList: positionList, ensureQueryData } = useDictionaryDataSelect({
|
categoryCode: CategoryCode.Position,
|
field1: PositionCodeEnum.Housekeeping,
|
});
|
|
const { ensureStandardServiceList, standardServiceListForCategoryMap } = useStandardServiceList({
|
params: {
|
releaseStatus: EnumStandardServiceReleaseStatus.InProcess,
|
},
|
});
|
|
onMounted(async () => {
|
try {
|
await Promise.all([ensureQueryData(), ensureStandardServiceList()]);
|
if (positionList.value.length > 0 && categoryRef.value) {
|
initCategory();
|
// const first = positionList.value[0];
|
// data.categoryChild = convertCategoryChild(
|
// first.value,
|
// standardServiceListForCategoryMap.value[first.value]
|
// );
|
}
|
} catch (error) {}
|
});
|
|
function initCategory() {
|
const currentIndex = Math.max(
|
positionList.value.findIndex((x) => x.value === servicePageJobCode.value),
|
0
|
);
|
categoryRef.value.getChildList(currentIndex);
|
systemStore.setServicePageJobCode('');
|
}
|
|
watch(servicePageJobCode, () => {
|
if (servicePageJobCode.value) {
|
initCategory();
|
}
|
});
|
|
function convertCategoryChild(jobCode: string, list: API.GetStandardServicesQueryResultItem[]) {
|
const categoryChild = {
|
catId: jobCode,
|
catName: '',
|
catLevel: 2,
|
catType: 1,
|
childCateList: [],
|
};
|
if (list?.length > 0) {
|
categoryChild.childCateList = list.map((x) => ({
|
backImg: setOSSLink(x.file),
|
catId: x.id,
|
catName: x.name,
|
showPic: true,
|
showVideo: false,
|
}));
|
}
|
return [categoryChild];
|
}
|
|
const category = computed(() =>
|
positionList.value.map((x) => ({
|
...x,
|
catName: x.label,
|
}))
|
);
|
|
const change = (index: number) => {
|
const current = positionList.value[index];
|
data.categoryChild = convertCategoryChild(
|
current.value,
|
standardServiceListForCategoryMap.value[current.value]
|
);
|
};
|
const onChange = (ev) => {
|
console.log('当前分类数据', ev);
|
Taro.navigateTo({
|
url: `${RouterPath.serciceDetail}?id=${ev.catId}`,
|
});
|
};
|
</script>
|
|
<style lang="scss">
|
@import '@/styles/common.scss';
|
|
.task-page-wrapper {
|
.category-page-inner {
|
height: 100%;
|
background-color: transparent;
|
}
|
}
|
</style>
|