From bc79e1fae76dffb3cbc3ddfa9ba23e66e150d098 Mon Sep 17 00:00:00 2001
From: zhang_nuo <zhang_12370@163.com>
Date: 星期五, 28 八月 2026 23:18:27 +0800
Subject: [PATCH] fix: 调整多个业务模块的页面展示与字段

---
 src/views/qualityManagement/nonconformingManagement/index.vue |  248 +++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 208 insertions(+), 40 deletions(-)

diff --git a/src/views/qualityManagement/nonconformingManagement/index.vue b/src/views/qualityManagement/nonconformingManagement/index.vue
index 319cfd5..7cc984e 100644
--- a/src/views/qualityManagement/nonconformingManagement/index.vue
+++ b/src/views/qualityManagement/nonconformingManagement/index.vue
@@ -1,41 +1,45 @@
 <template>
   <div class="app-container">
     <div class="search_form">
-      <div style="display: flex;flex-direction: row;align-items: center;">
-        <div>
-          <span class="search_title">绫诲瀷锛�</span>
-          <el-select v-model="searchForm.inspectType" clearable style="width: 240px" @change="handleQuery">
+      <el-form :model="searchForm" inline style="margin-bottom: 0;">
+        <el-form-item label="绫诲瀷锛�">
+          <el-select v-model="searchForm.inspectType" clearable style="width: 200px" @change="handleQuery">
             <el-option label="鍘熸潗鏂欐楠�" :value="0" />
             <el-option label="杩囩▼妫�楠�" :value="1" />
             <el-option label="鍑哄巶妫�楠�" :value="2" />
           </el-select>
-        </div>
-        <div style="margin-left: 10px">
-          <span class="search_title">鐘舵�侊細</span>
-          <el-select v-model="searchForm.inspectState" clearable style="width: 240px" @change="handleQuery">
+        </el-form-item>
+        <el-form-item label="鐘舵�侊細">
+          <el-select v-model="searchForm.inspectState" clearable style="width: 200px" @change="handleQuery">
             <el-option label="寰呭鐞�" :value="0" />
             <el-option label="宸插鐞�" :value="1" />
           </el-select>
-        </div>
-        <div style="margin-left: 10px">
-          <span class="search_title">浜у搧鍚嶇О锛�</span>
+        </el-form-item>
+        <el-form-item label="浜у搧鍚嶇О锛�">
           <el-input
               v-model="searchForm.productName"
-              style="width: 240px"
+              style="width: 200px"
               placeholder="璇疯緭鍏ヤ骇鍝佸悕绉版悳绱�"
               @change="handleQuery"
               clearable
               :prefix-icon="Search"
           />
-        </div>
-        <el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>
-      </div>
-      <div>
+        </el-form-item>
+        <el-form-item label="妫�娴嬫棩鏈燂細">
+          <el-date-picker v-model="searchForm.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange"
+                          style="width: 300px"
+                          placeholder="璇烽�夋嫨" clearable @change="changeDaterange" />
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="handleQuery">鎼滅储</el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+    <div class="mb20" style="text-align: right;">
         <el-button type="primary" @click="openForm('add')">鏂板</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
         <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
       </div>
-    </div>
     <div class="table_list">
       <PIMTable
           rowKey="id"
@@ -51,22 +55,61 @@
     </div>
     <FormDia ref="formDia" @close="handleQuery"></FormDia>
     <InspectionFormDia ref="inspectionFormDia" @close="handleQuery"></InspectionFormDia>
+    <el-dialog v-model="uploadDialogVisible" title="鎷嶇収涓婁紶闄勪欢" width="680px">
+      <el-form label-width="120px">
+        <el-form-item label="涓嶅悎鏍煎浘鐗囷細">
+          <AttachmentUploadImage
+            v-model:fileList="uploadPhotoList"
+            :limit="6"
+            button-text="鎷嶇収/涓婁紶鍥剧墖"
+            :watermark-text="watermarkText"
+          />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button @click="closeUploadDialog">鍙栨秷</el-button>
+        <el-button type="primary" :loading="uploadSaving" @click="submitUploadDialog">淇濆瓨</el-button>
+      </template>
+    </el-dialog>
+    <el-dialog v-model="photoPreviewVisible" :title="photoPreviewTitle" width="900px">
+      <div v-if="photoPreviewList.length" class="photo-preview-grid">
+        <el-image
+          v-for="(url, index) in photoPreviewList"
+          :key="`${url}-${index}`"
+          :src="url"
+          fit="cover"
+          class="photo-preview-item"
+          :preview-src-list="photoPreviewList"
+          preview-teleported
+        />
+      </div>
+      <el-empty v-else description="鏆傛棤闄勪欢鐓х墖" />
+      <template #footer>
+        <el-button @click="photoPreviewVisible = false">鍏抽棴</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
 <script setup>
 import { Search } from "@element-plus/icons-vue";
