| | |
| | | width="70%" |
| | | @close="closeDia" |
| | | > |
| | | <div style="margin-bottom: 10px;text-align: right"> |
| | | <div v-if="!isViewMode" style="margin-bottom: 10px;text-align: right"> |
| | | <el-button type="danger" plain @click="handleDelete">删除</el-button> |
| | | </div> |
| | | <PIMTable |
| | |
| | | :tableData="tableData" |
| | | :tableLoading="tableLoading" |
| | | :isSelection="true" |
| | | :isShowPagination="false" |
| | | @selection-change="handleSelectionChange" |
| | | height="600" |
| | | height="400" |
| | | > |
| | | <template #slot="{ row }"> |
| | | <el-input v-model="row.testValue" clearable/> |
| | | <template #judgeTypeSlot="{ row }"> |
| | | <el-tag v-if="row.judgeType === '≥'" type="success">≥</el-tag> |
| | | <el-tag v-else-if="row.judgeType === '≤'" type="warning">≤</el-tag> |
| | | <el-tag v-else-if="row.judgeType === '范围'" type="info">范围</el-tag> |
| | | <el-tag v-else>文字</el-tag> |
| | | </template> |
| | | <template #isRequiredSlot="{ row }"> |
| | | <el-tag v-if="row.isRequired === 1" type="danger">是</el-tag> |
| | | <el-tag v-else type="info">否</el-tag> |
| | | </template> |
| | | <template #testValueSlot="{ row }"> |
| | | <el-input v-model="row.testValue" clearable :disabled="isViewMode" @input="handleTestValueChange(row)" /> |
| | | </template> |
| | | <template #isQualifiedSlot="{ row }"> |
| | | <template v-if="row.judgeType !== '文字描述'"> |
| | | <el-tag v-if="row.isQualified === 1" type="success">合格</el-tag> |
| | | <el-tag v-else-if="row.isQualified === 0" type="danger">不合格</el-tag> |
| | | <span v-else>-</span> |
| | | </template> |
| | | <template v-else> |
| | | <el-select v-model="row.isQualified" placeholder="请选择" size="small" :disabled="isViewMode" @change="handleTextResultChange(row)"> |
| | | <el-option :value="1" label="合格" /> |
| | | <el-option :value="0" label="不合格" /> |
| | | </el-select> |
| | | </template> |
| | | </template> |
| | | </PIMTable> |
| | | |
| | | <div style="margin-top: 16px;"> |
| | | <el-form label-width="120px"> |
| | | <el-form-item label="自动判断结果"> |
| | | <template v-if="autoJudgeResult"> |
| | | <el-tag v-if="autoJudgeResult === '合格'" type="success" size="large">合格</el-tag> |
| | | <el-tag v-else-if="autoJudgeResult === '部分合格'" type="warning" size="large">部分合格</el-tag> |
| | | <el-tag v-else type="danger" size="large">不合格</el-tag> |
| | | <span v-if="autoJudgeResult === '不合格'" style="margin-left: 10px; color: #909399;"> |
| | | (必要判断参数有不合格项,不可手动修改) |
| | | </span> |
| | | <span v-if="autoJudgeResult === '部分合格'" style="margin-left: 10px; color: #909399;"> |
| | | (必要判断参数均合格,非必要参数有不合格项,可手动选择最终结果) |
| | | </span> |
| | | </template> |
| | | <template v-else> |
| | | <el-tag type="info" size="large">需手动判断</el-tag> |
| | | <span style="margin-left: 10px; color: #909399;"> |
| | | (所有参数均为文字描述类型,请手动选择) |
| | | </span> |
| | | </template> |
| | | </el-form-item> |
| | | <el-form-item label="最终判定"> |
| | | <el-radio-group v-model="checkResult" :disabled="isViewMode || autoJudgeResult === '不合格'"> |
| | | <el-radio label="合格">合格</el-radio> |
| | | <el-radio label="不合格">不合格</el-radio> |
| | | <el-radio label="部分合格">部分合格</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确认</el-button> |
| | | <el-button @click="closeDia">取消</el-button> |
| | | <template v-if="!isViewMode"> |
| | | <el-button type="primary" @click="submitForm">确认</el-button> |
| | | <el-button @click="closeDia">取消</el-button> |
| | | </template> |
| | | <el-button v-else @click="closeDia">关闭</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref} from "vue"; |
| | | import {Search} from "@element-plus/icons-vue"; |
| | | import { ref, computed, getCurrentInstance } from "vue"; |
| | | import { |
| | | qualityInspectParamDel, |
| | | qualityInspectParamInfo, |
| | | qualityInspectParamUpdate |
| | | } from "@/api/qualityManagement/qualityInspectParam.js"; |
| | | import {ElMessageBox} from "element-plus"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | const { proxy } = getCurrentInstance() |
| | | const emit = defineEmits(['close']) |
| | | |
| | |
| | | const operationType = ref('') |
| | | const currentId = ref('') |
| | | const selectedRows = ref([]); |
| | | const autoJudgeResult = ref(null) |
| | | const checkResult = ref('') |
| | | const isViewMode = computed(() => operationType.value === 'view') |
| | | |
| | | const tableColumn = ref([ |
| | | { |
| | | label: "指标", |
| | | prop: "parameterItem", |
| | | }, |
| | | { |
| | | label: "单位", |
| | | prop: "unit", |
| | | }, |
| | | { |
| | | label: "厂家标准值", |
| | | prop: "standardValue", |
| | | }, |
| | | { |
| | | label: "内控值", |
| | | prop: "controlValue", |
| | | }, |
| | | { |
| | | label: "检验值", |
| | | prop: "testValue", |
| | | dataType: 'slot', |
| | | slot: 'slot', |
| | | }, |
| | | { label: "指标", prop: "parameterItem" }, |
| | | { label: "单位", prop: "unit" }, |
| | | { label: "厂家标准值", prop: "standardValue" }, |
| | | { label: "下限值", prop: "minValue" }, |
| | | { label: "上限值", prop: "maxValue" }, |
| | | { label: "内控值", prop: "controlValue" }, |
| | | { label: "判断类型", prop: "judgeType", dataType: 'slot', slot: 'judgeTypeSlot' }, |
| | | { label: "必要判断", prop: "isRequired", dataType: 'slot', slot: 'isRequiredSlot' }, |
| | | { label: "检验值", prop: "testValue", dataType: 'slot', slot: 'testValueSlot' }, |
| | | { label: "是否合格", prop: "isQualified", dataType: 'slot', slot: 'isQualifiedSlot' }, |
| | | ]); |
| | | const tableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | |
| | | // 打开弹框 |
| | | const openDialog = (type, row) => { |
| | | operationType.value = type; |
| | | dialogFormVisible.value = true; |
| | | if (operationType.value === 'edit') { |
| | | autoJudgeResult.value = null |
| | | checkResult.value = '' |
| | | if (operationType.value === 'edit' || operationType.value === 'view') { |
| | | currentId.value = row.id; |
| | | getList() |
| | | } |
| | |
| | | tableData.value = res.data; |
| | | }) |
| | | } |
| | | // 表格选择数据 |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | // 提交产品表单 |
| | | |
| | | const handleTestValueChange = (row) => { |
| | | if (isViewMode.value) return; |
| | | if (!row.testValue || !row.judgeType || row.judgeType === '文字描述') { |
| | | return; |
| | | } |
| | | const testVal = parseFloat(row.testValue); |
| | | if (isNaN(testVal)) return; |
| | | |
| | | let qualified = false; |
| | | if (row.judgeType === '≥') { |
| | | const stdVal = parseFloat(row.standardValue); |
| | | if (isNaN(stdVal)) return; |
| | | qualified = testVal >= stdVal; |
| | | } else if (row.judgeType === '≤') { |
| | | const stdVal = parseFloat(row.standardValue); |
| | | if (isNaN(stdVal)) return; |
| | | qualified = testVal <= stdVal; |
| | | } else if (row.judgeType === '范围') { |
| | | const minVal = parseFloat(row.minValue); |
| | | const maxVal = parseFloat(row.maxValue); |
| | | if (isNaN(minVal) || isNaN(maxVal)) return; |
| | | qualified = testVal >= minVal && testVal <= maxVal; |
| | | } else { |
| | | return; |
| | | } |
| | | row.isQualified = qualified ? 1 : 0; |
| | | performAutoJudgeAll(); |
| | | }; |
| | | |
| | | const handleTextResultChange = () => { |
| | | performAutoJudgeAll() |
| | | }; |
| | | |
| | | const performAutoJudgeAll = () => { |
| | | if (!tableData.value.length) return; |
| | | const allTextDesc = tableData.value.every(item => item.judgeType === '文字描述'); |
| | | if (allTextDesc) { |
| | | autoJudgeResult.value = null; |
| | | return; |
| | | } |
| | | const requiredParams = tableData.value.filter(item => item.isRequired === 1); |
| | | if (requiredParams.length === 0) { |
| | | autoJudgeResult.value = null; |
| | | return; |
| | | } |
| | | const hasUnqualified = requiredParams.some(item => item.isQualified === 0); |
| | | const allJudged = requiredParams.every(item => item.isQualified === 1 || item.isQualified === 0); |
| | | if (!allJudged) { |
| | | autoJudgeResult.value = null; |
| | | return; |
| | | } |
| | | if (hasUnqualified) { |
| | | autoJudgeResult.value = '不合格'; |
| | | checkResult.value = '不合格'; |
| | | return; |
| | | } |
| | | const nonRequiredUnqualified = tableData.value.filter(item => item.isRequired !== 1 && item.isQualified === 0); |
| | | if (nonRequiredUnqualified.length > 0) { |
| | | autoJudgeResult.value = '部分合格'; |
| | | checkResult.value = '部分合格'; |
| | | } else { |
| | | autoJudgeResult.value = '合格'; |
| | | checkResult.value = '合格'; |
| | | } |
| | | }; |
| | | |
| | | const submitForm = () => { |
| | | performAutoJudgeAll(); |
| | | qualityInspectParamUpdate(tableData.value).then(res => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeDia(); |
| | | }) |
| | | } |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | dialogFormVisible.value = false; |
| | | emit('close') |
| | | }; |
| | | // 删除 |
| | | const handleDelete = () => { |
| | | let ids = []; |
| | | if (selectedRows.value.length > 0) { |
| | |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| | | </style> |