From 6749fc51f07d9824640c4c2508ff242b8850a323 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 21 四月 2026 10:44:01 +0800
Subject: [PATCH] 湟水峡 1.bug修改

---
 src/views/basicData/supplierManage/index.vue |  387 +++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 261 insertions(+), 126 deletions(-)

diff --git a/src/views/basicData/supplierManage/index.vue b/src/views/basicData/supplierManage/index.vue
index af76ab2..6f02c5b 100644
--- a/src/views/basicData/supplierManage/index.vue
+++ b/src/views/basicData/supplierManage/index.vue
@@ -62,72 +62,9 @@
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item
-              label="绾崇◣浜鸿瘑鍒彿锛�"
-              prop="taxpayerIdentificationNum"
-            >
-              <el-input
-                v-model="form.taxpayerIdentificationNum"
-                placeholder="璇疯緭鍏�"
-                clearable
-              />
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="30">
-          <el-col :span="12">
             <el-form-item label="鍏徃鍦板潃锛�" prop="companyAddress">
               <el-input
                 v-model="form.companyAddress"
-                placeholder="璇疯緭鍏�"
-                clearable
-              />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="鍏徃鐢佃瘽锛�" prop="companyPhone">
-              <el-input
-                v-model="form.companyPhone"
-                placeholder="璇疯緭鍏�"
-                clearable
-              />
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="30">
-          <el-col :span="12">
-            <el-form-item label="寮�鎴疯锛�" prop="bankAccountName">
-              <el-input
-                v-model="form.bankAccountName"
-                placeholder="璇疯緭鍏�"
-                clearable
-              />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="璐﹀彿锛�" prop="bankAccountNum">
-              <el-input
-                v-model="form.bankAccountNum"
-                placeholder="璇疯緭鍏�"
-                clearable
-              />
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="30">
-          <el-col :span="12">
-            <el-form-item label="鑱旂郴浜猴細" prop="contactUserName">
-              <el-input
-                v-model="form.contactUserName"
-                placeholder="璇疯緭鍏�"
-                clearable
-              />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="鑱旂郴鐢佃瘽锛�" prop="contactUserPhone">
-              <el-input
-                v-model="form.contactUserPhone"
                 placeholder="璇疯緭鍏�"
                 clearable
               />
@@ -138,6 +75,7 @@
           <el-col :span="12">
             <el-form-item label="缁存姢浜猴細" prop="maintainUserId">
               <el-select
+								filterable
                 v-model="form.maintainUserId"
                 placeholder="璇烽�夋嫨"
                 clearable
@@ -162,8 +100,41 @@
                 type="date"
                 placeholder="璇烽�夋嫨"
                 clearable
-                disabled
               />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="30">
+          <el-col :span="12">
+            <el-form-item label="浜у搧澶х被锛�" prop="productId">
+              <el-tree-select
+                v-model="form.productId"
+                placeholder="璇烽�夋嫨"
+                clearable
+                check-strictly
+                :data="productOptions"
+                :render-after-expand="false"
+                style="width: 100%"
+                @change="getModels"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
+              <el-select
+                v-model="form.productModelId"
+                placeholder="璇烽�夋嫨"
+                clearable
+                style="width: 100%"
+                @change="getProductModel"
+              >
+                <el-option
+                  v-for="item in modelOptions"
+                  :key="item.id"
+                  :label="item.model"
+                  :value="item.id"
+                />
+              </el-select>
             </el-form-item>
           </el-col>
         </el-row>
@@ -192,6 +163,7 @@
         :disabled="upload.isUploading"
         :on-progress="handleFileUploadProgress"
         :on-success="handleFileSuccess"
+        :on-error="handleFileError"
         :auto-upload="false"
         drag
       >
@@ -200,13 +172,13 @@
         <template #tip>
           <div class="el-upload__tip text-center">
             <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
-            <!-- <el-link
+            <el-link
               type="primary"
               :underline="false"
               style="font-size: 12px; vertical-align: baseline"
               @click="importTemplate"
               >涓嬭浇妯℃澘</el-link
-            > -->
+            >
           </div>
         </template>
       </el-upload>
@@ -217,15 +189,49 @@
         </div>
       </template>
     </el-dialog>
