ZaiZai пре 1 година
родитељ
комит
a6dc90bae3
2 измењених фајлова са 44 додато и 9 уклоњено
  1. 20 3
      src/views/project/modules/gist-list.vue
  2. 24 6
      src/views/project/modules/project-list.vue

+ 20 - 3
src/views/project/modules/gist-list.vue

@@ -143,7 +143,7 @@ const props = defineProps({
 
 //事件
 const emit = defineEmits(['tap', 'check', 'change'])
-const currentYear = new dayjs().year()
+const currentYear = new dayjs().format('YYYY')
 
 //监听权限
 const isAdminAuth = ref(props.isAdmin)
@@ -246,8 +246,23 @@ const getDetailData = async (id) => {
     yearData.value = res
     //设置默认数据
     if (table.length > 0) {
-        yearKey.value = table[0].year
-        yearIndex.value = 0
+        let isIndex = false
+        for (let i = 0; i < table.length; i++) {
+            const planYear = table[i].year
+            if (planYear === currentYear) {
+                yearIndex.value = i
+                yearKey.value = table[i].year
+                isIndex = true
+            }
+        }
+        //默认值
+        if (!isIndex) {
+            yearIndex.value = 0
+            yearKey.value = table[0].year
+        }
+    } else {
+        yearIndex.value = -1
+        yearKey.value = null
     }
 }
 
@@ -256,6 +271,8 @@ const drawerCancel = () => {
     isDrawer.value = false
     isDrawerType.value = ''
     yearData.value = {}
+    yearIndex.value = -1
+    yearKey.value = null
 }
 
 //删除

+ 24 - 6
src/views/project/modules/project-list.vue

@@ -254,6 +254,7 @@ import { onMounted, ref, watch } from 'vue'
 import mainApi from '~api/project/project'
 import { getArrValue, getObjValue } from 'js-fast-way'
 import BigNumber from 'bignumber.js'
+import dayjs from 'dayjs'
 import HcStatusCharts from './components/charts.vue'
 
 const props = defineProps({
@@ -282,6 +283,7 @@ watch(() => props.isAdmin, (admin) => {
 
 //渲染完成
 const isAfterRender = ref(false)
+const currentYear = new dayjs().format('YYYY')
 onMounted(() => {
     //表格太复杂,渲染较慢,等页面先加载完成,再渲染表格,不然会卡住一下不动。
     //因为表头涉及到年份,如果年份很多,那么会更卡。
@@ -361,14 +363,28 @@ const getDetailData = async (id) => {
     res.list = list
     rowDetail.value = res
     yearData.value = res
-    console.log(yearData.value, 'yearData.valu')
-   //设置默认数据
-   if (list.length > 0) {
-        yearKey.value = list[0].planYear
-        yearIndex.value = 0
+    //设置默认数据
+    if (list.length > 0) {
+        let isIndex = false
+        for (let i = 0; i < list.length; i++) {
+            const planYear = list[i].planYear.toString()
+            if (planYear === currentYear) {
+                yearIndex.value = i
+                yearKey.value = list[i].planYear
+                isIndex = true
+            }
+        }
+        //默认值
+        if (!isIndex) {
+            yearIndex.value = 0
+            yearKey.value = list[0].planYear
+        }
+    } else {
+        yearIndex.value = -1
+        yearKey.value = null
     }
-
 }
+
 //删除
 const delTableItem = async ({ item }, resolve) => {
     const { error, code, msg } = await mainApi.del(item.id)
@@ -386,6 +402,8 @@ const drawerCancel = () => {
     isDrawer.value = false
     isDrawerType.value = ''
     yearData.value = {}
+    yearIndex.value = -1
+    yearKey.value = null
 }