From 07f9f8657d057a38792c3822acc9b08d83478967 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 07 五月 2026 14:23:10 +0800
Subject: [PATCH] 合并代码

---
 src/views/procurementManagement/procurementLedger/index.vue |  416 +++++++++++++++++++++++++----------------------------------
 1 files changed, 175 insertions(+), 241 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 20c6b1c..cffdcc6 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -44,7 +44,8 @@
           </el-form-item>
           <el-form-item>
             <el-button type="primary"
-                       @click="handleQuery"> 鎼滅储 </el-button>
+                       @click="handleQuery"> 鎼滅储
+            </el-button>
           </el-form-item>
         </el-form>
       </div>
@@ -53,11 +54,14 @@
       <div style="display: flex;justify-content: flex-end;margin-bottom: 20px;">
         <el-button type="primary"
                    @click="openForm('add')">鏂板鍙拌处</el-button>
-        <el-button type="primary" plain @click="handleImport">瀵煎叆</el-button>
+        <el-button type="primary"
+                   plain
+                   @click="handleImport">瀵煎叆</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
         <el-button type="danger"
                    plain
-                   @click="handleDelete">鍒犻櫎</el-button>
+                   @click="handleDelete">鍒犻櫎
+        </el-button>
       </div>
       <el-table :data="tableData"
                 border
@@ -90,6 +94,10 @@
                                prop="unit" />
               <el-table-column label="鏁伴噺"
                                prop="quantity" />
+              <el-table-column label="鍙敤鏁伴噺"
+                               prop="availableQuality" />
+              <el-table-column label="閫�璐ф暟閲�"
+                               prop="returnQuality" />
               <el-table-column label="绋庣巼(%)"
                                prop="taxRate" />
               <el-table-column label="鍚◣鍗曚环(鍏�)"
@@ -114,11 +122,11 @@
                          show-overflow-tooltip />
         <el-table-column label="閿�鍞悎鍚屽彿"
                          prop="salesContractNo"
-                          width="160"
+                         width="160"
                          show-overflow-tooltip />
         <el-table-column label="渚涘簲鍟嗗悕绉�"
                          prop="supplierName"
-                          width="160"
+                         width="160"
                          show-overflow-tooltip />
         <el-table-column label="椤圭洰鍚嶇О"
                          prop="projectName"
@@ -129,9 +137,8 @@
                          width="100"
                          show-overflow-tooltip>
           <template #default="scope">
-            <el-tag 
-              :type="getApprovalStatusType(scope.row.approvalStatus)"
-              size="small">
+            <el-tag :type="getApprovalStatusType(scope.row.approvalStatus)"
+                    size="small">
               {{ approvalStatusText[scope.row.approvalStatus] || '鏈煡鐘舵��' }}
             </el-tag>
           </template>
@@ -168,13 +175,12 @@
           <template #default="scope">
             <el-button link
                        type="primary"
-                       size="small"
                        @click="openForm('edit', scope.row)"
-                       :disabled="scope.row.approvalStatus !== 1 && scope.row.approvalStatus !== 4">缂栬緫</el-button>
+                       :disabled="scope.row.approvalStatus !== 1 && scope.row.approvalStatus !== 4">缂栬緫
+            </el-button>
             <el-button link
                        type="primary"
-                       size="small"
-                       @click="downLoadFile(scope.row)">闄勪欢</el-button>
+                       @click="openFileDialog(scope.row)">闄勪欢</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -186,12 +192,12 @@
                   @pagination="paginationChange" />
     </div>
     <FormDialog v-model="dialogFormVisible"
-               :title="operationType === 'add' ? '鏂板閲囪喘鍙拌处椤甸潰' : '缂栬緫閲囪喘鍙拌处椤甸潰'"
-               :width="'70%'"
-               :operation-type="operationType"
-               @close="closeDia"
-               @confirm="submitForm"
-               @cancel="closeDia">
+                :title="operationType === 'add' ? '鏂板閲囪喘鍙拌处椤甸潰' : '缂栬緫閲囪喘鍙拌处椤甸潰'"
+                :width="'70%'"
+                :operation-type="operationType"
+                @close="closeDia"
+                @confirm="submitForm"
+                @cancel="closeDia">
       <el-form :model="form"
                label-width="140px"
                label-position="top"
