From 0805c8f58834e70b2a654cfa9f54fdaeaa0ddda1 Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期五, 06 六月 2025 15:59:03 +0800
Subject: [PATCH] bug修改

---
 src/views/salesManagement/invoiceLedger/index.vue |  159 ++++++++++++++++------------------------------------
 1 files changed, 50 insertions(+), 109 deletions(-)

diff --git a/src/views/salesManagement/invoiceLedger/index.vue b/src/views/salesManagement/invoiceLedger/index.vue
index e7eba1d..473969a 100644
--- a/src/views/salesManagement/invoiceLedger/index.vue
+++ b/src/views/salesManagement/invoiceLedger/index.vue
@@ -14,7 +14,7 @@
         <span class="search_title" style="margin-left: 10px">寮�绁ㄦ棩鏈燂細</span>
         <el-date-picker
             style="width: 240px"
-            v-model="form.invoiceDate"
+            v-model="searchForm.invoiceDate"
             value-format="YYYY-MM-DD"
             format="YYYY-MM-DD"
             type="date"
@@ -24,9 +24,7 @@
         <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 @click="handleOut">瀵煎嚭</el-button>
-        <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+        <el-button @click="handleOut" type="primary" style="width: 100px">瀵煎嚭</el-button>
       </div>
     </div>
     <div class="table_list">
@@ -41,8 +39,10 @@
         <el-table-column label="閿�鍞悎鍚屽彿" prop="salesContractNo" show-overflow-tooltip/>
         <el-table-column label="瀹㈡埛鍚堝悓鍙�" prop="customerContractNo" show-overflow-tooltip/>
         <el-table-column label="瀹㈡埛鍚嶇О" prop="customerName" show-overflow-tooltip/>
+        <el-table-column label="浜у搧澶х被" prop="productCategory" />
+        <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
         <el-table-column label="鍙戠エ鍙�" prop="invoiceNo" show-overflow-tooltip/>
-        <el-table-column label="鍙戠エ閲戦(鍏�)" prop="invoiceAmount" show-overflow-tooltip/>
+        <el-table-column label="鍙戠エ閲戦(鍏�)" prop="invoiceTotal" show-overflow-tooltip :formatter="formattedNumber"/>
         <el-table-column label="绋庣巼" prop="taxRate" show-overflow-tooltip/>
         <el-table-column label="寮�绁ㄤ汉" prop="invoicePerson" show-overflow-tooltip/>
         <el-table-column label="寮�绁ㄦ棩鏈�" prop="invoiceDate" show-overflow-tooltip/>
@@ -54,26 +54,24 @@
         </el-table-column>
         <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center">
           <template #default="scope">
-            <el-button link type="primary" size="small" @click="openForm('edit', scope.row);">缂栬緫</el-button>
+            <el-button link type="primary" size="small" @click="openForm(scope.row);">缂栬緫</el-button>
           </template>
         </el-table-column>
       </el-table>
       <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper" :page="page.current"
                   :limit="page.size" @pagination="paginationChange" />
     </div>
-    <el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? '鏂板寮�绁ㄥ彴璐﹂〉闈�' : '缂栬緫寮�绁ㄥ彴璐﹂〉闈�'" width="70%" @close="closeDia">
+    <el-dialog v-model="dialogFormVisible" title="寮�绁ㄥ彴璐﹂〉闈�" width="70%" @close="closeDia">
       <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
         <el-row :gutter="30">
           <el-col :span="12">
-            <el-form-item label="閿�鍞悎鍚屽彿锛�" prop="salesLedgerId">
-              <el-select v-model="form.salesLedgerId" placeholder="璇烽�夋嫨" clearable @change="ledgerChange" :disabled="operationType === 'edit'">
-                <el-option v-for="item in ledgerList" :key="item.id" :label="item.salesContractNo" :value="item.id"/>
-              </el-select>
+            <el-form-item label="閿�鍞悎鍚屽彿锛�" prop="salesContractNo">
+              <el-input v-model="form.salesContractNo" disabled></el-input>
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item label="瀹㈡埛鍚嶇О锛�" prop="customerName">
-              <el-input v-model="form.customerName" placeholder="鑷姩濉厖" clearable :disabled="operationType === 'edit'"/>
+              <el-input v-model="form.customerName" placeholder="鑷姩濉厖" clearable disabled/>
             </el-form-item>
           </el-col>
         </el-row>
