Browse Source

修改项目列表

ZaiZai 1 year ago
parent
commit
211be40754

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

@@ -121,7 +121,7 @@
 </template>
 </template>
 
 
 <script setup>
 <script setup>
-import { ref, watch } from 'vue'
+import { onMounted, ref, watch } from 'vue'
 import mainApi from '~api/project/gist'
 import mainApi from '~api/project/gist'
 import { deepClone, getArrValue, getObjValue, newDownBlob } from 'js-fast-way'
 import { deepClone, getArrValue, getObjValue, newDownBlob } from 'js-fast-way'
 import dayjs from 'dayjs'
 import dayjs from 'dayjs'
@@ -144,6 +144,12 @@ const props = defineProps({
 //事件
 //事件
 const emit = defineEmits(['tap', 'check', 'change'])
 const emit = defineEmits(['tap', 'check', 'change'])
 
 
+//时间处理
+const currentYear = ref('')
+onMounted(() => {
+    currentYear.value = new dayjs().format('YYYY')
+})
+
 //监听权限
 //监听权限
 const isAdminAuth = ref(props.isAdmin)
 const isAdminAuth = ref(props.isAdmin)
 watch(() => props.isAdmin, (admin) => {
 watch(() => props.isAdmin, (admin) => {
@@ -244,12 +250,11 @@ const getDetailData = async (id) => {
     res.table = table
     res.table = table
     yearData.value = res
     yearData.value = res
     //设置默认数据
     //设置默认数据
-    const currentYear = new dayjs().format('YYYY')
     if (table.length > 0) {
     if (table.length > 0) {
         let isIndex = false
         let isIndex = false
         for (let i = 0; i < table.length; i++) {
         for (let i = 0; i < table.length; i++) {
             const planYear = table[i].year
             const planYear = table[i].year
-            if (planYear === currentYear) {
+            if (planYear === currentYear.value) {
                 yearIndex.value = i
                 yearIndex.value = i
                 yearKey.value = table[i].year
                 yearKey.value = table[i].year
                 isIndex = true
                 isIndex = true

+ 3 - 2
src/views/project/modules/project-list.vue

@@ -282,10 +282,12 @@ watch(() => props.isAdmin, (admin) => {
 })
 })
 
 
 //渲染完成
 //渲染完成
+const currentYear = ref('')
 const isAfterRender = ref(false)
 const isAfterRender = ref(false)
 onMounted(() => {
 onMounted(() => {
     //表格太复杂,渲染较慢,等页面先加载完成,再渲染表格,不然会卡住一下不动。
     //表格太复杂,渲染较慢,等页面先加载完成,再渲染表格,不然会卡住一下不动。
     //因为表头涉及到年份,如果年份很多,那么会更卡。
     //因为表头涉及到年份,如果年份很多,那么会更卡。
+    currentYear.value = new dayjs().format('YYYY')
     setTimeout(() => {
     setTimeout(() => {
         isAfterRender.value = true
         isAfterRender.value = true
     }, 200)
     }, 200)
@@ -363,12 +365,11 @@ const getDetailData = async (id) => {
     rowDetail.value = res
     rowDetail.value = res
     yearData.value = res
     yearData.value = res
     //设置默认数据
     //设置默认数据
-    const currentYear = new dayjs().format('YYYY')
     if (list.length > 0) {
     if (list.length > 0) {
         let isIndex = false
         let isIndex = false
         for (let i = 0; i < list.length; i++) {
         for (let i = 0; i < list.length; i++) {
             const planYear = list[i].planYear.toString()
             const planYear = list[i].planYear.toString()
-            if (planYear === currentYear) {
+            if (planYear === currentYear.value) {
                 yearIndex.value = i
                 yearIndex.value = i
                 yearKey.value = list[i].planYear
                 yearKey.value = list[i].planYear
                 isIndex = true
                 isIndex = true