【类 型】:feat
【原 因】:添加公告模块 【过 程】: 【影 响】: # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
2ef12fc312
commit
0f0c18bd35
@ -437,7 +437,7 @@ const routes = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/message/index',
|
||||
path: '/message/pub',
|
||||
component: () => import('@/views/layout/components/main/message/pub'),
|
||||
meta: {
|
||||
title: '发布公告',
|
||||
|
@ -6,6 +6,7 @@ import settings from './modules/settings'
|
||||
import user from './modules/user'
|
||||
import api from '@/utils/api'
|
||||
import { Message, MessageBox, Notification } from 'element-ui'
|
||||
import { parseTime } from '@/utils/index'
|
||||
|
||||
// 把vuex作为插件引入到Vue示例中 ps:注册
|
||||
Vue.use(Vuex)
|
||||
@ -1143,6 +1144,7 @@ const store = new Vuex.Store({
|
||||
}
|
||||
return res
|
||||
},
|
||||
|
||||
/**
|
||||
* @description: 异步获取管理员消息列表 成功获取之后 弹出通知框 显示列表
|
||||
*/
|
||||
@ -1153,14 +1155,24 @@ const store = new Vuex.Store({
|
||||
const list = res.data.messageList || []
|
||||
commit('setMessageList', list)
|
||||
|
||||
// 每条通知之间延迟 800ms,显示时间为 8000ms
|
||||
// 弹出通知
|
||||
list.forEach((item, index) => {
|
||||
const formattedTime = parseTime(item.add_time, '{m}-{d} {h}:{i}')
|
||||
const sender = item.admin_uname || '管理员'
|
||||
|
||||
setTimeout(() => {
|
||||
Notification({
|
||||
title: item.tit || '通知',
|
||||
message: item.message || '',
|
||||
duration: 8000, // 显示时间 8 秒
|
||||
type: 'info' // 可选类型: success / warning / error / info
|
||||
message: `
|
||||
<div>
|
||||
<div>${item.message || ''}</div>
|
||||
<div style="display: flex; justify-content: flex-end;">
|
||||
<div style="color: #aaa;">BY. ${sender} ${formattedTime}</span>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
duration: 8000,
|
||||
dangerouslyUseHTMLString: true // 启用 HTML 格式
|
||||
})
|
||||
}, index * 800)
|
||||
})
|
||||
|
@ -9,6 +9,7 @@ const defaultModuleVisibilityMap = {
|
||||
site: true,
|
||||
shop: true,
|
||||
admin: true,
|
||||
message: true,
|
||||
category: true,
|
||||
broadcast: true,
|
||||
order: true,
|
||||
|
@ -162,6 +162,15 @@ export async function pubMessage (tit, message, idArr, endTime) {
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取全部公告列表(不限制过期、无admin_id限制)
|
||||
* @returns {Promise} 返回接口响应对象
|
||||
*/
|
||||
export async function getAllMessageList () {
|
||||
const res = await api.get('getAllMessageList', 'Admin')
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract 获取指定飞机组的飞行数据(按时间范围)
|
||||
* @param {Array} idArr 飞机ID数组
|
||||
|
@ -14,7 +14,7 @@
|
||||
</el-button-group>
|
||||
<!-- 管理员列表 -->
|
||||
<el-table class="w-100" ref="myTable"
|
||||
:data="adminListArr.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border tooltip-effect="dark">
|
||||
:data="adminListArr.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border tooltip-effect="dark" @selection-change="handleSelectionChange">
|
||||
<el-table-column align="center" type="selection" width="40">
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="id" label="id" width="50">
|
||||
|
@ -56,6 +56,7 @@ export default {
|
||||
{ value: 'planes', label: '无人机' },
|
||||
{ value: 'shop', label: '商铺管理' },
|
||||
{ value: 'admin', label: '账户列表' },
|
||||
{ value: 'message', label: '公告管理' },
|
||||
{ value: 'category', label: '分类管理' },
|
||||
{ value: 'product', label: '商品管理' },
|
||||
{ value: 'broadcast', label: '广告管理' },
|
||||
|
@ -2,58 +2,69 @@
|
||||
<div class="app-container">
|
||||
<!-- 组合按钮 -->
|
||||
<el-button-group class="m-b-20 m-r-20">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="$router.replace('/admin/add')">添加</el-button>
|
||||
<el-button type="danger" icon="el-icon-delete" @click="deleteAdmin(countSelIdArr($refs.myTable.selection))">删除
|
||||
</el-button>
|
||||
<el-button type="warning" icon="el-icon-edit" @click="toEditPage()">编辑</el-button>
|
||||
<el-button type="success" icon="el-icon-microphone" @click="toMessagePage(countSelIdArr($refs.myTable.selection))">发布公告</el-button>
|
||||
</el-button-group>
|
||||
<!-- 用户select选项 -->
|
||||
<el-button-group class="m-b-20">
|
||||
<SelectionShopId v-model="form.shop_id" :allSel="true" />
|
||||
</el-button-group>
|
||||
<!-- 管理员列表 -->
|
||||
|
||||
<!-- 公告列表 -->
|
||||
<el-table class="w-100" ref="myTable"
|
||||
:data="adminListArr.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border tooltip-effect="dark">
|
||||
<el-table-column align="center" type="selection" width="40">
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="id" label="id" width="50">
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" label="账户名" width="150" min-width="150">
|
||||
</el-table-column>
|
||||
<el-table-column prop="uname" label="昵称" min-width="150">
|
||||
</el-table-column>
|
||||
<el-table-column label="最后登录时间" width="140" min-width="120">
|
||||
:data="messageListArr.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border tooltip-effect="dark">
|
||||
<!-- 多选框 -->
|
||||
<el-table-column type="selection" width="55" />
|
||||
|
||||
<!-- 公告标题 -->
|
||||
<el-table-column prop="tit" label="标题" min-width="120" show-overflow-tooltip />
|
||||
|
||||
<!-- 公告内容 -->
|
||||
<el-table-column prop="message" label="内容" min-width="200" show-overflow-tooltip />
|
||||
|
||||
<!-- 添加人 -->
|
||||
<el-table-column prop="admin_uname" label="发布人" min-width="100" />
|
||||
|
||||
<!-- 接收人 -->
|
||||
<el-table-column prop="by_admin_uname" label="接收人" min-width="100" />
|
||||
|
||||
<!-- 添加时间 -->
|
||||
<el-table-column prop="add_time" label="发布时间" min-width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.lasttime | parseTime('{y}-{m}-{d} {h}:{i}') }}
|
||||
{{ parseTime(scope.row.add_time) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="注册时间" width="100" min-width="80">
|
||||
|
||||
<!-- 结束时间 -->
|
||||
<el-table-column prop="end_time" label="截止时间" min-width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.addtime | parseTime('{y}-{m}-{d}') }}
|
||||
{{ parseTime(scope.row.end_time) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="controler" label="操作" width="350" min-width="350">
|
||||
<template slot-scope="scope">
|
||||
|
||||
<!-- 操作 -->
|
||||
<el-table-column label="操作" width="220" fixed="right">
|
||||
<el-button-group>
|
||||
<el-button type="warning" icon="el-icon-edit"
|
||||
@click="$router.replace(`/admin/edit/${scope.row.id}`)">编辑</el-button>
|
||||
<el-button type="danger" icon="el-icon-delete" @click="deleteAdmin([scope.row.id])">删除</el-button>
|
||||
<el-button type="success" icon="el-icon-microphone" @click="toMessagePage([scope.row.id])">发布公告</el-button>
|
||||
</el-button-group>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<el-pagination class="m-t-20" layout="prev, pager, next" :current-page.sync="currentPage" :page-size="pageSize"
|
||||
:total="adminListArr.length">
|
||||
:total="messageListArr.length">
|
||||
</el-pagination>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { parseTime, countSelIdArr } from '@/utils'
|
||||
import SelectionShopId from '@/components/SelectionShopId'
|
||||
import { getAllMessageList } from '@/utils/api/table'
|
||||
|
||||
export default {
|
||||
name: 'Admin',
|
||||
@ -63,81 +74,45 @@ export default {
|
||||
currentPage: 1, // 当前页
|
||||
form: {
|
||||
shop_id: ''
|
||||
}
|
||||
},
|
||||
messageList: []
|
||||
}
|
||||
},
|
||||
components: {
|
||||
SelectionShopId
|
||||
},
|
||||
computed: {
|
||||
adminList () {
|
||||
return this.$store.state.adminList
|
||||
},
|
||||
/**
|
||||
* @description: 过滤掉 不对应客户的 飞机列表
|
||||
* @return: 飞机列表
|
||||
*/
|
||||
adminListArr () {
|
||||
// 获取公告列表
|
||||
messageListArr () {
|
||||
if (this.form.shop_id !== '') {
|
||||
return this.adminList.filter((item) => item.shop_id === this.form.shop_id)
|
||||
return this.messageList.filter((item) => item.shop_id === this.form.shop_id)
|
||||
} else {
|
||||
return this.adminList
|
||||
return this.messageList
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
countSelIdArr,
|
||||
/**
|
||||
* @description: 跳转到编辑页面
|
||||
*/
|
||||
toEditPage () {
|
||||
const selId = this.countSelIdArr(this.$refs.myTable.selection)
|
||||
switch (selId.length) {
|
||||
case 0:
|
||||
this.$message.error('请选择一条需要编辑的记录')
|
||||
break
|
||||
case 1:
|
||||
this.$router.push('/admin/edit/' + selId['0'])
|
||||
break
|
||||
default:
|
||||
this.$message.error('只能选择一条记录')
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @description: 跳转到发布公告页面
|
||||
*/
|
||||
toMessagePage (selIdArr) {
|
||||
if (selIdArr.length === 0) {
|
||||
this.$message.error('请选择至少一个用户')
|
||||
} else {
|
||||
this.$store.commit('app/setToMessageIdArr', selIdArr)// 传参
|
||||
this.$router.push('/admin/message/')
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @description: 删除用户
|
||||
*/
|
||||
deleteAdmin (idArr) {
|
||||
this.$store.dispatch('fetchDelAdmin', idArr)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
created () {
|
||||
this.getAllMessageList()
|
||||
},
|
||||
methods: {
|
||||
parseTime,
|
||||
// 获取公告列表
|
||||
async getAllMessageList () {
|
||||
const res = await getAllMessageList()
|
||||
if (res.data.status === 1) {
|
||||
this.messageList = res.data.messageList
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
parseTime,
|
||||
countSelIdArr
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "@/styles/theme.scss";
|
||||
|
||||
.el-tag {
|
||||
i {
|
||||
vertical-align: middle
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user