<template> 
 | 
  <div class="app-container"> 
 | 
    <div class="search_form"> 
 | 
      <div> 
 | 
        <span class="search_title">供应商名称:</span> 
 | 
        <el-input 
 | 
          v-model="searchForm.supplierName" 
 | 
          style="width: 240px" 
 | 
          placeholder="输入供应商名称" 
 | 
          @change="handleQuery" 
 | 
          clearable 
 | 
          :prefix-icon="Search" 
 | 
        /> 
 | 
        <el-button type="primary" @click="handleQuery" style="margin-left: 10px" 
 | 
          >搜索</el-button 
 | 
        > 
 | 
      </div> 
 | 
      <div></div> 
 | 
    </div> 
 | 
    <el-row :gutter="20"> 
 | 
      <el-col :span="14"> 
 | 
        <div class="table_list"> 
 | 
          <el-table 
 | 
            ref="multipleTable" 
 | 
            border 
 | 
            v-loading="tableLoading" 
 | 
            :data="tableData" 
 | 
            :header-cell-style="{ background: '#F0F1F5', color: '#333333' }" 
 | 
            height="calc(100vh - 18.5em)" 
 | 
            :highlight-current-row="true" 
 | 
            style="width: 100%" 
 | 
            stripe 
 | 
            tooltip-effect="dark" 
 | 
            @row-click="rowClick" 
 | 
            :show-summary="isShowSummary" 
 | 
            :summary-method="summarizeMainTable" 
 | 
            class="lims-table" 
 | 
          > 
 | 
            <el-table-column 
 | 
              align="center" 
 | 
              label="序号" 
 | 
              type="index" 
 | 
              width="60" 
 | 
            /> 
 | 
            <el-table-column label="供应商名称" prop="supplierName" /> 
 | 
            <el-table-column 
 | 
              label="发票金额(元)" 
 | 
              prop="invoiceAmount" 
 | 
              show-overflow-tooltip 
 | 
              :formatter="formattedNumber" 
 | 
            /> 
 | 
            <el-table-column 
 | 
              label="付款金额(元)" 
 | 
              prop="paymentAmount" 
 | 
              show-overflow-tooltip 
 | 
              :formatter="formattedNumber" 
 | 
            /> 
 | 
            <el-table-column 
 | 
              label="应付金额(元)" 
 | 
              prop="payableAmount" 
 | 
              show-overflow-tooltip 
 | 
            > 
 | 
              <template #default="{ row, column }"> 
 | 
                <el-text type="danger"> 
 | 
                  {{ formattedNumber(row, column, row.payableAmount) }} 
 | 
                </el-text> 
 | 
              </template> 
 | 
            </el-table-column> 
 | 
          </el-table> 
 | 
          <pagination 
 | 
            v-show="total > 0" 
 | 
            @pagination="paginationSearch" 
 | 
            :total="total" 
 | 
            :layout="page.layout" 
 | 
            :page="page.current" 
 | 
            :limit="page.size" 
 | 
          /> 
 | 
        </div> 
 | 
      </el-col> 
 | 
      <el-col :span="10"> 
 | 
        <div class="table_list"> 
 | 
          <PIMTable 
 | 
            rowKey="id" 
 | 
            :column="tableColumnSon" 
 | 
            :tableData="originalTableDataSon" 
 | 
            :isSelection="false" 
 | 
            :tableLoading="tableLoadingSon" 
 | 
            :isShowSummary="isShowSummarySon" 
 | 
            :summaryMethod="summarizeMainTable1" 
 | 
                        height="calc(100vh - 18.5em)" 
 | 
          > 
 | 
            <template #payableAmountSlot="{ row }"> 
 | 
              <el-text type="danger"> 
 | 
                {{ parseFloat(row.payableAmount).toFixed(2) }} 
 | 
              </el-text> 
 | 
            </template> 
 | 
          </PIMTable> 
 | 
          <pagination 
 | 
            v-show="sonTotal > 0" 
 | 
            :total="sonTotal" 
 | 
            @pagination="sonPaginationSearch" 
 | 
            :layout="page.layout" 
 | 
            :page="sonPage.current" 
 | 
            :limit="sonPage.size" 
 | 
          /> 
 | 
        </div> 
 | 
      </el-col> 
 | 
    </el-row> 
 | 
  </div> 
 | 