-import {onMounted, ref} from "vue";
+import { computed, onMounted, ref, reactive, toRefs, nextTick, getCurrentInstance } from "vue";
 import FormDia from "@/views/qualityManagement/nonconformingManagement/components/formDia.vue";
-import {ElMessageBox} from "element-plus";
-import {qualityUnqualifiedDel, qualityUnqualifiedListPage} from "@/api/qualityManagement/nonconformingManagement.js";
+import AttachmentUploadImage from "@/components/AttachmentUpload/image/index.vue";
+import { ElMessageBox } from "element-plus";
+import { getQualityUnqualifiedInfo, qualityUnqualifiedDel, qualityUnqualifiedListPage, qualityUnqualifiedUpdate } from "@/api/qualityManagement/nonconformingManagement.js";
 import InspectionFormDia from "@/views/qualityManagement/nonconformingManagement/components/inspectionFormDia.vue";
+import useUserStore from "@/store/modules/user";
+import dayjs from "dayjs";
 
 const data = reactive({
   searchForm: {
     inspectType: "",
     inspectState: "",
     productName: "",
+    entryDate: undefined, // 褰曞叆鏃ユ湡
+    entryDateStart: undefined,
+    entryDateEnd: undefined,
   },
 });
 const { searchForm } = toRefs(data);
@@ -90,7 +133,7 @@
       } else if (params == '鍚堟牸') {
         return "success";
       } else {
-        return null;
+        return 'danger';
       }
     },
   },
@@ -155,6 +198,28 @@
     width: 120
   },
   {
+    label: "涓嶅悎鏍肩被鍨�",
+    prop: "dealType",
+    width: 120,
+    formatData: val => {
+      if (val === 0) return "杞诲井杩斿伐";
+      if (val === 1) return "涓ラ噸杩斿伐";
+      if (val === 2) return "鎶ュ簾";
+      return "-";
+    }
+  },
+  {
+    label: "淇悊宸ユ椂",
+    prop: "repairWorkHour",
+    width: 100
+  },
+  {
+    label: "閲嶇敓鏂板崟",
+    prop: "regenerateNewOrder",
+    width: 100,
+    formatData: val => (val === 1 ? "鏄�" : "鍚�")
+  },
+  {
     label: "澶勭悊浜�",
     prop: "dealName",
     width: 120
@@ -169,25 +234,26 @@
     label: "鎿嶄綔",
     align: "center",
     fixed: "right",
-    width: 120,
-    operation: [
-      {
-        name: "缂栬緫",
-        type: "text",
-        clickFun: (row) => {
-          openForm("edit", row);
+      width: 240,
+      operation: [
+        {
+          name: "澶勭悊",
+          type: "text",
+          clickFun: (row) => {
+            openInspectionForm("edit", row);
+          },
+          disabled: (row) => row.inspectState === 1,
         },
-      },
-      {
-        name: "澶勭悊",
-        type: "text",
-        clickFun: (row) => {
-          openInspectionForm("edit", row);
+        {
+          name: "鎷嶇収涓婁紶",
+          type: "text",
+          clickFun: (row) => {
+            openUploadDialog(row);
+          },
         },
-      },
-    ],
-  },
-]);
+      ],
+    },
+  ]);
 const tableData = ref([]);
 const selectedRows = ref([]);
 const tableLoading = ref(false);
@@ -198,8 +264,31 @@
 });
 const formDia = ref()
 const inspectionFormDia = ref()
+const photoPreviewVisible = ref(false)
+const photoPreviewTitle = ref("")
+const photoPreviewList = ref([])
+const uploadDialogVisible = ref(false)
+const uploadSaving = ref(false)
+const uploadPhotoList = ref([])
+const currentUploadRow = ref(null)
 const { proxy } = getCurrentInstance()
