diff --git a/src/views/contract/contractList.vue b/src/views/contract/contractList.vue index b061468..0f0675f 100644 --- a/src/views/contract/contractList.vue +++ b/src/views/contract/contractList.vue @@ -1721,11 +1721,31 @@ export default { }, //获取资金渠道 async getMoneyWay() { - this.moneyWay = (await getparameter({ - number: 'money_way' - })).detail - - this.form.moneyWay = this.moneyWay + try { + const response = await getparameter({ + number: 'money_way' + }); + + if (response && response.detail) { + // 统一数据格式,确保每个项都有唯一的 id + this.moneyWay = response.detail.map((item, index) => ({ + id: item.id || `money_way_${index}`, + name: item.name || item.value || `资金来源${index + 1}`, + value: item.value || item.id || `money_way_${index}` + })); + + // 初始化表单的 moneyWay + this.form.moneyWay = []; + } else { + this.moneyWay = []; + this.form.moneyWay = []; + } + } catch (error) { + console.error('获取资金来源失败:', error); + this.$message.error('获取资金来源失败'); + this.moneyWay = []; + this.form.moneyWay = []; + } }, //获取购买方式 async getPurchaseWay() { @@ -2516,12 +2536,28 @@ export default { } }, - handleAddContract() { - this.isShowAdd = true; - // Call API to get category options - this.getCategoryOptions(); - // Reset form - this.resetForm(); + async handleAddContract() { + // 先设置 loading 状态 + this.loading = true; + + try { + // 显示弹窗 + this.isShowAdd = true; + + // 等待获取分类配置 + await this.getCategoryOptions(); + + // 先重置表单 + this.resetForm(); + + } catch (error) { + console.error('加载数据失败:', error); + this.$message.error('加载数据失败'); + } finally { + // 无论成功失败都关闭 loading + this.loading = false; + } + }, handleAddContractOk() { @@ -2646,7 +2682,7 @@ export default { // 获取分类名称的方法 getCategoryName(id) { const category = this.categoryOptions.find(item => item.id === id) - return category ? category.name : '' + return category ? category.value : '' }, getAffairTypeName(id) { @@ -2948,36 +2984,6 @@ export default { } }, - // 新增按钮点击事件 - handleAdd() { - this.isEditMode = false; - this.currentContractId = null; - this.isShowAdd = true; - this.currentStep = 1; - this.form = { - ...this.form, - category: '', - affairType: '', - contractType: '', - purchaseForm: '', - purchaseMethod: '', - type: '', - isBudget: false, - is_simple: 0, - has_charge: 0, - is_substitute: 0, - supply: '', - price: '', - name: '', - moneyWay: [], - plan: [], - contract_carry_department: [], - before_contract_template: null, - contract_template: null - }; - this.getCategoryOptions(); - }, - // 新增获取合同详情方法 async getContractDetail(id) { try {