</template> 
 | 
  
 | 
<script setup> 
 | 
import { ref, toRefs } from "vue"; 
 | 
import { Search } from "@element-plus/icons-vue"; 
 | 
import { 
 | 
  paymentLedgerList, 
 | 
  paymentRecordList, 
 | 
} from "@/api/procurementManagement/paymentLedger.js"; 
 | 
import Pagination from "../../../components/PIMTable/Pagination.vue"; 
 | 
  
 | 
const tableColumn = ref([ 
 | 
  { 
 | 
    label: "供应商名称", 
 | 
    prop: "supplierName", 
 | 
    width:240 
 | 
  }, 
 | 
  { 
 | 
    label: "发票金额(元)", 
 | 
    prop: "invoiceAmount", 
 | 
  }, 
 | 
  { 
 | 
    label: "付款金额(元)", 
 | 
    prop: "paymentAmount", 
 | 
  }, 
 | 
  { 
 | 
    label: "应付金额(元)", 
 | 
    prop: "payableAmount", 
 | 
  }, 
 | 
]); 
 | 
const tableData = ref([]); 
 | 
const tableLoading = ref(false); 
 | 
const data = reactive({ 
 | 
  searchForm: { 
 | 
    supplierNameOrContractNo: "", 
 | 
  }, 
 | 
}); 
 | 
const page = reactive({ 
 | 
  current: 1, 
 | 
  size: 100, 
 | 
}); 
 | 
const sonPage = reactive({ 
 | 
  current: 1, 
 | 
  size: 100, 
 | 
}); 
 | 
const total = ref(0); 
 | 
const sonTotal = ref(0); 
 | 
const isShowSummary = ref(true); 
 | 
const { searchForm } = toRefs(data); 
 | 
const currentSupplierId = ref(""); 
 | 
const rowClick = (row) => { 
 | 
  currentSupplierId.value = row.supplierId; 
 | 
  getPaymenRecordtList(row.supplierId); 
 | 
}; 
 | 
// 子模块 
 | 
const tableColumnSon = ref([ 
 | 
  { 
 | 
    label: "发生日期", 
 | 
    prop: "happenTime", 
 | 
        width: 110, 
 | 
  }, 
 | 
  { 
 | 
    label: "发票金额(元)", 
 | 
    prop: "invoiceAmount", 
 | 
        width: 200, 
 | 
    formatData: (params) => { 
 | 
      return params ? parseFloat(params).toFixed(2) : 0; 
 | 
    }, 
 | 
  }, 
 | 
  { 
 | 
    label: "付款金额(元)", 
 | 
    prop: "currentPaymentAmount", 
 | 
        width: 200, 
 | 
    formatData: (params) => { 
 | 
      return params ? parseFloat(params).toFixed(2) : 0; 
 | 
    }, 
 | 
  }, 
 | 
  { 
 | 
    label: "应付金额(元)", 
 | 
    dataType: "slot", 
 | 
        width: 200, 
 | 
    prop: "payableAmount", 
 | 
    slot: "payableAmountSlot", 
 | 
  }, 
 | 
]); 
 | 
const tableDataSon = ref([]); 
 | 
const originalTableDataSon = ref([]); 
 | 
const tableLoadingSon = ref(false); 
 | 
const isShowSummarySon = ref(true); 
 | 
const detailPageNum = ref(1); 
 | 
const detailPageSize = ref(10); 
 | 
const { proxy } = getCurrentInstance(); 
 | 
  
 | 
// 主表合计方法 
 | 
const summarizeMainTable = (param) => { 
 | 
  return proxy.summarizeTable( 
 | 
    param, 
 | 
    ["invoiceAmount", "paymentAmount", "payableAmount"], 
 | 
    { 
 | 
      ticketsNum: { noDecimal: true }, // 不保留小数 
 | 
      futureTickets: { noDecimal: true }, // 不保留小数 
 | 
    } 
 | 
  ); 
 | 
}; 
 | 
// 子表合计方法 
 | 
