From bc365ef47ae4e01754aeadbae26170e11c9bb80e Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 22 六月 2026 16:56:12 +0800
Subject: [PATCH] 新疆马铃薯 1.删除按钮添加操作权限

---
 src/views/salesManagement/salesLedger/index.vue |  179 ++++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 121 insertions(+), 58 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 4c13d3d..756ce00 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -56,7 +56,7 @@
             >瀵煎叆
           </el-button>
           <el-button @click="handleOut">瀵煎嚭</el-button>
-          <el-button type="danger" plain @click="handleDelete">鍒犻櫎 </el-button>
+          <el-button type="danger" plain @click="handleDelete" v-hasPermi="['salesManagement:salesLedger:remove']">鍒犻櫎 </el-button>
           <el-button type="primary" plain @click="handlePrint">鎵撳嵃 </el-button>
         </div>
       </div>
@@ -248,6 +248,21 @@
           width="200"
           show-overflow-tooltip
         />
+        <el-table-column
+          label="閫�璐х姸鎬�"
+          prop="returnStatus"
+          align="center"
+          width="100"
+        >
+          <template #default="scope">
+            <el-tag
+              :type="getReturnStatusType(scope.row.returnStatus)"
+              size="small"
+            >
+              {{ scope.row.returnStatus || '鏃犻��璐�' }}
+            </el-tag>
+          </template>
+        </el-table-column>
         <el-table-column fixed="right" label="鎿嶄綔" width="220" align="center">
           <template #default="scope">
             <el-button link type="primary" @click="openForm('view', scope.row)"
@@ -257,11 +272,7 @@
               link
               type="primary"
               @click="openForm('edit', scope.row)"
-              :disabled="
-                !scope.row.isEdit ||
-                scope.row.hasProductionRecord ||
-                !canEditLedger(scope.row)
-              "
+              :disabled="!canEditLedger(scope.row)"
               >缂栬緫
             </el-button>
             <el-button link type="primary" @click="openFileDialog(scope.row)"
@@ -408,9 +419,51 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="浠樻鏂瑰紡">
-              <el-input
+              <el-select
                 v-model="form.paymentMethod"
-                placeholder="璇疯緭鍏�"
+                placeholder="璇烽�夋嫨"
+                clearable
+                :disabled="operationType === 'view'"
+                style="width: 100%"
+              >
+                <el-option label="鐜伴噾" value="鐜伴噾" />
+                <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="purchaseContractNumber">
+              <el-select
+                v-model="form.purchaseContractNumber"
+                placeholder="璇烽�夋嫨閲囪喘鍚堝悓鍙�"
+                clearable
+                filterable
+                style="width: 100%"
+                :disabled="operationType === 'view'"
+              >
+                <el-option
+                  v-for="item in purchaseContractOptions"
+                  :key="item.purchaseContractNumber"
+                  :label="item.purchaseContractNumber + ' - ' + item.supplierName"
+                  :value="item.purchaseContractNumber"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="浜よ揣鏃ユ湡锛�" prop="entryDate">
+              <el-date-picker
+                style="width: 100%"
+                v-model="form.deliveryDate"
+                value-format="YYYY-MM-DD"
+                format="YYYY-MM-DD"
+                type="date"
+                placeholder="璇烽�夋嫨"
                 clearable
                 :disabled="operationType === 'view'"
               />
@@ -454,22 +507,6 @@
             </el-form-item>
           </el-col>
         </el-row>
-        <el-row :gutter="30">
-          <el-col :span="12">
-            <el-form-item label="浜よ揣鏃ユ湡锛�" prop="entryDate">
-              <el-date-picker
-                style="width: 100%"
-                v-model="form.deliveryDate"
-                value-format="YYYY-MM-DD"
-                format="YYYY-MM-DD"
-                type="date"
-                placeholder="璇烽�夋嫨"
-                clearable
-                :disabled="operationType === 'view'"
-              />
-            </el-form-item>
-          </el-col>
-        </el-row>
         <el-row>
           <el-form-item label="浜у搧淇℃伅锛�" prop="entryDate">
             <el-button
@@ -482,8 +519,7 @@
               v-if="operationType !== 'view'"
               plain
               type="danger"
-              @click="deleteProduct"
-              >鍒犻櫎
+              @click="deleteProduct">鍒犻櫎
             </el-button>
           </el-form-item>
         </el-row>
@@ -515,25 +551,26 @@
           <el-table-column
             label="鍚◣鍗曚环(鍏�)"
             prop="taxInclusiveUnitPrice"
-            :formatter="formattedNumber"
+            :formatter="sensitiveAmountFormatter"
           />
           <el-table-column
             label="鍚◣鎬讳环(鍏�)"
             prop="taxInclusiveTotalPrice"
