|
@@ -5,21 +5,17 @@
|
|
<hc-icon name="add" />
|
|
<hc-icon name="add" />
|
|
<span>新增</span>
|
|
<span>新增</span>
|
|
</el-button>
|
|
</el-button>
|
|
- <el-button :disabled="!isAddModal" hc-btn type="warning" @click="saveRowClick">
|
|
|
|
|
|
+ <el-button :disabled="!isAddModal" hc-btn type="warning" :loading="saveLoading" @click="saveRowClick">
|
|
<hc-icon name="add" />
|
|
<hc-icon name="add" />
|
|
<span>保存</span>
|
|
<span>保存</span>
|
|
</el-button>
|
|
</el-button>
|
|
</template>
|
|
</template>
|
|
<hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading">
|
|
<hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading">
|
|
- <template #key1="{ row }">
|
|
|
|
- <hc-table-input v-if="isNullES(row.id)" v-model="row.key1" />
|
|
|
|
- <span v-else>{{ row.key1 }}</span>
|
|
|
|
- </template>
|
|
|
|
- <template #key2="{ row }">
|
|
|
|
- <el-select v-if="isNullES(row.id)" v-model="row.key2" placeholder="选择年份" filterable block>
|
|
|
|
|
|
+ <template #periodYear="{ row }">
|
|
|
|
+ <el-select v-if="isNullES(row.id)" v-model="row.periodYear" placeholder="选择年份" filterable block @change="yearDataChange($event, row)">
|
|
<el-option v-for="item in yearDatas" :key="item" :label="item" :value="item" />
|
|
<el-option v-for="item in yearDatas" :key="item" :label="item" :value="item" />
|
|
</el-select>
|
|
</el-select>
|
|
- <span v-else>{{ row.key2 }}</span>
|
|
|
|
|
|
+ <span v-else>{{ row.periodYear }}</span>
|
|
</template>
|
|
</template>
|
|
<template #action="{ row, index }">
|
|
<template #action="{ row, index }">
|
|
<el-link type="danger" @click="delRowClick(row, index)">删除</el-link>
|
|
<el-link type="danger" @click="delRowClick(row, index)">删除</el-link>
|
|
@@ -33,8 +29,8 @@ import { onActivated, ref } from 'vue'
|
|
import { useAppStore } from '~src/store'
|
|
import { useAppStore } from '~src/store'
|
|
import { HcDelMsg } from 'hc-vue3-ui'
|
|
import { HcDelMsg } from 'hc-vue3-ui'
|
|
import { getArrValue, isNullES } from 'js-fast-way'
|
|
import { getArrValue, isNullES } from 'js-fast-way'
|
|
|
|
+import mainApi from '~api/funding/index'
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
-import mainApi from '~api/funding/budget'
|
|
|
|
|
|
|
|
//获取全局变量
|
|
//获取全局变量
|
|
const store = useAppStore()
|
|
const store = useAppStore()
|
|
@@ -68,56 +64,73 @@ const setYearDatas = () => {
|
|
}
|
|
}
|
|
|
|
|
|
//表格数据
|
|
//表格数据
|
|
-const tableData = ref([
|
|
|
|
- { id: '1', key1:'2024年资金预算', key2: '2024' },
|
|
|
|
-])
|
|
|
|
|
|
+const tableData = ref([])
|
|
const tableColumn = ref([
|
|
const tableColumn = ref([
|
|
- { key: 'key1', name: '期名称' },
|
|
|
|
- { key: 'key2', name: '年份' },
|
|
|
|
|
|
+ { key: 'periodName', name: '期名称' },
|
|
|
|
+ { key: 'periodYear', name: '年份' },
|
|
{ key: 'action', name: '操作', width: 80, align: 'center' },
|
|
{ key: 'action', name: '操作', width: 80, align: 'center' },
|
|
])
|
|
])
|
|
|
|
|
|
//获取表格数据
|
|
//获取表格数据
|
|
const tableLoading = ref(false)
|
|
const tableLoading = ref(false)
|
|
const getTableData = async () => {
|
|
const getTableData = async () => {
|
|
- /*tableLoading.value = true
|
|
|
|
- const { data } = await mainApi.getPage({
|
|
|
|
- ...searchForm.value,
|
|
|
|
|
|
+ tableLoading.value = true
|
|
|
|
+ const { data } = await mainApi.periodPage({
|
|
projectId: projectId.value,
|
|
projectId: projectId.value,
|
|
|
|
+ contractId: contractId.value,
|
|
})
|
|
})
|
|
tableLoading.value = false
|
|
tableLoading.value = false
|
|
- tableData.value = getArrValue(data?.records)
|
|
|
|
- searchForm.value.total = data['total'] || 0*/
|
|
|
|
|
|
+ tableData.value = getArrValue(data)
|
|
}
|
|
}
|
|
|
|
|
|
//新增数据
|
|
//新增数据
|
|
const isAddModal = ref(false)
|
|
const isAddModal = ref(false)
|
|
const addRowClick = () => {
|
|
const addRowClick = () => {
|
|
- let year, toYear = Number(new dayjs().format('YYYY'))
|
|
|
|
|
|
+ let periodName, year, toYear = Number(new dayjs().format('YYYY'))
|
|
const data = tableData.value, years = yearDatas.value
|
|
const data = tableData.value, years = yearDatas.value
|
|
if (data.length <= 0) {
|
|
if (data.length <= 0) {
|
|
year = toYear //如果没有上一条数据,就取今年
|
|
year = toYear //如果没有上一条数据,就取今年
|
|
|
|
+ periodName = toYear + '年资金预算'
|
|
} else {
|
|
} else {
|
|
//如果存在上一条数据
|
|
//如果存在上一条数据
|
|
- const newYear = Number(data[data.length - 1].key2) + 1
|
|
|
|
|
|
+ const newYear = Number(data[data.length - 1].periodYear) + 1
|
|
//判断,上一条数据的年份 + 1,是否超过了可选的年份
|
|
//判断,上一条数据的年份 + 1,是否超过了可选的年份
|
|
if (years[years.length - 1] < newYear) {
|
|
if (years[years.length - 1] < newYear) {
|
|
//如果超过了,就取可选年份的最后一年
|
|
//如果超过了,就取可选年份的最后一年
|
|
year = years[years.length - 1]
|
|
year = years[years.length - 1]
|
|
|
|
+ periodName = years[years.length - 1] + '年资金预算'
|
|
} else {
|
|
} else {
|
|
//如果没有超过,就取上一条数据的年份 + 1
|
|
//如果没有超过,就取上一条数据的年份 + 1
|
|
year = newYear
|
|
year = newYear
|
|
|
|
+ periodName = newYear + '年资金预算'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//插入数据
|
|
//插入数据
|
|
- tableData.value.push({ key2: year })
|
|
|
|
|
|
+ tableData.value.push({ periodName, periodYear: year })
|
|
isAddModal.value = true
|
|
isAddModal.value = true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//年份被选择
|
|
|
|
+const yearDataChange = (val, row) => {
|
|
|
|
+ row.periodName = val + '年资金预算'
|
|
|
|
+}
|
|
|
|
+
|
|
//批量保存
|
|
//批量保存
|
|
-const saveRowClick = () => {
|
|
|
|
- isAddModal.value = false
|
|
|
|
- getTableData()
|
|
|
|
|
|
+const saveLoading = ref(false)
|
|
|
|
+const saveRowClick = async () => {
|
|
|
|
+ const table = tableData.value
|
|
|
|
+ saveLoading.value = true
|
|
|
|
+ const { error, code } = await mainApi.periodEdit({
|
|
|
|
+ projectId: projectId.value,
|
|
|
|
+ contractId: contractId.value,
|
|
|
|
+ list: table,
|
|
|
|
+ })
|
|
|
|
+ saveLoading.value = false
|
|
|
|
+ if (!error && code === 200) {
|
|
|
|
+ window?.$message?.success('保存成功')
|
|
|
|
+ isAddModal.value = false
|
|
|
|
+ getTableData().then()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//删除数据
|
|
//删除数据
|