master
lion 1 month ago
parent 4f3c921e0b
commit 817523248d

@ -58,8 +58,15 @@
@click="handleBatchPay"
>批量支付</el-button>
</div>
<el-table ref="pendingTable" :data="pendingRows" border style="width: 100%">
<el-table-column type="selection" width="50"></el-table-column>
<el-table
ref="pendingTable"
:data="pendingRows"
border
style="width: 100%"
row-key="id"
@selection-change="handlePendingSelectionChange"
>
<el-table-column type="selection" width="50" reserve-selection></el-table-column>
<el-table-column label="申请人" width="120" align="center">
<template #default="{ row }">
{{ row.applicant }}
@ -129,9 +136,16 @@
</template>
</el-table-column>
</el-table>
<div style="margin-top: 10px; display: flex; justify-content: center; color: #666;">
{{ pendingRows.length }} 条记录 · 1 / 1
</div>
<el-pagination
style="margin-top: 10px"
@size-change="handlePendingSizeChange"
@current-change="handlePendingPageChange"
:current-page="pendingPage"
:page-sizes="[10, 20, 30, 40, 50, 100]"
:page-size="pendingPageSize"
layout="total, ->, prev, pager, next, sizes, jumper"
:total="pendingTotal"
/>
</el-tab-pane>
<el-tab-pane label="采购中" name="processing">
@ -185,8 +199,15 @@
@click="handleBatchConfirm"
>批量确认</el-button>
</div>
<el-table ref="processingTable" :data="processingRows" border style="width: 100%">
<el-table-column type="selection" width="50"></el-table-column>
<el-table
ref="processingTable"
:data="processingRows"
border
style="width: 100%"
row-key="id"
@selection-change="handleProcessingSelectionChange"
>
<el-table-column type="selection" width="50" reserve-selection></el-table-column>
<el-table-column label="申请人" width="120" align="center">
<template #default="{ row }">
{{ row.applicant }}
@ -255,7 +276,7 @@
@size-change="handleProcessingSizeChange"
@current-change="handleProcessingPageChange"
:current-page="processingPage"
:page-sizes="[10, 20, 30, 50, 100]"
:page-sizes="[10, 20, 30, 40, 50, 100]"
:page-size="processingPageSize"
layout="total, ->, prev, pager, next, sizes, jumper"
:total="processingTotal"
@ -313,8 +334,15 @@
@click="handleBatchCancel"
>批量取消</el-button>
</div>
<el-table ref="receivedTable" :data="receivedRows" border style="width: 100%">
<el-table-column type="selection" width="50"></el-table-column>
<el-table
ref="receivedTable"
:data="receivedRows"
border
style="width: 100%"
row-key="id"
@selection-change="handleReceivedSelectionChange"
>
<el-table-column type="selection" width="50" reserve-selection></el-table-column>
<el-table-column label="申请人" width="120" align="center">
<template #default="{ row }">
{{ row.applicant }}
@ -383,7 +411,7 @@
@size-change="handleReceivedSizeChange"
@current-change="handleReceivedPageChange"
:current-page="receivedPage"
:page-sizes="[10, 20, 30, 50, 100]"
:page-sizes="[10, 20, 30, 40, 50, 100]"
:page-size="receivedPageSize"
layout="total, ->, prev, pager, next, sizes, jumper"
:total="receivedTotal"
@ -423,6 +451,10 @@ export default {
keywords: '',
},
pendingRows: [],
pendingPage: 1,
pendingPageSize: 40,
pendingTotal: 0,
pendingSelectedIds: [],
isShowPay: false,
processingQuery: {
creator_department_id: '',
@ -431,8 +463,9 @@ export default {
},
processingRows: [],
processingPage: 1,
processingPageSize: 10,
processingPageSize: 40,
processingTotal: 0,
processingSelectedIds: [],
receivedQuery: {
creator_department_id: '',
created_by: '',
@ -440,8 +473,9 @@ export default {
},
receivedRows: [],
receivedPage: 1,
receivedPageSize: 10,
receivedPageSize: 40,
receivedTotal: 0,
receivedSelectedIds: [],
}
},
computed: {
@ -514,7 +548,54 @@ export default {
}
},
async handleBatchPay() {
const selectedRows = this.$refs.pendingTable?.selection || []
//
const currentPageIds = this.pendingRows.map(row => row.id)
const crossPageSelectedIds = this.pendingSelectedIds.filter(id => !currentPageIds.includes(id))
if (crossPageSelectedIds.length > 0) {
//
const params = {
page: 1,
page_size: this.pendingTotal || 9999 //
}
if (this.pendingQuery.creator_department_id) {
params.creator_department_id = this.pendingQuery.creator_department_id
}
if (this.pendingQuery.created_by) {
params.created_by = this.pendingQuery.created_by
}
if (this.pendingQuery.keywords) {
params.keywords = this.pendingQuery.keywords
}
try {
const res = await waitList(params)
const allData = res.data || []
//
const pagesToComplete = new Set()
crossPageSelectedIds.forEach(selectedId => {
const index = allData.findIndex(item => item.id === selectedId)
if (index !== -1) {
const page = Math.floor(index / this.pendingPageSize) + 1
pagesToComplete.add(page)
}
})
if (pagesToComplete.size > 0) {
const pagesArray = Array.from(pagesToComplete).sort((a, b) => a - b)
const pagesText = pagesArray.join('、')
this.$message.warning(`请完善第${pagesText}页的数据`)
return
}
} catch (err) {
console.error('获取数据失败:', err)
this.$message.warning('请完善其他页面的数据')
return
}
}
const selectedRows = this.$refs.pendingTable?.getSelectionRows() || []
if (selectedRows.length === 0) {
this.$message.warning('请先选择需要支付的明细')
return
@ -661,14 +742,13 @@ export default {
// this.$message.success('')
},
handleBatchConfirm() {
const selectedRows = this.$refs.processingTable?.selection || []
if (selectedRows.length === 0) {
if (this.processingSelectedIds.length === 0) {
this.$message.warning('请先选择需要确认收货的数据')
return
}
this.$confirm(`确定要确认收货吗?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
.then(() => {
const ids = selectedRows.map(row => row.id).join(',')
const ids = this.processingSelectedIds.join(',')
this.confirmReceive(ids)
})
.catch(() => {})
@ -687,6 +767,14 @@ export default {
is_receive: 1,
})
this.$message.success('确认收货成功')
// ID
const idArray = id.split(',')
idArray.forEach(idStr => {
const index = this.processingSelectedIds.indexOf(Number(idStr))
if (index > -1) {
this.processingSelectedIds.splice(index, 1)
}
})
//
await this.getProcessingList()
} catch (err) {
@ -695,14 +783,13 @@ export default {
}
},
handleBatchCancel() {
const selectedRows = this.$refs.receivedTable?.selection || []
if (selectedRows.length === 0) {
if (this.receivedSelectedIds.length === 0) {
this.$message.warning('请先选择需要取消收货的数据')
return
}
this.$confirm(`确定要取消收货吗?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
.then(() => {
const ids = selectedRows.map(row => row.id).join(',')
const ids = this.receivedSelectedIds.join(',')
this.cancelReceive(ids)
})
.catch(() => {})
@ -721,6 +808,14 @@ export default {
is_receive: 0,
})
this.$message.success('取消收货成功')
// ID
const idArray = id.split(',')
idArray.forEach(idStr => {
const index = this.receivedSelectedIds.indexOf(Number(idStr))
if (index > -1) {
this.receivedSelectedIds.splice(index, 1)
}
})
//
await this.getReceivedList()
} catch (err) {
@ -728,7 +823,80 @@ export default {
this.$message.error('取消收货失败')
}
},
handlePendingSelectionChange(selection) {
// ID
const currentPageIds = selection.map(row => row.id)
// ID
const currentPageAllIds = this.pendingRows.map(row => row.id)
// ID
currentPageAllIds.forEach(id => {
if (!currentPageIds.includes(id) && this.pendingSelectedIds.includes(id)) {
const index = this.pendingSelectedIds.indexOf(id)
if (index > -1) {
this.pendingSelectedIds.splice(index, 1)
}
}
})
// ID
currentPageIds.forEach(id => {
if (!this.pendingSelectedIds.includes(id)) {
this.pendingSelectedIds.push(id)
}
})
},
handleProcessingSelectionChange(selection) {
// ID
const currentPageIds = selection.map(row => row.id)
// ID
const currentPageAllIds = this.processingRows.map(row => row.id)
// ID
currentPageAllIds.forEach(id => {
if (!currentPageIds.includes(id) && this.processingSelectedIds.includes(id)) {
const index = this.processingSelectedIds.indexOf(id)
if (index > -1) {
this.processingSelectedIds.splice(index, 1)
}
}
})
// ID
currentPageIds.forEach(id => {
if (!this.processingSelectedIds.includes(id)) {
this.processingSelectedIds.push(id)
}
})
},
handleReceivedSelectionChange(selection) {
// ID
const currentPageIds = selection.map(row => row.id)
// ID
const currentPageAllIds = this.receivedRows.map(row => row.id)
// ID
currentPageAllIds.forEach(id => {
if (!currentPageIds.includes(id) && this.receivedSelectedIds.includes(id)) {
const index = this.receivedSelectedIds.indexOf(id)
if (index > -1) {
this.receivedSelectedIds.splice(index, 1)
}
}
})
// ID
currentPageIds.forEach(id => {
if (!this.receivedSelectedIds.includes(id)) {
this.receivedSelectedIds.push(id)
}
})
},
handlePendingQueryChange() {
this.pendingPage = 1
this.getWaitList()
},
handlePendingSizeChange(val) {
this.pendingPageSize = val
this.pendingPage = 1
this.getWaitList()
},
handlePendingPageChange(val) {
this.pendingPage = val
this.getWaitList()
},
handleProcessingQueryChange() {
@ -742,8 +910,8 @@ export default {
async getWaitList() {
try {
const params = {
page: 1,
page_size: 999,
page: this.pendingPage,
page_size: this.pendingPageSize,
}
if (this.pendingQuery.creator_department_id) {
params.creator_department_id = this.pendingQuery.creator_department_id
@ -756,6 +924,7 @@ export default {
}
const res = await waitList(params)
this.waitList = res.data || []
this.pendingTotal = res.total || 0
//
this.pendingRows = (res.data || []).map(item => ({
...item, // 便使
@ -773,6 +942,16 @@ export default {
applyNum: null, //
money: null, //
}))
//
this.$nextTick(() => {
if (this.$refs.pendingTable && this.pendingSelectedIds.length > 0) {
this.pendingRows.forEach(row => {
if (this.pendingSelectedIds.includes(row.id)) {
this.$refs.pendingTable.toggleRowSelection(row, true)
}
})
}
})
} catch (err) {
console.error('获取待采购列表失败:', err)
this.$message.error('获取待采购列表失败')
@ -811,6 +990,16 @@ export default {
unit: item.caigoumingxi?.danwei || '',
purpose: item.caigoumingxi?.yongtu || '',
}))
//
this.$nextTick(() => {
if (this.$refs.processingTable && this.processingSelectedIds.length > 0) {
this.processingRows.forEach(row => {
if (this.processingSelectedIds.includes(row.id)) {
this.$refs.processingTable.toggleRowSelection(row, true)
}
})
}
})
} catch (err) {
console.error('获取采购中列表失败:', err)
this.$message.error('获取采购中列表失败')
@ -849,6 +1038,16 @@ export default {
unit: item.caigoumingxi?.danwei || '',
purpose: item.caigoumingxi?.yongtu || '',
}))
//
this.$nextTick(() => {
if (this.$refs.receivedTable && this.receivedSelectedIds.length > 0) {
this.receivedRows.forEach(row => {
if (this.receivedSelectedIds.includes(row.id)) {
this.$refs.receivedTable.toggleRowSelection(row, true)
}
})
}
})
} catch (err) {
console.error('获取已收货列表失败:', err)
this.$message.error('获取已收货列表失败')
@ -876,12 +1075,15 @@ export default {
watch: {
activeTab(newTab, oldTab) {
//
if (newTab === 'processing') {
if (newTab === 'pending') {
this.pendingPage = 1
this.pendingPageSize = 40
} else if (newTab === 'processing') {
this.processingPage = 1
this.processingPageSize = 10
this.processingPageSize = 40
} else if (newTab === 'received') {
this.receivedPage = 1
this.receivedPageSize = 10
this.receivedPageSize = 40
}
//
@ -891,18 +1093,21 @@ export default {
created_by: '',
keywords: '',
}
this.pendingSelectedIds = []
} else if (newTab === 'processing') {
this.processingQuery = {
creator_department_id: '',
created_by: '',
keywords: '',
}
this.processingSelectedIds = []
} else if (newTab === 'received') {
this.receivedQuery = {
creator_department_id: '',
created_by: '',
keywords: '',
}
this.receivedSelectedIds = []
}
// 使 nextTick

Loading…
Cancel
Save