ZaiZai 1 年之前
父節點
當前提交
78d554e4fb
共有 5 個文件被更改,包括 77 次插入72 次删除
  1. 0 44
      src/api/modules/funding/budget.js
  2. 36 0
      src/api/modules/funding/index.js
  3. 2 2
      src/config/index.json
  4. 1 1
      src/views/funding/budget.vue
  5. 38 25
      src/views/funding/plan.vue

+ 0 - 44
src/api/modules/funding/budget.js

@@ -1,44 +0,0 @@
-import { HcApi } from '../../request/index'
-
-export default {
-    //分页
-    async getPage(form) {
-        return HcApi({
-            url: '/api/blade-meter/changeTokenForm/page',
-            method: 'get',
-            params: form,
-        })
-    },
-    //修改
-    async edit(form) {
-        return HcApi({
-            url: '/api/blade-meter/changeTokenForm/update',
-            method: 'post',
-            data: form,
-        }, false)
-    },
-    //新增
-    async add(form) {
-        return HcApi({
-            url: '/api/blade-meter/changeTokenForm/add',
-            method: 'post',
-            data: form,
-        }, false)
-    },
-    //删除
-    async del(form) {
-        return HcApi({
-            url: '/api/blade-meter/changeTokenForm/delete',
-            method: 'post',
-            params: form,
-        }, false)
-    },
-    //获取详情
-    async detail(form) {
-        return HcApi({
-            url: '/api/blade-meter/changeTokenForm/detail',
-            method: 'get',
-            params: form,
-        })
-    },
-}

+ 36 - 0
src/api/modules/funding/index.js

@@ -0,0 +1,36 @@
+import { HcApi } from '../../request/index'
+
+export default {
+    //资金预算期
+    async periodPage(form) {
+        return HcApi({
+            url: '/api/blade-meter/formPeriod/periodPage',
+            method: 'get',
+            params: form,
+        })
+    },
+    //修改
+    async periodEdit(form) {
+        return HcApi({
+            url: '/api/blade-meter/formPeriod/edit',
+            method: 'post',
+            data: form,
+        })
+    },
+    //获取资金预算计划
+    async getFormPlan(form) {
+        return HcApi({
+            url: '/api/blade-meter/formPeriod/getFormPlan',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    //获取详情
+    async updateFormPlan(form) {
+        return HcApi({
+            url: '/api/blade-meter/formPeriod/updateFormPlan',
+            method: 'post',
+            data: form,
+        })
+    },
+}

+ 2 - 2
src/config/index.json

@@ -1,8 +1,8 @@
 {
     "version": "20230607160059",
     "target1": "http://127.0.0.1:8090",
-    "target2": "http://192.168.0.125:8095",
-    "target": "http://39.108.216.210:8090",
+    "target": "http://192.168.0.125:8090",
+    "target3": "http://39.108.216.210:8090",
     "smsPhone": "",
     "vite": {
         "port": 5180,

+ 1 - 1
src/views/funding/budget.vue

@@ -74,7 +74,7 @@
 import { onActivated, ref } from 'vue'
 import { useAppStore } from '~src/store'
 import { getArrValue } from 'js-fast-way'
-import mainApi from '~api/funding/budget'
+import mainApi from '~api/funding/index'
 
 //获取全局变量
 const store = useAppStore()

+ 38 - 25
src/views/funding/plan.vue

@@ -5,21 +5,17 @@
                 <hc-icon name="add" />
                 <span>新增</span>
             </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" />
                 <span>保存</span>
             </el-button>
         </template>
         <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-select>
-                <span v-else>{{ row.key2 }}</span>
+                <span v-else>{{ row.periodYear }}</span>
             </template>
             <template #action="{ row, index }">
                 <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 { HcDelMsg } from 'hc-vue3-ui'
 import { getArrValue, isNullES } from 'js-fast-way'
+import mainApi from '~api/funding/index'
 import dayjs from 'dayjs'
-import mainApi from '~api/funding/budget'
 
 //获取全局变量
 const store = useAppStore()
@@ -68,56 +64,73 @@ const setYearDatas = () => {
 }
 
 //表格数据
-const tableData = ref([
-    { id: '1', key1:'2024年资金预算', key2: '2024' },
-])
+const tableData = ref([])
 const tableColumn = ref([
-    { key: 'key1', name: '期名称' },
-    { key: 'key2', name: '年份' },
+    { key: 'periodName', name: '期名称' },
+    { key: 'periodYear', name: '年份' },
     { key: 'action', name: '操作', width: 80, align: 'center' },
 ])
 
 //获取表格数据
 const tableLoading = ref(false)
 const getTableData = async () => {
-    /*tableLoading.value = true
-    const { data } = await mainApi.getPage({
-        ...searchForm.value,
+    tableLoading.value = true
+    const { data } = await mainApi.periodPage({
         projectId: projectId.value,
+        contractId: contractId.value,
     })
     tableLoading.value = false
-    tableData.value = getArrValue(data?.records)
-    searchForm.value.total = data['total'] || 0*/
+    tableData.value = getArrValue(data)
 }
 
 //新增数据
 const isAddModal = ref(false)
 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
     if (data.length <= 0) {
         year = toYear //如果没有上一条数据,就取今年
+        periodName = toYear + '年资金预算'
     } else {
         //如果存在上一条数据
-        const newYear = Number(data[data.length - 1].key2) + 1
+        const newYear = Number(data[data.length - 1].periodYear) + 1
         //判断,上一条数据的年份 + 1,是否超过了可选的年份
         if (years[years.length - 1] < newYear) {
             //如果超过了,就取可选年份的最后一年
             year = years[years.length - 1]
+            periodName = years[years.length - 1] + '年资金预算'
         } else {
             //如果没有超过,就取上一条数据的年份 + 1
             year = newYear
+            periodName = newYear + '年资金预算'
         }
     }
     //插入数据
-    tableData.value.push({ key2: year })
+    tableData.value.push({ periodName, periodYear: year })
     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()
+    }
 }
 
 //删除数据