@@ -233,7 +239,8 @@
                 <el-option v-for="item in supplierList"
                            :key="item.id"
                            :label="item.supplierName"
-													 :value="item.id" >{{item.supplierName + '---' + item.supplierType}}</el-option>
+                           :value="item.id">{{ item.supplierName + '---' + item.supplierType }}
+                </el-option>
               </el-select>
             </el-form-item>
           </el-col>
@@ -295,58 +302,16 @@
             </el-form-item>
           </el-col>
         </el-row>
-        <el-row :gutter="30">
-          <el-col :span="24">
-            <el-form-item>
-              <template #label>
-                <div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">
-                  <span>瀹℃壒浜洪�夋嫨锛�</span>
-                  <el-button type="primary" size="small" @click="addApproverNode" icon="Plus">鏂板鑺傜偣</el-button>
-                </div>
-              </template>
-              <div class="approver-nodes-container">
-                <div
-                  v-for="(node, index) in approverNodes"
-                  :key="node.id"
-                  class="approver-node-item"
-                >
-                  <div class="approver-node-header">
-                    <span class="approver-node-label">瀹℃壒鑺傜偣 {{ index + 1 }}</span>
-                    <el-button
-                      v-if="approverNodes.length > 1"
-                      type="danger"
-                      size="small"
-                      text
-                      @click="removeApproverNode(index)"
-                      icon="Delete"
-                    >鍒犻櫎</el-button>
-                  </div>
-                  <el-select
-                    v-model="node.userId"
-                    placeholder="璇烽�夋嫨瀹℃壒浜�"
-                    filterable
-                    style="width: 100%;"
-                  >
-                    <el-option
-                      v-for="user in userList"
-                      :key="user.userId"
-                      :label="user.nickName"
-                      :value="user.userId"
-                    />
-                  </el-select>
-                </div>
-              </div>
-            </el-form-item>
-          </el-col>
-        </el-row>
         <el-row>
           <el-form-item label="浜у搧淇℃伅锛�"
                         prop="entryDate">
             <el-button type="primary"
-                       @click="openProductForm('add')">娣诲姞</el-button>
+                       @click="openProductForm('add')">娣诲姞
+            </el-button>
             <el-button plain
                        type="danger"
-                       @click="deleteProduct">鍒犻櫎</el-button>
+                       @click="deleteProduct">鍒犻櫎
+            </el-button>
           </el-form-item>
           <div class="select-button-group"
                style="width: 500px; margin: 20px 0;"
@@ -370,11 +335,10 @@
                          :value="item.templateName">
                 <div style="display: flex; justify-content: space-between; align-items: center;">
                   <span>{{ item.templateName }}</span>
-                  <el-icon 
-                    v-if="item.id"
-                    class="delete-icon"
-                    @click.stop="handleDeleteTemplate(item)"
-                    style="cursor: pointer; color: #f56c6c; font-size: 14px; margin-left: 8px;">
+                  <el-icon v-if="item.id"
+                           class="delete-icon"
+                           @click.stop="handleDeleteTemplate(item)"
+                           style="cursor: pointer; color: #f56c6c; font-size: 14px; margin-left: 8px;">
                     <Delete />
                   </el-icon>
                 </div>
@@ -446,8 +410,8 @@
             <template #default="scope">
               <el-button link
                          type="primary"
-                         size="small"
-                         @click="openProductForm('edit', scope.row, scope.$index)">缂栬緫</el-button>
+                         @click="openProductForm('edit', scope.row, scope.$index)">缂栬緫
+              </el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -467,52 +431,31 @@
           <el-col :span="24">
             <el-form-item label="闄勪欢鏉愭枡锛�"
                           prop="purchaseLedgerFiles">
-              <el-upload v-model:file-list="fileList"
-                         :action="upload.url"
-                         multiple
-                         ref="fileUpload"
-                         auto-upload
-                         :headers="upload.headers"
-                         :before-upload="handleBeforeUpload"
-                         :on-error="handleUploadError"
-                         :on-success="handleUploadSuccess"
-                         :on-remove="handleRemove">
-                <el-button type="primary">涓婁紶</el-button>
-                <template #tip>
-                  <div class="el-upload__tip">
-                    鏂囦欢鏍煎紡鏀寔
-                    doc锛宒ocx锛寈ls锛寈lsx锛宲pt锛宲ptx锛宲df锛宼xt锛寈ml锛宩pg锛宩peg锛宲ng锛実if锛宐mp锛宺ar锛寊ip锛�7z
-                  </div>
-                </template>
-              </el-upload>
+              <FileUpload v-model:file-list="fileList" />
             </el-form-item>
           </el-col>
         </el-row>
       </el-form>
     </FormDialog>
     <!-- 瀵煎叆寮圭獥 -->
