huminmin
2026-06-01 a563ea879ef5fb6897e76d2df661e465dce2ab9b
src/views/salesManagement/receiptPaymentLedger/index.vue
@@ -1,166 +1,300 @@
<template>
  <div class="app-container">
    <div class="search_form">
    <div class="search_form"
         style="margin-bottom: 20px;">
      <div>
        <span class="search_title">回款台账</span>
        <el-input
            v-model="searchForm.searchText"
            style="width: 240px"
            placeholder="输入客户名称搜索"
            @change="handleQuery"
            clearable
            :prefix-icon="Search"
        />
        <el-button type="primary" @click="handleQuery" style="margin-left: 10px">搜索</el-button>
        <span class="search_title">客户名称:</span>
        <el-input v-model="searchForm.searchText"
                  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 style="display: flex">
      <div class="table_list">
        <el-table :data="tableData" border v-loading="tableLoading"
                  :row-key="row => row.id"
                  show-summary
                  :summary-method="summarizeMainTable"
                  @row-click = "rowClickMethod"
                  height="calc(100vh - 18.5em)">
          <el-table-column align="center" label="序号" type="index" width="60" />
          <el-table-column label="客户名称" prop="customerName" show-overflow-tooltip/>
          <el-table-column label="开票金额(元)" prop="invoiceTotal" show-overflow-tooltip :formatter="formattedNumber"/>
          <el-table-column label="回款金额(元)" prop="receiptPaymentAmount" show-overflow-tooltip :formatter="formattedNumber"/>
          <el-table-column label="未回款金额(元)" prop="unReceiptPaymentAmount" show-overflow-tooltip :formatter="formattedNumber"/>
        </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>
      <div class="table_list">
        <el-table :data="receiptRecord" border
                  :row-key="row => row.id"
                  show-summary
                  :summary-method="summarizeMainTable1"
                  height="calc(100vh - 18.5em)">
          <el-table-column align="center" label="序号" type="index" width="60" />
          <el-table-column label="发生日期" prop="receiptPaymentDate" show-overflow-tooltip/>
          <el-table-column label="回款金额(元)" prop="receiptPaymentAmount" show-overflow-tooltip :formatter="formattedNumber"/>
          <el-table-column label="待收金额(元)" prop="noReceiptAmount" show-overflow-tooltip :formatter="formattedNumber"/>
          <el-table-column label="应收金额(元)" prop="invoiceTotal" show-overflow-tooltip :formatter="formattedNumber"/>
        </el-table>
        <pagination v-show="recordTotal > 0" :total="recordTotal" layout="total, sizes, prev, pager, next, jumper" :page="recordPage.current"
                    :limit="recordPage.size" @pagination="recordPaginationChange" />
      </div>
    </div>
    <el-row :gutter="20">
      <!-- 左侧客户列表 -->
      <el-col :span="8">
        <div class="table_list"
             style="width: 100%">
          <el-table :data="tableData"
                    border
                    v-loading="tableLoading"
                    :row-key="(row) => row.customerId"
                    show-summary
                    :summary-method="summarizeMainTable"
                    @row-click="rowClickMethod"
                    highlight-current-row
                    height="calc(100vh - 18.5em)">
            <el-table-column align="center"
                             label="序号"
                             type="index"
                             width="60" />
            <el-table-column label="客户名称"
                             prop="customerName"
                             show-overflow-tooltip
                             width="200" />
            <el-table-column label="合同金额(元)"
                             prop="contractAmounts"
                             show-overflow-tooltip
                             :formatter="formattedNumber"
                             width="150" />
<!--            <el-table-column label="应收金额(元)"-->
<!--                             prop="receiptableAmount"-->
<!--                             show-overflow-tooltip-->
<!--                             width="150">-->
<!--              <template #default="{ row, column }">-->
<!--                <el-text type="danger">-->
<!--                  {{ formattedNumber(row, column, row.receiptableAmount) }}-->
<!--                </el-text>-->
<!--              </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-col>
      <!-- 右侧订单信息 -->
      <el-col :span="16">
        <div class="table_list"
             style="width: 100%">
          <el-table :data="orderRecord"
                    border
                    :row-key="(row) => row.id"
                    v-loading="orderLoading"
                    height="calc(100vh - 20em)">
            <el-table-column align="center"
                             label="序号"
                             type="index"
                             width="60" />
            <el-table-column label="销售订单"
                             prop="salesContractNo"
                             show-overflow-tooltip
                             width="150" />
            <!-- <el-table-column label="发货订单号"
                             prop="shippingNo"
                             show-overflow-tooltip
                             width="150" /> -->
            <el-table-column label="客户名称"
                             prop="customerName"
                             show-overflow-tooltip
                             width="150" />
            <el-table-column label="产品名称"
                             prop="productName"
                             show-overflow-tooltip
                             width="150" />
            <el-table-column label="规格型号"
                             prop="specificationModel"
                             show-overflow-tooltip
                             width="120" />
            <el-table-column label="发货时间"
                             prop="shippingDate"
                             show-overflow-tooltip
                             width="110" />
            <el-table-column label="发货数量"
                             prop="totalQuantity"
                             show-overflow-tooltip
                             width="100" />
            <!-- <el-table-column label="发货车牌号"
                             prop="shippingCarNumber"
                             show-overflow-tooltip
                             width="120" />
            <el-table-column label="快递公司"
                             prop="expressCompany"
                             show-overflow-tooltip
                             width="120" />
            <el-table-column label="快递单号"
                             prop="expressNumber"
                             show-overflow-tooltip
                             width="150" /> -->
            <el-table-column label="发货状态"
                             prop="status"
                             align="center"
                             width="100">
              <template #default="{ row }">
                <el-tag :type="getApprovalStatusType(row.status)">
                  {{ getApprovalStatusText(row.status) }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column label="出库单号"
                             prop="outboundBatches"
                             show-overflow-tooltip
                             width="130" />
          </el-table>
          <pagination v-show="orderTotal > 0"
                      :total="orderTotal"
                      layout="total, sizes, prev, pager, next, jumper"
                      :page="orderPage.current"
                      :limit="orderPage.size"
                      @pagination="orderPaginationChange" />
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script setup>
import { ref } from 'vue'
import {
  invoiceLedgerSalesAccount,
} from "../../../api/salesManagement/invoiceLedger.js";
import {
  receiptPaymentListPage
} from "../../../api/salesManagement/receiptPayment.js";
import Pagination from "../../../components/PIMTable/Pagination.vue";
const { proxy } = getCurrentInstance()
const tableData = ref([])
const receiptRecord = ref([])
const tableLoading = ref(false)
const page = reactive({
  current: 1,
  size: 10,
})
const recordPage = reactive({
  current: 1,
  size: 10,
})
const total = ref(0)
const recordTotal = ref(0)
const data = reactive({
  searchForm: {
    searchText: '',
    invoiceDate:''
  }
})
const customerId = ref('')
const { searchForm } = toRefs(data)
// 查询列表
/** 搜索按钮操作 */
const handleQuery = () => {
  page.current = 1
  getList()
}
const paginationChange = (obj) => {
  console.log('paginationChange', current,limit)
  page.current = obj.page;
  page.size = obj.limit;
  getList()
}
const getList = () => {
  tableLoading.value = true
  invoiceLedgerSalesAccount({...searchForm.value, ...page}).then(res => {
    tableLoading.value = false
    tableData.value = res.data.records;
    total.value = res.data.total;
    if(tableData.value.length > 0) {
      recordPage.current = 1
      customerId.value = tableData.value[0].id
      receiptPaymentList(customerId.value);
  import { onMounted, ref, reactive, toRefs, getCurrentInstance } from "vue";
  import {
    customewTransactions,
  } from "@/api/salesManagement/indicatorStats.js";
  import { deliveryLedgerListPage } from "@/api/salesManagement/deliveryLedger.js";
  import Pagination from "../../../components/PIMTable/Pagination.vue";
  const { proxy } = getCurrentInstance();
  const tableData = ref([]);
  const orderRecord = ref([]);
  const tableLoading = ref(false);
  const orderLoading = ref(false);
  const page = reactive({
    current: 1,
    size: 100,
  });
  const orderPage = reactive({
    current: 1,
    size: 100,
  });
  const total = ref(0);
  const orderTotal = ref(0);
  const data = reactive({
    searchForm: {
      searchText: "",
      invoiceDate: "",
    },
  });
  const customerId = ref("");
  const { searchForm } = toRefs(data);
  // 查询列表
  /** 搜索按钮操作 */
  const handleQuery = () => {
    page.current = 1;
    getList();
  };
  const paginationChange = obj => {
    page.current = obj.page;
    page.size = obj.limit;
    getList();
  };
  const getList = () => {
    tableLoading.value = true;
    customewTransactions({ ...searchForm.value, ...page }).then(res => {
      tableLoading.value = false;
      tableData.value = res.data.records;
      total.value = res.data.total;
      if (tableData.value.length > 0) {
        orderPage.current = 1;
        customerId.value = tableData.value[0].customerId;
        getOrderList(customerId.value);
      } else {
        orderRecord.value = [];
        customerId.value = "";
      }
    });
  };
  const formattedNumber = (row, column, cellValue) => {
    return cellValue ? parseFloat(cellValue).toFixed(2) : "0.00";
  };
  // 主表合计方法
  const summarizeMainTable = param => {
    return proxy.summarizeTable(
      param,
      ["contractAmounts", "receiptableAmount"],
      {
        ticketsNum: { noDecimal: true },
        futureTickets: { noDecimal: true },
      }
    );
  };
  // 获取订单列表(根据客户ID查询发货台账)
  const getOrderList = async (id) => {
    orderLoading.value = true;
    try {
      // 使用 deliveryLedgerListPage 接口根据 customerId 查询
      const res = await deliveryLedgerListPage({
        customerId: id,
        current: 1,
        size: 1000,
      });
      let orders = [];
      if (res.data) {
        if (Array.isArray(res.data)) {
          orders = res.data;
        } else if (res.data.records && Array.isArray(res.data.records)) {
          orders = res.data.records;
        }
      }
      orderTotal.value = orders.length;
      handleOrderPagination({ page: orderPage.current, limit: orderPage.size }, orders);
    } catch (error) {
      console.error('获取订单列表失败:', error);
      orderRecord.value = [];
    } finally {
      orderLoading.value = false;
    }
  })
}
const formattedNumber = (row, column, cellValue) => {
  return parseFloat(cellValue).toFixed(2);
};
// 主表合计方法
const summarizeMainTable = (param) => {
  return proxy.summarizeTable(param, ['invoiceTotal', 'receiptPaymentAmount', 'unReceiptPaymentAmount'], {
    ticketsNum: { noDecimal: true }, // 不保留小数
    futureTickets: { noDecimal: true }, // 不保留小数
  };
  // 订单列表分页
  const orderPaginationChange = pagination => {
    orderPage.current = pagination.page;
    orderPage.size = pagination.limit;
    getOrderList(customerId.value);
  };
  const handleOrderPagination = ({ page, limit }, allOrders) => {
    const start = (page - 1) * limit;
    const end = start + limit;
    orderRecord.value = allOrders.slice(start, end);
  };
  const rowClickMethod = row => {
    customerId.value = row.customerId;
    orderPage.current = 1;
    getOrderList(customerId.value);
  };
  // 审核状态标签类型
  const getApprovalStatusType = (status) => {
    const statusMap = {
      '已发货': 'success',
      '审核通过': 'success',
      '审核中': 'warning',
      '审核不通过': 'danger',
    };
    return statusMap[status] || 'info';
  };
  // 审核状态文本
  const getApprovalStatusText = (status) => {
    const statusMap = {
      '已发货': '已发货',
      '审核通过': '审核通过',
      '审核中': '审核中',
      '审核不通过': '审核不通过',
    };
    return statusMap[status] || status || '--';
  };
  onMounted(() => {
    getList();
  });
};
// 子表合计方法
const summarizeMainTable1 = (param) => {
  return proxy.summarizeTable(param, ['receiptPaymentAmount', 'noReceiptAmount', 'invoiceTotal'], {
    ticketsNum: { noDecimal: true }, // 不保留小数
    futureTickets: { noDecimal: true }, // 不保留小数
  });
};
const receiptPaymentList = (id) => {
  const param = {
    customerId:id,
    current: recordPage.current,
    size: recordPage.size,
  }
  console.log('param', param)
  receiptPaymentListPage(param).then(res => {
    receiptRecord.value = res.data.records;
    recordTotal.value = res.data.total;
  })
}
// 汇款记录列表分页
const recordPaginationChange = (obj) => {
  console.log('recordPaginationChange', obj );
  recordPage.current = obj.page;
  recordPage.size = obj.limit;
  console.log('recordPage',recordPage)
  receiptPaymentList(customerId.value);
}
const rowClickMethod = (row) => {
  customerId.value = row.id;
  receiptPaymentList(customerId.value);
}
getList()
</script>
<style scoped lang="scss">
.table_list {
  width: 50%;
}
  .table_list {
    width: 100%;
  }
</style>