| | |
| | | <div> |
| | | <span class="search_title">采购合同号:</span> |
| | | <el-input |
| | | v-model="searchForm.purchaseContractNo" |
| | | v-model="searchForm.purchaseContractNumber" |
| | | style="width: 240px" |
| | | placeholder="请输入" |
| | | @change="handleQuery" |
| | |
| | | <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 @click="handleOut">导出</el-button> |
| | | <!-- <el-button type="danger" plain @click="handleDelete">删除</el-button> --> |
| | | </div> |
| | | </div> |
| | | <div class="table_list"> |
| | | <el-table :data="tableData" border v-loading="tableLoading" |
| | | @selection-change="handleSelectionChange" |
| | | :row-key="row => row.id" |
| | | show-summary |
| | | :summary-method="summarizeMainTable" |
| | | height="calc(100vh - 18.5em)"> |
| | | <el-table-column align="center" type="selection" width="55" /> |
| | | <el-table-column align="center" label="序号" type="index" width="60" /> |
| | | <el-table-column label="采购合同号" prop="purchaseContractNumber" show-overflow-tooltip/> |
| | | <el-table-column label="销售合同号" prop="salesContractNo" show-overflow-tooltip/> |
| | | <el-table-column label="供应商名称" prop="supplierName" show-overflow-tooltip/> |
| | | <el-table-column label="发票号" prop="invoiceNumber" show-overflow-tooltip/> |
| | | <el-table-column label="发票金额(元)" prop="invoiceAmount" show-overflow-tooltip/> |
| | | <el-table-column label="税率(%)" prop="taxRate" show-overflow-tooltip/> |
| | | <el-table-column label="开票人" prop="issUer" show-overflow-tooltip/> |
| | | <el-table-column label="开票日期" prop="issueDate" show-overflow-tooltip/> |
| | | <!-- <el-table-column label="发票" prop="fileName" show-overflow-tooltip> |
| | | <template #default="scope"> |
| | | <span v-if="scope.row.fileName">{{ scope.row.fileName }}</span> |
| | | <el-button v-else link type="primary" @click="handleDownload(scope.row)">上传</el-button> |
| | | </template> |
| | | </el-table-column> --> |
| | | <!-- <el-table-column fixed="right" label="操作" min-width="60" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" size="small" @click="openForm('edit', scope.row);">编辑</el-button> |
| | | </template> |
| | | </el-table-column> --> |
| | | <el-table-column fixed="right" label="操作" min-width="60" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" size="small" @click="openForm('check', scope.row);">查看</el-button> |
| | | :expand-row-keys="expandedRowKeys" :row-key="row => row.id" show-summary :summary-method="summarizeMainTable" |
| | | @expand-change="expandChange" height="calc(100vh - 18.5em)"> |
| | | <el-table-column align="center" label="序号" type="index" width="55" /> |
| | | <el-table-column type="expand"> |
| | | <template #default="props"> |
| | | <el-table :data="props.row.children" border show-summary :summary-method="summarizeChildrenTable"> |
| | | <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" :formatter="formattedNumber" /> |
| | | <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" /> |
| | | <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" /> |
| | | <el-table-column label="本次来票数" prop="ticketsNum" /> |
| | | <el-table-column label="本次来票金额(元)" prop="ticketsAmount" :formatter="formattedNumber" /> |
| | | <el-table-column label="未来票数" prop="futureTickets" /> |
| | | <el-table-column label="未来票金额(元)" prop="futureTicketsAmount" :formatter="formattedNumber" /> |
| | | </el-table> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="采购合同号" prop="purchaseContractNumber" show-overflow-tooltip /> |
| | | <el-table-column label="销售合同号" prop="salesContractNo" show-overflow-tooltip /> |
| | | <el-table-column label="供应商名称" prop="supplierName" show-overflow-tooltip /> |
| | | <el-table-column label="发票号" prop="invoiceNumber" show-overflow-tooltip /> |
| | | <el-table-column label="合同金额(元)" prop="invoiceAmount" show-overflow-tooltip :formatter="formattedNumber" /> |
| | | <el-table-column label="开票人" prop="issUer" show-overflow-tooltip /> |
| | | <el-table-column label="开票日期" prop="issueDate" show-overflow-tooltip /> |
| | | </el-table> |
| | | <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper" :page="page.current" |
| | | :limit="page.size" @pagination="paginationChange" /> |
| | | <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-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="purchaseLedgerId"> |
| | | <el-select v-model="form.purchaseLedgerId" placeholder="请选择" clearable @change="setInfo"> |
| | | <el-option v-for="item in purchaseLedgerList" :key="item.id" :label="item.purchaseContractNumber" :value="item.id"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="销售合同号:" prop="salesContractNo"> |
| | | <el-input v-model="form.salesContractNo" placeholder="自动填充" clearable disabled/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="供应商名称:" prop="supplierName"> |
| | | <el-input v-model="form.supplierName" placeholder="自动填充" clearable disabled/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="发票号:" prop="invoiceNumber"> |
| | | <el-input v-model="form.invoiceNumber" placeholder="请输入" :disabled="operationType === 'check'" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="发票金额(元):" prop="invoiceAmount"> |
| | | <el-input type="number" :step="0.01" v-model="form.invoiceAmount" placeholder="请输入" :disabled="operationType === 'check'" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="税率:" prop="taxRate"> |
| | | <el-input type="number" :step="0.01" v-model="form.taxRate" placeholder="请输入" :disabled="operationType === 'check'" clearable/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="开票人:" prop="issUer"> |
| | | <el-input v-model="form.issUer" placeholder="请输入" clearable disabled/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="开票日期:" prop="issueDate"> |
| | | <el-date-picker |
| | | disabled |
| | | style="width: 100%" |
| | | v-model="form.issueDate" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="date" |
| | | placeholder="请选择" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="附件材料:" prop="remark"> |
| | | <el-upload |
| | | v-model:file-list="fileList" |
| | | :action="upload.url" |
| | | multiple |
| | | ref="fileUpload" |
| | | auto-upload |
| | | :headers="upload.headers" |
| | | accept=".pdf" |
| | | :limit="1" |
| | | :data="{ type: 3 }" |
| | | :before-upload="handleBeforeUpload" |
| | | :on-error="handleUploadError" |
| | | :on-success="handleUploadSuccess" |
| | | :on-remove="handleRemove" |
| | | > |
| | | <el-button type="primary">上传</el-button> |
| | | <template #tip> |
| | | <div class="el-upload__tip"> |
| | | 文件格式仅支持 pdf |
| | | </div> |
| | | </template> |
| | | </el-upload> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> --> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <!-- <el-button type="primary" @click="submitForm">确认</el-button> --> |
| | | <!-- <el-button @click="closeDia">取消</el-button> --> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <el-dialog title="上传弹窗" width="20%" v-model="uploadModal"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="附件材料:" prop="remark"> |
| | | <el-upload |
| | | v-model:file-list="fileList" |
| | | :action="upload.url1" |
| | | multiple |
| | | ref="fileUpload" |
| | | auto-upload |
| | | accept=".pdf" |
| | | :limit="1" |
| | | :data="{ type: 3,id: currentId }" |
| | | :headers="upload.headers" |
| | | :before-upload="handleBeforeUpload" |
| | | :on-error="handleUploadError" |
| | | :on-success="handleUploadSuccess" |
| | | :on-remove="handleRemove" |
| | | > |
| | | <el-button type="primary">上传</el-button> |
| | | <!-- 文件格式支持 doc,docx,xls,xlsx,ppt,pptx,pdf,txt,xml,jpg,jpeg,png,gif,bmp,rar,zip,7z--> |
| | | <template #tip> |
| | | <div class="el-upload__tip"> |
| | | 文件格式支持 pdf |
| | | </div> |
| | | </template> |
| | | </el-upload> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="commiInvoicetFile" type="primary">确认</el-button> |
| | | <el-button @click="commiInvoicetFile">取消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | import { ref } from 'vue' |
| | | import {Search} from "@element-plus/icons-vue"; |
| | | import {ElMessageBox } from "element-plus"; |
| | | import {productRecordList} from "@/api/procurementManagement/procurementInvoiceLedger.js"; |
| | | import { |
| | | delLedgerFile, |
| | | ledgerListNoPage |
| | | } from "@/api/salesManagement/salesLedger.js"; |
| | | import { getToken } from "@/utils/auth" |
| | | import {getProduct, getInfo} from "@/api/procurementManagement/invoiceEntry.js"; |
| | | import useUserStore from "@/store/modules/user.js"; |
| | | import { |
| | | addOrUpdateInvoice, delCommonFile, |
| | | delInvoice, |
| | | getInvoiceById, |
| | | invoiceList |
| | | } from "@/api/procurementManagement/procurementInvoiceLedger.js"; |
| | | const { proxy } = getCurrentInstance() |
| | | const tableData = ref([]) |
| | | const productData = ref([]) |
| | | const selectedRows = ref([]) |
| | | const tableLoading = ref(false) |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | }) |
| | | const total = ref(0) |
| | | const fileList = ref([]) |
| | | const ledgerList = ref([]) |
| | | const purchaseLedgerList = ref([]) |
| | | const userStore = useUserStore() |
| | | import { genFileId } from 'element-plus' |
| | | // 用户信息表单弹框数据 |
| | | const operationType = ref('') |
| | | const dialogFormVisible = ref(false) |
| | | const data = reactive({ |
| | | const data = reactive({ |
| | | searchForm: { |
| | | purchaseContractNo: '', |
| | | purchaseContractNumber: '', |
| | | supplierName: '', |
| | | issueDate:'' |
| | | }, |
| | | form: { |
| | | issueDate:"",// 开票日期 |
| | | purchaseLedgerId: '', |
| | | salesLedgerId: '', |
| | | customerId: '', |
| | | invoiceNumber: '', |
| | | invoiceAmount: '', |
| | | taxRate: '', |
| | | issUerId: '', |
| | | issUer: '', |
| | | issueDate: '', |
| | | customerName:'', |
| | | fileList:[] |
| | | purchaseLedgerNo: '', |
| | | issUerId: '', // 开票人id |
| | | issUer: '' ,// 开票人姓名 |
| | | }, |
| | | // rules: { |
| | | // purchaseLedgerId: [{ required: true, message: "请选择", trigger: "change" }], |
| | | // customerId: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | // invoiceNumber: [{ required: true, message: "请选择", trigger: "change" }], |
| | | // invoiceAmount: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | // taxRate: [{ required: true, message: "请选择", trigger: "change" }], |
| | | // issUer: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | // issueDate: [{ required: true, message: "请选择", trigger: "change" }], |
| | | // customerName: [{ required: true, message: "请选择", trigger: "change" }], |
| | | // } |
| | | rules: { |
| | | purchaseLedgerId: [{ required: true, message: "请选择", trigger: "change" }], |
| | | } |
| | | }) |
| | | const { searchForm, form, rules } = toRefs(data) |
| | | const currentId = ref('') |
| | | const upload = reactive({ |
| | | // 上传的地址 |
| | | url: import.meta.env.VITE_APP_BASE_API + "/file/upload", |
| | | url1: import.meta.env.VITE_APP_BASE_API + "/purchase/invoice/upload", |
| | | // 设置上传的请求头部 |
| | | headers: { Authorization: "Bearer " + getToken() }, |
| | | }) |
| | | const uploadModal = ref(false) |
| | | const { searchForm } = toRefs(data) |
| | | |
| | | // 查询列表 |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | |
| | | } |
| | | const getList = () => { |
| | | tableLoading.value = true |
| | | invoiceList({...searchForm.value, ...page}).then(res => { |
| | | invoiceList({ ...searchForm.value, ...page }).then(res => { |
| | | tableLoading.value = false |
| | | tableData.value = res.rows; |
| | | total.value = res.total; |
| | | tableData.value = res.rows |
| | | tableData.value.map(item => { |
| | | item.children = [] |
| | | }) |
| | | total.value = res.total |
| | | expandedRowKeys.value = [] |
| | | }).catch(() => { |
| | | tableLoading.value = false |
| | | }) |
| | | } |
| | | const formattedNumber = (row, column, cellValue) => { |
| | | return parseFloat(cellValue).toFixed(2); |
| | | }; |
| | | // 表格选择数据 |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection |
| | | const expandedRowKeys = ref([]) |
| | | // 展开行 |
| | | const expandChange = (row, expandedRows) => { |
| | | if (expandedRows.length > 0) { |
| | | expandedRowKeys.value = [] |
| | | try { |
| | | productRecordList({ id: row.id }).then(res => { |
| | | const index = tableData.value.findIndex(item => item.id === row.id); |
| | | if (index > -1) { |
| | | tableData.value[index].children = res; |
| | | } |
| | | expandedRowKeys.value.push(row.id) |
| | | }) |
| | | } catch (error) { |
| | | console.log(error) |
| | | } |
| | | } else { |
| | | expandedRowKeys.value = [] |
| | | } |
| | | } |
| | | // 主表合计方法 |
| | | const summarizeMainTable = (param) => { |
| | | const { columns, data } = param; |
| | | const sums = []; |
| | | columns.forEach((column, index) => { |
| | | if (index === 0) { |
| | | sums[index] = '合计'; |
| | | return; |
| | | } |
| | | const prop = column.property; |
| | | if (['invoiceAmount'].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, ['invoiceAmount'], { |
| | | ticketsNum: { noDecimal: true }, // 不保留小数 |
| | | futureTickets: { noDecimal: true }, // 不保留小数 |
| | | }); |
| | | }; |
| | | // 打来弹框 |
| | | const openForm = (type, row) => { |
| | | operationType.value = type |
| | | form.value = {} |
| | | productData.value = [] |
| | | fileList.value = [] |
| | | form.value.issUerId = userStore.id |
| | | form.value.issUer = userStore.name |
| | | form.value.issueDate = getCurrentDate(); |
| | | // 查询销售合同 |
| | | ledgerListNoPage({}).then(res => { |
| | | ledgerList.value = res.data; |
| | | }) |
| | | // 查询采购合同号 |
| | | getProduct().then(res => { |
| | | purchaseLedgerList.value = res |
| | | }) |
| | | if (type === 'edit') { |
| | | currentId.value = row.id; |
| | | getInvoiceById({id: row.id}).then(res => { |
| | | form.value = {...res} |
| | | fileList.value = res.commonFiles; |
| | | }) |
| | | } |
| | | dialogFormVisible.value = true |
| | | } |
| | | // 上传前校检 |
| | | function handleBeforeUpload(file) { |
| | | // 校检文件大小 |
| | | if (file.size > 1024 * 1024 * 10) { |
| | | proxy.$modal.msgError('上传文件大小不能超过10MB!') |
| | | return false |
| | | } |
| | | proxy.$modal.loading("正在上传文件,请稍候...") |
| | | return true |
| | | } |
| | | // 上传失败 |
| | | function handleUploadError(err) { |
| | | proxy.$modal.msgError("上传文件失败") |
| | | proxy.$modal.closeLoading() |
| | | } |
| | | // 上传成功回调 |
| | | function handleUploadSuccess(res, file, uploadFiles) { |
| | | proxy.$modal.closeLoading() |
| | | if (res.code === 200) { |
| | | file.tempId = res.data.tempId |
| | | proxy.$modal.msgSuccess("上传成功") |
| | | } else { |
| | | proxy.$modal.msgError(res.msg) |
| | | proxy.$refs.fileUpload.handleRemove(file) |
| | | } |
| | | } |
| | | // 移除文件 |
| | | function handleRemove (file) { |
| | | if (operationType.value === 'edit') { |
| | | let ids = [] |
| | | ids.push(file.id) |
| | | delCommonFile(ids).then(res => { |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | } |
| | | } |
| | | // 提交表单 |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | | let tempFileIds = [] |
| | | if (fileList.value.length > 0) { |
| | | tempFileIds = fileList.value.map(item => item.tempId) |
| | | } |
| | | form.value.tempFileIds = tempFileIds |
| | | form.value.type = 3; |
| | | addOrUpdateInvoice(form.value).then(res => { |
| | | proxy.$modal.msgSuccess("提交成功") |
| | | closeDia() |
| | | getList() |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef") |
| | | dialogFormVisible.value = false |
| | | } |
| | | // 子表合计方法 |
| | | const summarizeChildrenTable = (param) => { |
| | | return proxy.summarizeTable(param, ['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice', 'ticketsNum', 'ticketsAmount', 'futureTickets', 'futureTicketsAmount'], { |
| | | ticketsNum: { noDecimal: true }, // 不保留小数 |
| | | futureTickets: { noDecimal: true }, // 不保留小数 |
| | | }); |
| | | }; |
| | | |
| | | // 导出 |
| | | const handleOut = () => { |
| | | ElMessageBox.confirm( |
| | | '选中的内容将被导出,是否确认导出?', |
| | | '导出', { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | } |
| | | ).then(() => { |
| | | proxy.download("/purchase/invoice/export", {}, '来票台账.xlsx') |
| | | }).catch(() => { |
| | | proxy.$modal.msg("已取消") |
| | | }) |
| | | } |
| | | // 删除 |
| | | const handleDelete = () => { |
| | | let ids = [] |
| | | if (selectedRows.value.length > 0) { |
| | | ids = selectedRows.value.map(item => item.id); |
| | | } else { |
| | | proxy.$modal.msgWarning('请选择数据') |
| | | return |
| | | '选中的内容将被导出,是否确认导出?', |
| | | '导出', { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | } |
| | | ElMessageBox.confirm( |
| | | '选中的内容将被删除,是否确认删除?', |
| | | '导出', { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | } |
| | | ).then(() => { |
| | | delInvoice(ids).then(res => { |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | getList() |
| | | }) |
| | | proxy.download("/purchase/registration/export", {}, '来票登记.xlsx') |
| | | }).catch(() => { |
| | | proxy.$modal.msg("已取消") |
| | | }) |
| | | } |
| | | |
| | | // 选择采购合同号赋值 |
| | | const setInfo = (value) => { |
| | | getInfo({id: value}).then(res => { |
| | | form.value.salesContractNo = res.salesContractNo |
| | | form.value.projectName = res.projectName |
| | | productData.value = res.productData |
| | | form.value.supplierName = res.supplierName |
| | | form.value.businessPersonId = res.businessPersonId |
| | | }) |
| | | } |
| | | |
| | | // 打来附件上传弹窗 |
| | | const handleDownload = (val) => { |
| | | fileList.value = [] |
| | | uploadModal.value = true |
| | | currentId.value = val.id |
| | | } |
| | | |
| | | // 确认文件上传 |
| | | const commiInvoicetFile = () => { |
| | | uploadModal.value = false |
| | | getList(); |
| | | } |
| | | // 获取当前日期并格式化为 YYYY-MM-DD |
| | | function getCurrentDate() { |
| | | const today = new Date(); |
| | | const year = today.getFullYear(); |
| | | const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从0开始 |
| | | const day = String(today.getDate()).padStart(2, '0'); |
| | | return `${year}-${month}-${day}`; |
| | | } |
| | | getList() |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | |
| | | </style> |
| | | <style scoped lang="scss"></style> |