From 4d5c966e9ce603a6f920a889766eeb3f227b2199 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 25 三月 2026 14:30:03 +0800
Subject: [PATCH] fix: 检测化验提交后可以再编辑,还可以查看检验详情
---
src/views/qualityManagement/rawMaterial/components/formDia.vue | 229 +++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 175 insertions(+), 54 deletions(-)
diff --git a/src/views/qualityManagement/rawMaterial/components/formDia.vue b/src/views/qualityManagement/rawMaterial/components/formDia.vue
index 868ef66..fdbc95c 100644
--- a/src/views/qualityManagement/rawMaterial/components/formDia.vue
+++ b/src/views/qualityManagement/rawMaterial/components/formDia.vue
@@ -2,11 +2,18 @@
<div>
<el-dialog
v-model="dialogFormVisible"
- :title="operationType === 'add' ? '鏂板鍘熸枡' : '缂栬緫鍘熸枡'"
+ :title="operationType === 'add' ? '鏂板鍘熸枡' : operationType === 'view' ? '鍘熸枡璇︽儏' : '缂栬緫鍘熸枡'"
width="70%"
@close="closeDia"
>
- <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
+ <el-form
+ v-if="operationType !== 'view'"
+ :model="form"
+ label-width="140px"
+ label-position="top"
+ :rules="rules"
+ ref="formRef"
+ >
<el-row :gutter="30">
<el-col :span="12">
<el-form-item label="浜у搧鍚嶇О锛�" prop="productId">
@@ -18,18 +25,17 @@
@change="getModels"
:data="productOptions"
:render-after-expand="false"
- :disabled="operationType === 'edit'"
+ :disabled="operationType === 'edit' || operationType === 'view'"
style="width: 100%"
/>
</el-form-item>
</el-col>
- </el-row>
- <el-row :gutter="30">
<el-col :span="12">
<el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
- <el-select v-model="form.productModelId" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'edit'"
+ <el-select v-model="form.productModelId" placeholder="璇烽�夋嫨" clearable
+ :disabled="operationType === 'edit' || operationType === 'view'"
filterable readonly @change="handleChangeModel">
- <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id" />
+ <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id"/>
</el-select>
</el-form-item>
</el-col>
@@ -42,14 +48,20 @@
</el-col>
<el-col :span="12">
<el-form-item label="鎵瑰彿锛�" prop="batchNo">
- <el-input style="width: 100%" v-model="form.batchNo" placeholder="璇疯緭鍏�" clearable/>
+ <el-input
+ style="width: 100%"
+ v-model="form.batchNo"
+ placeholder="璇疯緭鍏�"
+ clearable
+ :disabled="operationType === 'view'"
+ />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="30">
<el-col :span="12">
<el-form-item label="妫�楠岀被鍨嬶細" prop="checkType">
- <el-select v-model="form.checkType">
+ <el-select v-model="form.checkType" :disabled="operationType === 'view'">
<el-option label="鍏ュ巶妫�" :value="0"/>
<el-option label="杞﹂棿妫�" :value="1"/>
<el-option label="鍑哄巶妫�" :value="2"/>
@@ -58,7 +70,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="妫�娴嬬粨鏋滐細" prop="checkResult">
- <el-select v-model="form.checkResult">
+ <el-select v-model="form.checkResult" :disabled="operationType === 'view'">
<el-option label="鍚堟牸" :value="1"/>
<el-option label="涓嶅悎鏍�" :value="0"/>
</el-select>
@@ -67,8 +79,15 @@
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="妫�楠屽憳锛�" prop="checkName">
- <el-select v-model="form.checkName" placeholder="璇烽�夋嫨" clearable filterable style="width: 100%">
+ <el-form-item label="妫�楠屽憳锛�" prop="checkUserName">
+ <el-select
+ v-model="form.checkUserName"
+ placeholder="璇烽�夋嫨"
+ clearable
+ filterable
+ style="width: 100%"
+ :disabled="operationType === 'view'"
+ >
<el-option v-for="item in userList" :key="item.nickName" :label="item.nickName"
:value="item.nickName"/>
</el-select>
@@ -85,44 +104,71 @@
format="YYYY-MM-DD"
clearable
style="width: 100%"
+ :disabled="operationType === 'view'"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
+ <el-descriptions
+ v-else
+ :column="2"
+ border
+ size="small"
+ style="margin-bottom: 12px;"
+ >
+ <el-descriptions-item label="浜у搧鍚嶇О">{{ viewProductName }}</el-descriptions-item>
+ <el-descriptions-item label="瑙勬牸鍨嬪彿">{{ viewProductModel }}</el-descriptions-item>
+ <el-descriptions-item label="鍗曚綅">{{ form.unit || '-' }}</el-descriptions-item>
+ <el-descriptions-item label="鎵瑰彿">{{ form.batchNo || '-' }}</el-descriptions-item>
+ <el-descriptions-item label="妫�楠岀被鍨�">{{ viewCheckType }}</el-descriptions-item>
+ <el-descriptions-item label="妫�娴嬬粨鏋�">{{ viewCheckResult }}</el-descriptions-item>
+ <el-descriptions-item label="妫�楠屽憳">{{ form.checkUserName || '-' }}</el-descriptions-item>
+ <el-descriptions-item label="妫�娴嬫棩鏈�">{{ form.checkTime || '-' }}</el-descriptions-item>
+ </el-descriptions>
<div style="margin-bottom: 10px">
- <el-button type="primary" @click="isShowItems = true">娣诲姞妫�娴嬮」鐩�</el-button>
+ <el-button
+ v-if="operationType !== 'view'"
+ type="primary"
+ @click="isShowItems = true"
+ >娣诲姞妫�娴嬮」鐩�</el-button>
</div>
<PIMTable
rowKey="id"
:column="tableColumn"
:tableData="tableData"
:tableLoading="tableLoading"
+ :is-show-pagination="false"
height="400"
>
<template #slot="{ row }">
- <el-input v-model="row.testValue" clearable/>
+ <span v-if="operationType === 'view'">{{ row.testValue }}</span>
+ <el-input
+ v-else
+ v-model="row.testValue"
+ clearable
+ />
</template>
</PIMTable>
<template #footer>
<div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeDia">鍙栨秷</el-button>
+ <el-button v-if="operationType !== 'view'" type="primary" @click="submitForm">纭</el-button>
+ <el-button @click="closeDia">{{ operationType === 'view' ? '鍏抽棴' : '鍙栨秷' }}</el-button>
</div>
</template>
</el-dialog>
- <item-select v-model="isShowItems" @confirm="handleItemSelect" />
+ <item-select v-model="isShowItems" @confirm="handleItemSelect"/>
</div>
</template>
<script setup>
-import {ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
+import {ref, reactive, toRefs, getCurrentInstance, nextTick, computed} from "vue";
import {modelList, productTreeList} from "@/api/basicData/product.js";
import {qualityInspectParamInfo} from "@/api/qualityManagement/qualityInspectParam.js";
import {qualityInspectDetailByProductId} from "@/api/qualityManagement/metricMaintenance.js";
import {userListNoPage} from "@/api/system/user.js";
-import {createRawMaterial, updateRawMaterial} from "@/api/qualityManagement/rawMaterial.js";
+import {createRawMaterial, findRawMaterialDetail, updateRawMaterial} from "@/api/qualityManagement/rawMaterial.js";
import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
const {proxy} = getCurrentInstance()
@@ -136,34 +182,30 @@
form: {
checkTime: "",
supplier: "",
- checkName: "",
productName: "",
productId: "",
productModelId: "",
model: "",
batchNo: "",
- unit: "",
- quantity: "",
- checkCompany: "",
+ checkType: undefined,
checkResult: "",
+ unit: "",
+ checkUserName: "",
},
rules: {
checkTime: [{required: true, message: "璇疯緭鍏�", trigger: "blur"},],
- supplier: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
- checkName: [{required: false, message: "璇疯緭鍏�", trigger: "blur"}],
+ checkUserName: [{required: false, message: "璇烽�夋嫨妫�楠屽憳", trigger: "blur"}],
productId: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
productModelId: [{required: true, message: "璇烽�夋嫨浜у搧鍨嬪彿", trigger: "change"}],
- batchNo: [{required: false, message: "璇疯緭鍏ユ壒娆�", trigger: "blur"}],
- unit: [{required: false, message: "璇疯緭鍏�", trigger: "blur"}],
- quantity: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
- checkCompany: [{required: false, message: "璇疯緭鍏�", trigger: "blur"}],
+ batchNo: [{required: true, message: "璇疯緭鍏ユ壒娆�", trigger: "blur"}],
+ checkType: [{required: true, message: "璇烽�夋嫨妫�楠岀被鍨�", trigger: "change"}],
checkResult: [{required: true, message: "璇烽�夋嫨妫�娴嬬粨鏋�", trigger: "change"}],
},
});
const tableColumn = ref([
{
- label: "鎸囨爣",
- prop: "parameterItem",
+ label: "妫�娴嬮」鐩�",
+ prop: "name",
},
{
label: "鍗曚綅",
@@ -175,7 +217,7 @@
},
{
label: "鍐呮帶鍊�",
- prop: "controlValue",
+ prop: "internalControl",
},
{
label: "鍖栭獙鍊�",
@@ -183,6 +225,21 @@
dataType: 'slot',
slot: 'slot',
},
+ {
+ dataType: 'action',
+ label: '鎿嶄綔',
+ align: 'center',
+ fixed: 'right',
+ width: 140,
+ operation: [
+ {
+ name: '鍒犻櫎',
+ type: 'text',
+ clickFun: (row) => handleDelete(row.id),
+ disabled: () => operationType.value === 'view',
+ }
+ ]
+ }
]);
const tableData = ref([]);
const tableLoading = ref(false);
@@ -191,8 +248,15 @@
const userList = ref([]);
const productOptions = ref([]);
const currentProductId = ref(0);
-const testStandardOptions = ref([]); // 鎸囨爣閫夋嫨涓嬫媺妗嗘暟鎹�
const modelOptions = ref([]);
+
+const getTodayStr = () => {
+ const now = new Date();
+ const y = now.getFullYear();
+ const m = String(now.getMonth() + 1).padStart(2, "0");
+ const d = String(now.getDate()).padStart(2, "0");
+ return `${y}-${m}-${d}`;
+};
// 鎵撳紑寮规
const openDialog = async (type, row) => {
@@ -201,31 +265,29 @@
userList.value = res.data || [];
})
// 鍏堥噸缃〃鍗曟暟鎹紙淇濇寔瀛楁瀹屾暣锛岄伩鍏嶅脊绐楅娆℃覆鏌撴椂瑙﹀彂蹇呭~绾㈡鈥滈棯涓�涓嬧�濓級
- form.value = {
- checkTime: "",
+ form.value = {
+ checkTime: getTodayStr(),
supplier: "",
- checkName: "",
productName: "",
productId: "",
productModelId: "",
model: "",
batchNo: "",
- unit: "",
- quantity: "",
- checkCompany: "",
+ checkType: "",
checkResult: "",
+ unit: "",
+ checkUserName: "",
}
- testStandardOptions.value = [];
tableData.value = [];
// 鍏堢‘淇濅骇鍝佹爲宸插姞杞斤紝鍚﹀垯缂栬緫鏃朵骇鍝�/瑙勬牸鍨嬪彿鏃犳硶鍙嶆樉
await getProductOptions();
if (operationType.value === 'edit') {
- form.value = {...row}
+ await fetchData(row.id);
currentProductId.value = row.productId || 0
// 鍏抽敭锛氱紪杈戞椂鍔犺浇瑙勬牸鍨嬪彿涓嬫媺閫夐」锛屾墠鑳藉弽鏄� productModelId
if (currentProductId.value) {
try {
- const res = await modelList({ id: currentProductId.value });
+ const res = await modelList({id: currentProductId.value});
modelOptions.value = res || [];
// 鍚屾鍥炲~ model / unit锛堟湁浜涙帴鍙h繑鍥炵殑 row 閲屽彲鑳芥病甯﹀叏锛�
if (form.value.productModelId) {
@@ -239,6 +301,27 @@
// 缂栬緫妯″紡涓嬶紝鍏堝姞杞芥寚鏍囬�夐」锛岀劧鍚庡姞杞藉弬鏁板垪琛�
if (currentProductId.value) {
+ } else {
+ getQualityInspectParamList(row.id);
+ }
+ }
+ if (operationType.value === 'view') {
+ await fetchData(row.id);
+ currentProductId.value = row.productId || 0
+ if (currentProductId.value) {
+ try {
+ const res = await modelList({id: currentProductId.value});
+ modelOptions.value = res || [];
+ if (form.value.productModelId) {
+ handleChangeModel(form.value.productModelId);
+ }
+ } catch (e) {
+ console.error("鍔犺浇瑙勬牸鍨嬪彿澶辫触", e);
+ modelOptions.value = [];
+ }
+ }
+ if (currentProductId.value) {
+ // 鍔犺浇鍙傛暟鍒楄〃锛屼繚璇佲�滆鎯呪�濅篃鑳藉睍绀哄寲楠屽��/鏍囧噯鍊肩瓑
} else {
getQualityInspectParamList(row.id);
}
@@ -261,7 +344,7 @@
modelOptions.value = [];
currentProductId.value = value
form.value.productName = findNodeById(productOptions.value, value);
- modelList({ id: value }).then((res) => {
+ modelList({id: value}).then((res) => {
modelOptions.value = res;
})
if (currentProductId.value) {
@@ -270,6 +353,8 @@
};
const handleItemSelect = (value) => {
+ // 杩囨护宸插瓨鍦ㄧ殑鎸囨爣
+ value = value.filter(item => !tableData.value.some(existingItem => existingItem.id === item.id));
tableData.value.push(...value)
}
@@ -280,7 +365,7 @@
const findNodeById = (nodes, productId) => {
for (let i = 0; i < nodes.length; i++) {
- if (nodes[i].value === productId) {
+ if (String(nodes[i].value) === String(productId)) {
return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣
}
if (nodes[i].children && nodes[i].children.length > 0) {
@@ -292,6 +377,34 @@
}
return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
};
+
+// 璇︽儏妯″紡灞曠ず瀛楁锛堜笉浣跨敤琛ㄥ崟鎺т欢锛�
+const viewProductName = computed(() => {
+ const id = form.value?.productId
+ const label = id ? findNodeById(productOptions.value || [], id) : null
+ return label || id || '-'
+})
+
+const viewProductModel = computed(() => {
+ const modelId = form.value?.productModelId
+ const matched = (modelOptions.value || []).find((x) => String(x.id) === String(modelId))
+ return matched?.model || modelId || '-'
+})
+
+const viewCheckType = computed(() => {
+ const t = form.value?.checkType
+ if (t === 0 || t === '0') return '鍏ュ巶妫�'
+ if (t === 1 || t === '1') return '杞﹂棿妫�'
+ if (t === 2 || t === '2') return '鍑哄巶妫�'
+ return '-'
+})
+
+const viewCheckResult = computed(() => {
+ const r = form.value?.checkResult
+ if (r === 1 || r === '1') return '鍚堟牸'
+ if (r === 0 || r === '0') return '涓嶅悎鏍�'
+ return '-'
+})
function convertIdToValue(data) {
return data.map((item) => {
@@ -310,15 +423,10 @@
// 鎻愪氦浜у搧琛ㄥ崟
const submitForm = () => {
+ if (operationType.value === 'view') return;
proxy.$refs.formRef.validate(valid => {
if (valid) {
- form.value.inspectType = 0
- if (operationType.value === "add") {
- tableData.value.forEach((item) => {
- delete item.id
- })
- }
- const data = {...form.value, qualityInspectParams: tableData.value}
+ const data = {...form.value, qualityInspectItem: tableData.value}
if (operationType.value === "add") {
createRawMaterial(data).then(res => {
proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
@@ -336,7 +444,6 @@
const getList = () => {
if (!currentProductId.value) {
- testStandardOptions.value = [];
tableData.value = [];
return;
}
@@ -358,10 +465,24 @@
const closeDia = () => {
proxy.resetForm("formRef");
tableData.value = [];
- testStandardOptions.value = [];
dialogFormVisible.value = false;
emit('close')
};
+
+const handleDelete = (id) => {
+ if (operationType.value === 'view') return;
+ tableData.value = tableData.value.filter(item => item.id !== id);
+}
+
+const fetchData = (id) => {
+ tableLoading.value = true;
+ findRawMaterialDetail(id).then(res => {
+ form.value = res.data;
+ tableData.value = res.data.qualityInspectItem;
+ }).finally(() => {
+ tableLoading.value = false;
+ })
+}
defineExpose({
openDialog,
});
@@ -369,4 +490,4 @@
<style scoped>
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.3