index.vue
3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<script setup lang="ts">
import { Button, List, Tooltip } from 'ant-design-vue';
import { PageWrapper } from '/@/components/Page';
import { BasicForm, useForm } from '/@/components/Form';
import { formSchemas } from './config';
import { TaskCard } from './components/TaskCard';
import { getTaskCenterList } from '/@/api/task';
import { ref } from 'vue';
import { onMounted } from 'vue';
import { DetailModal } from './components/DetailModal';
import { useModal } from '/@/components/Modal';
import { TaskRecordType } from '/@/api/task/model';
import { reactive } from 'vue';
import { ReloadOutlined } from '@ant-design/icons-vue';
import { DataActionModeEnum } from '/@/enums/toolEnum';
import { ModalParamsType } from '/#/utils';
const [registerModal, { openModal }] = useModal();
const [registerForm, { getFieldsValue }] = useForm({
schemas: formSchemas,
baseColProps: { span: 8 },
compact: true,
showAdvancedButton: true,
labelWidth: 100,
submitFunc: async () => {
pagination.params = getFieldsValue();
getDataSource();
},
});
const pagination = reactive({
total: 10,
current: 1,
showQuickJumper: true,
size: 'small',
showTotal: (total: number) => `共 ${total} 条数据`,
params: {} as Recordable,
});
const dataSource = ref<TaskRecordType[]>([]);
const loading = ref(false);
const getDataSource = async () => {
try {
loading.value = true;
const { items } = await getTaskCenterList({ page: 1, pageSize: 10, ...pagination.params });
dataSource.value = items;
} catch (error) {
throw error;
} finally {
loading.value = false;
}
};
const handleEdit = (record: TaskRecordType) => {
openModal(true, {
record,
mode: DataActionModeEnum.UPDATE,
} as ModalParamsType);
};
const reload = () => getDataSource();
onMounted(() => {
getDataSource();
});
</script>
<template>
<PageWrapper class="container">
<section
class="bg-light-50 flex p-4 justify-between items-center x dark:text-gray-300 dark:bg-dark-900"
>
<div class="text-2xl">任务</div>
<Button
type="primary"
@click="openModal(true, { mode: DataActionModeEnum.CREATE } as ModalParamsType)"
>创建任务</Button
>
</section>
<section
class="form-container bg-light-50 px-4 pt-4 mt-4 x dark:text-gray-300 dark:bg-dark-900"
>
<BasicForm @register="registerForm" />
</section>
<section class="bg-light-50 mt-4 p-4 x dark:text-gray-300 dark:bg-dark-900">
<List
:dataSource="dataSource"
:pagination="pagination"
:grid="{ gutter: 16, xs: 1, sm: 1, md: 2, lg: 3, xl: 3, xxl: 4, column: 4 }"
:loading="loading"
>
<template #header>
<section class="flex justify-end gap-4">
<!-- <CardLayoutButton /> -->
<Tooltip title="刷新">
<Button type="primary" @click="getDataSource">
<ReloadOutlined :spin="loading" />
</Button>
</Tooltip>
</section>
</template>
<template #renderItem="{ item }">
<List.Item :key="item.id">
<TaskCard :record="item" :reload="reload" @edit="handleEdit" />
</List.Item>
</template>
</List>
</section>
<DetailModal @register="registerModal" :reload="reload" />
</PageWrapper>
</template>
<style lang="less" scoped></style>