| | |
| | | <el-button type="primary" @click="handleQuery" style="margin-left: 10px">搜索</el-button> |
| | | </div> |
| | | <div> |
| | | <el-button type="primary" @click="openForm('add')">新增登记</el-button> |
| | | <el-button type="primary" @click="openForm">新增登记</el-button> |
| | | <el-button @click="handleOut">导出</el-button> |
| | | <el-button type="danger" plain @click="handleDelete">删除</el-button> |
| | | </div> |
| | | </div> |
| | | <div class="table_list"> |
| | |
| | | <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper" :page="page.current" |
| | | :limit="page.size" @pagination="paginationChange" /> |
| | | </div> |
| | | <el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? '新增开票登记页面' : '编辑开票登记页面'" width="70%" @close="closeDia"> |
| | | <el-dialog v-model="dialogFormVisible" title="新增开票登记页面" width="85%" @close="closeDia"> |
| | | <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="销售合同号:" prop="salesLedgerId"> |
| | | <el-select v-model="form.salesLedgerId" placeholder="请选择" clearable @change="ledgerChange" :disabled="operationType === 'edit'"> |
| | | <el-option v-for="item in ledgerList" :key="item.id" :label="item.salesContractNo" :value="item.id"/> |
| | | </el-select> |
| | | <el-form-item label="销售合同号:" prop="salesContractNo"> |
| | | <el-input v-model="form.salesContractNo" disabled></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | |
| | | <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" /> |
| | | <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" /> |
| | | <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" /> |
| | | <el-table-column label="本次开票数" prop="invoiceNum"> |
| | | <el-table-column label="本次开票数" prop="currentInvoiceNum"> |
| | | <template #default="scope"> |
| | | <el-input type="number" :step="1" min="0" v-model="scope.row.invoiceNum" @blur="invoiceNumBlur(scope.row)"></el-input> |
| | | <el-input type="number" :step="1" min="0" v-model="scope.row.currentInvoiceNum" @blur="invoiceNumBlur(scope.row)"></el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="本次开票金额(元)" prop="invoiceAmount" > |
| | | <el-table-column label="本次开票金额(元)" prop="currentInvoiceAmount" > |
| | | <template #default="scope"> |
| | | <el-input type="number" :step="0.01" min="0" v-model="scope.row.invoiceAmount" @blur="invoiceAmountBlur(scope.row)"></el-input> |
| | | <el-input type="number" :step="0.01" min="0" v-model="scope.row.currentInvoiceAmount" disabled></el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="未开票数" prop="noInvoiceNum" > |
| | |
| | | import {ElMessageBox } from "element-plus"; |
| | | // import {userListNoPage} from "@/api/system/user.js"; |
| | | import { |
| | | ledgerListNoPage, |
| | | getSalesLedgerWithProducts, |
| | | ledgerList, |
| | | productList, |
| | | } from "@/api/salesManagement/salesLedger.js"; |
| | | import { |
| | | invoiceRegistrationList, |
| | | invoiceRegistrationSaveOrUpdate, |
| | | invoiceRegistrationDel, |
| | | productList, |
| | | invoiceRegistrationDetail, |
| | | invoiceRegistrationSave, |
| | | } from "@/api/salesManagement/invoiceRegistration.js"; |
| | | const { proxy } = getCurrentInstance() |
| | | const tableData = ref([]) |
| | |
| | | size: 10, |
| | | }) |
| | | const total = ref(0) |
| | | const ledgerList = ref([]) |
| | | // 用户信息表单弹框数据 |
| | | const operationType = ref('') |
| | | const dialogFormVisible = ref(false) |
| | |
| | | } |
| | | const getList = () => { |
| | | tableLoading.value = true |
| | | invoiceRegistrationList({...searchForm.value, ...page}).then(res => { |
| | | ledgerList({...searchForm.value, ...page}).then(res => { |
| | | tableLoading.value = false |
| | | tableData.value = res.data.records; |
| | | tableData.value.map(item => { |
| | | item.children = [] |
| | | }) |
| | | total.value = res.data.total |
| | | tableData.value = res.rows; |
| | | total.value = res.total |
| | | expandedRowKeys.value = [] |
| | | }) |
| | | } |
| | | // 表格选择数据 |
| | | const handleSelectionChange = (selection) => { |
| | | console.log('selection', selection) |
| | | selectedRows.value = selection |
| | | } |
| | | const expandedRowKeys = ref([]) |
| | |
| | | if (expandedRows.length > 0) { |
| | | expandedRowKeys.value = [] |
| | | try { |
| | | productList({invoiceRegistrationId: row.id}).then(res => { |
| | | productList({salesLedgerId: row.id, |
| | | type: 1 }).then(res => { |
| | | const index = tableData.value.findIndex(item => item.id === row.id); |
| | | if (index > -1) { |
| | | tableData.value[index].children = res.data; |
| | | tableData.value[index].children = res; |
| | | } |
| | | expandedRowKeys.value.push(row.id) |
| | | }) |
| | |
| | | return sums; |
| | | } |
| | | // 打开弹框 |
| | | const openForm = (type, row) => { |
| | | operationType.value = type |
| | | const openForm = () => { |
| | | // 判断是否多选 |
| | | if(selectedRows.value.length != 1) { |
| | | proxy.$modal.msgError("请选择一条合同") |
| | | return; |
| | | } |
| | | form.value = {} |
| | | productData.value = [] |
| | | // 查询销售合同 |
| | | ledgerListNoPage({}).then(res => { |
| | | ledgerList.value = res.data; |
| | | }) |
| | | if (type === 'edit') { |
| | | invoiceRegistrationDetail({id: row.id}).then(res => { |
| | | form.value = {...res.data} |
| | | form.value.productDtoList = res.data.productDtoList |
| | | productData.value = form.value.productDtoList |
| | | getSalesLedgerWithProducts({id: selectedRows.value[0].id}).then(res => { |
| | | form.value = {...res} |
| | | productData.value = form.value.productData.map(item => { |
| | | return item |
| | | }) |
| | | } |
| | | dialogFormVisible.value = true |
| | | dialogFormVisible.value = true |
| | | console.log('productData.value ',productData.value ) |
| | | }) |
| | | |
| | | } |
| | | // 提交表单 |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | | form.value.productDtoList = proxy.HaveJson(productData.value) |
| | | delete form.value.productData |
| | | invoiceRegistrationSaveOrUpdate(form.value).then(res => { |
| | | form.value.productData = proxy.HaveJson(productData.value) |
| | | invoiceRegistrationSave(form.value).then(res => { |
| | | proxy.$modal.msgSuccess("提交成功") |
| | | closeDia() |
| | | getList() |
| | |
| | | proxy.$modal.msg("已取消") |
| | | }) |
| | | } |
| | | // 删除 |
| | | const handleDelete = () => { |
| | | let ids = [] |
| | | if (selectedRows.value.length > 0) { |
| | | ids = selectedRows.value.map(item => item.id); |
| | | } else { |
| | | proxy.$modal.msgWarning('请选择数据') |
| | | return |
| | | } |
| | | ElMessageBox.confirm( |
| | | '选中的内容将被删除,是否确认删除?', |
| | | '导出', { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | } |
| | | ).then(() => { |
| | | invoiceRegistrationDel(ids).then(res => { |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | getList() |
| | | }) |
| | | }).catch(() => { |
| | | proxy.$modal.msg("已取消") |
| | | }) |
| | | } |
| | | // 销售台账筛选 |
| | | const ledgerChange = (val) => { |
| | | if(val){ |
| | | getSalesLedgerWithProducts({id: val}).then(res => { |
| | | form.value = { |
| | | salesLedgerId: res.id, |
| | | customerName: res.customerName, |
| | | salesman: res.salesman, |
| | | projectName: res.projectName, |
| | | productData: res.productData, |
| | | salesContractNo: res.salesContractNo, |
| | | customerId: res.customerId, |
| | | } |
| | | productData.value = form.value.productData.map(item => { |
| | | item.noInvoiceNum = item.futureTickets |
| | | item.noInvoiceAmount = item.futureTicketsAmount |
| | | return item |
| | | }) |
| | | console.log('productData.value ',productData.value ) |
| | | }) |
| | | }else { |
| | | proxy.resetForm("formRef") |
| | | productData.value = [] |
| | | } |
| | | } |
| | | |
| | | //本次开票失焦操作 |
| | | const invoiceNumBlur = (row) => { |
| | | if(!row.invoiceNum){ |
| | | row.invoiceNum = 0 |
| | | if(!row.currentInvoiceNum){ |
| | | row.currentInvoiceNum = 0 |
| | | } |
| | | if(row.invoiceNum > row.noInvoiceNum){ |
| | | if(row.currentInvoiceNum > row.noInvoiceNum){ |
| | | proxy.$modal.msgWarning('本次开票数不得大于未开票数') |
| | | row.invoiceNum = 0 |
| | | row.currentInvoiceNum = 0 |
| | | } |
| | | row.noInvoiceNum = row.futureTickets - row.invoiceNum |
| | | // 计算本次开票金额 |
| | | row.currentInvoiceAmount = row.currentInvoiceNum * row.taxInclusiveUnitPrice |
| | | // 计算未开票数 |
| | | row.noInvoiceNum = row.noInvoiceNum - row.currentInvoiceNum |
| | | // 计算未开票金额 |
| | | row.noInvoiceAmount = row.noInvoiceNum * row.taxInclusiveUnitPrice |
| | | } |
| | | // 本次开票金额失焦操作 |
| | | const invoiceAmountBlur = (row) => { |
| | | if(!row.invoiceAmount){ |
| | | row.invoiceAmount = 0 |
| | | } |
| | | if(row.invoiceAmount > row.noInvoiceAmount){ |
| | | proxy.$modal.msgWarning('本次开票金额不得大于未开票金额') |
| | | row.invoiceAmount = 0 |
| | | } |
| | | row.noInvoiceAmount = row.futureTicketsAmount - row.invoiceAmount |
| | | } |
| | | |
| | | getList() |
| | | </script> |
| | | |