-    <FormDialog
-      v-model="importUpload.open"
-      :title="importUpload.title"
-      :width="'600px'"
-      @close="importUpload.open = false"
-      @confirm="submitImportFile"
-      @cancel="importUpload.open = false"
-    >
-      <el-upload
-        ref="importUploadRef"
-        :limit="1"
-        accept=".xlsx,.xls"
-        :action="importUpload.url"
-        :headers="importUpload.headers"
-        :before-upload="importUpload.beforeUpload"
-        :on-success="importUpload.onSuccess"
-        :on-error="importUpload.onError"
-        :on-progress="importUpload.onProgress"
-        :on-change="importUpload.onChange"
-        :auto-upload="false"
-        drag
-      >
+    <FormDialog v-model="importUpload.open"
+                :title="importUpload.title"
+                :width="'600px'"
+                @close="importUpload.open = false"
+                @confirm="submitImportFile"
+                @cancel="importUpload.open = false">
+      <el-upload ref="importUploadRef"
+                 :limit="1"
+                 accept=".xlsx,.xls"
+                 :action="importUpload.url"
+                 :headers="importUpload.headers"
+                 :before-upload="importUpload.beforeUpload"
+                 :on-success="importUpload.onSuccess"
+                 :on-error="importUpload.onError"
+                 :on-progress="importUpload.onProgress"
+                 :on-change="importUpload.onChange"
+                 :auto-upload="false"
+                 drag>
         <i class="el-icon-upload"></i>
         <div class="el-upload__text">
           灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em>
@@ -520,18 +463,20 @@
         <template #tip>
           <div class="el-upload__tip">
             浠呮敮鎸� xls/xlsx锛屽ぇ灏忎笉瓒呰繃 10MB銆�
-            <el-button link type="primary" @click="downloadTemplate">涓嬭浇瀵煎叆妯℃澘</el-button>
+            <el-button link
+                       type="primary"
+                       @click="downloadTemplate">涓嬭浇瀵煎叆妯℃澘</el-button>
           </div>
         </template>
       </el-upload>
     </FormDialog>
     <FormDialog v-model="productFormVisible"
-               :title="productOperationType === 'add' ? '鏂板浜у搧' : '缂栬緫浜у搧'"
-               :width="'40%'"
-               :operation-type="productOperationType"
-               @close="closeProductDia"
-               @confirm="submitProduct"
-               @cancel="closeProductDia">
+                :title="productOperationType === 'add' ? '鏂板浜у搧' : '缂栬緫浜у搧'"
+                :width="'40%'"
+                :operation-type="productOperationType"
+                @close="closeProductDia"
+                @confirm="submitProduct"
+                @cancel="closeProductDia">
       <el-form :model="productForm"
                label-width="140px"
                label-position="top"
@@ -544,6 +489,7 @@
               <el-tree-select v-model="productForm.productId"
                               placeholder="璇烽�夋嫨"
                               clearable
+                              filterable
                               check-strictly
                               @change="getModels"
                               :data="productOptions"
@@ -558,6 +504,7 @@
                           prop="productModelId">
               <el-select v-model="productForm.productModelId"
                          placeholder="璇烽�夋嫨"
+                         filterable
                          clearable
                          @change="getProductModel">
                 <el-option v-for="item in modelOptions"
@@ -584,12 +531,10 @@
                          placeholder="璇烽�夋嫨"
                          clearable
                          @change="mathNum">
-                <el-option label="1"
-                           value="1" />
-                <el-option label="6"
-                           value="6" />
-                <el-option label="13"
-                           value="13" />
+                <el-option v-for="dict in tax_rate"
+                           :key="dict.value"
+                           :label="dict.label"
+                           :value="dict.value" />
               </el-select>
             </el-form-item>
           </el-col>
@@ -688,15 +633,16 @@
         </el-row>
       </el-form>
     </FormDialog>
