admin-vben5/apps/web-antd/src/views/workflow/task/taskWaiting.vue

139 lines
4.1 KiB
Vue
Raw Normal View History

2024-08-07 08:57:56 +08:00
<script setup lang="ts">
2024-11-21 19:53:16 +08:00
import { reactive, ref } from 'vue';
2024-11-21 17:02:22 +08:00
2024-11-21 16:29:40 +08:00
import { Page } from '@vben/common-ui';
import {
Alert,
Avatar,
Card,
Divider,
2024-11-21 19:53:16 +08:00
InputSearch,
2024-11-21 16:29:40 +08:00
Space,
TabPane,
Tabs,
Tag,
} from 'ant-design-vue';
2024-11-21 19:21:20 +08:00
import { debounce, uniqueId } from 'lodash-es';
2024-11-21 16:29:40 +08:00
import { ApprovalCard } from '../components';
2024-11-21 17:02:22 +08:00
const handleScroll = debounce((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;
console.log(isBottom);
// console.log(scrollTop + clientHeight);
// console.log(scrollHeight);
}, 200);
2024-11-21 19:21:20 +08:00
const data = reactive(
Array.from({ length: 10 }).map(() => ({
id: uniqueId(),
startTime: '2022-01-01',
endTime: '2022-01-02',
title: '审批任务',
desc: '审批任务描述',
status: '审批中',
active: false,
})),
);
2024-11-21 19:53:16 +08:00
const lastSelectId = ref('');
2024-11-21 19:21:20 +08:00
function handleCardClick(id: string) {
2024-11-21 19:53:16 +08:00
// 点击的是同一个
if (lastSelectId.value === id) {
return;
}
// 反选状态 & 如果已经点击了 不变 & 保持只能有一个选中
2024-11-21 19:21:20 +08:00
data.forEach((item) => {
2024-11-21 19:53:16 +08:00
item.active = item.id === id;
2024-11-21 19:21:20 +08:00
});
2024-11-21 19:53:16 +08:00
lastSelectId.value = id;
2024-11-21 19:21:20 +08:00
}
2024-08-07 08:57:56 +08:00
</script>
<template>
2024-11-21 16:29:40 +08:00
<Page :auto-content-height="true">
<div class="flex h-full gap-2">
2024-11-21 19:53:16 +08:00
<div class="bg-background flex h-full 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="flex flex-1 flex-col gap-2 overflow-y-auto py-3"
@scroll="handleScroll"
>
2024-11-21 16:29:40 +08:00
<ApprovalCard
2024-11-21 19:21:20 +08:00
v-for="item in data"
:key="item.id"
:info="item"
2024-11-21 16:29:40 +08:00
class="mx-2"
2024-11-21 19:21:20 +08:00
@click="handleCardClick"
2024-11-21 16:29:40 +08:00
/>
</div>
2024-11-21 19:53:16 +08:00
<!-- 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">
{{ data.length }} 条记录
</div>
</div>
2024-11-21 16:29:40 +08:00
</div>
<Card class="flex-1" size="small" title="编号: 1234567890123456789012">
<div class="flex flex-col gap-5 p-4">
<div class="flex flex-col gap-3">
<div class="flex items-center gap-2">
<div class="text-2xl font-bold">报销申请</div>
<div>
<Tag color="warning">申请中</Tag>
</div>
</div>
<div class="flex items-center gap-2">
<Avatar
size="small"
src="https://plus.dapdap.top/minio-server/plus/2024/11/21/925ed278e2d441beb7f695b41e13c4dd.jpg"
/>
<span>疯狂的牛子Li</span>
<div class="flex items-center opacity-50">
<span>XXXX有限公司</span>
<Divider type="vertical" />
<span>提交于: 2022-01-01 12:00:00</span>
</div>
</div>
</div>
<Tabs>
<TabPane key="1" tab="审批详情">
<Alert message="该页面仅为静态页 后期可能会用到!" type="info" />
</TabPane>
<TabPane key="2" tab="审批记录">审批记录</TabPane>
<TabPane key="3" tab="全文评论(999+)">全文评论</TabPane>
</Tabs>
</div>
<!-- 固定底部 -->
<div
2024-11-21 19:53:16 +08:00
class="border-t-solid absolute bottom-0 left-0 w-full border-t-[1px] p-3"
2024-11-21 16:29:40 +08:00
>
<div class="flex justify-end">
<Space>
<a-button type="primary">通过</a-button>
<a-button danger type="primary">驳回</a-button>
<a-button>其他</a-button>
</Space>
</div>
</div>
</Card>
</div>
</Page>
2024-08-07 08:57:56 +08:00
</template>