From d6c50376cca57aae25141f537c3db9088660b28f Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期五, 23 五月 2025 15:21:59 +0800
Subject: [PATCH] 采购管理>来票登记=》数据新增发票时数据校验 处理调整ui 采购管理>来票台账=》重构模块 调整前端交互逻辑 采购管理>付款台账=》后端联调

---
 src/views/procurementManagement/procurementInvoiceLedger/index.vue |  487 +++++++++---------------------------------------
 src/api/procurementManagement/procurementInvoiceLedger.js          |    8 
 src/views/procurementManagement/invoiceEntry/index.vue             |   23 +
 src/views/procurementManagement/paymentEntry/index.vue             |   46 +++-
 src/api/procurementManagement/paymentEntry.js                      |    8 
 5 files changed, 158 insertions(+), 414 deletions(-)

diff --git a/src/api/procurementManagement/paymentEntry.js b/src/api/procurementManagement/paymentEntry.js
index 9abb7ca..53f865b 100644
--- a/src/api/procurementManagement/paymentEntry.js
+++ b/src/api/procurementManagement/paymentEntry.js
@@ -53,4 +53,12 @@
         method: 'delete',
         data: query
     })
+}
+// 鑾峰彇鍙戠エ鍙峰拰鍙戠エ閲戦
+export function getTicketNo(query){
+    return request({
+        url: "/purchase/registration/getTicketNo",
+        method: "get",
+        params: query
+    })
 }
\ No newline at end of file
diff --git a/src/api/procurementManagement/procurementInvoiceLedger.js b/src/api/procurementManagement/procurementInvoiceLedger.js
index 12efa78..c739a86 100644
--- a/src/api/procurementManagement/procurementInvoiceLedger.js
+++ b/src/api/procurementManagement/procurementInvoiceLedger.js
@@ -40,4 +40,12 @@
         method: 'delete',
         data: query
     })
+}
+// 瀛愯〃鏍兼煡璇�
+export function productRecordList(query){
+    return request({
+        url: '/purchase/registration/productRecordList',
+        method: 'get',
+        params: query
+    })
 }
\ No newline at end of file
diff --git a/src/views/procurementManagement/invoiceEntry/index.vue b/src/views/procurementManagement/invoiceEntry/index.vue
index 070b7ce..cac76ba 100644
--- a/src/views/procurementManagement/invoiceEntry/index.vue
+++ b/src/views/procurementManagement/invoiceEntry/index.vue
@@ -120,13 +120,17 @@
           <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
           <el-table-column label="鏈鏉ョエ鏁�" prop="ticketsNum" width="170">
             <template #default="scope">
-              <el-input-number v-model="scope.row.ticketsNum" :precision="0" :step="1" clearable style="width: 100%"
-                @blur="invoiceNumBlur(scope.row)" />
+              <el-input-number v-model="scope.row.ticketsNum" placeholder="璇烽�夋嫨" :precision="0" :step="1" clearable style="width: 100%"
+                @change="invoiceNumBlur(scope.row)" />
             </template>
           </el-table-column>
-          <el-table-column label="鏈鏉ョエ閲戦(鍏�)" prop="ticketsAmount" :formatter="formattedNumber"></el-table-column>
+          <el-table-column label="鏈鏉ョエ閲戦(鍏�)" prop="ticketsAmount" :formatter="formattedNumber">
+            <template #default="scope">
+              {{ scope.row.ticketsAmount || 0 }}
+            </template>
+          </el-table-column>
           <el-table-column label="鏈潵绁ㄦ暟" prop="futureTickets"
-            :formatter="(row) => row.futureTickets == null || row.futureTickets === '' ? row.quantity : row.futureTickets">
+            : ="(row) => row.futureTickets == null || row.futureTickets === '' ? row.quantity : row.futureTickets">
           </el-table-column>
           <el-table-column label="鏈潵绁ㄩ噾棰�(鍏�)" prop="futureTicketsAmount"
             :formatter="(row) => (row.futureTicketsAmount !== undefined && row.futureTicketsAmount !== null && row.futureTicketsAmount !== '' ? row.futureTicketsAmount : row.taxExclusiveTotalPrice)">
@@ -188,9 +192,13 @@
     purchaseLedgerNo: '',
     issUerId: '', // 寮�绁ㄤ汉id
     issUer: '' ,// 寮�绁ㄤ汉濮撳悕
