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 |  227 ++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 155 insertions(+), 72 deletions(-)

diff --git a/src/views/procurementManagement/paymentEntry/index.vue b/src/views/procurementManagement/paymentEntry/index.vue
index 56b143c..107ee30 100644
--- a/src/views/procurementManagement/paymentEntry/index.vue
+++ b/src/views/procurementManagement/paymentEntry/index.vue
@@ -37,28 +37,6 @@
           </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
@@ -66,14 +44,90 @@
         :column="tableColumn"
         :tableData="tableData"
         :page="page"
+        :expandRowKeys="expandedRowKeys"
         :isSelection="true"
         :isShowSummary="isShowSummarySon"
         :summaryMethod="summarizeMainTable1"
         @selection-change="handleSelectionChange"
+        @expand-change="expandChange"
         :tableLoading="tableLoading"
         @pagination="pagination"
         :total="page.total"
-      ></PIMTable>
+      >
+				<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"
@@ -146,6 +200,7 @@
           <el-col :span="12">
             <el-form-item label="鏈浠樻閲戦锛�" prop="currentPaymentAmount">
               <el-input-number :step="0.01" :min="0" style="width: 100%"
+															 :precision="2"
                 v-model="form.currentPaymentAmount"
                 placeholder="璇疯緭鍏�"
                 clearable
@@ -225,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",
@@ -275,9 +340,10 @@
   },
 ]);
 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,
@@ -324,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) => {
@@ -335,6 +403,13 @@
       futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
     }
   );
+};
+// 瀛愯〃鍚堣鏂规硶
+const summarizeMainTable2 = (param) => {
+	return proxy.summarizeTable(param, ["currentPaymentAmount"], {
+		ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+		futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+	});
 };
 // 鏌ヨ鍒楄〃
 /** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -353,7 +428,56 @@
     tableLoading.value = false;
     tableData.value = res.records;
 		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) => {
@@ -365,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] };
@@ -375,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 = () => {
@@ -442,20 +538,7 @@
   dialogFormVisible.value = false;
 };
 // 鍒犻櫎
-const handleDelete = () => {
-  let ids = [];
-  if (selectedRows.value.length > 0) {
-		// 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
-		const unauthorizedData = selectedRows.value.filter(item => item.issUer !== userStore.nickName);
-		if (unauthorizedData.length > 0) {
-			proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
-			return;
-		}
-    ids = selectedRows.value.map((item) => item.id);
-  } else {
-    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
-    return;
-  }
+const handleDelete = (row) => {
   ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
     confirmButtonText: "纭",
     cancelButtonText: "鍙栨秷",
@@ -463,7 +546,7 @@
   })
     .then(() => {
       tableLoading.value = true;
-      paymentRegistrationDel(ids)
+			delPaymentRegistration(row.id)
         .then((res) => {
           proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
           getList();

--
Gitblit v1.9.3