zouyu
7 小时以前 6570b36a352edd87532dcf13a124181d4d815a39
销项发票页面新增录入发票功能
已修改2个文件
130 ■■■■ 文件已修改
src/api/financialManagement/invoiceApply.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/financialManagement/receivable/outputInvoice.vue 119 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/financialManagement/invoiceApply.js
@@ -56,4 +56,13 @@
    url: `/accountInvoiceApplication/deleteAccountInvoiceApplication?${query}`,
    method: "delete",
  });
}
}
/** 根据客户id查询开票申请台账 */
export function getAccountInvoiceApplicationList(query) {
  return request({
    url: '/accountInvoiceApplication/getAccountInvoiceApplicationList',
    method: "get",
    params: query,
  });
}
src/views/financialManagement/receivable/outputInvoice.vue
@@ -37,7 +37,7 @@
      <div class="actions">
        <div></div>
        <div>
          <!-- <el-button type="primary" @click="add" icon="Plus">录入发票</el-button> -->
          <el-button type="primary" @click="add" icon="Plus">录入发票</el-button>
          <el-button type="success" @click="handleExport" icon="Download">导出</el-button>
        </div>
      </div>
@@ -111,13 +111,25 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="客户" prop="customerId">
              <el-select v-model="form.customerId" placeholder="请选择客户" style="width: 100%;" :disabled="isView">
              <el-select @change="checkCustomer" v-model="form.customerId" placeholder="请选择客户" style="width: 100%;" :disabled="isView">
                <el-option v-for="item in customerList" :key="item.id" :label="item.customerName" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="关联开票申请" prop="accountInvoiceApplicationId">
              <el-select v-model="form.accountInvoiceApplicationId"
                        placeholder="请先选择客户"
                        readonly
                         @change="selectionApply"
                        :disabled="!form.customerId || isView"
                        class="outbound-batch-select">
                <el-option v-for="(item,index) in applyList" :key="index" :label="item.invoiceApplicationNo" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开票日期" prop="invoiceDate">
              <el-date-picker
@@ -130,14 +142,15 @@
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="发票类型" prop="invoiceType">
              <el-select
                v-model="form.invoiceType"
                placeholder="请选择发票类型"
                style="width: 100%;"
                :disabled="isView"
                @change="handleInvoiceTypeChange"
                  v-model="form.invoiceType"
                  placeholder="请选择发票类型"
                  style="width: 100%;"
                  :disabled="isView"
              >
                <el-option label="增值税专用发票" value="增值税专用发票" />
                <el-option label="增值税普通发票" value="增值税普通发票" />
@@ -145,8 +158,6 @@
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="税率" prop="taxRate">
              <el-select
@@ -154,7 +165,7 @@
                placeholder="请选择税率"
                style="width: 100%;"
                :disabled="isView"
                @change="calculateTax"
                @change="handleTaxRateChange"
              >
                <el-option
                  v-for="dict in tax_rate"
@@ -175,7 +186,7 @@
                :precision="2"
                style="width: 100%;"
                :disabled="isView"
                @change="calculateTax"
                @change="handleTaxRateChange"
              />
            </el-form-item>
          </el-col>
@@ -224,6 +235,7 @@
  cancelAccountSalesInvoice,
  deleteAccountSalesInvoice,
} from "@/api/financialManagement/accountSalesInvoice.js";
import {getAccountInvoiceApplicationList} from "@/api/financialManagement/invoiceApply.js";
const FileList = defineAsyncComponent(() => import("@/components/Dialog/FileList.vue"));
@@ -271,6 +283,9 @@
const fileDialogVisible = ref(false);
const currentRecordId = ref(0);
const applySelectVisible = ref(false);
const applyList = ref([]);
const openFileDialog = (row) => {
  if (!row.accountInvoiceApplicationId) {
    ElMessage.warning("未关联开票申请,无法查看附件");
@@ -313,17 +328,88 @@
  totalAmount: 0,
  content: "",
  remark: "",
  deptId: undefined,
  accountInvoiceApplicationId: undefined,
  storageAttachmentId: undefined,
});
const rules = {
  invoiceNo: [{ required: true, message: "请输入发票号码", trigger: "blur" }],
  accountInvoiceApplicationId: [{ required: true, message: "请选择开票申请", trigger: "change" }],
  customerId: [{ required: true, message: "请选择客户", trigger: "change" }],
  invoiceDate: [{ required: true, message: "请选择开票日期", trigger: "change" }],
  invoiceType: [{ required: true, message: "请选择发票类型", trigger: "change" }],
  taxRate: [{ required: true, message: "请选择税率", trigger: "change" }],
  amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
};
// 选择客户
const checkCustomer = (val) =>{
  loadApplyList(val);
}
//查询开票申请列表
const loadApplyList = (customerId) => {
  if (!customerId) {
    applyList.value = [];
    return Promise.resolve();
  }
  return getAccountInvoiceApplicationList({ customerId })
      .then(res => {
        if (res.code === 200) {
          const list = res.data?.records ?? res.data ?? [];
          applyList.value = Array.isArray(list) ? list : [];
        } else {
          applyList.value = [];
        }
      })
      .catch(() => {
        applyList.value = [];
      })
};
const selectionApply = (val)=>{
  const applyObj = applyList.value.find(item=>item.id === val);
  if(!applyObj){
    ElMessage.warning("请选择关联的开票申请");
    return;
  }
  form.remark = applyObj.remark;
  form.content = applyObj.invoiceContent;
  form.invoiceDate = applyObj.applyDate;
  form.invoiceType = applyObj.invoiceType;
  form.deptId = applyObj.deptId;
  form.taxRate = applyObj.taxRate;
  form.totalAmount = applyObj.invoiceAmount
  handleTaxRateChange();
}
/** 价税合计变更:按税率反算不含税金额、税额 */
const calculateTaxFromInclusive = (inclusiveTotal) => {
  const total = Number(inclusiveTotal ?? form.totalAmount ?? 0);
  if (total <= 0) {
    form.amount = 0;
    form.taxAmount = 0;
    form.totalAmount = 0;
    return;
  }
  const rate = Number(form.taxRate) / 100;
  form.totalAmount = Number(total.toFixed(2));
  form.amount = Number((form.totalAmount / (1 + rate)).toFixed(2));
  form.taxAmount = Number((form.totalAmount - form.amount).toFixed(2));
};
const calculateTaxFromExclusive = () => {
  form.taxAmount = Number((form.amount * form.taxRate / 100).toFixed(2));
  form.totalAmount = Number((form.amount + form.taxAmount).toFixed(2));
};
const handleTaxRateChange = () => {
  if (form.totalAmount > 0) {
    calculateTaxFromInclusive(form.totalAmount);
  } else {
    calculateTaxFromExclusive();
  }
};
const getSummaries = ({ columns, data }) => {
@@ -350,15 +436,6 @@
const formatMoney = (value) => {
  if (value === undefined || value === null) return "0.00";
  return Number(value).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
};
const calculateTax = () => {
  form.taxAmount = Number((form.amount * form.taxRate / 100).toFixed(2));
  form.totalAmount = Number((form.amount + form.taxAmount).toFixed(2));
};
const handleInvoiceTypeChange = () => {
  calculateTax();
};
const normalizeTableRow = (row) => ({
@@ -506,6 +583,8 @@
const closeDialog = () => {
  dialogVisible.value = false;
  applySelectVisible.value = false;
  isView.value = false;
  isView.value = false;
};