From ef9f9b3a806f1f821d3445c4f7a3ddb045f1ed47 Mon Sep 17 00:00:00 2001 From: x_ying <2438792676@qq.com> Date: Wed, 24 Aug 2022 12:14:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E7=AE=A1=E7=90=86=20bug?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/notifyManage/index.vue | 123 +++++++++++------------- 1 file changed, 58 insertions(+), 65 deletions(-) diff --git a/src/views/system/notifyManage/index.vue b/src/views/system/notifyManage/index.vue index 756ce38..ed91ca6 100644 --- a/src/views/system/notifyManage/index.vue +++ b/src/views/system/notifyManage/index.vue @@ -89,7 +89,7 @@ - +
@@ -182,44 +182,64 @@ 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 { - 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 - 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 @@ -286,14 +306,17 @@ export default { this.isEdit = false this.sendVisible = true }, + // 修改 handleEdit() { this.isEdit = true 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) { this.pushObj = '用户' + this.selectOptions = temp.length === this.userOptions.length - 1 ? [0, ...temp] : temp } else { this.pushObj = '设备' + this.selectOptions = temp.length === this.devOptions.length - 1 ? [0, ...temp] : temp } this.sendVisible = true }, @@ -311,6 +334,7 @@ export default { 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) @@ -337,7 +361,6 @@ export default { }) this.$refs.formDom.resetFields() this.$refs.formDom.clearValidate() - // this.crud.refresh() } else { this.btnloading = false this.$message.error('发布失败') @@ -347,6 +370,9 @@ export default { handleClose() { this.$refs.formDom.resetFields() this.$refs.formDom.clearValidate() + this.sendForm.notification = '' + this.pushObj = '用户' + this.noticeType = 1 }, // 删除 handleDel() { @@ -400,42 +426,9 @@ export default { } 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) { if (val) { - // this.selectOptions = [] - // this.showTags = false this.defaultSelAll() this.showTags = true }