-            :formatter="formattedNumber"
+            :formatter="sensitiveAmountFormatter"
           />
           <el-table-column
             label="涓嶅惈绋庢�讳环(鍏�)"
             prop="taxExclusiveTotalPrice"
-            :formatter="formattedNumber"
+            :formatter="sensitiveAmountFormatter"
           />
-          <el-table-column label="鏄惁鐢熶骇" prop="isProduction" width="150">
+          <!-- 鏄惁鐢熶骇鍒楀凡闅愯棌锛岄粯璁ゅ�间负 false -->
+          <!-- <el-table-column label="鏄惁鐢熶骇" prop="isProduction" width="150">
             <template #default="scope">
               <el-tag :type="scope.row.isProduction ? 'success' : 'info'">
                 {{ scope.row.isProduction ? "鏄�" : "鍚�" }}
               </el-tag>
             </template>
-          </el-table-column>
+          </el-table-column> -->
           <el-table-column
             fixed="right"
             label="鎿嶄綔"
@@ -823,14 +860,15 @@
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="12">
+          <!-- 鏄惁鐢熶骇瀛楁宸查殣钘忥紝榛樿鍊间负 false -->
+          <!-- <el-col :span="12">
             <el-form-item label="鏄惁鐢熶骇锛�" prop="isProduction">
               <el-radio-group v-model="productForm.isProduction">
                 <el-radio label="鏄�" :value="true" />
                 <el-radio label="鍚�" :value="false" />
               </el-radio-group>
             </el-form-item>
-          </el-col>
+          </el-col> -->
         </el-row>
       </el-form>
     </FormDialog>
@@ -1062,6 +1100,15 @@
               />
             </el-form-item>
           </el-col>
+          <el-col :span="24" v-if="deliveryForm.type === '璐ц溅'">
+            <el-form-item label="鍑哄簱鎵瑰彿锛�" prop="outboundBatches">
+              <el-input
+                v-model="deliveryForm.outboundBatches"
+                placeholder="璇疯緭鍏ュ嚭搴撴壒鍙�"
+                clearable
+              />
+            </el-form-item>
+          </el-col>
           <el-col :span="24" v-else>
             <el-form-item label="蹇�掑叕鍙革細" prop="expressCompany">
               <el-input
@@ -1180,6 +1227,7 @@
 } from "@/api/salesManagement/salesLedger.js";
 import { getStockInventoryByModelId } from "@/api/inventoryManagement/stockInventory.js";
 import { modelList, productTreeList } from "@/api/basicData/product.js";
+import { purchaseList } from "@/api/procurementManagement/procurementLedger.js";
 import useFormData from "@/hooks/useFormData.js";
 import dayjs from "dayjs";
 import FileUpload from "@/components/AttachmentUpload/file/index.vue";
@@ -1204,6 +1252,7 @@
 const customerOption = ref([]);
 const productOptions = ref([]);
 const modelOptions = ref([]);
