From 28a67a22bffae3ce3b2e52fa15a397cbe4922f0e Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 14 七月 2025 11:47:32 +0800
Subject: [PATCH] 1.付款登记-添加明细展示,并且可以编辑和删除,付款流水数据展示要同步

---
 src/views/procurementManagement/paymentEntry/index.vue |  254 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 173 insertions(+), 81 deletions(-)

diff --git a/src/views/procurementManagement/paymentEntry/index.vue b/src/views/procurementManagement/paymentEntry/index.vue
index 59faa6d..107ee30 100644
--- a/src/views/procurementManagement/paymentEntry/index.vue
+++ b/src/views/procurementManagement/paymentEntry/index.vue
@@ -30,49 +30,104 @@
               <el-button type="primary" @click="openForm('add')">
                 鏂板浠樻
               </el-button>
-              <el-button type="danger" plain @click="handleDelete">
-                鍒犻櫎
-              </el-button>
+<!--              <el-button type="danger" plain @click="handleDelete">-->
+<!--                鍒犻櫎-->
+<!--              </el-button>-->
             </el-form-item>
           </el-col>
         </el-row>
       </el-form>
-      <!-- <div>
-        <span class="search_title">渚涘簲鍟嗗悕绉�/鍚堝悓鍙凤細</span>
-        <el-input
-          v-model="searchForm.supplierNameOrContractNo"
-          style="width: 240px"
-          placeholder="杈撳叆渚涘簲鍟嗗悕绉�/鍚堝悓鍙锋悳绱�"
-          @change="handleQuery"
-          clearable
-          :prefix-icon="Search"
-        />
-        <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 type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
-      </div> -->
     </div>
     <div class="table_list">
       <PIMTable
+        rowKey="id"
         :column="tableColumn"
         :tableData="tableData"
         :page="page"
+        :expandRowKeys="expandedRowKeys"
         :isSelection="true"
         :isShowSummary="isShowSummarySon"
         :summaryMethod="summarizeMainTable1"
-        :handleSelectionChange="handleSelectionChange"
+        @selection-change="handleSelectionChange"
+        @expand-change="expandChange"
         :tableLoading="tableLoading"
         @pagination="pagination"
-        :total="total"
-      ></PIMTable>
+        :total="page.total"
+      >
+				<template #expand="{ row }">
+					<el-table
+						:data="expandData"
+						border
+						show-summary
+						v-loading="childrenLoading"
+						:summary-method="summarizeMainTable2"
+					>
+						<el-table-column
+							align="center"
+							label="搴忓彿"
+							type="index"
+							width="60"
+						/>
+						<el-table-column label="浠樻鏃ユ湡" prop="paymentDate" />
+						<el-table-column label="浠樻閲戦" prop="currentPaymentAmount">
+							<template #default="scope">
+								<el-input-number :step="0.01" :min="0" style="width: 100%"
+																 v-model="scope.row.currentPaymentAmount"
+																 :disabled="!scope.row.editType"
+																 :precision="2"
+																 placeholder="璇疯緭鍏�"
+																 clearable
+								/>
+							</template>
+						</el-table-column>
+						<el-table-column label="浠樻鏂瑰紡" prop="paymentMethod">
+							<template #default="scope">
+								<el-select
+									:disabled="!scope.row.editType"
+									v-model="scope.row.paymentMethod"
+									placeholder="璇烽�夋嫨"
+									clearable
+								>
+									<el-option label="鐢垫眹" value="鐢垫眹" />
+									<el-option label="鎵垮厬" value="鎵垮厬" />
+								</el-select>
+							</template>
+						</el-table-column>
+						<el-table-column label="鐧昏浜�" prop="registrant" />
+						<el-table-column label="鐧昏鏃ユ湡" prop="registrationtDate" />
+						<el-table-column label="鎿嶄綔" width="150">
+							<template #default="scope">
+								<el-button
+									link
+									type="primary"
+									size="small"
+									@click="changeEditType(scope.row)"
+									v-if="!scope.row.editType"
+									:disabled="scope.row.registrant !== userStore.nickName"
+								>缂栬緫</el-button
+								>
+								<el-button
+									link
+									type="primary"
+									size="small"
+									@click="saveReceiptPayment(scope.row)"
+									v-if="scope.row.editType"
+									:disabled="scope.row.registrant !== userStore.nickName"
+								>淇濆瓨</el-button
+								>
+								<el-button
+									link
+									type="primary"
+									size="small"
+									@click="handleDelete(scope.row)"
+									:disabled="scope.row.registrant !== userStore.nickName"
+								>鍒犻櫎</el-button
+								>
+							</template>
+						</el-table-column>
+					</el-table>
+				</template>
+			</PIMTable>
     </div>
     <el-dialog
       v-model="dialogFormVisible"
