diff --git a/src/service/api/myTasks.ts b/src/service/api/myTasks.ts index 7ba0742..3ec0993 100644 --- a/src/service/api/myTasks.ts +++ b/src/service/api/myTasks.ts @@ -6,4 +6,12 @@ export function myTasksListApi() { url: `/api/my-tasks`, method: 'get', }); +} +// 撤回 +export function myTasksWithdrawApi(id:number,data: {reason:string}) { + return request({ + url: `/api/changes/${id}/withdraw`, + method: 'post', + data, + }); } \ No newline at end of file diff --git a/src/views/my/pending/index.vue b/src/views/my/pending/index.vue index bfaba90..9694d87 100644 --- a/src/views/my/pending/index.vue +++ b/src/views/my/pending/index.vue @@ -4,27 +4,24 @@ import { Icon } from '@iconify/vue' import { useThemeStore } from '@/store/modules/theme'; import { useRouterPush } from '@/hooks/common/router'; import { tagTextColor, tagBgColor, tagBorderColor } from '@/utils/common'; -import { myTasksListApi } from '@/service/api/myTasks'; import { systemConfigApi } from '@/service/api/system'; +import { myTasksListApi, myTasksWithdrawApi } from '@/service/api/myTasks'; const themeStore = useThemeStore(); const { routerPushByKey } = useRouterPush(); -const emit = defineEmits<{ go: [v: string, preset?: string];}>(); -interface MyChange { - id: string;title: string;status: string;detail: string;applyTime: string;updateTime: string; - level: "重要" | "一般"; dur: "永久" | "临时"; urgent?: boolean;deadline?: string; - stage: string; meta: string; left?: number; extended?: boolean; - node?: string; members?: { name: string; done: boolean }[]; -} const loading = ref(false); +// 当前行 const currentRow = ref(null); +// 进度抽屉 const progressDrawer = ref(false); +// 撤回弹框 const revokeModal = ref(false); const revokeSaving = ref(false); +// 撤回原因 const revokeReason = ref(""); +// 处置申请弹框 const disposalModal = ref(false); - // 变更类型 const typeList = ref([]); // 变更等级 @@ -67,25 +64,7 @@ const tabChange = (k: string) => { } }; -const stages = ["提交申请", "审批", "实施与投用前确认", "投用", "验收", "关闭"]; -const curIdx = computed(() => ({ 审批中: 1, 已批准: 2, 实施中: 2, 待PSSR: 2, 待验收: 4, 待关闭: 5, 已关闭: 6 } as Record)[currentRow.value?.status ?? ""] ?? 1); -const closed = computed(() => currentRow.value?.status === "已关闭"); -const timeOf = (i: number) => (i === 0 ? currentRow.value?.applyTime : i === 3 ? currentRow.value?.actualUse : i === 5 ? currentRow.value?.closeTime : undefined); - -interface SubOrder { - id: string; // 子单号:原单号-Y1(延期)/ -Z1(转永久) - parentId: string; // 原变更单号 - parentTitle: string; - kind: "extend" | "permanent"; - applicant: string; - reason: string; - newDeadline?: string; // 延期子单:申请延期至 - status: "审批中" | "已通过" | "已驳回"; - submitTime: string; - steps: { role: string; name: string; done: boolean }[]; // 会签:全员同意即通过 - rejectNote?: string; -} -const SUB_ORDERS: SubOrder[] = []; +const SUB_ORDERS: any[] = []; const subsOf = (id: string) => SUB_ORDERS.filter((s:any) => s.parentId === id); const pendingSubs = computed(() => subsOf(currentRow.value?.id).filter((s:any) => s.status === "审批中")); interface Opt { act: any; name: string; desc: string; disabled?: boolean; note?: string } @@ -110,22 +89,11 @@ const opts = computed(() => { }); // 打开详情 -const openDetail = (c: MyChange,type:string = '') => { +const openDetail = (c: any) => { routerPushByKey("my_highriskdetail",{ query: { id: c.id.toString() } }); }; -// 打开进度 -const openProgress = (c: any) => { - currentRow.value = c; - progressDrawer.value = true; -}; -// 打开撤回 -const openWithdraw = (c: MyChange) => { - revokeReason.value = ""; - currentRow.value = c; - revokeModal.value = true; -}; // 打开处置申请、修改重报 -const openDisposal = (c: MyChange,type:string = '') => { +const openDisposal = (c: any,type:string = '') => { currentRow.value = c; if(type==='reject'){ window.$message?.info("该任务暂无处置申请"); @@ -134,33 +102,37 @@ const openDisposal = (c: MyChange,type:string = '') => { disposalModal.value = true; }; // 打开资料关闭、关闭变更 -const openClosure = (c: MyChange,type:string = '') => { +const openClosure = (c: any,type:string = '') => { if(type==='reject'){ window.$message?.info("关闭该变更(驳回后不再推进,流程终止并归档备查)"); return; } }; -// 撤回取消 -const revokeCancel = () => { - revokeModal.value = false; + +// 打开进度 +const openProgress = (c: any) => { + currentRow.value = c; + progressDrawer.value = true; +}; +// 打开撤回 +const openWithdraw = (c: any) => { + revokeReason.value = ""; + currentRow.value = c; + revokeModal.value = true; }; // 撤回确认 -const revokeSave = () => { +const revokeSave = async () => { if (!revokeReason.value) { - window.$message?.warning("请填写撤回理由"); - return; + return window.$message?.warning("请填写撤回理由"); } revokeSaving.value = true; - setTimeout(() => { - revokeSaving.value = false; + const {error} = await myTasksWithdrawApi(currentRow.value?.change_id,{reason:revokeReason.value}); + if(!error){ revokeModal.value = false; - const pendingGroup = list.value.find((item: any) => item.status === 'approval'); - if (pendingGroup) { - // 过滤掉匹配 targetId 的项 - pendingGroup.list = pendingGroup.list.filter((item:any) => item.id !== currentRow.value?.id); - } - window.$message?.success(`已撤回 ${currentRow.value?.id},申请退回草稿箱,审批记录保留可查,修改后可重新提交`); - }, 1000); + window.$message?.success(`撤回成功,申请退回草稿箱,审批记录保留可查,修改后可重新提交`); + getList(); + } + revokeSaving.value = false; }; // 匹配变更等级 @@ -190,8 +162,7 @@ const getList = async () => { const {data,error} = await myTasksListApi(); if(!error){ dataSource.value = data; - list.value = resetGrouped([...dataSource.value.my_applications,...dataSource.value.todo]); - console.log(data) + tabChange(currentTab.value); // 统计数量 // 全部 tabCount.value["all"] = [...dataSource.value.my_applications,...dataSource.value.todo].length; @@ -416,7 +387,7 @@ onMounted(() => {
- 详情 + 详情 进度 修改重报 关闭变更 @@ -493,7 +464,7 @@ onMounted(() => {