From 6b35989783d91899169f89e21a7d3734d8cadc1d Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 04 一月 2026 15:19:54 +0800
Subject: [PATCH] 1.海川开心
---
src/views/qualityManagement/finalInspection/components/formDia.vue | 208 +++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 183 insertions(+), 25 deletions(-)
diff --git a/src/views/qualityManagement/finalInspection/components/formDia.vue b/src/views/qualityManagement/finalInspection/components/formDia.vue
index 3153374..3285750 100644
--- a/src/views/qualityManagement/finalInspection/components/formDia.vue
+++ b/src/views/qualityManagement/finalInspection/components/formDia.vue
@@ -2,8 +2,9 @@
<div>
<el-dialog
v-model="dialogFormVisible"
- :title="operationType === 'add' ? '鏂板鍘熸潗鏂欐楠�' : '缂栬緫鍘熸潗鏂欐楠�'"
+ :title="operationType === 'add' ? '鏂板鍑哄巶妫�楠�' : '缂栬緫鍑哄巶妫�楠�'"
width="70%"
+ draggable
@close="closeDia"
>
<el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
@@ -24,14 +25,17 @@
</el-col>
<el-col :span="12">
<el-form-item label="瑙勬牸鍨嬪彿锛�" prop="model">
- <el-input v-model="form.model" placeholder="璇疯緭鍏�" clearable/>
+ <el-input v-model="form.model" placeholder="璇疯緭鍏�" clearable/>
</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="璇疯緭鍏�" clearable/>
+ <el-select v-model="form.unit" placeholder="璇烽�夋嫨" clearable style="width: 100%">
+ <el-option label="绠�" value="绠�" />
+ <el-option label="鎻�" value="鎻�" />
+ </el-select>
</el-form-item>
</el-col>
<el-col :span="12">
@@ -42,11 +46,6 @@
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="妫�娴嬪崟浣嶏細" prop="checkCompany">
- <el-input v-model="form.checkCompany" placeholder="璇疯緭鍏�" clearable/>
- </el-form-item>
- </el-col>
- <el-col :span="12">
<el-form-item label="妫�娴嬬粨鏋滐細" prop="checkResult">
<el-select v-model="form.checkResult">
<el-option label="鍚堟牸" value="鍚堟牸" />
@@ -54,14 +53,19 @@
</el-select>
</el-form-item>
</el-col>
+ <el-col :span="12">
+ <el-form-item label="妫�楠屽憳锛�" prop="checkName">
+ <el-select v-model="form.checkName"
+ filterable
+ default-first-option
+ :reserve-keyword="false" placeholder="璇烽�夋嫨" clearable>
+ <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName"
+ :value="item.nickName"/>
+ </el-select>
+ </el-form-item>
+ </el-col>
</el-row>
<el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="妫�楠屽憳锛�" prop="checkName">
- <el-input v-model="form.checkName" placeholder="璇疯緭鍏�" clearable/>
-
- </el-form-item>
- </el-col>
<el-col :span="12">
<el-form-item label="妫�娴嬫棩鏈燂細" prop="checkTime">
<el-date-picker
@@ -77,6 +81,17 @@
</el-col>
</el-row>
</el-form>
+ <PIMTable
+ rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :tableLoading="tableLoading"
+ height="400"
+ >
+ <template #slot="{ row }">
+ <el-input v-model="row.testValue" clearable/>
+ </template>
+ </PIMTable>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm">纭</el-button>
@@ -88,12 +103,20 @@
</template>
<script setup>
-import {ref} from "vue";
+import {ref, computed, reactive, toRefs, getCurrentInstance} from "vue";
+import dayjs from "dayjs";
+import useUserStore from "@/store/modules/user.js";
import {getOptions} from "@/api/procurementManagement/procurementLedger.js";
-import {productTreeList} from "@/api/basicData/product.js";
+import {modelList, productTreeList} from "@/api/basicData/product.js";
import {qualityInspectAdd, qualityInspectUpdate} from "@/api/qualityManagement/rawMaterialInspection.js";
+import {userListNoPage} from "@/api/system/user.js";
+import {qualityInspectDetailByProductId} from "@/api/qualityManagement/metricMaintenance.js";
+import {qualityInspectParamInfo} from "@/api/qualityManagement/qualityInspectParam.js";
const { proxy } = getCurrentInstance()
const emit = defineEmits(['close'])
+const userStore = useUserStore()
+const currentUserName = computed(() => userStore.nickName || userStore.name || "")
+const getToday = () => dayjs().format("YYYY-MM-DD")
const dialogFormVisible = ref(false);
const operationType = ref('')
@@ -111,7 +134,7 @@
checkResult: "",
},
rules: {
- checkTime: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" },],
+ checkTime: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" },],
process: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
checkName: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
productId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
@@ -125,26 +148,139 @@
const { form, rules } = toRefs(data);
const supplierList = ref([]);
const productOptions = ref([]);
+const tableColumn = ref([
+ {
+ label: "鎸囨爣",
+ prop: "parameterItem",
+ },
+ {
+ label: "鍗曚綅",
+ prop: "unit",
+ },
+ {
+ label: "鏍囧噯鍊�",
+ prop: "standardValue",
+ },
+ {
+ label: "鍐呮帶鍊�",
+ prop: "controlValue",
+ },
+ {
+ label: "妫�楠屽��",
+ prop: "testValue",
+ dataType: 'slot',
+ slot: 'slot',
+ },
+]);
+const tableData = ref([]);
+const tableLoading = ref(false);
+const userList = ref([]);
+const currentProductId = ref(0);
+const modelOptions = ref([]);
// 鎵撳紑寮规
-const openDialog = (type, row) => {
+const openDialog = async (type, row) => {
operationType.value = type;
dialogFormVisible.value = true;
getOptions().then((res) => {
supplierList.value = res.data;
});
- getProductOptions();
+ let userLists = await userListNoPage();
+ userList.value = userLists.data;
+ form.value = {}
if (operationType.value === 'edit') {
form.value = {...row}
+ currentProductId.value = row.productId || 0
+ // 鍔犺浇褰撳墠浜у搧涓嬬殑瑙勬牸鍒楄〃锛屽苟鏍规嵁鍚庣杩斿洖鐨� model 鍙嶆煡骞惰缃� modelId锛屽疄鐜拌鏍间笅鎷夋鍙嶆樉
+ if (currentProductId.value) {
+ modelList({ id: currentProductId.value }).then((res) => {
+ modelOptions.value = res;
+ const target = res.find((item) => item.model === row.model);
+ if (target) {
+ form.value.modelId = target.id;
+ }
+ });
+ }
+ getQualityInspectParamList(row.id)
+ } else {
+ // 鏂板鏃惰缃粯璁ゅ��
+ form.value.unit = "绠�"; // 鍗曚綅榛樿涓虹
+ form.value.checkResult = "鍚堟牸"; // 妫�楠岀粨鏋滈粯璁や负鍚堟牸
}
+ await getProductOptions();
+ // 榛樿妫�楠屽憳涓哄綋鍓嶇櫥褰曚汉锛屾娴嬫棩鏈熼粯璁や负褰撳ぉ锛堢┖鏃跺~鍏咃級
+ if (currentUserName.value && !form.value.checkName) {
+ form.value.checkName = currentUserName.value;
+ }
+ if (!form.value.checkTime) {
+ form.value.checkTime = getToday();
+ }
}
-const getProductOptions = () => {
- productTreeList().then((res) => {
- productOptions.value = convertIdToValue(res);
- });
+const findNodeByLabel = (nodes, label) => {
+ for (let i = 0; i < nodes.length; i++) {
+ // 鍏堝皾璇曠簿纭尮閰�
+ if (nodes[i].label === label) {
+ return nodes[i].value; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣鐨剉alue
+ }
+ // 濡傛灉绮剧‘鍖归厤澶辫触锛屽皾璇曟ā绯婂尮閰嶏紙鍖呭惈鍏抽敭璇嶏級
+ if (nodes[i].label && nodes[i].label.includes(label)) {
+ return nodes[i].value;
+ }
+ if (nodes[i].children && nodes[i].children.length > 0) {
+ const foundValue = findNodeByLabel(nodes[i].children, label);
+ if (foundValue) {
+ return foundValue; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐圭殑value
+ }
+ }
+ }
+ return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
+};
+
+const getProductOptions = async () => {
+ const res = await productTreeList({productName: '璐ㄩ噺'});
+ productOptions.value = convertIdToValue(res);
+ // 鏂板妯″紡涓嬶紝榛樿閫夋嫨"鎴愬搧妫�楠�"
+ if (operationType.value === 'add') {
+ const finishedProductId = findNodeByLabel(productOptions.value, '鎴愬搧妫�楠�');
+ if (finishedProductId) {
+ form.value.productId = finishedProductId;
+ // 鎵惧埌瀵瑰簲鐨勮妭鐐癸紝浣跨敤瀹為檯鐨� label 浣滀负 productName
+ const findNode = (nodes, value) => {
+ for (let i = 0; i < nodes.length; i++) {
+ if (nodes[i].value === value) {
+ return nodes[i];
+ }
+ if (nodes[i].children && nodes[i].children.length > 0) {
+ const found = findNode(nodes[i].children, value);
+ if (found) return found;
+ }
+ }
+ return null;
+ };
+ const node = findNode(productOptions.value, finishedProductId);
+ form.value.productName = node ? node.label : '鎴愬搧妫�楠�';
+ getModels(finishedProductId);
+ }
+ }
};
const getModels = (value) => {
+ currentProductId.value = value
form.value.productName = findNodeById(productOptions.value, value);
+ modelList({ id: value }).then((res) => {
+ modelOptions.value = res;
+ });
+ if (currentProductId) {
+ getList();
+ }
+};
+const getProductModel = (value) => {
+ const index = modelOptions.value.findIndex((item) => item.id === value);
+ if (index !== -1) {
+ form.value.unit = modelOptions.value[index].unit;
+ form.value.model = modelOptions.value[index].model;
+ } else {
+ form.value.unit = null;
+ }
};
const findNodeById = (nodes, productId) => {
for (let i = 0; i < nodes.length; i++) {
@@ -179,13 +315,19 @@
proxy.$refs.formRef.validate(valid => {
if (valid) {
form.value.inspectType = 2
+ if (operationType.value === "add") {
+ tableData.value.forEach((item) => {
+ delete item.id
+ })
+ }
+ const data = {...form.value, qualityInspectParams: tableData.value}
if (operationType.value === "add") {
- qualityInspectAdd(form.value).then(res => {
+ qualityInspectAdd(data).then(res => {
proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
closeDia();
})
} else {
- qualityInspectUpdate(form.value).then(res => {
+ qualityInspectUpdate(data).then(res => {
proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
closeDia();
})
@@ -193,6 +335,22 @@
}
})
}
+const getList = () => {
+ qualityInspectDetailByProductId(currentProductId.value).then(res => {
+ tableData.value = res.data.map(item => ({
+ ...item,
+ testValue: item.testValue ?? 0
+ }));
+ })
+}
+const getQualityInspectParamList = (id) => {
+ qualityInspectParamInfo(id).then(res => {
+ tableData.value = res.data.map(item => ({
+ ...item,
+ testValue: item.testValue ?? 0
+ }));
+ })
+}
// 鍏抽棴寮规
const closeDia = () => {
proxy.resetForm("formRef");
--
Gitblit v1.9.3