2024-11-14 13:43:41 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
2024-11-19 09:55:07 +08:00
|
|
|
<div class="header">
|
|
|
|
<SvgIcon size="19" name="list" />
|
2024-11-19 12:15:56 +08:00
|
|
|
<div class="title">任务列表</div>
|
2024-11-19 09:55:07 +08:00
|
|
|
</div>
|
2024-11-14 13:43:41 +08:00
|
|
|
<BasicTable @register="registerTable">
|
|
|
|
<template #toolbar>
|
2024-11-19 09:55:07 +08:00
|
|
|
<a-button type="primary" @click="handleCreate" :icon="h(PlusOutlined)">新增</a-button>
|
2024-11-14 13:43:41 +08:00
|
|
|
</template>
|
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
|
<template v-if="column.dataIndex === 'action'">
|
|
|
|
<TableAction
|
|
|
|
:actions="[
|
|
|
|
{
|
|
|
|
label: '编辑',
|
|
|
|
icon: 'clarity:note-edit-line',
|
|
|
|
onClick: handleEdit.bind(null, record),
|
2024-11-15 17:30:24 +08:00
|
|
|
divider: true,
|
2024-11-14 13:43:41 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '删除',
|
|
|
|
icon: 'ant-design:delete-outlined',
|
|
|
|
color: 'error',
|
|
|
|
popConfirm: {
|
|
|
|
title: '是否确认删除',
|
|
|
|
confirm: handleDelete.bind(null, record),
|
|
|
|
placement: 'topRight',
|
|
|
|
},
|
2024-11-15 17:30:24 +08:00
|
|
|
ifShow: hasPermission('AUTH_DATA_TASK:DELETE'),
|
2024-11-14 13:43:41 +08:00
|
|
|
},
|
2024-11-19 09:55:07 +08:00
|
|
|
{
|
|
|
|
label: '详情',
|
|
|
|
icon: 'ant-design:eye-outlined',
|
|
|
|
onClick: handleView.bind(null, record),
|
|
|
|
divider: true
|
|
|
|
},
|
2024-11-14 13:43:41 +08:00
|
|
|
]"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</BasicTable>
|
2024-11-15 17:30:24 +08:00
|
|
|
<TaskDrawer @register="registerDrawer" @success="handleSuccess" />
|
2024-11-14 13:43:41 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
2024-11-15 17:30:24 +08:00
|
|
|
import { useGo } from '@/hooks/web/usePage';
|
2024-11-14 13:43:41 +08:00
|
|
|
import { usePermission } from '@/hooks/web/usePermission';
|
|
|
|
import { BasicTable, useTable, TableAction } from '@/components/Table';
|
|
|
|
import { isObject } from '@/utils/is';
|
|
|
|
import dayjs from 'dayjs';
|
2024-11-15 17:30:24 +08:00
|
|
|
import * as TaskApi from '@/api/data/taskApi';
|
2024-11-14 13:43:41 +08:00
|
|
|
import { useDrawer } from '@/components/Drawer';
|
2024-11-15 17:30:24 +08:00
|
|
|
import TaskDrawer from './drawer.vue';
|
2024-11-14 13:43:41 +08:00
|
|
|
import { columns, searchFormSchema } from './schema';
|
|
|
|
import { useMessage } from "@/hooks/web/useMessage";
|
2024-11-19 09:55:07 +08:00
|
|
|
import {SvgIcon} from "@/components/Icon";
|
|
|
|
import {h} from "vue";
|
|
|
|
import {PlusOutlined} from "@ant-design/icons-vue";
|
2024-11-14 13:43:41 +08:00
|
|
|
|
|
|
|
const { createMessage } = useMessage();
|
|
|
|
const { hasPermission } = usePermission();
|
|
|
|
const go = useGo();
|
|
|
|
|
|
|
|
const [registerDrawer, { openDrawer }] = useDrawer();
|
2024-11-19 10:56:01 +08:00
|
|
|
const [registerTable, { reload }] = useTable({
|
2024-11-15 17:30:24 +08:00
|
|
|
api: (params) => TaskApi.search(handleParams(params)),
|
2024-11-14 13:43:41 +08:00
|
|
|
columns,
|
|
|
|
formConfig: {
|
2024-11-19 09:55:07 +08:00
|
|
|
labelWidth: 0,
|
2024-11-14 13:43:41 +08:00
|
|
|
schemas: searchFormSchema,
|
|
|
|
showAdvancedButton: false,
|
|
|
|
},
|
|
|
|
useSearchForm: true,
|
|
|
|
showTableSetting: false,
|
2024-11-19 09:55:07 +08:00
|
|
|
bordered: true,
|
2024-11-14 13:43:41 +08:00
|
|
|
showIndexColumn: false,
|
|
|
|
canResize: false,
|
|
|
|
rowKey: (record: any) => record.id,
|
|
|
|
actionColumn: {
|
2024-11-19 09:55:07 +08:00
|
|
|
width: 250,
|
2024-11-14 13:43:41 +08:00
|
|
|
title: '操作',
|
|
|
|
dataIndex: 'action',
|
2024-11-19 09:55:07 +08:00
|
|
|
fixed: undefined,
|
2024-11-14 13:43:41 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-11-15 17:30:24 +08:00
|
|
|
const handleParams = (params) => {
|
2024-11-14 13:43:41 +08:00
|
|
|
const { pageNum, pageSize, field = 'id', order = 'descend', ...rest } = params;
|
|
|
|
const handledParams: any = { pageNum, pageSize, orderByClause: `${field} ${order === 'descend' ? 'desc' : 'asc'}` };
|
|
|
|
Object.keys(rest).forEach((key) => {
|
|
|
|
const schema = searchFormSchema.find((item) => item.field === key);
|
|
|
|
const value = params[key];
|
2024-11-19 09:55:07 +08:00
|
|
|
let paramKey = key;
|
2024-11-14 13:43:41 +08:00
|
|
|
if (schema) {
|
|
|
|
if (value !== undefined && value !== '') {
|
|
|
|
if (schema.component === 'Input') {
|
2024-11-15 17:30:24 +08:00
|
|
|
handledParams[paramKey] = `%${value.trim()}%`;
|
2024-11-14 13:43:41 +08:00
|
|
|
} else if (['Select', 'ApiSelect', 'ApiTreeSelect'].includes(schema.component)) {
|
|
|
|
handledParams[paramKey] = isObject(value) ? value.value : value;
|
|
|
|
} else if (schema.component === 'RangePicker') {
|
2024-11-19 09:55:07 +08:00
|
|
|
if (paramKey === 'startTimeQuery') {
|
|
|
|
paramKey = 'startTime';
|
|
|
|
}
|
2024-11-14 13:43:41 +08:00
|
|
|
handledParams[`${paramKey}From`] = dayjs(value[0]).startOf('d').format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
handledParams[`${paramKey}To`] = dayjs(value[1]).endOf('d').format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
} else if (schema.component === 'DatePicker') {
|
|
|
|
handledParams[paramKey] = dayjs(value).format((schema.componentProps as any).format || 'YYYY-MM-DD');
|
|
|
|
} else {
|
|
|
|
handledParams[paramKey] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
handledParams[paramKey] = value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return handledParams;
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleCreate = () => {
|
|
|
|
openDrawer(true, {
|
|
|
|
isUpdate: false,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleEdit = (record: Recordable) => {
|
|
|
|
openDrawer(true, {
|
|
|
|
record,
|
|
|
|
isUpdate: true,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleDelete = (record: Recordable) => {
|
2024-11-15 17:30:24 +08:00
|
|
|
TaskApi.remove(record.id).then((_) => {
|
2024-11-14 13:43:41 +08:00
|
|
|
reload();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleSuccess = () => {
|
|
|
|
reload();
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleView = (record) => {
|
2024-11-19 10:56:01 +08:00
|
|
|
go('/data/task/' + record.id);
|
2024-11-14 13:43:41 +08:00
|
|
|
};
|
|
|
|
</script>
|
2024-11-15 17:30:24 +08:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
@use '@/assets/custom.scss';
|
|
|
|
</style>
|