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()" @keyup.enter.native="dataFormSubmitHandle()"
:label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'">
<el-form-item label="所属街道" <el-form-item label="所属街道"
prop="deptId"> prop="streetId">
<el-select v-model="streetId" <el-select v-model="dataForm.streetId"
@change="changeStreet" @change="changeStreet"
placeholder="所属街道"> placeholder="所属街道">
<el-option v-for="item in streetList" <el-option v-for="item in streetList"
@ -21,7 +21,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="所属社区"> <el-form-item label="所属社区">
<el-select v-model="communityId" <el-select v-model="dataForm.communityId"
@change="changeCommunity" @change="changeCommunity"
placeholder="所属社区"> placeholder="所属社区">
<el-option v-for="item in communityList" <el-option v-for="item in communityList"
@ -32,7 +32,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="所属网格"> <el-form-item label="所属网格">
<el-select v-model="gridId" <el-select v-model="dataForm.gridId"
@change="changeGrid" @change="changeGrid"
placeholder="所属网格"> placeholder="所属网格">
<el-option v-for="item in gridList" <el-option v-for="item in gridList"
@ -82,8 +82,12 @@ export default {
visible: false, visible: false,
dataForm: { dataForm: {
id: '', id: '',
dept: '', streetId: '',
deptId: '', street: '',
communityId: '',
community: '',
gridId: '',
grid: '',
noticeTitle: '', noticeTitle: '',
noticeContent: '' noticeContent: ''
}, },
@ -106,18 +110,15 @@ export default {
], ],
uploadUrl: '', uploadUrl: '',
// end // end
streetId: '',
streetList: [], streetList: [],
communityId: '',
communityList: [], communityList: [],
gridId: '',
gridList: [] gridList: []
} }
}, },
computed: { computed: {
dataRule () { dataRule () {
return { return {
deptId: [ streetId: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } { required: true, message: this.$t('validate.required'), trigger: 'blur' }
], ],
noticeTitle: [ noticeTitle: [
@ -130,6 +131,7 @@ export default {
} }
}, },
created () { created () {
// 1169154711480528897 ID
this.getDeptInfoList('street', '1169154711480528897') this.getDeptInfoList('street', '1169154711480528897')
}, },
methods: { methods: {
@ -167,7 +169,7 @@ export default {
init () { init () {
this.visible = true this.visible = true
this.$nextTick(() => { this.$nextTick(() => {
this.communityId = this.streetId = this.gridId = null this.dataForm.communityId = this.dataForm.streetId = this.dataForm.gridId = null
// //
this.hideUpload = false this.hideUpload = false
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}`
@ -191,6 +193,12 @@ export default {
} }
this.dataForm = res.data this.dataForm = res.data
this.quillEditor.root.innerHTML = res.data.noticeContent 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(() => { }) }).catch(() => { })
}, },
// //
@ -199,7 +207,7 @@ export default {
if (!valid) { if (!valid) {
return false 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) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
@ -230,30 +238,30 @@ export default {
} }
}).catch(() => { }) }).catch(() => { })
}, },
changeStreet (event) { changeStreet () {
this.streetId = event //
let choosenItem = this.streetList.filter(item => item.id === this.streetId)[0] let choosenItem = this.streetList.filter(item => item.id === this.dataForm.streetId)[0]
this.initDeptIdAndName(choosenItem) this.dataForm.street = choosenItem.name
this.communityId = this.gridId = null //
this.dataForm.communityId = this.dataForm.gridId = this.dataForm.community = this.grid = null
this.communityList = this.gridList = [] this.communityList = this.gridList = []
this.getDeptInfoList('community', event) //
this.getDeptInfoList('community', this.dataForm.streetId)
}, },
changeCommunity (event) { changeCommunity () {
this.communityId = event //
let choosenItem = this.communityList.filter(item => item.id === this.communityId)[0] let choosenItem = this.communityList.filter(item => item.id === this.dataForm.communityId)[0]
this.initDeptIdAndName(choosenItem) this.dataForm.community = choosenItem.name
this.gridId = null //
this.dataForm.gridId = this.dataForm.grid = null
this.gridList = [] this.gridList = []
this.getDeptInfoList('grid', event) //
}, this.getDeptInfoList('grid', this.dataForm.communityId)
changeGrid (event) {
this.gridId = event
let choosenItem = this.gridList.filter(item => item.id === this.gridId)[0]
this.initDeptIdAndName(choosenItem)
}, },
initDeptIdAndName (choosenItem) { changeGrid () {
this.dataForm.dept = choosenItem.name //
this.dataForm.deptId = choosenItem.id 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" :model="dataForm"
@keyup.enter.native="getDataList()"> @keyup.enter.native="getDataList()">
<el-form-item> <el-form-item>
<el-input v-model="dataForm.id" <el-input v-model="dataForm.noticeTitle"
placeholder="id" placeholder="通知标题"
clearable></el-input> clearable></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -37,10 +37,15 @@
label="通知标题" label="通知标题"
header-align="center" header-align="center"
align="center"></el-table-column> align="center"></el-table-column>
<el-table-column prop="dept" <el-table-column prop="deptName"
label="发布通知部门" label="发布通知部门"
header-align="center" header-align="center"
align="center"></el-table-column> 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" <el-table-column prop="readingAmount"
label="阅读量" label="阅读量"
header-align="center" header-align="center"
@ -57,15 +62,19 @@
fixed="right" fixed="right"
header-align="center" header-align="center"
align="center" align="center"
width="150"> width="300">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-if="$hasPermission('news:notice:update')" <el-button v-if="$hasPermission('news:notice:update')"
type="text" type="primary"
size="small" size="mini"
@click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button> @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')" <el-button v-if="$hasPermission('news:notice:delete')"
type="text" type="danger"
size="small" size="mini"
@click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button> @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -100,12 +109,37 @@ export default {
deleteIsBatch: true deleteIsBatch: true
}, },
dataForm: { dataForm: {
id: '' id: '',
noticeTitle: ''
} }
} }
}, },
components: { components: {
AddOrUpdate 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> </script>

Loading…
Cancel
Save