@@ -84,24 +82,17 @@
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="鍙戠エ閲戦(鍏�)锛�" prop="invoiceAmount">
-              <el-input type="number" :step="0.01" v-model="form.invoiceAmount" placeholder="璇疯緭鍏�" clearable/>
+            <el-form-item label="鍙戠エ閲戦(鍏�)锛�" prop="invoiceTotal">
+              <el-input type="number" :step="0.01" v-model="form.invoiceTotal" placeholder="璇疯緭鍏�" clearable/>
             </el-form-item>
           </el-col>
         </el-row>
         <el-row :gutter="30">
-          <el-col :span="12">
-            <el-form-item label="绋庣巼锛�" prop="taxRate">
-              <el-input type="number" :step="0.01" v-model="form.taxRate" placeholder="璇疯緭鍏�" clearable/>
-            </el-form-item>
-          </el-col>
           <el-col :span="12">
             <el-form-item label="寮�绁ㄤ汉锛�" prop="invoicePerson">
-              <el-input v-model="form.invoicePerson" placeholder="璇疯緭鍏�" clearable/>
+              <el-input v-model="form.invoicePerson" placeholder="璇疯緭鍏�" clearable disabled/>
             </el-form-item>
           </el-col>
-        </el-row>
-        <el-row :gutter="30">
           <el-col :span="12">
             <el-form-item label="寮�绁ㄦ棩鏈燂細" prop="invoiceDate">
               <el-date-picker
@@ -112,6 +103,7 @@
                   type="date"
                   placeholder="璇烽�夋嫨"
                   clearable
+                  disabled
               />
             </el-form-item>
           </el-col>
@@ -196,18 +188,14 @@
 import { ref } from 'vue'
 import {Search} from "@element-plus/icons-vue";
 import {ElMessageBox } from "element-plus";
-import {
-  getSalesLedgerWithProducts,
-  ledgerListNoPage
-} from "@/api/salesManagement/salesLedger.js";
 import { getToken } from "@/utils/auth"
 import {
-  invoiceLedgerList,
-  invoiceLedgerDel,
   invoiceLedgerSaveOrUpdate,
-  invoiceLedgerDetail,
+  invoiceLedgerProductInfo,
   commitFile,
+  registrationProductPage
 } from "../../../api/salesManagement/invoiceLedger.js";
+import useUserStore from "@/store/modules/user.js";
 const { proxy } = getCurrentInstance()
 const tableData = ref([])
 const productData = ref([])
@@ -219,9 +207,6 @@
 })
 const total = ref(0)
 const fileList = ref([])
