This commit is contained in:
=
2025-12-24 11:20:21 +08:00
parent 2137d93232
commit 0fa2451d43
4 changed files with 118 additions and 21 deletions
@@ -225,10 +225,17 @@ layout("/layouts/platform.html"){
budgetOption: []
}
},
watch: {
'formData.activityType': function(newVal, oldVal) {
if (newVal !== oldVal) {
this.$set(this.formData, "deductionBudgetId", null)
this.getBudgetByYear()
}
}
},
methods: {
getBudgetByYear() {
this.budgetOption = []
this.$set(this.formData, "deductionBudgetId", null)
let outlayManageSource = ""
if (this.formData.activityType === "SCHOOL_UNION") {
outlayManageSource = "ACTIVITY_BUDGET_TYPE_ONE"
@@ -237,13 +244,15 @@ layout("/layouts/platform.html"){
} else if (this.formData.activityType === "CLUB") {
outlayManageSource = "ACTIVITY_BUDGET_TYPE_THREE"
}
this.$axios.post('/platform/activityReimbursement/apply/getBudgetByYear', {
return this.$axios.post('/platform/activityReimbursement/apply/getBudgetByYear', {
outlayManageSource: outlayManageSource,
clubId: this.formData.clubId
}).then(res => {
if (res.code === 0) {
this.budgetOption = res.data
}
return res.data
})
},
// 保存
@@ -309,11 +318,15 @@ layout("/layouts/platform.html"){
})
})
},
// 设置申报主体名称
setDeclareUnitName(val) {
const club = this.clubList.find(v => v.id === val)
this.$set(this.formData, "declareUnitName", club ? club.clubName : null)
// 清空当前预算选择,因为社团变更会影响可选的预算
this.$set(this.formData, "deductionBudgetId", null)
// 获取新的预算数据
this.getBudgetByYear()
},
// 申请类型选中
@@ -323,25 +336,43 @@ layout("/layouts/platform.html"){
} else if (val === "BRANCH_UNION") {
this.$set(this.formData, "declareUnitName", this.$store.state.user.union.name)
this.$set(this.formData, "unionId", this.$store.state.user.union.id)
} else if (val === "CLUB") {
// 当活动类型变为社团时,清空已选择的预算
this.$set(this.formData, "deductionBudgetId", null)
}
this.$set(this.formData, "deductionBudgetId", null)
this.getBudgetByYear()
},
findOne(id) {
this.$axios.post("/platform/activityDeclare/mine/findOne", {id})
.then((res) => {
if (res.code === 0) {
this.formData = res.data
if (res.data.clubId) {
this.setDeclareUnitName(res.data.clubId)
}
async findOne(id) {
try {
const res = await this.$axios.post("/platform/activityDeclare/mine/findOne", {id})
if (res.code === 0) {
if (res.data.planStartTime && res.data.planEndTime) {
this.$set(this.formData, "planDate", [res.data.planStartTime, res.data.planEndTime])
}
} else {
this.$message.error(res.msg)
const originalBudgetId = res.data.deductionBudgetId
this.formData = {...res.data}
this.$set(this.formData, "deductionBudgetId", null) // 先清空
if (res.data.clubId) {
this.setDeclareUnitName(res.data.clubId)
}
})
await this.getBudgetByYear()
// 预算数据加载完成后,再设置选中的预算ID
if (originalBudgetId) {
this.$set(this.formData, "deductionBudgetId", originalBudgetId)
}
if (res.data.planStartTime && res.data.planEndTime) {
this.$set(this.formData, "planDate", [res.data.planStartTime, res.data.planEndTime])
}
} else {
this.$message.error(res.msg)
}
} catch (error) {
this.$message.error("获取数据失败:" + error.message)
}
},
async initActivityTypeList() {
this.activityDeclareReimbursementList = await this.$businessTool.getEnumOptions("ActivityDeclareReimbursement")