From 77f82fbb8542b59de772164aa2c317b5729f6946 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 25 六月 2026 15:44:08 +0800
Subject: [PATCH] feat(components,qualityManagement): 新增PIMTreeSelect通用组件并优化质检管理模块代码
---
src/views/qualityManagement/processInspection/components/formDia.vue | 28
src/views/qualityManagement/nonconformingManagement/components/formDia.vue | 486 ++++---
src/components/PIMTreeSelect/index.vue | 84 +
src/views/qualityManagement/finalInspection/components/formDia.vue | 859 ++++++++------
src/views/qualityManagement/rawMaterialInspection/components/formDia.vue | 950 +++++++++-------
src/views/qualityManagement/metricBinding/index.vue | 979 ++++++++--------
6 files changed, 1,854 insertions(+), 1,532 deletions(-)
diff --git a/src/components/PIMTreeSelect/index.vue b/src/components/PIMTreeSelect/index.vue
new file mode 100644
index 0000000..094a941
--- /dev/null
+++ b/src/components/PIMTreeSelect/index.vue
@@ -0,0 +1,84 @@
+<template>
+ <el-tree-select
+ v-model="innerValue"
+ :data="data"
+ :multiple="multiple"
+ :filterable="filterable"
+ :collapse-tags="collapseTags"
+ :collapse-tags-tooltip="collapseTagsTooltip"
+ :placeholder="placeholder"
+ :clearable="clearable"
+ :check-strictly="checkStrictly"
+ :render-after-expand="renderAfterExpand"
+ :disabled="disabled"
+ v-bind="$attrs"
+ @change="handleChange"
+ />
+</template>
+
+<script setup>
+ import { computed } from "vue";
+
+ const props = defineProps({
+ modelValue: {
+ type: [String, Number, Array, Object],
+ default: undefined,
+ },
+ data: {
+ type: Array,
+ default: () => [],
+ },
+ multiple: {
+ type: Boolean,
+ default: false,
+ },
+ filterable: {
+ type: Boolean,
+ default: true,
+ },
+ collapseTags: {
+ type: Boolean,
+ default: false,
+ },
+ collapseTagsTooltip: {
+ type: Boolean,
+ default: false,
+ },
+ placeholder: {
+ type: String,
+ default: "璇烽�夋嫨",
+ },
+ clearable: {
+ type: Boolean,
+ default: true,
+ },
+ checkStrictly: {
+ type: Boolean,
+ default: true,
+ },
+ renderAfterExpand: {
+ type: Boolean,
+ default: false,
+ },
+ disabled: {
+ type: Boolean,
+ default: false,
+ },
+ });
+
+ const emit = defineEmits(["update:modelValue", "change"]);
+
+ const innerValue = computed({
+ get() {
+ return props.modelValue;
+ },
+ set(val) {
+ emit("update:modelValue", val);
+ },
+ });
+
+ const handleChange = val => {
+ emit("change", val);
+ };
+</script>
+
diff --git a/src/views/qualityManagement/finalInspection/components/formDia.vue b/src/views/qualityManagement/finalInspection/components/formDia.vue
index 10bfad9..94801ff 100644
--- a/src/views/qualityManagement/finalInspection/components/formDia.vue
+++ b/src/views/qualityManagement/finalInspection/components/formDia.vue
@@ -1,67 +1,86 @@
<template>
<div>
- <el-dialog
- v-model="dialogFormVisible"
- :title="operationType === 'add' ? '鏂板鍑哄巶妫�楠�' : operationType === 'view' ? '鏌ョ湅鍑哄巶妫�楠�' : '缂栬緫鍑哄巶妫�楠�'"
- width="70%"
- @close="closeDia"
- >
- <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
+ <el-dialog v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板鍑哄巶妫�楠�' : operationType === 'view' ? '鏌ョ湅鍑哄巶妫�楠�' : '缂栬緫鍑哄巶妫�楠�'"
+ width="70%"
+ @close="closeDia">
+ <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="浜у搧鍚嶇О锛�" prop="productId">
- <el-tree-select
- v-model="form.productId"
- placeholder="璇烽�夋嫨"
- clearable
- check-strictly
- @change="getModels"
- :data="productOptions"
- :render-after-expand="false"
- :disabled="isViewMode || operationType === 'edit'"
- style="width: 100%"
- />
+ <el-form-item label="浜у搧鍚嶇О锛�"
+ prop="productId">
+ <el-tree-select v-model="form.productId"
+ placeholder="璇烽�夋嫨"
+ filterable
+ clearable
+ check-strictly
+ @change="getModels"
+ :data="productOptions"
+ :render-after-expand="false"
+ :disabled="isViewMode || operationType === 'edit'"
+ style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
- <el-select v-model="form.productModelId" placeholder="璇烽�夋嫨" clearable :disabled="isViewMode || operationType === 'edit'"
- filterable readonly @change="handleChangeModel">
- <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id" />
+ <el-form-item label="瑙勬牸鍨嬪彿锛�"
+ prop="productModelId">
+ <el-select v-model="form.productModelId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ :disabled="isViewMode || operationType === 'edit'"
+ filterable
+ readonly
+ @change="handleChangeModel">
+ <el-option v-for="item in modelOptions"
+ :key="item.id"
+ :label="item.model"
+ :value="item.id" />
</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="璇烽�夋嫨鎸囨爣"
- clearable
- @change="handleTestStandardChange"
- style="width: 100%"
- :disabled="isViewMode"
- >
- <el-option
- v-for="item in testStandardOptions"
- :key="item.id"
- :label="item.standardName || item.standardNo"
- :value="item.id"
- />
+ <el-form-item label="鎸囨爣閫夋嫨锛�"
+ prop="testStandardId">
+ <el-select v-model="form.testStandardId"
+ placeholder="璇烽�夋嫨鎸囨爣"
+ clearable
+ @change="handleTestStandardChange"
+ style="width: 100%"
+ :disabled="isViewMode">
+ <el-option v-for="item in testStandardOptions"
+ :key="item.id"
+ :label="item.standardName || item.standardNo"
+ :value="item.id" />
</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 label="鍗曚綅锛�"
+ prop="unit">
+ <el-input v-model="form.unit"
+ placeholder="璇疯緭鍏�"
+ disabled />
</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="isViewMode || processQuantityDisabled"/>
+ <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="isViewMode || processQuantityDisabled" />
</el-form-item>
</el-col>
</el-row>
@@ -97,63 +116,79 @@
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="妫�娴嬪崟浣嶏細" prop="checkCompany">
- <el-input v-model="form.checkCompany" placeholder="璇疯緭鍏�" clearable :disabled="isViewMode"/>
+ <el-form-item label="妫�娴嬪崟浣嶏細"
+ prop="checkCompany">
+ <el-input v-model="form.checkCompany"
+ placeholder="璇疯緭鍏�"
+ clearable
+ :disabled="isViewMode" />
</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-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>
</el-col>
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="妫�楠屽憳锛�" prop="checkName">
- <el-select v-model="form.checkName" placeholder="璇烽�夋嫨" clearable :disabled="isViewMode">
- <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName"
- :value="item.nickName"/>
+ <el-form-item label="妫�楠屽憳锛�"
+ prop="checkName">
+ <el-select v-model="form.checkName"
+ placeholder="璇烽�夋嫨"
+ clearable
+ :disabled="isViewMode">
+ <el-option v-for="item in userList"
+ :key="item.nickName"
+ :label="item.nickName"
+ :value="item.nickName" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="妫�娴嬫棩鏈燂細" prop="checkTime">
- <el-date-picker
- v-model="form.checkTime"
- type="date"
- placeholder="璇烽�夋嫨鏃ユ湡"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- clearable
- style="width: 100%"
- :disabled="isViewMode"
- />
+ <el-form-item label="妫�娴嬫棩鏈燂細"
+ prop="checkTime">
+ <el-date-picker v-model="form.checkTime"
+ type="date"
+ placeholder="璇烽�夋嫨鏃ユ湡"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ clearable
+ style="width: 100%"
+ :disabled="isViewMode" />
</el-form-item>
</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 :disabled="isViewMode"/>
- </template>
- </PIMTable>
+ <PIMTable rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :tableLoading="tableLoading"
+ height="400">
+ <template #slot="{ row }">
+ <el-input v-model="row.testValue"
+ clearable
+ :disabled="isViewMode" />
+ </template>
+ </PIMTable>
<template #footer>
<div class="dialog-footer">
<template v-if="!isViewMode">
- <el-button type="primary" @click="submitForm">纭</el-button>
+ <el-button type="primary"
+ @click="submitForm">纭</el-button>
<el-button @click="closeDia">鍙栨秷</el-button>
</template>
- <el-button v-else @click="closeDia">鍏抽棴</el-button>
+ <el-button v-else
+ @click="closeDia">鍏抽棴</el-button>
</div>
</template>
</el-dialog>
@@ -161,336 +196,370 @@
</template>
<script setup>
-import {ref, reactive, toRefs, computed, getCurrentInstance, nextTick} from "vue";
-import {getOptions} from "@/api/procurementManagement/procurementLedger.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, getQualityTestStandardParamByTestStandardId} from "@/api/qualityManagement/metricMaintenance.js";
-import {qualityInspectParamInfo} from "@/api/qualityManagement/qualityInspectParam.js";
-const { proxy } = getCurrentInstance()
-const emit = defineEmits(['close'])
+ import {
+ ref,
+ reactive,
+ toRefs,
+ computed,
+ getCurrentInstance,
+ nextTick,
+ } from "vue";
+ import { getOptions } from "@/api/procurementManagement/procurementLedger.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,
+ getQualityTestStandardParamByTestStandardId,
+ } from "@/api/qualityManagement/metricMaintenance.js";
+ import { qualityInspectParamInfo } from "@/api/qualityManagement/qualityInspectParam.js";
+ const { proxy } = getCurrentInstance();
+ const emit = defineEmits(["close"]);
-const dialogFormVisible = ref(false);
-const operationType = ref("");
-const data = reactive({
- form: {
- checkTime: "",
- process: "",
- checkName: "",
- productName: "",
- productId: "",
- productModelId: "",
- model: "",
- testStandardId: "",
- unit: "",
- quantity: "",
- qualifiedQuantity: "",
- unqualifiedQuantity: "",
- checkCompany: "",
- checkResult: "",
- },
- rules: {
- checkTime: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- process: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- checkName: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
- productId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- productModelId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- testStandardId: [{ required: false, message: "璇烽�夋嫨鎸囨爣", trigger: "change" }],
- unit: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
- quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- qualifiedQuantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- unqualifiedQuantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
- checkResult: [{ required: true, message: "璇疯緭鍏�", trigger: "change" }],
- },
-});
-const { form, rules } = toRefs(data);
-// 鏄惁涓烘煡鐪嬫ā寮�
-const isViewMode = computed(() => operationType.value === 'view');
-// 缂栬緫鏃讹細productMainId 鎴� purchaseLedgerId 浠讳竴鏈夊�煎垯宸ュ簭銆佹暟閲忕疆鐏�
-const processQuantityDisabled = computed(() => {
- const v = form.value || {};
- return !!(v.productMainId != null || v.purchaseLedgerId != null);
-});
-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 testStandardOptions = ref([]); // 鎸囨爣閫夋嫨涓嬫媺妗嗘暟鎹�
-const modelOptions = ref([]);
-
-// 鎵撳紑寮规
-const openDialog = async (type, row) => {
- operationType.value = type;
- dialogFormVisible.value = true;
- // 鍏堟竻绌鸿〃鍗曢獙璇佺姸鎬侊紝閬垮厤闂儊
- await nextTick();
- proxy.$refs.formRef?.clearValidate();
-
- // 骞惰鍔犺浇鍩虹鏁版嵁
- const [userListsRes] = await Promise.all([
- userListNoPage(),
- getProductOptions(),
- getOptions().then((res) => {
- supplierList.value = res.data;
- })
+ const dialogFormVisible = ref(false);
+ const operationType = ref("");
+ const data = reactive({
+ form: {
+ checkTime: "",
+ process: "",
+ checkName: "",
+ productName: "",
+ productId: "",
+ productModelId: "",
+ model: "",
+ testStandardId: "",
+ unit: "",
+ quantity: "",
+ qualifiedQuantity: "",
+ unqualifiedQuantity: "",
+ checkCompany: "",
+ checkResult: "",
+ },
+ rules: {
+ checkTime: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ process: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ checkName: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ productId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ productModelId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ testStandardId: [
+ { required: false, message: "璇烽�夋嫨鎸囨爣", trigger: "change" },
+ ],
+ unit: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ qualifiedQuantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ unqualifiedQuantity: [
+ { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+ ],
+ checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ checkResult: [{ required: true, message: "璇疯緭鍏�", trigger: "change" }],
+ },
+ });
+ const { form, rules } = toRefs(data);
+ // 鏄惁涓烘煡鐪嬫ā寮�
+ const isViewMode = computed(() => operationType.value === "view");
+ // 缂栬緫鏃讹細productMainId 鎴� purchaseLedgerId 浠讳竴鏈夊�煎垯宸ュ簭銆佹暟閲忕疆鐏�
+ const processQuantityDisabled = computed(() => {
+ const v = form.value || {};
+ return !!(v.productMainId != null || v.purchaseLedgerId != null);
+ });
+ 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",
+ },
]);
- userList.value = userListsRes.data;
+ const tableData = ref([]);
+ const tableLoading = ref(false);
+ const userList = ref([]);
+ const currentProductId = ref(0);
+ const testStandardOptions = ref([]); // 鎸囨爣閫夋嫨涓嬫媺妗嗘暟鎹�
+ const modelOptions = ref([]);
- form.value = {}
- testStandardOptions.value = [];
- tableData.value = [];
+ // 鎵撳紑寮规
+ const openDialog = async (type, row) => {
+ operationType.value = type;
+ dialogFormVisible.value = true;
+ // 鍏堟竻绌鸿〃鍗曢獙璇佺姸鎬侊紝閬垮厤闂儊
+ await nextTick();
+ proxy.$refs.formRef?.clearValidate();
- if (operationType.value === 'edit' || operationType.value === 'view') {
- // 鍏堜繚瀛� testStandardId锛岄伩鍏嶈娓呯┖
- const savedTestStandardId = row.testStandardId;
- // 鍏堣缃〃鍗曟暟鎹紝浣嗘殏鏃舵竻绌� testStandardId锛岀瓑閫夐」鍔犺浇瀹屾垚鍚庡啀璁剧疆
- form.value = {...row, testStandardId: ''}
- currentProductId.value = row.productId || 0
- // 娓呯┖楠岃瘉鐘舵�侊紝閬垮厤鏁版嵁鍔犺浇杩囩▼涓殑鏍¢獙闂儊
- nextTick(() => {
- proxy.$refs.formRef?.clearValidate();
- });
+ // 骞惰鍔犺浇鍩虹鏁版嵁
+ const [userListsRes] = await Promise.all([
+ userListNoPage(),
+ getProductOptions(),
+ getOptions().then(res => {
+ supplierList.value = res.data;
+ }),
+ ]);
+ userList.value = userListsRes.data;
- // 缂栬緫妯″紡涓嬶紝骞惰鍔犺浇瑙勬牸鍨嬪彿鍜屾寚鏍囬�夐」
- if (currentProductId.value) {
- // 璁剧疆浜у搧鍚嶇О
- form.value.productName = findNodeById(productOptions.value, currentProductId.value);
-
- // 骞惰鍔犺浇瑙勬牸鍨嬪彿鍜屾寚鏍囬�夐」
- const params = {
- productId: currentProductId.value,
- inspectType: 2
- };
-
- Promise.all([
- modelList({ id: currentProductId.value }),
- qualityInspectDetailByProductId(params)
- ]).then(([modelRes, testStandardRes]) => {
- // 璁剧疆瑙勬牸鍨嬪彿閫夐」
- modelOptions.value = modelRes || [];
- // 濡傛灉琛ㄥ崟涓凡鏈� productModelId锛岃缃搴旂殑 model 鍜� unit
- if (form.value.productModelId && modelOptions.value.length > 0) {
- const selectedModel = modelOptions.value.find(item => item.id == form.value.productModelId);
- if (selectedModel) {
- form.value.model = selectedModel.model || '';
- form.value.unit = selectedModel.unit || '';
- }
- }
-
- // 璁剧疆鎸囨爣閫夐」
- testStandardOptions.value = testStandardRes.data || [];
-
- // 璁剧疆 testStandardId 骞跺姞杞藉弬鏁板垪琛�
- nextTick(() => {
- if (savedTestStandardId) {
- // 纭繚绫诲瀷鍖归厤锛坕tem.id 鍙兘鏄暟瀛楁垨瀛楃涓诧級
- const matchedOption = testStandardOptions.value.find(item =>
- item.id == savedTestStandardId || String(item.id) === String(savedTestStandardId)
- );
- if (matchedOption) {
- // 纭繚浣跨敤鍖归厤椤圭殑 id锛堜繚鎸佺被鍨嬩竴鑷达級
- form.value.testStandardId = matchedOption.id;
- } else {
- // 濡傛灉鎵句笉鍒板尮閰嶉」锛屽皾璇曠洿鎺ヤ娇鐢ㄥ師鍊�
- console.warn('鏈壘鍒板尮閰嶇殑鎸囨爣閫夐」锛宼estStandardId:', savedTestStandardId, '鍙敤閫夐」:', testStandardOptions.value);
- form.value.testStandardId = savedTestStandardId;
- }
- }
- // 缂栬緫鍦烘櫙淇濈暀宸叉湁妫�楠屽�硷紝鐩存帴鎷夊彇鍘熷弬鏁版暟鎹�
- getQualityInspectParamList(row.id);
- });
- });
- } else {
- getQualityInspectParamList(row.id);
- }
- }
-}
-const getProductOptions = () => {
- return productTreeList().then((res) => {
- productOptions.value = convertIdToValue(res);
- });
-};
-const getModels = (value) => {
- form.value.productModelId = undefined;
- form.value.unit = undefined;
- modelOptions.value = [];
- currentProductId.value = value
- form.value.productName = findNodeById(productOptions.value, value);
- modelList({ id: value }).then((res) => {
- modelOptions.value = res;
- })
- if (currentProductId.value) {
- getList();
- }
-};
-
-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 || '';
-}
-
-const handleQualifiedQuantityChange = (value) => {
- if (value === null || value === undefined) {
- form.value.qualifiedQuantity = 0;
- return;
- }
- const quantity = parseFloat(form.value.quantity) || 0;
- const qualified = parseFloat(value) || 0;
- form.value.qualifiedQuantity = qualified > quantity?quantity:qualified;
- form.value.unqualifiedQuantity = Math.max(0, quantity - qualified);
-};
-
-const handleUnqualifiedQuantityChange = (value) => {
- if (value === null || value === undefined) {
- form.value.unqualifiedQuantity = 0;
- return;
- }
- const quantity = parseFloat(form.value.quantity) || 0;
- const unqualified = parseFloat(value) || 0;
- form.value.unqualifiedQuantity = unqualified > quantity?quantity:unqualified;
- form.value.qualifiedQuantity = Math.max(0, quantity - unqualified);
-};
-
-const findNodeById = (nodes, productId) => {
- for (let i = 0; i < nodes.length; i++) {
- if (nodes[i].value === productId) {
- return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣
- }
- if (nodes[i].children && nodes[i].children.length > 0) {
- const foundNode = findNodeById(nodes[i].children, productId);
- if (foundNode) {
- return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐�
- }
- }
- }
- return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
-};
-function convertIdToValue(data) {
- return data.map((item) => {
- const { id, children, ...rest } = item;
- const newItem = {
- ...rest,
- value: id, // 灏� id 鏀逛负 value
- };
- if (children && children.length > 0) {
- newItem.children = convertIdToValue(children);
- }
-
- return newItem;
- });
-}
-// 鎻愪氦浜у搧琛ㄥ崟
-const submitForm = () => {
- 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(data).then(res => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- });
- } else {
- qualityInspectUpdate(data).then(res => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- });
- }
- }
- });
-}
-const getList = () => {
- if (!currentProductId.value) {
+ form.value = {};
testStandardOptions.value = [];
tableData.value = [];
- return;
- }
- let params = {
- productId: currentProductId.value,
- inspectType: 2
- };
- qualityInspectDetailByProductId(params).then(res => {
- // 淇濆瓨涓嬫媺妗嗛�夐」鏁版嵁
- testStandardOptions.value = res.data || [];
- // 娓呯┖琛ㄦ牸鏁版嵁锛岀瓑寰呯敤鎴烽�夋嫨鎸囨爣
- tableData.value = [];
- // 娓呯┖鎸囨爣閫夋嫨
- form.value.testStandardId = '';
- });
-}
-// 鎸囨爣閫夋嫨鍙樺寲澶勭悊
-const handleTestStandardChange = (testStandardId) => {
- if (!testStandardId) {
- tableData.value = [];
- return;
+ if (operationType.value === "edit" || operationType.value === "view") {
+ // 鍏堜繚瀛� testStandardId锛岄伩鍏嶈娓呯┖
+ const savedTestStandardId = row.testStandardId;
+ // 鍏堣缃〃鍗曟暟鎹紝浣嗘殏鏃舵竻绌� testStandardId锛岀瓑閫夐」鍔犺浇瀹屾垚鍚庡啀璁剧疆
+ form.value = { ...row, testStandardId: "" };
+ currentProductId.value = row.productId || 0;
+ // 娓呯┖楠岃瘉鐘舵�侊紝閬垮厤鏁版嵁鍔犺浇杩囩▼涓殑鏍¢獙闂儊
+ nextTick(() => {
+ proxy.$refs.formRef?.clearValidate();
+ });
+
+ // 缂栬緫妯″紡涓嬶紝骞惰鍔犺浇瑙勬牸鍨嬪彿鍜屾寚鏍囬�夐」
+ if (currentProductId.value) {
+ // 璁剧疆浜у搧鍚嶇О
+ form.value.productName = findNodeById(
+ productOptions.value,
+ currentProductId.value
+ );
+
+ // 骞惰鍔犺浇瑙勬牸鍨嬪彿鍜屾寚鏍囬�夐」
+ const params = {
+ productId: currentProductId.value,
+ inspectType: 2,
+ };
+
+ Promise.all([
+ modelList({ id: currentProductId.value }),
+ qualityInspectDetailByProductId(params),
+ ]).then(([modelRes, testStandardRes]) => {
+ // 璁剧疆瑙勬牸鍨嬪彿閫夐」
+ modelOptions.value = modelRes || [];
+ // 濡傛灉琛ㄥ崟涓凡鏈� productModelId锛岃缃搴旂殑 model 鍜� unit
+ if (form.value.productModelId && modelOptions.value.length > 0) {
+ const selectedModel = modelOptions.value.find(
+ item => item.id == form.value.productModelId
+ );
+ if (selectedModel) {
+ form.value.model = selectedModel.model || "";
+ form.value.unit = selectedModel.unit || "";
+ }
+ }
+
+ // 璁剧疆鎸囨爣閫夐」
+ testStandardOptions.value = testStandardRes.data || [];
+
+ // 璁剧疆 testStandardId 骞跺姞杞藉弬鏁板垪琛�
+ nextTick(() => {
+ if (savedTestStandardId) {
+ // 纭繚绫诲瀷鍖归厤锛坕tem.id 鍙兘鏄暟瀛楁垨瀛楃涓诧級
+ const matchedOption = testStandardOptions.value.find(
+ item =>
+ item.id == savedTestStandardId ||
+ String(item.id) === String(savedTestStandardId)
+ );
+ if (matchedOption) {
+ // 纭繚浣跨敤鍖归厤椤圭殑 id锛堜繚鎸佺被鍨嬩竴鑷达級
+ form.value.testStandardId = matchedOption.id;
+ } else {
+ // 濡傛灉鎵句笉鍒板尮閰嶉」锛屽皾璇曠洿鎺ヤ娇鐢ㄥ師鍊�
+ console.warn(
+ "鏈壘鍒板尮閰嶇殑鎸囨爣閫夐」锛宼estStandardId:",
+ savedTestStandardId,
+ "鍙敤閫夐」:",
+ testStandardOptions.value
+ );
+ form.value.testStandardId = savedTestStandardId;
+ }
+ }
+ // 缂栬緫鍦烘櫙淇濈暀宸叉湁妫�楠屽�硷紝鐩存帴鎷夊彇鍘熷弬鏁版暟鎹�
+ getQualityInspectParamList(row.id);
+ });
+ });
+ } else {
+ getQualityInspectParamList(row.id);
+ }
+ }
+ };
+ const getProductOptions = () => {
+ return productTreeList().then(res => {
+ productOptions.value = convertIdToValue(res);
+ });
+ };
+ const getModels = value => {
+ form.value.productModelId = undefined;
+ form.value.unit = undefined;
+ modelOptions.value = [];
+ currentProductId.value = value;
+ form.value.productName = findNodeById(productOptions.value, value);
+ modelList({ id: value }).then(res => {
+ modelOptions.value = res;
+ });
+ if (currentProductId.value) {
+ getList();
+ }
+ };
+
+ 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 || "";
+ };
+
+ const handleQualifiedQuantityChange = value => {
+ if (value === null || value === undefined) {
+ form.value.qualifiedQuantity = 0;
+ return;
+ }
+ const quantity = parseFloat(form.value.quantity) || 0;
+ const qualified = parseFloat(value) || 0;
+ form.value.qualifiedQuantity = qualified > quantity ? quantity : qualified;
+ form.value.unqualifiedQuantity = Math.max(0, quantity - qualified);
+ };
+
+ const handleUnqualifiedQuantityChange = value => {
+ if (value === null || value === undefined) {
+ form.value.unqualifiedQuantity = 0;
+ return;
+ }
+ const quantity = parseFloat(form.value.quantity) || 0;
+ const unqualified = parseFloat(value) || 0;
+ form.value.unqualifiedQuantity =
+ unqualified > quantity ? quantity : unqualified;
+ form.value.qualifiedQuantity = Math.max(0, quantity - unqualified);
+ };
+
+ const findNodeById = (nodes, productId) => {
+ for (let i = 0; i < nodes.length; i++) {
+ if (nodes[i].value === productId) {
+ return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣
+ }
+ if (nodes[i].children && nodes[i].children.length > 0) {
+ const foundNode = findNodeById(nodes[i].children, productId);
+ if (foundNode) {
+ return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐�
+ }
+ }
+ }
+ return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
+ };
+ function convertIdToValue(data) {
+ return data.map(item => {
+ const { id, children, ...rest } = item;
+ const newItem = {
+ ...rest,
+ value: id, // 灏� id 鏀逛负 value
+ };
+ if (children && children.length > 0) {
+ newItem.children = convertIdToValue(children);
+ }
+
+ return newItem;
+ });
}
- tableLoading.value = true;
- getQualityTestStandardParamByTestStandardId(testStandardId).then(res => {
- tableData.value = res.data || [];
- tableData.value = tableData.value.map(item => ({
- ...item,
- id: null
- }));
- }).catch(error => {
- console.error('鑾峰彇鏍囧噯鍙傛暟澶辫触:', error);
+ // 鎻愪氦浜у搧琛ㄥ崟
+ const submitForm = () => {
+ 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(data).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ });
+ } else {
+ qualityInspectUpdate(data).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ });
+ }
+ }
+ });
+ };
+ const getList = () => {
+ if (!currentProductId.value) {
+ testStandardOptions.value = [];
+ tableData.value = [];
+ return;
+ }
+ let params = {
+ productId: currentProductId.value,
+ inspectType: 2,
+ };
+ qualityInspectDetailByProductId(params).then(res => {
+ // 淇濆瓨涓嬫媺妗嗛�夐」鏁版嵁
+ testStandardOptions.value = res.data || [];
+ // 娓呯┖琛ㄦ牸鏁版嵁锛岀瓑寰呯敤鎴烽�夋嫨鎸囨爣
+ tableData.value = [];
+ // 娓呯┖鎸囨爣閫夋嫨
+ form.value.testStandardId = "";
+ });
+ };
+
+ // 鎸囨爣閫夋嫨鍙樺寲澶勭悊
+ const handleTestStandardChange = testStandardId => {
+ if (!testStandardId) {
+ tableData.value = [];
+ return;
+ }
+ tableLoading.value = true;
+ getQualityTestStandardParamByTestStandardId(testStandardId)
+ .then(res => {
+ tableData.value = res.data || [];
+ tableData.value = tableData.value.map(item => ({
+ ...item,
+ id: null,
+ }));
+ })
+ .catch(error => {
+ console.error("鑾峰彇鏍囧噯鍙傛暟澶辫触:", error);
+ tableData.value = [];
+ })
+ .finally(() => {
+ tableLoading.value = false;
+ });
+ };
+ const getQualityInspectParamList = id => {
+ qualityInspectParamInfo(id).then(res => {
+ tableData.value = res.data;
+ });
+ };
+ // 鍏抽棴寮规
+ const closeDia = () => {
+ proxy.resetForm("formRef");
tableData.value = [];
- }).finally(() => {
- tableLoading.value = false;
+ testStandardOptions.value = [];
+ form.value.testStandardId = "";
+ dialogFormVisible.value = false;
+ emit("close");
+ };
+ defineExpose({
+ openDialog,
});
-}
-const getQualityInspectParamList = (id) => {
- qualityInspectParamInfo(id).then(res => {
- tableData.value = res.data;
- });
-}
-// 鍏抽棴寮规
-const closeDia = () => {
- proxy.resetForm("formRef");
- tableData.value = [];
- testStandardOptions.value = [];
- form.value.testStandardId = '';
- dialogFormVisible.value = false;
- emit('close');
-}
-defineExpose({
- openDialog,
-});
</script>
<style scoped>
-
</style>
diff --git a/src/views/qualityManagement/metricBinding/index.vue b/src/views/qualityManagement/metricBinding/index.vue
index b5d2a8f..6e7a881 100644
--- a/src/views/qualityManagement/metricBinding/index.vue
+++ b/src/views/qualityManagement/metricBinding/index.vue
@@ -1,149 +1,167 @@
<template>
<div class="app-container metric-binding">
- <el-row :gutter="16" class="metric-binding-row">
+ <el-row :gutter="16"
+ class="metric-binding-row">
<!-- 宸︿晶锛氭娴嬫爣鍑嗗垪琛� -->
- <el-col :xs="24" :sm="24" :md="12" :lg="14" :xl="14" class="left-col">
+ <el-col :xs="24"
+ :sm="24"
+ :md="12"
+ :lg="14"
+ :xl="14"
+ class="left-col">
<div class="panel left-panel">
- <PIMTable
- rowKey="id"
- :column="standardColumns"
- :tableData="standardTableData"
- :page="page"
- :isSelection="false"
- :rowClassName="rowClassNameCenter"
- :tableLoading="tableLoading"
- :rowClick="handleTableRowClick"
- @pagination="handlePagination"
- :total="page.total"
- >
- <template #standardNoCell="{ row }">
- <span class="clickable-link" @click="handleStandardRowClick(row)">
- {{ row.standardNo }}
- </span>
- </template>
-
- <!-- 琛ㄥご鎼滅储 -->
- <template #standardNoHeader>
- <el-input
- v-model="searchForm.standardNo"
- placeholder="鏍囧噯缂栧彿"
- clearable
- size="small"
- @change="handleQuery"
- @clear="handleQuery"
- />
- </template>
- <template #standardNameHeader>
- <el-input
- v-model="searchForm.standardName"
- placeholder="鏍囧噯鍚嶇О"
- clearable
- size="small"
- @change="handleQuery"
- @clear="handleQuery"
- />
- </template>
- <template #inspectTypeHeader>
- <el-select
- v-model="searchForm.inspectType"
- placeholder="绫诲埆"
- clearable
- size="small"
- style="width: 120px"
- @change="handleQuery"
- @clear="handleQuery"
- >
- <el-option label="鍘熸潗鏂欐楠�" value="0" />
- <el-option label="杩囩▼妫�楠�" value="1" />
- <el-option label="鍑哄巶妫�楠�" value="2" />
- </el-select>
- </template>
- <template #stateHeader>
- <el-select
- v-model="searchForm.state"
- placeholder="鐘舵��"
- clearable
- size="small"
- style="width: 110px"
- @change="handleQuery"
- @clear="handleQuery"
- >
- <el-option label="鑽夌" value="0" />
- <el-option label="閫氳繃" value="1" />
- <el-option label="鎾ら攢" value="2" />
- </el-select>
- </template>
- </PIMTable>
+ <PIMTable rowKey="id"
+ :column="standardColumns"
+ :tableData="standardTableData"
+ :page="page"
+ :isSelection="false"
+ :rowClassName="rowClassNameCenter"
+ :tableLoading="tableLoading"
+ :rowClick="handleTableRowClick"
+ @pagination="handlePagination"
+ :total="page.total">
+ <template #standardNoCell="{ row }">
+ <span class="clickable-link"
+ @click="handleStandardRowClick(row)">
+ {{ row.standardNo }}
+ </span>
+ </template>
+ <!-- 琛ㄥご鎼滅储 -->
+ <template #standardNoHeader>
+ <el-input v-model="searchForm.standardNo"
+ placeholder="鏍囧噯缂栧彿"
+ clearable
+ size="small"
+ @change="handleQuery"
+ @clear="handleQuery" />
+ </template>
+ <template #standardNameHeader>
+ <el-input v-model="searchForm.standardName"
+ placeholder="鏍囧噯鍚嶇О"
+ clearable
+ size="small"
+ @change="handleQuery"
+ @clear="handleQuery" />
+ </template>
+ <template #inspectTypeHeader>
+ <el-select v-model="searchForm.inspectType"
+ placeholder="绫诲埆"
+ clearable
+ size="small"
+ style="width: 120px"
+ @change="handleQuery"
+ @clear="handleQuery">
+ <el-option label="鍘熸潗鏂欐楠�"
+ value="0" />
+ <el-option label="杩囩▼妫�楠�"
+ value="1" />
+ <el-option label="鍑哄巶妫�楠�"
+ value="2" />
+ </el-select>
+ </template>
+ <template #stateHeader>
+ <el-select v-model="searchForm.state"
+ placeholder="鐘舵��"
+ clearable
+ size="small"
+ style="width: 110px"
+ @change="handleQuery"
+ @clear="handleQuery">
+ <el-option label="鑽夌"
+ value="0" />
+ <el-option label="閫氳繃"
+ value="1" />
+ <el-option label="鎾ら攢"
+ value="2" />
+ </el-select>
+ </template>
+ </PIMTable>
</div>
</el-col>
-
<!-- 鍙充晶锛氱粦瀹氬垪琛� -->
- <el-col :xs="24" :sm="24" :md="12" :lg="10" :xl="10" class="right-col">
+ <el-col :xs="24"
+ :sm="24"
+ :md="12"
+ :lg="10"
+ :xl="10"
+ class="right-col">
<div class="panel right-panel">
- <div class="right-header">
- <div class="title">缁戝畾鍏崇郴</div>
- <div class="desc" v-if="currentStandard">
- 褰撳墠妫�娴嬫爣鍑嗙紪鍙凤細<span class="link-text">{{ currentStandard.standardNo }}</span>
- </div>
- <div class="desc" v-else>璇烽�夋嫨宸︿晶妫�娴嬫爣鍑�</div>
- </div>
-
- <div class="right-toolbar">
- <el-button type="primary" :disabled="!currentStandard" @click="openBindingDialog">娣诲姞缁戝畾</el-button>
- <el-button type="danger" plain :disabled="!currentStandard" @click="handleBatchUnbind">鍒犻櫎</el-button>
- </div>
-
- <el-table
- v-loading="bindingLoading"
- :data="bindingTableData"
- border
- :row-class-name="() => 'row-center'"
- class="center-table"
- style="width: 100%"
- height="calc(100vh - 220px)"
- @selection-change="handleBindingSelectionChange"
- >
- <el-table-column type="selection" width="48" align="center" />
- <el-table-column type="index" label="搴忓彿" width="60" align="center" />
- <el-table-column prop="productName" label="浜у搧鍚嶇О" min-width="140" />
- <el-table-column label="鎿嶄綔" width="120" fixed="right" align="center">
- <template #default="{ row }">
- <el-button link type="danger" size="small" @click="handleUnbind(row)">鍒犻櫎</el-button>
- </template>
- </el-table-column>
- </el-table>
+ <div class="right-header">
+ <div class="title">缁戝畾鍏崇郴</div>
+ <div class="desc"
+ v-if="currentStandard">
+ 褰撳墠妫�娴嬫爣鍑嗙紪鍙凤細<span class="link-text">{{ currentStandard.standardNo }}</span>
+ </div>
+ <div class="desc"
+ v-else>璇烽�夋嫨宸︿晶妫�娴嬫爣鍑�</div>
+ </div>
+ <div class="right-toolbar">
+ <el-button type="primary"
+ :disabled="!currentStandard"
+ @click="openBindingDialog">娣诲姞缁戝畾</el-button>
+ <el-button type="danger"
+ plain
+ :disabled="!currentStandard"
+ @click="handleBatchUnbind">鍒犻櫎</el-button>
+ </div>
+ <el-table v-loading="bindingLoading"
+ :data="bindingTableData"
+ border
+ :row-class-name="() => 'row-center'"
+ class="center-table"
+ style="width: 100%"
+ height="calc(100vh - 220px)"
+ @selection-change="handleBindingSelectionChange">
+ <el-table-column type="selection"
+ width="48"
+ align="center" />
+ <el-table-column type="index"
+ label="搴忓彿"
+ width="60"
+ align="center" />
+ <el-table-column prop="productName"
+ label="浜у搧鍚嶇О"
+ min-width="140" />
+ <el-table-column label="鎿嶄綔"
+ width="120"
+ fixed="right"
+ align="center">
+ <template #default="{ row }">
+ <el-button link
+ type="danger"
+ size="small"
+ @click="handleUnbind(row)">鍒犻櫎</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
</div>
</el-col>
</el-row>
-
<!-- 娣诲姞缁戝畾寮规 -->
- <el-dialog
- v-model="bindingDialogVisible"
- title="娣诲姞缁戝畾"
- width="520px"
- @close="closeBindingDialog"
- >
+ <el-dialog v-model="bindingDialogVisible"
+ title="娣诲姞缁戝畾"
+ width="520px"
+ @close="closeBindingDialog">
<el-form label-width="100px">
<el-form-item label="浜у搧">
- <el-tree-select
- v-model="selectedProductIds"
- multiple
- filterable
- collapse-tags
- collapse-tags-tooltip
- placeholder="璇烽�夋嫨浜у搧锛堝彲澶氶�夛級"
- clearable
- check-strictly
- :data="productOptions"
- :render-after-expand="false"
- style="width: 100%"
- />
+ <PIMTreeSelect v-model="selectedProductIds"
+ multiple
+ filterable
+ collapse-tags
+ collapse-tags-tooltip
+ placeholder="璇烽�夋嫨浜у搧锛堝彲澶氶�夛級"
+ clearable
+ check-strictly
+ :data="productOptions"
+ :render-after-expand="false"
+ style="width: 100%" />
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="closeBindingDialog">鍙栨秷</el-button>
- <el-button type="primary" @click="submitBinding">纭畾</el-button>
+ <el-button type="primary"
+ @click="submitBinding">纭畾</el-button>
</span>
</template>
</el-dialog>
@@ -151,387 +169,404 @@
</template>
<script setup>
-import { Search } from '@element-plus/icons-vue'
-import { ref, reactive, toRefs, onMounted, getCurrentInstance } from 'vue'
-import { ElMessageBox } from 'element-plus'
-import PIMTable from '@/components/PIMTable/PIMTable.vue'
-import { productTreeList } from '@/api/basicData/product.js'
-import {
- qualityTestStandardListPage
-} from '@/api/qualityManagement/metricMaintenance.js'
-import { productProcessListPage } from '@/api/basicData/productProcess.js'
-import {
- qualityTestStandardBindingList,
- qualityTestStandardBindingAdd,
- qualityTestStandardBindingDel
-} from '@/api/qualityManagement/qualityTestStandardBinding.js'
+ import { Search } from "@element-plus/icons-vue";
+ import { ref, reactive, toRefs, onMounted, getCurrentInstance } from "vue";
+ import { ElMessageBox } from "element-plus";
+ import PIMTable from "@/components/PIMTable/PIMTable.vue";
+ import PIMTreeSelect from "@/components/PIMTreeSelect/index.vue";
+ import { productTreeList } from "@/api/basicData/product.js";
+ import { qualityTestStandardListPage } from "@/api/qualityManagement/metricMaintenance.js";
+ import { productProcessListPage } from "@/api/basicData/productProcess.js";
+ import {
+ qualityTestStandardBindingList,
+ qualityTestStandardBindingAdd,
+ qualityTestStandardBindingDel,
+ } from "@/api/qualityManagement/qualityTestStandardBinding.js";
-const { proxy } = getCurrentInstance()
+ const { proxy } = getCurrentInstance();
-// 宸︿晶鏍囧噯鍒楄〃锛氭暣琛屽唴瀹瑰眳涓紙閰嶅悎鏍峰紡锛�
-const rowClassNameCenter = () => 'row-center'
+ // 宸︿晶鏍囧噯鍒楄〃锛氭暣琛屽唴瀹瑰眳涓紙閰嶅悎鏍峰紡锛�
+ const rowClassNameCenter = () => "row-center";
-const data = reactive({
- searchForm: {
- standardNo: '',
- standardName: '',
- state: '',
- inspectType: ''
+ const data = reactive({
+ searchForm: {
+ standardNo: "",
+ standardName: "",
+ state: "",
+ inspectType: "",
+ },
+ });
+ const { searchForm } = toRefs(data);
+
+ // 宸︿晶
+ const standardTableData = ref([]);
+ const tableLoading = ref(false);
+ const page = reactive({ current: 1, size: 10, total: 0 });
+
+ // 宸ュ簭涓嬫媺锛堢敤浜庡垪琛ㄥ洖鏄撅級
+ const processOptions = ref([]);
+
+ const getProcessList = async () => {
+ try {
+ const res = await productProcessListPage({ current: 1, size: 1000 });
+ if (res?.code === 200) {
+ const records = res?.data?.records || [];
+ processOptions.value = records.map(item => ({
+ label: item.processName || item.name || item.label,
+ value: item.id || item.processId || item.value,
+ }));
+ }
+ } catch (error) {
+ console.error("鑾峰彇宸ュ簭鍒楄〃澶辫触:", error);
+ }
+ };
+
+ const standardColumns = ref([
+ {
+ label: "鏍囧噯缂栧彿",
+ prop: "standardNo",
+ dataType: "slot",
+ slot: "standardNoCell",
+ minWidth: 160,
+ align: "center",
+ headerSlot: "standardNoHeader",
+ },
+ {
+ label: "鏍囧噯鍚嶇О",
+ prop: "standardName",
+ minWidth: 180,
+ align: "center",
+ headerSlot: "standardNameHeader",
+ },
+ {
+ label: "绫诲埆",
+ prop: "inspectType",
+ headerSlot: "inspectTypeHeader",
+ align: "center",
+ dataType: "tag",
+ formatData: val => {
+ const map = { 0: "鍘熸潗鏂欐楠�", 1: "杩囩▼妫�楠�", 2: "鍑哄巶妫�楠�" };
+ return map[val] || val;
+ },
+ },
+ {
+ label: "宸ュ簭",
+ prop: "processId",
+ align: "center",
+ dataType: "tag",
+ formatData: val => {
+ const target = processOptions.value.find(
+ item => String(item.value) === String(val)
+ );
+ return target?.label || val;
+ },
+ },
+ {
+ label: "澶囨敞",
+ prop: "remark",
+ minWidth: 160,
+ align: "center",
+ },
+ // {
+ // label: '鐘舵��',
+ // prop: 'state',
+ // headerSlot: 'stateHeader',
+ // dataType: 'tag',
+ // formatData: (val) => {
+ // const map = { 0: '鑽夌', 1: '閫氳繃', 2: '鎾ら攢' }
+ // return map[val] || val
+ // },
+ // formatType: (val) => {
+ // if (val == 1) return 'success'
+ // if (val == 2) return 'warning'
+ // return 'info'
+ // }
+ // }
+ ]);
+
+ const currentStandard = ref(null);
+
+ // 鍙充晶缁戝畾
+ const bindingTableData = ref([]);
+ const bindingLoading = ref(false);
+ const bindingSelectedRows = ref([]);
+ const bindingDialogVisible = ref(false);
+
+ // 浜у搧鏍戯紙鐢ㄤ簬缁戝畾閫夋嫨锛�
+ const productOptions = ref([]);
+ const selectedProductIds = ref([]);
+
+ const getProductOptions = async () => {
+ // 閬垮厤閲嶅璇锋眰
+ if (productOptions.value?.length) return;
+ const res = await productTreeList();
+ productOptions.value = convertIdToValue(Array.isArray(res) ? res : []);
+ };
+
+ function convertIdToValue(data) {
+ return (data || []).map(item => {
+ const { id, children, ...rest } = item;
+ const newItem = {
+ ...rest,
+ value: id,
+ };
+ if (children && children.length > 0) {
+ newItem.children = convertIdToValue(children);
+ }
+ return newItem;
+ });
}
-})
-const { searchForm } = toRefs(data)
-// 宸︿晶
-const standardTableData = ref([])
-const tableLoading = ref(false)
-const page = reactive({ current: 1, size: 10, total: 0 })
+ const handleQuery = () => {
+ page.current = 1;
+ getStandardList();
+ };
-// 宸ュ簭涓嬫媺锛堢敤浜庡垪琛ㄥ洖鏄撅級
-const processOptions = ref([])
+ const handlePagination = obj => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getStandardList();
+ };
-const getProcessList = async () => {
- try {
- const res = await productProcessListPage({ current: 1, size: 1000 })
- if (res?.code === 200) {
- const records = res?.data?.records || []
- processOptions.value = records.map((item) => ({
- label: item.processName || item.name || item.label,
- value: item.id || item.processId || item.value
- }))
- }
- } catch (error) {
- console.error('鑾峰彇宸ュ簭鍒楄〃澶辫触:', error)
- }
-}
-
-const standardColumns = ref([
- { label: '鏍囧噯缂栧彿', prop: 'standardNo', dataType: 'slot', slot: 'standardNoCell', minWidth: 160, align: 'center', headerSlot: 'standardNoHeader' },
- { label: '鏍囧噯鍚嶇О', prop: 'standardName', minWidth: 180, align: 'center', headerSlot: 'standardNameHeader' },
- {
- label: '绫诲埆',
- prop: 'inspectType',
- headerSlot: 'inspectTypeHeader',
- align: 'center',
- dataType: 'tag',
- formatData: (val) => {
- const map = { 0: '鍘熸潗鏂欐楠�', 1: '杩囩▼妫�楠�', 2: '鍑哄巶妫�楠�' }
- return map[val] || val
- }
- },
- {
- label: '宸ュ簭',
- prop: 'processId',
- align: 'center',
- dataType: 'tag',
- formatData: (val) => {
- const target = processOptions.value.find(
- (item) => String(item.value) === String(val)
- )
- return target?.label || val
- }
- },
- {
- label: '澶囨敞',
- prop: 'remark',
- minWidth: 160,
- align: 'center'
- }
- // {
- // label: '鐘舵��',
- // prop: 'state',
- // headerSlot: 'stateHeader',
- // dataType: 'tag',
- // formatData: (val) => {
- // const map = { 0: '鑽夌', 1: '閫氳繃', 2: '鎾ら攢' }
- // return map[val] || val
- // },
- // formatType: (val) => {
- // if (val == 1) return 'success'
- // if (val == 2) return 'warning'
- // return 'info'
- // }
- // }
-])
-
-const currentStandard = ref(null)
-
-// 鍙充晶缁戝畾
-const bindingTableData = ref([])
-const bindingLoading = ref(false)
-const bindingSelectedRows = ref([])
-const bindingDialogVisible = ref(false)
-
-// 浜у搧鏍戯紙鐢ㄤ簬缁戝畾閫夋嫨锛�
-const productOptions = ref([])
-const selectedProductIds = ref([])
-
-const getProductOptions = async () => {
- // 閬垮厤閲嶅璇锋眰
- if (productOptions.value?.length) return
- const res = await productTreeList()
- productOptions.value = convertIdToValue(Array.isArray(res) ? res : [])
-}
-
-function convertIdToValue(data) {
- return (data || []).map((item) => {
- const { id, children, ...rest } = item
- const newItem = {
- ...rest,
- value: id
- }
- if (children && children.length > 0) {
- newItem.children = convertIdToValue(children)
- }
- return newItem
- })
-}
-
-const handleQuery = () => {
- page.current = 1
- getStandardList()
-}
-
-const handlePagination = (obj) => {
- page.current = obj.page
- page.size = obj.limit
- getStandardList()
-}
-
-const getStandardList = () => {
- tableLoading.value = true
- qualityTestStandardListPage({
- ...searchForm.value,
- current: page.current,
- size: page.size,
- state: 1
- })
- .then((res) => {
- const records = res?.data?.records || []
- standardTableData.value = records
- page.total = res?.data?.total || records.length
+ const getStandardList = () => {
+ tableLoading.value = true;
+ qualityTestStandardListPage({
+ ...searchForm.value,
+ current: page.current,
+ size: page.size,
+ state: 1,
})
- .finally(() => {
- tableLoading.value = false
- })
-}
+ .then(res => {
+ const records = res?.data?.records || [];
+ standardTableData.value = records;
+ page.total = res?.data?.total || records.length;
+ })
+ .finally(() => {
+ tableLoading.value = false;
+ });
+ };
-// 琛ㄦ牸琛岀偣鍑伙紝鍔犺浇鍙充晶缁戝畾鍒楄〃
-const handleTableRowClick = (row) => {
- currentStandard.value = row
- loadBindingList()
-}
+ // 琛ㄦ牸琛岀偣鍑伙紝鍔犺浇鍙充晶缁戝畾鍒楄〃
+ const handleTableRowClick = row => {
+ currentStandard.value = row;
+ loadBindingList();
+ };
-// 宸︿晶琛岀偣鍑伙紝鍔犺浇鍙充晶缁戝畾鍒楄〃锛堜繚鐣欑敤浜庢爣鍑嗙紪鍙峰垪鐨勭偣鍑伙級
-const handleStandardRowClick = (row) => {
- currentStandard.value = row
- loadBindingList()
-}
+ // 宸︿晶琛岀偣鍑伙紝鍔犺浇鍙充晶缁戝畾鍒楄〃锛堜繚鐣欑敤浜庢爣鍑嗙紪鍙峰垪鐨勭偣鍑伙級
+ const handleStandardRowClick = row => {
+ currentStandard.value = row;
+ loadBindingList();
+ };
-const loadBindingList = () => {
- if (!currentStandard.value?.id) {
- bindingTableData.value = []
- return
- }
- bindingLoading.value = true
- qualityTestStandardBindingList({ testStandardId: currentStandard.value.id })
- .then((res) => {
- const base = res?.data || []
- // 灏嗗綋鍓嶆爣鍑嗙殑宸ュ簭鍜屽娉ㄥ甫鍒扮粦瀹氬垪琛ㄤ腑灞曠ず
- bindingTableData.value = base.map((item) => ({
- ...item,
- processId: currentStandard.value?.processId,
- remark: currentStandard.value?.remark
- }))
- })
- .finally(() => {
- bindingLoading.value = false
- })
-}
+ const loadBindingList = () => {
+ if (!currentStandard.value?.id) {
+ bindingTableData.value = [];
+ return;
+ }
+ bindingLoading.value = true;
+ qualityTestStandardBindingList({ testStandardId: currentStandard.value.id })
+ .then(res => {
+ const base = res?.data || [];
+ // 灏嗗綋鍓嶆爣鍑嗙殑宸ュ簭鍜屽娉ㄥ甫鍒扮粦瀹氬垪琛ㄤ腑灞曠ず
+ bindingTableData.value = base.map(item => ({
+ ...item,
+ processId: currentStandard.value?.processId,
+ remark: currentStandard.value?.remark,
+ }));
+ })
+ .finally(() => {
+ bindingLoading.value = false;
+ });
+ };
-const handleBindingSelectionChange = (selection) => {
- bindingSelectedRows.value = selection
-}
+ const handleBindingSelectionChange = selection => {
+ bindingSelectedRows.value = selection;
+ };
-const openBindingDialog = () => {
- if (!currentStandard.value?.id) return
- selectedProductIds.value = []
- getProductOptions()
- bindingDialogVisible.value = true
-}
+ const openBindingDialog = () => {
+ if (!currentStandard.value?.id) return;
+ selectedProductIds.value = [];
+ getProductOptions();
+ bindingDialogVisible.value = true;
+ };
-const closeBindingDialog = () => {
- bindingDialogVisible.value = false
-}
+ const closeBindingDialog = () => {
+ bindingDialogVisible.value = false;
+ };
-const submitBinding = async () => {
- const testStandardId = currentStandard.value?.id
- if (!testStandardId) return
- const ids = (selectedProductIds.value || []).filter(Boolean)
- if (!ids.length) {
- proxy.$message.warning('璇烽�夋嫨浜у搧')
- return
- }
- const payload = ids.map((pid) => ({
- productId: pid,
- testStandardId
- }))
- await qualityTestStandardBindingAdd(payload)
- proxy.$message.success('娣诲姞鎴愬姛')
- bindingDialogVisible.value = false
- loadBindingList()
-}
+ const submitBinding = async () => {
+ const testStandardId = currentStandard.value?.id;
+ if (!testStandardId) return;
+ const ids = (selectedProductIds.value || []).filter(Boolean);
+ if (!ids.length) {
+ proxy.$message.warning("璇烽�夋嫨浜у搧");
+ return;
+ }
+ const payload = ids.map(pid => ({
+ productId: pid,
+ testStandardId,
+ }));
+ await qualityTestStandardBindingAdd(payload);
+ proxy.$message.success("娣诲姞鎴愬姛");
+ bindingDialogVisible.value = false;
+ loadBindingList();
+ };
-const handleUnbind = async (row) => {
- const id = row?.id ?? row?.qualityTestStandardBindingId
- if (id == null || id === '') return
- try {
- await ElMessageBox.confirm('纭鍒犻櫎璇ョ粦瀹氾紵', '鎻愮ず', { type: 'warning' })
- } catch {
- return
- }
- try {
- await qualityTestStandardBindingDel([id])
- proxy.$message.success('鍒犻櫎鎴愬姛')
- loadBindingList()
- } catch (err) {
- console.error('鍒犻櫎缁戝畾澶辫触:', err)
- proxy.$message?.error(err?.message || '鍒犻櫎澶辫触')
- }
-}
+ const handleUnbind = async row => {
+ const id = row?.id ?? row?.qualityTestStandardBindingId;
+ if (id == null || id === "") return;
+ try {
+ await ElMessageBox.confirm("纭鍒犻櫎璇ョ粦瀹氾紵", "鎻愮ず", { type: "warning" });
+ } catch {
+ return;
+ }
+ try {
+ await qualityTestStandardBindingDel([id]);
+ proxy.$message.success("鍒犻櫎鎴愬姛");
+ loadBindingList();
+ } catch (err) {
+ console.error("鍒犻櫎缁戝畾澶辫触:", err);
+ proxy.$message?.error(err?.message || "鍒犻櫎澶辫触");
+ }
+ };
-const handleBatchUnbind = async () => {
- if (!bindingSelectedRows.value.length) {
- proxy.$message.warning('璇烽�夋嫨鏁版嵁')
- return
- }
- const ids = bindingSelectedRows.value
- .map((i) => i?.id ?? i?.qualityTestStandardBindingId)
- .filter((id) => id != null && id !== '')
- if (!ids.length) {
- proxy.$message.warning('閫変腑鏁版嵁缂哄皯鏈夋晥 id')
- return
- }
- try {
- await ElMessageBox.confirm('閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�', '鍒犻櫎鎻愮ず', { type: 'warning' })
- } catch {
- return
- }
- try {
- await qualityTestStandardBindingDel(ids)
- proxy.$message.success('鍒犻櫎鎴愬姛')
- loadBindingList()
- } catch (err) {
- console.error('鎵归噺鍒犻櫎缁戝畾澶辫触:', err)
- proxy.$message?.error(err?.message || '鍒犻櫎澶辫触')
- }
-}
+ const handleBatchUnbind = async () => {
+ if (!bindingSelectedRows.value.length) {
+ proxy.$message.warning("璇烽�夋嫨鏁版嵁");
+ return;
+ }
+ const ids = bindingSelectedRows.value
+ .map(i => i?.id ?? i?.qualityTestStandardBindingId)
+ .filter(id => id != null && id !== "");
+ if (!ids.length) {
+ proxy.$message.warning("閫変腑鏁版嵁缂哄皯鏈夋晥 id");
+ return;
+ }
+ try {
+ await ElMessageBox.confirm(
+ "閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�",
+ "鍒犻櫎鎻愮ず",
+ { type: "warning" }
+ );
+ } catch {
+ return;
+ }
+ try {
+ await qualityTestStandardBindingDel(ids);
+ proxy.$message.success("鍒犻櫎鎴愬姛");
+ loadBindingList();
+ } catch (err) {
+ console.error("鎵归噺鍒犻櫎缁戝畾澶辫触:", err);
+ proxy.$message?.error(err?.message || "鍒犻櫎澶辫触");
+ }
+ };
-onMounted(() => {
- getStandardList()
- getProcessList()
-})
+ onMounted(() => {
+ getStandardList();
+ getProcessList();
+ });
</script>
<style scoped>
-.metric-binding-row {
- width: 100%;
-}
+ .metric-binding-row {
+ width: 100%;
+ }
-.metric-binding-row .left-col,
-.metric-binding-row .right-col {
- margin-bottom: 16px;
-}
+ .metric-binding-row .left-col,
+ .metric-binding-row .right-col {
+ margin-bottom: 16px;
+ }
-.metric-binding-row .panel {
- background: #ffffff;
- padding: 16px;
- box-sizing: border-box;
- height: 100%;
- min-height: 400px;
-}
+ .metric-binding-row .panel {
+ background: #ffffff;
+ padding: 16px;
+ box-sizing: border-box;
+ height: 100%;
+ min-height: 400px;
+ }
-.left-panel,
-.right-panel {
- height: 100%;
-}
+ .left-panel,
+ .right-panel {
+ height: 100%;
+ }
-.toolbar {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 12px;
-}
+ .toolbar {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 12px;
+ }
-.toolbar-right {
- flex-shrink: 0;
-}
+ .toolbar-right {
+ flex-shrink: 0;
+ }
-.right-header {
- display: flex;
- align-items: baseline;
- justify-content: space-between;
- margin-bottom: 10px;
-}
+ .right-header {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ margin-bottom: 10px;
+ }
-.right-header .title {
- font-size: 16px;
- font-weight: 600;
-}
+ .right-header .title {
+ font-size: 16px;
+ font-weight: 600;
+ }
-.right-header .desc {
- font-size: 13px;
- color: #666;
-}
+ .right-header .desc {
+ font-size: 13px;
+ color: #666;
+ }
-.right-toolbar {
- display: flex;
- justify-content: flex-end;
- gap: 10px;
- margin-bottom: 10px;
-}
+ .right-toolbar {
+ display: flex;
+ justify-content: flex-end;
+ gap: 10px;
+ margin-bottom: 10px;
+ }
-.link-text {
- color: #409eff;
- cursor: default;
-}
+ .link-text {
+ color: #409eff;
+ cursor: default;
+ }
-.clickable-link {
- color: #409eff;
- cursor: pointer;
-}
+ .clickable-link {
+ color: #409eff;
+ cursor: pointer;
+ }
-.clickable-link:hover {
- text-decoration: underline;
-}
+ .clickable-link:hover {
+ text-decoration: underline;
+ }
-:deep(.row-center td) {
- text-align: center !important;
-}
+ :deep(.row-center td) {
+ text-align: center !important;
+ }
-/* el-table 琛ㄥご/鍐呭缁熶竴灞呬腑锛坮ow-class-name 涓嶄綔鐢ㄤ簬琛ㄥご锛� */
-:deep(.center-table .el-table__header-wrapper th .cell) {
- text-align: center !important;
-}
-:deep(.center-table .el-table__body-wrapper td .cell) {
- text-align: center !important;
-}
+ /* el-table 琛ㄥご/鍐呭缁熶竴灞呬腑锛坮ow-class-name 涓嶄綔鐢ㄤ簬琛ㄥご锛� */
+ :deep(.center-table .el-table__header-wrapper th .cell) {
+ text-align: center !important;
+ }
+ :deep(.center-table .el-table__body-wrapper td .cell) {
+ text-align: center !important;
+ }
-/* PIMTable 琛ㄥご灞呬腑 */
-:deep(.lims-table .pim-table-header-cell) {
- text-align: center;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
-}
+ /* PIMTable 琛ㄥご灞呬腑 */
+ :deep(.lims-table .pim-table-header-cell) {
+ text-align: center;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ }
-:deep(.lims-table .pim-table-header-title) {
- text-align: center;
- width: 100%;
-}
+ :deep(.lims-table .pim-table-header-title) {
+ text-align: center;
+ width: 100%;
+ }
-:deep(.lims-table .pim-table-header-extra) {
- width: 100%;
- margin-top: 4px;
-}
+ :deep(.lims-table .pim-table-header-extra) {
+ width: 100%;
+ margin-top: 4px;
+ }
</style>
diff --git a/src/views/qualityManagement/nonconformingManagement/components/formDia.vue b/src/views/qualityManagement/nonconformingManagement/components/formDia.vue
index e747d04..5e20709 100644
--- a/src/views/qualityManagement/nonconformingManagement/components/formDia.vue
+++ b/src/views/qualityManagement/nonconformingManagement/components/formDia.vue
@@ -1,121 +1,168 @@
<template>
<div>
- <el-dialog
- v-model="dialogFormVisible"
- :title="operationType === 'add' ? '鏂板涓嶅悎鏍肩鐞�' : '缂栬緫涓嶅悎鏍肩鐞�'"
- width="70%"
- @close="closeDia"
- >
- <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
+ <el-dialog v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板涓嶅悎鏍肩鐞�' : '缂栬緫涓嶅悎鏍肩鐞�'"
+ width="70%"
+ @close="closeDia">
+ <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="绫诲埆锛�" prop="inspectType">
+ <el-form-item label="绫诲埆锛�"
+ prop="inspectType">
<el-select v-model="form.inspectType">
- <el-option label="鍘熸潗鏂欐楠�" :value="0" />
- <el-option label="杩囩▼妫�楠�" :value="1" />
- <el-option label="鍑哄巶妫�楠�" :value="2" />
+ <el-option label="鍘熸潗鏂欐楠�"
+ :value="0" />
+ <el-option label="杩囩▼妫�楠�"
+ :value="1" />
+ <el-option label="鍑哄巶妫�楠�"
+ :value="2" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="浜у搧鍚嶇О锛�" prop="productId">
- <el-tree-select
- v-model="form.productId"
- placeholder="璇烽�夋嫨"
- clearable
- check-strictly
- @change="getModels"
- :data="productOptions"
- :render-after-expand="false"
- style="width: 100%"
- />
+ <el-form-item label="浜у搧鍚嶇О锛�"
+ prop="productId">
+ <el-tree-select v-model="form.productId"
+ placeholder="璇烽�夋嫨"
+ filterable
+ clearable
+ check-strictly
+ @change="getModels"
+ :data="productOptions"
+ :render-after-expand="false"
+ style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="model">
- <el-select v-model="form.productModelId" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'edit'"
- filterable readonly @change="handleChangeModel">
- <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id" />
+ <el-form-item label="瑙勬牸鍨嬪彿锛�"
+ prop="model">
+ <el-select v-model="form.productModelId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ :disabled="operationType === 'edit'"
+ filterable
+ readonly
+ @change="handleChangeModel">
+ <el-option v-for="item in modelOptions"
+ :key="item.id"
+ :label="item.model"
+ :value="item.id" />
</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="璇疯緭鍏�" clearable/>
+ <el-form-item label="鍗曚綅锛�"
+ prop="unit">
+ <el-input v-model="form.unit"
+ placeholder="璇疯緭鍏�"
+ clearable />
</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"/>
+ <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" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="妫�楠屽憳锛�" prop="checkName">
- <el-select v-model="form.checkName" placeholder="璇烽�夋嫨" clearable style="width: 100%">
- <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/>
+ <el-form-item label="妫�楠屽憳锛�"
+ prop="checkName">
+ <el-select v-model="form.checkName"
+ placeholder="璇烽�夋嫨"
+ clearable
+ style="width: 100%">
+ <el-option v-for="item in userList"
+ :key="item.nickName"
+ :label="item.nickName"
+ :value="item.nickName" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="妫�娴嬫棩鏈燂細" prop="checkTime">
- <el-date-picker
- v-model="form.checkTime"
- type="date"
- placeholder="璇烽�夋嫨鏃ユ湡"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- clearable
- style="width: 100%"
- />
+ <el-form-item label="妫�娴嬫棩鏈燂細"
+ prop="checkTime">
+ <el-date-picker v-model="form.checkTime"
+ type="date"
+ placeholder="璇烽�夋嫨鏃ユ湡"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ clearable
+ style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="涓嶅悎鏍肩幇璞★細" prop="defectivePhenomena">
- <el-input v-model="form.defectivePhenomena" placeholder="璇疯緭鍏�" clearable/>
+ <el-form-item label="涓嶅悎鏍肩幇璞★細"
+ prop="defectivePhenomena">
+ <el-input v-model="form.defectivePhenomena"
+ placeholder="璇疯緭鍏�"
+ clearable />
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="澶勭悊缁撴灉锛�" prop="dealResult">
- <el-select v-model="form.dealResult" placeholder="璇烽�夋嫨" clearable>
- <el-option :label="item.label" :value="item.value" v-for="item in rejection_handling" :key="item.value" />
+ <el-form-item label="澶勭悊缁撴灉锛�"
+ prop="dealResult">
+ <el-select v-model="form.dealResult"
+ placeholder="璇烽�夋嫨"
+ clearable>
+ <el-option :label="item.label"
+ :value="item.value"
+ v-for="item in rejection_handling"
+ :key="item.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="澶勭悊浜猴細" prop="dealName">
- <el-select v-model="form.dealName" placeholder="璇烽�夋嫨" clearable style="width: 100%">
- <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/>
+ <el-form-item label="澶勭悊浜猴細"
+ prop="dealName">
+ <el-select v-model="form.dealName"
+ placeholder="璇烽�夋嫨"
+ clearable
+ style="width: 100%">
+ <el-option v-for="item in userList"
+ :key="item.nickName"
+ :label="item.nickName"
+ :value="item.nickName" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="澶勭悊鏃ユ湡锛�" prop="dealTime">
- <el-date-picker
- v-model="form.dealTime"
- type="date"
- placeholder="璇烽�夋嫨鏃ユ湡"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- clearable
- style="width: 100%"
- />
+ <el-form-item label="澶勭悊鏃ユ湡锛�"
+ prop="dealTime">
+ <el-date-picker v-model="form.dealTime"
+ type="date"
+ placeholder="璇烽�夋嫨鏃ユ湡"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ clearable
+ style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
+ <el-button type="primary"
+ @click="submitForm">纭</el-button>
<el-button @click="closeDia">鍙栨秷</el-button>
</div>
</template>
@@ -124,173 +171,172 @@
</template>
<script setup>
-import {ref, reactive, toRefs} from "vue";
-import {modelList, productTreeList} from "@/api/basicData/product.js";
-import {
- getQualityUnqualifiedInfo,
- qualityUnqualifiedAdd,
- qualityUnqualifiedUpdate
-} from "@/api/qualityManagement/nonconformingManagement.js";
-import {userListNoPage} from "@/api/system/user.js";
-import useUserStore from "@/store/modules/user";
-const { proxy } = getCurrentInstance()
-const userStore = useUserStore()
-const emit = defineEmits(['close'])
+ import { ref, reactive, toRefs } from "vue";
+ import { modelList, productTreeList } from "@/api/basicData/product.js";
+ import {
+ getQualityUnqualifiedInfo,
+ qualityUnqualifiedAdd,
+ qualityUnqualifiedUpdate,
+ } from "@/api/qualityManagement/nonconformingManagement.js";
+ import { userListNoPage } from "@/api/system/user.js";
+ import useUserStore from "@/store/modules/user";
+ const { proxy } = getCurrentInstance();
+ const userStore = useUserStore();
+ const emit = defineEmits(["close"]);
-const dialogFormVisible = ref(false);
-const operationType = ref('')
-const { rejection_handling } = proxy.useDict("rejection_handling")
-const data = reactive({
- form: {
- checkTime: "",
- process: "",
- checkName: "",
- productName: "",
- productId: "",
- model: "",
- unit: "",
- quantity: undefined,
- checkCompany: "",
- checkResult: "",
- inspectType: '',
- defectivePhenomena: '',
- dealResult: '',
- dealName: '',
- dealTime: '',
- productModelId: undefined,
- },
- rules: {
- checkTime: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" },],
- process: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- checkName: [{ required: true, message: "璇烽�夋嫨妫�楠屽憳", trigger: "change" }],
- productId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- model: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- unit: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
- quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
- checkResult: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
- dealName: [{ required: true, message: "璇烽�夋嫨澶勭悊浜�", trigger: "change" }],
- },
-});
-const { form, rules } = toRefs(data);
-const productOptions = ref([]);
-const modelOptions = ref([]);
-const userList = ref([]); // 妫�楠屽憳/澶勭悊浜轰笅鎷夊垪琛�
-
-// 鎵撳紑寮规
-const openDialog = async (type, row) => {
- operationType.value = type;
- try {
- const userRes = await userListNoPage();
- userList.value = userRes.data || [];
- } catch (e) {
- console.error("鍔犺浇鐢ㄦ埛鍒楄〃澶辫触", e);
- userList.value = [];
- }
- dialogFormVisible.value = true;
- if (operationType.value === 'add') {
- form.value = {
- checkName: userStore.nickName || '',
- dealName: '',
- dealTime: '',
- dealResult: '',
- defectivePhenomena: '',
- inspectType: '',
- checkTime: '',
- productId: '',
- model: '',
- unit: '',
+ const dialogFormVisible = ref(false);
+ const operationType = ref("");
+ const { rejection_handling } = proxy.useDict("rejection_handling");
+ const data = reactive({
+ form: {
+ checkTime: "",
+ process: "",
+ checkName: "",
+ productName: "",
+ productId: "",
+ model: "",
+ unit: "",
quantity: undefined,
- productName: '',
+ checkCompany: "",
+ checkResult: "",
+ inspectType: "",
+ defectivePhenomena: "",
+ dealResult: "",
+ dealName: "",
+ dealTime: "",
productModelId: undefined,
- };
- } else {
- form.value = {};
- }
- getProductOptions();
- if (operationType.value === 'edit') {
- getQualityUnqualifiedInfo(row.id).then(res => {
- const { inspectState, ...rest } = (res.data || {})
- form.value = { ...rest }
- })
- }
-}
-const getProductOptions = () => {
- productTreeList().then((res) => {
- productOptions.value = convertIdToValue(res);
+ },
+ rules: {
+ checkTime: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ process: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ checkName: [{ required: true, message: "璇烽�夋嫨妫�楠屽憳", trigger: "change" }],
+ productId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ model: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ unit: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ checkResult: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ dealName: [{ required: true, message: "璇烽�夋嫨澶勭悊浜�", trigger: "change" }],
+ },
});
-};
-const getModels = (value) => {
- form.value.productName = findNodeById(productOptions.value, value);
- modelList({ id: value }).then((res) => {
- modelOptions.value = res;
- })
-};
-const handleChangeModel = (value) => {
- const selectedModel = modelOptions.value.find(item => item.id === value);
- if (selectedModel) {
- form.value.model = selectedModel.model;
- }
-};
-const findNodeById = (nodes, productId) => {
- for (let i = 0; i < nodes.length; i++) {
- if (nodes[i].value === productId) {
- return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣
+ const { form, rules } = toRefs(data);
+ const productOptions = ref([]);
+ const modelOptions = ref([]);
+ const userList = ref([]); // 妫�楠屽憳/澶勭悊浜轰笅鎷夊垪琛�
+
+ // 鎵撳紑寮规
+ const openDialog = async (type, row) => {
+ operationType.value = type;
+ try {
+ const userRes = await userListNoPage();
+ userList.value = userRes.data || [];
+ } catch (e) {
+ console.error("鍔犺浇鐢ㄦ埛鍒楄〃澶辫触", e);
+ userList.value = [];
}
- if (nodes[i].children && nodes[i].children.length > 0) {
- const foundNode = findNodeById(nodes[i].children, productId);
- if (foundNode) {
- return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐�
+ dialogFormVisible.value = true;
+ if (operationType.value === "add") {
+ form.value = {
+ checkName: userStore.nickName || "",
+ dealName: "",
+ dealTime: "",
+ dealResult: "",
+ defectivePhenomena: "",
+ inspectType: "",
+ checkTime: "",
+ productId: "",
+ model: "",
+ unit: "",
+ quantity: undefined,
+ productName: "",
+ productModelId: undefined,
+ };
+ } else {
+ form.value = {};
+ }
+ getProductOptions();
+ if (operationType.value === "edit") {
+ getQualityUnqualifiedInfo(row.id).then(res => {
+ const { inspectState, ...rest } = res.data || {};
+ form.value = { ...rest };
+ });
+ }
+ };
+ const getProductOptions = () => {
+ productTreeList().then(res => {
+ productOptions.value = convertIdToValue(res);
+ });
+ };
+ const getModels = value => {
+ form.value.productName = findNodeById(productOptions.value, value);
+ modelList({ id: value }).then(res => {
+ modelOptions.value = res;
+ });
+ };
+ const handleChangeModel = value => {
+ const selectedModel = modelOptions.value.find(item => item.id === value);
+ if (selectedModel) {
+ form.value.model = selectedModel.model;
+ }
+ };
+ const findNodeById = (nodes, productId) => {
+ for (let i = 0; i < nodes.length; i++) {
+ if (nodes[i].value === productId) {
+ return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣
+ }
+ if (nodes[i].children && nodes[i].children.length > 0) {
+ const foundNode = findNodeById(nodes[i].children, productId);
+ if (foundNode) {
+ return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐�
+ }
}
}
- }
- return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
-};
-function convertIdToValue(data) {
- return data.map((item) => {
- const { id, children, ...rest } = item;
- const newItem = {
- ...rest,
- value: id, // 灏� id 鏀逛负 value
- };
- if (children && children.length > 0) {
- newItem.children = convertIdToValue(children);
- }
-
- return newItem;
- });
-}
-// 鎻愪氦浜у搧琛ㄥ崟
-const submitForm = () => {
- proxy.$refs.formRef.validate(valid => {
- if (valid) {
- // 鐘舵�佸瓧娈典笉鍦ㄨ〃鍗曞~鍐欙紝涔熶笉浼犵粰鍚庣
- const { inspectState, ...payload } = (form.value || {})
- if (operationType.value === "add") {
- qualityUnqualifiedAdd(payload).then(res => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- })
- } else {
- qualityUnqualifiedUpdate(payload).then(res => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- })
+ return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
+ };
+ function convertIdToValue(data) {
+ return data.map(item => {
+ const { id, children, ...rest } = item;
+ const newItem = {
+ ...rest,
+ value: id, // 灏� id 鏀逛负 value
+ };
+ if (children && children.length > 0) {
+ newItem.children = convertIdToValue(children);
}
- }
- })
-}
-// 鍏抽棴寮规
-const closeDia = () => {
- proxy.resetForm("formRef");
- dialogFormVisible.value = false;
- emit('close')
-};
-defineExpose({
- openDialog,
-});
+
+ return newItem;
+ });
+ }
+ // 鎻愪氦浜у搧琛ㄥ崟
+ const submitForm = () => {
+ proxy.$refs.formRef.validate(valid => {
+ if (valid) {
+ // 鐘舵�佸瓧娈典笉鍦ㄨ〃鍗曞~鍐欙紝涔熶笉浼犵粰鍚庣
+ const { inspectState, ...payload } = form.value || {};
+ if (operationType.value === "add") {
+ qualityUnqualifiedAdd(payload).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ });
+ } else {
+ qualityUnqualifiedUpdate(payload).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ });
+ }
+ }
+ });
+ };
+ // 鍏抽棴寮规
+ const closeDia = () => {
+ proxy.resetForm("formRef");
+ dialogFormVisible.value = false;
+ emit("close");
+ };
+ defineExpose({
+ openDialog,
+ });
</script>
<style scoped>
-
</style>
diff --git a/src/views/qualityManagement/processInspection/components/formDia.vue b/src/views/qualityManagement/processInspection/components/formDia.vue
index 635360f..370b5f6 100644
--- a/src/views/qualityManagement/processInspection/components/formDia.vue
+++ b/src/views/qualityManagement/processInspection/components/formDia.vue
@@ -30,6 +30,7 @@
prop="productId">
<el-tree-select v-model="form.productId"
placeholder="璇烽�夋嫨"
+ filterable
clearable
check-strictly
@change="getModels"
@@ -141,7 +142,8 @@
<el-col :span="12">
<el-form-item label="妫�娴嬬粨鏋滐細"
prop="checkResult">
- <el-select v-model="form.checkResult" :disabled="isViewMode">
+ <el-select v-model="form.checkResult"
+ :disabled="isViewMode">
<el-option label="鍚堟牸"
value="鍚堟牸" />
<el-option label="涓嶅悎鏍�"
@@ -200,7 +202,8 @@
@click="submitForm">纭</el-button>
<el-button @click="closeDia">鍙栨秷</el-button>
</template>
- <el-button v-else @click="closeDia">鍏抽棴</el-button>
+ <el-button v-else
+ @click="closeDia">鍏抽棴</el-button>
</div>
</template>
</el-dialog>
@@ -258,11 +261,15 @@
checkName: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
productId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
productModelId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- testStandardId: [{ required: false, message: "璇烽�夋嫨鎸囨爣", trigger: "change" }],
+ testStandardId: [
+ { required: false, message: "璇烽�夋嫨鎸囨爣", trigger: "change" },
+ ],
unit: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
qualifiedQuantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- unqualifiedQuantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ unqualifiedQuantity: [
+ { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+ ],
checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
checkResult: [{ required: true, message: "璇疯緭鍏�", trigger: "change" }],
},
@@ -270,7 +277,7 @@
const userList = ref([]);
const { form, rules } = toRefs(data);
// 鏄惁涓烘煡鐪嬫ā寮�
- const isViewMode = computed(() => operationType.value === 'view');
+ const isViewMode = computed(() => operationType.value === "view");
// 缂栬緫鏃讹細productMainId 鎴� purchaseLedgerId 浠讳竴鏈夊�煎垯宸ュ簭銆佹暟閲忕疆鐏�
const processQuantityDisabled = computed(() => {
const v = form.value || {};
@@ -445,25 +452,26 @@
modelOptions.value.find(item => item.id == value)?.unit || "";
};
- const handleQualifiedQuantityChange = (value) => {
+ const handleQualifiedQuantityChange = value => {
if (value === null || value === undefined) {
form.value.qualifiedQuantity = 0;
return;
}
const quantity = parseFloat(form.value.quantity) || 0;
const qualified = parseFloat(value) || 0;
- form.value.qualifiedQuantity = qualified > quantity?quantity:qualified;
+ form.value.qualifiedQuantity = qualified > quantity ? quantity : qualified;
form.value.unqualifiedQuantity = Math.max(0, quantity - qualified);
};
- const handleUnqualifiedQuantityChange = (value) => {
+ const handleUnqualifiedQuantityChange = value => {
if (value === null || value === undefined) {
form.value.unqualifiedQuantity = 0;
return;
}
const quantity = parseFloat(form.value.quantity) || 0;
const unqualified = parseFloat(value) || 0;
- form.value.unqualifiedQuantity = unqualified > quantity?quantity:unqualified;
+ form.value.unqualifiedQuantity =
+ unqualified > quantity ? quantity : unqualified;
form.value.qualifiedQuantity = Math.max(0, quantity - unqualified);
};
@@ -571,7 +579,7 @@
tableData.value = res.data || [];
tableData.value = tableData.value.map(item => ({
...item,
- id: null
+ id: null,
}));
})
.catch(error => {
diff --git a/src/views/qualityManagement/rawMaterialInspection/components/formDia.vue b/src/views/qualityManagement/rawMaterialInspection/components/formDia.vue
index 8bcc72b..595bf80 100644
--- a/src/views/qualityManagement/rawMaterialInspection/components/formDia.vue
+++ b/src/views/qualityManagement/rawMaterialInspection/components/formDia.vue
@@ -1,166 +1,211 @@
<template>
<div>
- <el-dialog
- v-model="dialogFormVisible"
- :title="operationType === 'add' ? '鏂板鍘熸潗鏂欐楠�' : operationType === 'view' ? '鏌ョ湅鍘熸潗鏂欐楠�' : '缂栬緫鍘熸潗鏂欐楠�'"
- width="70%"
- @close="closeDia"
- >
- <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
+ <el-dialog v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板鍘熸潗鏂欐楠�' : operationType === 'view' ? '鏌ョ湅鍘熸潗鏂欐楠�' : '缂栬緫鍘熸潗鏂欐楠�'"
+ width="70%"
+ @close="closeDia">
+ <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="渚涘簲鍟嗭細" prop="supplier">
- <el-select
- v-model="form.supplier"
- placeholder="璇烽�夋嫨"
- clearable
- :disabled="isViewMode || supplierQuantityDisabled"
- >
- <el-option
- v-for="item in supplierList"
- :key="item.id"
- :label="item.supplierName"
- :value="item.supplierName"
- />
+ <el-form-item label="渚涘簲鍟嗭細"
+ prop="supplier">
+ <el-select v-model="form.supplier"
+ placeholder="璇烽�夋嫨"
+ clearable
+ :disabled="isViewMode || supplierQuantityDisabled">
+ <el-option v-for="item in supplierList"
+ :key="item.id"
+ :label="item.supplierName"
+ :value="item.supplierName" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="浜у搧鍚嶇О锛�" prop="productId">
- <el-tree-select
- v-model="form.productId"
- placeholder="璇烽�夋嫨"
- clearable
- check-strictly
- @change="getModels"
- :data="productOptions"
- :render-after-expand="false"
- :disabled="isViewMode || operationType === 'edit'"
- style="width: 100%"
- />
+ <el-form-item label="浜у搧鍚嶇О锛�"
+ prop="productId">
+ <el-tree-select v-model="form.productId"
+ placeholder="璇烽�夋嫨"
+ filterable
+ clearable
+ check-strictly
+ @change="getModels"
+ :data="productOptions"
+ :render-after-expand="false"
+ :disabled="isViewMode || operationType === 'edit'"
+ 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="isViewMode || operationType === 'edit'"
- filterable readonly @change="handleChangeModel">
- <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id" />
+ <el-form-item label="瑙勬牸鍨嬪彿锛�"
+ prop="productModelId">
+ <el-select v-model="form.productModelId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ :disabled="isViewMode || operationType === 'edit'"
+ filterable
+ readonly
+ @change="handleChangeModel">
+ <el-option v-for="item in modelOptions"
+ :key="item.id"
+ :label="item.model"
+ :value="item.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="鎸囨爣閫夋嫨锛�" prop="testStandardId">
- <el-select
- v-model="form.testStandardId"
- placeholder="璇烽�夋嫨鎸囨爣"
- clearable
- @change="handleTestStandardChange"
- style="width: 100%"
- :disabled="isViewMode"
- >
- <el-option
- v-for="item in testStandardOptions"
- :key="item.id"
- :label="item.standardName || item.standardNo"
- :value="item.id"
- />
+ <el-form-item label="鎸囨爣閫夋嫨锛�"
+ prop="testStandardId">
+ <el-select v-model="form.testStandardId"
+ placeholder="璇烽�夋嫨鎸囨爣"
+ clearable
+ @change="handleTestStandardChange"
+ style="width: 100%"
+ :disabled="isViewMode">
+ <el-option v-for="item in testStandardOptions"
+ :key="item.id"
+ :label="item.standardName || item.standardNo"
+ :value="item.id" />
</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" disabled/>
+ <el-form-item label="鍗曚綅锛�"
+ prop="unit">
+ <el-input v-model="form.unit"
+ disabled />
</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="isViewMode || supplierQuantityDisabled"/>
+ <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="isViewMode || supplierQuantityDisabled" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
- <el-form-item label="鍚堟牸鏁伴噺锛�" prop="qualifiedQuantity">
- <el-input-number :step="0.01" :min="0" :max="form.quantity || 0" style="width: 100%"
- v-model="form.qualifiedQuantity" placeholder="璇疯緭鍏�" :precision="2"
- @change="onQualifiedChange" :disabled="isViewMode"/>
+ <el-form-item label="鍚堟牸鏁伴噺锛�"
+ prop="qualifiedQuantity">
+ <el-input-number :step="0.01"
+ :min="0"
+ :max="form.quantity || 0"
+ style="width: 100%"
+ v-model="form.qualifiedQuantity"
+ placeholder="璇疯緭鍏�"
+ :precision="2"
+ @change="onQualifiedChange"
+ :disabled="isViewMode" />
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="涓嶅悎鏍兼暟閲忥細" prop="unqualifiedQuantity">
- <el-input-number :step="0.01" :min="0" :max="form.quantity || 0" style="width: 100%"
- v-model="form.unqualifiedQuantity" placeholder="璇疯緭鍏�" :precision="2"
- @change="onUnqualifiedChange" :disabled="isViewMode"/>
+ <el-form-item label="涓嶅悎鏍兼暟閲忥細"
+ prop="unqualifiedQuantity">
+ <el-input-number :step="0.01"
+ :min="0"
+ :max="form.quantity || 0"
+ style="width: 100%"
+ v-model="form.unqualifiedQuantity"
+ placeholder="璇疯緭鍏�"
+ :precision="2"
+ @change="onUnqualifiedChange"
+ :disabled="isViewMode" />
</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" placeholder="璇疯緭鍏�" clearable :disabled="isViewMode"/>
+ <el-form-item label="妫�娴嬪崟浣嶏細"
+ prop="checkCompany">
+ <el-input v-model="form.checkCompany"
+ placeholder="璇疯緭鍏�"
+ clearable
+ :disabled="isViewMode" />
</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-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>
</el-col>
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="妫�楠屽憳锛�" prop="checkName">
- <el-select v-model="form.checkName" placeholder="璇烽�夋嫨" clearable style="width: 100%" :disabled="isViewMode">
- <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/>
+ <el-form-item label="妫�楠屽憳锛�"
+ prop="checkName">
+ <el-select v-model="form.checkName"
+ placeholder="璇烽�夋嫨"
+ clearable
+ style="width: 100%"
+ :disabled="isViewMode">
+ <el-option v-for="item in userList"
+ :key="item.nickName"
+ :label="item.nickName"
+ :value="item.nickName" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="妫�娴嬫棩鏈燂細" prop="checkTime">
- <el-date-picker
- v-model="form.checkTime"
- type="date"
- placeholder="璇烽�夋嫨鏃ユ湡"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- clearable
- style="width: 100%"
- :disabled="isViewMode"
- />
+ <el-form-item label="妫�娴嬫棩鏈燂細"
+ prop="checkTime">
+ <el-date-picker v-model="form.checkTime"
+ type="date"
+ placeholder="璇烽�夋嫨鏃ユ湡"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ clearable
+ style="width: 100%"
+ :disabled="isViewMode" />
</el-form-item>
</el-col>
</el-row>
</el-form>
-<!-- <div style="margin-bottom: 10px;text-align: right">-->
-<!-- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>-->
-<!-- </div>-->
- <PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :tableLoading="tableLoading"
- height="400"
- >
+ <!-- <div style="margin-bottom: 10px;text-align: right">-->
+ <!-- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>-->
+ <!-- </div>-->
+ <PIMTable rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :tableLoading="tableLoading"
+ height="400">
<template #slot="{ row }">
- <el-input v-model="row.testValue" clearable :disabled="isViewMode"/>
+ <el-input v-model="row.testValue"
+ clearable
+ :disabled="isViewMode" />
</template>
</PIMTable>
<template #footer>
<div class="dialog-footer">
<template v-if="!isViewMode">
- <el-button type="primary" @click="submitForm">纭</el-button>
+ <el-button type="primary"
+ @click="submitForm">纭</el-button>
<el-button @click="closeDia">鍙栨秷</el-button>
</template>
- <el-button v-else @click="closeDia">鍏抽棴</el-button>
+ <el-button v-else
+ @click="closeDia">鍏抽棴</el-button>
</div>
</template>
</el-dialog>
@@ -168,358 +213,393 @@
</template>
<script setup>
-import {ref, reactive, toRefs, computed, getCurrentInstance, nextTick} from "vue";
-import {getOptions} from "@/api/procurementManagement/procurementLedger.js";
-import {modelList, productTreeList} from "@/api/basicData/product.js";
-import {qualityInspectAdd, qualityInspectUpdate} from "@/api/qualityManagement/rawMaterialInspection.js";
-import {qualityInspectParamDel, qualityInspectParamInfo} from "@/api/qualityManagement/qualityInspectParam.js";
-import {qualityInspectDetailByProductId, getQualityTestStandardParamByTestStandardId} from "@/api/qualityManagement/metricMaintenance.js";
-import {userListNoPage} from "@/api/system/user.js";
+ import {
+ ref,
+ reactive,
+ toRefs,
+ computed,
+ getCurrentInstance,
+ nextTick,
+ } from "vue";
+ import { getOptions } from "@/api/procurementManagement/procurementLedger.js";
+ import { modelList, productTreeList } from "@/api/basicData/product.js";
+ import {
+ qualityInspectAdd,
+ qualityInspectUpdate,
+ } from "@/api/qualityManagement/rawMaterialInspection.js";
+ import {
+ qualityInspectParamDel,
+ qualityInspectParamInfo,
+ } from "@/api/qualityManagement/qualityInspectParam.js";
+ import {
+ qualityInspectDetailByProductId,
+ getQualityTestStandardParamByTestStandardId,
+ } from "@/api/qualityManagement/metricMaintenance.js";
+ import { userListNoPage } from "@/api/system/user.js";
-const {proxy} = getCurrentInstance()
-const emit = defineEmits(['close'])
+ const { proxy } = getCurrentInstance();
+ const emit = defineEmits(["close"]);
-const dialogFormVisible = ref(false);
-const operationType = ref('')
-const data = reactive({
- form: {
- checkTime: "",
- supplier: "",
- checkName: "",
- productName: "",
- productId: "",
- productModelId: "",
- model: "",
- testStandardId: "",
- unit: "",
- quantity: "",
- checkCompany: "",
- checkResult: "",
- },
- rules: {
- checkTime: [{required: true, message: "璇疯緭鍏�", trigger: "blur"},],
- supplier: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
- checkName: [{required: false, message: "璇疯緭鍏�", trigger: "blur"}],
- productId: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
- productModelId: [{required: true, message: "璇烽�夋嫨浜у搧鍨嬪彿", trigger: "change"}],
- testStandardId: [{required: false, message: "璇烽�夋嫨鎸囨爣", trigger: "change"}],
- unit: [{required: false, message: "璇疯緭鍏�", trigger: "blur"}],
- quantity: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
- qualifiedQuantity: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
- unqualifiedQuantity: [{required: true, message: "璇疯緭鍏�", trigger: "blur"}],
- checkCompany: [{required: false, message: "璇疯緭鍏�", trigger: "blur"}],
- checkResult: [{required: true, message: "璇烽�夋嫨妫�娴嬬粨鏋�", trigger: "change"}],
- },
-});
-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 dialogFormVisible = ref(false);
+ const operationType = ref("");
+ const data = reactive({
+ form: {
+ checkTime: "",
+ supplier: "",
+ checkName: "",
+ productName: "",
+ productId: "",
+ productModelId: "",
+ model: "",
+ testStandardId: "",
+ unit: "",
+ quantity: "",
+ checkCompany: "",
+ checkResult: "",
+ },
+ rules: {
+ checkTime: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ supplier: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ checkName: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ productId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ productModelId: [
+ { required: true, message: "璇烽�夋嫨浜у搧鍨嬪彿", trigger: "change" },
+ ],
+ testStandardId: [
+ { required: false, message: "璇烽�夋嫨鎸囨爣", trigger: "change" },
+ ],
+ unit: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ qualifiedQuantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ unqualifiedQuantity: [
+ { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+ ],
+ checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ checkResult: [
+ { required: true, message: "璇烽�夋嫨妫�娴嬬粨鏋�", trigger: "change" },
+ ],
+ },
+ });
+ 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 {form, rules} = toRefs(data);
-const supplierList = ref([]);
-const productOptions = ref([]);
-const currentProductId = ref(0);
-const testStandardOptions = ref([]); // 鎸囨爣閫夋嫨涓嬫媺妗嗘暟鎹�
-const modelOptions = ref([]);
-const userList = ref([]); // 妫�楠屽憳涓嬫媺鍒楄〃
+ const { form, rules } = toRefs(data);
+ const supplierList = ref([]);
+ const productOptions = ref([]);
+ const currentProductId = ref(0);
+ const testStandardOptions = ref([]); // 鎸囨爣閫夋嫨涓嬫媺妗嗘暟鎹�
+ const modelOptions = ref([]);
+ const userList = ref([]); // 妫�楠屽憳涓嬫媺鍒楄〃
-// 鏄惁涓烘煡鐪嬫ā寮�
-const isViewMode = computed(() => operationType.value === 'view');
+ // 鏄惁涓烘煡鐪嬫ā寮�
+ const isViewMode = computed(() => operationType.value === "view");
-// 缂栬緫鏃讹細productMainId 鎴� purchaseLedgerId 浠讳竴鏈夊�煎垯渚涘簲鍟嗐�佹暟閲忕疆鐏�
-const supplierQuantityDisabled = computed(() => {
- const v = form.value || {};
- return !!(v.productMainId != null || v.purchaseLedgerId != null);
-});
-
-// 鎵撳紑寮规
-const openDialog = async (type, row) => {
- operationType.value = type;
- getOptions().then((res) => {
- supplierList.value = res.data;
+ // 缂栬緫鏃讹細productMainId 鎴� purchaseLedgerId 浠讳竴鏈夊�煎垯渚涘簲鍟嗐�佹暟閲忕疆鐏�
+ const supplierQuantityDisabled = computed(() => {
+ const v = form.value || {};
+ return !!(v.productMainId != null || v.purchaseLedgerId != null);
});
- try {
- const userRes = await userListNoPage();
- userList.value = userRes.data || [];
- } catch (e) {
- console.error("鍔犺浇妫�楠屽憳鍒楄〃澶辫触", e);
- userList.value = [];
- }
- // 鍏堥噸缃〃鍗曟暟鎹紙淇濇寔瀛楁瀹屾暣锛岄伩鍏嶅脊绐楅娆℃覆鏌撴椂瑙﹀彂蹇呭~绾㈡鈥滈棯涓�涓嬧�濓級
- form.value = {
- checkTime: "",
- supplier: "",
- checkName: "",
- productName: "",
- productId: "",
- productModelId: "",
- model: "",
- testStandardId: "",
- unit: "",
- quantity: "",
- checkCompany: "",
- checkResult: "",
- }
- testStandardOptions.value = [];
- tableData.value = [];
- // 鍏堢‘淇濅骇鍝佹爲宸插姞杞斤紝鍚﹀垯缂栬緫鏃朵骇鍝�/瑙勬牸鍨嬪彿鏃犳硶鍙嶆樉
- await getProductOptions();
- if (operationType.value === 'edit' || operationType.value === 'view') {
- // 鍏堜繚瀛� testStandardId锛岄伩鍏嶈娓呯┖
- const savedTestStandardId = row.testStandardId;
- form.value = {...row}
- currentProductId.value = row.productId || 0
- // 鍏抽敭锛氱紪杈戞椂鍔犺浇瑙勬牸鍨嬪彿涓嬫媺閫夐」锛屾墠鑳藉弽鏄� productModelId
- if (currentProductId.value) {
- try {
- const res = await modelList({ id: currentProductId.value });
- modelOptions.value = res || [];
- // 鍚屾鍥炲~ model / unit锛堟湁浜涙帴鍙h繑鍥炵殑 row 閲屽彲鑳芥病甯﹀叏锛�
- if (form.value.productModelId) {
- handleChangeModel(form.value.productModelId);
- }
- } catch (e) {
- console.error("鍔犺浇瑙勬牸鍨嬪彿澶辫触", e);
- modelOptions.value = [];
- }
- }
- // 缂栬緫妯″紡涓嬶紝鍏堝姞杞芥寚鏍囬�夐」锛岀劧鍚庡姞杞藉弬鏁板垪琛�
- if (currentProductId.value) {
- // 鍏堝姞杞芥寚鏍囬�夐」
- let params = {
- productId: currentProductId.value,
- inspectType: 0
- }
- qualityInspectDetailByProductId(params).then(res => {
- testStandardOptions.value = res.data || [];
- // 浣跨敤 nextTick 鍜� setTimeout 纭繚閫夐」宸茬粡娓叉煋鍒� DOM
- nextTick(() => {
- setTimeout(() => {
- // 濡傛灉缂栬緫鏁版嵁涓湁 testStandardId锛屽垯璁剧疆骞跺姞杞藉搴旂殑鍙傛暟
- if (savedTestStandardId) {
- // 纭繚绫诲瀷鍖归厤锛坕tem.id 鍙兘鏄暟瀛楁垨瀛楃涓诧級
- const matchedOption = testStandardOptions.value.find(item =>
- item.id == savedTestStandardId || String(item.id) === String(savedTestStandardId)
- );
- if (matchedOption) {
- // 纭繚浣跨敤鍖归厤椤圭殑 id锛堜繚鎸佺被鍨嬩竴鑷达級
- form.value.testStandardId = matchedOption.id;
- // 缂栬緫淇濈暀鍘熸楠屽�硷紝鐩存帴鎷夊彇鍘熷弬鏁版暟鎹�
- getQualityInspectParamList(row.id);
- } else {
- // 濡傛灉鎵句笉鍒板尮閰嶉」锛屽皾璇曠洿鎺ヤ娇鐢ㄥ師鍊�
- console.warn('鏈壘鍒板尮閰嶇殑鎸囨爣閫夐」锛宼estStandardId:', savedTestStandardId, '鍙敤閫夐」:', testStandardOptions.value);
- form.value.testStandardId = savedTestStandardId;
- getQualityInspectParamList(row.id);
- }
- } else {
- // 鍚﹀垯浣跨敤鏃х殑閫昏緫
- getQualityInspectParamList(row.id);
- }
- }, 100);
- });
- });
- } else {
- getQualityInspectParamList(row.id);
- }
- }
- // 鏈�鍚庡啀鎵撳紑寮圭獥锛屽苟娓呯悊鏍¢獙鎬侊紝閬垮厤蹇呭~鎻愮ず闂儊
- dialogFormVisible.value = true;
- nextTick(() => {
- proxy.$refs?.formRef?.clearValidate?.();
- });
-}
-const getProductOptions = () => {
- return productTreeList().then((res) => {
- productOptions.value = convertIdToValue(res);
- return productOptions.value;
- });
-};
-const getModels = (value) => {
- form.value.productModelId = undefined;
- form.value.unit = undefined;
- modelOptions.value = [];
- currentProductId.value = value
- form.value.productName = findNodeById(productOptions.value, value);
- modelList({ id: value }).then((res) => {
- modelOptions.value = res;
- })
- if (currentProductId.value) {
- getList();
- }
-};
+ // 鎵撳紑寮规
+ const openDialog = async (type, row) => {
+ operationType.value = type;
+ getOptions().then(res => {
+ supplierList.value = res.data;
+ });
-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 || '';
-}
-
-const findNodeById = (nodes, productId) => {
- for (let i = 0; i < nodes.length; i++) {
- if (nodes[i].value === productId) {
- return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣
+ try {
+ const userRes = await userListNoPage();
+ userList.value = userRes.data || [];
+ } catch (e) {
+ console.error("鍔犺浇妫�楠屽憳鍒楄〃澶辫触", e);
+ userList.value = [];
}
- if (nodes[i].children && nodes[i].children.length > 0) {
- const foundNode = findNodeById(nodes[i].children, productId);
- if (foundNode) {
- return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐�
- }
- }
- }
- return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
-};
-
-function convertIdToValue(data) {
- return data.map((item) => {
- const {id, children, ...rest} = item;
- const newItem = {
- ...rest,
- value: id, // 灏� id 鏀逛负 value
+ // 鍏堥噸缃〃鍗曟暟鎹紙淇濇寔瀛楁瀹屾暣锛岄伩鍏嶅脊绐楅娆℃覆鏌撴椂瑙﹀彂蹇呭~绾㈡鈥滈棯涓�涓嬧�濓級
+ form.value = {
+ checkTime: "",
+ supplier: "",
+ checkName: "",
+ productName: "",
+ productId: "",
+ productModelId: "",
+ model: "",
+ testStandardId: "",
+ unit: "",
+ quantity: "",
+ checkCompany: "",
+ checkResult: "",
};
- if (children && children.length > 0) {
- newItem.children = convertIdToValue(children);
- }
-
- return newItem;
- });
-}
-
-// 鎻愪氦浜у搧琛ㄥ崟
-const submitForm = () => {
- 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}
- if (operationType.value === "add") {
- qualityInspectAdd(data).then(res => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- })
- } else {
- qualityInspectUpdate(data).then(res => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- })
- }
- }
- })
-}
-
-const getList = () => {
- if (!currentProductId.value) {
testStandardOptions.value = [];
tableData.value = [];
- return;
- }
- let params = {
- productId: currentProductId.value,
- inspectType: 0
- }
- qualityInspectDetailByProductId(params).then(res => {
- // 淇濆瓨涓嬫媺妗嗛�夐」鏁版嵁
- testStandardOptions.value = res.data || [];
- // 娓呯┖琛ㄦ牸鏁版嵁锛岀瓑寰呯敤鎴烽�夋嫨鎸囨爣
- tableData.value = [];
- // 娓呯┖鎸囨爣閫夋嫨
- form.value.testStandardId = '';
- })
-}
-
-// 鎸囨爣閫夋嫨鍙樺寲澶勭悊
-const handleTestStandardChange = (testStandardId) => {
- if (!testStandardId) {
- tableData.value = [];
- return;
- }
- tableLoading.value = true;
- getQualityTestStandardParamByTestStandardId(testStandardId).then(res => {
- tableData.value = res.data || [];
- tableData.value = tableData.value.map(item => ({
- ...item,
- id: null
- }));
- }).catch(error => {
- console.error('鑾峰彇鏍囧噯鍙傛暟澶辫触:', error);
- tableData.value = [];
- }).finally(() => {
- tableLoading.value = false;
- })
-}
-
-const getQualityInspectParamList = (id) => {
- qualityInspectParamInfo(id).then(res => {
- tableData.value = res.data;
- })
-}
-// 鑷姩璁$畻鍚堟牸鏁伴噺鍙樺寲鏃剁殑涓嶅悎鏍兼暟閲�
-const onQualifiedChange = (value) => {
- if (form.value.quantity !== undefined && form.value.quantity !== null) {
- const maxUnqualified = form.value.quantity - value;
- if (maxUnqualified >= 0) {
- form.value.unqualifiedQuantity = maxUnqualified;
- } else {
- form.value.qualifiedQuantity = form.value.quantity;
- form.value.unqualifiedQuantity = 0;
+ // 鍏堢‘淇濅骇鍝佹爲宸插姞杞斤紝鍚﹀垯缂栬緫鏃朵骇鍝�/瑙勬牸鍨嬪彿鏃犳硶鍙嶆樉
+ await getProductOptions();
+ if (operationType.value === "edit" || operationType.value === "view") {
+ // 鍏堜繚瀛� testStandardId锛岄伩鍏嶈娓呯┖
+ const savedTestStandardId = row.testStandardId;
+ form.value = { ...row };
+ currentProductId.value = row.productId || 0;
+ // 鍏抽敭锛氱紪杈戞椂鍔犺浇瑙勬牸鍨嬪彿涓嬫媺閫夐」锛屾墠鑳藉弽鏄� productModelId
+ if (currentProductId.value) {
+ try {
+ const res = await modelList({ id: currentProductId.value });
+ modelOptions.value = res || [];
+ // 鍚屾鍥炲~ model / unit锛堟湁浜涙帴鍙h繑鍥炵殑 row 閲屽彲鑳芥病甯﹀叏锛�
+ if (form.value.productModelId) {
+ handleChangeModel(form.value.productModelId);
+ }
+ } catch (e) {
+ console.error("鍔犺浇瑙勬牸鍨嬪彿澶辫触", e);
+ modelOptions.value = [];
+ }
+ }
+ // 缂栬緫妯″紡涓嬶紝鍏堝姞杞芥寚鏍囬�夐」锛岀劧鍚庡姞杞藉弬鏁板垪琛�
+ if (currentProductId.value) {
+ // 鍏堝姞杞芥寚鏍囬�夐」
+ let params = {
+ productId: currentProductId.value,
+ inspectType: 0,
+ };
+ qualityInspectDetailByProductId(params).then(res => {
+ testStandardOptions.value = res.data || [];
+ // 浣跨敤 nextTick 鍜� setTimeout 纭繚閫夐」宸茬粡娓叉煋鍒� DOM
+ nextTick(() => {
+ setTimeout(() => {
+ // 濡傛灉缂栬緫鏁版嵁涓湁 testStandardId锛屽垯璁剧疆骞跺姞杞藉搴旂殑鍙傛暟
+ if (savedTestStandardId) {
+ // 纭繚绫诲瀷鍖归厤锛坕tem.id 鍙兘鏄暟瀛楁垨瀛楃涓诧級
+ const matchedOption = testStandardOptions.value.find(
+ item =>
+ item.id == savedTestStandardId ||
+ String(item.id) === String(savedTestStandardId)
+ );
+ if (matchedOption) {
+ // 纭繚浣跨敤鍖归厤椤圭殑 id锛堜繚鎸佺被鍨嬩竴鑷达級
+ form.value.testStandardId = matchedOption.id;
+ // 缂栬緫淇濈暀鍘熸楠屽�硷紝鐩存帴鎷夊彇鍘熷弬鏁版暟鎹�
+ getQualityInspectParamList(row.id);
+ } else {
+ // 濡傛灉鎵句笉鍒板尮閰嶉」锛屽皾璇曠洿鎺ヤ娇鐢ㄥ師鍊�
+ console.warn(
+ "鏈壘鍒板尮閰嶇殑鎸囨爣閫夐」锛宼estStandardId:",
+ savedTestStandardId,
+ "鍙敤閫夐」:",
+ testStandardOptions.value
+ );
+ form.value.testStandardId = savedTestStandardId;
+ getQualityInspectParamList(row.id);
+ }
+ } else {
+ // 鍚﹀垯浣跨敤鏃х殑閫昏緫
+ getQualityInspectParamList(row.id);
+ }
+ }, 100);
+ });
+ });
+ } else {
+ getQualityInspectParamList(row.id);
+ }
}
- }
-};
-
-// 鑷姩璁$畻涓嶅悎鏍兼暟閲忓彉鍖栨椂鐨勫悎鏍兼暟閲�
-const onUnqualifiedChange = (value) => {
- if (form.value.quantity !== undefined && form.value.quantity !== null) {
- const maxQualified = form.value.quantity - value;
- if (maxQualified >= 0) {
- form.value.qualifiedQuantity = maxQualified;
- } else {
- form.value.unqualifiedQuantity = form.value.quantity;
- form.value.qualifiedQuantity = 0;
+ // 鏈�鍚庡啀鎵撳紑寮圭獥锛屽苟娓呯悊鏍¢獙鎬侊紝閬垮厤蹇呭~鎻愮ず闂儊
+ dialogFormVisible.value = true;
+ nextTick(() => {
+ proxy.$refs?.formRef?.clearValidate?.();
+ });
+ };
+ const getProductOptions = () => {
+ return productTreeList().then(res => {
+ productOptions.value = convertIdToValue(res);
+ return productOptions.value;
+ });
+ };
+ const getModels = value => {
+ form.value.productModelId = undefined;
+ form.value.unit = undefined;
+ modelOptions.value = [];
+ currentProductId.value = value;
+ form.value.productName = findNodeById(productOptions.value, value);
+ modelList({ id: value }).then(res => {
+ modelOptions.value = res;
+ });
+ if (currentProductId.value) {
+ getList();
}
- }
-};
+ };
-// 鍏抽棴寮规
-const closeDia = () => {
- proxy.resetForm("formRef");
- tableData.value = [];
- testStandardOptions.value = [];
- form.value.testStandardId = '';
- dialogFormVisible.value = false;
- emit('close')
-};
-defineExpose({
- openDialog,
-});
+ 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 || "";
+ };
+
+ const findNodeById = (nodes, productId) => {
+ for (let i = 0; i < nodes.length; i++) {
+ if (nodes[i].value === productId) {
+ return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣
+ }
+ if (nodes[i].children && nodes[i].children.length > 0) {
+ const foundNode = findNodeById(nodes[i].children, productId);
+ if (foundNode) {
+ return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐�
+ }
+ }
+ }
+ return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
+ };
+
+ function convertIdToValue(data) {
+ return data.map(item => {
+ const { id, children, ...rest } = item;
+ const newItem = {
+ ...rest,
+ value: id, // 灏� id 鏀逛负 value
+ };
+ if (children && children.length > 0) {
+ newItem.children = convertIdToValue(children);
+ }
+
+ return newItem;
+ });
+ }
+
+ // 鎻愪氦浜у搧琛ㄥ崟
+ const submitForm = () => {
+ 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 };
+ if (operationType.value === "add") {
+ qualityInspectAdd(data).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ });
+ } else {
+ qualityInspectUpdate(data).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ });
+ }
+ }
+ });
+ };
+
+ const getList = () => {
+ if (!currentProductId.value) {
+ testStandardOptions.value = [];
+ tableData.value = [];
+ return;
+ }
+ let params = {
+ productId: currentProductId.value,
+ inspectType: 0,
+ };
+ qualityInspectDetailByProductId(params).then(res => {
+ // 淇濆瓨涓嬫媺妗嗛�夐」鏁版嵁
+ testStandardOptions.value = res.data || [];
+ // 娓呯┖琛ㄦ牸鏁版嵁锛岀瓑寰呯敤鎴烽�夋嫨鎸囨爣
+ tableData.value = [];
+ // 娓呯┖鎸囨爣閫夋嫨
+ form.value.testStandardId = "";
+ });
+ };
+
+ // 鎸囨爣閫夋嫨鍙樺寲澶勭悊
+ const handleTestStandardChange = testStandardId => {
+ if (!testStandardId) {
+ tableData.value = [];
+ return;
+ }
+ tableLoading.value = true;
+ getQualityTestStandardParamByTestStandardId(testStandardId)
+ .then(res => {
+ tableData.value = res.data || [];
+ tableData.value = tableData.value.map(item => ({
+ ...item,
+ id: null,
+ }));
+ })
+ .catch(error => {
+ console.error("鑾峰彇鏍囧噯鍙傛暟澶辫触:", error);
+ tableData.value = [];
+ })
+ .finally(() => {
+ tableLoading.value = false;
+ });
+ };
+
+ const getQualityInspectParamList = id => {
+ qualityInspectParamInfo(id).then(res => {
+ tableData.value = res.data;
+ });
+ };
+ // 鑷姩璁$畻鍚堟牸鏁伴噺鍙樺寲鏃剁殑涓嶅悎鏍兼暟閲�
+ const onQualifiedChange = value => {
+ if (form.value.quantity !== undefined && form.value.quantity !== null) {
+ const maxUnqualified = form.value.quantity - value;
+ if (maxUnqualified >= 0) {
+ form.value.unqualifiedQuantity = maxUnqualified;
+ } else {
+ form.value.qualifiedQuantity = form.value.quantity;
+ form.value.unqualifiedQuantity = 0;
+ }
+ }
+ };
+
+ // 鑷姩璁$畻涓嶅悎鏍兼暟閲忓彉鍖栨椂鐨勫悎鏍兼暟閲�
+ const onUnqualifiedChange = value => {
+ if (form.value.quantity !== undefined && form.value.quantity !== null) {
+ const maxQualified = form.value.quantity - value;
+ if (maxQualified >= 0) {
+ form.value.qualifiedQuantity = maxQualified;
+ } else {
+ form.value.unqualifiedQuantity = form.value.quantity;
+ form.value.qualifiedQuantity = 0;
+ }
+ }
+ };
+
+ // 鍏抽棴寮规
+ const closeDia = () => {
+ proxy.resetForm("formRef");
+ tableData.value = [];
+ testStandardOptions.value = [];
+ form.value.testStandardId = "";
+ dialogFormVisible.value = false;
+ emit("close");
+ };
+ defineExpose({
+ openDialog,
+ });
</script>
<style scoped>
-
</style>
--
Gitblit v1.9.3