@@ -135,8 +190,6 @@
           <el-col :span="12">
             <el-form-item label="鍙戠エ閲戦(鍏�)锛�" prop="invoiceAmount">
               <el-input
-                type="number"
-                :step="0.01"
                 v-model="form.invoiceAmount"
                 placeholder="鑷姩濉厖"
                 clearable
@@ -146,9 +199,8 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="鏈浠樻閲戦锛�" prop="currentPaymentAmount">
-              <el-input
-                type="number"
-                :step="0.01"
+              <el-input-number :step="0.01" :min="0" style="width: 100%"
+															 :precision="2"
                 v-model="form.currentPaymentAmount"
                 placeholder="璇疯緭鍏�"
                 clearable
@@ -228,11 +280,21 @@
   paymentRegistrationEdit,
   getTicketNo,
 } from "@/api/procurementManagement/paymentEntry.js";
-import { invoiceListPage } from "@/api/procurementManagement/procurementInvoiceLedger.js";
+import {
+	delPaymentRegistration,
+	invoiceListPage,
+	registrationListPageGetById,
+	updatePaymentRegistration
+} from "@/api/procurementManagement/procurementInvoiceLedger.js";
 import useFormData from "@/hooks/useFormData";
 
 const { proxy } = getCurrentInstance();
 const tableColumn = ref([
+	{
+		type: "expand",
+		dataType: "slot",
+		slot: "expand",
+	},
   {
     label: "閲囪喘鍚堝悓鍙�",
     prop: "purchaseContractNumber",
@@ -244,43 +306,50 @@
   {
     label: "渚涘簲鍟嗗悕绉�",
     prop: "supplierName",
+    width:240
   },
   {
     label: "鍙戠エ鍙�",
     prop: "invoiceNumber",
+    width:200
   },
   {
     label: "鍙戠エ閲戦(鍏�)",
     prop: "invoiceAmount",
     formatData: (params) => {
-      return parseFloat(params).toFixed(2);
+      return params ? parseFloat(params).toFixed(2) : 0;
     },
   },
   {
     label: "宸蹭粯娆鹃噾棰�(鍏�)",
     prop: "paymentAmountTotal",
     formatData: (params) => {
-      return parseFloat(params).toFixed(2);
+      return params ? parseFloat(params).toFixed(2) : 0;
     },
   },
   {
     label: "寰呬粯娆鹃噾棰�(鍏�)",
     prop: "unPaymentAmountTotal",
     formatData: (params) => {
-      return parseFloat(params).toFixed(2);
+      return params ? parseFloat(params).toFixed(2) : 0;
     },
+  },
+  {
+    label: "褰曞叆浜�",
+    prop: "issUer",
   },
 ]);
 const tableData = ref([]);
+const expandData = ref([]);
 const selectedRows = ref([]);
 const tableLoading = ref(false);
-const invoiceNumberList = ref([]);
+const childrenLoading = ref(false);
 const userStore = useUserStore();
 const page = reactive({
   current: 1,
   size: 100,
+	total: 0,
 });
-const total = ref(0);
 
 // 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
 const operationType = ref("");
@@ -321,6 +390,8 @@
 const { form, rules } = toRefs(data);
 const { form: searchForm, resetForm } = useFormData(data.searchForm);
 const isShowSummarySon = ref(true);
+const expandedRowKeys = ref([]);
+
 
 // 瀛愯〃鍚堣鏂规硶
 const summarizeMainTable1 = (param) => {
@@ -332,6 +403,13 @@
       futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
     }
   );