-    <FileListDialog 
-      ref="fileListRef" 
-      v-model="fileListDialogVisible"
-      title="闄勪欢鍒楄〃"
-    />
+    <FileList v-if="fileListDialogVisible"
+              v-model:visible="fileListDialogVisible"
+              record-type="purchase_ledger"
+              :record-id="recordId" />
   </div>
 </template>
 
 <script setup>
+  import FormDialog from "@/components/Dialog/FormDialog.vue";
+  import FileListDialog from "@/components/Dialog/FileListDialog.vue";
   import { getToken } from "@/utils/auth";
   import pagination from "@/components/PIMTable/Pagination.vue";
   import {
@@ -710,10 +656,7 @@
   import { Search, Delete } from "@element-plus/icons-vue";
   import { ElMessageBox, ElMessage } from "element-plus";
   import { userListNoPage } from "@/api/system/user.js";
-  import FormDialog from '@/components/Dialog/FormDialog.vue';
-  import FileListDialog from '@/components/Dialog/FileListDialog.vue';
   import {
-    getSalesLedgerWithProducts,
     addOrUpdateSalesLedgerProduct,
     delProduct,
     delLedgerFile,
@@ -734,8 +677,12 @@
     delPurchaseTemplate,
   } from "@/api/procurementManagement/procurementLedger.js";
   import useFormData from "@/hooks/useFormData.js";
+  const FileList = defineAsyncComponent(() =>
+    import("@/components/Dialog/FileList.vue")
+  );
 
   const { proxy } = getCurrentInstance();
+  const { tax_rate } = proxy.useDict("tax_rate");
   const tableData = ref([]);
   const productData = ref([]);
   const selectedRows = ref([]);
@@ -746,6 +693,7 @@
   const salesContractList = ref([]);
   const supplierList = ref([]);
   const tableLoading = ref(false);
+  const fileListDialogVisible = ref(false);
   const page = reactive({
     current: 1,
     size: 100,
@@ -755,18 +703,9 @@
   import useUserStore from "@/store/modules/user";
   import { modelList, productTreeList } from "@/api/basicData/product.js";
   import dayjs from "dayjs";
+  import FileUpload from "@/components/AttachmentUpload/file/index.vue";
 
   const userStore = useUserStore();
-
-  // 瀹℃壒浜鸿妭鐐癸紙浠块攢鍞彴璐﹀彂璐у鎵逛汉锛�
-  const approverNodes = ref([{ id: 1, userId: null }]);
-  let nextApproverId = 2;
-  const addApproverNode = () => {
-    approverNodes.value.push({ id: nextApproverId++, userId: null });
-  };
-  const removeApproverNode = (index) => {
-    approverNodes.value.splice(index, 1);
-  };
 
   // 璁㈠崟瀹℃壒鐘舵�佹樉绀烘枃鏈�
   const approvalStatusText = {
@@ -777,12 +716,12 @@
   };
 
   // 鑾峰彇瀹℃壒鐘舵�佹爣绛剧被鍨�
-  const getApprovalStatusType = (status) => {
+  const getApprovalStatusType = status => {
     const typeMap = {
-      1: "info",      // 寰呭鏍� - 鐏拌壊
-      2: "warning",   // 瀹℃壒涓� - 姗欒壊
-      3: "success",   // 瀹℃壒閫氳繃 - 缁胯壊
-      4: "danger",    // 瀹℃壒澶辫触 - 绾㈣壊
+      1: "info", // 寰呭鏍� - 鐏拌壊
+      2: "warning", // 瀹℃壒涓� - 姗欒壊
+      3: "success", // 瀹℃壒閫氳繃 - 缁胯壊
+      4: "danger", // 瀹℃壒澶辫触 - 绾㈣壊
     };
     return typeMap[status] || "";
   };
@@ -864,7 +803,8 @@
         form.value.paymentMethod = matchedTemplate.paymentMethod;
       }
       // 妯℃澘鏁版嵁涓殑浜у搧瀛楁鏄� productList锛岄渶瑕佽浆鎹负 productData
-      productData.value = matchedTemplate.productList || matchedTemplate.productData || [];
+      productData.value =
+        matchedTemplate.productList || matchedTemplate.productData || [];
     } else {
       // 鏈尮閰嶅埌宸叉湁妯℃澘锛岃涓烘柊妯℃澘
       currentTemplateId.value = null;
@@ -912,14 +852,11 @@
       supplierId: "",
       paymentMethod: "",
       executionDate: "",
-      isChecked: true,
+      isChecked: false,
     },
     rules: {
       purchaseContractNumber: [
         { required: true, message: "璇疯緭鍏�", trigger: "blur" },
-      ],
-      approverId: [
-        { required: true, message: "璇烽�夋嫨瀹℃壒浜�", trigger: "change" },
       ],
       projectName: [
         { required: true, message: "璇疯緭鍏ラ」鐩悕绉�", trigger: "blur" },
@@ -960,7 +897,7 @@
       taxExclusiveTotalPrice: "",
       invoiceType: "",
       warnNum: "",
-      isChecked: true,
+      isChecked: false,
     },
     productRules: {
       productId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
@@ -998,7 +935,7 @@
     url: import.meta.env.VITE_APP_BASE_API + "/purchase/ledger/import",
     headers: { Authorization: "Bearer " + getToken() },
     isUploading: false,
-    beforeUpload: (file) => {
+    beforeUpload: file => {
       const isExcel = file.name.endsWith(".xlsx") || file.name.endsWith(".xls");
       const isLt10M = file.size / 1024 / 1024 < 10;
       if (!isExcel) {
@@ -1047,7 +984,11 @@
 
   // 涓嬭浇瀵煎叆妯℃澘锛堝鍚庣璺緞涓嶅悓锛屽彲鍦ㄦ澶勮皟鏁达級
   const downloadTemplate = () => {
-    proxy.download("/purchase/ledger/exportTemplate", {}, "閲囪喘鍙拌处瀵煎叆妯℃澘.xlsx");
+    proxy.download(
+      "/purchase/ledger/exportTemplate",
+      {},
+      "閲囪喘鍙拌处瀵煎叆妯℃澘.xlsx"
+    );
   };
 
   const submitImportFile = () => {
@@ -1112,29 +1053,27 @@
     // 妫�鏌ユ槸鍚︽湁浜у搧鏁版嵁
     if (!productData.value || productData.value.length === 0) {
       ElMessage({
-        message: '璇峰厛娣诲姞浜у搧淇℃伅',
-        type: 'warning',
+        message: "璇峰厛娣诲姞浜у搧淇℃伅",
+        type: "warning",
       });
       return;
     }
 
     try {
-      // 鑾峰彇瀹℃壒浜篒D瀛楃涓�
-      const approveUserIds = approverNodes.value
-        .filter(node => node.userId)
-        .map(node => node.userId)
-        .join(",");
-      
       let params = {
         productData: proxy.HaveJson(productData.value),
         supplierId: form.value.supplierId,
         paymentMethod: form.value.paymentMethod,
         recorderId: form.value.recorderId,
         projectName: form.value.projectName,
-        approveUserIds: approveUserIds,
         templateName: templateName.value.trim(),
       };
-      console.log("template params ===>", params, "currentTemplateId:", currentTemplateId.value);
+      console.log(
+        "template params ===>",
+        params,
+        "currentTemplateId:",
+        currentTemplateId.value
+      );
 
       // 濡傛灉 currentTemplateId 鏈夊�硷紝璇存槑褰撳墠鏄�滅紪杈戝凡鏈夋ā鏉库�� 鈫� 璋冪敤鏇存柊鎺ュ彛
       // 鍚﹀垯涓衡�滄柊寤烘ā鏉库�� 鈫� 璋冪敤鏂板鎺ュ彛
@@ -1273,8 +1212,11 @@
         return;
       }
     }
-    
+
     await getTemplateList();
+    await userListNoPage().then(res => {
+      userList.value = res.data;
+    });
     operationType.value = type;
     form.value = {};
     productData.value = [];
@@ -1282,26 +1224,19 @@
     templateName.value = "";
     filterInputValue.value = "";
     isTemplateNameDuplicate.value = false;
-    // 閲嶇疆瀹℃壒浜鸿妭鐐癸紙榛樿涓�涓┖鑺傜偣锛�
-    approverNodes.value = [{ id: 1, userId: null }];
-    nextApproverId = 2;
     try {
       // 骞惰鍔犺浇鍩虹鏁版嵁
-      const [userRes, salesRes, supplierRes] = await Promise.all([
-        userListNoPage(),
+      const [salesRes, supplierRes] = await Promise.all([
         getSalesNo(),
         getOptions(),
       ]);
 
-      userList.value = userRes.data || [];
       salesContractList.value = salesRes || [];
       // 渚涘簲鍟嗚繃婊ゅ嚭isWhite=0 鐨勬暟鎹�
       supplierList.value = (supplierRes.data || []).filter(
         item => item.isWhite === 0
       );
 
-      // 璁剧疆榛樿鍊�
-      form.value.recorderId = userStore.id;
       form.value.entryDate = getCurrentDate();
 
       if (type === "add") {
@@ -1322,16 +1257,7 @@
           const purchaseRes = await getPurchaseById({ id: row.id, type: 2 });
           form.value = { ...purchaseRes };
           productData.value = purchaseRes.productData || [];
-          fileList.value = purchaseRes.salesLedgerFiles || [];
-          // 濡傛灉缂栬緫鏃舵湁瀹℃壒浜猴紝瑙f瀽瀹℃壒浜篒D瀛楃涓插苟璁剧疆鍒拌妭鐐逛腑
-          if (purchaseRes.approveUserIds) {
-            const approverIds = purchaseRes.approveUserIds.split(",");
-            approverNodes.value = approverIds.map((id, index) => ({
-              id: index + 1,
-              userId: Number(id)
-            }));
-            nextApproverId = approverIds.length + 1;
-          }
+          fileList.value = purchaseRes.storageBlobVOS || [];
         } catch (error) {
           console.error("鍔犺浇閲囪喘鍙拌处鏁版嵁澶辫触:", error);
           proxy.$modal.msgError("鍔犺浇鏁版嵁澶辫触");
@@ -1349,6 +1275,7 @@
       proxy.$modal.msgError("鍔犺浇鍩虹鏁版嵁澶辫触");
     }
   };
+
   // 涓婁紶鍓嶆牎妫�
   function handleBeforeUpload(file) {
     // 鏍℃鏂囦欢澶у皬
@@ -1359,11 +1286,13 @@
     proxy.$modal.loading("姝e湪涓婁紶鏂囦欢锛岃绋嶅��...");
     return true;
   }
+
   // 涓婁紶澶辫触
   function handleUploadError(err) {
     proxy.$modal.msgError("涓婁紶鏂囦欢澶辫触");
     proxy.$modal.closeLoading();
   }
+
   // 涓婁紶鎴愬姛鍥炶皟
   function handleUploadSuccess(res, file, uploadFiles) {
     proxy.$modal.closeLoading();
@@ -1375,6 +1304,7 @@
       proxy.$refs.fileUpload.handleRemove(file);
     }
   }
+
   // 绉婚櫎鏂囦欢
   async function handleRemove(file) {
     if (!file?.id) {
@@ -1396,18 +1326,11 @@
       }
     }
   }
+
   // 鎻愪氦琛ㄥ崟
   const submitForm = () => {
     proxy.$refs["formRef"].validate(valid => {
       if (valid) {
-        // 瀹℃壒浜哄繀濉牎楠岋紙鎵�鏈夎妭鐐归兘瑕侀�変汉锛�
-        const hasEmptyApprover = approverNodes.value.some(node => !node.userId);
-        if (hasEmptyApprover) {
-          proxy.$modal.msgError("璇蜂负鎵�鏈夊鎵硅妭鐐归�夋嫨瀹℃壒浜猴紒");
-          return;
-        }
-        const approveUserIds = approverNodes.value.map(node => node.userId).join(",");
-        
         if (productData.value.length > 0) {
           // 鏂板鏃讹紝闇�瑕佷粠姣忎釜浜у搧瀵硅薄涓垹闄� id 瀛楁
           let processedProductData = productData.value;
@@ -1422,13 +1345,8 @@
           proxy.$modal.msgWarning("璇锋坊鍔犱骇鍝佷俊鎭�");
           return;
         }
-        let tempFileIds = [];
-        if (fileList.value.length > 0) {
-          tempFileIds = fileList.value.map(item => item.tempId);
-        }
-        form.value.tempFileIds = tempFileIds;
+        form.value.storageBlobDTOS = fileList.value;
         form.value.type = 2;
-        form.value.approveUserIds = approveUserIds;
 
         // 濡傛灉salesLedgerId涓虹┖锛屽垯涓嶄紶閫抯alesContractNo
         if (!form.value.salesLedgerId) {
@@ -1452,9 +1370,6 @@
   // 鍏抽棴寮规
   const closeDia = () => {
     proxy.resetForm("formRef");
-    // 閲嶇疆瀹℃壒浜鸿妭鐐癸紙榛樿涓�涓┖鑺傜偣锛�
-    approverNodes.value = [{ id: 1, userId: null }];
-    nextApproverId = 2;
     dialogFormVisible.value = false;
   };
   // 鎵撳紑浜у搧寮规
@@ -1464,17 +1379,21 @@
     productForm.value = {};
     proxy.resetForm("productFormRef");
     productFormVisible.value = true;
-    
+
     // 鍏堣幏鍙栦骇鍝侀�夐」锛岀‘淇濇暟鎹姞杞藉畬鎴�
     await getProductOptions();
-    
+
     // 绛夊緟 DOM 鏇存柊
     await nextTick();
-    
+
+    if (type === "add") {
+      productForm.value.isChecked = false;
+    }
+
     if (type === "edit") {
       // 澶嶅埗琛屾暟鎹�
       productForm.value = { ...row };
-      
+
       // 濡傛灉鏄粠妯℃澘鍔犺浇鐨勬暟鎹紝鍙兘娌℃湁 productId 鍜� productModelId
       // 闇�瑕佹牴鎹� productCategory 鍜� specificationModel 鏉ユ煡鎵惧搴旂殑 ID
       if (!productForm.value.productId && productForm.value.productCategory) {
@@ -1485,25 +1404,34 @@
               return nodes[i].value;
             }
             if (nodes[i].children && nodes[i].children.length > 0) {
-              const found = findProductIdByCategory(nodes[i].children, categoryName);
+              const found = findProductIdByCategory(
+                nodes[i].children,
+                categoryName
+              );
               if (found) return found;
             }
           }
           return null;
         };
-        
-        const productId = findProductIdByCategory(productOptions.value, productForm.value.productCategory);
+
+        const productId = findProductIdByCategory(
+          productOptions.value,
+          productForm.value.productCategory
+        );
         if (productId) {
           productForm.value.productId = productId;
           // 鑾峰彇鍨嬪彿鍒楄〃骞剁瓑寰呭畬鎴�
           const modelRes = await modelList({ id: productId });
           modelOptions.value = modelRes;
-          
+
           // 绛夊緟 DOM 鏇存柊
           await nextTick();
-          
+
           // 鏍规嵁 specificationModel 鏌ユ壘 productModelId
-          if (productForm.value.specificationModel && modelOptions.value.length > 0) {
+          if (
+            productForm.value.specificationModel &&
+            modelOptions.value.length > 0
+          ) {
             const modelItem = modelOptions.value.find(
               item => item.model === productForm.value.specificationModel
             );
@@ -1517,15 +1445,15 @@
       } else if (productForm.value.productId) {
         // 濡傛灉鏈� productId锛屾甯稿姞杞藉瀷鍙峰垪琛�
         await getModels(productForm.value.productId);
-        
+
         // 绛夊緟 DOM 鏇存柊
         await nextTick();
-        
+
         if (productForm.value.productModelId) {
           getProductModel(productForm.value.productModelId);
         }
       }
-      
+
       // 鏈�鍚庡啀绛夊緟涓�娆� DOM 鏇存柊锛岀‘淇濇墍鏈夋暟鎹兘宸茶缃�
       await nextTick();
     }
@@ -1574,6 +1502,7 @@
     }
     return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
   };
+
   function convertIdToValue(data) {
     return data.map(item => {
       const { id, children, ...rest } = item;
@@ -1588,6 +1517,7 @@
       return newItem;
     });
   }
+
   // 鎻愪氦浜у搧琛ㄥ崟
   const submitProduct = () => {
     proxy.$refs["productFormRef"].validate(valid => {
@@ -1648,11 +1578,9 @@
           delProduct(ids).then(res => {
             proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
             closeProductDia();
-            getPurchaseById({ id: currentId.value, type: 2 }).then(
-              res => {
-                productData.value = res.productData;
-              }
-            );
+            getPurchaseById({ id: currentId.value, type: 2 }).then(res => {
+              productData.value = res.productData;
+            });
           });
         })
         .catch(() => {
@@ -1683,12 +1611,14 @@
   const handleDelete = () => {
     let ids = [];
     if (selectedRows.value.length > 0) {
-      ids = selectedRows.value.map(item => item.id);
+      ids = selectedRows.value
+        .filter(item => item.salesLedgerId === null)
+        .map(item => item.id);
     } else {
       proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
       return;
     }
-    ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+    ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎", {
       confirmButtonText: "纭",
       cancelButtonText: "鍙栨秷",
       type: "warning",
@@ -1703,6 +1633,7 @@
         proxy.$modal.msg("宸插彇娑�");
       });
   };
+
   // 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
   function getCurrentDate() {
     const today = new Date();
@@ -1711,6 +1642,7 @@
     const day = String(today.getDate()).padStart(2, "0");
     return `${year}-${month}-${day}`;
   }
+
   const mathNum = () => {
     if (!productForm.value.taxRate) {
       proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
@@ -1843,14 +1775,6 @@
     }
   };
 
-  const fileListRef = ref(null);
-  const fileListDialogVisible = ref(false);
-  const downLoadFile = row => {
-    if (fileListRef.value) {
-      fileListRef.value.open(row.salesLedgerFiles);
-    }
-  };
-
   // 鑾峰彇妯℃澘淇℃伅
   const getTemplateList = async () => {
     let res = await getPurchaseTemplateList();
@@ -1859,13 +1783,19 @@
     }
   };
 
+  // 鎵撳紑闄勪欢寮规
+  const openFileDialog = async row => {
+    recordId.value = row.id;
+    fileListDialogVisible.value = true;
+  };
+
   // 鍒犻櫎妯℃澘
-  const handleDeleteTemplate = async (item) => {
+  const handleDeleteTemplate = async item => {
     if (!item.id) {
       proxy.$modal.msgWarning("鏃犳硶鍒犻櫎璇ユā鏉�");
       return;
     }
-    
+
     try {
       await ElMessageBox.confirm(
         `纭畾瑕佸垹闄ゆā鏉�"${item.templateName}"鍚楋紵`,
@@ -1876,7 +1806,7 @@
           type: "warning",
         }
       );
-      
+
       const res = await delPurchaseTemplate([item.id]);
       if (res && res.code === 200) {
         ElMessage({
@@ -1918,18 +1848,21 @@
     opacity: 0.6;
     background-color: #f5f7fa;
   }
+
   .el-row {
     justify-content: space-between;
     align-items: center;
   }
+
   .no-arrow-select {
     --el-select-suffix-icon-color: transparent; /* 闅愯棌榛樿涓嬫媺绠ご */
   }
+
   .select-button-group {
     display: flex;
     align-items: center;
   }
-  
+
   // 瀹℃壒浜鸿妭鐐瑰鍣ㄦ牱寮�
   .approver-nodes-container {
     display: flex;
@@ -1940,7 +1873,7 @@
     border-radius: 4px;
     border: 1px solid #e4e7ed;
   }
-  
+
   .approver-node-item {
     flex: 0 0 calc(33.333% - 12px);
     min-width: 200px;
@@ -1949,41 +1882,42 @@
     border-radius: 4px;
     border: 1px solid #dcdfe6;
     transition: all 0.3s;
-    
+
     &:hover {
       border-color: #409eff;
       box-shadow: 0 2px 8px rgba(64, 158, 255, 0.1);
     }
   }
-  
+
   .approver-node-header {
     display: flex;
     justify-content: space-between;
     align-items: center;
     margin-bottom: 8px;
   }
-  
+
   .approver-node-label {
     font-size: 13px;
     font-weight: 500;
     color: #606266;
   }
-  
+
   @media (max-width: 1200px) {
     .approver-node-item {
       flex: 0 0 calc(50% - 8px);
     }
   }
-  
+
   @media (max-width: 768px) {
     .approver-node-item {
       flex: 0 0 100%;
     }
   }
-  
+
   // 鍒犻櫎鍥炬爣鏍峰紡
   .delete-icon {
     transition: all 0.3s;
+
     &:hover {
       color: #f56c6c !important;
       transform: scale(1.2);

--
Gitblit v1.9.3