From 868d6fc726b62b2980fd50aeb225b782df695932 Mon Sep 17 00:00:00 2001 From: zmj <1493694146@qq.com> Date: Sun, 26 May 2024 22:20:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=92=8C=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8C=85?= =?UTF-8?q?=E6=8B=AC=E5=AF=B9oa=5FInitiate=E7=9A=84=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=92=8Coa=5Fflow=5Ftype=E7=9A=84=E7=BC=96=E8=BE=91=E5=92=8C?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/oa_Initiate.ts | 30 +-- src/components/generateForm/index.vue | 23 +- src/components/oaFlow/index.vue | 143 ++++++++----- src/stores/modules/multipleTabs.ts | 288 +++++++++++++------------- src/views/oa_Initiate/detail.vue | 131 +++++++++--- src/views/oa_Initiate/edit.vue | 11 +- src/views/oa_flow_type/edit.vue | 27 +-- src/views/oa_flow_type/index.vue | 17 -- 8 files changed, 368 insertions(+), 302 deletions(-) diff --git a/src/api/oa_Initiate.ts b/src/api/oa_Initiate.ts index 302a35e..64cc81f 100644 --- a/src/api/oa_Initiate.ts +++ b/src/api/oa_Initiate.ts @@ -1,30 +1,4 @@ import request from "@/utils/request"; - -// // 审批流程表列表 -// export function apiOaFlowLists(params: any) { -// return request.get({ url: "/works.bgsp.oa_flow/lists", params }); -// } - -// // 添加审批流程表 -// export function apiOaFlowAdd(params: any) { -// return request.post({ url: "/works.bgsp.oa_flow/add", params }); -// } - -// // 编辑审批流程表 -// export function apiOaFlowEdit(params: any) { -// return request.post({ url: "/works.bgsp.oa_flow/edit", params }); -// } - -// // 删除审批流程表 -// export function apiOaFlowDelete(params: any) { -// return request.post({ url: "/works.bgsp.oa_flow/delete", params }); -// } - -// // 审批流程表详情 -// export function apiOaFlowDetail(params: any) { -// return request.get({ url: "/works.bgsp.oa_flow/detail", params }); -// } - // 审批流程表列表 export function apiOaFlowTypeLists(params: any) { return request.get({ url: "/works.bgsp.oa_flow_type/all", params }); @@ -49,3 +23,7 @@ export function apiOaoaApproveCopy(params: any) { export function apiOaoaApprovelst(params: any) { return request.get({ url: "/works.bgsp.oa_approve/lst", params }); } + +export function apiOaoaApproveCheck(params: any) { + return request.post({ url: "/works.bgsp.oa_approve/check", params }); +} diff --git a/src/components/generateForm/index.vue b/src/components/generateForm/index.vue index 5c34024..9ce491e 100644 --- a/src/components/generateForm/index.vue +++ b/src/components/generateForm/index.vue @@ -10,14 +10,17 @@ value-format="YYYY-MM-DD" :placeholder="'请选择' + item.label"> + - + + - @@ -36,7 +39,7 @@ - \ No newline at end of file diff --git a/src/components/oaFlow/index.vue b/src/components/oaFlow/index.vue index e1f6461..3ce4af5 100644 --- a/src/components/oaFlow/index.vue +++ b/src/components/oaFlow/index.vue @@ -1,68 +1,105 @@ \ No newline at end of file + diff --git a/src/stores/modules/multipleTabs.ts b/src/stores/modules/multipleTabs.ts index 6654738..dab1573 100644 --- a/src/stores/modules/multipleTabs.ts +++ b/src/stores/modules/multipleTabs.ts @@ -1,168 +1,170 @@ -import { defineStore } from 'pinia' -import { isExternal } from '@/utils/validate' +import { defineStore } from "pinia"; +import { isExternal } from "@/utils/validate"; import type { - LocationQuery, - RouteLocationNormalized, - RouteParamsRaw, - Router, - RouteRecordName -} from 'vue-router' -import { PageEnum } from '@/enums/pageEnum' + LocationQuery, + RouteLocationNormalized, + RouteParamsRaw, + Router, + RouteRecordName, +} from "vue-router"; +import { PageEnum } from "@/enums/pageEnum"; interface TabItem { - name: RouteRecordName - fullPath: string - path: string - title?: string - query?: LocationQuery - params?: RouteParamsRaw + name: RouteRecordName; + fullPath: string; + path: string; + title?: string; + query?: LocationQuery; + params?: RouteParamsRaw; } interface TabsSate { - cacheTabList: Set - tabList: TabItem[] - tasMap: Record - indexRouteName: RouteRecordName + cacheTabList: Set; + tabList: TabItem[]; + tasMap: Record; + indexRouteName: RouteRecordName; } const getHasTabIndex = (fullPath: string, tabList: TabItem[]) => { - return tabList.findIndex((item) => item.fullPath == fullPath) -} + return tabList.findIndex((item) => item.fullPath == fullPath); +}; const isCannotAddRoute = (route: RouteLocationNormalized, router: Router) => { - const { path, meta, name } = route - if (!path || isExternal(path)) return true - if (meta?.hideTab) return true - if (!router.hasRoute(name!)) return true - if (([PageEnum.LOGIN, PageEnum.ERROR_403] as string[]).includes(path)) { - return true - } - return false -} + const { path, meta, name } = route; + if (!path || isExternal(path)) return true; + if (meta?.hideTab) return true; + if (!router.hasRoute(name!)) return true; + if (([PageEnum.LOGIN, PageEnum.ERROR_403] as string[]).includes(path)) { + return true; + } + return false; +}; const findTabsIndex = (fullPath: string, tabList: TabItem[]) => { - return tabList.findIndex((item) => item.fullPath === fullPath) -} + return tabList.findIndex((item) => item.fullPath === fullPath); +}; const getComponentName = (route: RouteLocationNormalized) => { - return route.matched.at(-1)?.components?.default?.name -} + // return route.matched.at(-1)?.components?.default?.name || null; +}; export const getRouteParams = (tabItem: TabItem) => { - const { params, path, query } = tabItem - return { - params: params || {}, - path, - query: query || {} - } -} + const { params, path, query } = tabItem; + return { + params: params || {}, + path, + query: query || {}, + }; +}; const useTabsStore = defineStore({ - id: 'tabs', - state: (): TabsSate => ({ - cacheTabList: new Set(), - tabList: [], - tasMap: {}, - indexRouteName: '' - }), - getters: { - getTabList(): TabItem[] { - return this.tabList - }, - getCacheTabList(): string[] { - return Array.from(this.cacheTabList) - } + id: "tabs", + state: (): TabsSate => ({ + cacheTabList: new Set(), + tabList: [], + tasMap: {}, + indexRouteName: "", + }), + getters: { + getTabList(): TabItem[] { + return this.tabList; }, - actions: { - setRouteName(name: RouteRecordName) { - this.indexRouteName = name - }, - addCache(componentName?: string) { - if (componentName) this.cacheTabList.add(componentName) - }, - removeCache(componentName?: string) { - if (componentName && this.cacheTabList.has(componentName)) { - this.cacheTabList.delete(componentName) - } - }, - clearCache() { - this.cacheTabList.clear() - }, - resetState() { - this.cacheTabList = new Set() - this.tabList = [] - this.tasMap = {} - this.indexRouteName = '' - }, - addTab(router: Router) { - const route = unref(router.currentRoute) - const { name, query, meta, params, fullPath, path } = route - if (isCannotAddRoute(route, router)) return - const hasTabIndex = getHasTabIndex(fullPath!, this.tabList) - const componentName = getComponentName(route) - const tabItem = { - name: name!, - path, - fullPath, - title: meta?.title, - query, - params - } - this.tasMap[fullPath] = tabItem - if (meta?.keepAlive) { - this.addCache(componentName) - } - if (hasTabIndex != -1) { - return - } + getCacheTabList(): string[] { + return Array.from(this.cacheTabList); + }, + }, + actions: { + setRouteName(name: RouteRecordName) { + this.indexRouteName = name; + }, + addCache(componentName?: string) { + if (componentName) this.cacheTabList.add(componentName); + }, + removeCache(componentName?: string) { + if (componentName && this.cacheTabList.has(componentName)) { + this.cacheTabList.delete(componentName); + } + }, + clearCache() { + this.cacheTabList.clear(); + }, + resetState() { + this.cacheTabList = new Set(); + this.tabList = []; + this.tasMap = {}; + this.indexRouteName = ""; + }, + addTab(router: Router) { + const route = unref(router.currentRoute); + const { name, query, meta, params, fullPath, path } = route; + if (isCannotAddRoute(route, router)) return; + const hasTabIndex = getHasTabIndex(fullPath!, this.tabList); + const componentName = getComponentName(route); + const tabItem = { + name: name!, + path, + fullPath, + title: meta?.title, + query, + params, + }; + this.tasMap[fullPath] = tabItem; + if (meta?.keepAlive) { + this.addCache(componentName); + } + if (hasTabIndex != -1) { + return; + } - this.tabList.push(tabItem) - }, - removeTab(fullPath: string, router: Router) { - const { currentRoute, push } = router - const index = findTabsIndex(fullPath, this.tabList) - // 移除tab - if (this.tabList.length > 1) { - index !== -1 && this.tabList.splice(index, 1) - } - const componentName = getComponentName(currentRoute.value) - this.removeCache(componentName) - if (fullPath !== currentRoute.value.fullPath) { - return - } - // 删除选中的tab - let toTab: TabItem | null = null + this.tabList.push(tabItem); + }, + removeTab(fullPath: string, router: Router) { + const { currentRoute, push } = router; + const index = findTabsIndex(fullPath, this.tabList); + // 移除tab + if (this.tabList.length > 1) { + index !== -1 && this.tabList.splice(index, 1); + } + const componentName = getComponentName(currentRoute.value); + this.removeCache(componentName); + if (fullPath !== currentRoute.value.fullPath) { + return; + } + // 删除选中的tab + let toTab: TabItem | null = null; - if (index === 0) { - toTab = this.tabList[index] - } else { - toTab = this.tabList[index - 1] - } + if (index === 0) { + toTab = this.tabList[index]; + } else { + toTab = this.tabList[index - 1]; + } - const toRoute = getRouteParams(toTab) - push(toRoute) - }, - removeOtherTab(route: RouteLocationNormalized) { - this.tabList = this.tabList.filter((item) => item.fullPath == route.fullPath) - const componentName = getComponentName(route) - this.cacheTabList.forEach((name) => { - if (componentName !== name) { - this.removeCache(name) - } - }) - }, - removeAllTab(router: Router) { - const { push, currentRoute } = router - const { name } = unref(currentRoute) - if (name == this.indexRouteName) { - this.removeOtherTab(currentRoute.value) - return - } - this.tabList = [] - this.clearCache() - push(PageEnum.INDEX) + const toRoute = getRouteParams(toTab); + push(toRoute); + }, + removeOtherTab(route: RouteLocationNormalized) { + this.tabList = this.tabList.filter( + (item) => item.fullPath == route.fullPath + ); + const componentName = getComponentName(route); + this.cacheTabList.forEach((name) => { + if (componentName !== name) { + this.removeCache(name); } - } -}) + }); + }, + removeAllTab(router: Router) { + const { push, currentRoute } = router; + const { name } = unref(currentRoute); + if (name == this.indexRouteName) { + this.removeOtherTab(currentRoute.value); + return; + } + this.tabList = []; + this.clearCache(); + push(PageEnum.INDEX); + }, + }, +}); -export default useTabsStore +export default useTabsStore; diff --git a/src/views/oa_Initiate/detail.vue b/src/views/oa_Initiate/detail.vue index a44ff22..c475e68 100644 --- a/src/views/oa_Initiate/detail.vue +++ b/src/views/oa_Initiate/detail.vue @@ -1,40 +1,87 @@ - diff --git a/src/views/oa_Initiate/edit.vue b/src/views/oa_Initiate/edit.vue index 0ee7509..8f885a5 100644 --- a/src/views/oa_Initiate/edit.vue +++ b/src/views/oa_Initiate/edit.vue @@ -1,18 +1,14 @@ @@ -61,7 +57,6 @@ const setFormData = async (data: Record) => { // 提交按钮 const handleSubmit = async () => { - console.log(formData) await formRef.value?.validate(); const data = { ...formData }; await apiOaoaApproveAdd(data) diff --git a/src/views/oa_flow_type/edit.vue b/src/views/oa_flow_type/edit.vue index 5971628..966b2b8 100644 --- a/src/views/oa_flow_type/edit.vue +++ b/src/views/oa_flow_type/edit.vue @@ -1,6 +1,7 @@