-const ledgerList = ref([])
-// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
-const operationType = ref('')
 const dialogFormVisible = ref(false)
 const data = reactive({
   searchForm: {
@@ -232,7 +217,7 @@
     salesLedgerId: '',
     customerId: '',
     invoiceNo: '',
-    invoiceAmount: '',
+    invoiceTotal: '',
     taxRate: '',
     invoicePerson: '',
     invoiceDate: '',
@@ -252,6 +237,7 @@
 })
 const { searchForm, form, rules } = toRefs(data)
 const currentId = ref('')
+const userStore = useUserStore()
 const upload = reactive({
   // 涓婁紶鐨勫湴鍧�
   url: import.meta.env.VITE_APP_BASE_API + "/invoiceLedger/uploadFile",
@@ -260,6 +246,9 @@
 })
 const matchFileType = ref(['pdf'])
 const uploadModal = ref(false)
+const formattedNumber = (row, column, cellValue) => {
+  return parseFloat(cellValue).toFixed(2);
+};
 // 鏌ヨ鍒楄〃
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 const handleQuery = () => {
@@ -273,7 +262,7 @@
 }
 const getList = () => {
   tableLoading.value = true
-  invoiceLedgerList({...searchForm.value, ...page}).then(res => {
+  registrationProductPage({...searchForm.value, ...page}).then(res => {
     tableLoading.value = false
     tableData.value = res.data.records;
     total.value = res.data.total;
@@ -285,44 +274,29 @@
 }
 // 涓昏〃鍚堣鏂规硶
 const summarizeMainTable = (param) => {
-  const { columns, data } = param;
-  const sums = [];
-  columns.forEach((column, index) => {
-    if (index === 0) {
-      sums[index] = '鍚堣';
-      return;
-    }
-    const prop = column.property;
-    if (['invoiceAmount'].includes(prop)) {
-      const values = data.map(item => Number(item[prop]));
-      if (!values.every(value => isNaN(value))) {
-        sums[index] = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0);
-      } else {
-        sums[index] = '';
-      }
-    } else {
-      sums[index] = '';
-    }
-  })
-  return sums;
+  return proxy.summarizeTable(param, ['invoiceTotal'], {
+    ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+    futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+  });
 };
 // 鎵撳紑寮规
-const openForm = (type, row) => {
-  operationType.value = type
+const openForm = (row) => {
   form.value = {}
   productData.value = []
   fileList.value = []
-  // 鏌ヨ閿�鍞悎鍚�
-  ledgerListNoPage({}).then(res => {
-    ledgerList.value = res.data;
+  currentId.value = row.id;
+
+  invoiceLedgerProductInfo({id: row.id}).then(res => {
+    form.value = {...res.data}
+    fileList.value = res.data.fileList;
+    if(!form.value.invoicePerson){
+      form.value.invoicePerson = userStore.nickName
+      form.value.entryDate = getCurrentDate();
+    }
+    if(!form.value.invoiceDate){
+      form.value.invoiceDate = getCurrentDate();
+    }
   })
-  if (type === 'edit') {
-    currentId.value = row.id;
-    invoiceLedgerDetail({id: row.id}).then(res => {
-      form.value = {...res.data}
-      fileList.value = res.data.fileList;
-    })
-  }
   dialogFormVisible.value = true
 }
 // 涓婁紶澶氫釜鏂囦欢灏辫鐩栧師鏉ョ殑
@@ -334,6 +308,7 @@
 };
 // 涓婁紶鍓嶆牎妫�
 function handleBeforeUpload(file) {
+  console.log('file',file)
   // 鏍℃鏂囦欢澶у皬
   if (file.size > 1024 * 1024 * 10) {
     proxy.$modal.msgError('涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃10MB!')
@@ -405,49 +380,6 @@
     proxy.$modal.msg("宸插彇娑�")
   })
 }
-// 鍒犻櫎
-const handleDelete = () => {
-  let ids = []
-  if (selectedRows.value.length > 0) {
-    ids = selectedRows.value.map(item => item.id);
-  } else {
-    proxy.$modal.msgWarning('璇烽�夋嫨鏁版嵁')
-    return
-  }
-  ElMessageBox.confirm(
-      '閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�',
-      '瀵煎嚭', {
-        confirmButtonText: '纭',
-        cancelButtonText: '鍙栨秷',
-        type: 'warning',
-      }
-  ).then(() => {
-    invoiceLedgerDel(ids).then(res => {
-      proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
-      getList()
-    })
-  }).catch(() => {
-    proxy.$modal.msg("宸插彇娑�")
-  })
-}
-
-// 閿�鍞彴璐︾瓫閫�
-const ledgerChange = (val) => {
-  if(val){
-    getSalesLedgerWithProducts({id: val}).then(res => {
-      form.value = {
-        salesLedgerId: res.id,
-        customerName: res.customerName,
-        customerId: res.customerId,
-        salesContractNo: res.salesContractNo
-      }
-    })
-  }else {
-    form.value.salesLedgerId = ''
-    form.value.customerName = ''
-    form.value.customerId = ''
-  }
-}
 
 // 鎵撳紑闄勪欢涓婁紶寮圭獥
 const handleDownload = (val) => {
@@ -474,6 +406,15 @@
 
 }
 
+// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
+function getCurrentDate() {
+  const today = new Date();
+  const year = today.getFullYear();
+  const month = String(today.getMonth() + 1).padStart(2, '0'); // 鏈堜唤浠�0寮�濮�
+  const day = String(today.getDate()).padStart(2, '0');
+  return `${year}-${month}-${day}`;
+}
+
 getList()
 </script>
 

--
Gitblit v1.9.3