Browse Source

通知相关

master
yujintao 6 years ago
parent
commit
cd6493958b
  1. 72
      src/views/modules/news/notice-add-or-update.vue
  2. 52
      src/views/modules/news/notice.vue

72
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'">
<el-form-item label="所属街道"
prop="deptId">
<el-select v-model="streetId"
prop="streetId">
<el-select v-model="dataForm.streetId"
@change="changeStreet"
placeholder="所属街道">
<el-option v-for="item in streetList"
@ -21,7 +21,7 @@
</el-select>
</el-form-item>
<el-form-item label="所属社区">
<el-select v-model="communityId"
<el-select v-model="dataForm.communityId"
@change="changeCommunity"
placeholder="所属社区">
<el-option v-for="item in communityList"
@ -32,7 +32,7 @@
</el-select>
</el-form-item>
<el-form-item label="所属网格">
<el-select v-model="gridId"
<el-select v-model="dataForm.gridId"
@change="changeGrid"
placeholder="所属网格">
<el-option v-for="item in gridList"
@ -82,8 +82,12 @@ export default {
visible: false,
dataForm: {
id: '',
dept: '',
deptId: '',
streetId: '',
street: '',
communityId: '',
community: '',
gridId: '',
grid: '',
noticeTitle: '',
noticeContent: ''
},
@ -106,18 +110,15 @@ export default {
],
uploadUrl: '',
// end
streetId: '',
streetList: [],
communityId: '',
communityList: [],
gridId: '',
gridList: []
}
},
computed: {
dataRule () {
return {
deptId: [
streetId: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
noticeTitle: [
@ -130,6 +131,7 @@ export default {
}
},
created () {
// 1169154711480528897 ID
this.getDeptInfoList('street', '1169154711480528897')
},
methods: {
@ -167,7 +169,7 @@ export default {
init () {
this.visible = true
this.$nextTick(() => {
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
}
}

52
src/views/modules/news/notice.vue

@ -6,8 +6,8 @@
:model="dataForm"
@keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.id"
placeholder="id"
<el-input v-model="dataForm.noticeTitle"
placeholder="通知标题"
clearable></el-input>
</el-form-item>
<el-form-item>
@ -37,10 +37,15 @@
label="通知标题"
header-align="center"
align="center"></el-table-column>
<el-table-column prop="dept"
<el-table-column prop="deptName"
label="发布通知部门"
header-align="center"
align="center"></el-table-column>
<el-table-column prop="isPublish"
label="已发布"
header-align="center"
:formatter="showIsPublishFormatter"
align="center"></el-table-column>
<el-table-column prop="readingAmount"
label="阅读量"
header-align="center"
@ -57,15 +62,19 @@
fixed="right"
header-align="center"
align="center"
width="150">
width="300">
<template slot-scope="scope">
<el-button v-if="$hasPermission('news:notice:update')"
type="text"
size="small"
type="primary"
size="mini"
@click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
<el-button v-if="$hasPermission('news:notice:publish') && scope.row.isPublish === '0'"
type="primary"
size="mini"
@click="noticePublishHandle(scope.row.id)">发布</el-button>
<el-button v-if="$hasPermission('news:notice:delete')"
type="text"
size="small"
type="danger"
size="mini"
@click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
</template>
</el-table-column>
@ -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 '是'
}
}
}
</script>

Loading…
Cancel
Save