锦水项目前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
6.9 KiB

6 years ago
<template>
<el-card shadow="never"
class="aui-card--fill">
<div class="mod-news__notice}">
<el-form :inline="true"
:model="dataForm"
@keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.noticeTitle"
placeholder="通知标题"
clearable></el-input>
</el-form-item>
<el-form-item label="所属模块" prop="noticeCategory">
<el-select v-model="dataForm.noticeCategory" placeholder="请选择模块" clearable>
<el-option
v-for="item in optionNoticeCategoryCode"
:key="item.dictValue"
:label="item.dictName"
:value="item.dictValue">
</el-option>
</el-select>
</el-form-item>
6 years ago
<el-form-item>
<el-button @click="getDataList()">{{ $t('query') }}</el-button>
</el-form-item>
<el-form-item>
<el-button v-if="$hasPermission('news:notice:save')"
type="primary"
@click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
</el-form-item>
<el-form-item>
<el-button v-if="$hasPermission('news:notice:delete')"
type="danger"
@click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
</el-form-item>
</el-form>
<el-table v-loading="dataListLoading"
:data="dataList"
border
@selection-change="dataListSelectionChangeHandle"
style="width: 100%;">
<el-table-column type="selection"
header-align="center"
align="center"></el-table-column>
<el-table-column prop="noticeTitle"
label="通知标题"
header-align="center"
align="center"
width="350"></el-table-column>
<el-table-column prop="noticeCategory"
label="所属模块"
6 years ago
header-align="center"
align="center"
:formatter="noticeCategoryFormat"></el-table-column>
6 years ago
<el-table-column prop="readingAmount"
label="阅读量"
header-align="center"
align="center"
width="100"></el-table-column>
<el-table-column prop="noticeReleaseState"
label="已发布"
header-align="center"
:formatter="showIsPublishFormatter"
align="center"
width="100"></el-table-column>
<el-table-column prop="releaseTime"
label="发布时间"
header-align="center"
align="center"
width="220"></el-table-column>
6 years ago
<el-table-column :label="$t('handle')"
fixed="right"
header-align="center"
align="center"
width="240">
6 years ago
<template slot-scope="scope">
<el-button v-if="$hasPermission('news:notice:update')"
type="primary"
size="mini"
@click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
<el-button v-if="$hasPermission('news:notice:publish') && scope.row.noticeReleaseState === '0'"
type="primary"
size="mini"
@click="noticePublishHandle(scope.row.id)">发布</el-button>
<el-button v-if="$hasPermission('news:notice:delete')"
type="danger"
size="mini"
@click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination :current-page="page"
:page-sizes="[10, 20, 50, 100]"
:page-size="limit"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="pageSizeChangeHandle"
@current-change="pageCurrentChangeHandle">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible"
ref="addOrUpdate"
@refreshDataList="getDataList"></add-or-update>
</div>
</el-card>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './notice-add-or-update'
export default {
mixins: [mixinViewModule],
data () {
return {
mixinViewModuleOptions: {
getDataListURL: '/news/notice/page',
getDataListIsPage: true,
deleteURL: '/news/notice',
deleteIsBatch: true
},
dataForm: {
noticeTitle: ''
},
optionNoticeCategoryCode: []
6 years ago
}
},
components: {
AddOrUpdate
},
created () {
// 根据数据字典类型notice_category 获取简版数据字典列表,用于页面下拉菜单
this.getListSimpleByDictType()
},
6 years ago
methods: {
// 发布通知
noticePublishHandle (id) {
this.$confirm(this.$t('prompt.info', { 'handle': '发布' }), this.$t('发布'), {
confirmButtonText: this.$t('confirm'),
cancelButtonText: this.$t('cancel'),
type: 'warning'
}).then(() => {
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(() => { })
}).catch(() => { })
},
showIsPublishFormatter: function (row, column) {
if (row.noticeReleaseState === '0') {
return '否'
}
return '是'
},
showDeptNameFormatter: function (row, column) {
if (row.grid) {
return row.grid
}
if (row.community) {
return row.community
}
if (row.street) {
return row.street
}
},
getListSimpleByDictType () {
this.$http.get(`/news/notice/listSimple/notice_category`).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.optionNoticeCategoryCode = res.data
}).catch(() => {})
},
noticeCategoryFormat (row, column) {
for (var property in this.optionNoticeCategoryCode) {
if (row.noticeCategory === this.optionNoticeCategoryCode[property].dictValue) {
return this.optionNoticeCategoryCode[property].dictName
}
}
6 years ago
}
}
}
</script>