const summarizeMainTable1 = (param) => { 
 | 
  let summarizeTable = proxy.summarizeTable( 
 | 
    param, 
 | 
    ["invoiceAmount", "currentPaymentAmount"], 
 | 
    { 
 | 
      ticketsNum: { noDecimal: true }, // 不保留小数 
 | 
      futureTickets: { noDecimal: true }, // 不保留小数 
 | 
    } 
 | 
  ); 
 | 
  if (originalTableDataSon.value.length > 0) { 
 | 
    summarizeTable[summarizeTable.length - 1] = 
 | 
      originalTableDataSon.value[ 
 | 
        originalTableDataSon.value.length - 1 
 | 
      ].payableAmount.toFixed(2); 
 | 
  } else { 
 | 
    summarizeTable[summarizeTable.length - 1] = 0.0; 
 | 
  } 
 | 
  return summarizeTable; 
 | 
}; 
 | 
/** 搜索按钮操作 */ 
 | 
const handleQuery = () => { 
 | 
  page.current = 1; 
 | 
  getList(); 
 | 
}; 
 | 
const paginationSearch = (obj) => { 
 | 
  page.current = obj.page; 
 | 
  page.size = obj.limit; 
 | 
  getList(); 
 | 
}; 
 | 
const getList = () => { 
 | 
  tableLoading.value = true; 
 | 
  paymentLedgerList({ 
 | 
    ...searchForm.value, 
 | 
    ...page, 
 | 
    detailPageNum: detailPageNum.value, // 新增 
 | 
    detailPageSize: detailPageSize.value, // 新增 
 | 
  }).then((res) => { 
 | 
    let result = res.data; 
 | 
    tableLoading.value = false; 
 | 
    tableData.value = result.records || []; 
 | 
    total.value = result.total || 0; 
 | 
    if (tableData.value.length > 0) { 
 | 
      getPaymenRecordtList(tableData.value[0].supplierId); 
 | 
      currentSupplierId.value = tableData.value[0].supplierId; 
 | 
    } 
 | 
  }); 
 | 
}; 
 | 
  
 | 
const getPaymenRecordtList = (supplierId) => { 
 | 
  tableLoadingSon.value = true; 
 | 
  paymentRecordList(supplierId) 
 | 
    .then((res) => { 
 | 
      tableLoadingSon.value = false; 
 | 
      tableDataSon.value = res.data; 
 | 
      handlePagination({ page: 1, limit: sonPage.size }); 
 | 
      sonTotal.value = res.data.length; 
 | 
    }) 
 | 
    .catch((e) => { 
 | 
      tableLoadingSon.value = false; 
 | 
    }); 
 | 
}; 
 | 
const handlePagination = ({ page, limit }) => { 
 | 
  sonPage.current = page; 
 | 
  sonPage.size = limit; 
 | 
  
 | 
  const start = (page - 1) * limit; 
 | 
  const end = start + limit; 
 | 
  
 | 
  originalTableDataSon.value = tableDataSon.value.slice(start, end); 
 | 
}; 
 | 
  
 | 
const sonPaginationSearch = (pagination) => { 
 | 
  // 接收分页器参数 { page, limit } 
 | 
  handlePagination(pagination); 
 | 
}; 
 | 
const formattedNumber = (row, column, cellValue) => { 
 | 
  if (column.property !== "supplierName") { 
 | 
    return parseFloat(cellValue).toFixed(2); 
 | 
  } else { 
 | 
    return cellValue; 
 | 
  } 
 | 
}; 
 | 
getList(); 
 | 
</script> 
 | 
  
 | 
<style scoped lang="scss"> 
 | 
.el-pagination { 
 | 
  width: 100%; 
 | 
  height: 55px; 
 | 
  display: flex; 
 | 
  justify-content: flex-end; 
 | 
  float: right; 
 | 
  flex-direction: row; 
 | 
  align-items: center; 
 | 
  background: #fff; 
 | 
  margin: -20px 0 0 0; 
 | 
  padding: 0 20px; 
 | 
} 
 | 
.pagination-container { 
 | 
  margin-top: 0; 
 | 
} 
 | 
</style> 
 |