+    <el-dialog
+      v-model="historyDialogVisible"
+      :title="`${currentHistorySupplierName || ''}鍚堜綔鍘嗗彶`"
+      width="80%"
+    >
+      <el-table
+        :data="historyTableData"
+        border
+        v-loading="historyTableLoading"
+        style="width: 100%"
+        max-height="500"
+      >
+        <el-table-column align="center" label="搴忓彿" type="index" width="60" />
+        <el-table-column label="閲囪喘鍚堝悓鍙�" prop="purchaseContractNumber" min-width="180" show-overflow-tooltip />
+        <el-table-column label="閿�鍞悎鍚屽彿" prop="salesContractNo" min-width="180" show-overflow-tooltip />
+        <el-table-column label="渚涘簲鍟嗗悕绉�" prop="supplierName" min-width="160" show-overflow-tooltip />
+        <el-table-column label="浠樻鏂瑰紡" prop="paymentMethod" min-width="120" show-overflow-tooltip />
+        <el-table-column label="鍚堝悓閲戦(鍏�)" prop="contractAmount" min-width="140" show-overflow-tooltip />
+        <el-table-column label="褰曞叆浜�" prop="recorderName" min-width="100" show-overflow-tooltip />
+        <el-table-column label="褰曞叆鏃ユ湡" prop="entryDate" min-width="120" show-overflow-tooltip />
+      </el-table>
+      <pagination
+        v-show="historyPage.total > 0"
+        :total="historyPage.total"
+        layout="total, sizes, prev, pager, next, jumper"
+        :page="historyPage.current"
+        :limit="historyPage.size"
+        @pagination="historyPagination"
+      />
+    </el-dialog>
+		<files-dia ref="filesDia"></files-dia>
   </div>
 </template>
 
 <script setup>
-import { ref } from "vue";
+import { onMounted, ref } from "vue";
 import { Search } from "@element-plus/icons-vue";
+import Pagination from "@/components/PIMTable/Pagination.vue";
 import { delSupplier } from "@/api/basicData/supplierManageFile.js";
 import { ElMessageBox } from "element-plus";
 import { userListNoPage } from "@/api/system/user.js";
+import { purchaseListPage } from "@/api/procurementManagement/procurementLedger.js";
+import { productTreeList, modelList } from "@/api/basicData/product.js";
 import {
   addSupplier,
   getSupplier,
@@ -234,6 +240,7 @@
 } from "@/api/basicData/supplierManageFile.js";
 import useUserStore from "@/store/modules/user";
 import { getToken } from "@/utils/auth.js";
+import FilesDia from "./filesDia.vue";
 const { proxy } = getCurrentInstance();
 const userStore = useUserStore();
 
@@ -241,68 +248,49 @@
   {
     label: "渚涘簲鍟嗗悕绉�",
     prop: "supplierName",
-    width: 250,
-  },
-  {
-    label: "绾崇◣浜鸿瘑鍒彿",
-    prop: "taxpayerIdentificationNum",
-    width: 230,
   },
   {
     label: "鍏徃鍦板潃",
     prop: "companyAddress",
-    width: 220,
-  },
-  {
-    label: "鑱旂郴鏂瑰紡",
-    prop: "companyPhone",
-    width:150
-  },
-  {
-    label: "寮�鎴疯",
-    prop: "bankAccountName",
-    width: 220,
-  },
-  {
-    label: "璐﹀彿",
-    prop: "bankAccountNum",
-    width: 220,
-  },
-  {
-    label: "鑱旂郴浜�",
-    prop: "contactUserName",
-  },
-  {
-    label: "鑱旂郴鐢佃瘽",
-    prop: "contactUserPhone",
-    width: 150,
   },
   {
     label: "缁存姢浜�",
     prop: "maintainUserName",
   },
-
   {
     label: "缁存姢鏃堕棿",
     prop: "maintainTime",
-    width:100
+    width:160
   },
   {
     dataType: "action",
     label: "鎿嶄綔",
     align: "center",
 		fixed: 'right',
+		width:230,
     operation: [
       {
         name: "缂栬緫",
         type: "text",
         clickFun: (row) => {
           openForm("edit", row);
-        },
-				disabled: (row) => {
-					return row.maintainUserName !== userStore.nickName
-				}
+        }
       },
+      {
+        name: "鍚堜綔鍘嗗彶",
+        type: "text",
+        clickFun: (row) => {
+          openHistoryDialog(row);
+        }
+      },
+			{
+				//璧勮川闄勪欢
+				name: "璧勮川鏂囦欢",
+				type: "text",
+				clickFun: (row) => {
+					openFilesFormDia(row)
+				}
+			}
     ],
   },
 ]);
