| | |
| | | <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检验模式:"> |
| | | <el-tag :type="inspectModeTag" size="large">{{ inspectModeLabel }}</el-tag> |
| | | <span v-if="showSampleFields && currentInspect" class="mode-tip"> |
| | | (抽检比例: {{ currentInspect.sampleRatio || 0 }}%) |
| | | </span> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测结果:" prop="checkResult"> |
| | | <el-select v-model="form.checkResult" placeholder="请选择检测结果" style="width: 100%" @change="handleCheckResultChange"> |
| | | <el-option label="合格" value="合格" /> |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="指标选择:" prop="testStandardId"> |
| | | <el-select v-model="form.testStandardId" placeholder="请选择指标" style="width: 100%" @change="handleTestStandardChange"> |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="showSampleFields"> |
| | | <el-form-item label="抽检数量:" prop="sampleQuantity"> |
| | | <el-input-number |
| | | :step="1" |
| | | :min="1" |
| | | :max="maxSampleQuantity" |
| | | style="width: 100%" |
| | | v-model="form.sampleQuantity" |
| | | placeholder="请输入抽检数量" |
| | | :precision="0" |
| | | /> |
| | | <span class="tip-text">最大可抽检: {{ maxSampleQuantity }}</span> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <template v-if="form.checkResult"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="数量:" prop="quantity"> |
| | | <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.quantity" placeholder="请输入数量" clearable :precision="2" @change="handleQuantityChange"/> |
| | | <el-form-item label="检验数量:" prop="quantity"> |
| | | <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.quantity" placeholder="请输入数量" clearable :precision="2" @change="handleQuantityChange" :disabled="showSampleFields"/> |
| | | <span v-if="showSampleFields" class="tip-text">抽检模式下检验数量等于抽检数量</span> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="合格数量:" prop="qualifiedQuantity"> |
| | | <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.qualifiedQuantity" placeholder="请输入合格数量" clearable :precision="2" @change="handleQualifiedQuantityChange"/> |
| | | <el-input-number :step="0.01" :min="0" :max="form.quantity" style="width: 100%" v-model="form.qualifiedQuantity" placeholder="请输入合格数量" clearable :precision="2" @change="handleQualifiedQuantityChange"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="不合格数量:" prop="unqualifiedQuantity"> |
| | | <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.unqualifiedQuantity" placeholder="请输入不合格数量" clearable :precision="2" @change="handleUnqualifiedQuantityChange"/> |
| | | <el-input-number :step="0.01" :min="0" :max="form.quantity" style="width: 100%" v-model="form.unqualifiedQuantity" placeholder="请输入不合格数量" clearable :precision="2" @change="handleUnqualifiedQuantityChange"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive, toRefs, getCurrentInstance, nextTick } from "vue"; |
| | | import { ref, reactive, toRefs, getCurrentInstance, nextTick, computed, watch } from "vue"; |
| | | import { userListNoPage } from "@/api/system/user.js"; |
| | | import { batchQuickInspect } from "@/api/qualityManagement/rawMaterialInspection.js"; |
| | | import { qualityInspectDetailByProductId, getQualityTestStandardParamByTestStandardId } from "@/api/qualityManagement/metricMaintenance.js"; |
| | |
| | | const selectedRows = ref([]); |
| | | const testStandardOptions = ref([]); |
| | | const inspectType = ref(1); // 过程检验类型 |
| | | const currentInspect = ref(null); |
| | | |
| | | const data = reactive({ |
| | | form: { |
| | | checkResult: '', |
| | | testStandardId: '', |
| | | quantity: undefined, |
| | | sampleQuantity: undefined, |
| | | qualifiedQuantity: undefined, |
| | | unqualifiedQuantity: undefined, |
| | | checkCompany: '', |
| | |
| | | }); |
| | | const { form, rules } = toRefs(data); |
| | | |
| | | // 检验模式标签 |
| | | const inspectModeLabel = computed(() => { |
| | | if (!currentInspect.value) return '全检'; |
| | | return currentInspect.value.inspectRule === 1 ? '抽检' : '全检'; |
| | | }); |
| | | |
| | | const inspectModeTag = computed(() => { |
| | | if (!currentInspect.value) return 'success'; |
| | | return currentInspect.value.inspectRule === 1 ? 'warning' : 'success'; |
| | | }); |
| | | |
| | | // 是否显示抽检字段 |
| | | const showSampleFields = computed(() => { |
| | | return currentInspect.value && currentInspect.value.inspectRule === 1; |
| | | }); |
| | | |
| | | // 总数量 |
| | | const totalQuantity = computed(() => { |
| | | return currentInspect.value?.quantity || 0; |
| | | }); |
| | | |
| | | // 最大抽检数量 |
| | | const maxSampleQuantity = computed(() => { |
| | | return totalQuantity.value; |
| | | }); |
| | | |
| | | // 默认抽检数量(从检验单获取或按比例计算) |
| | | const defaultSampleQuantity = computed(() => { |
| | | if (!currentInspect.value) return 0; |
| | | if (currentInspect.value.sampleQuantity) { |
| | | return currentInspect.value.sampleQuantity; |
| | | } |
| | | if (currentInspect.value.sampleRatio) { |
| | | return Math.ceil(totalQuantity.value * currentInspect.value.sampleRatio / 100); |
| | | } |
| | | return totalQuantity.value; |
| | | }); |
| | | |
| | | // 监听抽检数量变化 |
| | | watch(() => form.value.sampleQuantity, (val) => { |
| | | if (showSampleFields.value && val) { |
| | | form.value.quantity = val; |
| | | // 更新合格/不合格数量 |
| | | if (form.value.checkResult === '合格') { |
| | | form.value.qualifiedQuantity = val; |
| | | form.value.unqualifiedQuantity = 0; |
| | | } else if (form.value.checkResult === '不合格') { |
| | | form.value.qualifiedQuantity = 0; |
| | | form.value.unqualifiedQuantity = val; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | const tableColumn = ref([ |
| | | { |
| | | label: "指标", |
| | |
| | | prop: "unit", |
| | | }, |
| | | { |
| | | label: "标准值", |
| | | label: "厂家标准值", |
| | | prop: "standardValue", |
| | | }, |
| | | { |
| | |
| | | selectedIds.value = ids; |
| | | selectedRows.value = rows; |
| | | dialogVisible.value = true; |
| | | |
| | | |
| | | // 取第一条检验单的信息作为参考 |
| | | if (rows && rows.length > 0) { |
| | | currentInspect.value = rows[0]; |
| | | } else { |
| | | currentInspect.value = null; |
| | | } |
| | | |
| | | // 加载用户列表 |
| | | const userListsRes = await userListNoPage(); |
| | | userList.value = userListsRes.data; |
| | | |
| | | |
| | | // 加载指标选项(根据第一个选中行的产品ID) |
| | | if (rows && rows.length > 0 && rows[0].productId) { |
| | | const params = { |
| | |
| | | } else { |
| | | testStandardOptions.value = []; |
| | | } |
| | | |
| | | |
| | | // 重置表单 |
| | | const totalQty = currentInspect.value?.quantity || undefined; |
| | | const sampleQty = showSampleFields.value ? defaultSampleQuantity.value : undefined; |
| | | |
| | | form.value = { |
| | | checkResult: '', |
| | | testStandardId: '', |
| | | quantity: undefined, |
| | | quantity: showSampleFields.value ? sampleQty : totalQty, |
| | | sampleQuantity: sampleQty, |
| | | qualifiedQuantity: undefined, |
| | | unqualifiedQuantity: undefined, |
| | | checkCompany: '', |
| | |
| | | checkTime: '', |
| | | }; |
| | | tableData.value = []; |
| | | |
| | | |
| | | await nextTick(); |
| | | proxy.$refs.formRef?.clearValidate(); |
| | | }; |
| | |
| | | |
| | | // 检测结果变化处理 |
| | | const handleCheckResultChange = (value) => { |
| | | const qty = form.value.quantity || 0; |
| | | if (value === '合格') { |
| | | // 合格时,合格数量等于数量,不合格数量为0 |
| | | form.value.qualifiedQuantity = form.value.quantity || 0; |
| | | form.value.qualifiedQuantity = qty; |
| | | form.value.unqualifiedQuantity = 0; |
| | | } else if (value === '不合格') { |
| | | // 不合格时,合格数量为0,不合格数量等于数量 |
| | | form.value.qualifiedQuantity = 0; |
| | | form.value.unqualifiedQuantity = form.value.quantity || 0; |
| | | form.value.unqualifiedQuantity = qty; |
| | | } else if (value === '部分合格') { |
| | | form.value.qualifiedQuantity = undefined; |
| | | form.value.unqualifiedQuantity = undefined; |
| | | } |
| | | }; |
| | | |
| | |
| | | const handleQualifiedQuantityChange = (value) => { |
| | | const quantity = form.value.quantity || 0; |
| | | if (value > quantity) { |
| | | proxy.$modal.msgWarning("合格数量不能大于总数量"); |
| | | proxy.$modal.msgWarning("合格数量不能大于检验数量"); |
| | | form.value.qualifiedQuantity = quantity; |
| | | form.value.unqualifiedQuantity = 0; |
| | | } else { |
| | |
| | | const handleUnqualifiedQuantityChange = (value) => { |
| | | const quantity = form.value.quantity || 0; |
| | | if (value > quantity) { |
| | | proxy.$modal.msgWarning("不合格数量不能大于总数量"); |
| | | proxy.$modal.msgWarning("不合格数量不能大于检验数量"); |
| | | form.value.unqualifiedQuantity = quantity; |
| | | form.value.qualifiedQuantity = 0; |
| | | } else { |
| | |
| | | const qualified = form.value.qualifiedQuantity || 0; |
| | | const unqualified = form.value.unqualifiedQuantity || 0; |
| | | const quantity = form.value.quantity || 0; |
| | | |
| | | |
| | | if (qualified === quantity && unqualified === 0) { |
| | | form.value.checkResult = '合格'; |
| | | } else if (unqualified === quantity && qualified === 0) { |
| | |
| | | const submitForm = () => { |
| | | proxy.$refs.formRef.validate((valid) => { |
| | | if (valid) { |
| | | // 部分合格时校验数量 |
| | | if (form.value.checkResult === '部分合格') { |
| | | const sum = (form.value.qualifiedQuantity || 0) + (form.value.unqualifiedQuantity || 0); |
| | | if (sum > (form.value.quantity || 0)) { |
| | | proxy.$modal.msgWarning('合格数量+不合格数量不能超过检验数量'); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | const data = { |
| | | ids: selectedIds.value, |
| | | inspectType: inspectType.value, |
| | |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .mode-tip { |
| | | margin-left: 10px; |
| | | font-size: 13px; |
| | | color: #909399; |
| | | } |
| | | |
| | | .tip-text { |
| | | display: block; |
| | | font-size: 12px; |
| | | color: #909399; |
| | | margin-top: 4px; |
| | | } |
| | | </style> |