From cd6493958b6531f08527d85ad5958bcd306128bc Mon Sep 17 00:00:00 2001 From: yujintao Date: Thu, 5 Sep 2019 17:08:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/news/notice-add-or-update.vue | 72 ++++++++++--------- src/views/modules/news/notice.vue | 52 +++++++++++--- 2 files changed, 83 insertions(+), 41 deletions(-) diff --git a/src/views/modules/news/notice-add-or-update.vue b/src/views/modules/news/notice-add-or-update.vue index 9a2753d5..e69e524d 100644 --- a/src/views/modules/news/notice-add-or-update.vue +++ b/src/views/modules/news/notice-add-or-update.vue @@ -9,8 +9,8 @@ @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> - + - - { - this.communityId = this.streetId = this.gridId = null + this.dataForm.communityId = this.dataForm.streetId = this.dataForm.gridId = null // 富文本 this.hideUpload = false this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` @@ -191,6 +193,12 @@ export default { } this.dataForm = res.data this.quillEditor.root.innerHTML = res.data.noticeContent + if (this.dataForm.streetId) { + this.getDeptInfoList('community', this.dataForm.streetId) + } + if (this.dataForm.communityId) { + this.getDeptInfoList('grid', this.dataForm.communityId) + } }).catch(() => { }) }, // 表单提交 @@ -199,7 +207,7 @@ export default { if (!valid) { return false } - this.$http[!this.dataForm.id ? 'post' : 'put']('/news/notice/', this.dataForm).then(({ data: res }) => { + this.$http[!this.dataForm.id ? 'post' : 'put']('/news/notice', this.dataForm).then(({ data: res }) => { if (res.code !== 0) { return this.$message.error(res.msg) } @@ -230,30 +238,30 @@ export default { } }).catch(() => { }) }, - changeStreet (event) { - this.streetId = event - let choosenItem = this.streetList.filter(item => item.id === this.streetId)[0] - this.initDeptIdAndName(choosenItem) - this.communityId = this.gridId = null + changeStreet () { + // 给街道变量赋值 + let choosenItem = this.streetList.filter(item => item.id === this.dataForm.streetId)[0] + this.dataForm.street = choosenItem.name + // 清空社区与网格的变量值 + this.dataForm.communityId = this.dataForm.gridId = this.dataForm.community = this.grid = null this.communityList = this.gridList = [] - this.getDeptInfoList('community', event) + // 获取街道下属社区 + this.getDeptInfoList('community', this.dataForm.streetId) }, - changeCommunity (event) { - this.communityId = event - let choosenItem = this.communityList.filter(item => item.id === this.communityId)[0] - this.initDeptIdAndName(choosenItem) - this.gridId = null + changeCommunity () { + // 给社区变量赋值 + let choosenItem = this.communityList.filter(item => item.id === this.dataForm.communityId)[0] + this.dataForm.community = choosenItem.name + // 情况网格的变量值 + this.dataForm.gridId = this.dataForm.grid = null this.gridList = [] - this.getDeptInfoList('grid', event) - }, - changeGrid (event) { - this.gridId = event - let choosenItem = this.gridList.filter(item => item.id === this.gridId)[0] - this.initDeptIdAndName(choosenItem) + // 获取社区下属网格 + this.getDeptInfoList('grid', this.dataForm.communityId) }, - initDeptIdAndName (choosenItem) { - this.dataForm.dept = choosenItem.name - this.dataForm.deptId = choosenItem.id + changeGrid () { + // 给网格变量赋值 + let choosenItem = this.gridList.filter(item => item.id === this.dataForm.gridId)[0] + this.dataForm.grid = choosenItem.name } } diff --git a/src/views/modules/news/notice.vue b/src/views/modules/news/notice.vue index b7b83114..8725e177 100644 --- a/src/views/modules/news/notice.vue +++ b/src/views/modules/news/notice.vue @@ -6,8 +6,8 @@ :model="dataForm" @keyup.enter.native="getDataList()"> - @@ -37,10 +37,15 @@ label="通知标题" header-align="center" align="center"> - + + width="300"> @@ -100,12 +109,37 @@ export default { deleteIsBatch: true }, dataForm: { - id: '' + id: '', + noticeTitle: '' } } }, components: { AddOrUpdate + }, + methods: { + // 发布通知 + noticePublishHandle (id) { + this.$http.post(`/news/notice/publish/${id}`).then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg) + } + this.$message({ + message: this.$t('prompt.success'), + type: 'success', + duration: 500, + onClose: () => { + this.getDataList() + } + }) + }).catch(() => { }) + }, + showIsPublishFormatter: function (row, column) { + if (row.isPublish === '0') { + return '否' + } + return '是' + } } }