refactor: 调整选择过滤时刷新逻辑

bak
elseif 2 years ago
parent feb57a65e8
commit cc7e9715c4

@ -157,16 +157,17 @@ export const fieldMap = {
field2: '拜访客户类型',
field3: '拜访客户名称',
field4: '任务来源',
field5: '厂商1',
field5: '厂商',
field6: '拜访客户级别',
field7: '科室名称',
field8: '拜访小结',
field9: '产品名称',
field10: '定位信息',
field11: 2002,
field11: '拜访日期',
field12: '定位距离',
field13: '病历号',
field14: '是否重复',
field15: '任务类型',
field16: '任务状态',
field17: '项目类别',
}

@ -10,6 +10,7 @@ import type { Filter } from '/#/home'
import type { AsideEntity } from '@/config/aside'
import { asideMap } from '@/config/final'
import type { AsideConfig } from '/#/api'
import emitter from '@/utils/mitt'
const finalStore = useFinal()
@ -142,7 +143,7 @@ function filterHandler(filterList: Filter[]) {
filerMap[key] = value
}
// TODO:
emitter.emit('filter-final', filerMap)
}
function editFilter(filter: any) {

@ -1,4 +1,8 @@
<script lang="ts" setup>
import type { DataTableColumns, DataTableRowKey, PaginationProps } from 'naive-ui'
import { NDataTable, useDialog, useMessage } from 'naive-ui'
import { computed, h, nextTick, onMounted, onUnmounted, reactive, ref, unref, watch } from 'vue'
import { Action, CustomTabelModal, ImportExcelModal, RepeatModal, RepeatTaskTableModal } from '../comp'
import { getFinalList } from '@/api/final'
import { audit } from '@/api/task/task'
import SvgIcon from '@/components/Icon/SvgIcon.vue'
@ -10,11 +14,8 @@ import { useFinal } from '@/store/modules/final'
import { getViewportOffset } from '@/utils/domUtils'
import { isBoolean } from '@/utils/is'
import ConfrimModal from '@/views/task/modal/ConfrimModal.vue'
import type { DataTableColumns, DataTableRowKey, PaginationProps } from 'naive-ui'
import { NDataTable, useDialog, useMessage } from 'naive-ui'
import { computed, h, nextTick, onMounted, reactive, ref, unref, watch } from 'vue'
import { Action, CustomTabelModal, ImportExcelModal, RepeatModal, RepeatTaskTableModal } from '../comp'
import type { ApprovalParam } from '/#/api'
import emitter from '@/utils/mitt'
const columns: DataTableColumns<RowData> = [
{
@ -107,11 +108,17 @@ const columns: DataTableColumns<RowData> = [
const deviceHeight = ref(600)
onMounted(() => {
emitter.on('filter-final', refreshHandler)
nextTick(() => {
computeListHeight()
})
})
onUnmounted(() => {
emitter.off('filter-final', refreshHandler)
})
const columnsRef = ref(columns)
const tableRef = ref<InstanceType<typeof NDataTable>>()
const rowKey = (row: RowData) => row.id
@ -128,9 +135,11 @@ const dialog = useDialog()
const message = useMessage()
const finalStore = useFinal()
async function query(page: number, pageSize: number) {
const filterParams = unref(finalStore.getAsideValue)
const result = await getFinalList({ sortorder: 'asc', pageSize, currPage: page, sortname: '', ...filterParams })
async function query(page: number, pageSize: number, filterValues?: any) {
const asideParmas = unref(finalStore.getAsideValue)
// 使使
const params = filterValues || asideParmas
const result = await getFinalList({ sortorder: 'asc', pageSize, currPage: page, sortname: '', ...params })
const { data, pageCount } = result
tableData.value = data
pagination.page = page
@ -268,20 +277,20 @@ function validate(items: any[]) {
if (items.length === 0)
return '至少选中一个任务'
const useInfo = userStore.getUserInfo
const username = useInfo.loginname
// const useInfo = userStore.getUserInfo
// const username = useInfo.loginname
for (const item of items) {
const { iztrueorfalse, states, assignee } = item
if (iztrueorfalse === null)
return '未判别真假'
// for (const item of items) {
// const { iztrueorfalse, states, assignee } = item
// if (iztrueorfalse === null)
// return ''
else if (states !== 2)
return '审批状态不合法'
// else if (states !== 2)
// return ''
else if (assignee !== username)
return '审批人不一致'
}
// else if (assignee !== username)
// return ''
// }
return null
}
@ -395,8 +404,9 @@ function reset() {
pagination.pageSize = 1
}
async function refreshHandler() {
query(pagination.page, pagination.pageSize)
async function refreshHandler(filterValues?: any) {
reset()
query(pagination.page, pagination.pageSize, filterValues)
}
</script>

@ -21,7 +21,7 @@ const emit = defineEmits<{
(e: 'show-filter'): void
(e: 'show-custom'): void
(e: 'update:search'): void
(e: 'select', filterList: Filter[])
(e: 'select', id: string)
}>()
const data = ref<FilterEntity[]>([])
@ -132,7 +132,7 @@ function generateFilterEntityList(data) {
function selectHandler(item: FilterEntity) {
(popover.value as any).setShow(false)
emit('select', item.filterList)
emit('select', item.id)
}
const inputHandler = debounce((word) => {

@ -34,6 +34,8 @@ const generateModalRef = ref(null)
const LoginSuccessModalRef = ref(null)
const loading = ref(false)
const message = useMessage()
let canloadMore = true
let filterId = null
async function computeListHeight() {
const headEl = document.querySelector('.wrapper-content')!
@ -82,19 +84,8 @@ const layout = debounce(() => {
message.error('图片错误')
loading.value = false
})
// imagesloaded('.grid-item', () => {
// (_masonry as any).layout()
// const scrollHeight = el.value!.scrollHeight
// const clientHeight = el.value!.clientHeight
// const top = scrollHeight - clientHeight - 20
// el.value!.scrollTo({ top, behavior: 'instant' })
// loading.value = false
// })
}, 300)
let canloadMore = true
useInfiniteScroll(
el as any,
() => {
@ -136,8 +127,9 @@ async function featchList() {
pagination.pageNo += 1
const filterParams = unref(configStore.getAsideValue)
const result = await getPictureList({ ...pagination, ...contentParams, ...filterParams })
const asideParams = unref(configStore.getAsideValue)
const params = filterId ? { userSearchId: filterId } : asideParams
const result = await getPictureList({ ...pagination, ...contentParams, ...params })
const { data, pageCount } = result
canloadMore = pageCount >= pagination.pageNo && pageCount > 0
@ -190,8 +182,6 @@ async function commitHandler(settingParam) {
finalParam.buessinessno = settingParam.packagename
finalParam.search_history = settingParam.comparehistory ? 1 : 0
// TODO
const modal = generateModalRef.value as any
modal.showModal()
@ -224,33 +214,28 @@ watch(() => configStore.asideValue, (newVal, oldVal) => {
refreshHandler()
}, { deep: true })
async function refreshHandler() {
function reset() {
pagination.pageNo = 0
pagination.pageSize = 50
listData.value.length = 0
loading.value = true
loading.value = false
canloadMore = true
filterId = null
}
const contentParams = {
search_month: timeRange.value,
search_history: 0,
}
async function refreshHandler(filtersearchId?: any) {
reset()
const filterParams = unref(configStore.getAsideValue)
const result = await getPictureList({ ...pagination, ...contentParams, ...filterParams })
const { data, pageCount } = result
pagination.pageNo += 1
canloadMore = pageCount >= pagination.pageNo
const list = data.map((item) => {
return {
imgUrl: item.imgurl,
upname: item.upname,
ocrPictureclass: item.ocrPictureclass,
uphead: item.uphead,
}
})
if (filtersearchId)
filterId = filtersearchId
listData.value = list
useInfiniteScroll(
el as any,
() => {
loadMore()
},
{ distance: 10, canLoadMore: () => canloadMore },
)
}
function getAvatar(url: string): string {

@ -256,6 +256,15 @@ function previewHandler(event: MouseEvent) {
if (imageRef.value)
(imageRef.value as any).mergedOnClick()
}
function getPercent(pictureid: string) {
const { ocpictureid, pictureresult } = taskDetailInfo.value
const index = ocpictureid.split(',').indexOf(String(pictureid))
const results = pictureresult.split(',')
const percent = results[index] || '0'
const val = Number.parseFloat(percent)
return `${val}%`
}
</script>
<template>
@ -352,7 +361,7 @@ function previewHandler(event: MouseEvent) {
<div class="right">
<n-scrollbar v-if="totalCount > 0" style="max-height: 100%">
<div class="header">
<span>相似图片{{ totalCount }}</span>
<span>相似图片({{ totalCount }})</span>
<SvgIcon
style="margin-right: 20px;cursor: pointer;" name="max" size="24"
@click="showModal(batchModalRef)"
@ -370,7 +379,7 @@ function previewHandler(event: MouseEvent) {
/>
</div>
<div class="percent">
96%
{{ getPercent(item.pictureid) }}
</div>
</div>
</div>

1
types/home.d.ts vendored

@ -6,6 +6,7 @@ export interface Filter {
// 过滤
export interface FilterEntity {
id: string
name: string // 过滤名称
favorite: boolean// 是否收藏
isDefaultFilter: boolean// 默认筛选

Loading…
Cancel
Save