chore: 我发起的

This commit is contained in:
dap 2024-12-16 15:19:15 +08:00
parent 75b766eeba
commit 1c9ea51780
4 changed files with 183 additions and 13 deletions

View File

@ -1,6 +1,7 @@
import type { TaskInfo } from '../task/model';
import type { FlowInfoResponse } from './model';
import type { ID, IDS, PageQuery } from '#/api/common';
import type { ID, IDS, PageQuery, PageResult } from '#/api/common';
import { requestClient } from '#/api/request';
@ -67,10 +68,13 @@ export function workflowInstanceActive(instanceId: ID, active: boolean) {
/**
*
* @param params
* @returns
* @returns PageResult<Flow>
*/
export function pageByCurrent(params?: PageQuery) {
return requestClient.get('/workflow/instance/current', { params });
return requestClient.get<PageResult<TaskInfo>>(
'/workflow/instance/pageByCurrent',
{ params },
);
}
/**

View File

@ -2,12 +2,19 @@
import type { FlowInfoResponse } from '#/api/workflow/instance/model';
import type { TaskInfo } from '#/api/workflow/task/model';
import { onUnmounted, ref, watch } from 'vue';
import { computed, onUnmounted, ref, watch } from 'vue';
import { Fallback, VbenAvatar } from '@vben/common-ui';
import { DictEnum } from '@vben/constants';
import { Card, Divider, Space, TabPane, Tabs } from 'ant-design-vue';
import {
Card,
Divider,
Popconfirm,
Space,
TabPane,
Tabs,
} from 'ant-design-vue';
import { flowInfo } from '#/api/workflow/instance';
import { renderDict } from '#/utils/render';
@ -19,7 +26,27 @@ defineOptions({
inheritAttrs: false,
});
const props = defineProps<{ task?: TaskInfo }>();
// eslint-disable-next-line no-use-before-define
const props = defineProps<{ task?: TaskInfo; type: ApprovalType }>();
/**
* myself 我发起的
* readonly 只读 只用于查看
*/
type ApprovalType = 'myself' | 'readonly';
const showFooter = computed(() => {
if (props.type === 'readonly') {
return false;
}
// && [, ]
if (
props.type === 'myself' &&
['finish', 'invalid'].includes(props.task?.flowStatus ?? '')
) {
return false;
}
return true;
});
const currentFlowInfo = ref<FlowInfoResponse>();
/**
@ -43,6 +70,10 @@ async function handleLoadInfo(task: TaskInfo | undefined) {
watch(() => props.task, handleLoadInfo);
onUnmounted(() => (currentFlowInfo.value = undefined));
async function handleCancel() {
// await cancelProcessApply()
}
</script>
<template>
@ -102,11 +133,22 @@ onUnmounted(() => (currentFlowInfo.value = undefined));
</Tabs>
</div>
<!-- 固定底部 -->
<div class="h-[57px]"></div>
<div
v-if="showFooter"
class="border-t-solid bg-background absolute bottom-0 left-0 w-full border-t-[1px] p-3"
>
<div class="flex justify-end">
<Space>
<Space v-if="type === 'myself'">
<Popconfirm
placement="topRight"
title="确定要撤销该申请吗?"
@confirm="handleCancel"
>
<a-button danger type="primary">撤销申请</a-button>
</Popconfirm>
</Space>
<Space v-if="false">
<a-button type="primary">通过</a-button>
<a-button danger type="primary">驳回</a-button>
<a-button>其他</a-button>

View File

@ -1,9 +1,133 @@
<script setup lang="ts">
import CommonSkeleton from '#/views/common';
import type { FlowInfoResponse } from '#/api/workflow/instance/model';
import type { TaskInfo } from '#/api/workflow/task/model';
import { computed, onMounted, ref } from 'vue';
import { Page } from '@vben/common-ui';
import { Empty, InputSearch } from 'ant-design-vue';
import { debounce } from 'lodash-es';
import { flowInfo, pageByCurrent } from '#/api/workflow/instance';
import { ApprovalCard, ApprovalPanel } from '../components';
const emptyImage = Empty.PRESENTED_IMAGE_SIMPLE;
const taskList = ref<({ active: boolean } & TaskInfo)[]>([]);
const taskTotal = ref(0);
const page = ref(1);
/**
* 是否已经加载全部数据 taskList.length === taskTotal
*/
const isLoadComplete = computed(
() => taskList.value.length === taskTotal.value,
);
onMounted(async () => {
/**
* 获取待办任务列表
*/
const resp = await pageByCurrent({ pageSize: 10, pageNum: page.value });
console.log(resp);
taskList.value = resp.rows.map((item) => ({ ...item, active: false }));
taskTotal.value = resp.total;
});
const handleScroll = debounce(async (e: Event) => {
if (!e.target) {
return;
}
// e.target.scrollTop
// e.target.clientHeight
// e.target.scrollHeight
const { scrollTop, clientHeight, scrollHeight } = e.target as HTMLElement;
//
const isBottom = scrollTop + clientHeight >= scrollHeight;
//
if (isBottom && !isLoadComplete.value) {
page.value += 1;
const resp = await pageByCurrent({ pageSize: 10, pageNum: page.value });
taskList.value.push(
...resp.rows.map((item) => ({ ...item, active: false })),
);
}
}, 200);
const currentInstance = ref<FlowInfoResponse>();
const lastSelectId = ref('');
const currentTask = ref<TaskInfo>();
async function handleCardClick(item: TaskInfo) {
const { id, businessId } = item;
//
if (lastSelectId.value === id) {
return;
}
currentTask.value = item;
// & &
taskList.value.forEach((item) => {
item.active = item.id === id;
});
lastSelectId.value = id;
const resp = await flowInfo(businessId);
currentInstance.value = resp;
}
</script>
<template>
<div>
<CommonSkeleton />
</div>
<Page :auto-content-height="true">
<div class="flex h-full gap-2">
<div
class="bg-background flex h-full min-w-[320px] max-w-[320px] flex-col rounded-lg"
>
<!-- 搜索条件 -->
<div
class="bg-background z-100 sticky left-0 top-0 w-full rounded-t-lg border-b-[1px] border-solid p-2"
>
<InputSearch placeholder="搜索还没做" />
</div>
<div
class="thin-scrollbar flex flex-1 flex-col gap-2 overflow-y-auto py-3"
@scroll="handleScroll"
>
<template v-if="taskList.length > 0">
<ApprovalCard
v-for="item in taskList"
:key="item.id"
:info="item"
class="mx-2"
@click="handleCardClick(item)"
/>
</template>
<Empty v-else :image="emptyImage" />
</div>
<!-- total显示 -->
<div
class="bg-background sticky bottom-0 w-full rounded-b-lg border-t-[1px] py-2"
>
<div class="flex items-center justify-center">
{{ taskList.length }} 条记录
</div>
</div>
</div>
<ApprovalPanel :task="currentTask" type="myself" />
</div>
</Page>
</template>
<style lang="scss" scoped>
.thin-scrollbar {
&::-webkit-scrollbar {
width: 5px;
}
}
:deep(.ant-card-body) {
@apply thin-scrollbar;
}
</style>

View File

@ -90,7 +90,7 @@ async function handleCardClick(item: TaskInfo) {
<div
class="bg-background z-100 sticky left-0 top-0 w-full rounded-t-lg border-b-[1px] border-solid p-2"
>
<InputSearch placeholder="搜索任务名称" />
<InputSearch placeholder="搜索还没做" />
</div>
<div
class="thin-scrollbar flex flex-1 flex-col gap-2 overflow-y-auto py-3"
@ -116,7 +116,7 @@ async function handleCardClick(item: TaskInfo) {
</div>
</div>
</div>
<ApprovalPanel :task="currentTask" />
<ApprovalPanel :task="currentTask" type="readonly" />
</div>
</Page>
</template>