Merge branch 'main' of http://129.211.33.98:3210/hjq/mart-admin
This commit is contained in:
commit
de46692c89
29
src/api/messagePush/index.ts
Normal file
29
src/api/messagePush/index.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import request from '/@/utils/request';
|
||||
import { baseUrlHost } from '../baseUrlHost';
|
||||
|
||||
/**
|
||||
* (不建议写成 request.post(xxx),因为这样 post 时,无法 params 与 data 同时传参)
|
||||
* 注意在写get请求时,参数是params,而不是data,要标注好
|
||||
*
|
||||
* 登录api接口集合
|
||||
* @method getMessagePushList 分页查询消息
|
||||
* @method getMessagePushDetail 查看单个消息
|
||||
*/
|
||||
|
||||
export function messagePushApi() {
|
||||
return {
|
||||
getMessagePushList: (params: object) => {
|
||||
return request({
|
||||
url: baseUrlHost + '/sysMessage',
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
},
|
||||
getMessagePushDetail: (id: Number) => {
|
||||
return request({
|
||||
url: baseUrlHost + `/sysMessage/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
@ -25,7 +25,8 @@ export default {
|
||||
attachmentDetail: 'attachmentDetail',
|
||||
addAttachment: 'addAttachment',
|
||||
editAttachment: 'editAttachment',
|
||||
|
||||
messagePush: 'messagePush',
|
||||
messagePushDetail: 'messagePushDetail',
|
||||
log:'log',
|
||||
limits: 'limits',
|
||||
limitsFrontEnd: 'FrontEnd',
|
||||
|
@ -25,6 +25,8 @@ export default {
|
||||
attachmentDetail: '附件详情',
|
||||
addAttachment: '新增附件',
|
||||
editAttachment: '编辑附件',
|
||||
messagePush: '站内消息推送',
|
||||
messagePushDetail: '站内消息推送详情',
|
||||
log:'系统日志',
|
||||
limits: '权限管理',
|
||||
limitsFrontEnd: '前端控制',
|
||||
|
@ -25,6 +25,8 @@ export default {
|
||||
attachmentDetail: '附件詳情',
|
||||
addAttachment: '附件新增',
|
||||
editAttachment: '附件編輯',
|
||||
messagePush: '站内消息推送',
|
||||
messagePushDetail: '站内消息推送詳情',
|
||||
log:'系統日誌',
|
||||
limits: '許可權管理',
|
||||
limitsFrontEnd: '前端控制',
|
||||
|
@ -434,6 +434,38 @@ export const dynamicRoutes: Array<RouteRecordRaw> = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/messagePush',
|
||||
name: 'messagePush',
|
||||
component: () => import('/@/views/messagePush/index.vue'),
|
||||
meta: {
|
||||
title: 'message.router.messagePush',
|
||||
isLink: '',
|
||||
isHide: false,
|
||||
isKeepAlive: true,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin', 'common'],
|
||||
icon: 'iconfont icon-jiliandongxuanzeqi',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/messagePush/detail',
|
||||
name: 'messagePushDetail',
|
||||
component: () => import('/@/views/messagePush/component/detail.vue'),
|
||||
meta: {
|
||||
title: 'message.router.messagePushDetail',
|
||||
isLink: '',
|
||||
isHide: true,
|
||||
isKeepAlive: false,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin','common'],
|
||||
icon: 'ele-Document',
|
||||
},
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/limits',
|
||||
name: 'limits',
|
||||
|
100
src/views/messagePush/component/detail.vue
Normal file
100
src/views/messagePush/component/detail.vue
Normal file
@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<div class="system-menu-dialog-container">
|
||||
<el-dialog :title="state.dialog.title" v-model="state.dialog.isShowDialog" width="400px">
|
||||
<el-form ref="menuDialogFormRef" :model="state.ruleForm" size="default" label-width="120px" v-loading="state.dialog.loading">
|
||||
<el-form-item label="标题:">
|
||||
{{ state.ruleForm.title }}
|
||||
</el-form-item>
|
||||
<el-form-item label="发送者:">
|
||||
{{ state.ruleForm.sendUserName }}
|
||||
</el-form-item>
|
||||
<el-form-item label="接收者:">
|
||||
{{ state.ruleForm.userName }}
|
||||
</el-form-item>
|
||||
<el-form-item label="内容:">
|
||||
{{ state.ruleForm.message }}
|
||||
</el-form-item>
|
||||
<el-form-item label="时间:">
|
||||
{{ dateFormatter() }}
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button plain @click="onCancel" size="default">关 闭</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="messagePushDialog">
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { messagePushApi } from '/@/api/messagePush';
|
||||
|
||||
// 定义变量内容
|
||||
const menuDialogFormRef = ref();
|
||||
const state = reactive({
|
||||
ruleForm: {
|
||||
id: '',
|
||||
title: '',
|
||||
sendUserName: "",
|
||||
userName: "",
|
||||
message: "",
|
||||
createtime: []
|
||||
},
|
||||
dialog: {
|
||||
isShowDialog: false,
|
||||
title: '',
|
||||
loading: false
|
||||
},
|
||||
});
|
||||
|
||||
// 引入 api 请求接口
|
||||
const mesApi = messagePushApi();
|
||||
|
||||
// 日期格式化
|
||||
const dateFormatter = () => {
|
||||
if(state.ruleForm.createtime === null) return '暂无';
|
||||
let date = state.ruleForm.createtime;
|
||||
return `${date[0]}-${date[1]}-${date[2]} ${date[3]}:${date[4]}:${date[5]}`;
|
||||
}
|
||||
|
||||
// 获取信息详情
|
||||
const getDetail = async(id? : number) => {
|
||||
try {
|
||||
state.dialog.loading = true;
|
||||
let res = await mesApi.getMessagePushDetail(id);
|
||||
if(res?.success){
|
||||
state.ruleForm = res.data;
|
||||
}else{
|
||||
ElMessage.error('信息详情获取失败!');
|
||||
}
|
||||
} catch (error) {
|
||||
} finally {
|
||||
state.dialog.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id?: any) => {
|
||||
console.log(id)
|
||||
state.dialog.isShowDialog = true;
|
||||
state.dialog.title = '人才信息';
|
||||
getDetail(id);
|
||||
};
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
state.dialog.isShowDialog = false;
|
||||
};
|
||||
|
||||
// 取消
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
140
src/views/messagePush/index.vue
Normal file
140
src/views/messagePush/index.vue
Normal file
@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<div class="system-dept-container layout-padding">
|
||||
<el-card shadow="hover" class="layout-padding-auto">
|
||||
<div class="system-dept-search mb15">
|
||||
<el-input size="default" placeholder="请输入标题" v-model="state.tableData.param.title" class="ml10" style="max-width: 180px"> </el-input>
|
||||
<el-input size="default" placeholder="请输入发送者" v-model="state.tableData.param.sendUserName" class="ml10" style="max-width: 180px"> </el-input>
|
||||
<el-input size="default" placeholder="请输入接收者" v-model="state.tableData.param.userName" class="ml10" style="max-width: 180px"> </el-input>
|
||||
<el-button @click="getTableData" size="default" type="primary" class="ml10">
|
||||
<el-icon>
|
||||
<ele-Search />
|
||||
</el-icon>
|
||||
查询
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%" @selection-change="handleSelectionChange"
|
||||
ref="tableRef">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="title" label="标题" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="message" label="内容" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="sendUserName" label="发送者" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="userName" label="接收者" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="createtime" label="创建时间" :formatter="dateFormatter" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template #default="scope">
|
||||
<el-button size="small" text type="primary" @click="toShowDetail(scope.row.id)">查看详情</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="onHandleSizeChange"
|
||||
@current-change="onHandleCurrentChange"
|
||||
class="mt15"
|
||||
:pager-count="5"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
v-model:current-page="state.tableData.param.current"
|
||||
background
|
||||
v-model:page-size="state.tableData.param.size"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="state.tableData.total"
|
||||
>
|
||||
</el-pagination>
|
||||
</el-card>
|
||||
<MessageDialog ref="messageDialogRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="messagePushIndex">
|
||||
import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
|
||||
import { messagePushApi } from '/@/api/messagePush';
|
||||
import { ElMessage, TableColumnCtx } from 'element-plus';
|
||||
|
||||
// 引入组件
|
||||
const MessageDialog = defineAsyncComponent(() => import('/@/views/messagePush/component/detail.vue'));
|
||||
const messageDialogRef = ref();
|
||||
|
||||
// 表格数据
|
||||
const state = reactive({
|
||||
tableData: {
|
||||
data: [],
|
||||
total: 0,
|
||||
loading: false,
|
||||
param: {
|
||||
sendUserName: '',
|
||||
userName: '',
|
||||
title: '',
|
||||
current: 1,
|
||||
size: 10,
|
||||
},
|
||||
},
|
||||
selectedRows: [] as any[], // 用于存储选中的消息
|
||||
});
|
||||
|
||||
// 引入 api 请求接口
|
||||
const mspApi = messagePushApi();
|
||||
|
||||
// 获取表格数据
|
||||
const getTableData = async () => {
|
||||
try {
|
||||
state.tableData.loading = true;
|
||||
let res = await mspApi.getMessagePushList(state.tableData.param);
|
||||
if (res?.success) {
|
||||
state.tableData.data = res.data.records;
|
||||
state.tableData.total = res.data.total;
|
||||
} else {
|
||||
ElMessage.error('消息列表获取失败!');
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
ElMessage.error('数据加载失败!');
|
||||
} finally {
|
||||
state.tableData.loading = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 处理多选
|
||||
const handleSelectionChange = (selection: any[]) => {
|
||||
state.selectedRows = selection;
|
||||
};
|
||||
|
||||
// 消息详情
|
||||
const toShowDetail = (id: any) => {
|
||||
messageDialogRef.value.openDialog(id);
|
||||
}
|
||||
|
||||
// 日期格式化
|
||||
const dateFormatter = (row: any, column: TableColumnCtx<String>) => {
|
||||
let date = new Date(row.createtime);
|
||||
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
||||
};
|
||||
|
||||
// 分页改变
|
||||
const onHandleSizeChange = (val: number) => {
|
||||
state.tableData.param.size = val;
|
||||
getTableData();
|
||||
};
|
||||
|
||||
// 分页改变
|
||||
const onHandleCurrentChange = (val: number) => {
|
||||
state.tableData.param.current = val;
|
||||
getTableData();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getTableData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.system-dept-container {
|
||||
:deep(.el-card__body) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
.el-table {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user