+    invoiceNumber:"", // 鍙戠エ鍙�
+    invoiceAmount:"", // 鍙戠エ閲戦
   },
   rules: {
-    purchaseLedgerId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+    invoiceNumber: [{ required: true, message: '璇疯緭鍏ュ彂绁ㄥ彿' , trigger: 'blur' },{type:"string"}],
+    invoiceAmount: [{ required: true, message: '璇疯緭鍏ュ彂绁ㄩ噾棰�' , trigger: 'blur'}],
+    
   }
 })
 const { searchForm, form, rules } = toRefs(data)
@@ -279,6 +287,7 @@
 
 // 鎵撳紑寮规
 const openForm = (type, row) => {
+  invoiceNumBlur(row)
   operationType.value = type
   form.value = {}
   productData.value = []
@@ -396,8 +405,8 @@
 }
 //鏈寮�绁ㄥけ鐒︽搷浣�
 const invoiceNumBlur = (row) => {
-  if (!row.ticketsNum) {
-    row.ticketsNum = 0
+  if (!row.ticketsNum || row.ticketsNum === '') {
+      row.ticketsNum = 0
   }
   if (Number(row.ticketsNum) > Number(row.futureTickets)) {
     proxy.$modal.msgWarning('鏈寮�绁ㄦ暟涓嶅緱澶т簬鏈紑绁ㄦ暟')
diff --git a/src/views/procurementManagement/paymentEntry/index.vue b/src/views/procurementManagement/paymentEntry/index.vue
index 5f8054a..a209b87 100644
--- a/src/views/procurementManagement/paymentEntry/index.vue
+++ b/src/views/procurementManagement/paymentEntry/index.vue
@@ -46,7 +46,9 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="鍙戠エ鍙凤細" prop="invoiceNumber">
-              <el-input v-model="form.invoiceNumber" placeholder="鑷姩濉厖" clearable disabled/>
+              <el-select v-model="form.invoiceNumber" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'edit'" @change="setInvoiceAmount">
+                <el-option v-for="item in invoiceNumberList" :key="item.id" :label="item.invoiceNumber" :value="item.invoiceNumber"/>
+              </el-select>
             </el-form-item>
           </el-col>
         </el-row>
@@ -58,7 +60,10 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="绋庣巼(%)锛�" prop="taxRate">
-              <el-input type="number" :step="0.01" v-model="form.taxRate" placeholder="鑷姩濉厖" clearable disabled/>
+              <!-- <el-input type="number" :step="0.01" v-model="form.taxRate" placeholder="鑷姩濉厖" clearable/> -->
+               <el-select v-model="form.taxRate"  placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'edit'">
+                <el-option v-for="item in taxRateSelection" :key="item.value" :label="item.label" :value="item.value"/>
+              </el-select>
             </el-form-item>
           </el-col>
         </el-row>
@@ -121,10 +126,18 @@
   paymentRegistrationAdd, paymentRegistrationDel,
   paymentRegistrationEdit,
   registrationInfo,
-  registrationList
+  registrationList,
+  getTicketNo
 } from "@/api/procurementManagement/paymentEntry.js";
 const { proxy } = getCurrentInstance()
-
+const taxRateSelection = [
+  { value: '0', label: '0%' },
+  { value: '3', label: '3%' },
+  { value: '6', label: '6%' },
+  { value: '9', label: '9%' },
+  { value: '13', label: '13%' },
+  { value: '17', label: '17%' },
+]
 const tableColumn = ref([
   {
     label: '閲囪喘鍚堝悓鍙�',
@@ -145,10 +158,6 @@
   {
     label: '鍙戠エ閲戦(鍏�)',
     prop: 'invoiceAmount'
-  },
-  {
-    label: '绋庣巼(%)',
-    prop: 'taxRate'
   },
   {
     label: '寰呬粯娆鹃噾棰�(鍏�)',
@@ -173,6 +182,7 @@
 const selectedRows = ref([])
 const tableLoading = ref(false)
 const purchaseLedgerList = ref([])
+const invoiceNumberList = ref([])
 const userStore = useUserStore()
 const page = reactive({
   current: 1,
@@ -235,6 +245,7 @@
 const openForm = (type, row) => {
   operationType.value = type
   form.value = {}
+  invoiceNumberList.value = []
   // 鏌ヨ閲囪喘鍚堝悓鍙�
   getPurchaseNo().then(res => {
     purchaseLedgerList.value = res
@@ -249,22 +260,33 @@
   }
   dialogFormVisible.value = true
 }
+// 閫夋嫨鍙戠エ鍙蜂互鍚庣粰鍙戠エ閲戦璧嬪��
+const setInvoiceAmount = (value) => {
+  if (value) {
+    invoiceNumberList.value.forEach(item => {
+      if (item.invoiceNumber === value) {
+        form.value.invoiceAmount = item.invoiceAmount
+      }
+    })
+  } else {
+    form.value.invoiceAmount = ''
+  }
+}
 // 閫夋嫨閲囪喘鍚堝悓鍙疯祴鍊�
 const setInfo = (value) => {
+  getTicketNo().then((res)=>{
+        invoiceNumberList.value = res.data
+      })
   if (value) {
     byPurchaseId(value).then(res => {
       form.value.salesContractNo = res.data.salesContractNo
       form.value.supplierName = res.data.supplierName
-      form.value.invoiceNumber = res.data.invoiceNumber
-      form.value.invoiceAmount = res.data.invoiceAmount
       form.value.taxRate = res.data.taxRate
       form.value.supplierId = res.data.supplierId
     })
   } else {
     form.value.salesContractNo = ''
     form.value.supplierName = ''
-    form.value.invoiceNumber = ''
-    form.value.invoiceAmount = ''
     form.value.taxRate = ''
     form.value.supplierId = ''
   }
diff --git a/src/views/procurementManagement/procurementInvoiceLedger/index.vue b/src/views/procurementManagement/procurementInvoiceLedger/index.vue
index d73b2b3..dca8d7b 100644
--- a/src/views/procurementManagement/procurementInvoiceLedger/index.vue
+++ b/src/views/procurementManagement/procurementInvoiceLedger/index.vue
@@ -4,7 +4,7 @@
       <div>
         <span class="search_title">閲囪喘鍚堝悓鍙凤細</span>
         <el-input
-            v-model="searchForm.purchaseContractNo"
+            v-model="searchForm.purchaseContractNumber"
             style="width: 240px"
             placeholder="璇疯緭鍏�"
             @change="handleQuery"
@@ -33,182 +33,44 @@
         <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> -->
       </div>
     </div>
     <div class="table_list">
       <el-table :data="tableData" border v-loading="tableLoading"
-                @selection-change="handleSelectionChange"
-                :row-key="row => row.id"
-                show-summary
-                :summary-method="summarizeMainTable"
-                height="calc(100vh - 18.5em)">
-        <el-table-column align="center" type="selection" width="55" />
-        <el-table-column align="center" label="搴忓彿" type="index" width="60" />
-        <el-table-column label="閲囪喘鍚堝悓鍙�" prop="purchaseContractNumber" show-overflow-tooltip/>
-        <el-table-column label="閿�鍞悎鍚屽彿" prop="salesContractNo" show-overflow-tooltip/>
-        <el-table-column label="渚涘簲鍟嗗悕绉�" prop="supplierName" show-overflow-tooltip/>
-        <el-table-column label="鍙戠エ鍙�" prop="invoiceNumber" show-overflow-tooltip/>
-        <el-table-column label="鍙戠エ閲戦(鍏�)" prop="invoiceAmount" show-overflow-tooltip/>
-        <el-table-column label="绋庣巼(%)" prop="taxRate" show-overflow-tooltip/>
-        <el-table-column label="寮�绁ㄤ汉" prop="issUer" show-overflow-tooltip/>
-        <el-table-column label="寮�绁ㄦ棩鏈�" prop="issueDate" show-overflow-tooltip/>
-        <!-- <el-table-column label="鍙戠エ" prop="fileName" show-overflow-tooltip>
-          <template #default="scope">
-            <span v-if="scope.row.fileName">{{ scope.row.fileName }}</span>
-            <el-button v-else link type="primary" @click="handleDownload(scope.row)">涓婁紶</el-button>
-          </template>
-        </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>
-          </template>
-        </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('check', scope.row);">鏌ョ湅</el-button>
+        :expand-row-keys="expandedRowKeys" :row-key="row => row.id" show-summary :summary-method="summarizeMainTable"
+        @expand-change="expandChange" height="calc(100vh - 18.5em)">
+        <el-table-column align="center"  label="搴忓彿" type="index" width="55" />
+        <el-table-column type="expand">
+          <template #default="props">
+            <el-table :data="props.row.children" border show-summary :summary-method="summarizeChildrenTable">
+              <el-table-column align="center" label="搴忓彿" type="index" width="60" />
+              <el-table-column label="浜у搧澶х被" prop="productCategory" />
+              <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
+              <el-table-column label="鍗曚綅" prop="unit" />
+              <el-table-column label="鏁伴噺" prop="quantity" />
+              <el-table-column label="绋庣巼(%)" prop="taxRate" />
+              <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" />
+              <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" />
+              <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
+              <el-table-column label="鏈鏉ョエ鏁�" prop="ticketsNum" />
+              <el-table-column label="鏈鏉ョエ閲戦(鍏�)" prop="ticketsAmount" :formatter="formattedNumber" />
+              <el-table-column label="鏈潵绁ㄦ暟" prop="futureTickets" />
+              <el-table-column label="鏈潵绁ㄩ噾棰�(鍏�)" prop="futureTicketsAmount" :formatter="formattedNumber" />
+            </el-table>
           </template>
         </el-table-column>
+        <el-table-column label="閲囪喘鍚堝悓鍙�" prop="purchaseContractNumber" show-overflow-tooltip />
+        <el-table-column label="閿�鍞悎鍚屽彿" prop="salesContractNo" show-overflow-tooltip />
+        <el-table-column label="渚涘簲鍟嗗悕绉�" prop="supplierName" show-overflow-tooltip />
+        <el-table-column label="鍙戠エ鍙�" prop="invoiceNumber" show-overflow-tooltip />
+        <el-table-column label="鍚堝悓閲戦(鍏�)" prop="invoiceAmount" show-overflow-tooltip :formatter="formattedNumber" />
+        <el-table-column label="寮�绁ㄤ汉" prop="issUer" show-overflow-tooltip />
+        <el-table-column label="寮�绁ㄦ棩鏈�" prop="issueDate" show-overflow-tooltip />
       </el-table>
-      <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper" :page="page.current"
-                  :limit="page.size" @pagination="paginationChange" />
+      <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-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="purchaseLedgerId">
-              <el-select v-model="form.purchaseLedgerId" placeholder="璇烽�夋嫨" clearable @change="setInfo">
-                <el-option v-for="item in purchaseLedgerList" :key="item.id" :label="item.purchaseContractNumber" :value="item.id"/>
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="閿�鍞悎鍚屽彿锛�" prop="salesContractNo">
-              <el-input v-model="form.salesContractNo" placeholder="鑷姩濉厖" clearable disabled/>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="30">
-          <el-col :span="12">
-            <el-form-item label="渚涘簲鍟嗗悕绉帮細" prop="supplierName">
-              <el-input v-model="form.supplierName" placeholder="鑷姩濉厖" clearable disabled/>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="鍙戠エ鍙凤細" prop="invoiceNumber">
-              <el-input v-model="form.invoiceNumber" placeholder="璇疯緭鍏�" :disabled="operationType === 'check'" clearable/>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="30">
-          <el-col :span="12">
-            <el-form-item label="鍙戠エ閲戦(鍏�)锛�" prop="invoiceAmount">
-              <el-input type="number" :step="0.01" v-model="form.invoiceAmount" placeholder="璇疯緭鍏�" :disabled="operationType === 'check'" clearable/>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="绋庣巼锛�" prop="taxRate">
-              <el-input type="number" :step="0.01" v-model="form.taxRate" placeholder="璇疯緭鍏�" :disabled="operationType === 'check'" clearable/>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="30">
-          <el-col :span="12">
-            <el-form-item label="寮�绁ㄤ汉锛�" prop="issUer">
-              <el-input v-model="form.issUer" placeholder="璇疯緭鍏�" clearable disabled/>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="寮�绁ㄦ棩鏈燂細" prop="issueDate">
-              <el-date-picker
-                  disabled
-                  style="width: 100%"
-                  v-model="form.issueDate"
-                  value-format="YYYY-MM-DD"
-                  format="YYYY-MM-DD"
-                  type="date"
-                  placeholder="璇烽�夋嫨"
-                  clearable
-              />
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <!-- <el-row :gutter="30">
-          <el-col :span="24">
-            <el-form-item label="闄勪欢鏉愭枡锛�" prop="remark">
-              <el-upload
-                  v-model:file-list="fileList"
-                  :action="upload.url"
-                  multiple
-                  ref="fileUpload"
-                  auto-upload
-                  :headers="upload.headers"
-                  accept=".pdf"
-                  :limit="1"
-                  :data="{ type: 3 }"
-                  :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">
-                    鏂囦欢鏍煎紡浠呮敮鎸� pdf
-                  </div>
-                </template>
-              </el-upload>
-            </el-form-item>
-          </el-col>
-        </el-row> -->
-      </el-form>
-      <template #footer>
-        <div class="dialog-footer">
-          <!-- <el-button type="primary" @click="submitForm">纭</el-button> -->
-          <!-- <el-button @click="closeDia">鍙栨秷</el-button> -->
-        </div>
-      </template>
-    </el-dialog>
-    <el-dialog title="涓婁紶寮圭獥" width="20%" v-model="uploadModal">
-      <el-row :gutter="30">
-        <el-col :span="24">
-          <el-form-item label="闄勪欢鏉愭枡锛�" prop="remark">
-            <el-upload
-                v-model:file-list="fileList"
-                :action="upload.url1"
-                multiple
-                ref="fileUpload"
-                auto-upload
-                accept=".pdf"
-                :limit="1"
-                :data="{ type: 3,id: currentId }"
-                :headers="upload.headers"
-                :before-upload="handleBeforeUpload"
-                :on-error="handleUploadError"
-                :on-success="handleUploadSuccess"
-                :on-remove="handleRemove"
-            >
-              <el-button type="primary">涓婁紶</el-button>
-                <!--                  鏂囦欢鏍煎紡鏀寔 doc锛宒ocx锛寈ls锛寈lsx锛宲pt锛宲ptx锛宲df锛宼xt锛寈ml锛宩pg锛宩peg锛宲ng锛実if锛宐mp锛宺ar锛寊ip锛�7z-->
-              <template #tip>
-                <div class="el-upload__tip">
-                  鏂囦欢鏍煎紡鏀寔 pdf
-                </div>
-              </template>
-            </el-upload>
-          </el-form-item>
-        </el-col>
-      </el-row>
-      <template #footer>
-        <div class="dialog-footer">
-          <el-button @click="commiInvoicetFile" type="primary">纭</el-button>
-          <el-button  @click="commiInvoicetFile">鍙栨秷</el-button>
-        </div>
-      </template>
-    </el-dialog>
   </div>
 </template>
 
@@ -217,77 +79,38 @@
 import { ref } from 'vue'
 import {Search} from "@element-plus/icons-vue";
 import {ElMessageBox } from "element-plus";
+import {productRecordList} from "@/api/procurementManagement/procurementInvoiceLedger.js";
 import {
-  delLedgerFile,
-  ledgerListNoPage
-} from "@/api/salesManagement/salesLedger.js";
-import { getToken } from "@/utils/auth"
-import {getProduct, getInfo} from "@/api/procurementManagement/invoiceEntry.js";
-import useUserStore from "@/store/modules/user.js";
-import {
-  addOrUpdateInvoice, delCommonFile,
-  delInvoice,
-  getInvoiceById,
   invoiceList
 } from "@/api/procurementManagement/procurementInvoiceLedger.js";
 const { proxy } = getCurrentInstance()
 const tableData = ref([])
-const productData = ref([])
-const selectedRows = ref([])
 const tableLoading = ref(false)
 const page = reactive({
   current: 1,
   size: 10,
 })
 const total = ref(0)
-const fileList = ref([])
-const ledgerList = ref([])
-const purchaseLedgerList = ref([])
-const userStore = useUserStore()
-import { genFileId } from 'element-plus'
 // 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
-const operationType = ref('')
-const dialogFormVisible = ref(false)
-const data = reactive({
+  const data = reactive({
   searchForm: {
-    purchaseContractNo: '',
+    purchaseContractNumber: '',
     supplierName: '',
     issueDate:''
   },
   form: {
+    issueDate:"",// 寮�绁ㄦ棩鏈�
     purchaseLedgerId: '',
-    salesLedgerId: '',
-    customerId: '',
-    invoiceNumber: '',
-    invoiceAmount: '',
-    taxRate: '',
-    issUerId: '',
-    issUer: '',
-    issueDate: '',
-    customerName:'',
-    fileList:[]
+    purchaseLedgerNo: '',
+    issUerId: '', // 寮�绁ㄤ汉id
+    issUer: '' ,// 寮�绁ㄤ汉濮撳悕
   },
-  // rules: {
-  //   purchaseLedgerId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
-  //   customerId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-  //   invoiceNumber: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
-  //   invoiceAmount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-  //   taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
-  //   issUer: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-  //   issueDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
-  //   customerName: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
-  // }
+  rules: {
+    purchaseLedgerId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+  }
 })
-const { searchForm, form, rules } = toRefs(data)
-const currentId = ref('')
-const upload = reactive({
-  // 涓婁紶鐨勫湴鍧�
-  url: import.meta.env.VITE_APP_BASE_API + "/file/upload",
-  url1: import.meta.env.VITE_APP_BASE_API + "/purchase/invoice/upload",
-  // 璁剧疆涓婁紶鐨勮姹傚ご閮�
-  headers: { Authorization: "Bearer " + getToken() },
-})
-const uploadModal = ref(false)
+const { searchForm } = toRefs(data)
+
 // 鏌ヨ鍒楄〃
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 const handleQuery = () => {
@@ -301,199 +124,73 @@
 }
 const getList = () => {
   tableLoading.value = true
-  invoiceList({...searchForm.value, ...page}).then(res => {
+  invoiceList({ ...searchForm.value, ...page }).then(res => {
     tableLoading.value = false
-    tableData.value = res.rows;
-    total.value = res.total;
+    tableData.value = res.rows
+    tableData.value.map(item => {
+      item.children = []
+    })
+    total.value = res.total
+    expandedRowKeys.value = []
+  }).catch(() => {
+    tableLoading.value = false
   })
 }
+const formattedNumber = (row, column, cellValue) => {
+  return parseFloat(cellValue).toFixed(2);
+};
 // 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
-  selectedRows.value = selection
+const expandedRowKeys = ref([])
+// 灞曞紑琛�
+const expandChange = (row, expandedRows) => {
+  if (expandedRows.length > 0) {
+    expandedRowKeys.value = []
+    try {
+      productRecordList({ id: row.id }).then(res => {
+        const index = tableData.value.findIndex(item => item.id === row.id);
+        if (index > -1) {
+          tableData.value[index].children = res;
+        }
+        expandedRowKeys.value.push(row.id)
+      })
+    } catch (error) {
+      console.log(error)
+    }
+  } else {
+    expandedRowKeys.value = []
+  }
 }
 // 涓昏〃鍚堣鏂规硶
 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, ['invoiceAmount'], {
+    ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+    futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+  });
 };
-// 鎵撴潵寮规
-const openForm = (type, row) => {
-  operationType.value = type
-  form.value = {}
-  productData.value = []
-  fileList.value = []
-  form.value.issUerId = userStore.id
-  form.value.issUer = userStore.name
-  form.value.issueDate = getCurrentDate();
-  // 鏌ヨ閿�鍞悎鍚�
-  ledgerListNoPage({}).then(res => {
-    ledgerList.value = res.data;
-  })
-  // 鏌ヨ閲囪喘鍚堝悓鍙�
-  getProduct().then(res => {
-    purchaseLedgerList.value = res
-  })
-  if (type === 'edit') {
-    currentId.value = row.id;
-    getInvoiceById({id: row.id}).then(res => {
-      form.value = {...res}
-      fileList.value = res.commonFiles;
-    })
-  }
-  dialogFormVisible.value = true
-}
-// 涓婁紶鍓嶆牎妫�
-function handleBeforeUpload(file) {
-  // 鏍℃鏂囦欢澶у皬
-  if (file.size > 1024 * 1024 * 10) {
-    proxy.$modal.msgError('涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃10MB!')
-    return false
-  }
-  proxy.$modal.loading("姝e湪涓婁紶鏂囦欢锛岃绋嶅��...")
-  return true
-}
-// 涓婁紶澶辫触
-function handleUploadError(err) {
-  proxy.$modal.msgError("涓婁紶鏂囦欢澶辫触")
-  proxy.$modal.closeLoading()
-}
-// 涓婁紶鎴愬姛鍥炶皟
-function handleUploadSuccess(res, file, uploadFiles) {
-  proxy.$modal.closeLoading()
-  if (res.code === 200) {
-    file.tempId = res.data.tempId
-    proxy.$modal.msgSuccess("涓婁紶鎴愬姛")
-  } else {
-    proxy.$modal.msgError(res.msg)
-    proxy.$refs.fileUpload.handleRemove(file)
-  }
-}
-// 绉婚櫎鏂囦欢
-function handleRemove (file) {
-  if (operationType.value === 'edit') {
-    let ids = []
-    ids.push(file.id)
-    delCommonFile(ids).then(res => {
-      proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
-    })
-  }
-}
-// 鎻愪氦琛ㄥ崟
-const submitForm = () => {
-  proxy.$refs["formRef"].validate(valid => {
-    if (valid) {
-      let tempFileIds = []
-      if (fileList.value.length > 0) {
-        tempFileIds = fileList.value.map(item => item.tempId)
-      }
-      form.value.tempFileIds = tempFileIds
-      form.value.type = 3;
-      addOrUpdateInvoice(form.value).then(res => {
-        proxy.$modal.msgSuccess("鎻愪氦鎴愬姛")
-        closeDia()
-        getList()
-      })
-    }
-  })
-}
-// 鍏抽棴寮规
-const closeDia = () => {
-  proxy.resetForm("formRef")
-  dialogFormVisible.value = false
-}
+// 瀛愯〃鍚堣鏂规硶
+const summarizeChildrenTable = (param) => {
+  return proxy.summarizeTable(param, ['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice', 'ticketsNum', 'ticketsAmount', 'futureTickets', 'futureTicketsAmount'], {
+    ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+    futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+  });
+};
+
 // 瀵煎嚭
 const handleOut = () => {
   ElMessageBox.confirm(
-      '閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�',
-      '瀵煎嚭', {
-        confirmButtonText: '纭',
-        cancelButtonText: '鍙栨秷',
-        type: 'warning',
-      }
-  ).then(() => {
-    proxy.download("/purchase/invoice/export", {}, '鏉ョエ鍙拌处.xlsx')
-  }).catch(() => {
-    proxy.$modal.msg("宸插彇娑�")
-  })
-}
-// 鍒犻櫎
-const handleDelete = () => {
-  let ids = []
-  if (selectedRows.value.length > 0) {
-    ids = selectedRows.value.map(item => item.id);
-  } else {
-    proxy.$modal.msgWarning('璇烽�夋嫨鏁版嵁')
-    return
+    '閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�',
+    '瀵煎嚭', {
+    confirmButtonText: '纭',
+    cancelButtonText: '鍙栨秷',
+    type: 'warning',
   }
-  ElMessageBox.confirm(
-      '閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�',
-      '瀵煎嚭', {
-        confirmButtonText: '纭',
-        cancelButtonText: '鍙栨秷',
-        type: 'warning',
-      }
   ).then(() => {
-    delInvoice(ids).then(res => {
-      proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
-      getList()
-    })
+    proxy.download("/purchase/registration/export", {}, '鏉ョエ鐧昏.xlsx')
   }).catch(() => {
     proxy.$modal.msg("宸插彇娑�")
   })
-}
-
-// 閫夋嫨閲囪喘鍚堝悓鍙疯祴鍊�
-const setInfo = (value) => {
-  getInfo({id: value}).then(res => {
-    form.value.salesContractNo = res.salesContractNo
-    form.value.projectName = res.projectName
-    productData.value = res.productData
-    form.value.supplierName = res.supplierName
-    form.value.businessPersonId = res.businessPersonId
-  })
-}
-
-// 鎵撴潵闄勪欢涓婁紶寮圭獥
-const handleDownload = (val) => {
-  fileList.value = []
-  uploadModal.value = true
-  currentId.value = val.id
-}
-
-// 纭鏂囦欢涓婁紶
-const commiInvoicetFile = () => {
-  uploadModal.value = false
-  getList();
-}
-// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� 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>
 
-<style scoped lang="scss">
-
-</style>
+<style scoped lang="scss"></style>
\ No newline at end of file

--
Gitblit v1.9.3