-
+
已选择:{{ select.plan_name }}
已选择:{{ form.plan_display }}
清空选择
-
+
+
+
+
+
-
点击行进行选择
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -1204,6 +1210,7 @@ export default {
{ label: '工程合同', value: 'project' },
{ label: '服务合同', value: 'service' }
],
+ plan: [], // 添加这个来存储选中的预算计划
}
},
methods: {
@@ -1234,10 +1241,7 @@ export default {
row.useMoney = 0
return
}
- let money = Number(row.update_money) == 0 ? Number(row.money) : Number(row.update_money);
- console.log(e, money, row.use_money_total)
- console.log(e <= (money - Number(row.use_money_total)))
- if (e <= (money - Number(row.use_money_total))) {
+ if (e <= (Number(row.money) - Number(row.use_money_total))) {
row.useMoney = e
this.plan.forEach(item => {
if (item.value.plan_id == row.id) {
@@ -1620,32 +1624,68 @@ export default {
this.isShowPlan = true
await this.getBudgets()
},
- async showPlanForSearch(search='search') {
- console.log("sdfsdfsdfsdfsfsfsd:"+search)
- this.planSource = search
- this.isShowPlanForSearch = true
- await this.getBudgets();
- },
- //选择计划 搜索
- selectPlanForSearch(sel) {
- console.log(sel)
-
- if (this.planSource === 'search') {
- if (sel) {
- this.select.plan_id = sel.id;
- this.select.plan_name = sel.name;
- } else {
- this.select.plan_id = "";
- this.select.plan_name = "";
- }
+ showPlanForSearch(source) {
+ this.planSource = source
+ this.isShowPlan = true
+ this.getBudgets()
+ // 初始化 plan 数组
+ if (source === 'modal') {
+ this.plan = this.form.plan || []
} else {
+ this.plan = []
+ }
+ },
+ selectPlanForSearch(sel, row) {
+ if (this.planSource === 'modal') {
if (sel) {
- this.form.plan_display = sel.name;
+ let select = sel.map(item => {
+ let plan = this.plans.find(p => p.id === item.id)
+ return {
+ label: plan.name,
+ value: {
+ plan_id: plan.id,
+ use_money: plan.useMoney || 0,
+ new_money: plan.money
+ }
+ }
+ })
+ this.plan = [...this.form.plan, ...select]
+ // 更新显示文本,显示所有已选择的计划
+ this.form.plan_display = this.plan.map(item => item.label).join(', ')
} else {
- this.form.plan_display = "";
+ this.plan = this.form.plan
+ // 更新显示文本,显示所有已选择的计划
+ this.form.plan_display = this.plan.map(item => item.label).join(', ')
}
+ } else {
+ this.select.plan_name = row.name
+ this.select.plan_id = row.id
}
},
+ planSelectForSearch() {
+ if (this.plan.length === 0) {
+ Message({
+ type: 'warning',
+ message: '选择计划不能为空'
+ })
+ return
+ }
+ for (let item of this.plan) {
+ if (!item.value.use_money) {
+ Message({
+ type: 'warning',
+ message: '金额不能为空'
+ })
+ return
+ }
+ }
+ // 设置表单数据
+ this.form.plan = this.plan
+ // 设置显示文本
+ this.form.plan_display = this.plan.map(item => item.label).join(', ')
+ // 关闭对话框
+ this.isShowPlan = false
+ },
//选择计划
selectPlan(sel, row) {
console.log(sel)
@@ -1660,87 +1700,49 @@ export default {
}
}
})
-
-
- //说明被删除了
- if (sel.filter(plan => {
- return plan.id == row.id
- }).length == 0) {
- this.delPlan({
- value: {
- plan_id: row.id
- }
- })
- }
- let _plan = JSON.parse(JSON.stringify(this.plan));
-
- var _select = [];
- select.map(item => {
- if (_plan.filter(plan => {
- return plan.value.plan_id == item.value.plan_id
- }).length == 0) {
- _select.push(item)
- }
- });
-
- this.plan = [..._plan, ..._select]
+ this.plan = [...this.form.plan, ...select]
} else {
- this.plan = []
+ this.plan = this.form.plan
}
},
//确认计划选择
planSelect() {
- const selectedRows = this.$refs.planTable.getSelection()
- if (!selectedRows || selectedRows.length === 0) {
- this.$Message.warning('请选择至少一个预算计划')
+ if (this.plan.length === 0) {
+ Message({
+ type: 'warning',
+ message: '选择计划不能为空'
+ })
return
}
-
- // 更新选中的预算计划
- this.form.plan = selectedRows.map(item => ({
- id: item.id,
- name: item.name,
- money: item.money,
- useMoney: item.useMoney || 0
- }))
-
- // 更新显示文本
- this.updatePlanDisplay()
-
- // 关闭弹框
+ for (let item of this.plan) {
+ if (!item.value.use_money) {
+ Message({
+ type: 'warning',
+ message: '金额不能为空'
+ })
+ return
+ }
+ }
+ // 设置表单数据
+ this.form.plan = this.plan
+ // 设置显示文本
+ this.form.plan_display = this.plan.map(item => item.label).join(', ')
+ // 关闭对话框
this.isShowPlan = false
},
delPlan(val) {
- this.form.plan.map((item, index) => {
- if (item.value.plan_id === val.value.plan_id) {
- this.form.plan.splice(index, 1)
- }
- })
- this.plan.map((item, index) => {
- if (item.value.plan_id === val.value.plan_id) {
- this.plan.splice(index, 1)
- }
- })
- },
- //确认计划选择搜索
- planSelectForSearch() {
- // if (this.select.plan_id == "") {
- // Message({
- // type: 'warning',
- // message: '选择计划不能为空'
- // })
- // return
- // }
- this.isShowPlanForSearch = false
+ this.form.plan = this.form.plan.filter(item => item.value.plan_id !== val.value.plan_id)
},
//默认选择计划
- toggleSelection(plans, type) {
-
+ toggleSelection(plans) {
if (plans) {
this.plans.filter(plan => {
if (plans.includes(plan.id)) {
- plan.useMoney = this.plan[plans.indexOf(plan.id)].value.use_money
+ let selectedPlan = this.plan.find(item => item.value.plan_id === plan.id)
+ if (selectedPlan) {
+ plan.useMoney = selectedPlan.value.use_money
+ }
return true
}
}).map(row => {
@@ -1888,7 +1890,22 @@ export default {
},
nextStep() {
- if (this.validateCurrentStep()) {
+ // 验证当前步骤的表单
+ if (this.currentStep === 2) {
+ this.$refs.basicInfoForm.validate((valid) => {
+ if (valid) {
+ // 如果显示预算计划字段,需要验证是否选择了预算计划
+ if (this.showFields.budgetPlan && (!this.form.plan || this.form.plan.length === 0)) {
+ Message({
+ type: 'warning',
+ message: '请选择关联预算计划'
+ })
+ return
+ }
+ this.currentStep++
+ }
+ })
+ } else {
this.currentStep++
}
},
@@ -1961,6 +1978,14 @@ export default {
fundChannel: config.fund_channel === 1, // 资金渠道
budgetPlan: config.budget_plan === 1 // 预算计划
})
+
+ // 保存支付表格模板
+ if (config.before_contract_template) {
+ this.form.before_contract_template = config.before_contract_template
+ }
+ if (config.contract_template) {
+ this.form.contract_template = config.contract_template
+ }
},
handleAddContract() {
@@ -1972,26 +1997,16 @@ export default {
},
handleAddContractOk() {
- if (this.currentStep < 2) {
- // 第一步,执行验证并进入下一步
- if (this.validateCurrentStep()) {
- this.currentStep++;
- }
- } else {
- // 最后一步,执行提交
- if (this.validateCurrentStep()) {
- this.submit()
- }
- }
+ // 这个方法可以移除,因为功能已经被 nextStep 和 submit 方法替代
},
handleAddContractCancel() {
- this.resetForm()
- this.isShowAdd = false
+ // 这个方法可以移除,因为功能已经被 cancel 方法替代
},
cancel() {
- this.handleAddContractCancel()
+ this.isShowAdd = false
+ this.resetForm()
},
resetForm() {
@@ -2183,18 +2198,13 @@ export default {
}
},
// 新增方法:移除预算计划
- removePlan(plan) {
- const index = this.form.plan.findIndex(item => item.id === plan.id)
- if (index !== -1) {
- this.form.plan.splice(index, 1)
-
- // 更新显示文本
- if (this.form.plan && this.form.plan.length > 0) {
- this.form.plan_display = `已选择 ${this.form.plan.length} 个预算计划`
- } else {
- this.form.plan_display = ''
- }
- }
+ removePlan(item) {
+ // 从 plan 数组中移除
+ this.plan = this.plan.filter(p => p.value.plan_id !== item.value.plan_id)
+ // 从 form.plan 中移除
+ this.form.plan = this.form.plan.filter(p => p.value.plan_id !== item.value.plan_id)
+ // 更新显示文本
+ this.form.plan_display = this.plan.map(p => p.label).join(', ')
},
},
mounted() {
@@ -2581,4 +2591,15 @@ export default {
height: 400px;
overflow-y: auto;
}
+
+.modal-footer {
+ display: flex;
+ justify-content: flex-end;
+ gap: 12px;
+ padding: 10px 0;
+
+ .action-button {
+ min-width: 100px;
+ }
+}