+const userStore = useUserStore()
+const watermarkText = computed(() => {
+  const now = new Date();
+  const pad = (n) => String(n).padStart(2, "0");
+  return `澶╂触甯傜幃鑻撲箰鍣ㄦ湁闄愬叕鍙�
+${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
+})
 
+const changeDaterange = (value) => {
+  searchForm.value.entryDateStart = undefined;
+  searchForm.value.entryDateEnd = undefined;
+  if (value) {
+    searchForm.value.entryDateStart = dayjs(value[0]).format("YYYY-MM-DD");
+    searchForm.value.entryDateEnd = dayjs(value[1]).format("YYYY-MM-DD");
+  }
+  getList();
+};
 // 鏌ヨ鍒楄〃
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 const handleQuery = () => {
@@ -213,7 +302,9 @@
 };
 const getList = () => {
   tableLoading.value = true;
-  qualityUnqualifiedListPage({...page, ...searchForm.value}).then(res => {
+  const params = { ...searchForm.value, ...page };
+  params.entryDate = undefined
+  qualityUnqualifiedListPage(params).then(res => {
     tableLoading.value = false;
     tableData.value = res.data.records
     page.total = res.data.total;
@@ -228,15 +319,79 @@
 
 // 鎵撳紑寮规
 const openForm = (type, row) => {
+  if (type !== 'add' && row?.inspectState === 1) {
+    proxy.$modal.msgWarning("宸插鐞嗙殑鏁版嵁涓嶈兘鍐嶇紪杈�");
+    return;
+  }
   nextTick(() => {
     formDia.value?.openDialog(type, row)
   })
 };
 // 鎵撳紑澶勭悊寮规
 const openInspectionForm = (type, row) => {
+  if (row?.inspectState === 1) {
+    proxy.$modal.msgWarning("宸插鐞嗙殑鏁版嵁涓嶈兘鍐嶅鐞�");
+    return;
+  }
   nextTick(() => {
     inspectionFormDia.value?.openDialog(type, row)
   })
+};
+const openPhotoPreview = row => {
+  const urls = String(row.photoUrls || "")
+    .split(",")
+    .map(item => item.trim())
+    .filter(Boolean);
+  photoPreviewList.value = urls;
+  photoPreviewTitle.value = `闄勪欢鐓х墖${row.productName ? ` - ${row.productName}` : ""}`;
+  photoPreviewVisible.value = true;
+};
+const openUploadDialog = async (row) => {
+  if (!row?.id) {
+    proxy.$modal.msgWarning("鏈壘鍒板綋鍓嶆暟鎹�");
+    return;
+  }
+  try {
+    const res = await getQualityUnqualifiedInfo(row.id);
+    const detail = res.data || {};
+    currentUploadRow.value = detail;
+    uploadPhotoList.value = detail.photoUrls
+      ? String(detail.photoUrls).split(",").filter(Boolean).map((url, index) => ({
+          name: `image-${index + 1}`,
+          url,
+        }))
+      : [];
+    uploadDialogVisible.value = true;
+  } catch (e) {
+    proxy.$modal.msgError("鍔犺浇闄勪欢淇℃伅澶辫触");
+  }
+};
+const closeUploadDialog = () => {
+  uploadDialogVisible.value = false;
+  uploadSaving.value = false;
+  uploadPhotoList.value = [];
+  currentUploadRow.value = null;
+};
+const submitUploadDialog = async () => {
+  if (!currentUploadRow.value?.id) {
+    proxy.$modal.msgWarning("鏈壘鍒板綋鍓嶆暟鎹�");
+    return;
+  }
+  const payload = {
+    ...currentUploadRow.value,
+    photoUrls: Array.isArray(uploadPhotoList.value)
+      ? uploadPhotoList.value.map(item => item.url || item.previewURL || item.previewUrl || item).filter(Boolean).join(",")
+      : "",
+  };
+  uploadSaving.value = true;
+  try {
+    await qualityUnqualifiedUpdate(payload);
+    proxy.$modal.msgSuccess("淇濆瓨鎴愬姛");
+    closeUploadDialog();
+    getList();
+  } catch (e) {
+    uploadSaving.value = false;
+  }
 };
 
 // 鍒犻櫎
@@ -282,4 +437,17 @@
 });
 </script>
 
-<style scoped></style>
+<style scoped>
+.photo-preview-grid {
+  display: grid;
+  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
+  gap: 12px;
+}
+
+.photo-preview-item {
+  width: 100%;
+  height: 180px;
+  border-radius: 8px;
+  overflow: hidden;
+}
+</style>

--
Gitblit v1.9.3