fix: 修复全局搜索后页面数据多次获取问题

pull/183/head
刘释隆 1 year ago
parent 572903f4dc
commit 6caa3d46bf

3
components.d.ts vendored

@ -11,7 +11,6 @@ declare module 'vue' {
BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default']
DataHeader: typeof import('./src/components/DataHeader/index.vue')['default']
NAvatar: typeof import('naive-ui')['NAvatar']
NBackTop: typeof import('naive-ui')['NBackTop']
NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard']
NCheckbox: typeof import('naive-ui')['NCheckbox']
@ -22,7 +21,6 @@ declare module 'vue' {
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
NDivider: typeof import('naive-ui')['NDivider']
NDropdown: typeof import('naive-ui')['NDropdown']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NGi: typeof import('naive-ui')['NGi']
@ -34,7 +32,6 @@ declare module 'vue' {
NModal: typeof import('naive-ui')['NModal']
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
NotPassed: typeof import('./src/components/NotPassed.vue')['default']
NPopconfirm: typeof import('naive-ui')['NPopconfirm']
NPopover: typeof import('naive-ui')['NPopover']
NPopselect: typeof import('naive-ui')['NPopselect']
NProgress: typeof import('naive-ui')['NProgress']

@ -41,9 +41,6 @@ import emitter from '@/utils/mitt'
import { formatToDateHMS } from '@/utils/dateUtil'
import { getAllfieldList, getfieldList, savefield } from '@/api/home/filter'
import DataHeader from '@/components/DataHeader/index.vue'
import console from 'console'
const emit = defineEmits(['changeShow'])
function changeContent() {
@ -57,6 +54,7 @@ const route = useRoute()
const reviewType = 0
const sortorder = ref('asc')
const sortname = ref('states')
const searchContent = route.query.searchContent as string
const actionsColumns = {
title: '操作',
key: 'actions',
@ -201,6 +199,7 @@ async function getColumns() {
width: 120,
})
}
return v
})
}
else {
@ -212,6 +211,7 @@ async function getColumns() {
fixed: 'left',
width: 120,
})
return v
})
userFieldUnFixed.map((v) => {
const item = allList.find(v2 => v2.name == v)
@ -220,6 +220,7 @@ async function getColumns() {
key: item.name,
width: 120,
})
return v
})
}
// TODO:
@ -421,6 +422,7 @@ async function formatColumns() {
const deviceHeight = ref(600)
onMounted(() => {
// query(pagination.page, pagination.pageSize);
emitter.on('filter-final', refreshHandler)
getColumns()
@ -481,6 +483,7 @@ const message = useMessage()
const finalStore = useFinal()
async function query(page: number, pageSize: number, filterId?: any, taskName?: string) {
console.log('query', taskName)
const asideParmas = unref(finalStore.getAsideValue)
// 使使
// let params = filterId ? { userSearchId: filterId } : asideParmas
@ -586,10 +589,6 @@ const scrollX = computed(() => {
return width
})
onMounted(() => {
query(pagination.page, pagination.pageSize)
})
const customTabelRef = ref(null)
const importExcelRef = ref(null)
const notPassModalRef = ref(null) //
@ -709,7 +708,7 @@ function resetHandler() {
// TODO
// const result = await resetApproval()
},
onNegativeClick: () => { },
onNegativeClick: () => {},
})
}
@ -816,7 +815,7 @@ function doAudit(param: any) {
}
})
},
onNegativeClick: () => { },
onNegativeClick: () => {},
})
}
@ -855,15 +854,23 @@ function reset() {
async function refreshHandler(searchId?: any) {
reset()
query(pagination.page, pagination.pageSize, searchId)
let searchKeyword = ''
if (searchContent) {
const id_param = searchContent.match(/-\d+-/)
if (id_param)
searchKeyword = id_param[0].slice(1, -1)
}
console.log('refreshHandler', searchKeyword)
query(pagination.page, pagination.pageSize, searchId, searchKeyword)
}
function filterTableData(keyword) {
pagination.page = 1
pagination.pageSize = 10
if (keyword) {
if (keyword)
query(pagination.page, pagination.pageSize, '', keyword)
} else { query(pagination.page, pagination.pageSize) }
else
query(pagination.page, pagination.pageSize)
}
defineExpose({
@ -876,10 +883,20 @@ defineExpose({
<div class="wrapper-header">
<div class="wrapper-header-left">
<span class="wrapper-header-font">任务管理列表</span>
<SvgIcon style="cursor: pointer" size="16" name="list-mode" @click="changeContent" />
<SvgIcon
style="cursor: pointer"
size="16"
name="list-mode"
@click="changeContent"
/>
</div>
<div>
<SvgIcon style="margin-right: 6px" size="13" name="summary" @click="showModal(repeatModalRef)" />
<SvgIcon
style="margin-right: 6px"
size="13"
name="summary"
@click="showModal(repeatModalRef)"
/>
<NButton class="xjcc" text @click="showModal(repeatModalRef)">
小结查重
</NButton>
@ -898,14 +915,29 @@ defineExpose({
取消
</NButton>
<img class="btn-approval btn-left" src="@/assets/images/task/btn-not-pass.png" alt=""
@click.stop="batchReject">
<img
class="btn-approval btn-left"
src="@/assets/images/task/btn-not-pass.png"
alt=""
@click.stop="batchReject"
>
<SvgIcon size="24" name="vs" />
<img class="btn-approval" src="@/assets/images/task/btn-pass.png" alt="" @click.stop="batchApproval">
<img
class="btn-approval"
src="@/assets/images/task/btn-pass.png"
alt=""
@click.stop="batchApproval"
>
</div>
<n-popover ref="popover" :style="{ padding: '0px' }" style="width: 148px" :show-arrow="false"
placement="bottom-start" trigger="click">
<n-popover
ref="popover"
:style="{ padding: '0px' }"
style="width: 148px"
:show-arrow="false"
placement="bottom-start"
trigger="click"
>
<template #trigger>
<div class="icon-wrap">
<SvgIcon size="20" name="more-blue" />
@ -945,20 +977,46 @@ defineExpose({
</div>
</div> -->
<div class="wrapper-settings">
<SvgIcon style="cursor: pointer" size="18" name="column" @click="showModal(customTabelRef)" />
<SvgIcon
style="cursor: pointer"
size="18"
name="column"
@click="showModal(customTabelRef)"
/>
</div>
<div class="wrapper-content">
<NDataTable id="table" ref="tableRef" v-model:checked-row-keys="checkedRowKeys" remote :columns="columnsRef"
:scroll-x="scrollX" :max-height="maxHeight" :data="tableData" :loading="loading" :pagination="pagination"
:row-key="rowKey" @update:page="handlePageChange" @update-page-size="handlePageSizeChange"
@update:checked-row-keys="handleCheck" @update:sorter="handleSorterChange" />
<NDataTable
id="table"
ref="tableRef"
v-model:checked-row-keys="checkedRowKeys"
remote
:columns="columnsRef"
:scroll-x="scrollX"
:max-height="maxHeight"
:data="tableData"
:loading="loading"
:pagination="pagination"
:row-key="rowKey"
@update:page="handlePageChange"
@update-page-size="handlePageSizeChange"
@update:checked-row-keys="handleCheck"
@update:sorter="handleSorterChange"
/>
</div>
<CustomTabelModal ref="customTabelRef" @commit="commitHandler" />
<ImportExcelModal ref="importExcelRef" :on-success="sucessHandler" :header-config="headRules" />
<ImportExcelModal
ref="importExcelRef"
:on-success="sucessHandler"
:header-config="headRules"
/>
<NotPassed ref="notPassModalRef" @success="reload" />
<RepeatModal ref="repeatModalRef" @reject="repeatBatchReject" @viewrepeat="showModal(repeatTaskTableModalRef)" />
<RepeatModal
ref="repeatModalRef"
@reject="repeatBatchReject"
@viewrepeat="showModal(repeatTaskTableModalRef)"
/>
<RepeatTaskTableModal ref="repeatTaskTableModalRef" />
</div>
</template>

@ -1,7 +1,7 @@
<script lang="ts" setup>
import { nextTick, onMounted, ref, watch } from 'vue'
import { debounce } from 'lodash-es'
import { useRoute } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import { asideMap } from '@/config/aside'
import type { SearchEntity } from '/#/home'
import { useConfig } from '@/store/modules/asideConfig'
@ -18,6 +18,7 @@ const emit = defineEmits<{
const finalStore = useFinal()
const router = useRouter()
const route = useRoute()
const searchContent = route.query.searchContent as string
const data = ref<SearchEntity[]>([])
@ -69,6 +70,9 @@ function close() {
searchKeyword.value = ''
configStore.setSearchValue(searchKeyword.value)
finalStore.setSearchValue(searchKeyword.value)
if (searchContent)
router.push(route.path)
emit('close')
}

Loading…
Cancel
Save