Files
my-spring/web-vue/packages/biz/views/biz/myNoticeTodo/list.vue
2026-03-24 22:06:31 +08:00

268 lines
7.0 KiB
Vue

<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<template>
<div>
<BasicTable @register="registerTable">
<template #tableTitle>
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
<span> {{ getTitle.value }} </span>
</template>
<template #toolbar>
<a-button type="default" :loading="loading" @click="handleExport()">
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
</a-button>
<a-button type="primary" @click="handleForm({})" v-auth="'biz:myNoticeTodo:edit'">
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
</a-button>
</template>
<template #bizScopeKey="{ record, text, value }">
<a @click="handleForm({ id: record.id })" :title="value">
{{ text }}
</a>
</template>
</BasicTable>
<InputForm @register="registerDrawer" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup name="ViewsBizMyNoticeTodoList">
import { onMounted, ref, unref } from 'vue';
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
import { useGlobSetting } from '@jeesite/core/hooks/setting';
import { downloadByUrl } from '@jeesite/core/utils/file/download';
import { router } from '@jeesite/core/router';
import { Icon } from '@jeesite/core/components/Icon';
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
import { MyNoticeTodo, myNoticeTodoList } from '@jeesite/biz/api/biz/myNoticeTodo';
import { myNoticeTodoDelete, myNoticeTodoListData } from '@jeesite/biz/api/biz/myNoticeTodo';
import { useDrawer } from '@jeesite/core/components/Drawer';
import { useModal } from '@jeesite/core/components/Modal';
import { FormProps } from '@jeesite/core/components/Form';
import InputForm from './form.vue';
const { t } = useI18n('biz.myNoticeTodo');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<MyNoticeTodo>({} as MyNoticeTodo);
const getTitle = {
icon: meta.icon || 'i-ant-design:book-outlined',
value: meta.title || t('消息管理'),
};
const loading = ref(false);
const searchForm: FormProps<MyNoticeTodo> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('记录时间起'),
field: 'createTime_gte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('记录时间止'),
field: 'createTime_lte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('通知标题'),
field: 'title',
component: 'Input',
},
{
label: t('消息类型'),
field: 'type',
component: 'Input',
},
{
label: t('是否已读'),
field: 'readFlag',
component: 'Input',
},
{
label: t('是否关闭'),
field: 'clickClose',
component: 'Input',
},
{
label: t('发布状态'),
field: 'ustatus',
component: 'Input',
},
],
};
const tableColumns: BasicColumn<MyNoticeTodo>[] = [
{
title: t('记录时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 150,
align: 'center',
fixed: 'left',
},
{
title: t('通知标题'),
dataIndex: 'title',
key: 'a.title',
sorter: true,
width: 130,
align: 'left',
slot: 'bizScopeKey',
},
{
title: t('到期时间'),
dataIndex: 'datetime',
key: 'a.datetime',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('消息类型'),
dataIndex: 'type',
key: 'a.type',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('是否已读'),
dataIndex: 'readFlag',
key: 'a.read_flag',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('是否关闭'),
dataIndex: 'clickClose',
key: 'a.click_close',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('额外信息'),
dataIndex: 'extra',
key: 'a.extra',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('待办意见'),
dataIndex: 'extraDesc',
key: 'a.extra_desc',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('颜色值'),
dataIndex: 'color',
key: 'a.color',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('发布状态'),
dataIndex: 'ustatus',
key: 'a.ustatus',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('更新时间'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 150,
align: 'center',
},
];
const actionColumn: BasicColumn<MyNoticeTodo> = {
width: 160,
actions: (record: MyNoticeTodo) => [
{
icon: 'i-clarity:note-edit-line',
title: t('编辑'),
onClick: handleForm.bind(this, { id: record.id }),
auth: 'biz:myNoticeTodo:edit',
},
{
icon: 'i-ant-design:delete-outlined',
color: 'error',
title: t('删除'),
popConfirm: {
title: t('是否确认删除消息?'),
confirm: handleDelete.bind(this, record),
},
auth: 'biz:myNoticeTodo:edit',
},
],
};
const [registerTable, { reload, getForm }] = useTable<MyNoticeTodo>({
api: myNoticeTodoListData,
beforeFetch: (params) => {
return params;
},
columns: tableColumns,
actionColumn: actionColumn,
formConfig: searchForm,
showTableSetting: true,
useSearchForm: true,
canResize: true,
});
onMounted(async () => {
const res = await myNoticeTodoList();
record.value = (res.myNoticeTodo || {}) as MyNoticeTodo;
await getForm().setFieldsValue(record.value);
});
const [registerDrawer, { openDrawer }] = useDrawer();
function handleForm(record: Recordable) {
openDrawer(true, record);
}
async function handleExport() {
loading.value = true;
const { ctxAdminPath } = useGlobSetting();
await downloadByUrl({
url: ctxAdminPath + '/biz/myNoticeTodo/exportData',
params: getForm().getFieldsValue(),
});
loading.value = false;
}
async function handleDelete(record: Recordable) {
const params = { id: record.id };
const res = await myNoticeTodoDelete(params);
showMessage(res.message);
await handleSuccess(record);
}
async function handleSuccess(record: Recordable) {
await reload({ record });
}
</script>