+};
+// 瀛愯〃鍚堣鏂规硶
+const summarizeMainTable2 = (param) => {
+	return proxy.summarizeTable(param, ["currentPaymentAmount"], {
+		ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+		futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+	});
 };
 // 鏌ヨ鍒楄〃
 /** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -349,8 +427,57 @@
   invoiceListPage({ ...searchForm, ...page }).then((res) => {
     tableLoading.value = false;
     tableData.value = res.records;
-    total.value = res.total;
+		page.total = res.total;
+		if (expandedRowKeys.value.length > 0) {
+			const arr = []
+			const index = tableData.value.findIndex(item => item.id === expandedRowKeys.value[0]);
+			if (index > -1) {
+				arr.push(tableData.value[index]);
+				expandChange(tableData.value[index], arr)
+			}
+		}
   });
+};
+// 灞曞紑琛�
+const expandChange = (row, expandedRows) => {
+	if (expandedRows.length > 0) {
+		nextTick(() => {
+			expandedRowKeys.value = [];
+			try {
+				childrenLoading.value = true;
+				registrationListPageGetById({ id: row.id }).then((res) => {
+					childrenLoading.value = false;
+					const index = tableData.value.findIndex((item) => item.id === row.id);
+					if (index > -1) {
+						expandData.value = res;
+					}
+					expandedRowKeys.value.push(row.id);
+				});
+			} catch (error) {
+				childrenLoading.value = false;
+				console.log(error);
+			}
+		})
+	} else {
+		expandedRowKeys.value = [];
+	}
+};
+// 缂栬緫淇敼鐘舵��
+const changeEditType = (row) => {
+	row.editType = !row.editType;
+};
+// 淇濆瓨鍥炴璁板綍
+const saveReceiptPayment = (row) => {
+	let updateData = {
+		id: row.id,
+		currentPaymentAmount: row.currentPaymentAmount,
+		paymentMethod: row.paymentMethod,
+	};
+	updatePaymentRegistration(updateData).then((res) => {
+		row.editType = !row.editType;
+		getList();
+		proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+	});
 };
 // 琛ㄦ牸閫夋嫨鏁版嵁
 const handleSelectionChange = (selection) => {
@@ -362,6 +489,10 @@
     proxy.$message.error("璇烽�夋嫨涓�鏉″彂绁ㄦ暟鎹�");
     return;
   }
+	if (selectedRows.value[0].unPaymentAmountTotal == 0) {
+		proxy.$message.warning("鏃犻渶鍐嶄粯娆�");
+		return;
+	}
   operationType.value = type;
   form.value = {};
   form.value = { ...selectedRows.value[0] };
@@ -372,38 +503,6 @@
   form.value.paymentDate = getCurrentDate();
   form.value.registrant = userStore.name;
   dialogFormVisible.value = true;
-};
-// 閫夋嫨鍙戠エ鍙蜂互鍚庣粰鍙戠エ閲戦璧嬪��
-const setInvoiceAmount = (value) => {
-  if (value) {
-    invoiceNumberList.value.forEach((item) => {
-      if (item.invoiceNumber === value) {
-        form.value.invoiceAmount = item.invoiceAmount;
-        form.value.ticketRegistrationId = item.id;
-      }
-    });
-  } else {
-    form.value.invoiceAmount = "";
-  }
-};
-// 閫夋嫨閲囪喘鍚堝悓鍙疯祴鍊�
-const setInfo = (value) => {
-  getTicketNo({ id: value }).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.taxRate = res.data.taxRate;
-      form.value.supplierId = res.data.supplierId;
-    });
-  } else {
-    form.value.salesContractNo = "";
-    form.value.supplierName = "";
-    form.value.taxRate = "";
-    form.value.supplierId = "";
-  }
 };
 // 鎻愪氦琛ㄥ崟
 const submitForm = () => {
@@ -439,14 +538,7 @@
   dialogFormVisible.value = false;
 };
 // 鍒犻櫎
-const handleDelete = () => {
-  let ids = [];
-  if (selectedRows.value.length > 0) {
-    ids = selectedRows.value.map((item) => item.id);
-  } else {
-    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
-    return;
-  }
+const handleDelete = (row) => {
   ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
     confirmButtonText: "纭",
     cancelButtonText: "鍙栨秷",
@@ -454,7 +546,7 @@
   })
     .then(() => {
       tableLoading.value = true;
-      paymentRegistrationDel(ids)
+			delPaymentRegistration(row.id)
         .then((res) => {
           proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
           getList();

--
Gitblit v1.9.3