This commit is contained in:
2026-04-25 14:51:03 +08:00
parent 9b92c29197
commit e8e39c128c
4 changed files with 184 additions and 88 deletions
@@ -186,6 +186,36 @@ layout("/layouts/platform.html"){
}
},
methods: {
/**
* 确认提示文案优先展示页面当前筛选季度。
* 未选择季度时再回退到系统当前自然季度,避免提示文案与用户当前查看条件不一致。
*/
getPromptQuarter() {
return this.pageForm.quarterly || this.$moment().quarter()
},
/**
* 季度记录生成、重置记录都要按页面当前筛选的年度和季度执行。
* 这里统一封装请求参数,避免前后端再次出现“提示季度”和“实际执行季度”不一致的问题。
*/
getCurrentQuarterParams() {
return {
quarterly: this.pageForm.quarterly || this.$moment().quarter(),
year: this.pageForm.year
}
},
/**
* 生成、重置、一键分配都只允许操作当前自然季度。
* 这里统一做前端入口校验,避免同类判断分散在多个按钮方法里难维护。
*/
validateCurrentQuarterAction(actionName) {
const currentQuarter = this.$moment().quarter()
const selectedQuarter = Number(this.getCurrentQuarterParams().quarterly)
if (selectedQuarter !== currentQuarter) {
this.$message.warning('当前仅允许操作第' + currentQuarter + '季度' + actionName + ',请切换后再操作')
return false
}
return true
},
doEdit(row) {
this.$confirm('确定要给【' + row.unionName + '】分配预算吗?', '提示', {
confirmButtonText: '确定',
@@ -207,13 +237,21 @@ layout("/layouts/platform.html"){
})
},
deleteAllocateRecord() {
this.$confirm('确定要重置【第' + this.$moment().quarter() + '季度】的预算记录吗?', '提示', {
if (!this.validateCurrentQuarterAction('记录重置')) {
return
}
// 重置动作以当前列表是否已有记录为前置条件,避免用户在空列表场景下误操作。
if (this.tableData.length === 0) {
this.$message.warning('当前列表无可重置记录')
return
}
this.$confirm('确定要重置【第' + this.getPromptQuarter() + '季度】的预算记录吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.formLoading = true
this.$axios.post("/platform/outlay/outlayManage/unionAllocate/deleteAllocateRecord").then((resp) => {
this.$axios.post("/platform/outlay/outlayManage/unionAllocate/deleteAllocateRecord", this.getCurrentQuarterParams()).then((resp) => {
if (resp.code === 0) {
this.$message.success(resp.msg)
this.doSearch()
@@ -224,13 +262,16 @@ layout("/layouts/platform.html"){
})
},
doAllocateRecord() {
this.$confirm('确定要生成【第' + this.$moment().quarter() + '季度】的预算记录吗?', '提示', {
if (!this.validateCurrentQuarterAction('记录生成')) {
return
}
this.$confirm('确定要生成【第' + this.getPromptQuarter() + '季度】的预算记录吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.formLoading = true
this.$axios.post("/platform/outlay/outlayManage/unionAllocate/doAllocateRecord").then((resp) => {
this.$axios.post("/platform/outlay/outlayManage/unionAllocate/doAllocateRecord", this.getCurrentQuarterParams()).then((resp) => {
if (resp.code === 0) {
this.$message.success(resp.msg)
this.doSearch()
@@ -241,18 +282,21 @@ layout("/layouts/platform.html"){
})
},
showBatchAllocateDialog() {
if (!this.validateCurrentQuarterAction('一键分配')) {
return
}
if (this.tableData.length === 0) {
this.$message.warning('当前没有可分配的工会记录,请先生成季度记录')
return
}
const quarter = this.$moment().quarter()
const currentParams = this.getCurrentQuarterParams()
const openDialog = () => {
this.resetBatchAllocateForm()
this.batchAllocateDialogVisible = true
}
this.$axios.post("/platform/outlay/outlayManage/unionAllocate/hasAllocated", {
quarterly: quarter,
year: this.pageForm.year
quarterly: currentParams.quarterly,
year: currentParams.year
}).then((resp) => {
if (resp.code !== 0) {
return
@@ -305,7 +349,7 @@ layout("/layouts/platform.html"){
this.$set(this.batchAllocateForm, "importPreviewList", [])
},
doBatchAllocate() {
const quarter = this.$moment().quarter()
const currentParams = this.getCurrentQuarterParams()
if (this.batchAllocateForm.allocateMode === "uniform") {
if (!this.batchAllocateForm.allocateMoney || this.batchAllocateForm.allocateMoney <= 0) {
this.$message.warning('请输入有效的分配额度')
@@ -314,8 +358,8 @@ layout("/layouts/platform.html"){
this.formLoading = true
this.$axios.post("/platform/outlay/outlayManage/unionAllocate/doBatchAllocate", {
allocateMoney: this.batchAllocateForm.allocateMoney,
quarterly: quarter,
year: this.pageForm.year
quarterly: currentParams.quarterly,
year: currentParams.year
}).then((resp) => {
if (resp.code === 0) {
this.$message.success(resp.msg)
@@ -339,8 +383,8 @@ layout("/layouts/platform.html"){
this.formLoading = true
this.$axios.post("/platform/outlay/outlayManage/unionAllocate/doImportAllocate", {
data: JSON.stringify(this.batchAllocateForm.importPreviewList),
quarterly: quarter,
year: this.pageForm.year
quarterly: currentParams.quarterly,
year: currentParams.year
}).then((resp) => {
if (resp.code === 0) {
this.$message.success(resp.msg)