|
|
@ -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 }) |
|
|
|