@@ -310,7 +298,18 @@
 const selectedRows = ref([]);
 const userList = ref([]);
 const tableLoading = ref(false);
+const productOptions = ref([]);
+const modelOptions = ref([]);
+const historyDialogVisible = ref(false);
+const historyTableData = ref([]);
+const historyTableLoading = ref(false);
+const currentHistorySupplierName = ref("");
 const page = reactive({
+  current: 1,
+  size: 100,
+  total: 0,
+});
+const historyPage = reactive({
   current: 1,
   size: 100,
   total: 0,
@@ -325,32 +324,23 @@
   },
   form: {
     supplierName: "",
-    taxpayerIdentificationNum: "",
     companyAddress: "",
-    companyPhone: "",
-    bankAccountName: "",
-    bankAccountNum: "",
-    contactUserName: "",
-    contactUserPhone: "",
     maintainUserId: "",
     maintainTime: "",
+    productId: "",
+    productCategory: "",
+    productModelId: "",
+    specificationModel: "",
   },
   rules: {
     supplierName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-    taxpayerIdentificationNum: [
-      { required: true, message: "璇疯緭鍏�", trigger: "blur" },
-    ],
     companyAddress: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-    companyPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-    bankAccountName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-    bankAccountNum: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-    contactUserName: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
-    contactUserPhone: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
     maintainUserId: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
     maintainTime: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
   },
 });
 const { searchForm, form, rules } = toRefs(data);
+const filesDia = ref()
 
 // 鏌ヨ鍒楄〃
 /** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -365,7 +355,7 @@
 };
 /** 鎻愪氦涓婁紶鏂囦欢 */
 function submitFileForm() {
-  console.log(upload.url + '?updateSupport=' + upload.updateSupport)
+  upload.isUploading = true;
   proxy.$refs["uploadRef"].submit();
 }
 const getList = () => {
@@ -375,6 +365,12 @@
     tableData.value = res.data.records;
     page.total = res.data.total;
   });
