Browse Source

通知管理

master
x_ying 2 years ago
parent
commit
194a975f3a
  1. 12
      src/api/system/logs.js
  2. 139
      src/views/system/notifyManage/index.vue

12
src/api/system/logs.js

@ -46,10 +46,20 @@ export function noticeCreate(data) {
})
}
// 删除
export function noticeDel(data) {
return request({
url: '/api/notice/delete',
method: 'delete',
data
})
}
export default {
warnRemark,
noticeCreate,
getNoticeList,
getAllUser,
getAllDev
getAllDev,
noticeDel
}

139
src/views/system/notifyManage/index.vue

@ -9,14 +9,12 @@
<span class="right-top-line" />
<span class="left-bottom-line" />
<!--表格渲染-->
<!-- :cell-class-name="cell"
@selection-change="selectionChangeHandler"
-->
<el-table
ref="table"
:data="tableData"
style="width: 100%;"
height="calc(100vh - 294px)"
:default-sort="{prop: 'create_time', order: 'descending'}"
@row-click="clickRowHandler"
@selection-change="selectionChangeHandler"
>
@ -26,18 +24,12 @@
<el-table-column prop="noticeType" label="消息类型" align="center" min-width="150" />
<el-table-column prop="pushTo" label="推送对象" align="center" min-width="150" />
<el-table-column prop="update_by" label="推送人" align="center" min-width="150" />
<el-table-column prop="create_time" label="推送时间" align="center" min-width="180">
<el-table-column prop="create_time" sortable label="推送时间" align="center" min-width="180">
<template slot-scope="scope">
<div>{{ scope.row.create_time | parseTime }}</div>
</template>
</el-table-column>
<!-- <el-table-column prop="bindState" label="绑定状态" align="center">
<template slot-scope="scope">
<span class="clear" style="width:76px">{{ scope.row.bindState }}</span>
</template>
</el-table-column> -->
</el-table>
<!-- <pagination /> -->
<el-pagination
:page-size.sync="page.size"
:total="page.total"
@ -81,7 +73,7 @@
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleSave">保存</el-button>
<el-button v-loading="btnloading" type="primary" @click="handleSave">保存</el-button>
</div>
</div>
</el-dialog>
@ -102,12 +94,10 @@
<script>
import { presenter, crud } from '@crud/crud'
// import pagination from '@crud/Pagination'
import { noticeCreate, getAllDev, getAllUser, getNoticeList } from '@/api/system/logs'
import { noticeCreate, getAllDev, getAllUser, getNoticeList, noticeDel } from '@/api/system/logs'
export default {
name: 'NotifyManage',
// components: { pagination },
mixins: [presenter(), crud()],
data() {
return {
@ -123,29 +113,15 @@ export default {
},
pushObj: '用户',
checked: '',
noticeType: '1',
noticeType: 1,
msgTypeOptions: [
{ value: '1', label: '系统通知' }
{ value: 1, label: '系统通知' }
// { value: 2, label: '', disabled: true },
// { value: 3, label: '', disabled: true },
// { value: 4, label: '', disabled: true }
],
userOptions: [
// { value: 0, label: '' },
// { value: 1, label: ' - ' },
// { value: 2, label: ' - ' },
// { value: 3, label: ' - ' },
// { value: 4, label: ' - ' },
// { value: 5, label: ' - ' },
// { value: 6, label: ' - ' },
// { value: 7, label: ' - ' }
],
devOptions: [
// { value: 0, label: '' },
// { value: 1, label: '1' },
// { value: 2, label: '2' },
// { value: 3, label: '3' }
],
userOptions: [],
devOptions: [],
selectOptions: [],
oldSelect: null,
showTags: true,
@ -166,7 +142,9 @@ export default {
total: 0,
size: 10,
page: 1
}
},
btnloading: false,
isEdit: null
}
},
computed: {
@ -195,16 +173,17 @@ export default {
},
getTableData() {
getNoticeList(this.getParams()).then(res => { //
console.log(res, 'res')
const table = res.content
this.page.total = res.totalElements
table.forEach(item => {
item.pushTo = null
item.pushVal = null
if (item.noticeDevices.length > 0) { //
if (item.noticeDevices.length === this.devOptions.length - 1) {
item.pushTo = '全部设备'
item.pushVal = this.sendObjOptions.map(i => { return i.value })
} else {
// let push
item.pushVal = item.noticeDevices.map(i => { return i.deviceInfoId })
item.pushTo = item.noticeDevices.map(i => {
let dev = null
this.devOptions.forEach(val => {
@ -219,8 +198,9 @@ export default {
// pushArr = item.noticeDevices
if (item.noticeUsers.length === this.devOptions.length - 1) {
item.pushTo = '全部用户'
item.pushVal = this.sendObjOptions.map(i => { return i.value })
} else {
// let push
item.pushVal = item.noticeUsers.map(i => { return i.userId })
item.pushTo = item.noticeUsers.map(i => {
let user = null
this.userOptions.forEach(val => {
@ -233,14 +213,12 @@ export default {
}
}
})
console.log(table, 'table')
this.tableData = table
})
},
//
async getUser() {
await getAllUser().then(res => {
console.log(res, '用户')
const arr0 = [{ value: 0, label: '全部用户' }]
const arr = res.map(item => {
const val = item.id
@ -252,13 +230,11 @@ export default {
return obj
})
this.userOptions = arr0.concat(arr)
console.log(this.userOptions, '---用户')
})
},
//
async getDev() {
await getAllDev().then(res => {
console.log(res, '设备')
const arr0 = [{ value: 0, label: '全部设备' }]
const arr = res.map(item => {
const val = item.id
@ -270,7 +246,6 @@ export default {
return obj
})
this.devOptions = arr0.concat(arr)
console.log(this.devOptions, '---设备')
})
},
//
@ -278,16 +253,14 @@ export default {
this.loading = true
this.page.size = e
this.page.page = 1
this.getTableData(this.getParams())
this.getTableData()
this.loading = false
},
//
pageChangeHandler(e) {
this.loading = true
this.page.page = e
this.params.page = e - 1
this.getTableData(this.getParams())
this.getTableData()
this.loading = false
},
clickRowHandler(row) {
@ -300,10 +273,18 @@ export default {
//
handleSend() {
this.defaultSelAll()
this.isEdit = false
this.sendVisible = true
},
handleEdit() {
this.sendForm.notification = this.selections[0].notification
this.isEdit = true
this.sendForm.notification = this.selections[0].noticeContent
this.selectOptions = this.selections[0].pushVal
if (this.selections[0].pushType === 1) {
this.pushObj = '用户'
} else {
this.pushObj = '设备'
}
this.sendVisible = true
},
//
@ -321,26 +302,54 @@ export default {
params.userId = this.selectOptions
}
}
// params.users = params.users.map(item => {
// return item + ''
// })
console.log(params, '--params')
noticeCreate(params).then(res => {
console.log(res, '===创建')
if (res === 'SUCCESS') {
this.sendVisible = false
this.$refs.formDom.resetFields()
this.$refs.formDom.clearValidate()
}
})
// this.sendVisible = false
// this.$refs.formDom.resetFields()
// this.$refs.formDom.clearValidate()
} else {
return false
}
})
},
getPushParams() { //
const params = {}
params.noticeType = this.noticeType
params.noticeContent = this.sendForm.notification
if (this.pushObj === '用户') { //
params.pushType = 1
params.userId = this.selectOptions.filter(item => item !== 0)
} else { //
params.pushType = 2
params.deviceInfoId = this.selectOptions.filter(item => item !== 0)
}
if (this.isEdit) {
params.id = this.selections[0].id
}
return params
},
//
noticeSend(params) {
noticeCreate(params).then(res => {
if (res === 'SUCCESS') {
this.btnloading = false
this.sendVisible = false
this.getTableData()
this.$message({
message: '发布成功',
type: 'success'
})
this.$refs.formDom.resetFields()
this.$refs.formDom.clearValidate()
// this.crud.refresh()
} else {
this.btnloading = false
this.$message.error('发布失败')
}
})
},
handleClose() {
this.$refs.formDom.resetFields()
this.$refs.formDom.clearValidate()
@ -351,6 +360,18 @@ export default {
},
//
handleDelConfirm() {
const params = this.selections.map(item => { return item.id })
noticeDel(params).then(res => {
if (res === 'SUCCESS') {
this.getTableData()
this.$message({
message: '删除成功',
type: 'success'
})
} else {
this.$message.error('删除失败')
}
})
this.delVisible = false
},
//
@ -361,16 +382,6 @@ export default {
this.checked = false
}
},
// selectAll(val) {
// this.sendForm.sendObj = []
// if (val) {
// this.sendForm.sendObj = this.sendObjOptions.map(item => item.value)
// } else {
// this.sendForm.sendObj = []
// }
// // console.log(this.sendForm.sendObj)
// },
// el-select val
//
defaultSelAll() {
this.selectOptions = this.sendObjOptions.map(item => { return item.value })

Loading…
Cancel
Save