Browse Source

通知管理 bug处理

master
x_ying 4 years ago
parent
commit
ef9f9b3a80
  1. 123
      src/views/system/notifyManage/index.vue

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

@ -89,7 +89,7 @@
</div> </div>
</el-dialog> </el-dialog>
<!-- 删除 --> <!-- 删除 -->
<el-dialog :visible.sync="delVisible" title="提示" @close="handleClose">
<el-dialog :visible.sync="delVisible" title="提示">
<span class="dialog-right-top" /> <span class="dialog-right-top" />
<span class="dialog-left-bottom" /> <span class="dialog-left-bottom" />
<div class="setting-dialog"> <div class="setting-dialog">
@ -182,44 +182,64 @@ export default {
}, },
getTableData() { getTableData() {
getNoticeList(this.getParams()).then(res => { // 获取列表 getNoticeList(this.getParams()).then(res => { // 获取列表
console.log(res, 'res')
const table = res.content const table = res.content
this.page.total = res.totalElements this.page.total = res.totalElements
table.forEach(item => { table.forEach(item => {
item.pushTo = null item.pushTo = null
item.pushVal = 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 {
item.pushVal = item.noticeDevices.map(i => { return i.deviceInfoId })
item.pushTo = item.noticeDevices.map(i => {
let dev = null
this.devOptions.forEach(val => {
if (val.value === i.deviceInfoId) {
dev = val.label
}
})
return dev
if (item.pushType === 2) { // 推送对象为设备
// if (item.noticeDevices.length === this.devOptions.length - 1) {
// item.pushTo = '全部设备'
// item.pushVal = this.sendObjOptions.map(i => { return i.value })
// } else {
item.pushVal = item.noticeDevices.map(i => { return i.deviceInfoId })
item.pushTo = item.noticeDevices.map(i => {
let dev = null
this.devOptions.forEach(val => {
if (val.value === i.deviceInfoId) {
dev = val.label
}
}) })
}
} else if (item.noticeUsers.length > 0) { // 推送对象为用户
return dev
})
// }
} else if (item.pushType === 1) { // 推送对象为用户
// pushArr = item.noticeDevices // pushArr = item.noticeDevices
if (item.noticeUsers.length === this.userOptions.length - 1) {
item.pushTo = '全部用户'
item.pushVal = this.userOptions.map(i => { return i.value })
} else {
item.pushVal = item.noticeUsers.map(i => { return i.userId })
item.pushTo = item.noticeUsers.map(i => {
let user = null
this.userOptions.forEach(val => {
if (val.value === i.userId) {
user = val.label
}
})
return user
// if (item.noticeUsers.length === this.userOptions.length - 1) {
// item.pushTo = '全部用户'
// item.pushVal = this.userOptions.map(i => { return i.value })
// } else {
item.pushVal = item.noticeUsers.map(i => { return i.userId })
item.pushTo = item.noticeUsers.map(i => {
let user = null
this.userOptions.forEach(val => {
if (val.value === i.userId) {
user = val.label
}
}) })
return user
})
// }
}
// 去重
const arrTo = []
const arrVal = []
item.pushTo.forEach(i => {
if (arrTo.indexOf(i) === -1) {
arrTo.push(i)
} }
})
item.pushVal.forEach(i => {
if (arrVal.indexOf(i) === -1) {
arrVal.push(i)
}
})
item.pushVal = arrVal
if (item.pushType === 1) { // 用户
item.pushTo = arrVal.length === this.userOptions.length - 1 ? '全部用户' : arrTo
} else {
item.pushTo = arrVal.length === this.devOptions.length - 1 ? '全部设备' : arrTo
} }
}) })
this.tableData = table this.tableData = table
@ -286,14 +306,17 @@ export default {
this.isEdit = false this.isEdit = false
this.sendVisible = true this.sendVisible = true
}, },
// 修改
handleEdit() { handleEdit() {
this.isEdit = true this.isEdit = true
this.sendForm.notification = this.selections[0].noticeContent this.sendForm.notification = this.selections[0].noticeContent
this.selectOptions = this.selections[0].pushVal
const temp = this.selections[0].pushVal
if (this.selections[0].pushType === 1) { if (this.selections[0].pushType === 1) {
this.pushObj = '用户' this.pushObj = '用户'
this.selectOptions = temp.length === this.userOptions.length - 1 ? [0, ...temp] : temp
} else { } else {
this.pushObj = '设备' this.pushObj = '设备'
this.selectOptions = temp.length === this.devOptions.length - 1 ? [0, ...temp] : temp
} }
this.sendVisible = true this.sendVisible = true
}, },
@ -311,6 +334,7 @@ export default {
const params = {} const params = {}
params.noticeType = this.noticeType params.noticeType = this.noticeType
params.noticeContent = this.sendForm.notification params.noticeContent = this.sendForm.notification
//* ************** */
if (this.pushObj === '用户') { // 选择用户 if (this.pushObj === '用户') { // 选择用户
params.pushType = 1 params.pushType = 1
params.userId = this.selectOptions.filter(item => item !== 0) params.userId = this.selectOptions.filter(item => item !== 0)
@ -337,7 +361,6 @@ export default {
}) })
this.$refs.formDom.resetFields() this.$refs.formDom.resetFields()
this.$refs.formDom.clearValidate() this.$refs.formDom.clearValidate()
// this.crud.refresh()
} else { } else {
this.btnloading = false this.btnloading = false
this.$message.error('发布失败') this.$message.error('发布失败')
@ -347,6 +370,9 @@ export default {
handleClose() { handleClose() {
this.$refs.formDom.resetFields() this.$refs.formDom.resetFields()
this.$refs.formDom.clearValidate() this.$refs.formDom.clearValidate()
this.sendForm.notification = ''
this.pushObj = '用户'
this.noticeType = 1
}, },
// 删除 // 删除
handleDel() { handleDel() {
@ -400,42 +426,9 @@ export default {
} }
this.oldSelect = this.selectOptions this.oldSelect = this.selectOptions
} }
// 最后选中得值
// var endSelectVal = val[val.length - 1]
// // showTags配合 collapse-tags 属性来
// if (!val.includes('全选') && val.length === this.sendObjOptions.length) {
// // 当前选中得值不包含“全选”,且其他项全选中
// this.showTags = true
// val.unshift('全选')
// this.$refs.selectBox.$el.querySelector('.el-input__inner').style.height = '34px'
// } else if (val.includes('全选') && val.length === 1) {
// // 当前选中得值是“全选”时
// this.showTags = true
// this.sendObjOptions.map(item => {
// val.push(item.value)
// })
// } else if (val.includes('全选') && val.length - 1 < this.sendObjOptions.length && endSelectVal === '全选') {
// // 当前选中得值是其他项,未全部选完,而最后选中得是“全选”时
// val = []
// this.sendObjOptions.map(item => {
// val.push(item.value)
// })
// val.unshift('全选')
// this.showTags = true
// this.$refs.selectBox.$el.querySelector('.el-input__inner').style.height = '34px'
// } else if (val.includes('全选') && val.length - 1 < this.sendObjOptions.length) {
// // 当前选中得值是其他项,未全部选完时
// this.showTags = false
// val = val.filter(item => {
// return item !== '全选'
// })
// }
// this.selectOptions = val // 赋值给select绑定得
}, },
pushObjChange(val) { pushObjChange(val) {
if (val) { if (val) {
// this.selectOptions = []
// this.showTags = false
this.defaultSelAll() this.defaultSelAll()
this.showTags = true this.showTags = true
} }

Loading…
Cancel
Save