chenrui
2025-06-06 ece2dfeb926d728b10db38038e4d12e9e9851c24
src/views/salesManagement/invoiceRegistration/index.vue
@@ -35,16 +35,16 @@
              <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" />
              <el-table-column label="数量" prop="quantity" />
              <el-table-column label="税率" prop="taxRate" />
              <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" />
              <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" />
              <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" />
              <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" />
              <el-table-column label="开票金额(元)" prop="invoiceAmount" :formatter="formattedNumber" />
              <el-table-column label="未开票数" prop="noInvoiceNum" />
              <el-table-column label="未开票金额(元)" prop="noInvoiceAmount"/>
              <el-table-column label="未开票金额(元)" prop="noInvoiceAmount" :formatter="formattedNumber"/>
            </el-table>
          </template>
        </el-table-column>
@@ -54,8 +54,8 @@
        <el-table-column label="客户名称" prop="customerName" show-overflow-tooltip/>
        <el-table-column label="业务员" prop="salesman" show-overflow-tooltip/>
        <el-table-column label="项目名称" prop="projectName" show-overflow-tooltip/>
        <el-table-column label="合同金额(元)" prop="contractAmount" show-overflow-tooltip/>
        <el-table-column label="未开票金额(元)" prop="noInvoiceAmountTotal" show-overflow-tooltip/>
        <el-table-column label="合同金额(元)" prop="contractAmount" show-overflow-tooltip :formatter="formattedNumber"/>
        <el-table-column label="未开票金额(元)" prop="noInvoiceAmountTotal" 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" />
@@ -95,19 +95,19 @@
          <el-table-column label="产品大类" prop="productCategory" />
          <el-table-column label="规格型号" prop="specificationModel" />
          <el-table-column label="单位" prop="unit" />
          <el-table-column label="数量" prop="quantity" />
          <el-table-column label="税率" prop="taxRate" />
          <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" />
          <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" />
          <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" />
          <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" width="150" />
          <el-table-column label="本次开票数" prop="currentInvoiceNum">
            <template #default="scope">
              <el-input type="number" :step="1" min="0" v-model="scope.row.currentInvoiceNum" @blur="invoiceNumBlur(scope.row)"></el-input>
              <el-input type="number" :step="0.1" min="0" v-model="scope.row.currentInvoiceNum" @blur="invoiceNumBlur(scope.row)"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="本次开票金额(元)" prop="currentInvoiceAmount" >
          <el-table-column label="本次开票金额(元)" prop="currentInvoiceAmount" width="150">
            <template #default="scope">
              <el-input type="number" :step="0.01" min="0" v-model="scope.row.currentInvoiceAmount" disabled></el-input>
              <el-input type="number" :step="0.01" min="0" v-model="scope.row.currentInvoiceAmount" @blur="invoiceAmountBlur(scope.row)" ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="未开票数" prop="noInvoiceNum" >
@@ -115,9 +115,9 @@
              <el-input type="number" min="0" disabled v-model="scope.row.noInvoiceNum"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="未开票金额(元)" prop="noInvoiceAmount" >
          <el-table-column label="未开票金额(元)" prop="noInvoiceAmount"  width="150" >
            <template #default="scope">
              <el-input  type="number" min="0"  disabled v-model="scope.row.noInvoiceAmount"></el-input>
              <el-input type="number" min="0" disabled v-model="scope.row.noInvoiceAmount" :precision="2" :step="0.01"></el-input>
            </template>
          </el-table-column>
        </el-table>
@@ -140,7 +140,7 @@
// import {userListNoPage} from "@/api/system/user.js";
import {
  getSalesLedgerWithProducts,
  ledgerList,
  ledgerListPage,
  productList,
} from "@/api/salesManagement/salesLedger.js";
import {
@@ -176,22 +176,29 @@
})
const { searchForm, form, rules } = toRefs(data)
const formattedNumber = (row, column, cellValue) => {
  if (cellValue) {
    return parseFloat(cellValue).toFixed(2);
  } else {
    return cellValue;
  }
};
// 查询列表
/** 搜索按钮操作 */
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 = () => {
  tableLoading.value = true
  ledgerList({...searchForm.value, ...page}).then(res => {
  ledgerListPage({...searchForm.value, ...page}).then(res => {
    tableLoading.value = false
    tableData.value = res.rows;
    tableData.value = res.records;
    total.value = res.total
    expandedRowKeys.value = []
  })
@@ -224,49 +231,11 @@
}
// 主表合计方法
const summarizeMainTable = (param) => {
  const { columns, data } = param;
  const sums = [];
  columns.forEach((column, index) => {
    if (index === 0) {
      sums[index] = '合计';
      return;
    }
    const prop = column.property;
    if (['contractAmount'].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, ['contractAmount','noInvoiceAmountTotal']);
};
// 子表合计方法
const summarizeChildrenTable = (param) => {
  const { columns, data } = param;
  const sums = [];
  columns.forEach((column, index) => {
    if (index === 0) {
      sums[index] = '合计';
      return;
    }
    const prop = column.property;
    if (['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice','invoiceNum','invoiceAmount','noInvoiceNum','noInvoiceAmount'].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, ['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice','invoiceNum','invoiceAmount','noInvoiceNum','noInvoiceAmount']);
}
// 打开弹框
const openForm = () => {
@@ -326,16 +295,33 @@
  if(!row.currentInvoiceNum){
    row.currentInvoiceNum = 0
  }
  if(row.currentInvoiceNum > row.noInvoiceNum){
  if(row.currentInvoiceNum > row.tempNoInvoiceNum){
    proxy.$modal.msgWarning('本次开票数不得大于未开票数')
    row.currentInvoiceNum = 0
  }
  // 计算本次开票金额
  row.currentInvoiceAmount = row.currentInvoiceNum * row.taxInclusiveUnitPrice
  row.currentInvoiceAmount = (row.currentInvoiceNum * row.taxInclusiveUnitPrice).toFixed(2)
  // 计算未开票数
  row.noInvoiceNum = row.originalNoInvoiceNum - row.currentInvoiceNum
  // 计算未开票金额
  row.noInvoiceAmount = row.noInvoiceNum * row.taxInclusiveUnitPrice
  row.noInvoiceAmount = row.tempnoInvoiceAmount -  row.currentInvoiceAmount
}
// 本次开票金额失焦操作
const invoiceAmountBlur = (row) => {
  if(!row.currentInvoiceAmount){
    row.currentInvoiceAmount = 0
  }
  // 计算是否超过开票总金额
  if(row.currentInvoiceAmount > row.tempnoInvoiceAmount){
    proxy.$modal.msgWarning('本次开票金额不得大于未开票金额')
    row.currentInvoiceAmount = 0
  }
  // 计算本次开票数
  row.currentInvoiceNum = (row.currentInvoiceAmount / row.taxInclusiveUnitPrice).toFixed(2)
  // 计算未开票数
  row.noInvoiceNum = row.originalNoInvoiceNum - row.currentInvoiceNum
  // 计算未开票金额
  row.noInvoiceAmount = row.tempnoInvoiceAmount -  row.currentInvoiceAmount
}
getList()