消息管理
This commit is contained in:
parent
60475d2d11
commit
d85ee87215
@ -77,8 +77,6 @@ const editVisible=ref(false)
|
|||||||
const selectionData = ref([])
|
const selectionData = ref([])
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const formParams = reactive({
|
const formParams = reactive({
|
||||||
title:'',
|
|
||||||
status:'',
|
|
||||||
type:1
|
type:1
|
||||||
});
|
});
|
||||||
const actionColumn = reactive({
|
const actionColumn = reactive({
|
||||||
|
56
src/views/data/message/columns.ts
Normal file
56
src/views/data/message/columns.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
import { ElTag } from 'element-plus';
|
||||||
|
|
||||||
|
export const columns = [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '消息标题',
|
||||||
|
prop: 'title',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '消息类型',
|
||||||
|
prop: 'type',
|
||||||
|
render(record) {
|
||||||
|
let typeText = ''
|
||||||
|
switch (record.row.type) {
|
||||||
|
case 1:
|
||||||
|
typeText='系统通知'
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
typeText='用户私信 '
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
typeText='代办事项'
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return h('span', typeText || '-');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '业务类型',
|
||||||
|
prop: 'status',
|
||||||
|
render(record) {
|
||||||
|
return h('span', record.row.bizType === 1 ? '订单' : '其他')
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '消息状态',
|
||||||
|
prop: 'status',
|
||||||
|
render(record) {
|
||||||
|
return h('span', record.row.status === 1 ? '已读' : '未读')
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
label: '创建人',
|
||||||
|
prop: 'createUser',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
},
|
||||||
|
];
|
108
src/views/data/message/edit.vue
Normal file
108
src/views/data/message/edit.vue
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-model="props.visible"
|
||||||
|
title="消息详情"
|
||||||
|
|
||||||
|
width="700"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:before-close="dialogClose"
|
||||||
|
>
|
||||||
|
<el-descriptions column="2">
|
||||||
|
<el-descriptions-item label="消息标题:">{{formData.title}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消息类型:">{{getTyepText(formData.type)}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="业务类型:">{{formData.bizType==1?'订单':'其他'}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消息状态:">{{formData.status==1?'已读':'未读'}}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消息内容:">{{formData.content}}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="dialogClose">关闭</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type {FormInstance} from "element-plus";
|
||||||
|
import {getMessageDetail} from "@/api/data/message";
|
||||||
|
import {onMounted, reactive, shallowRef} from "vue";
|
||||||
|
|
||||||
|
const emit = defineEmits(["success", "update:visible"]);
|
||||||
|
const formRef = shallowRef<FormInstance>();
|
||||||
|
const formData = reactive({
|
||||||
|
id: "",
|
||||||
|
title: "",
|
||||||
|
type:'',
|
||||||
|
bizType:'',
|
||||||
|
status:'',
|
||||||
|
content:''
|
||||||
|
});
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
messageId: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const dialogClose = () => {
|
||||||
|
emit("update:visible", false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const setFormData = async () => {
|
||||||
|
const data = await getMessageDetail(props.messageId);
|
||||||
|
for (const key in formData) {
|
||||||
|
if (data[key] != null && data[key] != undefined) {
|
||||||
|
//@ts-ignore
|
||||||
|
formData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const getBizType =(type)=>{
|
||||||
|
let typeText = ''
|
||||||
|
switch (type) {
|
||||||
|
case 1:
|
||||||
|
typeText='系统用户'
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
typeText='会员用户'
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
typeText='其他'
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return typeText
|
||||||
|
}
|
||||||
|
const getTyepText =(type)=>{
|
||||||
|
let typeText = ''
|
||||||
|
switch (type) {
|
||||||
|
case 1:
|
||||||
|
typeText='系统通知'
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
typeText='用户私信 '
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
typeText='代办事项'
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return typeText
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.messageId) {
|
||||||
|
setFormData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
136
src/views/data/message/index.vue
Normal file
136
src/views/data/message/index.vue
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<template>
|
||||||
|
<PageWrapper>
|
||||||
|
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||||
|
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset"></BasicForm>
|
||||||
|
</el-card>
|
||||||
|
<el-card :bordered="false" class="proCard">
|
||||||
|
<BasicTable
|
||||||
|
:columns="columns"
|
||||||
|
:request="loadDataTable"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
ref="tableRef"
|
||||||
|
:actionColumn="actionColumn"
|
||||||
|
@selection-change="onSelectionChange"
|
||||||
|
>
|
||||||
|
<template #tableTitle>
|
||||||
|
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length" v-perm="['sys:message:batchDelete']">
|
||||||
|
<template #icon>
|
||||||
|
<el-icon class="el-input__icon">
|
||||||
|
<Delete />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<editDialog
|
||||||
|
v-if="editVisible"
|
||||||
|
:messageId="messageId"
|
||||||
|
v-model:visible="editVisible"
|
||||||
|
@success="reloadTable('noRefresh')"
|
||||||
|
>
|
||||||
|
</editDialog>
|
||||||
|
</PageWrapper>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { reactive, ref, h,nextTick,defineAsyncComponent } from 'vue';
|
||||||
|
import { ColProps } from 'element-plus';
|
||||||
|
import { schemas } from './querySchemas';
|
||||||
|
import { useForm } from '@/components/Form/index';
|
||||||
|
import { TableAction } from '@/components/Table';
|
||||||
|
import { getMessageList,messageDelete,messageBatchDelete } from '@/api/data/message';
|
||||||
|
import { columns } from './columns';
|
||||||
|
import {message,confirm} from "@/utils/auth";
|
||||||
|
const editDialog = defineAsyncComponent(() =>
|
||||||
|
import('./edit.vue')
|
||||||
|
)
|
||||||
|
const messageId =ref(0)
|
||||||
|
const editVisible=ref(false)
|
||||||
|
const selectionData = ref([])
|
||||||
|
const tableRef = ref();
|
||||||
|
const formParams = reactive({
|
||||||
|
title:'',
|
||||||
|
bizType:'',
|
||||||
|
type:'',
|
||||||
|
status:''
|
||||||
|
});
|
||||||
|
const actionColumn = reactive({
|
||||||
|
width: 250,
|
||||||
|
label: '操作',
|
||||||
|
prop: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
render(record) {
|
||||||
|
return h(TableAction, {
|
||||||
|
style: 'button',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
type: 'warning',
|
||||||
|
onClick: handleInfo.bind(null, record),
|
||||||
|
auth: ['sys:message:detail'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'danger',
|
||||||
|
onClick: handleDelete.bind(null, record),
|
||||||
|
auth: ['sys:message:delete'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadDataTable = async (res: any) => {
|
||||||
|
const result = await getMessageList({ ...formParams, ...res });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
function reloadTable(noRefresh='') {
|
||||||
|
tableRef.value.reload(noRefresh?{}:{pageNo:1});
|
||||||
|
}
|
||||||
|
const [register, {}] = useForm({
|
||||||
|
labelWidth: 80,
|
||||||
|
layout: 'horizontal',
|
||||||
|
colProps: { span: 6 } as ColProps,
|
||||||
|
submitOnReset:true,
|
||||||
|
schemas
|
||||||
|
});
|
||||||
|
function handleSubmit(values: Recordable) {
|
||||||
|
handleReset()
|
||||||
|
for (const key in values) {
|
||||||
|
formParams[key] = values[key]
|
||||||
|
}
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleReset() {
|
||||||
|
for (const key in formParams) {
|
||||||
|
formParams[key] ='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleInfo = async (record: Recordable) => {
|
||||||
|
messageId.value=record.row.id
|
||||||
|
await nextTick();
|
||||||
|
editVisible.value=true
|
||||||
|
};
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
let ids = []
|
||||||
|
if(!record){
|
||||||
|
ids = selectionData.value.map(({id}) => id);
|
||||||
|
}
|
||||||
|
await confirm('确定要删除?');
|
||||||
|
record? await messageDelete(record.row.id):await messageBatchDelete(ids);
|
||||||
|
message("删除成功");
|
||||||
|
reloadTable()
|
||||||
|
}
|
||||||
|
function onSelectionChange(value){
|
||||||
|
selectionData.value = value
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
72
src/views/data/message/querySchemas.ts
Normal file
72
src/views/data/message/querySchemas.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import { FormSchema } from '@/components/Form/index';
|
||||||
|
export const schemas: FormSchema[] = [
|
||||||
|
{
|
||||||
|
field: 'title',
|
||||||
|
component: 'Input',
|
||||||
|
label: '消息标题',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入消息标题',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
component: 'Select',
|
||||||
|
label: '消息类型',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择消息类型',
|
||||||
|
clearable: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '系统通知',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户私信',
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '代办事项',
|
||||||
|
value: 3,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'bizType',
|
||||||
|
component: 'Select',
|
||||||
|
label: '业务类型',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择业务类型',
|
||||||
|
clearable: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '订单',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '其他',
|
||||||
|
value: 2,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
component: 'Select',
|
||||||
|
label: '消息状态',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择消息状态',
|
||||||
|
clearable: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: '未读',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '已读',
|
||||||
|
value: 1,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
];
|
@ -15,14 +15,13 @@ export const schemas: FormSchema[] = [
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请选择状态',
|
placeholder: '请选择状态',
|
||||||
clearable: true,
|
clearable: true,
|
||||||
clearable:true,
|
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
label: '正常',
|
label: '正常',
|
||||||
value: '1',
|
value: '1',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '禁用',
|
label: '停用',
|
||||||
value: '2',
|
value: '2',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user