66 lines
1.7 KiB
Vue
66 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
import { computed, onActivated, onMounted, ref } from 'vue'
|
|
import localforage from 'localforage'
|
|
import { getMajorDictEntries, isMajorIdInIndustryScope } from '@/sql'
|
|
import XmFactorGrid from '@/components/common/XmFactorGrid.vue'
|
|
import MethodUnavailableNotice from '@/components/common/MethodUnavailableNotice.vue'
|
|
|
|
interface XmBaseInfoState {
|
|
projectIndustry?: string
|
|
}
|
|
|
|
type MajorItem = {
|
|
code: string
|
|
name: string
|
|
defCoe: number | null
|
|
desc?: string | null
|
|
notshowByzxflxs?: boolean
|
|
}
|
|
|
|
const PROJECT_INFO_KEY = 'xm-base-info-v1'
|
|
const projectIndustry = ref('')
|
|
const hasProjectBaseInfo = ref(false)
|
|
|
|
const loadProjectIndustry = async () => {
|
|
try {
|
|
const data = await localforage.getItem<XmBaseInfoState>(PROJECT_INFO_KEY)
|
|
hasProjectBaseInfo.value = Boolean(data)
|
|
projectIndustry.value =
|
|
typeof data?.projectIndustry === 'string' ? data.projectIndustry.trim() : ''
|
|
} catch (error) {
|
|
console.error('loadProjectIndustry failed:', error)
|
|
hasProjectBaseInfo.value = false
|
|
projectIndustry.value = ''
|
|
}
|
|
}
|
|
|
|
const filteredMajorDict = computed<Record<string, MajorItem>>(() => {
|
|
const industry = projectIndustry.value
|
|
if (!industry) return {}
|
|
const entries = getMajorDictEntries()
|
|
.filter(({ id }) => isMajorIdInIndustryScope(id, industry))
|
|
.map(({ id, item }) => [id, item as MajorItem] as const)
|
|
return Object.fromEntries(entries)
|
|
})
|
|
|
|
onMounted(() => {
|
|
void loadProjectIndustry()
|
|
})
|
|
|
|
onActivated(() => {
|
|
void loadProjectIndustry()
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<XmFactorGrid
|
|
title="工程专业系数明细"
|
|
storage-key="xm-major-factor-v1"
|
|
:dict="filteredMajorDict"
|
|
:disable-budget-edit-when-standard-null="true"
|
|
:exclude-notshow-by-zxflxs="true"
|
|
|
|
/>
|
|
</template>
|