|
|
|
|
@ -33,6 +33,7 @@
|
|
|
|
|
<Button type="primary" @click="load">查询</Button>
|
|
|
|
|
<Button type="primary" @click="edit()">新增预算包</Button>
|
|
|
|
|
<Button type="error" @click="batchDelete" :disabled="selectedRows.length === 0">批量删除</Button>
|
|
|
|
|
<Button type="primary" @click="openBatchSortDialog">批量设置排序</Button>
|
|
|
|
|
<Button type="warning" @click="recalculateYearAmounts">重算年度大包金额</Button>
|
|
|
|
|
<Button type="success" @click="toggleTreeView">{{ showTree ? '列表视图' : '树形视图' }}</Button>
|
|
|
|
|
<Button type="warning" @click="showSummaryView">汇总查看</Button>
|
|
|
|
|
@ -850,6 +851,34 @@
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- 批量排序对话框:保留单条编辑排序,同时支持集中录入后一次提交 -->
|
|
|
|
|
<el-dialog title="批量设置排序" :visible.sync="batchSortDialogVisible" width="760px" :close-on-click-modal="false">
|
|
|
|
|
<div style="margin-bottom: 14px; color: #909399;">
|
|
|
|
|
按同级排序值从小到大展示;可集中修改后一次性保存。排序值相同则按创建顺序排列。
|
|
|
|
|
</div>
|
|
|
|
|
<el-table :data="batchSortRows" max-height="520" border>
|
|
|
|
|
<el-table-column label="预算包" min-width="320">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<span :style="{ paddingLeft: ((scope.row.level || 1) - 1) * 20 + 'px' }">
|
|
|
|
|
{{ scope.row.name }}
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="层级" width="100" align="center">
|
|
|
|
|
<template slot-scope="scope">{{ getLevelText(scope.row.level) }}</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="排序值" width="180" align="center">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-input-number v-model="scope.row.sort_order" :min="1" :step="1" controls-position="right" style="width: 140px" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button @click="batchSortDialogVisible = false">取 消</el-button>
|
|
|
|
|
<el-button type="primary" :loading="batchSortSubmitting" @click="submitBatchSort">一次性保存</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- 大包详情弹窗 -->
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="大包详情"
|
|
|
|
|
@ -1109,6 +1138,7 @@ import {
|
|
|
|
|
updateBudgetCollectionPackage,
|
|
|
|
|
deleteBudgetCollectionPackage,
|
|
|
|
|
batchDeleteBudgetCollectionPackage,
|
|
|
|
|
batchUpdateBudgetCollectionPackageSortOrder,
|
|
|
|
|
recalculateBudgetCollectionPackageAmount,
|
|
|
|
|
recalculateBudgetCollectionYearPackageAmounts,
|
|
|
|
|
getBudgetCollectionPackageOptions,
|
|
|
|
|
@ -1130,6 +1160,9 @@ export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
dialogFormVisible: false,
|
|
|
|
|
batchSortDialogVisible: false,
|
|
|
|
|
batchSortSubmitting: false,
|
|
|
|
|
batchSortRows: [],
|
|
|
|
|
bigPackageDetailVisible: false,
|
|
|
|
|
mediumPackageDetailVisible: false,
|
|
|
|
|
economicDetailVisible: false,
|
|
|
|
|
@ -1661,6 +1694,72 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async openBatchSortDialog() {
|
|
|
|
|
if (!this.searchFields.year_id) {
|
|
|
|
|
this.$Message.warning('请先选择预算年度')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await getBudgetCollectionPackageList({
|
|
|
|
|
year_id: this.searchFields.year_id,
|
|
|
|
|
show_tree: true
|
|
|
|
|
})
|
|
|
|
|
const tree = Array.isArray(response) ? response : (response && response.data ? response.data : [])
|
|
|
|
|
const rows = []
|
|
|
|
|
const flatten = (items, depth = 1) => {
|
|
|
|
|
const safeItems = items || []
|
|
|
|
|
safeItems.forEach(item => {
|
|
|
|
|
rows.push({
|
|
|
|
|
id: item.id,
|
|
|
|
|
name: item.name,
|
|
|
|
|
level: item.level || depth,
|
|
|
|
|
sort_order: Number(item.sort_order) > 0 ? Number(item.sort_order) : 1
|
|
|
|
|
})
|
|
|
|
|
flatten(item.children, depth + 1)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
flatten(tree)
|
|
|
|
|
|
|
|
|
|
if (!rows.length) {
|
|
|
|
|
this.$Message.warning('当前年度暂无可排序的预算包')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.batchSortRows = rows
|
|
|
|
|
this.batchSortDialogVisible = true
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('加载批量排序数据失败:', error)
|
|
|
|
|
this.$Message.error('加载批量排序数据失败')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async submitBatchSort() {
|
|
|
|
|
const invalidRow = this.batchSortRows.find(item => !Number.isInteger(Number(item.sort_order)) || Number(item.sort_order) < 1)
|
|
|
|
|
if (invalidRow) {
|
|
|
|
|
this.$Message.warning(`“${invalidRow.name}”的排序值必须是大于 0 的整数`)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.batchSortSubmitting = true
|
|
|
|
|
try {
|
|
|
|
|
const items = this.batchSortRows.map(item => ({
|
|
|
|
|
id: item.id,
|
|
|
|
|
sort_order: Number(item.sort_order)
|
|
|
|
|
}))
|
|
|
|
|
const response = await batchUpdateBudgetCollectionPackageSortOrder(this.searchFields.year_id, items)
|
|
|
|
|
const result = response && response.data ? response.data : response
|
|
|
|
|
this.$Message.success(`排序已保存,共更新 ${(result && result.updated_count) || 0} 条记录`)
|
|
|
|
|
this.batchSortDialogVisible = false
|
|
|
|
|
this.load()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('批量保存排序失败:', error)
|
|
|
|
|
this.$Message.error('批量保存排序失败')
|
|
|
|
|
} finally {
|
|
|
|
|
this.batchSortSubmitting = false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
batchDelete() {
|
|
|
|
|
if (this.selectedRows.length === 0) {
|
|
|
|
|
this.$Message.warning('请选择要删除的记录')
|
|
|
|
|
|