From 4dee4cb5b31a7f1dcd2c7b3d72f74b78d2fe3f29 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 18 九月 2026 15:56:41 +0800
Subject: [PATCH] fix: 质检是否入库
---
src/views/qualityManagement/processInspection/components/formDia.vue | 132 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 115 insertions(+), 17 deletions(-)
diff --git a/src/views/qualityManagement/processInspection/components/formDia.vue b/src/views/qualityManagement/processInspection/components/formDia.vue
index 635360f..722fb93 100644
--- a/src/views/qualityManagement/processInspection/components/formDia.vue
+++ b/src/views/qualityManagement/processInspection/components/formDia.vue
@@ -130,6 +130,48 @@
</el-row>
<el-row :gutter="30">
<el-col :span="12">
+ <el-form-item label="鏄惁鎶芥锛�"
+ prop="isSampling">
+ <el-radio-group v-model="form.isSampling"
+ class="sampling-radio-group"
+ :disabled="isViewMode"
+ @change="handleSamplingChange">
+ <el-radio-button :label="1">鏄�</el-radio-button>
+ <el-radio-button :label="0">鍚�</el-radio-button>
+ </el-radio-group>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12"
+ v-if="form.isSampling === 1">
+ <el-form-item label="鎶芥鏁伴噺锛�"
+ prop="samplingQuantity">
+ <el-input-number :step="0.01"
+ :min="0"
+ style="width: 100%"
+ v-model="form.samplingQuantity"
+ placeholder="璇疯緭鍏�"
+ clearable
+ :precision="2"
+ :disabled="isViewMode" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30"
+ v-if="operationType === 'edit'">
+ <el-col :span="12">
+ <el-form-item label="鏄惁鍏ュ簱锛�"
+ prop="isStockIn">
+ <el-switch v-model="form.isStockIn"
+ :active-value="1"
+ :inactive-value="0"
+ active-text="鏄�"
+ inactive-text="鍚�" />
+ <span class="stock-in-tip">閫夋嫨鈥滄槸鈥濆皢鐢熸垚鍏ュ簱璁板綍鍜屽簱瀛橈紝閫夋嫨鈥滃惁鈥濆彧淇濆瓨璐ㄦ璁板綍</span>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
<el-form-item label="妫�娴嬪崟浣嶏細"
prop="checkCompany">
<el-input v-model="form.checkCompany"
@@ -139,16 +181,8 @@
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="妫�娴嬬粨鏋滐細"
- prop="checkResult">
- <el-select v-model="form.checkResult" :disabled="isViewMode">
- <el-option label="鍚堟牸"
- value="鍚堟牸" />
- <el-option label="涓嶅悎鏍�"
- value="涓嶅悎鏍�" />
- <el-option label="閮ㄥ垎鍚堟牸"
- value="閮ㄥ垎鍚堟牸" />
- </el-select>
+ <el-form-item label="鍚堟牸鐜囷細">
+ <el-tag :type="passRateTagType">{{ passRateDisplayText }}</el-tag>
</el-form-item>
</el-col>
</el-row>
@@ -250,7 +284,9 @@
qualifiedQuantity: "",
unqualifiedQuantity: "",
checkCompany: "",
- checkResult: "",
+ isSampling: 0,
+ samplingQuantity: "",
+ isStockIn: 0,
},
rules: {
checkTime: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
@@ -264,13 +300,45 @@
qualifiedQuantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
unqualifiedQuantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
- checkResult: [{ required: true, message: "璇疯緭鍏�", trigger: "change" }],
+ isSampling: [{ required: true, message: "璇烽�夋嫨鏄惁鎶芥", trigger: "change" }],
+ samplingQuantity: [{ required: true, message: "璇疯緭鍏ユ娊妫�鏁伴噺", trigger: "blur" }],
},
});
const userList = ref([]);
const { form, rules } = toRefs(data);
// 鏄惁涓烘煡鐪嬫ā寮�
const isViewMode = computed(() => operationType.value === 'view');
+
+ const passRateValue = computed(() => {
+ const fromApi = form.value.passRate;
+ if (fromApi != null && fromApi !== '') {
+ const n = Number(fromApi);
+ if (!Number.isNaN(n)) return n;
+ }
+ const qualified = Number(form.value.qualifiedQuantity) || 0;
+ const unqualified = Number(form.value.unqualifiedQuantity) || 0;
+ const total = qualified + unqualified;
+ if (!total || total === 0) return null;
+ return (qualified / total) * 100;
+ });
+
+ const passRateDisplayText = computed(() => {
+ const params = passRateValue.value;
+ if (params == null || params === '') return '鈥�';
+ const n = Number(params);
+ if (Number.isNaN(n)) return '鈥�';
+ return `${n.toFixed(2)}%`;
+ });
+
+ const passRateTagType = computed(() => {
+ const params = passRateValue.value;
+ if (params == null || params === '') return 'info';
+ const n = Number(params);
+ if (Number.isNaN(n)) return 'info';
+ if (n >= 100) return 'success';
+ if (n >= 90) return 'warning';
+ return 'danger';
+ });
// 缂栬緫鏃讹細productMainId 鎴� purchaseLedgerId 浠讳竴鏈夊�煎垯宸ュ簭銆佹暟閲忕疆鐏�
const processQuantityDisabled = computed(() => {
const v = form.value || {};
@@ -338,7 +406,9 @@
unit: "",
quantity: "",
checkCompany: "",
- checkResult: "",
+ isSampling: 0,
+ samplingQuantity: "",
+ isStockIn: 0,
};
testStandardOptions.value = [];
tableData.value = [];
@@ -347,8 +417,10 @@
if (operationType.value === "edit" || operationType.value === "view") {
// 鍏堜繚瀛� testStandardId锛岄伩鍏嶈娓呯┖
const savedTestStandardId = row.testStandardId;
- // 鍏堣缃〃鍗曟暟鎹紝浣嗘殏鏃舵竻绌� testStandardId锛岀瓑閫夐」鍔犺浇瀹屾垚鍚庡啀璁剧疆
- form.value = { ...row, testStandardId: "" };
+ const { passRate, ...rowWithoutPassRate } = row;
+ form.value = { ...rowWithoutPassRate, testStandardId: "" };
+ // 缂栬緫鏃�"鏄惁鍏ュ簱"榛樿鍚︼紝浠呬慨鏀硅川妫�璁板綍
+ form.value.isStockIn = 0;
currentProductId.value = row.productId || 0;
// 鍏抽敭锛氱紪杈戞椂鍔犺浇瑙勬牸鍨嬪彿涓嬫媺閫夐」锛屾墠鑳藉弽鏄� productModelId
if (currentProductId.value) {
@@ -357,7 +429,11 @@
modelOptions.value = res || [];
// 鍚屾鍥炲~ model / unit锛堟湁浜涙帴鍙h繑鍥炵殑 row 閲屽彲鑳芥病甯﹀叏锛�
if (form.value.productModelId) {
- handleChangeModel(form.value.productModelId);
+ const selectedModel = modelOptions.value.find(item => item.id == form.value.productModelId);
+ if (selectedModel) {
+ form.value.model = selectedModel.model || "";
+ form.value.unit = selectedModel.unit || "";
+ }
}
} catch (e) {
console.error("鍔犺浇瑙勬牸鍨嬪彿澶辫触", e);
@@ -369,6 +445,7 @@
// 鍏堝姞杞芥寚鏍囬�夐」
let params = {
productId: currentProductId.value,
+ productModelId: form.value.productModelId || undefined,
inspectType: 1,
process: form.value.process || "",
};
@@ -443,6 +520,8 @@
modelOptions.value.find(item => item.id == value)?.model || "";
form.value.unit =
modelOptions.value.find(item => item.id == value)?.unit || "";
+ // 瑙勬牸鍨嬪彿鍙樺寲鍚庢寜 浜у搧+瑙勬牸鍨嬪彿 閲嶆柊杩囨护鍙�夋寚鏍�
+ getList(value);
};
const handleQualifiedQuantityChange = (value) => {
@@ -537,7 +616,7 @@
}
});
};
- const getList = () => {
+ const getList = (modelId) => {
if (!currentProductId.value) {
testStandardOptions.value = [];
tableData.value = [];
@@ -546,6 +625,7 @@
const processName = form.value.process || "";
let params = {
productId: currentProductId.value,
+ productModelId: modelId ?? form.value.productModelId ?? undefined,
inspectType: 1,
process: processName,
};
@@ -587,6 +667,15 @@
tableData.value = res.data;
});
};
+ // 鏄惁鎶芥鍒囨崲
+ const handleSamplingChange = (value) => {
+ if (value !== 1) {
+ form.value.samplingQuantity = "";
+ nextTick(() => {
+ proxy.$refs?.formRef?.clearValidate?.("samplingQuantity");
+ });
+ }
+ };
// 鍏抽棴寮规
const closeDia = () => {
proxy.resetForm("formRef");
@@ -602,4 +691,13 @@
</script>
<style scoped>
+.sampling-radio-group {
+ height: 32px;
+}
+
+.stock-in-tip {
+ margin-left: 12px;
+ font-size: 12px;
+ color: #909399;
+}
</style>
--
Gitblit v1.9.3