| | |
| | | <el-dialog :title="modalOptions.title" |
| | | v-model="visible" |
| | | @close="close"> |
| | | <EditForm ref="editFormRef" /> |
| | | <el-form :model="form"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="采购合同号:"> |
| | | <el-tag size="large">{{ form.purchaseContractNumber }}</el-tag> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="销售合同号:"> |
| | | <el-text>{{ form.salesContractNo }}</el-text> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="含税单价(元):"> |
| | | <el-text type="primary">{{ form.taxInclusiveUnitPrice }}</el-text> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="创建时间:"> |
| | | <el-text>{{ form.createdAt }}</el-text> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="发票号:"> |
| | | <el-input disabled |
| | | v-model="form.invoiceNumber" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="来票数:"> |
| | | <el-input-number :step="0.1" |
| | | :min="0" |
| | | style="width: 100%" |
| | | v-model="form.ticketsNum" |
| | | @change="inputTicketsNum" |
| | | :precision="2" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="本次来票金额(元):"> |
| | | <el-input-number :step="0.1" |
| | | :min="0" |
| | | style="width: 100%" |
| | | v-model="form.ticketsAmount" |
| | | @change="inputTicketsAmount" |
| | | :precision="2" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="未来票数:"> |
| | | <el-text type="success">{{ form.futureTickets }}</el-text> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button type="primary" |
| | | :loading="loading" |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { useModal } from "@/hooks/useModal"; |
| | | import EditForm from "../Form/EditForm.vue"; |
| | | import { updateRegistration } from "@/api/procurementManagement/procurementInvoiceLedger"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { useModal } from "@/hooks/useModal"; |
| | | import useFormData from "@/hooks/useFormData"; |
| | | import { updateRegistration, getProductRecordById } from "@/api/procurementManagement/procurementInvoiceLedger"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { getCurrentInstance, ref, nextTick } from "vue"; |
| | | |
| | | defineOptions({ |
| | | name: "来票台账编辑", |
| | | defineOptions({ |
| | | name: "来票台账编辑", |
| | | }); |
| | | const emits = defineEmits(["success"]); |
| | | |
| | | const saleLedgerProjectId = ref(""); |
| | | const temFutureTickets = ref(0); |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | const { |
| | | id, |
| | | visible, |
| | | loading, |
| | | openModal, |
| | | modalOptions, |
| | | handleConfirm, |
| | | closeModal, |
| | | } = useModal({ title: "来票台账" }); |
| | | |
| | | const { form, resetForm } = useFormData({ |
| | | id: undefined, |
| | | purchaseContractNumber: undefined, // 采购合同号 |
| | | salesContractNo: undefined, // 销售合同号 |
| | | createdAt: undefined, // 创建时间 |
| | | invoiceNumber: undefined, // 发票号 |
| | | ticketsNum: undefined, // 来票数 |
| | | ticketsAmount: undefined, // 来票金额 |
| | | taxInclusiveUnitPrice: undefined, // 含税单价 |
| | | futureTickets: undefined, // 未来票数 |
| | | }); |
| | | |
| | | const load = async (id, purchaseLedgerId, productModelId) => { |
| | | const { code, data } = await getProductRecordById({ |
| | | id: id, |
| | | purchaseLedgerId: purchaseLedgerId, |
| | | productModelId: productModelId, |
| | | }); |
| | | const emits = defineEmits(["success"]); |
| | | if (code === 200) { |
| | | form.id = data.id; |
| | | form.purchaseContractNumber = data.purchaseContractNumber; |
| | | form.salesContractNo = data.salesContractNo; |
| | | form.createdAt = data.createdAt; |
| | | form.invoiceNumber = data.invoiceNumber; |
| | | form.ticketsNum = data.ticketsNum; |
| | | form.ticketsAmount = data.ticketsAmount.toFixed(2); |
| | | form.taxInclusiveUnitPrice = data.taxInclusiveUnitPrice; |
| | | form.futureTickets = data.futureTickets; |
| | | temFutureTickets.value = data.futureTickets; |
| | | } |
| | | }; |
| | | |
| | | const saleLedgerProjectId = ref(""); |
| | | const editFormRef = ref(); |
| | | const { |
| | | id, |
| | | visible, |
| | | loading, |
| | | openModal, |
| | | modalOptions, |
| | | handleConfirm, |
| | | closeModal, |
| | | } = useModal({ title: "来票台账" }); |
| | | const inputTicketsNum = val => { |
| | | // 确保含税单价存在且不为零 |
| | | if (!form.taxInclusiveUnitPrice || Number(form.taxInclusiveUnitPrice) === 0) { |
| | | proxy.$modal.msgWarning("含税单价不能为零或未定义"); |
| | | return; |
| | | } |
| | | if (Number(form.ticketsNum) > Number(temFutureTickets.value)) { |
| | | proxy.$modal.msgWarning("开票数不得大于未开票数"); |
| | | form.ticketsNum = temFutureTickets.value; |
| | | } |
| | | |
| | | const open = async row => { |
| | | openModal(row.id); |
| | | saleLedgerProjectId.value = row.saleLedgerProjectId; |
| | | await nextTick(); |
| | | editFormRef.value.load(row.id, row.purchaseLedgerId, row.productModelId); |
| | | }; |
| | | // 确保所有数值都转换为数字类型进行计算 |
| | | const ticketsAmount = |
| | | Number(form.ticketsNum) * Number(form.taxInclusiveUnitPrice); |
| | | const futureTickets = |
| | | Number(temFutureTickets.value) - Number(form.ticketsNum); |
| | | form.futureTickets = Number(futureTickets.toFixed(2)); |
| | | form.ticketsAmount = Number(ticketsAmount.toFixed(2)); |
| | | }; |
| | | |
| | | const close = () => { |
| | | editFormRef.value.resetForm(); |
| | | closeModal(); |
| | | }; |
| | | const inputTicketsAmount = val => { |
| | | // 确保含税单价存在且不为零 |
| | | if (!form.taxInclusiveUnitPrice || Number(form.taxInclusiveUnitPrice) === 0) { |
| | | proxy.$modal.msgWarning("含税单价不能为零或未定义"); |
| | | return; |
| | | } |
| | | |
| | | const sendForm = async () => { |
| | | const form = editFormRef.value.form; |
| | | form.saleLedgerProjectId = saleLedgerProjectId.value; |
| | | const { code } = await updateRegistration(form); |
| | | if (code === 200) { |
| | | emits("success"); |
| | | ElMessage({ message: "操作成功", type: "success" }); |
| | | close(); |
| | | } |
| | | }; |
| | | if (Number(val) > Number(form.futureTickets * form.taxInclusiveUnitPrice)) { |
| | | proxy.$modal.msgWarning("本次来票金额不得大于总金额"); |
| | | form.ticketsAmount = ( |
| | | form.futureTickets * form.taxInclusiveUnitPrice |
| | | ).toFixed(2); |
| | | const ticketsNum = |
| | | Number(form.ticketsAmount) / Number(form.taxInclusiveUnitPrice); |
| | | form.ticketsNum = Number(ticketsNum.toFixed(2)); |
| | | return; |
| | | } |
| | | |
| | | defineExpose({ |
| | | open, |
| | | }); |
| | | // 确保所有数值都转换为数字类型进行计算 |
| | | const ticketsNum = Number(val) / Number(form.taxInclusiveUnitPrice); |
| | | form.ticketsNum = Number(ticketsNum.toFixed(2)); |
| | | }; |
| | | |
| | | const open = async row => { |
| | | openModal(row.id); |
| | | saleLedgerProjectId.value = row.saleLedgerProjectId; |
| | | await nextTick(); |
| | | load(row.id, row.purchaseLedgerId, row.productModelId); |
| | | }; |
| | | |
| | | const close = () => { |
| | | resetForm(); |
| | | closeModal(); |
| | | }; |
| | | |
| | | const sendForm = async () => { |
| | | form.saleLedgerProjectId = saleLedgerProjectId.value; |
| | | const { code } = await updateRegistration(form); |
| | | if (code === 200) { |
| | | emits("success"); |
| | | ElMessage({ message: "操作成功", type: "success" }); |
| | | close(); |
| | | } |
| | | }; |
| | | |
| | | defineExpose({ |
| | | open, |
| | | }); |
| | | </script> |
| | | |
| | | <style lang="scss" scoped></style> |