chore: 我发起的
This commit is contained in:
parent
af8052ce49
commit
58dac45dde
@ -1,16 +1,27 @@
|
|||||||
|
<!-- eslint-disable no-use-before-define -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FlowInfoResponse } from '#/api/workflow/instance/model';
|
|
||||||
import type { TaskInfo } from '#/api/workflow/task/model';
|
import type { TaskInfo } from '#/api/workflow/task/model';
|
||||||
|
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, onMounted, ref, useTemplateRef } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
import { useTabs } from '@vben/hooks';
|
import { useTabs } from '@vben/hooks';
|
||||||
|
import { getPopupContainer } from '@vben/utils';
|
||||||
|
|
||||||
import { Empty, InputSearch } from 'ant-design-vue';
|
import { FilterOutlined, RedoOutlined } from '@ant-design/icons-vue';
|
||||||
import { debounce } from 'lodash-es';
|
import {
|
||||||
|
Empty,
|
||||||
|
Form,
|
||||||
|
FormItem,
|
||||||
|
Input,
|
||||||
|
InputSearch,
|
||||||
|
Popover,
|
||||||
|
Spin,
|
||||||
|
Tooltip,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
import { cloneDeep, debounce } from 'lodash-es';
|
||||||
|
|
||||||
import { flowInfo, pageByCurrent } from '#/api/workflow/instance';
|
import { pageByCurrent } from '#/api/workflow/instance';
|
||||||
|
|
||||||
import { ApprovalCard, ApprovalPanel } from '../components';
|
import { ApprovalCard, ApprovalPanel } from '../components';
|
||||||
|
|
||||||
@ -19,6 +30,15 @@ const emptyImage = Empty.PRESENTED_IMAGE_SIMPLE;
|
|||||||
const taskList = ref<({ active: boolean } & TaskInfo)[]>([]);
|
const taskList = ref<({ active: boolean } & TaskInfo)[]>([]);
|
||||||
const taskTotal = ref(0);
|
const taskTotal = ref(0);
|
||||||
const page = ref(1);
|
const page = ref(1);
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
const defaultFormData = {
|
||||||
|
flowName: '', // 流程定义名称
|
||||||
|
nodeName: '', // 任务名称
|
||||||
|
flowCode: '', // 流程定义编码
|
||||||
|
category: null as null | number, // 流程分类
|
||||||
|
};
|
||||||
|
const formData = ref(cloneDeep(defaultFormData));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否已经加载全部数据 即 taskList.length === taskTotal
|
* 是否已经加载全部数据 即 taskList.length === taskTotal
|
||||||
@ -27,14 +47,44 @@ const isLoadComplete = computed(
|
|||||||
() => taskList.value.length === taskTotal.value,
|
() => taskList.value.length === taskTotal.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(async () => {
|
// 卡片父容器的ref
|
||||||
/**
|
const cardContainerRef = useTemplateRef('cardContainerRef');
|
||||||
* 获取待办任务列表
|
|
||||||
*/
|
/**
|
||||||
const resp = await pageByCurrent({ pageSize: 10, pageNum: page.value });
|
* @param resetFields 是否清空查询参数
|
||||||
|
*/
|
||||||
|
async function reload(resetFields: boolean = false) {
|
||||||
|
// 需要先滚动到顶部
|
||||||
|
cardContainerRef.value?.scroll({ top: 0, behavior: 'auto' });
|
||||||
|
|
||||||
|
page.value = 1;
|
||||||
|
currentTask.value = undefined;
|
||||||
|
taskTotal.value = 0;
|
||||||
|
lastSelectId.value = '';
|
||||||
|
|
||||||
|
if (resetFields) {
|
||||||
|
formData.value = cloneDeep(defaultFormData);
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true;
|
||||||
|
const resp = await pageByCurrent({
|
||||||
|
pageSize: 10,
|
||||||
|
pageNum: page.value,
|
||||||
|
...formData.value,
|
||||||
|
});
|
||||||
taskList.value = resp.rows.map((item) => ({ ...item, active: false }));
|
taskList.value = resp.rows.map((item) => ({ ...item, active: false }));
|
||||||
taskTotal.value = resp.total;
|
taskTotal.value = resp.total;
|
||||||
});
|
|
||||||
|
loading.value = false;
|
||||||
|
// 默认选中第一个
|
||||||
|
if (taskList.value.length > 0) {
|
||||||
|
const firstTask = taskList.value[0]!;
|
||||||
|
currentTask.value = firstTask;
|
||||||
|
handleCardClick(firstTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(reload);
|
||||||
|
|
||||||
const handleScroll = debounce(async (e: Event) => {
|
const handleScroll = debounce(async (e: Event) => {
|
||||||
if (!e.target) {
|
if (!e.target) {
|
||||||
@ -49,20 +99,24 @@ const handleScroll = debounce(async (e: Event) => {
|
|||||||
|
|
||||||
// 滚动到底部且没有加载完成
|
// 滚动到底部且没有加载完成
|
||||||
if (isBottom && !isLoadComplete.value) {
|
if (isBottom && !isLoadComplete.value) {
|
||||||
|
loading.value = true;
|
||||||
page.value += 1;
|
page.value += 1;
|
||||||
const resp = await pageByCurrent({ pageSize: 10, pageNum: page.value });
|
const resp = await pageByCurrent({
|
||||||
|
pageSize: 10,
|
||||||
|
pageNum: page.value,
|
||||||
|
...formData.value,
|
||||||
|
});
|
||||||
taskList.value.push(
|
taskList.value.push(
|
||||||
...resp.rows.map((item) => ({ ...item, active: false })),
|
...resp.rows.map((item) => ({ ...item, active: false })),
|
||||||
);
|
);
|
||||||
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
const currentInstance = ref<FlowInfoResponse>();
|
|
||||||
|
|
||||||
const lastSelectId = ref('');
|
const lastSelectId = ref('');
|
||||||
const currentTask = ref<TaskInfo>();
|
const currentTask = ref<TaskInfo>();
|
||||||
async function handleCardClick(item: TaskInfo) {
|
async function handleCardClick(item: TaskInfo) {
|
||||||
const { id, businessId } = item;
|
const { id } = item;
|
||||||
// 点击的是同一个
|
// 点击的是同一个
|
||||||
if (lastSelectId.value === id) {
|
if (lastSelectId.value === id) {
|
||||||
return;
|
return;
|
||||||
@ -73,9 +127,6 @@ async function handleCardClick(item: TaskInfo) {
|
|||||||
item.active = item.id === id;
|
item.active = item.id === id;
|
||||||
});
|
});
|
||||||
lastSelectId.value = id;
|
lastSelectId.value = id;
|
||||||
|
|
||||||
const resp = await flowInfo(businessId);
|
|
||||||
currentInstance.value = resp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { refreshTab } = useTabs();
|
const { refreshTab } = useTabs();
|
||||||
@ -85,15 +136,72 @@ const { refreshTab } = useTabs();
|
|||||||
<Page :auto-content-height="true">
|
<Page :auto-content-height="true">
|
||||||
<div class="flex h-full gap-2">
|
<div class="flex h-full gap-2">
|
||||||
<div
|
<div
|
||||||
class="bg-background flex h-full min-w-[320px] max-w-[320px] flex-col rounded-lg"
|
class="bg-background relative flex h-full min-w-[320px] max-w-[320px] flex-col rounded-lg"
|
||||||
>
|
>
|
||||||
<!-- 搜索条件 -->
|
<!-- 搜索条件 -->
|
||||||
<div
|
<div
|
||||||
class="bg-background z-100 sticky left-0 top-0 w-full rounded-t-lg border-b-[1px] border-solid p-2"
|
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 class="flex items-center gap-1">
|
||||||
|
<InputSearch
|
||||||
|
v-model:value="formData.flowName"
|
||||||
|
placeholder="流程名称搜索"
|
||||||
|
@search="reload(false)"
|
||||||
|
/>
|
||||||
|
<Tooltip placement="top" title="重置">
|
||||||
|
<a-button @click="reload(true)">
|
||||||
|
<RedoOutlined />
|
||||||
|
</a-button>
|
||||||
|
</Tooltip>
|
||||||
|
<Popover
|
||||||
|
:get-popup-container="getPopupContainer"
|
||||||
|
placement="rightTop"
|
||||||
|
trigger="click"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<div class="w-full border-b pb-[12px] text-[16px]">搜索</div>
|
||||||
|
</template>
|
||||||
|
<template #content>
|
||||||
|
<Form
|
||||||
|
:colon="false"
|
||||||
|
:label-col="{ span: 6 }"
|
||||||
|
:model="formData"
|
||||||
|
autocomplete="off"
|
||||||
|
class="w-[300px]"
|
||||||
|
@finish="() => reload(false)"
|
||||||
|
>
|
||||||
|
<FormItem label="任务名称">
|
||||||
|
<Input
|
||||||
|
v-model:value="formData.nodeName"
|
||||||
|
placeholder="请输入"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="流程编码">
|
||||||
|
<Input
|
||||||
|
v-model:value="formData.flowCode"
|
||||||
|
placeholder="请输入"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem>
|
||||||
|
<div class="flex">
|
||||||
|
<a-button block html-type="submit" type="primary">
|
||||||
|
搜索
|
||||||
|
</a-button>
|
||||||
|
<a-button block class="ml-2" @click="reload(true)">
|
||||||
|
重置
|
||||||
|
</a-button>
|
||||||
|
</div>
|
||||||
|
</FormItem>
|
||||||
|
</Form>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
<FilterOutlined />
|
||||||
|
</a-button>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
ref="cardContainerRef"
|
||||||
class="thin-scrollbar flex flex-1 flex-col gap-2 overflow-y-auto py-3"
|
class="thin-scrollbar flex flex-1 flex-col gap-2 overflow-y-auto py-3"
|
||||||
@scroll="handleScroll"
|
@scroll="handleScroll"
|
||||||
>
|
>
|
||||||
@ -107,6 +215,19 @@ const { refreshTab } = useTabs();
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<Empty v-else :image="emptyImage" />
|
<Empty v-else :image="emptyImage" />
|
||||||
|
<div
|
||||||
|
v-if="isLoadComplete && taskList.length > 0"
|
||||||
|
class="flex items-center justify-center text-[14px] opacity-50"
|
||||||
|
>
|
||||||
|
没有更多数据了
|
||||||
|
</div>
|
||||||
|
<!-- 遮罩loading层 -->
|
||||||
|
<div
|
||||||
|
v-if="loading"
|
||||||
|
class="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-[rgba(0,0,0,0.1)]"
|
||||||
|
>
|
||||||
|
<Spin tip="加载中..." />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- total显示 -->
|
<!-- total显示 -->
|
||||||
<div
|
<div
|
||||||
|
Loading…
Reference in New Issue
Block a user