+};
+// 鎵撳紑闄勪欢寮规
+const openFilesFormDia = (row) => {
+	nextTick(() => {
+		filesDia.value?.openDialog(row)
+	})
 };
 const upload = reactive({
   // 鏄惁鏄剧ず寮瑰嚭灞傦紙渚涘簲鍟嗗鍏ワ級
@@ -395,6 +391,10 @@
   upload.title = "渚涘簲鍟嗗鍏�";
   upload.open = true;
 }
+/** 涓嬭浇妯℃澘 */
+function importTemplate() {
+  proxy.download("/system/supplier/downloadTemplate", {}, "渚涘簲鍟嗗鍏ユā鏉�.xlsx");
+}
 
 /**鏂囦欢涓婁紶涓鐞� */
 const handleFileUploadProgress = (event, file, fileList) => {
@@ -403,28 +403,157 @@
 
 /** 鏂囦欢涓婁紶鎴愬姛澶勭悊 */
 const handleFileSuccess = (response, file, fileList) => {
-  upload.open = false;
   upload.isUploading = false;
-  proxy.$refs["uploadRef"].handleRemove(file);
-  getList();
+  if(response.code === 200){
+    proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+    upload.open = false;
+    proxy.$refs["uploadRef"].clearFiles();
+    getList();
+  }else if(response.code === 500){
+    proxy.$modal.msgError(response.msg);
+  }else{
+    proxy.$modal.msgWarning(response.msg);
+  }
+};
+
+/** 鏂囦欢涓婁紶澶辫触澶勭悊 */
+const handleFileError = (error, file, fileList) => {
+  upload.isUploading = false;
+  proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
 };
 // 琛ㄦ牸閫夋嫨鏁版嵁
 const handleSelectionChange = (selection) => {
   selectedRows.value = selection;
 };
+const getProductTreeData = () => {
+  return productTreeList().then((res) => {
+    productOptions.value = convertIdToValue(res);
+    return productOptions.value;
+  });
+};
+const getModels = (value) => {
+  form.value.productId = value;
+  form.value.productModelId = "";
+  form.value.specificationModel = "";
+  form.value.productCategory = findNodeById(productOptions.value, value);
+  modelList({ id: value }).then((res) => {
+    modelOptions.value = res;
+  });
+};
+const getProductModel = (value) => {
+  const index = modelOptions.value.findIndex((item) => item.id === value);
+  if (index !== -1) {
+    form.value.specificationModel = modelOptions.value[index].model;
+  } else {
+    form.value.specificationModel = "";
+  }
+};
+const findNodeById = (nodes, productId) => {
+  for (let i = 0; i < nodes.length; i++) {
+    if (nodes[i].value === productId) {
+      return nodes[i].label;
+    }
+    if (nodes[i].children && nodes[i].children.length > 0) {
+      const foundNode = findNodeById(nodes[i].children, productId);
+      if (foundNode) {
+        return foundNode;
+      }
+    }
+  }
+  return "";
+};
+const findNodeIdByLabel = (nodes, label) => {
+  for (let i = 0; i < nodes.length; i++) {
+    if (nodes[i].label === label) {
+      return nodes[i].id;
+    }
+    if (nodes[i].children && nodes[i].children.length > 0) {
+      const found = findNodeIdByLabel(nodes[i].children, label);
+      if (found) {
+        return found;
+      }
+    }
+  }
+  return "";
+};
+const convertIdToValue = (data) => {
+  return data.map((item) => {
+    const { id, children, ...rest } = item;
+    const newItem = {
+      ...rest,
+      value: id,
+    };
+    if (children && children.length > 0) {
+      newItem.children = convertIdToValue(children);
+    }
+    return newItem;
+  });
+};
+const getHistoryList = () => {
+  if (!currentHistorySupplierName.value) {
+    historyTableData.value = [];
+    historyPage.total = 0;
+    return;
+  }
+  historyTableLoading.value = true;
+  purchaseListPage({
+    supplierName: currentHistorySupplierName.value,
+    current: historyPage.current,
+    size: historyPage.size,
+  })
+    .then((res) => {
+      historyTableData.value = res.data.records || [];
+      historyPage.total = res.data.total || 0;
+    })
+    .finally(() => {
+      historyTableLoading.value = false;
+    });
+};
+const openHistoryDialog = (row) => {
+  currentHistorySupplierName.value = row.supplierName || "";
+  historyPage.current = 1;
+  historyDialogVisible.value = true;
+  getHistoryList();
+};
+const historyPagination = (obj) => {
+  historyPage.current = obj.page;
+  historyPage.size = obj.limit;
+  getHistoryList();
+};
 // 鎵撳紑寮规
 const openForm = (type, row) => {
   operationType.value = type;
   form.value = {};
+  modelOptions.value = [];
   form.value.maintainUserId = userStore.id;
   form.value.maintainTime = getCurrentDate();
   userListNoPage().then((res) => {
     userList.value = res.data;
   });
   if (type === "edit") {
-    getSupplier(row.id).then((res) => {
-      form.value = { ...res.data };
+    getProductTreeData().then(() => {
+      getSupplier(row.id).then(async (res) => {
+        form.value = { ...res.data };
+        try {
+          const productId = form.value.producutId || form.value.productId;
+          if (productId) {
+            form.value.productId = productId;
+            form.value.productCategory = findNodeById(productOptions.value, productId);
+            const models = await modelList({ id: productId });
+            modelOptions.value = models || [];
+            const currentModel = (modelOptions.value || []).find((m) => `${m.id}` === `${form.value.supplyProduct}`);
+            if (currentModel) {
+              form.value.productModelId = currentModel.id;
+              form.value.specificationModel = currentModel.model;
+            }
+          }
+        } catch (e) {
+          console.error("鍔犺浇浜у搧瑙勬牸鍨嬪彿澶辫触", e);
+        }
+      });
     });
+  } else {
+    getProductTreeData();
   }
   dialogFormVisible.value = true;
 };
@@ -442,7 +571,10 @@
 };
 // 鎻愪氦鏂板
 const submitAdd = () => {
-  addSupplier(form.value).then((res) => {
+  addSupplier({
+    ...form.value,
+    supplyProduct: form.value.productModelId,
+  }).then((res) => {
     proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
     closeDia();
     getList();
@@ -450,7 +582,10 @@
 };
 // 鎻愪氦淇敼
 const submitEdit = () => {
-  updateSupplier(form.value).then((res) => {
+  updateSupplier({
+    ...form.value,
+    supplyProduct: form.value.productModelId,
+  }).then((res) => {
     proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
     closeDia();
     getList();

--
Gitblit v1.9.3