¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="search_form"> |
| | | <div> |
| | | <span class="search_title">éè´ååå·ï¼</span> |
| | | <el-input |
| | | v-model="searchForm.searchText" |
| | | style="width: 240px" |
| | | placeholder="请è¾å
¥" |
| | | @change="handleQuery" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | /> |
| | | <span class="search_title" style="margin-left: 10px">æ¥ç¥¨æ¥æï¼</span> |
| | | <el-date-picker |
| | | style="width: 240px" |
| | | v-model="form.issueDate" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="date" |
| | | placeholder="è¯·éæ©" |
| | | clearable |
| | | /> |
| | | <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="purchaseContractNo" 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> |
| | | <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" :disabled="operationType === 'edit'"> |
| | | <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="请è¾å
¥" 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="请è¾å
¥" 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="请è¾å
¥" 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> |
| | | <template #tip> |
| | | <!-- æä»¶æ ¼å¼æ¯æ docï¼docxï¼xlsï¼xlsxï¼pptï¼pptxï¼pdfï¼txtï¼xmlï¼jpgï¼jpegï¼pngï¼gifï¼bmpï¼rarï¼zipï¼7z--> |
| | | <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> |
| | | |
| | | <script setup> |
| | | import pagination from '@/components/PIMTable/Pagination.vue' |
| | | import { ref } from 'vue' |
| | | import {Search} from "@element-plus/icons-vue"; |
| | | import {ElMessageBox } from "element-plus"; |
| | | 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({ |
| | | searchForm: { |
| | | searchText: '', |
| | | issueDate:'' |
| | | }, |
| | | form: { |
| | | purchaseLedgerId: '', |
| | | salesLedgerId: '', |
| | | customerId: '', |
| | | invoiceNumber: '', |
| | | invoiceAmount: '', |
| | | taxRate: '', |
| | | issUerId: '', |
| | | issUer: '', |
| | | issueDate: '', |
| | | customerName:'', |
| | | fileList:[] |
| | | }, |
| | | 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" }], |
| | | } |
| | | }) |
| | | 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 handleQuery = () => { |
| | | page.current = 1 |
| | | getList() |
| | | } |
| | | const paginationChange = ({ current, limit }) => { |
| | | page.current = current; |
| | | page.size = limit; |
| | | getList() |
| | | } |
| | | const getList = () => { |
| | | tableLoading.value = true |
| | | invoiceList({...searchForm.value, ...page}).then(res => { |
| | | tableLoading.value = false |
| | | tableData.value = res.rows; |
| | | total.value = res.total; |
| | | }) |
| | | } |
| | | // è¡¨æ ¼éæ©æ°æ® |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection |
| | | } |
| | | // 主表åè®¡æ¹æ³ |
| | | 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; |
| | | }; |
| | | // ææ¥å¼¹æ¡ |
| | | 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) { |
| | | console.log('handleRemove', file.id) |
| | | 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 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 |
| | | } |
| | | ElMessageBox.confirm( |
| | | 'éä¸çå
容å°è¢«å é¤ï¼æ¯å¦ç¡®è®¤å é¤ï¼', |
| | | '导åº', { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning', |
| | | } |
| | | ).then(() => { |
| | | delInvoice(ids).then(res => { |
| | | proxy.$modal.msgSuccess("å 餿å") |
| | | getList() |
| | | }) |
| | | }).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> |