From 0d70f0294ad72c3c051cb7b86249aecbb406464c Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期一, 23 三月 2026 14:25:08 +0800
Subject: [PATCH] feat(质量巡检): 新增产品巡检记录管理功能
---
src/views/qualityManagement/productInspectionRecord/components/formDia.vue | 301 +++++++++++++++++++++++++++
src/api/qualityManagement/productInspectionRecord.js | 54 ++++
src/views/qualityManagement/productInspectionRecord/index.vue | 258 +++++++++++++++++++++++
3 files changed, 613 insertions(+), 0 deletions(-)
diff --git a/src/api/qualityManagement/productInspectionRecord.js b/src/api/qualityManagement/productInspectionRecord.js
new file mode 100644
index 0000000..88824cb
--- /dev/null
+++ b/src/api/qualityManagement/productInspectionRecord.js
@@ -0,0 +1,54 @@
+import request from '@/utils/request'
+
+// 宸℃璁板綍 鍒嗛〉鏌ヨ
+export function productInspectionRecordListPage(query) {
+ return request({
+ url: '/productInspectionRecord/listPage',
+ method: 'get',
+ params: query,
+ })
+}
+
+// 宸℃璁板綍 鏂板
+export function addProductInspectionRecord(data) {
+ return request({
+ url: '/productInspectionRecord/addProductInspectionRecord',
+ method: 'post',
+ data: data,
+ })
+}
+
+// 宸℃璁板綍 淇敼
+export function updProductInspectionRecord(data) {
+ return request({
+ url: '/productInspectionRecord/updProductInspectionRecord',
+ method: 'put',
+ data: data,
+ })
+}
+
+// 宸℃璁板綍 鍒犻櫎
+export function delProductInspectionRecord(ids) {
+ return request({
+ url: `/productInspectionRecord/${ids}`,
+ method: 'delete',
+ })
+}
+
+// 宸℃璁板綍 閫氱煡
+export function notifyProductInspectionRecord(ids) {
+ return request({
+ url: '/productInspectionRecord/notify',
+ method: 'post',
+ data: ids,
+ })
+}
+
+// 鏍规嵁宸ュ簭鍜屾楠岀被鍨嬭幏鍙栨娴嬮」鐩�
+export function getParameterItemByProcessOrCategory(params) {
+ return request({
+ url: '/qualityTestStandard/getParameterItemByProcessOrCategory',
+ method: 'get',
+ params: params,
+ })
+}
diff --git a/src/views/qualityManagement/productInspectionRecord/components/formDia.vue b/src/views/qualityManagement/productInspectionRecord/components/formDia.vue
new file mode 100644
index 0000000..1cfe396
--- /dev/null
+++ b/src/views/qualityManagement/productInspectionRecord/components/formDia.vue
@@ -0,0 +1,301 @@
+<template>
+ <el-dialog
+ v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板宸℃璁板綍' : '缂栬緫宸℃璁板綍'"
+ width="700px"
+ @close="closeDia"
+ >
+ <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="宸ュ簭锛�" prop="processId">
+ <el-select v-model="form.processId" placeholder="璇烽�夋嫨宸ュ簭" clearable @change="handleProcessChange" style="width: 100%">
+ <el-option
+ v-for="item in processList"
+ :key="item.id"
+ :label="item.processName || item.name"
+ :value="item.id"
+ />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="宸℃鏃堕棿锛�" prop="inspectionTime">
+ <el-date-picker
+ v-model="form.inspectionTime"
+ value-format="YYYY-MM-DD HH:mm:ss"
+ format="YYYY-MM-DD HH:mm:ss"
+ type="datetime"
+ placeholder="璇烽�夋嫨宸℃鏃堕棿"
+ style="width: 100%"
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="宸℃鍛橈細" prop="inspector">
+ <el-input v-model="form.inspector" placeholder="璇疯緭鍏ュ贰妫�鍛�" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="妫�娴嬮」锛�" prop="inspectionItem">
+ <el-select v-model="form.inspectionItem" placeholder="璇烽�夋嫨妫�娴嬮」" clearable @change="handleInspectionItemChange" style="width: 100%">
+ <el-option v-for="item in inspectionItemList" :key="item.parameterItem" :label="item.parameterItem" :value="item.parameterItem" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="鏍囧噯瑕佹眰锛�" prop="standardRequirement">
+ <el-input v-model="form.standardRequirement" placeholder="鏍囧噯瑕佹眰" readonly />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="瀹炴祴鍊硷細" prop="actualValue">
+ <el-input v-model="form.actualValue" placeholder="璇疯緭鍏ュ疄娴嬪��" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="鍒ゅ畾锛�" prop="judgement">
+ <el-select v-model="form.judgement" placeholder="璇烽�夋嫨" clearable style="width: 100%">
+ <el-option label="鍚堟牸" value="yes" />
+ <el-option label="涓嶅悎鏍�" value="no" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="涓嶅悎鏍艰鍗曪細" prop="unqualifiedOrder">
+ <el-input v-model="form.unqualifiedOrder" placeholder="璇疯緭鍏ヤ笉鍚堟牸璁㈠崟" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="24">
+ <el-form-item label="澶囨敞锛�" prop="remark">
+ <el-input v-model="form.remark" type="textarea" :rows="3" placeholder="璇疯緭鍏ュ娉�" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="submitForm">纭</el-button>
+ <el-button @click="closeDia">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+</template>
+
+<script setup>
+import { ref, reactive } from "vue";
+import { ElMessage } from "element-plus";
+import { addProductInspectionRecord, updProductInspectionRecord, getParameterItemByProcessOrCategory } from "@/api/qualityManagement/productInspectionRecord.js";
+import { processList as getProcessList } from "@/api/productionManagement/productionProcess.js";
+import useUserStore from "@/store/modules/user";
+
+const userStore = useUserStore();
+const dialogFormVisible = ref(false);
+const operationType = ref("add");
+const formRef = ref(null);
+
+const form = reactive({
+ id: undefined,
+ processId: undefined,
+ process: "",
+ checkDate: undefined,
+ inspector: "",
+ inspectionTime: undefined,
+ inspectionItem: "",
+ standardRequirement: "",
+ actualValue: "",
+ judgement: "",
+ unqualifiedOrder: "",
+ remark: "",
+ createUser: "",
+ createTime: undefined,
+});
+
+const processList = ref([]);
+const inspectionItemList = ref([]);
+
+/** 宸ュ簭 id 涓庡悗绔彲鑳戒负 number/string锛岀粺涓�姣旇緝 */
+const sameProcessId = (a, b) => a != null && b != null && String(a) === String(b);
+
+/** 浠庡伐搴忓垪琛ㄥ彇涓� row 鍖归厤鐨� id锛堜繚璇佷笌 el-option 鐨� value 绫诲瀷涓�鑷达紝閬垮厤鍥炴樉鎴愮函鏁板瓧锛� */
+const resolveProcessIdFromRow = (row) => {
+ let pid = row.processId ?? row.process_id;
+ if (pid != null && pid !== "") {
+ const hit = processList.value.find((item) => sameProcessId(item.id, pid));
+ return hit ? hit.id : pid;
+ }
+ // 閮ㄥ垎鎺ュ彛鎶婂伐搴� id 瀛樺湪 process 瀛楁閲�
+ const p = row.process;
+ if (p != null && p !== "" && /^\d+$/.test(String(p).trim())) {
+ const hit = processList.value.find((item) => sameProcessId(item.id, p));
+ return hit ? hit.id : p;
+ }
+ return undefined;
+};
+
+const getProcessLabel = (item) => item?.processName || item?.name || "";
+
+const rules = {
+ processId: [{ required: true, message: "璇烽�夋嫨宸ュ簭", trigger: "change" }],
+ checkDate: [{ required: true, message: "璇烽�夋嫨宸℃鏃ユ湡", trigger: "change" }],
+};
+
+const loadProcessList = async () => {
+ try {
+ const res = await getProcessList({ current: 1, size: 1000 });
+ processList.value = res.data || [];
+ } catch (error) {
+ console.error("鍔犺浇宸ュ簭鍒楄〃澶辫触", error);
+ }
+};
+
+/**
+ * @param processId 宸ュ簭 id
+ * @param options.preserveInspection 涓� true 鏃朵繚鐣欏凡鏈夋娴嬮」/鏍囧噯锛堢紪杈戝洖鏄撅級
+ */
+const handleProcessChange = async (processId, options = {}) => {
+ const { preserveInspection = false } = options;
+
+ if (!preserveInspection) {
+ form.process = "";
+ form.inspectionItem = "";
+ form.standardRequirement = "";
+ }
+ inspectionItemList.value = [];
+
+ if (!processId) {
+ return;
+ }
+ const process = processList.value.find((item) => sameProcessId(item.id, processId));
+ if (process) {
+ form.process = getProcessLabel(process);
+ }
+
+ try {
+ const { data } = await getParameterItemByProcessOrCategory({
+ id: processId,
+ inspectType: 3,
+ });
+ if (data && data.length > 0) {
+ inspectionItemList.value = data;
+ if (preserveInspection && form.inspectionItem) {
+ const cur = data.find((i) => i.parameterItem === form.inspectionItem);
+ form.standardRequirement = cur?.standardValue ?? form.standardRequirement ?? "";
+ } else {
+ const firstItem = data[0];
+ form.inspectionItem = firstItem.parameterItem;
+ form.standardRequirement = firstItem.standardValue || "";
+ }
+ }
+ } catch (error) {
+ console.error("鍔犺浇妫�娴嬮」鐩け璐�", error);
+ }
+};
+
+const handleInspectionItemChange = (val) => {
+ if (!val) {
+ form.standardRequirement = "";
+ return;
+ }
+ const item = inspectionItemList.value.find(i => i.parameterItem === val);
+ if (item) {
+ form.standardRequirement = item.standardValue || "";
+ }
+};
+
+const open = async (type, row) => {
+ operationType.value = type;
+ await loadProcessList();
+ if (type === "edit" && row) {
+ Object.assign(form, row);
+ const resolvedId = resolveProcessIdFromRow(row);
+ if (resolvedId != null && resolvedId !== "") {
+ form.processId = resolvedId;
+ const processItem = processList.value.find((item) => sameProcessId(item.id, resolvedId));
+ if (processItem) {
+ form.process = getProcessLabel(processItem);
+ } else if (row.process && !/^\d+$/.test(String(row.process).trim())) {
+ form.process = row.process;
+ }
+ }
+ if (form.processId != null && form.processId !== "") {
+ await handleProcessChange(form.processId, { preserveInspection: true });
+ }
+ } else {
+ resetForm();
+ }
+ dialogFormVisible.value = true;
+};
+
+const formatDateTime = () => {
+ const now = new Date();
+ const year = now.getFullYear();
+ const month = String(now.getMonth() + 1).padStart(2, '0');
+ const day = String(now.getDate()).padStart(2, '0');
+ const hours = String(now.getHours()).padStart(2, '0');
+ const minutes = String(now.getMinutes()).padStart(2, '0');
+ const seconds = String(now.getSeconds()).padStart(2, '0');
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+};
+
+const resetForm = () => {
+ form.id = undefined;
+ form.processId = undefined;
+ form.process = "";
+ form.checkDate = undefined;
+ form.inspector = "";
+ form.inspectionTime = formatDateTime();
+ form.inspectionItem = "";
+ form.standardRequirement = "";
+ form.actualValue = "";
+ form.judgement = "";
+ form.unqualifiedOrder = "";
+ form.remark = "";
+ form.createUser = "";
+ form.createTime = undefined;
+ inspectionItemList.value = [];
+};
+
+const closeDia = () => {
+ dialogFormVisible.value = false;
+ resetForm();
+};
+
+const submitForm = async () => {
+ const valid = await formRef.value.validate().catch(() => false);
+ if (!valid) return;
+ const p = processList.value.find((item) => sameProcessId(item.id, form.processId));
+ form.process = getProcessLabel(p);
+
+ try {
+ if (operationType.value === "add") {
+ await addProductInspectionRecord(form);
+ ElMessage.success("鏂板鎴愬姛");
+ } else {
+ await updProductInspectionRecord(form);
+ ElMessage.success("淇敼鎴愬姛");
+ }
+ closeDia();
+ emit("close");
+ } catch (error) {
+ console.error(error);
+ }
+};
+
+const emit = defineEmits(["close"]);
+
+defineExpose({
+ open,
+});
+</script>
+
+<style scoped>
+</style>
\ No newline at end of file
diff --git a/src/views/qualityManagement/productInspectionRecord/index.vue b/src/views/qualityManagement/productInspectionRecord/index.vue
new file mode 100644
index 0000000..f619622
--- /dev/null
+++ b/src/views/qualityManagement/productInspectionRecord/index.vue
@@ -0,0 +1,258 @@
+<template>
+ <div class="app-container">
+ <div class="search_form">
+ <div>
+ <span class="search_title">宸ュ簭锛�</span>
+ <el-input
+ v-model="searchForm.process"
+ style="width: 240px"
+ placeholder="璇疯緭鍏ュ伐搴忔悳绱�"
+ @change="handleQuery"
+ clearable
+ />
+ <span style="margin-left: 10px" class="search_title">宸℃鏃ユ湡锛�</span>
+ <el-date-picker v-model="searchForm.checkDate"
+ value-format="YYYY-MM-DD HH:mm:ss"
+ format="YYYY-MM-DD HH:mm:ss"
+ type="datetimerange"
+ 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="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+ <el-button type="success" plain @click="handleNotify">閫氱煡</el-button>
+ </div>
+ </div>
+ <div class="table_list">
+ <PIMTable
+ rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :page="page"
+ :isSelection="true"
+ @selection-change="handleSelectionChange"
+ :tableLoading="tableLoading"
+ @pagination="pagination"
+ :total="page.total"
+ ></PIMTable>
+ </div>
+ <FormDia ref="formDia" @close="handleQuery"></FormDia>
+ </div>
+</template>
+
+<script setup>
+import { onMounted, ref, reactive, toRefs } from "vue";
+import FormDia from "./components/formDia.vue";
+import {ElMessage, ElMessageBox} from "element-plus";
+import {
+ productInspectionRecordListPage,
+ delProductInspectionRecord,
+ notifyProductInspectionRecord
+} from "@/api/qualityManagement/productInspectionRecord.js";
+
+const data = reactive({
+ searchForm: {
+ keyword: "",
+ checkDate: undefined,
+ checkDateStart: undefined,
+ checkDateEnd: undefined,
+ },
+});
+const { searchForm } = toRefs(data);
+
+const tableData = ref([]);
+const tableLoading = ref(false);
+const page = reactive({
+ current: 1,
+ size: 10,
+ total: 0,
+});
+const ids = ref([]);
+
+const tableColumn = ref([
+ {
+ label: "宸ュ簭",
+ prop: "process",
+ },
+ {
+ label: "妫�娴嬮」",
+ prop: "inspectionItem",
+ },
+ {
+ label: "鏍囧噯瑕佹眰",
+ prop: "standardRequirement",
+ },
+ {
+ label: "瀹炴祴鍊�",
+ prop: "actualValue",
+ },
+ {
+ label: "鍒ゅ畾",
+ prop: "judgement",
+ dataType: "tag",
+ formatData: (params) => {
+ if (params === 'yes') {
+ return "鍚堟牸";
+ } else if (params === 'no') {
+ return "涓嶅悎鏍�";
+ }
+ return params;
+ },
+ formatType: (params) => {
+ if (params === 'yes') {
+ return "success";
+ } else if (params === 'no') {
+ return "danger";
+ }
+ return null;
+ },
+ },
+ {
+ label: "涓嶅悎鏍艰鍗�",
+ prop: "unqualifiedOrder",
+ },
+ {
+ label: "宸℃鏃ユ湡",
+ prop: "inspectionTime",
+ width: 160
+ },
+ {
+ label: "宸℃鍛�",
+ prop: "inspector",
+ },
+ {
+ label: "鍒涘缓浜�",
+ prop: "createUser",
+ },
+ {
+ label: "鍒涘缓鏃堕棿",
+ prop: "createTime",
+ width: 160
+ },
+ {
+ dataType: "action",
+ label: "鎿嶄綔",
+ align: "center",
+ fixed: "right",
+ width: 150,
+ operation: [
+ {
+ name: "缂栬緫",
+ type: "text",
+ clickFun: (row) => {
+ openForm("edit", row);
+ },
+ },
+ {
+ name: "鍒犻櫎",
+ type: "text",
+ clickFun: (row) => {
+ handleDelete(row);
+ },
+ },
+ ],
+ },
+]);
+
+const formDia = ref(null);
+
+const openForm = (type, row) => {
+ formDia.value.open(type, row);
+};
+
+const changeDaterange = (val) => {
+ if (val) {
+ searchForm.value.startTime = val[0];
+ searchForm.value.endTime = val[1];
+ } else {
+ searchForm.value.startTime = undefined;
+ searchForm.value.endTime = undefined;
+ }
+ handleQuery();
+};
+
+const handleQuery = () => {
+ page.current = 1;
+ getList();
+};
+
+const pagination = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList();
+};
+
+const getList = async () => {
+ tableLoading.value = true;
+ try {
+ const res = await productInspectionRecordListPage({
+ ...searchForm.value,
+ current: page.current,
+ size: page.size,
+ });
+ tableData.value = res.data.records || [];
+ page.total = res.data.total || 0;
+ } finally {
+ tableLoading.value = false;
+ }
+};
+
+const handleSelectionChange = (selection) => {
+ ids.value = selection.map((item) => item.id);
+};
+
+const handleDelete = (row) => {
+ const _ids = row ? [row.id] : ids.value;
+ if (_ids.length === 0) {
+ ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
+ return;
+ }
+ ElMessageBox.confirm("鏄惁纭鍒犻櫎閫変腑鐨勬暟鎹紵", "璀﹀憡", {
+ confirmButtonText: "纭畾",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ }).then(async () => {
+ await delProductInspectionRecord(_ids);
+ ElMessage.success("鍒犻櫎鎴愬姛");
+ getList();
+ });
+};
+
+const handleNotify = () => {
+ if (ids.value.length === 0) {
+ ElMessage.warning("璇烽�夋嫨瑕侀�氱煡鐨勬暟鎹�");
+ return;
+ }
+ ElMessageBox.confirm("鏄惁纭鍙戦�侀�氱煡锛�", "璀﹀憡", {
+ confirmButtonText: "纭畾",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ }).then(async () => {
+ await notifyProductInspectionRecord(ids.value);
+ ElMessage.success("鍙戦�侀�氱煡鎴愬姛");
+ })
+};
+
+onMounted(() => {
+ getList();
+});
+</script>
+
+<style scoped lang="scss">
+.search_form {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 16px;
+}
+
+.search_title {
+ font-size: 14px;
+ color: #606266;
+}
+</style>
\ No newline at end of file
--
Gitblit v1.9.3