From ec4bd863247a4f1ab0e8b16e7287dd81ec4ba930 Mon Sep 17 00:00:00 2001 From: elseif Date: Mon, 18 Mar 2024 01:46:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E5=AE=A1?= =?UTF-8?q?=E6=89=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- pnpm-lock.yaml | 39 +- src/api/task/task.ts | 8 +- src/api/work/work.ts | 12 +- src/store/modules/dictonary.ts | 15 +- src/store/modules/task.ts | 15 +- src/utils/dateUtil.ts | 8 +- src/utils/index.ts | 9 + src/views/final/aside/Aside.vue | 8 +- src/views/final/comp/FilterModal.vue | 347 ++++++++++++++++ src/views/final/comp/NewFilterModal.vue | 380 ++++++++++++++++++ src/views/final/comp/index.ts | 4 +- src/views/home/aside/Aside.vue | 4 +- src/views/home/aside/comp/AdvanceFilter.vue | 10 +- src/views/home/aside/comp/Search.vue | 4 + .../aside/comp/modals/CustomFilterModal.vue | 2 +- .../home/aside/comp/modals/NewFilterModal.vue | 50 ++- src/views/login/components/Login.vue | 6 +- src/views/task/aside/Aside.vue | 2 +- src/views/task/aside/TaskList.vue | 51 ++- src/views/task/content/Content.vue | 25 +- src/views/task/modal/BatchModal.vue | 4 + types/task.d.ts | 1 - 23 files changed, 909 insertions(+), 97 deletions(-) create mode 100644 src/views/final/comp/FilterModal.vue create mode 100644 src/views/final/comp/NewFilterModal.vue diff --git a/package.json b/package.json index 2be2e59..8960260 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "@vueup/vue-quill": "^1.2.0", - "@vueuse/core": "^10.7.0", + "@vueuse/core": "10.9.0", "axios": "^1.4.0", "date-fns": "^2.30.0", "esno": "^0.16.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 29f8e15..d92ef5c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^1.2.0 version: 1.2.0(vue@3.3.10) '@vueuse/core': - specifier: ^10.7.0 - version: 10.7.0(vue@3.3.10) + specifier: 10.9.0 + version: 10.9.0(vue@3.3.10) axios: specifier: ^1.4.0 version: 1.6.2 @@ -1640,26 +1640,26 @@ packages: vue: 3.3.10(typescript@4.9.5) dev: false - /@vueuse/core@10.7.0(vue@3.3.10): - resolution: {integrity: sha512-4EUDESCHtwu44ZWK3Gc/hZUVhVo/ysvdtwocB5vcauSV4B7NiGY5972WnsojB3vRNdxvAt7kzJWE2h9h7C9d5w==} + /@vueuse/core@10.9.0(vue@3.3.10): + resolution: {integrity: sha512-/1vjTol8SXnx6xewDEKfS0Ra//ncg4Hb0DaZiwKf7drgfMsKFExQ+FnnENcN6efPen+1kIzhLQoGSy0eDUVOMg==} dependencies: '@types/web-bluetooth': 0.0.20 - '@vueuse/metadata': 10.7.0 - '@vueuse/shared': 10.7.0(vue@3.3.10) - vue-demi: 0.14.6(vue@3.3.10) + '@vueuse/metadata': 10.9.0 + '@vueuse/shared': 10.9.0(vue@3.3.10) + vue-demi: 0.14.7(vue@3.3.10) transitivePeerDependencies: - '@vue/composition-api' - vue dev: false - /@vueuse/metadata@10.7.0: - resolution: {integrity: sha512-GlaH7tKP2iBCZ3bHNZ6b0cl9g0CJK8lttkBNUX156gWvNYhTKEtbweWLm9rxCPIiwzYcr/5xML6T8ZUEt+DkvA==} + /@vueuse/metadata@10.9.0: + resolution: {integrity: sha512-iddNbg3yZM0X7qFY2sAotomgdHK7YJ6sKUvQqbvwnf7TmaVPxS4EJydcNsVejNdS8iWCtDk+fYXr7E32nyTnGA==} dev: false - /@vueuse/shared@10.7.0(vue@3.3.10): - resolution: {integrity: sha512-kc00uV6CiaTdc3i1CDC4a3lBxzaBE9AgYNtFN87B5OOscqeWElj/uza8qVDmk7/U8JbqoONLbtqiLJ5LGRuqlw==} + /@vueuse/shared@10.9.0(vue@3.3.10): + resolution: {integrity: sha512-Uud2IWncmAfJvRaFYzv5OHDli+FbOzxiVEQdLCKQKLyhz94PIyFC3CHcH7EDMwIn8NPtD06+PNbC/PiO0LGLtw==} dependencies: - vue-demi: 0.14.6(vue@3.3.10) + vue-demi: 0.14.7(vue@3.3.10) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -7116,6 +7116,21 @@ packages: vue: 3.3.10(typescript@4.9.5) dev: false + /vue-demi@0.14.7(vue@3.3.10): + resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + peerDependencies: + '@vue/composition-api': ^1.0.0-rc.1 + vue: ^3.0.0-0 || ^2.6.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + dependencies: + vue: 3.3.10(typescript@4.9.5) + dev: false + /vue-draggable-plus@0.3.5(@types/sortablejs@1.15.7): resolution: {integrity: sha512-HqIxV4Wr4U5LRPLRi2oV+EJ4g6ibyRKhuaiH4ZQo+LxK4zrk2XcBk9UyXC88OXp4SAq0XYH4Wco/T3LX5kJ79A==} peerDependencies: diff --git a/src/api/task/task.ts b/src/api/task/task.ts index 1be74e1..09a328d 100644 --- a/src/api/task/task.ts +++ b/src/api/task/task.ts @@ -7,16 +7,16 @@ import { ContentTypeEnum } from '@/enums/httpEnum' * 获取审核列表 * @returns */ -export async function getApprovalList(page: PageParam, assigneeId: string) { +export async function getApprovalList(page: PageParam) { const res = await http.request({ url: `/flow/task/listalldata`, method: 'get', - params: { pageSize: page.pageSize, currPage: page.pageNo, assigneeId }, + params: { pageSize: page.pageSize, currPage: page.pageNo }, }) - const { data: { list, totalPage } } = res + const { data: { list, totalCount } } = res return { - pageCount: totalPage, + pageCount: Math.ceil(totalCount / page.pageSize!), data: list, } } diff --git a/src/api/work/work.ts b/src/api/work/work.ts index 206e926..949fc80 100644 --- a/src/api/work/work.ts +++ b/src/api/work/work.ts @@ -28,8 +28,10 @@ export async function getPackageList(params: PageParam, packagename: string) { * @returns */ export async function getPackageTaskList(packageid: string, params: PageParam) { + const pid = packageid || 0 + const res = await http.request({ - url: `/backstage/jifen/ocrtaskchildpicture/listbypackageid/${packageid}`, + url: `/backstage/jifen/ocrtaskchildpicture/listbypackageid/${pid}`, method: 'get', params, }) @@ -48,8 +50,10 @@ export async function getPackageTaskList(packageid: string, params: PageParam) { * @returns */ export async function getTaskDetailInfo(taskId: string, packageid: string) { + const pid = packageid || 0 + const res = await http.request({ - url: `/backstage/jifen/ocrtaskchildpicture/getdata/${taskId}/${packageid}`, + url: `/backstage/jifen/ocrtaskchildpicture/getdata/${taskId}/${pid}`, method: 'get', }) @@ -64,8 +68,10 @@ export async function getTaskDetailInfo(taskId: string, packageid: string) { * @returns */ export async function getTaskDetailPictureList(packageid: string, taskchildpictureid: string, params: PageParam & PictureSortParam) { + const pid = packageid || 0 + const res = await http.request({ - url: `/backstage/jifen/ocrtaskchildpicture/listbypictureid/${packageid}/${taskchildpictureid}`, + url: `/backstage/jifen/ocrtaskchildpicture/listbypictureid/${pid}/${taskchildpictureid}`, method: 'get', params, }) diff --git a/src/store/modules/dictonary.ts b/src/store/modules/dictonary.ts index ac5b6af..e61e5d8 100644 --- a/src/store/modules/dictonary.ts +++ b/src/store/modules/dictonary.ts @@ -18,7 +18,7 @@ export interface DictionaryState { izCustomtypeList: any izcustomnameList: any izcustomlevelList: any - izizprojecttypeList: any + izprojecttypeList: any izvisitcityList: any rejectList: any backList: any @@ -44,7 +44,7 @@ export const useDictionaryStore = defineStore({ izcustomnameList: null, izCustomtypeList: null, izcustomlevelList: null, - izizprojecttypeList: null, + izprojecttypeList: null, izvisitcityList: null, rejectList: null, backList: null, @@ -94,8 +94,11 @@ export const useDictionaryStore = defineStore({ getizcustomlevel: (state) => { return state.izcustomlevelList }, - getizizprojecttype: (state) => { - return state.izizprojecttypeList + getizprojecttype: (state) => { + return state.izprojecttypeList + }, + getizstatus: (state) => { + return state.izstatusList }, }, actions: { @@ -195,8 +198,8 @@ export const useDictionaryStore = defineStore({ // 项目类别 async fetchizizprojecttypeList() { const list = await getBusinessList('izprojecttype') - this.izizprojecttypeList = list - return this.izizprojecttypeList + this.izprojecttypeList = list + return this.izprojecttypeList }, // 发布地区 async fetchizvisitcityList() { diff --git a/src/store/modules/task.ts b/src/store/modules/task.ts index 869f655..c9b1adb 100644 --- a/src/store/modules/task.ts +++ b/src/store/modules/task.ts @@ -10,7 +10,6 @@ export const useTaskStore = defineStore({ activeId: '', approvalList: [], packageid: '', - refresh: false, immersion: false, }), getters: { @@ -26,7 +25,7 @@ export const useTaskStore = defineStore({ setActive(index: number, taskId?: string) { this.currentIndex = index const task = this.approvalList[index] - this.activeId = taskId || task?.formid + this.activeId = taskId || task?.id this.packageid = task.packageid }, forward() { @@ -43,14 +42,12 @@ export const useTaskStore = defineStore({ this.setActive(--this.currentIndex) }, - async fetchApprovalList(pagination, id, refresh?: boolean) { - const res = await getApprovalList(pagination, id) - + async fetchApprovalList(pagination) { + const res = await getApprovalList(pagination) if (res.data.length > 0) { - this.setApprovalList(res.data) - this.setActive(0) - // 审批操作完成后,需要刷新,为防止activeId在刷新后值不变,通过此值刷新 - this.refresh = !this.refresh + this.approvalList.push(...res.data) + if (!this.activeId) + this.setActive(0) } return res diff --git a/src/utils/dateUtil.ts b/src/utils/dateUtil.ts index ad6a168..09b2c70 100644 --- a/src/utils/dateUtil.ts +++ b/src/utils/dateUtil.ts @@ -1,4 +1,4 @@ -import { format } from 'date-fns' +import { format, parse } from 'date-fns' const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm' const DATE_FORMAT = 'YYYY-MM-DD ' @@ -20,3 +20,9 @@ export function formatToDate2(date: Date | number, formatStr = DATA_FORMAT_2): s export function formatToDateHMS(date: Date | number, formatStr = DATE_FORMAT_HMS) { return format(date, formatStr) } + +// 将yyyy/mm/dd转换为时间戳 +export function formatToDate3(dateString: string) { + const dateObject = parse(dateString, 'yyyy/MM/dd', new Date()) + return dateObject.getTime() +} diff --git a/src/utils/index.ts b/src/utils/index.ts index a46e12f..26eb5d0 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -275,3 +275,12 @@ export function arrayEquals(a, b) { export function notEmpty(value: any) { return !(value === undefined || value === '' || value === null || (Array.isArray(value) && value.length === 0)) } + +/** + * 值是否为空 + * @param value + * @returns + */ +export function isEmpty(value: any) { + return (value === undefined || value === '' || value === null) +} diff --git a/src/views/final/aside/Aside.vue b/src/views/final/aside/Aside.vue index 70ae259..1608e22 100644 --- a/src/views/final/aside/Aside.vue +++ b/src/views/final/aside/Aside.vue @@ -1,6 +1,6 @@ + + + + diff --git a/src/views/final/comp/NewFilterModal.vue b/src/views/final/comp/NewFilterModal.vue new file mode 100644 index 0000000..68ecf26 --- /dev/null +++ b/src/views/final/comp/NewFilterModal.vue @@ -0,0 +1,380 @@ + + + + + diff --git a/src/views/final/comp/index.ts b/src/views/final/comp/index.ts index 26f47eb..eb57edf 100644 --- a/src/views/final/comp/index.ts +++ b/src/views/final/comp/index.ts @@ -5,5 +5,7 @@ import RepeatTaskTableModal from './RepeatTaskTableModal.vue' import Action from './Action.vue' import RejectModal from './RejectModal.vue' import CustomFilterModalVue from './CustomFilterModalVue.vue' +import FilterModal from './FilterModal.vue' +import NewFilterModal from './NewFilterModal.vue' -export { CustomTabelModal, ImportExcelModal, RepeatModal, RepeatTaskTableModal, Action, RejectModal, CustomFilterModalVue } +export { CustomTabelModal, ImportExcelModal, RepeatModal, RepeatTaskTableModal, Action, RejectModal, CustomFilterModalVue, FilterModal, NewFilterModal } diff --git a/src/views/home/aside/Aside.vue b/src/views/home/aside/Aside.vue index 642039a..1a008f2 100644 --- a/src/views/home/aside/Aside.vue +++ b/src/views/home/aside/Aside.vue @@ -82,7 +82,7 @@ configStore.$subscribe(() => { const config = configStore.getConfig const customConfig = configStore.getCustomConfig - if (config === null || customConfig === null) + if (config == null || customConfig == null) return const showKeys = [...customConfig].filter(key => !asideMap[key].isDefaultFilter) @@ -168,7 +168,7 @@ watch(asideValue, (newVal) => { diff --git a/src/views/home/aside/comp/AdvanceFilter.vue b/src/views/home/aside/comp/AdvanceFilter.vue index 9f10cb5..d168d2f 100644 --- a/src/views/home/aside/comp/AdvanceFilter.vue +++ b/src/views/home/aside/comp/AdvanceFilter.vue @@ -9,6 +9,14 @@ import type { FilterSearchParam } from '/#/api' defineOptions({ name: 'AdvanceFilter' }) +const props = defineProps({ + type: { + type: Number, + default: 0, + required: true, + }, +}) + const emit = defineEmits<{ (e: 'show-filter'): void (e: 'show-custom'): void @@ -78,7 +86,7 @@ async function featchList() { loading = true try { const searchParam: FilterSearchParam = { search_searchname: { value: keyword.value, op: 'like', type: 'string' } } - const result = await getConditionList(pagination, searchParam, 0) + const result = await getConditionList(pagination, searchParam, props.type) const { data } = result // pagination.pageNo += 1 // canloadMore = pageCount >= pagination.pageNo diff --git a/src/views/home/aside/comp/Search.vue b/src/views/home/aside/comp/Search.vue index ef20cdd..9aa087c 100644 --- a/src/views/home/aside/comp/Search.vue +++ b/src/views/home/aside/comp/Search.vue @@ -23,6 +23,10 @@ const inputHandler = debounce((keyword) => { configStore.$subscribe(() => { const customConfig = configStore.getCustomConfig + + if (customConfig == null) + return + const keys = customConfig ? [...customConfig] : [] if (keys.length === 0) diff --git a/src/views/home/aside/comp/modals/CustomFilterModal.vue b/src/views/home/aside/comp/modals/CustomFilterModal.vue index 09526e4..321754e 100644 --- a/src/views/home/aside/comp/modals/CustomFilterModal.vue +++ b/src/views/home/aside/comp/modals/CustomFilterModal.vue @@ -113,7 +113,7 @@ configStore.$subscribe(() => { const config = configStore.getConfig const customConfig = configStore.getCustomConfig - if (config === null || customConfig === null) + if (config == null || customConfig == null) return const { showList, hideList } = generatList(config, customConfig) diff --git a/src/views/home/aside/comp/modals/NewFilterModal.vue b/src/views/home/aside/comp/modals/NewFilterModal.vue index bfc78cc..d7e5b5b 100644 --- a/src/views/home/aside/comp/modals/NewFilterModal.vue +++ b/src/views/home/aside/comp/modals/NewFilterModal.vue @@ -6,9 +6,7 @@ import { useDictionary } from '@/store/modules/dictonary' import { useConfig } from '@/store/modules/asideConfig' import type { FilterCondition } from '/#/api' import { addCondition, updateCondition } from '@/api/home/filter' -import { formatToDate2 } from '@/utils/dateUtil' - -defineOptions({ name: 'NewFilterModal' }) +import { formatToDate2, formatToDate3 } from '@/utils/dateUtil' type Status = 'edit' | 'new' @@ -96,7 +94,6 @@ const formValue = reactive({ function handleSumbit(e: MouseEvent) { e.preventDefault() - const v = formRef.value formRef.value?.validate((errors) => { if (errors) return @@ -127,6 +124,7 @@ function handleSumbit(e: MouseEvent) { }) } +// 调用接口前转换为服务端格式 function formatValue(searchfield: string, searchvalue: any) { if (searchfield === 'izyear') { const start = formatToDate2(searchvalue[0]) @@ -134,12 +132,29 @@ function formatValue(searchfield: string, searchvalue: any) { return `${start}-${end}` } - if (Array.isArray(searchvalue)) + if (searchfield === 'izsimilarity' && Array.isArray(searchvalue)) return searchvalue.join(',') return searchvalue } +// 编辑前前转换为服务端格式 +function unformatValue(searchfield: string, searchvalue: any) { + // 2022/01/03-2023/02/04 + if (searchfield === 'izyear') { + const dataStrs = searchvalue.split('-') + const start = formatToDate3(dataStrs[0]) + const end = formatToDate3(dataStrs[1]) + return [start, end] + } + + // 80,90 + if (searchfield === 'izsimilarity') + return searchvalue.split(',') + + return searchvalue +} + function createCondition() { formValue.conditions.push({ type: null, @@ -194,8 +209,6 @@ watch(() => dicStore.relationTypeList, (newval) => { logicOptions.value = newval }) -const resultOptions = ref([]) - function showModal() { show.value = true } @@ -206,6 +219,7 @@ function closeModal() { function generateAllData(config): Option[] { const initVal: Option[] = [] + const list = Object.keys(config).reduce((acc, value) => { if (value.startsWith('iz') && asideMap[value]?.inFilterList !== false) { const name = asideMap[value]?.label @@ -222,19 +236,20 @@ function generateAllData(config): Option[] { } watch(() => configStore.systemConfig, (newVal) => { + if (!newVal) + return + const list = generateAllData(newVal) typeOptions.value = list }) -function handleTypeUpate(value: string) { - if (value === 'izsimilarity') { - resultOptions.value = similarityOptions as any - return - } +function getOptions(key: string) { + if (key === 'izsimilarity') + return similarityOptions - const key = `get${value}` - const options = unref(dicStore[key]) - resultOptions.value = options || [] + const getterName = `get${key}` + const options = unref(dicStore[getterName]) + return options || [] } function leaveHandler() { @@ -261,7 +276,7 @@ function edit(editFilter: any) { return { type: item.searchfield, operator: item.searchtype, - result: item.searchvalue, + result: unformatValue(item.searchfield, item.searchvalue), } }) } @@ -296,7 +311,6 @@ defineExpose({ > diff --git a/src/views/task/aside/TaskList.vue b/src/views/task/aside/TaskList.vue index ce0e7e4..ca972d6 100644 --- a/src/views/task/aside/TaskList.vue +++ b/src/views/task/aside/TaskList.vue @@ -3,7 +3,6 @@ import { onMounted, onUnmounted, reactive, ref, watch } from 'vue' import { useInfiniteScroll } from '@vueuse/core' import ListItem from './ListItem.vue' import { useTaskStore } from '@/store/modules/task' -import { useUser } from '@/store/modules/user' import emitter from '@/utils/mitt' defineOptions({ name: 'WorkSheetList' }) @@ -14,11 +13,10 @@ const activeId = ref('') const el = ref(null) const keyword = ref('') const canloadMore = ref(true) -const userStore = useUser() const pagination = reactive({ pageNo: 0, - pageSize: 10, + pageSize: 30, }) function selectHandler(id: string, index: number) { @@ -30,10 +28,7 @@ const { isLoading } = useInfiniteScroll( () => { loadMore() }, - { distance: 10, interval: 300, canLoadMore: () => { - // console.log('canloadmore excuted!') - return canloadMore.value - } }, + { distance: 10, interval: 300, canLoadMore: () => canloadMore.value }, ) async function loadMore() { @@ -47,10 +42,9 @@ async function loadMore() { async function fetchList() { try { pagination.pageNo += 1 - const id = userStore.getUserInfo.id - const result = await taskStore.fetchApprovalList(pagination, id) + const result = await taskStore.fetchApprovalList(pagination) const { data, pageCount } = result - canloadMore.value = pageCount >= pagination.pageNo && pageCount !== 0 + canloadMore.value = pageCount >= pagination.pageNo return data || [] } catch (error) { @@ -65,9 +59,11 @@ watch(() => taskStore.activeId, (newVal) => { function reset() { pagination.pageNo = 0 - pagination.pageSize = 10 + pagination.pageSize = 30 canloadMore.value = true data.value.length = 0 + + taskStore.reset() } async function search(word: string) { @@ -91,7 +87,6 @@ onUnmounted(() => { }) async function refreshHandler() { - reset() search('') } @@ -101,17 +96,29 @@ defineExpose({ diff --git a/src/views/task/content/Content.vue b/src/views/task/content/Content.vue index 8ece0bb..fdd60c4 100644 --- a/src/views/task/content/Content.vue +++ b/src/views/task/content/Content.vue @@ -1,14 +1,15 @@