| | |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <el-row class="mb8" v-if="!isViewMode"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAddRow">新增一行</el-button> |
| | | </el-row> |
| | | <PIMTable rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :tableLoading="tableLoading" |
| | | height="400"> |
| | | <template #parameterItemSlot="{ row }"> |
| | | <span v-if="isViewMode">{{ row.parameterItem }}</span> |
| | | <el-input v-else v-model="row.parameterItem" placeholder="请输入" /> |
| | | </template> |
| | | <template #parameterTypeSlot="{ row }"> |
| | | <span v-if="isViewMode">{{ row.parameterType === 1 ? '数字' : row.parameterType === 0 ? '文字' : '' }}</span> |
| | | <el-select v-else v-model="row.parameterType" @change="handleTypeChange(row)"> |
| | | <el-option label="文字" :value="0" /> |
| | | <el-option label="数字" :value="1" /> |
| | | </el-select> |
| | | </template> |
| | | <template #maxValueSlot="{ row }"> |
| | | <span v-if="isViewMode">{{ row.maxValue }}</span> |
| | | <el-input-number v-else v-model="row.maxValue" :controls="false" :disabled="row.parameterType !== 1" style="width: 100%" /> |
| | | </template> |
| | | <template #minValueSlot="{ row }"> |
| | | <span v-if="isViewMode">{{ row.minValue }}</span> |
| | | <el-input-number v-else v-model="row.minValue" :controls="false" :disabled="row.parameterType !== 1" style="width: 100%" /> |
| | | </template> |
| | | <template #unitSlot="{ row }"> |
| | | <span v-if="isViewMode">{{ row.unit }}</span> |
| | | <el-input v-else v-model="row.unit" /> |
| | | </template> |
| | | <template #standardValueSlot="{ row }"> |
| | | <span v-if="isViewMode">{{ row.standardValue }}</span> |
| | | <el-input v-else v-model="row.standardValue" :disabled="row.parameterType !== 0" /> |
| | | </template> |
| | | <template #controlValueSlot="{ row }"> |
| | | <span v-if="isViewMode">{{ row.controlValue }}</span> |
| | | <el-input v-else v-model="row.controlValue" /> |
| | | </template> |
| | | <template #operationSlot="{ row }"> |
| | | <el-button v-if="!isViewMode" type="danger" link @click="removeRow(row)">删除</el-button> |
| | | </template> |
| | | <template #slot="{ row }"> |
| | | <el-input v-model="row.testValue" |
| | | <el-input-number v-if="row.parameterType === 1" |
| | | v-model="row.testValue" |
| | | :controls="false" |
| | | clearable |
| | | :disabled="isViewMode" |
| | | style="width: 100%" /> |
| | | <el-input v-else |
| | | v-model="row.testValue" |
| | | clearable |
| | | :disabled="isViewMode" /> |
| | | </template> |
| | |
| | | computed, |
| | | getCurrentInstance, |
| | | nextTick, |
| | | watch |
| | | } from "vue"; |
| | | import { getOptions } from "@/api/procurementManagement/procurementLedger.js"; |
| | | import { modelList, productTreeList } from "@/api/basicData/product.js"; |
| | |
| | | }); |
| | | const supplierList = ref([]); |
| | | const productOptions = ref([]); |
| | | const tableColumn = ref([ |
| | | { |
| | | label: "指标", |
| | | prop: "parameterItem", |
| | | }, |
| | | { |
| | | label: "单位", |
| | | prop: "unit", |
| | | }, |
| | | { |
| | | label: "标准值", |
| | | prop: "standardValue", |
| | | }, |
| | | { |
| | | label: "内控值", |
| | | prop: "controlValue", |
| | | }, |
| | | { |
| | | label: "检验值", |
| | | prop: "testValue", |
| | | dataType: "slot", |
| | | slot: "slot", |
| | | }, |
| | | ]); |
| | | const tableColumn = computed(() => { |
| | | const cols = [ |
| | | { |
| | | label: "指标", |
| | | prop: "parameterItem", |
| | | dataType: "slot", |
| | | slot: "parameterItemSlot" |
| | | }, |
| | | { |
| | | label: "参数类型", |
| | | prop: "parameterType", |
| | | dataType: "slot", |
| | | slot: "parameterTypeSlot", |
| | | width: "120" |
| | | }, |
| | | { |
| | | label: "最大值", |
| | | prop: "maxValue", |
| | | dataType: "slot", |
| | | slot: "maxValueSlot", |
| | | width: "100" |
| | | }, |
| | | { |
| | | label: "最小值", |
| | | prop: "minValue", |
| | | dataType: "slot", |
| | | slot: "minValueSlot", |
| | | width: "100" |
| | | }, |
| | | { |
| | | label: "单位", |
| | | prop: "unit", |
| | | dataType: "slot", |
| | | slot: "unitSlot", |
| | | width: "100" |
| | | }, |
| | | { |
| | | label: "标准值", |
| | | prop: "standardValue", |
| | | dataType: "slot", |
| | | slot: "standardValueSlot" |
| | | }, |
| | | { |
| | | label: "内控值", |
| | | prop: "controlValue", |
| | | dataType: "slot", |
| | | slot: "controlValueSlot" |
| | | }, |
| | | { |
| | | label: "检验值", |
| | | prop: "testValue", |
| | | dataType: "slot", |
| | | slot: "slot", |
| | | } |
| | | ]; |
| | | if (!isViewMode.value) { |
| | | cols.push({ |
| | | label: "操作", |
| | | prop: "operation", |
| | | dataType: "slot", |
| | | slot: "operationSlot", |
| | | width: "80", |
| | | fixed: "right" |
| | | }); |
| | | } |
| | | return cols; |
| | | }); |
| | | const tableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | const userList = ref([]); |
| | | const currentProductId = ref(0); |
| | | const testStandardOptions = ref([]); // 指标选择下拉框数据 |
| | | const modelOptions = ref([]); |
| | | |
| | | watch(() => tableData.value, (newVal) => { |
| | | if (isViewMode.value) return; |
| | | if (!newVal || newVal.length === 0) return; |
| | | |
| | | let passCount = 0; |
| | | let failCount = 0; |
| | | |
| | | newVal.forEach(item => { |
| | | let isPass = false; |
| | | const val = item.testValue; |
| | | |
| | | if (val === null || val === undefined || val === '') { |
| | | isPass = false; |
| | | } else if (item.parameterType === 1) { |
| | | const numVal = Number(val); |
| | | const min = Number(item.minValue); |
| | | const max = Number(item.maxValue); |
| | | if (!isNaN(numVal) && numVal >= min && numVal <= max) { |
| | | isPass = true; |
| | | } |
| | | } else { |
| | | if (String(val) === String(item.standardValue)) { |
| | | isPass = true; |
| | | } |
| | | } |
| | | |
| | | if (isPass) { |
| | | passCount++; |
| | | } else { |
| | | failCount++; |
| | | } |
| | | }); |
| | | |
| | | if (failCount === 0 && passCount > 0) { |
| | | form.value.checkResult = "合格"; |
| | | } else if (passCount === 0 && failCount > 0) { |
| | | form.value.checkResult = "不合格"; |
| | | } else { |
| | | form.value.checkResult = "部分合格"; |
| | | } |
| | | }, { deep: true }); |
| | | |
| | | // 打开弹框 |
| | | const openDialog = async (type, row) => { |
| | |
| | | ...item, |
| | | id: null, |
| | | })); |
| | | |
| | | if (tableData.value.some(item => item.parameterType === null || item.parameterType === undefined)) { |
| | | proxy.$modal.msgWarning("参数类型未配置,请配置指标维护模板"); |
| | | } |
| | | }) |
| | | .catch(error => { |
| | | console.error("获取标准参数失败:", error); |
| | |
| | | tableData.value = res.data; |
| | | }); |
| | | }; |
| | | |
| | | const handleAddRow = () => { |
| | | tableData.value.push({ |
| | | parameterItem: '', |
| | | parameterType: 0, |
| | | maxValue: undefined, |
| | | minValue: undefined, |
| | | unit: '', |
| | | standardValue: '', |
| | | controlValue: '', |
| | | testValue: '' |
| | | }); |
| | | }; |
| | | |
| | | const removeRow = (row) => { |
| | | const index = tableData.value.indexOf(row); |
| | | if (index !== -1) { |
| | | tableData.value.splice(index, 1); |
| | | } |
| | | }; |
| | | |
| | | const handleTypeChange = (row) => { |
| | | if (row.parameterType === 0) { |
| | | row.maxValue = undefined; |
| | | row.minValue = undefined; |
| | | } else { |
| | | row.standardValue = ''; |
| | | } |
| | | row.testValue = ''; |
| | | }; |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |