gaoluyang
2025-06-09 183d13a62353fc7594417068f5d2709c09cdb523
src/views/salesManagement/receiptPayment/index.vue
@@ -23,18 +23,41 @@
                :row-key="row => row.id"
                show-summary
                :summary-method="summarizeMainTable"
                :expand-row-keys="expandedRowKeys"
                @expand-change="expandChange"
                height="calc(100vh - 18.5em)">
        <el-table-column align="center" type="selection" 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" width="70"/>
              <el-table-column label="数量" prop="quantity" width="70"/>
              <el-table-column label="税率" prop="taxRate" width="70" />
              <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="invoiceNum" />
              <el-table-column label="开票金额(元)" prop="invoiceAmount" :formatter="formattedNumber" />
              <el-table-column label="未开票数" prop="noInvoiceNum" />
              <el-table-column label="未开票金额(元)" prop="noInvoiceAmount" :formatter="formattedNumber"/>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column align="center" label="序号" type="index" width="60" />
        <el-table-column label="销售合同号" prop="salesContractNo" show-overflow-tooltip/>
        <el-table-column label="客户合同号" prop="customerContractNo" show-overflow-tooltip/>
        <el-table-column label="客户名称" prop="customerName" show-overflow-tooltip/>
        <el-table-column label="产品大类" prop="productCategory" show-overflow-tooltip/>
        <el-table-column label="发票号" prop="invoiceNo" show-overflow-tooltip/>
        <el-table-column label="发票金额(元)" prop="invoiceTotal" show-overflow-tooltip/>
        <el-table-column label="发票金额(元)" prop="invoiceTotal" show-overflow-tooltip :formatter="formattedNumber"/>
        <el-table-column label="税率" prop="taxRate" show-overflow-tooltip/>
        <el-table-column label="回款金额(元)" prop="receiptPaymentAmountTotal" show-overflow-tooltip/>
        <el-table-column label="待回款金额(元)" prop="noReceiptAmount" show-overflow-tooltip/>
        <el-table-column label="回款金额(元)" prop="receiptPaymentAmountTotal" show-overflow-tooltip :formatter="formattedNumber"/>
        <el-table-column label="待回款金额(元)" prop="noReceiptAmount" 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" />
@@ -73,7 +96,7 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="本次回款金额:" prop="receiptPaymentAmount">
              <el-input type="number" v-model="form.receiptPaymentAmount" placeholder="请输入" :step="0.01" clearable/>
              <el-input type="number" min="0" v-model="form.receiptPaymentAmount" placeholder="请输入" :step="0.01" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
@@ -87,7 +110,7 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="登记人:" prop="registrant">
              <el-input v-model="form.registrant" placeholder="请输入" clearable/>
              <el-input v-model="form.registrant" placeholder="请输入" clearable disabled/>
            </el-form-item>
          </el-col>
        </el-row>
@@ -123,17 +146,20 @@
import {
  receiptPaymentSaveOrUpdate,
  bindInvoiceNoRegPage,
  invoiceInfo
  invoiceInfo, receiptPaymentHistoryListNoPage
} from "../../../api/salesManagement/receiptPayment.js";
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const { proxy } = getCurrentInstance()
const tableData = ref([])
const selectedRows = ref([])
const tableLoading = ref(false)
const page = reactive({
  current: 1,
  size: 10,
  size: 100,
})
const total = ref(0)
const expandedRowKeys = ref([])
// 用户信息表单弹框数据
const dialogFormVisible = ref(false)
@@ -167,15 +193,18 @@
const { searchForm, form, rules } = toRefs(data)
const { receipt_payment_type } = proxy.useDict("receipt_payment_type")
const formattedNumber = (row, column, cellValue) => {
  return parseFloat(cellValue).toFixed(2);
};
// 查询列表
/** 搜索按钮操作 */
const handleQuery = () => {
  page.current = 1
  getList()
}
const paginationChange = ({ current, limit }) => {
  page.current = current;
  page.size = limit;
const paginationChange = (obj) => {
  page.current = obj.page;
  page.size = obj.limit;
  getList()
}
const getList = () => {
@@ -188,33 +217,41 @@
    tableLoading.value = false
  })
}
// 展开行
const expandChange = (row, expandedRows) => {
  if (expandedRows.length > 0) {
    expandedRowKeys.value = []
    try {
      receiptPaymentHistoryListNoPage({invoiceLedgerId: row.id,
        type: 1 }).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 handleSelectionChange = (selection) => {
  selectedRows.value = selection
}
// 主表合计方法
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','receiptPaymentAmount'].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, ['invoiceTotal', 'receiptPaymentAmountTotal', 'noReceiptAmount'], {
    ticketsNum: { noDecimal: true }, // 不保留小数
    futureTickets: { noDecimal: true }, // 不保留小数
  });
};
// 子表合计方法
const summarizeChildrenTable = (param) => {
  return proxy.summarizeTable(param, ['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice','invoiceNum','invoiceAmount','noInvoiceNum','noInvoiceAmount']);
}
// 打开弹框
const openForm = () => {
  form.value = {}
@@ -222,10 +259,17 @@
    proxy.$modal.msgError("请选择一条数据")
    return
  }
  //
  console.log('(selectedRows.value',selectedRows.value)
  if(selectedRows.value[0].noReceiptAmount === 0){
    proxy.$modal.msgError("待回款金额为0元")
    return
  }
  invoiceInfo({id: selectedRows.value[0].id}).then(res => {
    form.value = {...res.data}
    form.value.invoiceLedgerId = form.value.id
    form.value.id = ''
    form.value.registrant = userStore.nickName
  })
  dialogFormVisible.value = true
}