fix
This commit is contained in:
1 parent
ad4e9cdee0
commit
043e1fc879
8 files changed
+529
-112
No files matched your search
@@ -5,20 +5,29 @@
|
||||
:subtitle="`合同ID:${contractId}`"
|
||||
:copy-text="contractId"
|
||||
:storage-key="`zxfw-pricing-active-cat-${contractId}-${serviceId}`"
|
||||
default-category="investment-scale-method"
|
||||
:default-category="defaultCategory"
|
||||
:categories="pricingCategories"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineAsyncComponent, defineComponent, h, markRaw, type Component } from 'vue'
|
||||
import { computed, defineAsyncComponent, defineComponent, h, markRaw, type Component } from 'vue'
|
||||
import TypeLine from '@/layout/typeLine.vue'
|
||||
import MethodUnavailableNotice from '@/components/common/MethodUnavailableNotice.vue'
|
||||
|
||||
interface ServiceMethodType {
|
||||
scale?: boolean | null
|
||||
onlyCostScale?: boolean | null
|
||||
amount?: boolean | null
|
||||
workDay?: boolean | null
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
contractId: string
|
||||
contractName?: string
|
||||
serviceId: string|number
|
||||
fwName:string
|
||||
type?: ServiceMethodType
|
||||
}>()
|
||||
|
||||
interface PricingCategoryItem {
|
||||
@@ -27,6 +36,22 @@ interface PricingCategoryItem {
|
||||
component: Component
|
||||
}
|
||||
|
||||
const resolveMethodEnabled = (value: boolean | null | undefined, fallback = true) =>
|
||||
typeof value === 'boolean' ? value : fallback
|
||||
|
||||
const methodAvailability = computed(() => {
|
||||
const scale = resolveMethodEnabled(props.type?.scale, true)
|
||||
const onlyCostScale = resolveMethodEnabled(props.type?.onlyCostScale, false)
|
||||
const amount = resolveMethodEnabled(props.type?.amount, true)
|
||||
const workDay = resolveMethodEnabled(props.type?.workDay, true)
|
||||
return {
|
||||
investmentScale: scale,
|
||||
landScale: scale && !onlyCostScale,
|
||||
workload: amount,
|
||||
hourly: workDay
|
||||
}
|
||||
})
|
||||
|
||||
const createPricingPane = (name: string) =>
|
||||
markRaw(
|
||||
defineComponent({
|
||||
@@ -44,15 +69,66 @@ const createPricingPane = (name: string) =>
|
||||
})
|
||||
)
|
||||
|
||||
const createMethodUnavailablePane = (title: string, message: string) =>
|
||||
markRaw(
|
||||
defineComponent({
|
||||
name: 'MethodUnavailablePane',
|
||||
setup() {
|
||||
return () => h(MethodUnavailableNotice, { title, message })
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
const investmentScaleView = createPricingPane('InvestmentScalePricingPane')
|
||||
const landScaleView = createPricingPane('LandScalePricingPane')
|
||||
const workloadView = createPricingPane('WorkloadPricingPane')
|
||||
const hourlyView = createPricingPane('HourlyPricingPane')
|
||||
|
||||
const pricingCategories: PricingCategoryItem[] = [
|
||||
{ key: 'investment-scale-method', label: '投资规模法', component: investmentScaleView },
|
||||
{ key: 'land-scale-method', label: '用地规模法', component: landScaleView },
|
||||
{ key: 'workload-method', label: '工作量法', component: workloadView },
|
||||
{ key: 'hourly-method', label: '工时法', component: hourlyView }
|
||||
]
|
||||
const investmentScaleUnavailableView = createMethodUnavailablePane(
|
||||
'该服务不适用投资规模法',
|
||||
'当前服务未启用规模法,投资规模法不可编辑。'
|
||||
)
|
||||
const landScaleUnavailableView = createMethodUnavailablePane(
|
||||
'该服务不适用用地规模法',
|
||||
'当前服务仅支持投资规模法,用地规模法不可编辑。'
|
||||
)
|
||||
const workloadUnavailableView = createMethodUnavailablePane(
|
||||
'该服务不适用工作量法',
|
||||
'当前服务未启用工作量法,工作量法不可编辑。'
|
||||
)
|
||||
const hourlyUnavailableView = createMethodUnavailablePane(
|
||||
'该服务不适用工时法',
|
||||
'当前服务未启用工时法,工时法不可编辑。'
|
||||
)
|
||||
|
||||
const pricingCategories = computed<PricingCategoryItem[]>(() => [
|
||||
{
|
||||
key: 'investment-scale-method',
|
||||
label: '投资规模法',
|
||||
component: methodAvailability.value.investmentScale ? investmentScaleView : investmentScaleUnavailableView
|
||||
},
|
||||
{
|
||||
key: 'land-scale-method',
|
||||
label: '用地规模法',
|
||||
component: methodAvailability.value.landScale ? landScaleView : landScaleUnavailableView
|
||||
},
|
||||
{
|
||||
key: 'workload-method',
|
||||
label: '工作量法',
|
||||
component: methodAvailability.value.workload ? workloadView : workloadUnavailableView
|
||||
},
|
||||
{
|
||||
key: 'hourly-method',
|
||||
label: '工时法',
|
||||
component: methodAvailability.value.hourly ? hourlyView : hourlyUnavailableView
|
||||
}
|
||||
])
|
||||
|
||||
const defaultCategory = computed(() => {
|
||||
if (methodAvailability.value.investmentScale) return 'investment-scale-method'
|
||||
if (methodAvailability.value.landScale) return 'land-scale-method'
|
||||
if (methodAvailability.value.workload) return 'workload-method'
|
||||
if (methodAvailability.value.hourly) return 'hourly-method'
|
||||
return 'investment-scale-method'
|
||||
})
|
||||
</script>
|
||||
Reference in new issue
Block a user