ZaiZai 1 year ago
parent
commit
3b9daa92ae
3 changed files with 35 additions and 16 deletions
  1. 1 4
      src/layout/index.vue
  2. 3 1
      src/views/tentative/detect/test-form.vue
  3. 31 11
      src/views/tentative/detect/test.vue

+ 1 - 4
src/layout/index.vue

@@ -92,10 +92,7 @@ onMounted(() => {
 })
 
 //监听layout
-watch(() => [
-    useRoutes?.query?.layout,
-    store.isLayout,
-], ([layout, layout2]) => {
+watch(() => [useRoutes?.query?.layout, store.isLayout], ([layout, layout2]) => {
     isLayout.value = layout ?? layout2
 }, { deep: true })
 

+ 3 - 1
src/views/tentative/detect/test-form.vue

@@ -245,6 +245,7 @@ const nodeId = routerQuery?.nodeId || ''
 const dataType = routerQuery?.dataType || '1'
 let isaddType = routerQuery?.isaddType || false
 let currentCid = routerQuery?.cid
+let currentPage = routerQuery?.current
 const afterAdd = ref(false)
 const dayDate = dayjs().format('YYYY-MM-DD')
 const testTreeItem = ref(getStoreValue('testTreeItem'))
@@ -1500,11 +1501,12 @@ const abolishOneSave = async () => {
         getTableDataAll()
     }
 }
+
 //返回
 const toBackClick = () => {
     router.push({
         path: '/tentative/detect/test',
-        query: {},
+        query: { current: currentPage ?? '' },
     })
     // setTimeout(() => {
     //     window?.location?.reload()  //刷新页面

+ 31 - 11
src/views/tentative/detect/test.vue

@@ -301,7 +301,7 @@
 
 <script setup>
 import { onActivated, onMounted, ref, watch } from 'vue'
-import { useRouter } from 'vue-router'
+import { useRoute, useRouter } from 'vue-router'
 import { useAppStore } from '~src/store'
 import TestTree from '../material/components/TestTree.vue'
 import { delStoreValue, getStoreValue, setStoreValue } from '~src/utils/storage'
@@ -314,12 +314,13 @@ import dataApi from '~api/tentative/detect/test'
 import testSampleApi from '~api/tentative/material/testSample'
 import commissionApi from '~api/tentative/detect/commission'
 import acquisitionApi from '~api/tentative/acquisition/data'
-import { arrToId, formValidate, getArrValue, getObjVal, isNullES, isString } from 'js-fast-way'
+import { arrToId, formValidate, getArrValue, getObjVal, getObjValue, isNullES, isString } from 'js-fast-way'
 import { HcDelMsg } from 'hc-vue3-ui'
 import { toPdfPage } from '~uti/btn-auth'
 
 //变量
 const router = useRouter()
+const useRoutes = useRoute()
 const useAppState = useAppStore()
 const userInfo = ref(useAppState.getUserInfo)
 const projectId = ref(useAppState.getProjectId)
@@ -330,10 +331,7 @@ const isCollapse = ref(useAppState.getCollapse)
 const isBubble = ref(useAppState.getBubble)
 
 //监听
-watch(() => [
-    useAppState.getCollapse,
-    useAppState.getBubble,
-], ([Collapse, bubble]) => {
+watch(() => [useAppState.getCollapse, useAppState.getBubble], ([Collapse, bubble]) => {
     isCollapse.value = Collapse
     isBubble.value = bubble
 })
@@ -357,10 +355,23 @@ onMounted(() => {
 
 //缓存被激活时,重新获取表格数据
 onActivated(() => {
-    // setMountOnEventKey()
-    getTableData()
+    getDataApi()
 })
 
+const isFirstTime = ref(false)
+const getDataApi = async () => {
+    isFirstTime.value = true
+    const routerQuery = useRoutes?.query
+    let currentPage = routerQuery?.current
+    if (isNullES(currentPage)) {
+        searchForm.value.current = 1
+    } else {
+        searchForm.value.current = Number(currentPage)
+    }
+    console.log(searchForm.value)
+    // setMountOnEventKey()
+    getTableData().then()
+}
 
 //获取合同段信息
 const contractData = ref([])
@@ -425,7 +436,12 @@ const wbsElTreeClick = ({ data, keys }) => {
     setStoreValue('testTreeExpandKeys', keys)
     //改变搜索表单数据
     searchForm.value.nodeId = data['primaryKeyId']
-    searchForm.value.current = 1
+    if (!isFirstTime.value) {
+        searchForm.value.current = 1
+    } else {
+        isFirstTime.value = false
+    }
+    console.log('isFirstTime', isFirstTime.value)
     getTableData()
 }
 
@@ -550,13 +566,15 @@ const tableSelection = (rows) => {
 const addFormModalClick = () => {
     delStoreValue('test-form')
     setStoreValue('prenodeDataInfo', nodeDataInfo.value)
+    const obj = getObjValue(searchForm.value)
     router.push({
         path: '/tentative/detect/test-form',
         query: {
             nodeId: primaryKeyId.value,
             dataType: authBtnTabKey.value,
-            cid: searchForm.value?.contractId,
+            cid: obj?.contractId,
             isaddType: true,
+            current: obj?.current,
         },
     })
 }
@@ -565,6 +583,7 @@ const addFormModalClick = () => {
 const tableRowEdit = (row, tabTypeKey) => {
     setStoreValue('test-form', row)
     setStoreValue('prenodeDataInfo', nodeDataInfo.value)
+    const obj = getObjValue(searchForm.value)
     router.push({
         path: '/tentative/detect/test-form',
         query: {
@@ -572,7 +591,8 @@ const tableRowEdit = (row, tabTypeKey) => {
             nodeId: row.nodeId,
             dataType: row.type,
             tabTypeKey: tabTypeKey,
-            cid: searchForm.value?.contractId,
+            cid: obj?.contractId,
+            current: obj?.current,
             // prenodeDataInfo:JSON.stringify(nodeDataInfo.value)
         },
     })