Compare commits
2 Commits
e93920f5fa
...
d2dbbf6722
| Author | SHA1 | Date |
|---|---|---|
|
|
d2dbbf6722 | |
|
|
530cace976 |
|
|
@ -0,0 +1,34 @@
|
|||
import { responsesmodel } from './model/queryModal';
|
||||
import { defHttp } from '@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
LoadSysImMsgList = '/api/ImMsg/LoadSysImMsgList',
|
||||
VirtualDeleteEntitys = '/api/ImMsg/VirtualDeleteEntitys',
|
||||
DeleteEntitys = '/api/ImMsg/DeleteEntitys',
|
||||
ReadMsg = '/api/ImMsg/ReadMsg',
|
||||
}
|
||||
|
||||
export function loadSysImMsgList(params) {
|
||||
return defHttp.get<responsesmodel>({
|
||||
url: Api.LoadSysImMsgList,
|
||||
params,
|
||||
});
|
||||
}
|
||||
export function virtualDeleteEntitys(params) {
|
||||
return defHttp.post({
|
||||
url: Api.VirtualDeleteEntitys,
|
||||
params,
|
||||
});
|
||||
}
|
||||
export function deleteEntitys(params) {
|
||||
return defHttp.post({
|
||||
url: Api.DeleteEntitys,
|
||||
params,
|
||||
});
|
||||
}
|
||||
export function readMsg(params) {
|
||||
return defHttp.post({
|
||||
url: Api.ReadMsg + '?id=' + params.id,
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
|
@ -25,7 +25,38 @@ export const tabListData: TabItem[] = [
|
|||
{
|
||||
key: '1',
|
||||
name: '通知',
|
||||
list: [],
|
||||
list: [
|
||||
{
|
||||
id: 'string',
|
||||
avatar: 'string',
|
||||
// 通知的标题内容
|
||||
title: 'string',
|
||||
// 是否在标题上显示删除线
|
||||
titleDelete: true,
|
||||
datetime: 'string',
|
||||
type: 'string',
|
||||
read: true,
|
||||
description: 'string',
|
||||
clickClose: true,
|
||||
extra: 'string',
|
||||
color: 'string',
|
||||
},
|
||||
{
|
||||
id: 'string',
|
||||
avatar: 'string',
|
||||
// 通知的标题内容
|
||||
title: 'string',
|
||||
// 是否在标题上显示删除线
|
||||
titleDelete: false,
|
||||
datetime: 'string',
|
||||
type: 'string',
|
||||
read: false,
|
||||
description: 'string',
|
||||
clickClose: false,
|
||||
extra: 'string',
|
||||
color: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
import { BasicColumn, FormSchema } from '@/components/Table';
|
||||
import { h } from 'vue';
|
||||
import { Switch, Tag } from 'ant-design-vue';
|
||||
import { setRoleStatus } from '@/api/demo/system';
|
||||
import { useMessage } from '@/hooks/web/useMessage';
|
||||
|
||||
type CheckedType = boolean | string | number;
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '内容',
|
||||
dataIndex: 'content',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'isRead',
|
||||
width: 80,
|
||||
customRender: ({ record }) => {
|
||||
const isRead = record.isRead;
|
||||
const enable = ~~isRead === 0;
|
||||
const color = enable ? 'green' : 'red';
|
||||
const text = enable ? '已读' : '未读';
|
||||
return h(Tag, { color: color }, () => text);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '时间',
|
||||
dataIndex: 'createDate',
|
||||
width: 180,
|
||||
},
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'key',
|
||||
label: '关键字',
|
||||
component: 'Input',
|
||||
colProps: { span: 8 },
|
||||
},
|
||||
{
|
||||
field: 'isDelete',
|
||||
component: 'Select',
|
||||
label: '是否回收',
|
||||
defaultValue: 0,
|
||||
componentProps: {
|
||||
options: [
|
||||
{
|
||||
label: '否',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
label: '是',
|
||||
value: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
colProps: { span: 8 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'id',
|
||||
label: '角色名称',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
ifShow: false,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
label: '角色名称',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
label: '状态',
|
||||
component: 'RadioButtonGroup',
|
||||
defaultValue: 0,
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '启用', value: 0 },
|
||||
{ label: '停用', value: 1 },
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :searchInfo="searchInfo">
|
||||
<template #toolbar>
|
||||
<PermissionBtn @btn-event="onBtnClicked" />
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
// icon: 'ant-design:ellipsis-outlined',
|
||||
label: '查看',
|
||||
onClick: viewAccount.bind(null, record),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
</BasicTable>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '@/components/Table';
|
||||
import { useMessage } from '@/hooks/web/useMessage';
|
||||
import { useModal } from '@/components/Modal';
|
||||
import { PermissionBtn } from '@/components/PermissionBtn/index';
|
||||
import { columns, searchFormSchema } from './data';
|
||||
import {
|
||||
loadSysImMsgList,
|
||||
deleteEntitys,
|
||||
virtualDeleteEntitys,
|
||||
readMsg,
|
||||
} from '@/api/demo/message';
|
||||
|
||||
const { createConfirm, createMessage } = useMessage();
|
||||
const searchInfo = reactive<Recordable>({});
|
||||
const isDelete = ref(0);
|
||||
const [registerTable, { reload, getSelectRows, clearSelectedRowKeys }] = useTable({
|
||||
title: '消息列表',
|
||||
api: loadSysImMsgList,
|
||||
columns,
|
||||
rowKey: 'msgId',
|
||||
formConfig: {
|
||||
labelWidth: 120,
|
||||
schemas: searchFormSchema,
|
||||
},
|
||||
useSearchForm: true,
|
||||
showTableSetting: true,
|
||||
bordered: true,
|
||||
// 勾选列
|
||||
rowSelection: {
|
||||
//多选框
|
||||
type: 'checkbox',
|
||||
},
|
||||
// 搜索
|
||||
handleSearchInfoFn(info) {
|
||||
console.log(info);
|
||||
isDelete.value = info.isDelete;
|
||||
return info;
|
||||
},
|
||||
actionColumn: {
|
||||
width: 80,
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
// slots: { customRender: 'action' },
|
||||
fixed: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
async function viewAccount(record: Recordable) {
|
||||
await readMsg({
|
||||
id: record.msgId,
|
||||
});
|
||||
}
|
||||
|
||||
async function handleDelete() {
|
||||
let rows = getSelectRows();
|
||||
if (rows.length == 0) {
|
||||
return createMessage.warn('请勾选至少一条消息进行删除');
|
||||
}
|
||||
const ids = rows.map((t) => t.msgId);
|
||||
createConfirm({
|
||||
iconType: 'info',
|
||||
title: '删除',
|
||||
content: '确定要删除选中消息吗',
|
||||
onOk: async () => {
|
||||
const data = await virtualDeleteEntitys(ids);
|
||||
if (data) {
|
||||
handleSuccess();
|
||||
createMessage.success('删除成功');
|
||||
} else {
|
||||
createMessage.error('删除失败');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
// 彻底删除
|
||||
async function completelyDel() {
|
||||
let rows = getSelectRows();
|
||||
if (rows.length == 0) {
|
||||
return createMessage.warn('请勾选至少一条消息进行彻底删除');
|
||||
}
|
||||
const ids = rows.map((t) => t.msgId);
|
||||
createConfirm({
|
||||
iconType: 'info',
|
||||
title: '彻底删除',
|
||||
content: '确定要彻底删除选中消息吗',
|
||||
onOk: async () => {
|
||||
const data = await deleteEntitys(ids);
|
||||
if (data) {
|
||||
handleSuccess();
|
||||
createMessage.success('彻底删除成功');
|
||||
} else {
|
||||
createMessage.error('彻底删除失败');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
clearSelectedRowKeys();
|
||||
reload();
|
||||
}
|
||||
function onBtnClicked(domId) {
|
||||
switch (domId) {
|
||||
case 'btnDelete':
|
||||
console.log(isDelete.value);
|
||||
if (isDelete.value == 1) {
|
||||
completelyDel();
|
||||
} else {
|
||||
handleDelete();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in New Issue