From 8deee9363e7a5d180bd77cdb2db0fa22dbb1702d Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 01 四月 2026 14:59:07 +0800
Subject: [PATCH] fix: 优化库存管理
---
src/views/qualityManagement/finalInspection/components/formDia.vue | 278 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 258 insertions(+), 20 deletions(-)
diff --git a/src/views/qualityManagement/finalInspection/components/formDia.vue b/src/views/qualityManagement/finalInspection/components/formDia.vue
index 5f4c975..6c91846 100644
--- a/src/views/qualityManagement/finalInspection/components/formDia.vue
+++ b/src/views/qualityManagement/finalInspection/components/formDia.vue
@@ -49,16 +49,85 @@
</el-select>
</el-form-item>
</el-col>
- </el-row>
- <el-row :gutter="30">
<el-col :span="12">
<el-form-item label="鍗曚綅锛�" prop="unit">
<el-input v-model="form.unit" placeholder="璇疯緭鍏�" disabled/>
</el-form-item>
</el-col>
+ </el-row>
+ <el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="鏁伴噺锛�" prop="quantity">
+ <el-form-item label="鎵瑰彿锛�" prop="batchNo">
+ <el-input
+ v-model="form.batchNo"
+ placeholder="璇疯緭鍏�"
+ clearable
+ :disabled="operationType === 'edit'"
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="UID鐮侊細" prop="uidNo">
+ <el-input v-model="form.uidNo" placeholder="璇疯緭鍏�" disabled/>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="妫�鍝佹暟閲忥細" prop="inspectedQuantity">
+ <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.inspectedQuantity" placeholder="璇疯緭鍏�" clearable :precision="2"/>
+ </el-form-item>
+ </el-col>
+ <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" :disabled="quantityDisabled"/>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="妫�鍝佹暟閲忥細" prop="inspectedQuantity">
+ <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.inspectedQuantity" placeholder="璇疯緭鍏ワ紝涓嶅ぇ浜庢�绘暟閲�" clearable :precision="2" :disabled="quantityDisabled"/>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="妫�楠岀敤绮夊墏/娑叉儏鍐碉細" prop="inspectMaterialCondition">
+ <el-radio-group v-model="form.inspectMaterialCondition">
+ <el-radio label="妫�楠岀敤绮夊墏鎯呭喌">妫�楠岀敤绮夊墏鎯呭喌</el-radio>
+ <el-radio label="妫�楠岀敤娑插墏鎯呭喌">妫�楠岀敤娑插墏鎯呭喌</el-radio>
+ </el-radio-group>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="鐢熶骇鏃ユ湡锛�" prop="productionDate">
+ <el-date-picker
+ v-model="form.productionDate"
+ type="date"
+ placeholder="璇烽�夋嫨鏃ユ湡"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ clearable
+ style="width: 100%"
+ @change="calculateValidityDate"
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鏈夋晥鏈燂細" prop="validityDate">
+ <el-date-picker
+ v-model="form.validityDate"
+ type="date"
+ placeholder="鑷姩璁$畻鎴栨墜鍔ㄩ�夋嫨"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ clearable
+ style="width: 100%"
+ />
</el-form-item>
</el-col>
</el-row>
@@ -108,9 +177,51 @@
:tableLoading="tableLoading"
height="400"
>
- <template #slot="{ row }">
- <el-input v-model="row.testValue" clearable/>
- </template>
+ <template #instrument="{ row }">
+ <el-select
+ v-model="row.instrument"
+ placeholder="璇烽�夋嫨鎴栬緭鍏�"
+ filterable
+ allow-create
+ default-first-option
+ clearable
+ style="width: 100%"
+ @change="handleInstrumentChange(row)"
+ >
+ <el-option label="鐩祴" value="鐩祴" />
+ <el-option
+ v-for="item in deviceList"
+ :key="item.id"
+ :label="item.deviceName + (item.deviceModel ? ' / ' + item.deviceModel : '')"
+ :value="item.deviceName"
+ />
+ </el-select>
+ </template>
+ <template #deviceStatus="{ row }">
+ <el-select
+ v-model="row.deviceStatus"
+ placeholder="璇烽�夋嫨"
+ default-first-option
+ clearable
+ style="width: 100%"
+ >
+ <el-option label="姝e父" value="姝e父" />
+ <el-option label="鍋滄満" value="鍋滄満" />
+ <el-option label="杩愯" value="杩愯" />
+ <el-option label="缁翠慨" value="缁翠慨" />
+ <el-option label="/" value="/" />
+ </el-select>
+ </template>
+ <template #result="{ row }">
+ <el-input v-model="row.result" placeholder="璇疯緭鍏�" clearable />
+ </template>
+ <template #resultJudgment="{ row }">
+ <el-select v-model="row.resultJudgment" placeholder="璇烽�夋嫨" clearable style="width: 100%">
+ <el-option label="鍚堟牸" value="鍚堟牸" />
+ <el-option label="涓嶅悎鏍�" value="涓嶅悎鏍�" />
+ <el-option label="/" value="/" />
+ </el-select>
+ </template>
</PIMTable>
<template #footer>
<div class="dialog-footer">
@@ -130,11 +241,21 @@
import {userListNoPage} from "@/api/system/user.js";
import {qualityInspectDetailByProductId, getQualityTestStandardParamByTestStandardId} from "@/api/qualityManagement/metricMaintenance.js";
import {qualityInspectParamInfo} from "@/api/qualityManagement/qualityInspectParam.js";
+import {deviceList as qualityInspectParamDeviceList} from "@/api/energyManagement/index.js";
const { proxy } = getCurrentInstance()
const emit = defineEmits(['close'])
const dialogFormVisible = ref(false);
const operationType = ref('')
+
+const validateBatchNo = (rule, value, callback) => {
+ if (value === undefined || value === null || String(value).trim() === '') {
+ callback(new Error('璇疯緭鍏ユ壒鍙�'));
+ return;
+ }
+ callback();
+};
+
const data = reactive({
form: {
checkTime: "",
@@ -146,7 +267,14 @@
model: "",
testStandardId: "",
unit: "",
+ uidNo: "",
+ batchNo: "",
+ inspectedQuantity: "",
quantity: "",
+ inspectedQuantity: "",
+ inspectMaterialCondition: "",
+ productionDate: "",
+ validityDate: "",
checkCompany: "",
checkResult: "",
},
@@ -158,8 +286,29 @@
productModelId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
testStandardId: [{required: false, message: "璇烽�夋嫨鎸囨爣", trigger: "change"}],
unit: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ inspectedQuantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ inspectedQuantity: [
+ { required: true, message: "璇疯緭鍏ユ鍝佹暟閲�", trigger: "blur" },
+ {
+ validator: (rule, value, callback) => {
+ if (value !== '' && value !== null && value !== undefined) {
+ const qty = Number(form.value.quantity);
+ const inspectedQty = Number(value);
+ if (!isNaN(qty) && !isNaN(inspectedQty) && inspectedQty > qty) {
+ callback(new Error("妫�鍝佹暟閲忎笉鑳藉ぇ浜庢�绘暟閲�"));
+ } else {
+ callback();
+ }
+ } else {
+ callback();
+ }
+ },
+ trigger: "blur"
+ }
+ ],
checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ batchNo: [{ required: true, validator: validateBatchNo, trigger: "blur" }],
checkResult: [{ required: true, message: "璇疯緭鍏�", trigger: "change" }],
},
});
@@ -173,26 +322,47 @@
const productOptions = ref([]);
const tableColumn = ref([
{
- label: "鎸囨爣",
+ label: "妫�娴嬮」鐩�",
prop: "parameterItem",
+ width: 150
},
{
- label: "鍗曚綅",
- prop: "unit",
- },
- {
- label: "鏍囧噯鍊�",
+ label: "鏍囧噯瑕佹眰",
prop: "standardValue",
+ width: 180
},
+ {
+ label: "鍗曚綅",
+ prop: "unit",
+ width: 70
+ },
+ {
+ label: "妫�娴嬪櫒鍏�",
+ prop: "instrument",
+ dataType: 'slot',
+ slot: 'instrument',
+ width: 220
+ },
+ {
+ label: "璁惧鐘舵��",
+ prop: "deviceStatus",
+ dataType: 'slot',
+ slot: 'deviceStatus',
+ width: 120
+ },
+ {
+ label: "妫�娴嬬粨鏋�",
+ prop: "result",
+ dataType: 'slot',
+ slot: 'result',
+ width: 150
+ },
{
- label: "鍐呮帶鍊�",
- prop: "controlValue",
- },
- {
- label: "妫�楠屽��",
- prop: "testValue",
+ label: "缁撴灉鍒ゆ柇",
+ prop: "resultJudgment",
dataType: 'slot',
- slot: 'slot',
+ slot: 'resultJudgment',
+ width: 120
},
]);
const tableData = ref([]);
@@ -201,6 +371,7 @@
const currentProductId = ref(0);
const testStandardOptions = ref([]); // 鎸囨爣閫夋嫨涓嬫媺妗嗘暟鎹�
const modelOptions = ref([]);
+const deviceList = ref([]);
// 鎵撳紑寮规
const openDialog = async (type, row) => {
@@ -209,6 +380,8 @@
// 鍏堟竻绌鸿〃鍗曢獙璇佺姸鎬侊紝閬垮厤闂儊
await nextTick();
proxy.$refs.formRef?.clearValidate();
+ // 鍔犺浇璁惧鍙拌处鍒楄〃
+ loadDeviceList();
// 骞惰鍔犺浇鍩虹鏁版嵁
const [userListsRes] = await Promise.all([
@@ -258,6 +431,7 @@
if (selectedModel) {
form.value.model = selectedModel.model || '';
form.value.unit = selectedModel.unit || '';
+ form.value.uidNo = selectedModel.uidNo || '';
}
}
@@ -297,6 +471,8 @@
const getModels = (value) => {
form.value.productModelId = undefined;
form.value.unit = undefined;
+ form.value.uidNo = undefined;
+ form.value.batchNo = "";
modelOptions.value = [];
currentProductId.value = value
form.value.productName = findNodeById(productOptions.value, value);
@@ -311,6 +487,11 @@
const handleChangeModel = (value) => {
form.value.model = modelOptions.value.find(item => item.id == value)?.model || '';
form.value.unit = modelOptions.value.find(item => item.id == value)?.unit || '';
+ form.value.uidNo = modelOptions.value.find(item => item.id == value)?.uidNo || '';
+ // 閫夋嫨瑙勬牸鍨嬪彿鍚庯紝濡傛灉宸叉湁鐢熶骇鏃ユ湡鍒欓噸鏂拌绠楁湁鏁堟湡
+ if (form.value.productionDate) {
+ calculateValidityDate();
+ }
}
const findNodeById = (nodes, productId) => {
@@ -404,9 +585,66 @@
}
const getQualityInspectParamList = (id) => {
qualityInspectParamInfo(id).then(res => {
- tableData.value = res.data;
+ tableData.value = (res.data || []).map(item => ({...item}));
})
}
+
+// 璁$畻鏈夋晥鏈燂紙鐢熶骇鏃ユ湡 + 瑙勬牸鍨嬪彿涓殑鏈夋晥鏈燂級
+const calculateValidityDate = async () => {
+ if (!form.value.productionDate) {
+ form.value.validityDate = '';
+ return;
+ }
+ // 鑾峰彇瑙勬牸鍨嬪彿鐨勬湁鏁堟湡
+ const selectedModel = modelOptions.value.find(item => item.id == form.value.productModelId);
+ if (selectedModel && selectedModel.validityPeriod) {
+ const productionDate = new Date(form.value.productionDate);
+ const validityPeriod = parseFloat(selectedModel.validityPeriod);
+ const validityDate = new Date(productionDate);
+ validityDate.setFullYear(validityDate.getFullYear() + Math.floor(validityPeriod));
+ validityDate.setMonth(validityDate.getMonth() + Math.round((validityPeriod % 1) * 12));
+ form.value.validityDate = validityDate.toISOString().split('T')[0];
+ }
+};
+
+// 鑾峰彇璁惧鍙拌处鍒楄〃
+const loadDeviceList = () => {
+ qualityInspectParamDeviceList().then(res => {
+ deviceList.value = res.data || [];
+ });
+};
+
+// 璁惧鐘舵�侀鑹叉槧灏�
+const getDeviceStatusType = (status) => {
+ const map = {
+ '姝e父': 'success',
+ '杩愯': 'primary',
+ '鍋滄満': 'warning',
+ '缁翠慨': 'danger'
+ };
+ return map[status] || 'info';
+};
+
+// 妫�娴嬪櫒鍏峰彉鍖栨椂锛岃嚜鍔ㄥ~鍏呰澶囩姸鎬�
+const handleInstrumentChange = (row) => {
+ if (row.instrument === '鐩祴') {
+ row.deviceId = null;
+ row.deviceName = '鐩祴';
+ row.deviceStatus = '';
+ return;
+ }
+ const device = deviceList.value.find(d => d.deviceName === row.instrument);
+ if (device) {
+ row.deviceId = device.id;
+ row.deviceName = device.deviceName;
+ row.deviceStatus = device.status || '';
+ } else {
+ row.deviceId = null;
+ row.deviceName = row.instrument || '';
+ row.deviceStatus = '';
+ }
+};
+
// 鍏抽棴寮规
const closeDia = () => {
proxy.resetForm("formRef");
--
Gitblit v1.9.3