+const purchaseContractOptions = ref([]);
 const tableLoading = ref(false);
 const page = reactive({
   current: 1,
@@ -1237,6 +1286,7 @@
     executionDate: "",
     hasProductionRecord: false,
     createTime: "",
+    purchaseContractNumber: "",
   },
   rules: {
     salesman: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
@@ -1264,7 +1314,7 @@
     taxInclusiveTotalPrice: "",
     taxExclusiveTotalPrice: "",
     invoiceType: "",
-    isProduction: false,
+    isProduction: false, // 榛樿鍊间负 false锛堝惁锛�
   },
   productRules: {
     productCategory: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
@@ -1375,22 +1425,9 @@
 const getDeliveryBatchNoList = async (productModelId) => {
   if (!productModelId) return [];
   const res = await getStockInventoryByModelId(productModelId);
-  const rawList = Array.isArray(res?.data)
-    ? res.data
-    : res?.data?.records || res?.data?.rows || [];
+  const rawList = res.data || [];
   const seenIds = new Set();
   return rawList
-    .filter((item) => {
-      if (!item?.id || !item?.batchNo || seenIds.has(item.id)) {
-        return false;
-      }
-      seenIds.add(item.id);
-      return true;
-    })
-    .map((item) => ({
-      ...item,
-      deliveryQuantity: 0,
-    }));
 };
 const validateDeliveryShippingCarNumber = (_rule, value, callback) => {
   if (deliveryForm.value.type === "璐ц溅" && !value) {
@@ -1410,6 +1447,7 @@
     expressCompany: "",
     expressNumber: "",
     type: "璐ц溅", // 璐ц溅, 蹇��
+    outboundBatches: "",
   },
   deliveryRules: {
     shippingCarNumber: [
@@ -1742,6 +1780,8 @@
   listCustomer({ current: -1, size: -1, type: 0 }).then((res) => {
     customerOption.value = res.data.records;
   });
+  // 鑾峰彇閲囪喘鍚堝悓鍒楄〃
+  await getPurchaseContractList();
   form.value.entryPerson = userStore.id;
   if (type === "add") {
     // 鏂板鏃惰缃綍鍏ユ棩鏈熶负褰撳ぉ
@@ -1749,7 +1789,7 @@
     // 绛捐鏃ユ湡榛樿涓哄綋澶�
     form.value.executionDate = getCurrentDate();
     // 鍒涘缓鏃堕棿榛樿涓哄綋澶�
-    form.value.createTime = getCurrentDate();
+    form.value.createTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
     // 榛樿鑷姩鐢熸垚閿�鍞悎鍚屽彿
     form.value.autoGenerateContractNo = true;
   } else {
@@ -1871,7 +1911,7 @@
       taxInclusiveTotalPrice: taxInclusiveTotalPrice,
       taxExclusiveTotalPrice: taxExclusiveTotalPrice,
       invoiceType: "澧炴櫘绁�",
-      isProduction: true,
+      isProduction: false, // 榛樿鍊间负 false锛堝惁锛�
       productId: p.productId,
       productModelId: p.productModelId,
     };
@@ -1927,7 +1967,7 @@
   productOperationType.value = type;
   productForm.value = {};
   if (type === "add") {
-    productForm.value.isProduction = true;
+    productForm.value.isProduction = false; // 榛樿鍊间负 false锛堝惁锛�
   }
   proxy.resetForm("productFormRef");
   if (type === "edit") {
@@ -1962,6 +2002,17 @@
     getProductOptions();
   }
   productFormVisible.value = true;
+};
+
+// 鑾峰彇閲囪喘鍚堝悓鍒楄〃
+const getPurchaseContractList = async () => {
+  try {
+    const res = await purchaseList({ current: -1, size: -1 });
+    purchaseContractOptions.value = res.rows;
+  } catch (error) {
+    console.error("鑾峰彇閲囪喘鍚堝悓鍒楄〃澶辫触", error);
+    purchaseContractOptions.value = [];
+  }
 };
 // 鎻愪氦浜у搧琛ㄥ崟
 const submitProduct = () => {
@@ -2155,7 +2206,7 @@
 };
 
 // 鎵撳嵃鍔熻兘
-const handlePrint = async () => {
+  const handlePrint = async () => {
   if (selectedRows.value.length === 0) {
     proxy.$modal.msgWarning("璇烽�夋嫨瑕佹墦鍗扮殑鏁版嵁");
     return;
@@ -2512,11 +2563,7 @@
 // 鏍煎紡鍖栨棩鏈�
 const formatDate = (dateString) => {
   if (!dateString) return getCurrentDate();
-  const date = new Date(dateString);
-  const year = date.getFullYear();
-  const month = String(date.getMonth() + 1).padStart(2, "0");
-  const day = String(date.getDate()).padStart(2, "0");
-  return `${year}/${month}/${day}`;
+  return dayjs(dateString).format("YYYY/MM/DD HH:mm:ss");
 };
 // 鏍煎紡鍖栨棩鏈熸椂闂�
 const formatDateTime = (date) => {
@@ -2860,6 +2907,7 @@
     type: "璐ц溅",
     batchNo: [],
     batchNoList,
+    outboundBatches: "",
   };
   deliveryFileList.value = [];
   deliveryFormVisible.value = true;
@@ -2902,6 +2950,10 @@
         shippingCarNumber:
           deliveryForm.value.type === "璐ц溅"
             ? deliveryForm.value.shippingCarNumber
+            : "",
+        outboundBatches:
+          deliveryForm.value.type === "璐ц溅"
+            ? deliveryForm.value.outboundBatches
             : "",
         expressCompany:
           deliveryForm.value.type === "蹇��"
@@ -2971,6 +3023,17 @@
   let res = await userStore.getInfo();
   currentFactoryName.value = res.user.currentFactoryName;
 };
+
+// 鑾峰彇閫�璐х姸鎬佹爣绛剧被鍨�
+const getReturnStatusType = (returnStatus) => {
+  const statusMap = {
+    '鏃犻��璐�': 'success',
+    '閮ㄥ垎閫�璐�': 'warning',
+    '鍏ㄩ儴閫�璐�': 'danger',
+  };
+  return statusMap[returnStatus] || 'info';
+};
+
 onMounted(() => {
   searchForm.salesContractNo = route.query.salesContractNo;
   getList();
@@ -3179,4 +3242,4 @@
     page-break-after: avoid;
   }
 }
-</style>
+</style>
\ No newline at end of file

--
Gitblit v1.9.3