|
|
@@ -9,30 +9,60 @@
|
|
|
|
|
|
<template>
|
|
|
<Dialog v-model="dialogVisible" :title="title" width="550">
|
|
|
- <ElForm ref="formRef" :model="formData" :labelWidth="120">
|
|
|
- <template v-for="item in schema" :key="item.field">
|
|
|
- <el-form-item v-if="!getIsHidden(item)" :label="item.label" :prop="item.field" :rules="item.rules">
|
|
|
- <component
|
|
|
- :is="componentMap[item.component]"
|
|
|
- :key="item.field"
|
|
|
- v-model="formData[item.field]"
|
|
|
- v-bind="item.componentProps"
|
|
|
- >
|
|
|
- <template v-if="item.component === 'Select'">
|
|
|
- <el-option
|
|
|
- v-for="option in item.componentProps?.options"
|
|
|
- :key="option.value"
|
|
|
- :label="option.label"
|
|
|
- :value="option.value"
|
|
|
- />
|
|
|
- </template>
|
|
|
- </component>
|
|
|
- </el-form-item>
|
|
|
- </template>
|
|
|
- <el-form-item label="">
|
|
|
- <span>{{ `将自动为勾选的${equipCount}台设备添加检验方案` }}</span>
|
|
|
- </el-form-item>
|
|
|
- </ElForm>
|
|
|
+ <el-tabs v-model="inspectionPlanType" type="border-card" @tab-change="handleTabChange">
|
|
|
+ <el-tab-pane label="通用" name="commPlan">
|
|
|
+ <ElForm ref="formRef" :model="formData" :labelWidth="120">
|
|
|
+ <template v-for="item in schema" :key="item.field">
|
|
|
+ <el-form-item v-if="!getIsHidden(item)" :label="item.label" :prop="item.field" :rules="item.rules">
|
|
|
+ <component
|
|
|
+ :is="componentMap[item.component]"
|
|
|
+ :key="item.field"
|
|
|
+ v-model="formData[item.field]"
|
|
|
+ v-bind="item.componentProps"
|
|
|
+ >
|
|
|
+ <template v-if="item.component === 'Select'">
|
|
|
+ <el-option
|
|
|
+ v-for="option in item.componentProps?.options"
|
|
|
+ :key="option.value"
|
|
|
+ :label="option.label"
|
|
|
+ :value="option.value"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </component>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ <el-form-item label="">
|
|
|
+ <span>{{ `将自动为勾选的${equipCount}台设备添加检验方案` }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ </ElForm>
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane label="自编" name="selfPlan">
|
|
|
+ <ElForm ref="formRef" :model="formData" :labelWidth="120">
|
|
|
+ <template v-for="item in schema" :key="item.field">
|
|
|
+ <el-form-item v-if="!getIsHidden(item)" :label="item.label" :prop="item.field" :rules="item.rules">
|
|
|
+ <component
|
|
|
+ :is="componentMap[item.component]"
|
|
|
+ :key="item.field"
|
|
|
+ v-model="formData[item.field]"
|
|
|
+ v-bind="item.componentProps"
|
|
|
+ >
|
|
|
+ <template v-if="item.component === 'Select'">
|
|
|
+ <el-option
|
|
|
+ v-for="option in item.componentProps?.options"
|
|
|
+ :key="option.value"
|
|
|
+ :label="option.label"
|
|
|
+ :value="option.value"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </component>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ <el-form-item label="">
|
|
|
+ <span>{{ `将自动为勾选的${equipCount}台设备添加检验方案` }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ </ElForm>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
<template #footer>
|
|
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
|
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
@@ -43,11 +73,13 @@
|
|
|
import { FormSchema } from '@/types/form'
|
|
|
import { ElForm } from 'element-plus'
|
|
|
import { isFunction } from '@/utils/is'
|
|
|
+import {getPressureReportTemplateListNoLimit} from "@/api/pressure2/reportTemplate";
|
|
|
+import {PressureBoilerCheckTypeMap} from "@/utils/constants";
|
|
|
|
|
|
const emits = defineEmits(['success'])
|
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
|
const title = ref('')
|
|
|
-
|
|
|
+const inspectionPlanType = ref('selfPlan')
|
|
|
const formLoading = ref(false) // 表单的加载中
|
|
|
const formRef = ref<InstanceType<typeof ElForm>>()
|
|
|
const formData = ref<Recordable>({})
|
|
|
@@ -57,6 +89,7 @@ const options = ref<{
|
|
|
value: string
|
|
|
[k:string]: any
|
|
|
}[]>([])
|
|
|
+const currentParams = ref<Record<string, any>>({}) // 保存当前参数,用于标签切换时重新加载
|
|
|
|
|
|
const componentMap = {
|
|
|
Input: 'el-input',
|
|
|
@@ -109,17 +142,65 @@ const getIsHidden = (item: FormSchema) => {
|
|
|
/** 打开弹窗 */
|
|
|
const open = (params: Record<string, any>, titleText: string) => {
|
|
|
title.value = titleText
|
|
|
- options.value = params.options || []
|
|
|
+ currentParams.value = params // 保存参数
|
|
|
+ getInspectionPlanData(params)
|
|
|
+
|
|
|
+ dialogVisible.value = true
|
|
|
+ resetForm()
|
|
|
+}
|
|
|
+
|
|
|
+const getInspectionPlanData = async (params: Record<string, any>) => {
|
|
|
+ // 查询检验方案模板数据
|
|
|
+ const optionsResult = ref<any[]>([])
|
|
|
+ const searchParams = { type: '6',reportType : 600 }
|
|
|
+ const response = await getPressureReportTemplateListNoLimit({...searchParams, pageNo: 1, pageSize: 100, status: 200})
|
|
|
+ optionsResult.value = response?.data?.list || response?.list || response || []
|
|
|
+
|
|
|
+ // 根据 inspectionPlanType 筛选数据
|
|
|
+ let filteredOptions = optionsResult.value
|
|
|
+ if (inspectionPlanType.value === 'commPlan') {
|
|
|
+ // 通用方案:筛选 reportType=900 且 pjType=5 的数据
|
|
|
+ filteredOptions = optionsResult.value.filter(item => item.reportType === 900 && item.pjType === 3)
|
|
|
+ } else if (inspectionPlanType.value === 'selfPlan') {
|
|
|
+ // 自编方案:筛选 reportType=500 且 pjType=3 的数据
|
|
|
+ filteredOptions = optionsResult.value.filter(item => item.reportType === 500 && item.pjType === 5)
|
|
|
+ }
|
|
|
+
|
|
|
+ const equipType = params.taskOrderDetail.orderItems[0]?.typeName;
|
|
|
+ const checkType = PressureBoilerCheckTypeMap[params.taskOrderDetail?.checkType] || '-'
|
|
|
+
|
|
|
+ const newParams = {
|
|
|
+ options: filteredOptions.map(item => ({
|
|
|
+ ...item,
|
|
|
+ label: item.tbName,
|
|
|
+ reportName: equipType + checkType + "-" + item.tbName,
|
|
|
+ value: item.id
|
|
|
+ })),
|
|
|
+ formData: {
|
|
|
+ orderId: params.taskOrderDetail.id,
|
|
|
+ },
|
|
|
+ equipCount: unref(params.selectedEquips).length
|
|
|
+ }
|
|
|
+
|
|
|
+ options.value = newParams.options || []
|
|
|
+
|
|
|
const firstOptionValue = options.value[0]?.value
|
|
|
const reportName = options.value[0]?.reportName
|
|
|
formData.value = {
|
|
|
- ...params.formData,
|
|
|
+ ...newParams.formData,
|
|
|
templateId: firstOptionValue,
|
|
|
reportName: reportName,
|
|
|
+ isSelfType: inspectionPlanType.value === 'selfPlan'
|
|
|
+ }
|
|
|
+ equipCount.value = newParams.equipCount || 0
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// 标签页切换事件
|
|
|
+const handleTabChange = () => {
|
|
|
+ if (currentParams.value && Object.keys(currentParams.value).length > 0) {
|
|
|
+ getInspectionPlanData(currentParams.value)
|
|
|
}
|
|
|
- equipCount.value = params.equipCount || 0
|
|
|
- dialogVisible.value = true
|
|
|
- resetForm()
|
|
|
}
|
|
|
|
|
|
/** 提交表单 */
|