4848 @selection-change =" handleSelectionChange"
4949 v-loading =" loading"
5050 :row-key =" (row: any) => row.id"
51+ :storeKey =" storeKey"
5152 >
5253 <el-table-column type =" selection" width =" 55" :reserve-selection =" true" />
5354 <el-table-column prop =" name" label =" 文件名称" min-width =" 280" >
156157 </LayoutContainer >
157158</template >
158159<script setup lang="ts">
159- import { ref , onMounted , reactive , onBeforeUnmount } from ' vue'
160- import { useRouter , useRoute } from ' vue-router'
160+ import { ref , onMounted , onBeforeUnmount , computed } from ' vue'
161+ import { useRouter , useRoute , onBeforeRouteLeave , onBeforeRouteUpdate } from ' vue-router'
161162import { ElTable } from ' element-plus'
162163import documentApi from ' @/api/document'
163164import ImportDocumentDialog from ' ./component/ImportDocumentDialog.vue'
@@ -172,7 +173,24 @@ const {
172173 params : { id } // id为datasetID
173174} = route as any
174175
175- const { dataset, document } = useStore ()
176+ const { common, dataset, document } = useStore ()
177+
178+ const storeKey = ' documents'
179+
180+ onBeforeRouteUpdate ((to : any , from : any ) => {
181+ common .savePage (storeKey , null )
182+ common .saveCondition (storeKey , null )
183+ })
184+ onBeforeRouteLeave ((to : any , from : any ) => {
185+ if (to .name !== ' Paragraph' ) {
186+ common .savePage (storeKey , null )
187+ common .saveCondition (storeKey , null )
188+ } else {
189+ common .saveCondition (storeKey , filterText .value )
190+ }
191+ })
192+ const beforePagination = computed (() => common .paginationConfig [storeKey ])
193+ const beforeSearch = computed (() => common .search [storeKey ])
176194
177195const SyncWebDialogRef = ref ()
178196const loading = ref (false )
@@ -182,7 +200,7 @@ const documentData = ref<any[]>([])
182200const currentMouseId = ref (null )
183201const datasetDetail = ref <any >({})
184202
185- const paginationConfig = reactive ({
203+ const paginationConfig = ref ({
186204 current_page: 1 ,
187205 page_size: 10 ,
188206 total: 0
@@ -355,21 +373,21 @@ function cellMouseLeave() {
355373}
356374
357375function handleSizeChange() {
358- paginationConfig .current_page = 1
376+ paginationConfig .value . current_page = 1
359377 getList ()
360378}
361379
362380function getList(bool ? : boolean ) {
363381 documentApi
364382 .getDocument (
365383 id as string ,
366- paginationConfig ,
384+ paginationConfig . value ,
367385 filterText .value && { name: filterText .value },
368386 bool ? undefined : loading
369387 )
370388 .then ((res ) => {
371389 documentData .value = res .data .records
372- paginationConfig .total = res .data .total
390+ paginationConfig .value . total = res .data .total
373391 })
374392}
375393
@@ -380,12 +398,18 @@ function getDetail() {
380398}
381399
382400function refresh() {
383- paginationConfig .current_page = 1
401+ paginationConfig .value . current_page = 1
384402 getList ()
385403}
386404
387405onMounted (() => {
388406 getDetail ()
407+ if (beforePagination .value ) {
408+ paginationConfig .value = beforePagination .value
409+ }
410+ if (beforeSearch .value ) {
411+ filterText .value = beforeSearch .value
412+ }
389413 getList ()
390414 // 初始化定时任务
391415 initInterval ()
0 commit comments