指标绑定选择产品时,加上工序选择框(过程检、出厂检),支持多选。出厂检验及指标维护给出厂检增加工序字段
| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="dialogFormVisible" |
| | | <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"> |
| | | @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" |
| | | <el-form-item label="工序:" |
| | | prop="process"> |
| | | <el-select v-model="form.process" |
| | | placeholder="请选择工序" |
| | | clearable |
| | | :disabled="processQuantityDisabled" |
| | | @change="handleProcessChange" |
| | | style="width: 100%"> |
| | | <el-option v-for="item in processList" |
| | | :key="item.name" |
| | | :label="item.name" |
| | | :value="item.name" /> |
| | | </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 |
| | |
| | | :data="productOptions" |
| | | :render-after-expand="false" |
| | | :disabled="operationType === 'edit'" |
| | | style="width: 100%" |
| | | /> |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="规格型号:" prop="productModelId"> |
| | | <el-select v-model="form.productModelId" placeholder="请选择" clearable :disabled="operationType === 'edit'" |
| | | 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="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" |
| | | <el-form-item label="指标选择:" |
| | | prop="testStandardId"> |
| | | <el-select v-model="form.testStandardId" |
| | | placeholder="请选择指标" |
| | | clearable |
| | | @change="handleTestStandardChange" |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="item in testStandardOptions" |
| | | style="width: 100%"> |
| | | <el-option v-for="item in testStandardOptions" |
| | | :key="item.id" |
| | | :label="item.standardName || item.standardNo" |
| | | :value="item.id" |
| | | /> |
| | | :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="quantityDisabled"/> |
| | | <el-form-item label="数量:" |
| | | prop="quantity"> |
| | | <el-input-number :step="0.01" |
| | | :min="0" |
| | | style="width: 100%" |
| | | v-model="form.quantity" |
| | | placeholder="请输入" |
| | | clearable |
| | | :precision="2" |
| | | :disabled="quantityDisabled" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测单位:" prop="checkCompany"> |
| | | <el-input v-model="form.checkCompany" placeholder="请输入" clearable/> |
| | | <el-form-item label="检测单位:" |
| | | prop="checkCompany"> |
| | | <el-input v-model="form.checkCompany" |
| | | placeholder="请输入" |
| | | clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测结果:" prop="checkResult"> |
| | | <el-form-item label="检测结果:" |
| | | prop="checkResult"> |
| | | <el-select v-model="form.checkResult"> |
| | | <el-option label="合格" value="合格" /> |
| | | <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 filterable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" |
| | | <el-form-item label="检验员:" |
| | | prop="checkName"> |
| | | <el-select v-model="form.checkName" |
| | | placeholder="请选择" |
| | | clearable |
| | | filterable> |
| | | <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" |
| | | <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%" |
| | | /> |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <PIMTable |
| | | rowKey="id" |
| | | <PIMTable rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :tableLoading="tableLoading" |
| | | height="400" |
| | | > |
| | | height="400"> |
| | | <template #slot="{ row }"> |
| | | <el-input v-model="row.testValue" clearable/> |
| | | <el-input v-model="row.testValue" |
| | | clearable /> |
| | | </template> |
| | | </PIMTable> |
| | | <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> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, reactive, toRefs, computed, getCurrentInstance, nextTick} from "vue"; |
| | | 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 { |
| | | qualityInspectAdd, |
| | | qualityInspectUpdate, |
| | | } from "@/api/qualityManagement/rawMaterialInspection.js"; |
| | | import {userListNoPage} from "@/api/system/user.js"; |
| | | import {qualityInspectDetailByProductId, getQualityTestStandardParamByTestStandardId} from "@/api/qualityManagement/metricMaintenance.js"; |
| | | import { |
| | | qualityInspectDetailByProductId, |
| | | getQualityTestStandardParamByTestStandardId, |
| | | } from "@/api/qualityManagement/metricMaintenance.js"; |
| | | import {qualityInspectParamInfo} from "@/api/qualityManagement/qualityInspectParam.js"; |
| | | const { proxy } = getCurrentInstance() |
| | | const emit = defineEmits(['close']) |
| | | import { list } from "@/api/productionManagement/productionProcess"; |
| | | const { proxy } = getCurrentInstance(); |
| | | const emit = defineEmits(["close"]); |
| | | |
| | | const dialogFormVisible = ref(false); |
| | | const operationType = ref('') |
| | | const operationType = ref(""); |
| | | const data = reactive({ |
| | | form: { |
| | | checkTime: "", |
| | |
| | | checkResult: "", |
| | | }, |
| | | rules: { |
| | | checkTime: [{ required: true, message: "请输入", trigger: "blur" },], |
| | | process: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | checkTime: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | process: [{ required: true, message: "请选择工序", trigger: "change" }], |
| | | 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" }], |
| | | checkCompany: [{ required: false, message: "请输入", trigger: "blur" }], |
| | |
| | | const v = form.value || {}; |
| | | return !!(v.productMainId != null || v.purchaseLedgerId != null); |
| | | }); |
| | | const processQuantityDisabled = computed(() => { |
| | | const v = form.value || {}; |
| | | return !!(v.productMainId != null || v.purchaseLedgerId != null); |
| | | }); |
| | | const processList = ref([]); // 工序下拉列表(工序名称 name) |
| | | const supplierList = ref([]); |
| | | const productOptions = ref([]); |
| | | const tableColumn = ref([ |
| | |
| | | { |
| | | label: "检验值", |
| | | prop: "testValue", |
| | | dataType: 'slot', |
| | | slot: 'slot', |
| | | dataType: "slot", |
| | | slot: "slot", |
| | | }, |
| | | ]); |
| | | const tableData = ref([]); |
| | |
| | | const modelOptions = ref([]); |
| | | |
| | | // 打开弹框 |
| | | const openDialog = async (type, row, defaultCheckResult = "", defaultCheckName = "") => { |
| | | const openDialog = async ( |
| | | type, |
| | | row, |
| | | defaultCheckResult = "", |
| | | defaultCheckName = "" |
| | | ) => { |
| | | operationType.value = type; |
| | | dialogFormVisible.value = true; |
| | | // 先清空表单验证状态,避免闪烁 |
| | | await nextTick(); |
| | | proxy.$refs.formRef?.clearValidate(); |
| | | proxy.$refs.formRef?.clearValidate?.(); |
| | | |
| | | // 并行加载基础数据 |
| | | const [userListsRes] = await Promise.all([ |
| | | userListNoPage(), |
| | | getProductOptions(), |
| | | getOptions().then((res) => { |
| | | getOptions().then(res => { |
| | | supplierList.value = res.data; |
| | | }), |
| | | list() |
| | | .then(res => { |
| | | processList.value = res.data || []; |
| | | }) |
| | | .catch(() => { |
| | | processList.value = []; |
| | | }), |
| | | ]); |
| | | // 筛选 roleIds 包含 106 的用户 |
| | | userList.value = (userListsRes.data || []).filter(user => { |
| | | const roleIds = user.roleIds || []; |
| | | return roleIds.includes(106) || roleIds.includes('106'); |
| | | return roleIds.includes(106) || roleIds.includes("106"); |
| | | }); |
| | | |
| | | form.value = {} |
| | | currentProductId.value = 0; |
| | | modelOptions.value = []; |
| | | form.value = { |
| | | checkTime: "", |
| | | process: "", |
| | | checkName: defaultCheckName || "", |
| | | productName: "", |
| | | productId: "", |
| | | productModelId: "", |
| | | model: "", |
| | | testStandardId: "", |
| | | unit: "", |
| | | quantity: "", |
| | | checkCompany: "", |
| | | checkResult: defaultCheckResult || "", |
| | | }; |
| | | testStandardOptions.value = []; |
| | | tableData.value = []; |
| | | |
| | | if (operationType.value === 'edit') { |
| | | if (operationType.value === "edit") { |
| | | // 先保存 testStandardId,避免被清空 |
| | | const savedTestStandardId = row.testStandardId; |
| | | // 先设置表单数据,但暂时清空 testStandardId,等选项加载完成后再设置 |
| | | form.value = {...row, testStandardId: ''} |
| | | form.value = { ...row, testStandardId: "" }; |
| | | // 如果传入了默认检测结果,覆盖row中的值 |
| | | if (defaultCheckResult) { |
| | | form.value.checkResult = defaultCheckResult; |
| | | } |
| | | // 如果传入了默认检验员,覆盖row中的值(优先使用传入的检验员) |
| | | console.log('formDia checkName debug:', { defaultCheckName, rowCheckName: row.checkName }); |
| | | console.log("formDia checkName debug:", { |
| | | defaultCheckName, |
| | | rowCheckName: row.checkName, |
| | | }); |
| | | form.value.checkName = defaultCheckName || row.checkName || ""; |
| | | currentProductId.value = row.productId || 0 |
| | | currentProductId.value = row.productId || 0; |
| | | // 清空验证状态,避免数据加载过程中的校验闪烁 |
| | | nextTick(() => { |
| | | proxy.$refs.formRef?.clearValidate(); |
| | |
| | | // 编辑模式下,并行加载规格型号和指标选项 |
| | | if (currentProductId.value) { |
| | | // 设置产品名称 |
| | | form.value.productName = findNodeById(productOptions.value, currentProductId.value); |
| | | form.value.productName = findNodeById( |
| | | productOptions.value, |
| | | currentProductId.value |
| | | ); |
| | | |
| | | // 并行加载规格型号和指标选项 |
| | | const params = { |
| | | productId: currentProductId.value, |
| | | inspectType: 2 |
| | | inspectType: 2, |
| | | process: form.value.process || "", |
| | | }; |
| | | |
| | | Promise.all([ |
| | | modelList({ id: currentProductId.value }), |
| | | qualityInspectDetailByProductId(params) |
| | | 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); |
| | | const selectedModel = modelOptions.value.find( |
| | | item => item.id == form.value.productModelId |
| | | ); |
| | | if (selectedModel) { |
| | | form.value.model = selectedModel.model || ''; |
| | | form.value.unit = selectedModel.unit || ''; |
| | | form.value.model = selectedModel.model || ""; |
| | | form.value.unit = selectedModel.unit || ""; |
| | | } |
| | | } |
| | | |
| | |
| | | nextTick(() => { |
| | | if (savedTestStandardId) { |
| | | // 确保类型匹配(item.id 可能是数字或字符串) |
| | | const matchedOption = testStandardOptions.value.find(item => |
| | | item.id == savedTestStandardId || String(item.id) === String(savedTestStandardId) |
| | | 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('未找到匹配的指标选项,testStandardId:', savedTestStandardId, '可用选项:', testStandardOptions.value); |
| | | console.warn( |
| | | "未找到匹配的指标选项,testStandardId:", |
| | | savedTestStandardId, |
| | | "可用选项:", |
| | | testStandardOptions.value |
| | | ); |
| | | form.value.testStandardId = savedTestStandardId; |
| | | } |
| | | } |
| | |
| | | getQualityInspectParamList(row.id); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | const getProductOptions = () => { |
| | | return productTreeList().then((res) => { |
| | | return productTreeList().then(res => { |
| | | productOptions.value = convertIdToValue(res); |
| | | }); |
| | | }; |
| | | const getModels = (value) => { |
| | | const getModels = value => { |
| | | form.value.productModelId = undefined; |
| | | form.value.unit = undefined; |
| | | modelOptions.value = []; |
| | | currentProductId.value = value |
| | | currentProductId.value = value; |
| | | form.value.productName = findNodeById(productOptions.value, value); |
| | | modelList({ id: value }).then((res) => { |
| | | modelList({ id: value }).then(res => { |
| | | modelOptions.value = res; |
| | | }) |
| | | }); |
| | | if (currentProductId.value) { |
| | | 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 handleProcessChange = () => { |
| | | testStandardOptions.value = []; |
| | | tableData.value = []; |
| | | form.value.testStandardId = ""; |
| | | 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 findNodeById = (nodes, productId) => { |
| | | for (let i = 0; i < nodes.length; i++) { |
| | |
| | | return null; // 没有找到节点,返回null |
| | | }; |
| | | function convertIdToValue(data) { |
| | | return data.map((item) => { |
| | | return data.map(item => { |
| | | const { id, children, ...rest } = item; |
| | | const newItem = { |
| | | ...rest, |
| | |
| | | const submitForm = () => { |
| | | proxy.$refs.formRef.validate(valid => { |
| | | if (valid) { |
| | | form.value.inspectType = 2 |
| | | form.value.inspectType = 2; |
| | | if (operationType.value === "add") { |
| | | tableData.value.forEach((item) => { |
| | | delete item.id |
| | | }) |
| | | tableData.value.forEach(item => { |
| | | delete item.id; |
| | | }); |
| | | } |
| | | const data = {...form.value, qualityInspectParams: tableData.value} |
| | | const processName = form.value.process || ""; |
| | | const data = { |
| | | ...form.value, |
| | | process: processName, |
| | | 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 = []; |
| | |
| | | } |
| | | let params = { |
| | | productId: currentProductId.value, |
| | | inspectType: 2 |
| | | } |
| | | inspectType: 2, |
| | | process: form.value.process || "", |
| | | }; |
| | | qualityInspectDetailByProductId(params).then(res => { |
| | | // 保存下拉框选项数据 |
| | | testStandardOptions.value = res.data || []; |
| | | // 清空表格数据,等待用户选择指标 |
| | | tableData.value = []; |
| | | // 清空指标选择 |
| | | form.value.testStandardId = ''; |
| | | }) |
| | | } |
| | | form.value.testStandardId = ""; |
| | | }); |
| | | }; |
| | | |
| | | // 指标选择变化处理 |
| | | const handleTestStandardChange = (testStandardId) => { |
| | | const handleTestStandardChange = testStandardId => { |
| | | if (!testStandardId) { |
| | | tableData.value = []; |
| | | return; |
| | | } |
| | | tableLoading.value = true; |
| | | getQualityTestStandardParamByTestStandardId(testStandardId).then(res => { |
| | | getQualityTestStandardParamByTestStandardId(testStandardId) |
| | | .then(res => { |
| | | tableData.value = res.data || []; |
| | | }).catch(error => { |
| | | console.error('获取标准参数失败:', error); |
| | | tableData.value = []; |
| | | }).finally(() => { |
| | | tableLoading.value = false; |
| | | }) |
| | | } |
| | | const getQualityInspectParamList = (id) => { |
| | | .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 = []; |
| | | testStandardOptions.value = []; |
| | | form.value.testStandardId = ''; |
| | | form.value.testStandardId = ""; |
| | | dialogFormVisible.value = false; |
| | | emit('close') |
| | | emit("close"); |
| | | }; |
| | | defineExpose({ |
| | | openDialog, |
| | |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| | |
| | | <div class="app-container"> |
| | | <div class="search_form"> |
| | | <div> |
| | | <span class="search_title">产品名称:</span> |
| | | <el-input |
| | | v-model="searchForm.productName" |
| | | <span class="search_title">工序:</span> |
| | | <el-input v-model="searchForm.process" |
| | | style="width: 240px" |
| | | placeholder="请输入工序搜索" |
| | | @change="handleQuery" |
| | | clearable |
| | | :prefix-icon="Search" /> |
| | | <span style="margin-left: 10px" |
| | | class="search_title">产品名称:</span> |
| | | <el-input v-model="searchForm.productName" |
| | | style="width: 240px" |
| | | placeholder="请输入产品名称搜索" |
| | | @change="handleQuery" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | /> |
| | | <span style="margin-left: 10px" class="search_title">检测日期:</span> |
| | | <el-date-picker v-model="searchForm.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange" |
| | | placeholder="请选择" clearable @change="changeDaterange" /> |
| | | <el-button type="primary" @click="handleQuery" style="margin-left: 10px" |
| | | >搜索</el-button |
| | | > |
| | | :prefix-icon="Search" /> |
| | | <span style="margin-left: 10px" |
| | | class="search_title">检测日期:</span> |
| | | <el-date-picker v-model="searchForm.entryDate" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="daterange" |
| | | placeholder="请选择" |
| | | clearable |
| | | @change="changeDaterange" /> |
| | | <el-button type="primary" |
| | | @click="handleQuery" |
| | | style="margin-left: 10px">搜索</el-button> |
| | | </div> |
| | | <div> |
| | | <el-button type="primary" @click="openForm('add')">新增</el-button> |
| | | <el-button type="primary" |
| | | @click="openForm('add')">新增</el-button> |
| | | <el-button @click="handleOut">导出</el-button> |
| | | <el-button type="danger" plain @click="handleDelete">删除</el-button> |
| | | <el-button type="danger" |
| | | plain |
| | | @click="handleDelete">删除</el-button> |
| | | </div> |
| | | </div> |
| | | <div class="table_list"> |
| | | <PIMTable |
| | | rowKey="id" |
| | | <PIMTable rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :page="page" |
| | |
| | | @selection-change="handleSelectionChange" |
| | | :tableLoading="tableLoading" |
| | | @pagination="pagination" |
| | | :total="page.total" |
| | | ></PIMTable> |
| | | :total="page.total"></PIMTable> |
| | | </div> |
| | | <InspectionFormDia ref="inspectionFormDia" @close="handleQuery"></InspectionFormDia> |
| | | <FormDia ref="formDia" @close="handleQuery"></FormDia> |
| | | <files-dia ref="filesDia" @close="handleQuery"></files-dia> |
| | | <InspectionFormDia ref="inspectionFormDia" |
| | | @close="handleQuery"></InspectionFormDia> |
| | | <FormDia ref="formDia" |
| | | @close="handleQuery"></FormDia> |
| | | <files-dia ref="filesDia" |
| | | @close="handleQuery"></files-dia> |
| | | <!-- 检验结果选择对话框 --> |
| | | <el-dialog v-model="quickCheckVisible" title="检验" width="40%" @close="closeQuickCheck"> |
| | | <el-form :model="quickCheckForm" label-width="140px" label-position="top" ref="quickCheckRef"> |
| | | <el-dialog v-model="quickCheckVisible" |
| | | title="检验" |
| | | width="40%" |
| | | @close="closeQuickCheck"> |
| | | <el-form :model="quickCheckForm" |
| | | label-width="140px" |
| | | label-position="top" |
| | | ref="quickCheckRef"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测结果:" required> |
| | | <el-form-item label="检测结果:" |
| | | required> |
| | | <el-radio-group v-model="quickCheckForm.checkResult"> |
| | | <el-radio value="合格">合格</el-radio> |
| | | <el-radio value="不合格">不合格</el-radio> |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检验员:" required> |
| | | <el-select v-model="quickCheckForm.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="检验员:" |
| | | required> |
| | | <el-select v-model="quickCheckForm.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-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测日期:" required> |
| | | <el-date-picker |
| | | v-model="quickCheckForm.checkTime" |
| | | <el-form-item label="检测日期:" |
| | | required> |
| | | <el-date-picker v-model="quickCheckForm.checkTime" |
| | | type="date" |
| | | placeholder="请选择日期" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | clearable |
| | | style="width: 100%" |
| | | /> |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="指标选择:"> |
| | | <el-select |
| | | v-model="quickCheckForm.testStandardId" |
| | | <el-select v-model="quickCheckForm.testStandardId" |
| | | placeholder="请选择指标" |
| | | clearable |
| | | @change="handleTestStandardChange" |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="item in testStandardOptions" |
| | | style="width: 100%"> |
| | | <el-option v-for="item in testStandardOptions" |
| | | :key="item.id" |
| | | :label="item.standardName || item.standardNo" |
| | | :value="item.id" |
| | | /> |
| | | :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测单位:"> |
| | | <el-input v-model="quickCheckForm.checkCompany" placeholder="请输入" clearable style="width: 100%"/> |
| | | <el-input v-model="quickCheckForm.checkCompany" |
| | | placeholder="请输入" |
| | | clearable |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- 检验值表格 --> |
| | | <el-form-item label="检验值:" v-if="quickCheckTableData.length > 0"> |
| | | <PIMTable |
| | | rowKey="id" |
| | | <el-form-item label="检验值:" |
| | | v-if="quickCheckTableData.length > 0"> |
| | | <PIMTable rowKey="id" |
| | | :column="quickCheckTableColumn" |
| | | :tableData="quickCheckTableData" |
| | | :tableLoading="quickCheckTableLoading" |
| | | height="200" |
| | | > |
| | | height="200"> |
| | | <template #slot="{ row }"> |
| | | <el-input v-model="row.testValue" clearable placeholder="请输入检验值"/> |
| | | <el-input v-model="row.testValue" |
| | | clearable |
| | | placeholder="请输入检验值" /> |
| | | </template> |
| | | </PIMTable> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="handleQuickCheckConfirm">确认</el-button> |
| | | <el-button type="primary" |
| | | @click="handleQuickCheckConfirm">确认</el-button> |
| | | <el-button @click="closeQuickCheck">取消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <el-dialog v-model="dialogFormVisible" title="编辑检验员" width="30%" |
| | | <el-dialog v-model="dialogFormVisible" |
| | | title="编辑检验员" |
| | | width="30%" |
| | | @close="closeDia"> |
| | | <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef"> |
| | | <el-form-item label="检验员:" prop="checkName"> |
| | | <el-select v-model="form.checkName" placeholder="请选择" clearable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" |
| | | <el-form :model="form" |
| | | label-width="140px" |
| | | label-position="top" |
| | | :rules="rules" |
| | | ref="formRef"> |
| | | <el-form-item label="检验员:" |
| | | prop="checkName"> |
| | | <el-select v-model="form.checkName" |
| | | placeholder="请选择" |
| | | clearable> |
| | | <el-option v-for="item in userList" |
| | | :key="item.nickName" |
| | | :label="item.nickName" |
| | | :value="item.nickName"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </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> |
| | |
| | | |
| | | <script setup> |
| | | import { Search } from "@element-plus/icons-vue"; |
| | | import {onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue"; |
| | | import { |
| | | onMounted, |
| | | ref, |
| | | reactive, |
| | | toRefs, |
| | | getCurrentInstance, |
| | | nextTick, |
| | | } from "vue"; |
| | | import InspectionFormDia from "@/views/qualityManagement/finalInspection/components/inspectionFormDia.vue"; |
| | | import FormDia from "@/views/qualityManagement/finalInspection/components/formDia.vue"; |
| | | import {ElMessageBox} from "element-plus"; |
| | |
| | | downloadQualityInspect, |
| | | qualityInspectDel, |
| | | qualityInspectDetail, |
| | | qualityInspectListPage, qualityInspectUpdate, |
| | | qualityInspectListPage, |
| | | qualityInspectUpdate, |
| | | submitQualityInspect, |
| | | qualityInspectExportNew |
| | | qualityInspectExportNew, |
| | | } from "@/api/qualityManagement/rawMaterialInspection.js"; |
| | | import {qualityInspectDetailByProductId, getQualityTestStandardParamByTestStandardId} from "@/api/qualityManagement/metricMaintenance.js"; |
| | | import { |
| | | qualityInspectDetailByProductId, |
| | | getQualityTestStandardParamByTestStandardId, |
| | | } from "@/api/qualityManagement/metricMaintenance.js"; |
| | | import FilesDia from "@/views/qualityManagement/finalInspection/components/filesDia.vue"; |
| | | import dayjs from "dayjs"; |
| | | import {userListNoPage} from "@/api/system/user.js"; |
| | |
| | | |
| | | const data = reactive({ |
| | | searchForm: { |
| | | process: "", |
| | | productName: "", |
| | | entryDate: undefined, // 录入日期 |
| | | entryDateStart: undefined, |
| | |
| | | { |
| | | label: "检测日期", |
| | | prop: "checkTime", |
| | | width: 120 |
| | | width: 120, |
| | | }, |
| | | { |
| | | label: "生产工单号", |
| | | prop: "workOrderNo", |
| | | width: 120 |
| | | width: 120, |
| | | }, |
| | | { |
| | | label: "工序", |
| | | prop: "process", |
| | | width: 230, |
| | | }, |
| | | { |
| | | label: "检验员", |
| | |
| | | { |
| | | label: "数量", |
| | | prop: "quantity", |
| | | width: 100 |
| | | width: 100, |
| | | }, |
| | | { |
| | | label: "检测单位", |
| | | prop: "checkCompany", |
| | | width: 120 |
| | | width: 120, |
| | | }, |
| | | { |
| | | label: "检测结果", |
| | | prop: "checkResult", |
| | | dataType: "tag", |
| | | formatType: (params) => { |
| | | if (params == '不合格') { |
| | | formatType: params => { |
| | | if (params == "不合格") { |
| | | return "danger"; |
| | | } else if (params == '合格') { |
| | | } else if (params == "合格") { |
| | | return "success"; |
| | | } else { |
| | | return null; |
| | |
| | | { |
| | | label: "提交状态", |
| | | prop: "inspectState", |
| | | formatData: (params) => { |
| | | formatData: params => { |
| | | if (params) { |
| | | return "已提交"; |
| | | } else { |
| | |
| | | { |
| | | name: "检验", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | clickFun: row => { |
| | | openQuickCheck(row); |
| | | }, |
| | | disabled: (row) => { |
| | | disabled: row => { |
| | | // 已提交则禁用 |
| | | if (row.inspectState == 1) return true; |
| | | // 如果检验员有值,只有当前登录用户能编辑 |
| | |
| | | return row.checkName !== userStore.nickName; |
| | | } |
| | | return false; |
| | | } |
| | | }, |
| | | }, |
| | | { |
| | | name: "附件", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | clickFun: row => { |
| | | openFilesFormDia(row); |
| | | }, |
| | | }, |
| | | { |
| | | name: "提交", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | clickFun: row => { |
| | | submit(row.id); |
| | | }, |
| | | disabled: (row) => { |
| | | disabled: row => { |
| | | // 已提交则禁用 |
| | | if (row.inspectState == 1) return true; |
| | | // 如果检验员有值,只有当前登录用户能提交 |
| | |
| | | return row.checkName !== userStore.nickName; |
| | | } |
| | | return false; |
| | | } |
| | | }, |
| | | }, |
| | | { |
| | | name: "分配检验员", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | clickFun: row => { |
| | | if (!row.checkName) { |
| | | open(row) |
| | | open(row); |
| | | } else { |
| | | proxy.$modal.msgError("检验员已存在"); |
| | | } |
| | | }, |
| | | disabled: (row) => { |
| | | disabled: row => { |
| | | return row.inspectState == 1 || row.checkName; |
| | | } |
| | | }, |
| | | }, |
| | | { |
| | | name: "下载", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | clickFun: row => { |
| | | downLoadFile(row); |
| | | }, |
| | | }, |
| | |
| | | const tableData = ref([]); |
| | | const selectedRows = ref([]); |
| | | const tableLoading = ref(false); |
| | | const currentRow = ref(null) |
| | | const currentRow = ref(null); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 100, |
| | | total: 0 |
| | | total: 0, |
| | | }); |
| | | const formDia = ref() |
| | | const filesDia = ref() |
| | | const inspectionFormDia = ref() |
| | | const { proxy } = getCurrentInstance() |
| | | const userStore = useUserStore() |
| | | const formDia = ref(); |
| | | const filesDia = ref(); |
| | | const inspectionFormDia = ref(); |
| | | const { proxy } = getCurrentInstance(); |
| | | const userStore = useUserStore(); |
| | | const userList = ref([]); |
| | | const form = ref({ |
| | | checkName: "" |
| | | checkName: "", |
| | | }); |
| | | const dialogFormVisible = ref(false); |
| | | const quickCheckVisible = ref(false); |
| | |
| | | checkName: "", |
| | | checkTime: "", |
| | | testStandardId: "", |
| | | checkCompany: "" |
| | | checkCompany: "", |
| | | }); |
| | | const quickCheckRef = ref(null); |
| | | const testStandardOptions = ref([]); // 指标选择下拉框数据 |
| | |
| | | { |
| | | label: "检验值", |
| | | prop: "testValue", |
| | | dataType: 'slot', |
| | | slot: 'slot', |
| | | dataType: "slot", |
| | | slot: "slot", |
| | | }, |
| | | ]); |
| | | const quickCheckTableData = ref([]); |
| | | const quickCheckTableLoading = ref(false); |
| | | |
| | | const changeDaterange = (value) => { |
| | | const changeDaterange = value => { |
| | | searchForm.value.entryDateStart = undefined; |
| | | searchForm.value.entryDateEnd = undefined; |
| | | if (value) { |
| | |
| | | page.current = 1; |
| | | getList(); |
| | | }; |
| | | const pagination = (obj) => { |
| | | const pagination = obj => { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | getList(); |
| | |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | const params = { ...searchForm.value, ...page }; |
| | | params.entryDate = undefined |
| | | qualityInspectListPage({...params, inspectType: 2}).then(res => { |
| | | params.entryDate = undefined; |
| | | qualityInspectListPage({ ...params, inspectType: 2 }) |
| | | .then(res => { |
| | | tableLoading.value = false; |
| | | tableData.value = res.data.records |
| | | tableData.value = res.data.records; |
| | | page.total = res.data.total; |
| | | }).catch(err => { |
| | | tableLoading.value = false; |
| | | }) |
| | | .catch(err => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }; |
| | | // 表格选择数据 |
| | | const handleSelectionChange = (selection) => { |
| | | const handleSelectionChange = selection => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | |
| | | // 打开弹框 |
| | | const openForm = (type, row) => { |
| | | nextTick(() => { |
| | | formDia.value?.openDialog(type, row) |
| | | }) |
| | | formDia.value?.openDialog(type, row); |
| | | }); |
| | | }; |
| | | // 打开新增检验弹框 |
| | | const openInspectionForm = (type, row) => { |
| | | nextTick(() => { |
| | | inspectionFormDia.value?.openDialog(type, row) |
| | | }) |
| | | inspectionFormDia.value?.openDialog(type, row); |
| | | }); |
| | | }; |
| | | // 打开附件弹框 |
| | | const openFilesFormDia = (type, row) => { |
| | | nextTick(() => { |
| | | filesDia.value?.openDialog(type, row) |
| | | }) |
| | | filesDia.value?.openDialog(type, row); |
| | | }); |
| | | }; |
| | | |
| | | // 删除 |
| | | const handleDelete = () => { |
| | | let ids = []; |
| | | if (selectedRows.value.length > 0) { |
| | | ids = selectedRows.value.map((item) => item.id); |
| | | ids = selectedRows.value.map(item => item.id); |
| | | } else { |
| | | proxy.$modal.msgWarning("请选择数据"); |
| | | return; |
| | |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | qualityInspectDel(ids).then((res) => { |
| | | qualityInspectDel(ids).then(res => { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | getList(); |
| | | }); |
| | |
| | | // 构建导出参数 |
| | | const exportData = { |
| | | inspectType: 2, |
| | | process: searchForm.value.process || "", |
| | | productName: searchForm.value.productName || "", |
| | | entryDateStart: searchForm.value.entryDateStart || "", |
| | | entryDateEnd: searchForm.value.entryDateEnd || "", |
| | |
| | | } |
| | | |
| | | // 调用新导出接口 |
| | | qualityInspectExportNew(exportData).then((blobData) => { |
| | | qualityInspectExportNew(exportData) |
| | | .then(blobData => { |
| | | const blob = new Blob([blobData], { |
| | | type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
| | | type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", |
| | | }); |
| | | const downloadUrl = window.URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | const link = document.createElement("a"); |
| | | link.href = downloadUrl; |
| | | link.download = '出厂检验.xlsx'; |
| | | link.download = "出厂检验.xlsx"; |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | window.URL.revokeObjectURL(downloadUrl); |
| | | }).catch((error) => { |
| | | }) |
| | | .catch(error => { |
| | | proxy.$modal.msgError("导出失败"); |
| | | }); |
| | | }) |
| | |
| | | }; |
| | | |
| | | // 提价 |
| | | const submit = async (id) => { |
| | | const res = await submitQualityInspect({id: id}) |
| | | const submit = async id => { |
| | | const res = await submitQualityInspect({ id: id }); |
| | | if (res.code === 200) { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | getList(); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | |
| | | if (currentRow.value) { |
| | | const data = { |
| | | ...form.value, |
| | | id: currentRow.value.id |
| | | } |
| | | id: currentRow.value.id, |
| | | }; |
| | | qualityInspectUpdate(data).then(res => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeDia(); |
| | | getList(); |
| | | }) |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | const open = async (row) => { |
| | | const open = async row => { |
| | | let userLists = await userListNoPage(); |
| | | // 筛选 roleIds 包含 106 的用户 |
| | | userList.value = (userLists.data || []).filter(user => { |
| | | const roleIds = user.roleIds || []; |
| | | return roleIds.includes(106) || roleIds.includes('106'); |
| | | return roleIds.includes(106) || roleIds.includes("106"); |
| | | }); |
| | | currentRow.value = row |
| | | dialogFormVisible.value = true |
| | | } |
| | | currentRow.value = row; |
| | | dialogFormVisible.value = true; |
| | | }; |
| | | |
| | | const downLoadFile = (row) => { |
| | | downloadQualityInspect({ id: row.id }).then((blobData) => { |
| | | const downLoadFile = row => { |
| | | downloadQualityInspect({ id: row.id }).then(blobData => { |
| | | const blob = new Blob([blobData], { |
| | | type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
| | | }) |
| | | const downloadUrl = window.URL.createObjectURL(blob) |
| | | type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", |
| | | }); |
| | | const downloadUrl = window.URL.createObjectURL(blob); |
| | | |
| | | const link = document.createElement('a') |
| | | link.href = downloadUrl |
| | | link.download = '出厂检验报告.docx' |
| | | document.body.appendChild(link) |
| | | link.click() |
| | | const link = document.createElement("a"); |
| | | link.href = downloadUrl; |
| | | link.download = "出厂检验报告.docx"; |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | |
| | | document.body.removeChild(link) |
| | | window.URL.revokeObjectURL(downloadUrl) |
| | | }) |
| | | document.body.removeChild(link); |
| | | window.URL.revokeObjectURL(downloadUrl); |
| | | }); |
| | | }; |
| | | |
| | | // 打开检验结果选择对话框 |
| | | const openQuickCheck = async (row) => { |
| | | const openQuickCheck = async row => { |
| | | // 先调用详情接口获取完整数据(包含指标和检验值) |
| | | let detailData = row; |
| | | try { |
| | |
| | | const userLists = await userListNoPage(); |
| | | userList.value = (userLists.data || []).filter(user => { |
| | | const roleIds = user.roleIds || []; |
| | | return roleIds.includes(106) || roleIds.includes('106'); |
| | | return roleIds.includes(106) || roleIds.includes("106"); |
| | | }); |
| | | } catch (e) { |
| | | console.error("加载检验员列表失败", e); |
| | |
| | | try { |
| | | const params = { |
| | | productId: detailData.productId, |
| | | inspectType: 2 |
| | | inspectType: 2, |
| | | process: detailData.process || "", |
| | | }; |
| | | const res = await qualityInspectDetailByProductId(params); |
| | | testStandardOptions.value = res.data || []; |
| | |
| | | checkName: detailData.checkName || userStore.nickName || "", |
| | | checkTime: detailData.checkTime || dayjs().format("YYYY-MM-DD"), |
| | | testStandardId: detailData.testStandardId || "", |
| | | checkCompany: detailData.checkCompany || "" |
| | | checkCompany: detailData.checkCompany || "", |
| | | }; |
| | | // 如果有检验参数数据,回显到表格 |
| | | if (detailData.qualityInspectParams && detailData.qualityInspectParams.length > 0) { |
| | | if ( |
| | | detailData.qualityInspectParams && |
| | | detailData.qualityInspectParams.length > 0 |
| | | ) { |
| | | quickCheckTableData.value = detailData.qualityInspectParams; |
| | | } else { |
| | | quickCheckTableData.value = []; |
| | |
| | | }; |
| | | |
| | | // 指标选择变化处理 |
| | | const handleTestStandardChange = (testStandardId) => { |
| | | const handleTestStandardChange = testStandardId => { |
| | | if (!testStandardId) { |
| | | quickCheckTableData.value = []; |
| | | return; |
| | | } |
| | | quickCheckTableLoading.value = true; |
| | | getQualityTestStandardParamByTestStandardId(testStandardId).then(res => { |
| | | getQualityTestStandardParamByTestStandardId(testStandardId) |
| | | .then(res => { |
| | | quickCheckTableData.value = res.data || []; |
| | | }).catch(error => { |
| | | console.error('获取标准参数失败:', error); |
| | | }) |
| | | .catch(error => { |
| | | console.error("获取标准参数失败:", error); |
| | | quickCheckTableData.value = []; |
| | | }).finally(() => { |
| | | }) |
| | | .finally(() => { |
| | | quickCheckTableLoading.value = false; |
| | | }); |
| | | }; |
| | |
| | | checkName: "", |
| | | checkTime: "", |
| | | testStandardId: "", |
| | | checkCompany: "" |
| | | checkCompany: "", |
| | | }; |
| | | quickCheckTableData.value = []; |
| | | testStandardOptions.value = []; |
| | |
| | | testStandardId: testStandardIdToPass, |
| | | checkCompany: checkCompanyToPass, |
| | | inspectType: 2, |
| | | qualityInspectParams: qualityInspectParamsToPass |
| | | qualityInspectParams: qualityInspectParamsToPass, |
| | | }; |
| | | qualityInspectUpdate(data).then(res => { |
| | | proxy.$modal.msgSuccess("检验成功"); |
| | |
| | | currentRow.value.checkTime = checkTimeToPass; |
| | | currentRow.value.checkCompany = checkCompanyToPass; |
| | | currentRow.value.testStandardId = testStandardIdToPass; |
| | | formDia.value?.openDialog("edit", currentRow.value, checkResultToPass, checkNameToPass, testStandardIdToPass, checkCompanyToPass, qualityInspectParamsToPass); |
| | | formDia.value?.openDialog( |
| | | "edit", |
| | | currentRow.value, |
| | | checkResultToPass, |
| | | checkNameToPass, |
| | | testStandardIdToPass, |
| | | checkCompanyToPass, |
| | | qualityInspectParamsToPass |
| | | ); |
| | | }); |
| | | } |
| | | }; |
| | |
| | | <template> |
| | | <div class="app-container metric-binding"> |
| | | <el-tabs v-model="activeTab" @tab-change="handleTabChange" class="metric-tabs"> |
| | | <el-tab-pane label="原材料检验" name="0" /> |
| | | <el-tab-pane label="过程检验" name="1" /> |
| | | <el-tab-pane label="出厂检验" name="2" /> |
| | | <el-tabs v-model="activeTab" |
| | | @tab-change="handleTabChange" |
| | | class="metric-tabs"> |
| | | <el-tab-pane label="原材料检验" |
| | | name="0" /> |
| | | <el-tab-pane label="过程检验" |
| | | name="1" /> |
| | | <el-tab-pane label="出厂检验" |
| | | name="2" /> |
| | | </el-tabs> |
| | | <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" |
| | | <PIMTable rowKey="id" |
| | | :column="standardColumns" |
| | | :tableData="standardTableData" |
| | | :page="page" |
| | |
| | | :tableLoading="tableLoading" |
| | | :rowClick="handleTableRowClick" |
| | | @pagination="handlePagination" |
| | | :total="page.total" |
| | | > |
| | | :total="page.total"> |
| | | <template #standardNoCell="{ row }"> |
| | | <span class="clickable-link" @click="handleStandardRowClick(row)"> |
| | | <span class="clickable-link" |
| | | @click="handleStandardRowClick(row)"> |
| | | {{ row.standardNo }} |
| | | </span> |
| | | </template> |
| | | |
| | | <!-- 表头搜索 --> |
| | | <template #standardNoHeader> |
| | | <el-input |
| | | v-model="searchForm.standardNo" |
| | | <el-input v-model="searchForm.standardNo" |
| | | placeholder="标准编号" |
| | | clearable |
| | | size="small" |
| | | @change="handleQuery" |
| | | @clear="handleQuery" |
| | | /> |
| | | @clear="handleQuery" /> |
| | | </template> |
| | | <template #standardNameHeader> |
| | | <el-input |
| | | v-model="searchForm.standardName" |
| | | <el-input v-model="searchForm.standardName" |
| | | placeholder="标准名称" |
| | | clearable |
| | | size="small" |
| | | @change="handleQuery" |
| | | @clear="handleQuery" |
| | | /> |
| | | @clear="handleQuery" /> |
| | | </template> |
| | | <template #stateHeader> |
| | | <el-select |
| | | v-model="searchForm.state" |
| | | <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" /> |
| | | @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"> |
| | | <div class="desc" |
| | | v-if="currentStandard"> |
| | | 当前检测标准编号:<span class="link-text">{{ currentStandard.standardNo }}</span> |
| | | </div> |
| | | <div class="desc" v-else>请选择左侧检测标准</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> |
| | | <el-button type="primary" |
| | | :disabled="!currentStandard" |
| | | @click="openBindingDialog">添加绑定</el-button> |
| | | <el-button v-if="activeTab === '1' || activeTab === '2'" |
| | | type="primary" |
| | | :disabled="!leftProcessOptions.length" |
| | | @click="openProcessBindingDialog">按工序批量绑定</el-button> |
| | | <el-button type="danger" |
| | | plain |
| | | :disabled="!currentStandard" |
| | | @click="handleBatchUnbind">删除</el-button> |
| | | </div> |
| | | |
| | | <el-table |
| | | v-loading="bindingLoading" |
| | | <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"> |
| | | @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> |
| | | <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" |
| | | <el-dialog v-model="bindingDialogVisible" |
| | | title="添加绑定" |
| | | width="520px" |
| | | @close="closeBindingDialog" |
| | | > |
| | | @close="closeBindingDialog"> |
| | | <el-form label-width="100px"> |
| | | <el-form-item label="产品"> |
| | | <el-tree-select |
| | | v-model="selectedProductIds" |
| | | <el-tree-select v-model="selectedProductIds" |
| | | multiple |
| | | collapse-tags |
| | | collapse-tags-tooltip |
| | |
| | | check-strictly |
| | | :data="productOptions" |
| | | :render-after-expand="false" |
| | | style="width: 100%" |
| | | /> |
| | | 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> |
| | | <el-dialog v-model="processBindingDialogVisible" |
| | | title="按工序批量绑定" |
| | | width="520px" |
| | | @close="closeProcessBindingDialog"> |
| | | <el-form label-width="100px"> |
| | | <el-form-item label="产品"> |
| | | <el-tree-select v-model="processBindingProductIds" |
| | | multiple |
| | | collapse-tags |
| | | collapse-tags-tooltip |
| | | placeholder="请选择产品(可多选)" |
| | | clearable |
| | | check-strictly |
| | | :data="productOptions" |
| | | :render-after-expand="false" |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | <el-form-item label="工序"> |
| | | <el-select v-model="processBindingProcessIds" |
| | | multiple |
| | | filterable |
| | | clearable |
| | | collapse-tags |
| | | collapse-tags-tooltip |
| | | placeholder="请选择工序(必选,可多选)" |
| | | style="width: 100%"> |
| | | <el-option v-for="item in leftProcessOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="closeProcessBindingDialog">取消</el-button> |
| | | <el-button type="primary" |
| | | @click="submitProcessBinding">确定</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | |
| | | </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 { Search } from "@element-plus/icons-vue"; |
| | | import { |
| | | qualityTestStandardListPage |
| | | } from '@/api/qualityManagement/metricMaintenance.js' |
| | | import { productProcessListPage } from '@/api/basicData/productProcess.js' |
| | | ref, |
| | | reactive, |
| | | toRefs, |
| | | onMounted, |
| | | getCurrentInstance, |
| | | computed, |
| | | } 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' |
| | | qualityTestStandardBindingDel, |
| | | } from "@/api/qualityManagement/qualityTestStandardBinding.js"; |
| | | |
| | | const { proxy } = getCurrentInstance() |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | // 类别 Tab(0=原材料,1=过程,2=出厂) |
| | | const activeTab = ref('0') |
| | | const activeTab = ref("0"); |
| | | |
| | | // 左侧标准列表:整行内容居中(配合样式) |
| | | const rowClassNameCenter = () => 'row-center' |
| | | const rowClassNameCenter = () => "row-center"; |
| | | |
| | | const data = reactive({ |
| | | searchForm: { |
| | | standardNo: '', |
| | | standardName: '', |
| | | state: '', |
| | | inspectType: '' |
| | | } |
| | | }) |
| | | const { searchForm } = toRefs(data) |
| | | 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 standardTableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ current: 1, size: 10, total: 0 }); |
| | | |
| | | // 工序下拉(用于列表回显) |
| | | const processOptions = ref([]) |
| | | const processOptions = ref([]); |
| | | |
| | | const getProcessList = async () => { |
| | | try { |
| | | const res = await productProcessListPage({ current: 1, size: 1000 }) |
| | | const res = await productProcessListPage({ current: 1, size: 1000 }); |
| | | if (res?.code === 200) { |
| | | const records = res?.data?.records || [] |
| | | processOptions.value = records.map((item) => ({ |
| | | const records = res?.data?.records || []; |
| | | processOptions.value = records.map(item => ({ |
| | | label: item.processName || item.name || item.label, |
| | | value: item.id || item.processId || item.value |
| | | })) |
| | | value: item.id || item.processId || item.value, |
| | | })); |
| | | } |
| | | } catch (error) { |
| | | console.error('获取工序列表失败:', 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', |
| | | 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', |
| | | label: "标准编号", |
| | | prop: "standardNo", |
| | | dataType: "slot", |
| | | slot: "standardNoCell", |
| | | minWidth: 160, |
| | | align: 'center' |
| | | } |
| | | align: "center", |
| | | headerSlot: "standardNoHeader", |
| | | }, |
| | | { |
| | | label: "标准名称", |
| | | prop: "standardName", |
| | | minWidth: 180, |
| | | align: "center", |
| | | headerSlot: "standardNameHeader", |
| | | }, |
| | | { |
| | | label: "类别", |
| | | prop: "inspectType", |
| | | 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', |
| | |
| | | // return 'info' |
| | | // } |
| | | // } |
| | | ]) |
| | | ]); |
| | | |
| | | const handleTabChange = () => { |
| | | searchForm.value.standardNo = '' |
| | | searchForm.value.standardName = '' |
| | | searchForm.value.state = '' |
| | | searchForm.value.inspectType = activeTab.value |
| | | page.current = 1 |
| | | currentStandard.value = null |
| | | bindingTableData.value = [] |
| | | bindingSelectedRows.value = [] |
| | | getStandardList() |
| | | } |
| | | searchForm.value.standardNo = ""; |
| | | searchForm.value.standardName = ""; |
| | | searchForm.value.state = ""; |
| | | searchForm.value.inspectType = activeTab.value; |
| | | page.current = 1; |
| | | currentStandard.value = null; |
| | | bindingTableData.value = []; |
| | | bindingSelectedRows.value = []; |
| | | bindingDialogVisible.value = false; |
| | | processBindingDialogVisible.value = false; |
| | | getStandardList(); |
| | | }; |
| | | |
| | | const currentStandard = ref(null) |
| | | const currentStandard = ref(null); |
| | | |
| | | // 右侧绑定 |
| | | const bindingTableData = ref([]) |
| | | const bindingLoading = ref(false) |
| | | const bindingSelectedRows = ref([]) |
| | | const bindingDialogVisible = ref(false) |
| | | const bindingTableData = ref([]); |
| | | const bindingLoading = ref(false); |
| | | const bindingSelectedRows = ref([]); |
| | | const bindingDialogVisible = ref(false); |
| | | const processBindingDialogVisible = ref(false); |
| | | |
| | | // 产品树(用于绑定选择) |
| | | const productOptions = ref([]) |
| | | const selectedProductIds = ref([]) |
| | | const productOptions = ref([]); |
| | | const selectedProductIds = ref([]); |
| | | const processBindingProductIds = ref([]); |
| | | const processBindingProcessIds = ref([]); |
| | | const leftProcessOptions = computed(() => { |
| | | const ids = new Set( |
| | | (standardTableData.value || []) |
| | | .map(i => i?.processId) |
| | | .filter(v => v !== null && v !== undefined && String(v) !== "") |
| | | .map(v => String(v)) |
| | | ); |
| | | if (!ids.size) return []; |
| | | return (processOptions.value || []) |
| | | .filter(p => ids.has(String(p.value))) |
| | | .sort((a, b) => String(a.label).localeCompare(String(b.label), "zh-CN")); |
| | | }); |
| | | |
| | | const getProductOptions = async () => { |
| | | // 避免重复请求 |
| | | if (productOptions.value?.length) return |
| | | const res = await productTreeList() |
| | | productOptions.value = convertIdToValue(Array.isArray(res) ? res : []) |
| | | } |
| | | 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 |
| | | return (data || []).map(item => { |
| | | const { id, children, ...rest } = item; |
| | | const newItem = { |
| | | ...rest, |
| | | value: id |
| | | } |
| | | value: id, |
| | | }; |
| | | if (children && children.length > 0) { |
| | | newItem.children = convertIdToValue(children) |
| | | newItem.children = convertIdToValue(children); |
| | | } |
| | | return newItem |
| | | }) |
| | | return newItem; |
| | | }); |
| | | } |
| | | |
| | | const handleQuery = () => { |
| | | page.current = 1 |
| | | getStandardList() |
| | | } |
| | | page.current = 1; |
| | | getStandardList(); |
| | | }; |
| | | |
| | | const handlePagination = (obj) => { |
| | | page.current = obj.page |
| | | page.size = obj.limit |
| | | getStandardList() |
| | | } |
| | | const handlePagination = obj => { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | getStandardList(); |
| | | }; |
| | | |
| | | const getStandardList = () => { |
| | | tableLoading.value = true |
| | | tableLoading.value = true; |
| | | qualityTestStandardListPage({ |
| | | ...searchForm.value, |
| | | current: page.current, |
| | | size: page.size, |
| | | state: 1 |
| | | state: 1, |
| | | }) |
| | | .then((res) => { |
| | | const records = res?.data?.records || [] |
| | | standardTableData.value = records |
| | | page.total = res?.data?.total || records.length |
| | | .then(res => { |
| | | const records = res?.data?.records || []; |
| | | standardTableData.value = records; |
| | | page.total = res?.data?.total || records.length; |
| | | }) |
| | | .finally(() => { |
| | | tableLoading.value = false |
| | | }) |
| | | } |
| | | 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 |
| | | bindingTableData.value = []; |
| | | return; |
| | | } |
| | | bindingLoading.value = true |
| | | bindingLoading.value = true; |
| | | qualityTestStandardBindingList({ testStandardId: currentStandard.value.id }) |
| | | .then((res) => { |
| | | const base = res?.data || [] |
| | | .then(res => { |
| | | const base = res?.data || []; |
| | | // 将当前标准的工序和备注带到绑定列表中展示 |
| | | bindingTableData.value = base.map((item) => ({ |
| | | bindingTableData.value = base.map(item => ({ |
| | | ...item, |
| | | processId: currentStandard.value?.processId, |
| | | remark: currentStandard.value?.remark |
| | | })) |
| | | remark: currentStandard.value?.remark, |
| | | })); |
| | | }) |
| | | .finally(() => { |
| | | bindingLoading.value = false |
| | | }) |
| | | } |
| | | 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 |
| | | } |
| | | if (!currentStandard.value?.id) return; |
| | | selectedProductIds.value = []; |
| | | getProductOptions(); |
| | | bindingDialogVisible.value = true; |
| | | }; |
| | | |
| | | const closeBindingDialog = () => { |
| | | bindingDialogVisible.value = false |
| | | } |
| | | bindingDialogVisible.value = false; |
| | | }; |
| | | |
| | | const openProcessBindingDialog = () => { |
| | | if (activeTab.value !== "1" && activeTab.value !== "2") return; |
| | | processBindingProductIds.value = []; |
| | | processBindingProcessIds.value = []; |
| | | getProductOptions(); |
| | | processBindingDialogVisible.value = true; |
| | | }; |
| | | |
| | | const closeProcessBindingDialog = () => { |
| | | processBindingDialogVisible.value = false; |
| | | }; |
| | | |
| | | const submitBinding = async () => { |
| | | const testStandardId = currentStandard.value?.id |
| | | if (!testStandardId) return |
| | | const ids = (selectedProductIds.value || []).filter(Boolean) |
| | | const ids = (selectedProductIds.value || []).filter(Boolean); |
| | | if (!ids.length) { |
| | | proxy.$message.warning('请选择产品') |
| | | return |
| | | proxy.$message.warning("请选择产品"); |
| | | return; |
| | | } |
| | | const payload = ids.map((pid) => ({ |
| | | const testStandardId = currentStandard.value?.id; |
| | | if (!testStandardId) return; |
| | | const payload = ids.map(pid => ({ |
| | | productId: pid, |
| | | testStandardId |
| | | })) |
| | | await qualityTestStandardBindingAdd(payload) |
| | | proxy.$message.success('添加成功') |
| | | bindingDialogVisible.value = false |
| | | loadBindingList() |
| | | testStandardId, |
| | | })); |
| | | await qualityTestStandardBindingAdd(payload); |
| | | proxy.$message.success("添加成功"); |
| | | bindingDialogVisible.value = false; |
| | | loadBindingList(); |
| | | }; |
| | | |
| | | const submitProcessBinding = async () => { |
| | | const ids = (processBindingProductIds.value || []).filter(Boolean); |
| | | if (!ids.length) { |
| | | proxy.$message.warning("请选择产品"); |
| | | return; |
| | | } |
| | | const processIds = (processBindingProcessIds.value || []).filter(Boolean); |
| | | if (!processIds.length) { |
| | | proxy.$message.warning("请选择工序"); |
| | | return; |
| | | } |
| | | const allow = new Set(leftProcessOptions.value.map(i => String(i.value))); |
| | | const processIdSet = new Set(processIds.map(i => String(i))); |
| | | for (const pid of processIdSet) { |
| | | if (!allow.has(pid)) { |
| | | proxy.$message.warning("所选工序必须在左侧列表中出现过"); |
| | | return; |
| | | } |
| | | } |
| | | const standards = (standardTableData.value || []).filter(s => |
| | | processIdSet.has(String(s?.processId)) |
| | | ); |
| | | if (!standards.length) { |
| | | proxy.$message.warning("左侧列表未找到匹配工序的检测标准"); |
| | | return; |
| | | } |
| | | |
| | | const handleUnbind = async (row) => { |
| | | const id = row?.id ?? row?.qualityTestStandardBindingId |
| | | if (id == null || id === '') return |
| | | const uniq = new Set(); |
| | | const payload = []; |
| | | for (const std of standards) { |
| | | const testStandardId = std?.id; |
| | | if (!testStandardId) continue; |
| | | for (const pid of ids) { |
| | | const key = `${String(testStandardId)}__${String(pid)}`; |
| | | if (uniq.has(key)) continue; |
| | | uniq.add(key); |
| | | payload.push({ |
| | | productId: pid, |
| | | testStandardId, |
| | | }); |
| | | } |
| | | } |
| | | if (!payload.length) { |
| | | proxy.$message.warning("未生成有效绑定数据"); |
| | | return; |
| | | } |
| | | await qualityTestStandardBindingAdd(payload); |
| | | proxy.$message.success(`已添加 ${payload.length} 条绑定`); |
| | | processBindingDialogVisible.value = false; |
| | | if (currentStandard.value?.id) { |
| | | loadBindingList(); |
| | | } |
| | | }; |
| | | |
| | | const handleUnbind = async row => { |
| | | const id = row?.id ?? row?.qualityTestStandardBindingId; |
| | | if (id == null || id === "") return; |
| | | try { |
| | | await ElMessageBox.confirm('确认删除该绑定?', '提示', { type: 'warning' }) |
| | | await ElMessageBox.confirm("确认删除该绑定?", "提示", { type: "warning" }); |
| | | } catch { |
| | | return |
| | | return; |
| | | } |
| | | try { |
| | | await qualityTestStandardBindingDel([id]) |
| | | proxy.$message.success('删除成功') |
| | | loadBindingList() |
| | | await qualityTestStandardBindingDel([id]); |
| | | proxy.$message.success("删除成功"); |
| | | loadBindingList(); |
| | | } catch (err) { |
| | | console.error('删除绑定失败:', err) |
| | | proxy.$message?.error(err?.message || '删除失败') |
| | | console.error("删除绑定失败:", err); |
| | | proxy.$message?.error(err?.message || "删除失败"); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | const handleBatchUnbind = async () => { |
| | | if (!bindingSelectedRows.value.length) { |
| | | proxy.$message.warning('请选择数据') |
| | | return |
| | | proxy.$message.warning("请选择数据"); |
| | | return; |
| | | } |
| | | const ids = bindingSelectedRows.value |
| | | .map((i) => i?.id ?? i?.qualityTestStandardBindingId) |
| | | .filter((id) => id != null && id !== '') |
| | | .map(i => i?.id ?? i?.qualityTestStandardBindingId) |
| | | .filter(id => id != null && id !== ""); |
| | | if (!ids.length) { |
| | | proxy.$message.warning('选中数据缺少有效 id') |
| | | return |
| | | proxy.$message.warning("选中数据缺少有效 id"); |
| | | return; |
| | | } |
| | | try { |
| | | await ElMessageBox.confirm('选中的内容将被删除,是否确认删除?', '删除提示', { type: 'warning' }) |
| | | await ElMessageBox.confirm( |
| | | "选中的内容将被删除,是否确认删除?", |
| | | "删除提示", |
| | | { type: "warning" } |
| | | ); |
| | | } catch { |
| | | return |
| | | return; |
| | | } |
| | | try { |
| | | await qualityTestStandardBindingDel(ids) |
| | | proxy.$message.success('删除成功') |
| | | loadBindingList() |
| | | await qualityTestStandardBindingDel(ids); |
| | | proxy.$message.success("删除成功"); |
| | | loadBindingList(); |
| | | } catch (err) { |
| | | console.error('批量删除绑定失败:', err) |
| | | proxy.$message?.error(err?.message || '删除失败') |
| | | console.error("批量删除绑定失败:", err); |
| | | proxy.$message?.error(err?.message || "删除失败"); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | searchForm.value.inspectType = activeTab.value |
| | | getStandardList() |
| | | getProcessList() |
| | | }) |
| | | searchForm.value.inspectType = activeTab.value; |
| | | getStandardList(); |
| | | getProcessList(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | <template> |
| | | <FormDialog |
| | | v-model="dialogVisible" |
| | | <FormDialog v-model="dialogVisible" |
| | | :title="computedTitle" |
| | | :operation-type="operationType" |
| | | :width="width" |
| | | @close="emit('close')" |
| | | @cancel="handleCancel" |
| | | @confirm="handleConfirm" |
| | | > |
| | | <el-form |
| | | ref="formRef" |
| | | @confirm="handleConfirm"> |
| | | <el-form ref="formRef" |
| | | :model="form" |
| | | :rules="rules" |
| | | label-width="100px" |
| | | > |
| | | <el-form-item label="标准编号" prop="standardNo"> |
| | | <el-input v-model="form.standardNo" placeholder="请输入标准编号" /> |
| | | label-width="100px"> |
| | | <el-form-item label="标准编号" |
| | | prop="standardNo"> |
| | | <el-input v-model="form.standardNo" |
| | | placeholder="请输入标准编号" /> |
| | | </el-form-item> |
| | | <el-form-item label="标准名称" prop="standardName"> |
| | | <el-input v-model="form.standardName" placeholder="请输入标准名称" /> |
| | | <el-form-item label="标准名称" |
| | | prop="standardName"> |
| | | <el-input v-model="form.standardName" |
| | | placeholder="请输入标准名称" /> |
| | | </el-form-item> |
| | | <el-form-item v-if="needProcess" label="工序" prop="processId"> |
| | | <el-select v-model="form.processId" placeholder="请选择工序" style="width: 100%"> |
| | | <el-option |
| | | v-for="item in processOptions" |
| | | <el-form-item v-if="needProcess" |
| | | label="工序" |
| | | prop="processId"> |
| | | <el-select v-model="form.processId" |
| | | placeholder="请选择工序" |
| | | style="width: 100%"> |
| | | <el-option v-for="item in processOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | :value="item.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="state"> |
| | | <el-select v-model="form.state" placeholder="请选择状态" style="width: 100%"> |
| | | <el-option label="草稿" value="0" /> |
| | | <el-option label="通过" value="1" /> |
| | | <el-option label="撤销" value="2" /> |
| | | <el-form-item label="状态" |
| | | prop="state"> |
| | | <el-select v-model="form.state" |
| | | placeholder="请选择状态" |
| | | style="width: 100%"> |
| | | <el-option label="草稿" |
| | | value="0" /> |
| | | <el-option label="通过" |
| | | value="1" /> |
| | | <el-option label="撤销" |
| | | value="2" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="备注" prop="remark"> |
| | | <el-input |
| | | v-model="form.remark" |
| | | <el-form-item label="备注" |
| | | prop="remark"> |
| | | <el-input v-model="form.remark" |
| | | type="textarea" |
| | | :rows="3" |
| | | placeholder="请输入备注" |
| | | /> |
| | | placeholder="请输入备注" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | </FormDialog> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { computed, ref } from 'vue' |
| | | import FormDialog from '@/components/Dialog/FormDialog.vue' |
| | | import { computed, ref } from "vue"; |
| | | import FormDialog from "@/components/Dialog/FormDialog.vue"; |
| | | |
| | | const props = defineProps({ |
| | | modelValue: { |
| | | type: Boolean, |
| | | default: false |
| | | default: false, |
| | | }, |
| | | operationType: { |
| | | type: String, |
| | | default: 'add' |
| | | default: "add", |
| | | }, |
| | | form: { |
| | | type: Object, |
| | | required: true |
| | | required: true, |
| | | }, |
| | | rules: { |
| | | type: Object, |
| | | default: () => ({}) |
| | | default: () => ({}), |
| | | }, |
| | | processOptions: { |
| | | type: Array, |
| | | default: () => [] |
| | | default: () => [], |
| | | }, |
| | | width: { |
| | | type: String, |
| | | default: '500px' |
| | | default: "500px", |
| | | }, |
| | | inspectType:{ |
| | | type: String, |
| | | default: null |
| | | } |
| | | }) |
| | | default: null, |
| | | }, |
| | | }); |
| | | |
| | | const emit = defineEmits(['update:modelValue', 'close', 'cancel', 'confirm']) |
| | | const emit = defineEmits(["update:modelValue", "close", "cancel", "confirm"]); |
| | | |
| | | const dialogVisible = computed({ |
| | | get: () => props.modelValue, |
| | | set: (val) => emit('update:modelValue', val) |
| | | }) |
| | | set: val => emit("update:modelValue", val), |
| | | }); |
| | | |
| | | const formRef = ref(null) |
| | | const formRef = ref(null); |
| | | |
| | | const needProcess = computed(() => String(props.inspectType ?? '') === '1') |
| | | const needProcess = computed(() => |
| | | ["1", "2"].includes(String(props.inspectType ?? "")) |
| | | ); |
| | | |
| | | const computedTitle = computed(() => { |
| | | if (props.operationType === 'edit') return '编辑检测标准' |
| | | if (props.operationType === 'copy') return '复制检测标准' |
| | | return '新增检测标准' |
| | | }) |
| | | if (props.operationType === "edit") return "编辑检测标准"; |
| | | if (props.operationType === "copy") return "复制检测标准"; |
| | | return "新增检测标准"; |
| | | }); |
| | | |
| | | const handleConfirm = () => { |
| | | if (!formRef.value) { |
| | | emit('confirm') |
| | | return |
| | | emit("confirm"); |
| | | return; |
| | | } |
| | | formRef.value.validate((valid) => { |
| | | formRef.value.validate(valid => { |
| | | if (valid) { |
| | | emit('confirm') |
| | | emit("confirm"); |
| | | } |
| | | }) |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | const handleCancel = () => { |
| | | emit('cancel') |
| | | dialogVisible.value = false |
| | | } |
| | | emit("cancel"); |
| | | dialogVisible.value = false; |
| | | }; |
| | | |
| | | const resetFields = () => { |
| | | formRef.value?.resetFields?.() |
| | | } |
| | | formRef.value?.resetFields?.(); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | resetFields |
| | | }) |
| | | resetFields, |
| | | }); |
| | | </script> |
| | |
| | | <template> |
| | | <div class="app-container metric-maintenance"> |
| | | <el-tabs v-model="activeTab" @tab-change="handleTabChange" class="metric-tabs"> |
| | | <el-tab-pane label="原材料检验" name="0" /> |
| | | <el-tab-pane label="过程检验" name="1" /> |
| | | <el-tab-pane label="出厂检验" name="2" /> |
| | | <el-tabs v-model="activeTab" |
| | | @tab-change="handleTabChange" |
| | | class="metric-tabs"> |
| | | <el-tab-pane label="原材料检验" |
| | | name="0" /> |
| | | <el-tab-pane label="过程检验" |
| | | name="1" /> |
| | | <el-tab-pane label="出厂检验" |
| | | name="2" /> |
| | | </el-tabs> |
| | | <el-row :gutter="16" class="metric-maintenance-row"> |
| | | <el-row :gutter="16" |
| | | class="metric-maintenance-row"> |
| | | <!-- 左侧:检测标准列表 --> |
| | | <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="left-col"> |
| | | <el-col :xs="24" |
| | | :sm="24" |
| | | :md="12" |
| | | :lg="12" |
| | | :xl="12" |
| | | class="left-col"> |
| | | <div class="left-panel"> |
| | | <div class="toolbar"> |
| | | <div class="toolbar-left"></div> |
| | | <div class="toolbar-right"> |
| | | <el-button type="primary" @click="openStandardDialog('add')">新增</el-button> |
| | | <el-button type="success" plain @click="handleBatchAudit(1)">批准</el-button> |
| | | <el-button type="warning" plain @click="handleBatchAudit(2)">撤销</el-button> |
| | | <el-button type="danger" plain @click="handleBatchDelete">删除</el-button> |
| | | <el-button type="primary" |
| | | @click="openStandardDialog('add')">新增</el-button> |
| | | <el-button type="success" |
| | | plain |
| | | @click="handleBatchAudit(1)">批准</el-button> |
| | | <el-button type="warning" |
| | | plain |
| | | @click="handleBatchAudit(2)">撤销</el-button> |
| | | <el-button type="danger" |
| | | plain |
| | | @click="handleBatchDelete">删除</el-button> |
| | | </div> |
| | | </div> |
| | | <PIMTable |
| | | rowKey="id" |
| | | <PIMTable rowKey="id" |
| | | :column="standardColumns" |
| | | :tableData="standardTableData" |
| | | :page="page" |
| | |
| | | :rowClick="handleTableRowClick" |
| | | @selection-change="handleSelectionChange" |
| | | @pagination="handlePagination" |
| | | :total="page.total" |
| | | > |
| | | :total="page.total"> |
| | | <template #standardNoCell="{ row }"> |
| | | <span class="clickable-link" @click="handleStandardRowClick(row)"> |
| | | <span class="clickable-link" |
| | | @click="handleStandardRowClick(row)"> |
| | | {{ row.standardNo }} |
| | | </span> |
| | | </template> |
| | | |
| | | <!-- 表头搜索插槽 --> |
| | | <template #standardNoHeader> |
| | | <el-input |
| | | v-model="searchForm.standardNo" |
| | | <el-input v-model="searchForm.standardNo" |
| | | placeholder="标准编号" |
| | | clearable |
| | | size="small" |
| | | @change="handleQuery" |
| | | @clear="handleQuery" |
| | | /> |
| | | @clear="handleQuery" /> |
| | | </template> |
| | | <template #standardNameHeader> |
| | | <el-input |
| | | v-model="searchForm.standardName" |
| | | <el-input v-model="searchForm.standardName" |
| | | placeholder="标准名称" |
| | | clearable |
| | | size="small" |
| | | @change="handleQuery" |
| | | @clear="handleQuery" |
| | | /> |
| | | @clear="handleQuery" /> |
| | | </template> |
| | | <template #stateHeader> |
| | | <el-select |
| | | v-model="searchForm.state" |
| | | <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" /> |
| | | @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="12" :xl="12" class="right-col"> |
| | | <el-col :xs="24" |
| | | :sm="24" |
| | | :md="12" |
| | | :lg="12" |
| | | :xl="12" |
| | | class="right-col"> |
| | | <div class="right-panel"> |
| | | <div class="right-header"> |
| | | <div class="title">标准参数</div> |
| | | <div class="desc" v-if="currentStandard"> |
| | | <div class="desc" |
| | | v-if="currentStandard"> |
| | | 您当前选择的检测标准编号是: |
| | | <span class="link-text">{{ currentStandard.standardNo }}</span> |
| | | </div> |
| | | <div class="desc" v-else>请先在左侧选择一个检测标准</div> |
| | | <div class="desc" |
| | | v-else>请先在左侧选择一个检测标准</div> |
| | | </div> |
| | | |
| | | <div class="right-toolbar"> |
| | | <el-button type="primary" :disabled="!currentStandard || isStandardReadonly" @click="openParamDialog('add')"> |
| | | <el-button type="primary" |
| | | :disabled="!currentStandard || isStandardReadonly" |
| | | @click="openParamDialog('add')"> |
| | | 新增 |
| | | </el-button> |
| | | <el-button type="danger" plain :disabled="!currentStandard || isStandardReadonly" @click="handleParamBatchDelete"> |
| | | <el-button type="danger" |
| | | plain |
| | | :disabled="!currentStandard || isStandardReadonly" |
| | | @click="handleParamBatchDelete"> |
| | | 删除 |
| | | </el-button> |
| | | </div> |
| | | |
| | | <el-table |
| | | v-loading="detailLoading" |
| | | <el-table v-loading="detailLoading" |
| | | :data="detailTableData" |
| | | border |
| | | :row-class-name="() => 'row-center'" |
| | | class="center-table" |
| | | style="width: 100%" |
| | | height="calc(100vh - 220px)" |
| | | @selection-change="handleParamSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="48" align="center" /> |
| | | <el-table-column type="index" label="序号" width="60" align="center" /> |
| | | <el-table-column prop="parameterItem" label="参数项" min-width="120" /> |
| | | <el-table-column prop="unit" label="单位" width="80" /> |
| | | <el-table-column prop="standardValue" label="标准值" min-width="120" /> |
| | | <el-table-column prop="controlValue" label="内控值" min-width="120" /> |
| | | <el-table-column prop="defaultValue" label="默认值" min-width="120" /> |
| | | <el-table-column label="操作" width="140" fixed="right" align="center"> |
| | | @selection-change="handleParamSelectionChange"> |
| | | <el-table-column type="selection" |
| | | width="48" |
| | | align="center" /> |
| | | <el-table-column type="index" |
| | | label="序号" |
| | | width="60" |
| | | align="center" /> |
| | | <el-table-column prop="parameterItem" |
| | | label="参数项" |
| | | min-width="120" /> |
| | | <el-table-column prop="unit" |
| | | label="单位" |
| | | width="80" /> |
| | | <el-table-column prop="standardValue" |
| | | label="标准值" |
| | | min-width="120" /> |
| | | <el-table-column prop="controlValue" |
| | | label="内控值" |
| | | min-width="120" /> |
| | | <el-table-column prop="defaultValue" |
| | | label="默认值" |
| | | min-width="120" /> |
| | | <el-table-column label="操作" |
| | | width="140" |
| | | fixed="right" |
| | | align="center"> |
| | | <template #default="{ row }"> |
| | | <el-button link type="primary" size="small" :disabled="isStandardReadonly" @click="openParamDialog('edit', row)"> |
| | | <el-button link |
| | | type="primary" |
| | | size="small" |
| | | :disabled="isStandardReadonly" |
| | | @click="openParamDialog('edit', row)"> |
| | | 编辑 |
| | | </el-button> |
| | | <el-button link type="danger" size="small" :disabled="isStandardReadonly" @click="handleParamDelete(row)"> |
| | | <el-button link |
| | | type="danger" |
| | | size="small" |
| | | :disabled="isStandardReadonly" |
| | | @click="handleParamDelete(row)"> |
| | | 删除 |
| | | </el-button> |
| | | </template> |
| | |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <!-- 新增 / 编辑检测标准 --> |
| | | <StandardFormDialog |
| | | ref="standardFormDialogRef" |
| | | <StandardFormDialog ref="standardFormDialogRef" |
| | | v-model="standardDialogVisible" |
| | | :operation-type="standardOperationType" |
| | | :form="standardForm" |
| | |
| | | :process-options="processOptions" |
| | | @confirm="submitStandardForm" |
| | | @close="closeStandardDialog" |
| | | @cancel="closeStandardDialog" |
| | | /> |
| | | |
| | | <ParamFormDialog |
| | | ref="paramFormDialogRef" |
| | | @cancel="closeStandardDialog" /> |
| | | <ParamFormDialog ref="paramFormDialogRef" |
| | | v-model="paramDialogVisible" |
| | | :operation-type="paramOperationType" |
| | | :inspectType="activeTab.value" |
| | | :form="paramForm" |
| | | @confirm="submitParamForm" |
| | | @close="closeParamDialog" |
| | | @cancel="closeParamDialog" |
| | | /> |
| | | @cancel="closeParamDialog" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { Search } from '@element-plus/icons-vue' |
| | | import { ref, reactive, toRefs, onMounted, getCurrentInstance, computed } from 'vue' |
| | | import { ElMessageBox } from 'element-plus' |
| | | import { Search } from "@element-plus/icons-vue"; |
| | | import { |
| | | ref, |
| | | reactive, |
| | | toRefs, |
| | | onMounted, |
| | | getCurrentInstance, |
| | | computed, |
| | | } from "vue"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import { |
| | | qualityTestStandardListPage, |
| | | qualityTestStandardAdd, |
| | |
| | | qualityTestStandardParamList, |
| | | qualityTestStandardParamAdd, |
| | | qualityTestStandardParamUpdate, |
| | | qualityTestStandardParamDel |
| | | } from '@/api/qualityManagement/metricMaintenance.js' |
| | | import { productProcessListPage } from '@/api/basicData/productProcess.js' |
| | | import StandardFormDialog from './StandardFormDialog.vue' |
| | | import ParamFormDialog from './ParamFormDialog.vue' |
| | | qualityTestStandardParamDel, |
| | | } from "@/api/qualityManagement/metricMaintenance.js"; |
| | | import { productProcessListPage } from "@/api/basicData/productProcess.js"; |
| | | import StandardFormDialog from "./StandardFormDialog.vue"; |
| | | import ParamFormDialog from "./ParamFormDialog.vue"; |
| | | |
| | | const { proxy } = getCurrentInstance() |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | // 类别 Tab(0=原材料,1=过程,2=出厂) |
| | | const activeTab = ref('0') |
| | | const activeTab = ref("0"); |
| | | |
| | | // 左侧标准列表:整行内容居中(配合样式) |
| | | const rowClassNameCenter = () => 'row-center' |
| | | const rowClassNameCenter = () => "row-center"; |
| | | |
| | | // 标准状态为“通过(1)”时,右侧参数禁止增删改 |
| | | const isStandardReadonly = computed(() => { |
| | | const state = currentStandard.value?.state |
| | | return state === 1 || state === '1' |
| | | }) |
| | | const state = currentStandard.value?.state; |
| | | return state === 1 || state === "1"; |
| | | }); |
| | | |
| | | // 搜索条件 |
| | | const data = reactive({ |
| | | searchForm: { |
| | | standardNo: '', |
| | | standardName: '', |
| | | remark: '', |
| | | state: '', |
| | | inspectType: '', |
| | | processId: '' |
| | | standardNo: "", |
| | | standardName: "", |
| | | remark: "", |
| | | state: "", |
| | | inspectType: "", |
| | | processId: "", |
| | | }, |
| | | standardForm: { |
| | | id: undefined, |
| | | standardNo: '', |
| | | standardName: '', |
| | | remark: '', |
| | | state: '0', |
| | | inspectType: '', |
| | | processId: '' |
| | | standardNo: "", |
| | | standardName: "", |
| | | remark: "", |
| | | state: "0", |
| | | inspectType: "", |
| | | processId: "", |
| | | }, |
| | | standardRules: { |
| | | standardNo: [{ required: true, message: '请输入标准编号', trigger: 'blur' }], |
| | | standardName: [{ required: true, message: '请输入标准名称', trigger: 'blur' }], |
| | | processId: [{ |
| | | standardNo: [ |
| | | { required: true, message: "请输入标准编号", trigger: "blur" }, |
| | | ], |
| | | standardName: [ |
| | | { required: true, message: "请输入标准名称", trigger: "blur" }, |
| | | ], |
| | | processId: [ |
| | | { |
| | | validator: (_rule, value, callback) => { |
| | | const inspectType = String(standardForm.value.inspectType ?? activeTab.value ?? '') |
| | | if (inspectType === '1' && (value === '' || value === null || value === undefined)) { |
| | | callback(new Error('请选择工序')) |
| | | return |
| | | const inspectType = String( |
| | | standardForm.value.inspectType ?? activeTab.value ?? "" |
| | | ); |
| | | if ( |
| | | (inspectType === "1" || inspectType === "2") && |
| | | (value === "" || value === null || value === undefined) |
| | | ) { |
| | | callback(new Error("请选择工序")); |
| | | return; |
| | | } |
| | | callback() |
| | | callback(); |
| | | }, |
| | | trigger: 'change' |
| | | }] |
| | | } |
| | | }) |
| | | trigger: "change", |
| | | }, |
| | | ], |
| | | }, |
| | | }); |
| | | |
| | | const { searchForm, standardForm, standardRules } = toRefs(data) |
| | | const { searchForm, standardForm, standardRules } = toRefs(data); |
| | | |
| | | // 左侧表格 |
| | | const standardTableData = ref([]) |
| | | const selectedRows = ref([]) |
| | | const tableLoading = ref(false) |
| | | const standardTableData = ref([]); |
| | | const selectedRows = ref([]); |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | total: 0 |
| | | }) |
| | | total: 0, |
| | | }); |
| | | |
| | | // 工序下拉 |
| | | const processOptions = ref([]) |
| | | const processOptions = ref([]); |
| | | |
| | | // 获取工序列表 |
| | | const getProcessList = async () => { |
| | | try { |
| | | const res = await productProcessListPage({ current: 1, size: 1000 }) |
| | | const res = await productProcessListPage({ current: 1, size: 1000 }); |
| | | if (res?.code === 200) { |
| | | const records = res?.data?.records || [] |
| | | const records = res?.data?.records || []; |
| | | processOptions.value = records.map(item => ({ |
| | | label: item.processName || item.name || item.label, |
| | | value: item.id || item.processId || item.value |
| | | })) |
| | | value: item.id || item.processId || item.value, |
| | | })); |
| | | } |
| | | } catch (error) { |
| | | console.error('获取工序列表失败:', error) |
| | | console.error("获取工序列表失败:", error); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // 当前选中的标准 & 右侧详情 |
| | | const currentStandard = ref(null) |
| | | const detailTableData = ref([]) |
| | | const detailLoading = ref(false) |
| | | const paramSelectedRows = ref([]) |
| | | const paramDialogVisible = ref(false) |
| | | const paramOperationType = ref('add') // add | edit |
| | | const paramFormDialogRef = ref(null) |
| | | const currentStandard = ref(null); |
| | | const detailTableData = ref([]); |
| | | const detailLoading = ref(false); |
| | | const paramSelectedRows = ref([]); |
| | | const paramDialogVisible = ref(false); |
| | | const paramOperationType = ref("add"); // add | edit |
| | | const paramFormDialogRef = ref(null); |
| | | const paramForm = reactive({ |
| | | id: undefined, |
| | | parameterItem: '', |
| | | unit: '', |
| | | standardValue: '', |
| | | controlValue: '', |
| | | defaultValue: '' |
| | | }) |
| | | parameterItem: "", |
| | | unit: "", |
| | | standardValue: "", |
| | | controlValue: "", |
| | | defaultValue: "", |
| | | }); |
| | | |
| | | // 弹窗 |
| | | const standardDialogVisible = ref(false) |
| | | const standardOperationType = ref('add') // add | edit | copy |
| | | const standardFormDialogRef = ref(null) |
| | | const standardDialogVisible = ref(false); |
| | | const standardOperationType = ref("add"); // add | edit | copy |
| | | const standardFormDialogRef = ref(null); |
| | | |
| | | // 列定义 |
| | | const standardColumns = ref([ |
| | | { |
| | | label: '标准编号', |
| | | prop: 'standardNo', |
| | | dataType: 'slot', |
| | | slot: 'standardNoCell', |
| | | label: "标准编号", |
| | | prop: "standardNo", |
| | | dataType: "slot", |
| | | slot: "standardNoCell", |
| | | minWidth: 160, |
| | | align: 'center', |
| | | headerSlot: 'standardNoHeader' |
| | | align: "center", |
| | | headerSlot: "standardNoHeader", |
| | | }, |
| | | { |
| | | label: '标准名称', |
| | | prop: 'standardName', |
| | | label: "标准名称", |
| | | prop: "standardName", |
| | | minWidth: 180, |
| | | align: 'center', |
| | | headerSlot: 'standardNameHeader' |
| | | align: "center", |
| | | headerSlot: "standardNameHeader", |
| | | }, |
| | | { |
| | | label: '类别', |
| | | prop: 'inspectType', |
| | | align: 'center', |
| | | dataType: 'tag', |
| | | label: "类别", |
| | | prop: "inspectType", |
| | | align: "center", |
| | | dataType: "tag", |
| | | minWidth: 120, |
| | | formatData: (val) => { |
| | | formatData: val => { |
| | | const map = { |
| | | 0: '原材料检验', |
| | | 1: '过程检验', |
| | | 2: '出厂检验' |
| | | } |
| | | return map[val] || val |
| | | } |
| | | 0: "原材料检验", |
| | | 1: "过程检验", |
| | | 2: "出厂检验", |
| | | }; |
| | | return map[val] || val; |
| | | }, |
| | | }, |
| | | { |
| | | label: '工序', |
| | | prop: 'processId', |
| | | align: 'center', |
| | | dataType: 'tag', |
| | | visible: visible => activeTab.value === '1', |
| | | formatData: (val) => { |
| | | label: "工序", |
| | | prop: "processId", |
| | | align: "center", |
| | | dataType: "tag", |
| | | visible: visible => ["1", "2"].includes(String(activeTab.value)), |
| | | formatData: val => { |
| | | const target = processOptions.value.find( |
| | | (item) => String(item.value) === String(val) |
| | | ) |
| | | return target?.label || val |
| | | } |
| | | item => String(item.value) === String(val) |
| | | ); |
| | | return target?.label || val; |
| | | }, |
| | | }, |
| | | { |
| | | label: '状态', |
| | | prop: 'state', |
| | | headerSlot: 'stateHeader', |
| | | align: 'center', |
| | | dataType: 'tag', |
| | | formatData: (val) => { |
| | | label: "状态", |
| | | prop: "state", |
| | | headerSlot: "stateHeader", |
| | | align: "center", |
| | | dataType: "tag", |
| | | formatData: val => { |
| | | const map = { |
| | | 0: '草稿', |
| | | 1: '通过', |
| | | 2: '撤销' |
| | | } |
| | | return map[val] || val |
| | | 0: "草稿", |
| | | 1: "通过", |
| | | 2: "撤销", |
| | | }; |
| | | return map[val] || val; |
| | | }, |
| | | formatType: (val) => { |
| | | if (val === '1' || val === 1) return 'success' |
| | | if (val === '2' || val === 2) return 'warning' |
| | | return 'info' |
| | | } |
| | | formatType: val => { |
| | | if (val === "1" || val === 1) return "success"; |
| | | if (val === "2" || val === 2) return "warning"; |
| | | return "info"; |
| | | }, |
| | | }, |
| | | { |
| | | label: '备注', |
| | | prop: 'remark', |
| | | label: "备注", |
| | | prop: "remark", |
| | | minWidth: 160, |
| | | align: 'center' |
| | | align: "center", |
| | | }, |
| | | { |
| | | dataType: 'action', |
| | | label: '操作', |
| | | align: 'center', |
| | | fixed: 'right', |
| | | dataType: "action", |
| | | label: "操作", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: 220, |
| | | operation: [ |
| | | { |
| | | name: '编辑', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | openStandardDialog('edit', row) |
| | | } |
| | | name: "编辑", |
| | | type: "text", |
| | | clickFun: row => { |
| | | openStandardDialog("edit", row); |
| | | }, |
| | | }, |
| | | { |
| | | name: '复制', |
| | | type: 'text', |
| | | clickFun: async (row) => { |
| | | if (!row?.id) return |
| | | name: "复制", |
| | | type: "text", |
| | | clickFun: async row => { |
| | | if (!row?.id) return; |
| | | try { |
| | | await ElMessageBox.confirm('确认复制该标准参数?', '提示', { type: 'warning' }) |
| | | await ElMessageBox.confirm("确认复制该标准参数?", "提示", { |
| | | type: "warning", |
| | | }); |
| | | } catch { |
| | | return |
| | | return; |
| | | } |
| | | await qualityTestStandardCopyParam(row.id) |
| | | proxy.$message.success('复制成功') |
| | | getStandardList() |
| | | await qualityTestStandardCopyParam(row.id); |
| | | proxy.$message.success("复制成功"); |
| | | getStandardList(); |
| | | if (currentStandard.value?.id === row.id) { |
| | | loadDetail(row.id) |
| | | } |
| | | loadDetail(row.id); |
| | | } |
| | | }, |
| | | }, |
| | | { |
| | | name: '删除', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | handleDelete(row) |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | ]) |
| | | name: "删除", |
| | | type: "text", |
| | | clickFun: row => { |
| | | handleDelete(row); |
| | | }, |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | const handleTabChange = () => { |
| | | searchForm.value.standardNo = '' |
| | | searchForm.value.standardName = '' |
| | | searchForm.value.remark = '' |
| | | searchForm.value.state = '' |
| | | searchForm.value.processId = '' |
| | | searchForm.value.inspectType = activeTab.value |
| | | page.current = 1 |
| | | currentStandard.value = null |
| | | detailTableData.value = [] |
| | | paramSelectedRows.value = [] |
| | | getStandardList() |
| | | } |
| | | searchForm.value.standardNo = ""; |
| | | searchForm.value.standardName = ""; |
| | | searchForm.value.remark = ""; |
| | | searchForm.value.state = ""; |
| | | searchForm.value.processId = ""; |
| | | searchForm.value.inspectType = activeTab.value; |
| | | page.current = 1; |
| | | currentStandard.value = null; |
| | | detailTableData.value = []; |
| | | paramSelectedRows.value = []; |
| | | getStandardList(); |
| | | }; |
| | | |
| | | // 查询列表 |
| | | const getStandardList = () => { |
| | | tableLoading.value = true |
| | | tableLoading.value = true; |
| | | const params = { |
| | | ...searchForm.value, |
| | | current: page.current, |
| | | size: page.size |
| | | } |
| | | size: page.size, |
| | | }; |
| | | qualityTestStandardListPage(params) |
| | | .then((res) => { |
| | | const records = res?.data?.records || [] |
| | | standardTableData.value = records |
| | | page.total = res?.data?.total || records.length |
| | | .then(res => { |
| | | const records = res?.data?.records || []; |
| | | standardTableData.value = records; |
| | | page.total = res?.data?.total || records.length; |
| | | }) |
| | | .finally(() => { |
| | | tableLoading.value = false |
| | | }) |
| | | } |
| | | tableLoading.value = false; |
| | | }); |
| | | }; |
| | | |
| | | const handleQuery = () => { |
| | | page.current = 1 |
| | | getStandardList() |
| | | } |
| | | page.current = 1; |
| | | getStandardList(); |
| | | }; |
| | | |
| | | const resetQuery = () => { |
| | | searchForm.value.standardNo = '' |
| | | searchForm.value.standardName = '' |
| | | searchForm.value.remark = '' |
| | | searchForm.value.state = '' |
| | | searchForm.value.inspectType = '' |
| | | searchForm.value.processId = '' |
| | | handleQuery() |
| | | } |
| | | searchForm.value.standardNo = ""; |
| | | searchForm.value.standardName = ""; |
| | | searchForm.value.remark = ""; |
| | | searchForm.value.state = ""; |
| | | searchForm.value.inspectType = ""; |
| | | searchForm.value.processId = ""; |
| | | handleQuery(); |
| | | }; |
| | | |
| | | const handlePagination = (obj) => { |
| | | page.current = obj.page |
| | | page.size = obj.limit |
| | | getStandardList() |
| | | } |
| | | const handlePagination = obj => { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | getStandardList(); |
| | | }; |
| | | |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection |
| | | } |
| | | const handleSelectionChange = selection => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | |
| | | // 批量审核:状态 1=批准,2=撤销 |
| | | const handleBatchAudit = async (state) => { |
| | | const handleBatchAudit = async state => { |
| | | if (!selectedRows.value.length) { |
| | | proxy.$message.warning('请选择数据') |
| | | return |
| | | proxy.$message.warning("请选择数据"); |
| | | return; |
| | | } |
| | | const text = state === 1 ? '批准' : '撤销' |
| | | const text = state === 1 ? "批准" : "撤销"; |
| | | const payload = selectedRows.value |
| | | .filter(i => i?.id) |
| | | .map((item) => ({ id: item.id, state })) |
| | | .map(item => ({ id: item.id, state })); |
| | | |
| | | if (!payload.length) { |
| | | proxy.$message.warning('请选择有效数据') |
| | | return |
| | | proxy.$message.warning("请选择有效数据"); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | await ElMessageBox.confirm(`确认${text}选中的标准?`, '提示', { type: 'warning' }) |
| | | await ElMessageBox.confirm(`确认${text}选中的标准?`, "提示", { |
| | | type: "warning", |
| | | }); |
| | | } catch { |
| | | return |
| | | return; |
| | | } |
| | | await qualityTestStandardAudit(payload) |
| | | proxy.$message.success(`${text}成功`) |
| | | getStandardList() |
| | | } |
| | | await qualityTestStandardAudit(payload); |
| | | proxy.$message.success(`${text}成功`); |
| | | getStandardList(); |
| | | }; |
| | | |
| | | // 表格行点击,加载右侧参数 |
| | | const handleTableRowClick = (row) => { |
| | | currentStandard.value = row |
| | | loadDetail(row.id) |
| | | } |
| | | const handleTableRowClick = row => { |
| | | currentStandard.value = row; |
| | | loadDetail(row.id); |
| | | }; |
| | | |
| | | // 左侧行点击,加载右侧参数(保留用于标准编号列的点击) |
| | | const handleStandardRowClick = (row) => { |
| | | currentStandard.value = row |
| | | loadDetail(row.id) |
| | | } |
| | | const handleStandardRowClick = row => { |
| | | currentStandard.value = row; |
| | | loadDetail(row.id); |
| | | }; |
| | | |
| | | const loadDetail = (standardId) => { |
| | | const loadDetail = standardId => { |
| | | if (!standardId) { |
| | | detailTableData.value = [] |
| | | return |
| | | detailTableData.value = []; |
| | | return; |
| | | } |
| | | detailLoading.value = true |
| | | qualityTestStandardParamList({ testStandardId: standardId }).then((res) => { |
| | | detailTableData.value = res?.data || [] |
| | | detailLoading.value = true; |
| | | qualityTestStandardParamList({ testStandardId: standardId }) |
| | | .then(res => { |
| | | detailTableData.value = res?.data || []; |
| | | }) |
| | | .finally(() => { |
| | | detailLoading.value = false |
| | | }) |
| | | } |
| | | detailLoading.value = false; |
| | | }); |
| | | }; |
| | | |
| | | const handleParamSelectionChange = (selection) => { |
| | | paramSelectedRows.value = selection |
| | | } |
| | | const handleParamSelectionChange = selection => { |
| | | paramSelectedRows.value = selection; |
| | | }; |
| | | |
| | | const openParamDialog = (type, row) => { |
| | | if (!currentStandard.value?.id) return |
| | | if (!currentStandard.value?.id) return; |
| | | if (isStandardReadonly.value) { |
| | | proxy.$message.warning('该标准已通过,参数不可编辑') |
| | | return |
| | | proxy.$message.warning("该标准已通过,参数不可编辑"); |
| | | return; |
| | | } |
| | | paramOperationType.value = type |
| | | if (type === 'add') { |
| | | paramOperationType.value = type; |
| | | if (type === "add") { |
| | | Object.assign(paramForm, { |
| | | id: undefined, |
| | | parameterItem: '', |
| | | unit: '', |
| | | standardValue: '', |
| | | controlValue: '', |
| | | defaultValue: '' |
| | | }) |
| | | } else if (type === 'edit' && row) { |
| | | Object.assign(paramForm, row) |
| | | parameterItem: "", |
| | | unit: "", |
| | | standardValue: "", |
| | | controlValue: "", |
| | | defaultValue: "", |
| | | }); |
| | | } else if (type === "edit" && row) { |
| | | Object.assign(paramForm, row); |
| | | } |
| | | paramDialogVisible.value = true |
| | | } |
| | | paramDialogVisible.value = true; |
| | | }; |
| | | |
| | | const closeParamDialog = () => { |
| | | paramDialogVisible.value = false |
| | | paramFormDialogRef.value?.resetFields?.() |
| | | } |
| | | paramDialogVisible.value = false; |
| | | paramFormDialogRef.value?.resetFields?.(); |
| | | }; |
| | | |
| | | const submitParamForm = async () => { |
| | | const testStandardId = currentStandard.value?.id |
| | | if (!testStandardId) return |
| | | const testStandardId = currentStandard.value?.id; |
| | | if (!testStandardId) return; |
| | | if (isStandardReadonly.value) { |
| | | proxy.$message.warning('该标准已通过,参数不可编辑') |
| | | return |
| | | proxy.$message.warning("该标准已通过,参数不可编辑"); |
| | | return; |
| | | } |
| | | const payload = { ...paramForm, testStandardId } |
| | | if (paramOperationType.value === 'edit') { |
| | | await qualityTestStandardParamUpdate(payload) |
| | | proxy.$message.success('提交成功') |
| | | const payload = { ...paramForm, testStandardId }; |
| | | if (paramOperationType.value === "edit") { |
| | | await qualityTestStandardParamUpdate(payload); |
| | | proxy.$message.success("提交成功"); |
| | | } else { |
| | | await qualityTestStandardParamAdd(payload) |
| | | proxy.$message.success('提交成功') |
| | | await qualityTestStandardParamAdd(payload); |
| | | proxy.$message.success("提交成功"); |
| | | } |
| | | closeParamDialog() |
| | | loadDetail(testStandardId) |
| | | } |
| | | closeParamDialog(); |
| | | loadDetail(testStandardId); |
| | | }; |
| | | |
| | | const handleParamDelete = async (row) => { |
| | | if (!row?.id) return |
| | | const handleParamDelete = async row => { |
| | | if (!row?.id) return; |
| | | if (isStandardReadonly.value) { |
| | | proxy.$message.warning('该标准已通过,参数不可编辑') |
| | | return |
| | | proxy.$message.warning("该标准已通过,参数不可编辑"); |
| | | return; |
| | | } |
| | | try { |
| | | await ElMessageBox.confirm('确认删除该参数?', '提示', { type: 'warning' }) |
| | | await ElMessageBox.confirm("确认删除该参数?", "提示", { type: "warning" }); |
| | | } catch { |
| | | return |
| | | return; |
| | | } |
| | | await qualityTestStandardParamDel([row.id]) |
| | | proxy.$message.success('删除成功') |
| | | loadDetail(currentStandard.value?.id) |
| | | } |
| | | await qualityTestStandardParamDel([row.id]); |
| | | proxy.$message.success("删除成功"); |
| | | loadDetail(currentStandard.value?.id); |
| | | }; |
| | | |
| | | const handleParamBatchDelete = async () => { |
| | | if (isStandardReadonly.value) { |
| | | proxy.$message.warning('该标准已通过,参数不可编辑') |
| | | return |
| | | proxy.$message.warning("该标准已通过,参数不可编辑"); |
| | | return; |
| | | } |
| | | if (!paramSelectedRows.value.length) { |
| | | proxy.$message.warning('请选择数据') |
| | | return |
| | | proxy.$message.warning("请选择数据"); |
| | | return; |
| | | } |
| | | const ids = paramSelectedRows.value.map((i) => i.id) |
| | | const ids = paramSelectedRows.value.map(i => i.id); |
| | | try { |
| | | await ElMessageBox.confirm('选中的内容将被删除,是否确认删除?', '删除提示', { type: 'warning' }) |
| | | await ElMessageBox.confirm( |
| | | "选中的内容将被删除,是否确认删除?", |
| | | "删除提示", |
| | | { type: "warning" } |
| | | ); |
| | | } catch { |
| | | return |
| | | return; |
| | | } |
| | | await qualityTestStandardParamDel(ids) |
| | | proxy.$message.success('删除成功') |
| | | loadDetail(currentStandard.value?.id) |
| | | } |
| | | await qualityTestStandardParamDel(ids); |
| | | proxy.$message.success("删除成功"); |
| | | loadDetail(currentStandard.value?.id); |
| | | }; |
| | | |
| | | // 新增 / 编辑 / 复制 |
| | | const openStandardDialog = (type, row) => { |
| | | standardOperationType.value = type |
| | | if (type === 'add') { |
| | | standardOperationType.value = type; |
| | | if (type === "add") { |
| | | Object.assign(standardForm.value, { |
| | | id: undefined, |
| | | standardNo: '', |
| | | standardName: '', |
| | | remark: '', |
| | | state: '0', |
| | | standardNo: "", |
| | | standardName: "", |
| | | remark: "", |
| | | state: "0", |
| | | inspectType: activeTab.value, |
| | | processId: activeTab.value === '1' ? '' : null |
| | | }) |
| | | } else if (type === 'edit' && row) { |
| | | processId: ["1", "2"].includes(String(activeTab.value)) ? "" : null, |
| | | }); |
| | | } else if (type === "edit" && row) { |
| | | Object.assign(standardForm.value, { |
| | | ...row, |
| | | // 确保 inspectType 和 state 转换为字符串,以匹配 el-select 的 value 类型 |
| | | inspectType: row.inspectType !== null && row.inspectType !== undefined ? String(row.inspectType) : '', |
| | | state: row.state !== null && row.state !== undefined ? String(row.state) : '0', |
| | | inspectType: |
| | | row.inspectType !== null && row.inspectType !== undefined |
| | | ? String(row.inspectType) |
| | | : "", |
| | | state: |
| | | row.state !== null && row.state !== undefined ? String(row.state) : "0", |
| | | // 确保 processId 转换为字符串或数字(根据实际需要) |
| | | processId: String(row.inspectType) === '1' && row.processId !== null && row.processId !== undefined ? row.processId : null |
| | | }) |
| | | } else if (type === 'copy' && row) { |
| | | const { id, ...rest } = row |
| | | processId: |
| | | ["1", "2"].includes(String(row.inspectType)) && |
| | | row.processId !== null && |
| | | row.processId !== undefined |
| | | ? row.processId |
| | | : null, |
| | | }); |
| | | } else if (type === "copy" && row) { |
| | | const { id, ...rest } = row; |
| | | Object.assign(standardForm.value, { |
| | | ...rest, |
| | | id: undefined, |
| | | standardNo: '', |
| | | state: '0', |
| | | standardNo: "", |
| | | state: "0", |
| | | // 确保 inspectType 转换为字符串 |
| | | inspectType: activeTab.value, |
| | | processId: activeTab.value === '1' ? (rest.processId ?? '') : null |
| | | }) |
| | | processId: ["1", "2"].includes(String(activeTab.value)) |
| | | ? rest.processId ?? "" |
| | | : null, |
| | | }); |
| | | } |
| | | standardDialogVisible.value = true |
| | | } |
| | | standardDialogVisible.value = true; |
| | | }; |
| | | |
| | | const closeStandardDialog = () => { |
| | | standardDialogVisible.value = false |
| | | standardFormDialogRef.value?.resetFields?.() |
| | | } |
| | | standardDialogVisible.value = false; |
| | | standardFormDialogRef.value?.resetFields?.(); |
| | | }; |
| | | |
| | | const submitStandardForm = () => { |
| | | const payload = { ...standardForm.value } |
| | | payload.inspectType = activeTab.value |
| | | if (String(payload.inspectType) !== '1') { |
| | | payload.processId = null |
| | | const payload = { ...standardForm.value }; |
| | | payload.inspectType = activeTab.value; |
| | | if (!["1", "2"].includes(String(payload.inspectType))) { |
| | | payload.processId = null; |
| | | } |
| | | const isEdit = standardOperationType.value === 'edit' |
| | | const isEdit = standardOperationType.value === "edit"; |
| | | if (isEdit) { |
| | | qualityTestStandardUpdate(payload).then(() => { |
| | | proxy.$message.success('提交成功') |
| | | standardDialogVisible.value = false |
| | | getStandardList() |
| | | }) |
| | | proxy.$message.success("提交成功"); |
| | | standardDialogVisible.value = false; |
| | | getStandardList(); |
| | | }); |
| | | } else { |
| | | qualityTestStandardAdd(payload).then(() => { |
| | | proxy.$message.success('提交成功') |
| | | standardDialogVisible.value = false |
| | | getStandardList() |
| | | }) |
| | | proxy.$message.success("提交成功"); |
| | | standardDialogVisible.value = false; |
| | | getStandardList(); |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // 删除(单条) |
| | | const handleDelete = (row) => { |
| | | const ids = [row.id] |
| | | ElMessageBox.confirm('选中的内容将被删除,是否确认删除?', '删除提示', { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | const handleDelete = row => { |
| | | const ids = [row.id]; |
| | | ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除提示", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | tableLoading.value = true |
| | | tableLoading.value = true; |
| | | qualityTestStandardDel(ids) |
| | | .then(() => { |
| | | proxy.$message.success('删除成功') |
| | | getStandardList() |
| | | proxy.$message.success("删除成功"); |
| | | getStandardList(); |
| | | if (currentStandard.value && currentStandard.value.id === row.id) { |
| | | currentStandard.value = null |
| | | detailTableData.value = [] |
| | | currentStandard.value = null; |
| | | detailTableData.value = []; |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | tableLoading.value = false |
| | | }) |
| | | tableLoading.value = false; |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal?.msg('已取消') |
| | | }) |
| | | } |
| | | proxy.$modal?.msg("已取消"); |
| | | }); |
| | | }; |
| | | |
| | | // 批量删除 |
| | | const handleBatchDelete = () => { |
| | | if (!selectedRows.value.length) { |
| | | proxy.$message.warning('请选择数据') |
| | | return |
| | | proxy.$message.warning("请选择数据"); |
| | | return; |
| | | } |
| | | const ids = selectedRows.value.map((item) => item.id) |
| | | ElMessageBox.confirm('选中的内容将被删除,是否确认删除?', '删除提示', { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | const ids = selectedRows.value.map(item => item.id); |
| | | ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除提示", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | tableLoading.value = true |
| | | tableLoading.value = true; |
| | | qualityTestStandardDel(ids) |
| | | .then(() => { |
| | | proxy.$message.success('删除成功') |
| | | getStandardList() |
| | | proxy.$message.success("删除成功"); |
| | | getStandardList(); |
| | | if (currentStandard.value && ids.includes(currentStandard.value.id)) { |
| | | currentStandard.value = null |
| | | detailTableData.value = [] |
| | | currentStandard.value = null; |
| | | detailTableData.value = []; |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | tableLoading.value = false |
| | | }) |
| | | tableLoading.value = false; |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal?.msg('已取消') |
| | | }) |
| | | } |
| | | proxy.$modal?.msg("已取消"); |
| | | }); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | searchForm.value.inspectType = activeTab.value |
| | | getProcessList() |
| | | getStandardList() |
| | | }) |
| | | searchForm.value.inspectType = activeTab.value; |
| | | getProcessList(); |
| | | getStandardList(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |