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

Merged
liushilong merged 1 commits from fix/fetch_bug into test 1 year ago

3
components.d.ts vendored

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

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

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

Loading…
Cancel
Save