| | |
| | | <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> |
| | |
| | | </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 |
| | |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="发票类型" prop="invoiceType"> |
| | | <el-select |
| | |
| | | placeholder="请选择发票类型" |
| | | style="width: 100%;" |
| | | :disabled="isView" |
| | | @change="handleInvoiceTypeChange" |
| | | > |
| | | <el-option label="增值税专用发票" value="增值税专用发票" /> |
| | | <el-option label="增值税普通发票" value="增值税普通发票" /> |
| | |
| | | </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 |
| | |
| | | placeholder="请选择税率" |
| | | style="width: 100%;" |
| | | :disabled="isView" |
| | | @change="calculateTax" |
| | | @change="handleTaxRateChange" |
| | | > |
| | | <el-option |
| | | v-for="dict in tax_rate" |
| | |
| | | :precision="2" |
| | | style="width: 100%;" |
| | | :disabled="isView" |
| | | @change="calculateTax" |
| | | @change="handleTaxRateChange" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | cancelAccountSalesInvoice, |
| | | deleteAccountSalesInvoice, |
| | | } from "@/api/financialManagement/accountSalesInvoice.js"; |
| | | import {getAccountInvoiceApplicationList} from "@/api/financialManagement/invoiceApply.js"; |
| | | |
| | | const FileList = defineAsyncComponent(() => import("@/components/Dialog/FileList.vue")); |
| | | |
| | |
| | | const fileDialogVisible = ref(false); |
| | | const currentRecordId = ref(0); |
| | | |
| | | const applySelectVisible = ref(false); |
| | | const applyList = ref([]); |
| | | |
| | | const openFileDialog = (row) => { |
| | | if (!row.accountInvoiceApplicationId) { |
| | | ElMessage.warning("未关联开票申请,无法查看附件"); |
| | |
| | | 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 }) => { |
| | |
| | | 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) => ({ |
| | |
| | | |
| | | const closeDialog = () => { |
| | | dialogVisible.value = false; |
| | | applySelectVisible.value = false; |
| | | isView.value = false; |
| | | isView.value = false; |
| | | }; |
| | | |