master
lion 1 month ago
parent 4f3c921e0b
commit 817523248d

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

Loading…
Cancel
Save