diff --git a/src/utils/api.js b/src/utils/api.js
index a160eae..17c2fd2 100644
--- a/src/utils/api.js
+++ b/src/utils/api.js
@@ -757,6 +757,7 @@ export const indirectPaymentAPI = {
*/
export const contractAPI = {
list: (params) => request.get('/budget/contracts', params),
+ create: (data) => request.post('/budget/contracts', data),
detail: (id) => request.get(`/budget/contracts/${id}`),
update: (id, data) => request.put(`/budget/contracts/${id}`, data),
remove: (id) => request.delete(`/budget/contracts/${id}`),
diff --git a/src/views/funds/Budget.vue b/src/views/funds/Budget.vue
index 0022065..05780aa 100644
--- a/src/views/funds/Budget.vue
+++ b/src/views/funds/Budget.vue
@@ -1097,7 +1097,9 @@ const loadYearOptions = async () => {
if (res.code === 0) {
yearOptions.value = res.data || []
if (!filterForm.value.year_id && yearOptions.value.length > 0) {
- filterForm.value.year_id = yearOptions.value[0].value
+ const currentYear = new Date().getFullYear()
+ const matchedYear = yearOptions.value.find(item => Number(item.year) === currentYear)
+ filterForm.value.year_id = matchedYear ? matchedYear.value : yearOptions.value[0].value
}
} else {
ElMessage.error(res.msg || '加载年度失败')
diff --git a/src/views/funds/BudgetManagement.vue b/src/views/funds/BudgetManagement.vue
index fad744f..c635592 100644
--- a/src/views/funds/BudgetManagement.vue
+++ b/src/views/funds/BudgetManagement.vue
@@ -468,7 +468,9 @@ const loadYearOptions = async () => {
if (response.code === 0) {
yearOptions.value = response.data || []
if (yearOptions.value.length > 0 && !filterForm.year_id) {
- filterForm.year_id = yearOptions.value[0].value
+ const currentYear = new Date().getFullYear()
+ const matchedYear = yearOptions.value.find(item => Number(item.year) === currentYear)
+ filterForm.year_id = matchedYear ? matchedYear.value : yearOptions.value[0].value
await loadTreeData()
}
} else {
@@ -964,4 +966,3 @@ onMounted(() => {
display: none;
}
-
diff --git a/src/views/payment/ContractManagement.vue b/src/views/payment/ContractManagement.vue
index f51ce80..90f4af7 100644
--- a/src/views/payment/ContractManagement.vue
+++ b/src/views/payment/ContractManagement.vue
@@ -26,6 +26,10 @@
重置
+
+
+ 新增合同
+
历史合同导入
@@ -148,7 +152,7 @@
- {{ row.fund_source_budget_data?.name || row.fund_source || '-' }}
+ {{ row.fund_source_display || row.fund_source_budget_data?.name || '-' }}
@@ -217,7 +221,7 @@
-
+
@@ -512,7 +516,7 @@
- 保存
+ {{ submitButtonText }}
取消
@@ -543,7 +547,7 @@
{{ viewData.fund_source_year?.year ? viewData.fund_source_year.year + '年' : (viewData.fund_source_budget_data?.budget_year?.year ? viewData.fund_source_budget_data.budget_year.year + '年' : '-') }}
- {{ viewData.fund_source_budget_data?.name || viewData.fund_source || '-' }}
+ {{ viewData.fund_source_display || viewData.fund_source_budget_data?.name || '-' }}
@@ -1249,6 +1253,9 @@ const viewData = ref(null)
const formRef = ref(null)
const form = reactive(getEmptyForm())
const payPlanDeleteIds = ref([])
+const isCreateMode = computed(() => !form.id)
+const drawerTitle = computed(() => (isCreateMode.value ? '新增合同' : '编辑合同'))
+const submitButtonText = computed(() => (isCreateMode.value ? '创建' : '保存'))
// 采购类别维护相关
// 类型维护相关状态
@@ -1720,6 +1727,24 @@ function getEmptyForm() {
}
}
+function resetContractForm({ withDefaultPayPlan = false } = {}) {
+ Object.assign(form, getEmptyForm())
+ payPlanDeleteIds.value = []
+ attachmentFileList.value = []
+ inferredAttachmentInfo.value = null
+ fundSourceOptions.value = []
+
+ if (withDefaultPayPlan) {
+ form.pay_plans = [
+ {
+ phase_no: 1,
+ due_date: '',
+ amount_plan: 0
+ }
+ ]
+ }
+}
+
async function fetchList() {
loading.value = true
try {
@@ -2220,13 +2245,18 @@ function openForm(row) {
ElMessage.warning('请选择要编辑的合同')
return
}
- Object.assign(form, getEmptyForm())
- payPlanDeleteIds.value = []
- attachmentFileList.value = []
- inferredAttachmentInfo.value = null
+ resetContractForm()
loadDetail(row.id)
}
+function openCreateForm() {
+ resetContractForm({ withDefaultPayPlan: true })
+ drawerVisible.value = true
+ nextTick(() => {
+ formRef.value?.clearValidate()
+ })
+}
+
async function loadDetail(id) {
loading.value = true
try {
@@ -2324,6 +2354,9 @@ async function loadDetail(id) {
Object.assign(form, data, { pay_plans: data.pay_plans || [] })
drawerVisible.value = true
+ nextTick(() => {
+ formRef.value?.clearValidate()
+ })
} else {
ElMessage.error(response?.msg || '获取详情失败')
}
@@ -2449,13 +2482,11 @@ function handleSubmit() {
saving.value = true
try {
const payload = collectPayload()
- if (!form.id) {
- ElMessage.error('不支持新建合同,请选择已有合同编辑')
- return
- }
- const response = await request.put(`/budget/contracts/${form.id}`, payload)
+ const response = form.id
+ ? await contractAPI.update(form.id, payload)
+ : await contractAPI.create(payload)
if (response && response.code === 0) {
- ElMessage.success('更新成功')
+ ElMessage.success(form.id ? '更新成功' : '创建成功')
drawerVisible.value = false
fetchList()
} else {