<template> <el-tabs v-model="active" class="tabs"> <el-tab-pane v-for="tab in tabs" :label="tab.label" :name="tab.name" > <list :data="tab?.data" :index="tab.name" :disabled="true" ref="listRef" /> </el-tab-pane> </el-tabs> </template> <script setup> import { ref, reactive, onMounted } from 'vue' import list from './components/list.vue' import { getUnderlyingSurfaceRunoffConfigItemList } from '@/api/preassess/runoffCoefficient' import { getFacilitiesPolluteRemoveConfigItemList } from '@/api/preassess/removalRate' import { getFacilitiesAdaptabilityConfigItemList } from '@/api/preassess/adaptationConfig' import { getDicts } from '@/api/preassess/noopReview' const { proxy } = getCurrentInstance() const props = defineProps({ projectInfo: { type: Object, default: () => {} }, uploadCallbackData: { type: Object, default: () => {} } }) const { projectInfo } = props const sponge_facilities_type = ref([]) const tabs = ref([]) const active = ref(0) const templateData = { underlySurface: { name: "建设工程下垫面", list: [] }, facility: { name: "建设工程设施", list: [] }, elevation: { name: "分区高程", data: { groundElevation: '', facilityBaseElevation: '' } } } const underlySurfaceList = ref([]) const facilityList = ref([]) const getTabs = () => { active.value = 0 tabs.value = props.uploadCallbackData.map((item, i) => ({ name: i, label: item.name, data: null })) } const getTableList = () => { getTabs() // 填充图纸数据 setUploadLoadData(underlySurfaceList.value, facilityList.value) // 填充默认值 setDefaultData() } const getUnderlySurfaceList = async () => { const res = await getUnderlyingSurfaceRunoffConfigItemList({ status: '1'}) if(res?.code !== 200) return [] res.data.forEach((item) => { item.area = '' item.runoffCoefficient = item.downValue }) console.log('下垫面模版数据', res.data) return res.data } const getFacilityList = async () => { const res = await getFacilitiesPolluteRemoveConfigItemList({ status: '1' }) if(res?.code !== 200) return const data = res.data const res1 = await getFacilitiesAdaptabilityConfigItemList({ status: '1' }) if(res1?.code !== 200) return const filterData = res1.data const result = [] for (const item of sponge_facilities_type.value) { const list = getChildrenTableList(item.value, data, filterData) if(list.length) { result.push({name: item.label, list}) } } console.log('设施模版数据', result) return result } const getChildrenTableList = (itemType, data, filterData) => { const list = data.filter(it => it.itemType === itemType) return list.filter(it => { it.facilityArea = '' it.effectiveStorageDepth = '' it.facilityServiceArea = '' it.pollutionRemovalRate = it.downValue const ele = filterData.find((val) => (val.itemType + val.itemName) === (it.itemType + it.itemName)) if(ele) { const adaptabilityConfigJson = JSON.parse(ele.adaptabilityConfigJson) const engineeringType = projectInfo.engineeringType const item = adaptabilityConfigJson.find(it => it.key === engineeringType) return item.value !== 'unsuitable' } else { return true } }) } const setUploadLoadData = (underlySurfaceList, facilityList) => { for (const tab of tabs.value) { const cloneData = JSON.parse(JSON.stringify(templateData)) cloneData.underlySurface.list = JSON.parse(JSON.stringify(underlySurfaceList)) cloneData.facility.list = JSON.parse(JSON.stringify(facilityList)) const curTabData = props.uploadCallbackData.find(it => it.name === tab.label) // 填充建设工程下垫面的数据 setUnderlySurfaceData(cloneData, curTabData) // 填充建设工程设施的数据 setFacilityData(cloneData, curTabData) tab.data = cloneData } } const setUnderlySurfaceData = (cloneData, curTabData) => { for (const item of cloneData.underlySurface.list) { const curTabUnderlySurfaceItemData = curTabData.underlyingSurfaceList.find(it => it.name === item.itemName) if(curTabUnderlySurfaceItemData){ item.area = curTabUnderlySurfaceItemData.area item.runoffCoefficient = curTabUnderlySurfaceItemData.underlyingSurfaceValue } } } const setFacilityData = (cloneData, curTabData) => { for (const item of cloneData.facility.list) { for (const it of item.list) { const curTabFacilityItemData = curTabData.polluteRemoveList.find(val => val.name === it.itemName) if(curTabFacilityItemData){ it.facilityArea = curTabFacilityItemData.area it.effectiveStorageDepth = curTabFacilityItemData.depth it.facilityServiceArea = curTabFacilityItemData.volume } } } } const setDefaultData = () => { for (let i = 0; i < tabs.value.length; i++) { const tab = tabs.value[i]; const data = tab.data for (const item of data.underlySurface.list) { item.area = item.area || '0' } for (const item of data.facility.list) { for (const it of item.list) { it.facilityArea = it.facilityArea || '0' it.effectiveStorageDepth = it.effectiveStorageDepth || '0' it.facilityServiceArea = it.facilityServiceArea || '0' } } if(i > 0) { for (const key in data.elevation.data) { if (Object.hasOwnProperty.call(data.elevation.data, key)) { data.elevation.data[key] = data.elevation.data[key] || '0'; } } } } } const getSpongeFacilitiesType = async () => { const res = await getDicts('sponge_facilities_type') if(res?.code !== 200) return sponge_facilities_type.value = res.data.map(item => ({ value: item.dictValue, label: item.dictLabel })) } const getList = async (data) => { getSpongeFacilitiesType() underlySurfaceList.value = await getUnderlySurfaceList() facilityList.value = await getFacilityList() getTableList() } onMounted(() => { getList() }) </script> <style lang="scss" scoped></style>