13 changed files with 3025 additions and 0 deletions
@ -0,0 +1,371 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" |
|||
title="查看" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
@close="visible= false"> |
|||
<el-form :model="dataForm" |
|||
:rules="dataRule" |
|||
ref="dataForm" |
|||
:label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|||
<el-form-item label="新闻模块" |
|||
prop="businessName"> |
|||
{{dataForm.businessName}} |
|||
</el-form-item> |
|||
<el-form-item label="类别" |
|||
prop="newsCateroryId"> |
|||
<el-form-item> |
|||
{{dataForm.newsProperty}} |
|||
</el-form-item> |
|||
</el-form-item> |
|||
<el-form-item label="栏目" |
|||
prop="newsSubCateroryId"> |
|||
<el-form-item> |
|||
{{dataForm.newsColumn}} |
|||
</el-form-item> |
|||
</el-form-item> |
|||
<el-form-item label="新闻标题" |
|||
prop="newsTitle"> |
|||
<el-form-item> |
|||
{{dataForm.newsTitle}} |
|||
</el-form-item> |
|||
</el-form-item> |
|||
<el-form-item prop="newsContent" |
|||
label="正文编辑"> |
|||
<!-- 富文本编辑器, 容器 --> |
|||
<div id="J_quillEditor"></div> |
|||
<!-- 自定义上传图片功能 (使用element upload组件) --> |
|||
<el-upload :action="uploadUrl" |
|||
:show-file-list="false" |
|||
:before-upload="uploadBeforeUploadHandle" |
|||
:on-success="uploadSuccessHandle" |
|||
style="display: none;"> |
|||
<el-button ref="uploadBtn" |
|||
type="primary" |
|||
size="small">{{ $t('upload.button') }}</el-button> |
|||
</el-upload> |
|||
</el-form-item> |
|||
<el-form-item v-if="dataForm.newsApprovalState === '1'" label="驳回原因" |
|||
prop="approvalReason"> |
|||
<el-form-item> |
|||
{{dataForm.approvalReason}} |
|||
</el-form-item> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-dialog |
|||
width="30%" |
|||
title="驳回原因" |
|||
:visible.sync="dialogVisible" |
|||
append-to-body> |
|||
<el-form :model="dataForm" |
|||
:rules="dataRule" |
|||
ref="dataForm"> |
|||
<el-form-item label="驳回原因" prop="approvalReason"> |
|||
<el-input type="textarea" v-model="dataForm.approvalReason" placeholder="不超过1000字"></el-input> |
|||
</el-form-item> |
|||
<el-button @click="dialogVisible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" @click="reviewRefusal">确 定</el-button> |
|||
</el-form> |
|||
</el-dialog> |
|||
<template slot="footer"> |
|||
<el-button v-if="$hasPermission('honest:newshonest:review') && dataForm.newsApprovalState === '0'" type="primary" @click="reviewOk">通过</el-button> |
|||
<el-button v-if="$hasPermission('honest:newshonest:review') && dataForm.newsApprovalState === '0'" type="primary" @click="beforeRefusal">驳回</el-button> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import Cookies from 'js-cookie' |
|||
import debounce from 'lodash/debounce' |
|||
import 'quill/dist/quill.snow.css' |
|||
import Quill from 'quill' |
|||
import mixinViewModule from '@/mixins/view-module' |
|||
import AddOrUpdate from './newshonest-add-or-update' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/news/newshonest/page', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/news/newshonest', |
|||
deleteIsBatch: true |
|||
}, |
|||
dataForm: { |
|||
id: '', |
|||
businessId: '', |
|||
newsCateroryId: '', |
|||
newsSubCateroryId: '', |
|||
newsProperty: '', |
|||
newsColumn: '', |
|||
newsTitle: '', |
|||
newsReleaseStartTime: '', |
|||
newsReleaseEndTime: '', |
|||
newsContent: '', |
|||
newsImageUrl: '', |
|||
businessName: '', |
|||
allDeptIdsShow: [] |
|||
}, |
|||
dialogVisible: false, |
|||
time: [], |
|||
options: [], |
|||
categorys: [], |
|||
loading: false, |
|||
// 富文本 |
|||
quillEditor: null, |
|||
quillEditorToolbarOptions: [ |
|||
['bold', 'italic', 'underline', 'strike'], |
|||
['blockquote', 'code-block', 'image'], |
|||
[{ 'header': 1 }, { 'header': 2 }], |
|||
[{ 'list': 'ordered' }, { 'list': 'bullet' }], |
|||
[{ 'script': 'sub' }, { 'script': 'super' }], |
|||
[{ 'indent': '-1' }, { 'indent': '+1' }], |
|||
[{ 'direction': 'rtl' }], |
|||
[{ 'size': ['small', false, 'large', 'huge'] }], |
|||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }], |
|||
[{ 'color': [] }, { 'background': [] }], |
|||
[{ 'font': [] }], |
|||
[{ 'align': [] }], |
|||
['clean'] |
|||
], |
|||
uploadUrl: '', |
|||
// 富文本end |
|||
fileList: [], |
|||
visible: false |
|||
} |
|||
}, |
|||
created () { |
|||
this.getListCategory() |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
// 富文本 |
|||
this.hideUpload = false |
|||
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
|||
if (this.quillEditor) { |
|||
this.quillEditor.deleteText(0, this.quillEditor.getLength()) |
|||
} else { |
|||
this.quillEditorHandle() |
|||
} |
|||
// 富文本end |
|||
}) |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
approvalReason: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.dataForm.newsProperty = '' |
|||
this.dataForm.newsColumn = '' |
|||
this.$http.get(`/news/newshonest/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { ...this.dataForm, ...res.data } |
|||
this.quillEditor.root.innerHTML = res.data.newsContent |
|||
let business = this.options.find(item=>{ |
|||
return item.code === this.dataForm.businessId |
|||
}) |
|||
this.dataForm.businessName = business.title |
|||
}).catch(() => { }) |
|||
}, |
|||
reviewOk () { |
|||
this.dataForm.newsApprovalState = 2 |
|||
this.dataForm.newsUpDownState = 0 |
|||
this.dataForm.approvalReason = '' |
|||
this.visible = false |
|||
this.$http['post']('/news/newshonest/review', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
}).catch(() => { }) |
|||
}, |
|||
handleClose(done) { |
|||
this.$confirm('确认关闭?') |
|||
.then(_ => { |
|||
done(); |
|||
}) |
|||
.catch(_ => {}); |
|||
}, |
|||
beforeRefusal () { |
|||
this.dialogVisible = true |
|||
}, |
|||
reviewRefusal () { |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.dataForm.newsApprovalState = 1 |
|||
this.dialogVisible = false |
|||
this.visible = false |
|||
this.$http['post']('/news/newshonest/review', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
}).catch(() => { }) |
|||
}) |
|||
}, |
|||
changeCaterory () { |
|||
// 给新闻类别变量赋值 |
|||
let choosenItem = this.categorys.filter(item => item.id === this.dataForm.newsCateroryId)[0] |
|||
this.dataForm.newsProperty = choosenItem.name |
|||
}, |
|||
getListCategory () { |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
// 富文本编辑器 |
|||
quillEditorHandle () { |
|||
this.quillEditor = new Quill('#J_quillEditor', { |
|||
modules: { |
|||
toolbar: this.quillEditorToolbarOptions |
|||
}, |
|||
readOnly: true, |
|||
theme: 'snow' |
|||
}) |
|||
this.quillEditor.container.style.height = `${300}px` |
|||
// // 自定义上传图片功能 (使用element upload组件) |
|||
this.quillEditor.getModule('toolbar').addHandler('image', () => { |
|||
this.$refs.uploadBtn.$el.click() |
|||
}) |
|||
// 监听内容变化,动态赋值 |
|||
this.quillEditor.on('text-change', () => { |
|||
this.dataForm.newsContent = this.quillEditor.root.innerHTML |
|||
if ((this.dataForm.newsContent).length > 10000) { |
|||
return this.$message.error('您输入的的内容已超过字数不能提交') |
|||
} |
|||
}) |
|||
}, |
|||
// 上传图片之前 (富文本) |
|||
uploadBeforeUploadHandle (file) { |
|||
if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') { |
|||
this.$message.error(this.$t('upload.tip', { 'format': 'jpg、png、gif' })) |
|||
return false |
|||
} |
|||
}, |
|||
// 上传图片成功 (富文本) |
|||
uploadSuccessHandle (res, file, fileList) { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.url) |
|||
}, |
|||
// 上传图片 |
|||
handleAvatarSuccess (res, file) { |
|||
this.loading = false |
|||
this.dataForm.newsImageUrl = res.data.url |
|||
}, |
|||
beforeAvatarUpload (file) { |
|||
this.loading = true |
|||
}, |
|||
setRegistTime () { |
|||
this.dataForm.newsReleaseStartTime = this.time[0] |
|||
this.dataForm.newsReleaseEndTime = this.time[1] |
|||
}, |
|||
resetRegistTime () { |
|||
this.time = [this.dataForm.newsReleaseStartTime.substr(0, 10), this.dataForm.newsReleaseEndTime.substr(0, 10)] |
|||
}, |
|||
// 上传图片end |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
if ((this.dataForm.newsContent).length > 10000) { |
|||
return this.$message.error('您输入的的内容已超过字数不能提交') |
|||
} |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http['put']('/news/newshonest/', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
}).catch(() => { }) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }) |
|||
}, |
|||
components: { |
|||
AddOrUpdate |
|||
} |
|||
} |
|||
</script> |
|||
<style> |
|||
.avatar-uploader .el-upload { |
|||
border: 1px dashed #d9d9d9; |
|||
border-radius: 6px; |
|||
cursor: pointer; |
|||
position: relative; |
|||
overflow: hidden; |
|||
} |
|||
.avatar-uploader .el-upload:hover { |
|||
border-color: #409eff; |
|||
} |
|||
.avatar-uploader-icon { |
|||
font-size: 28px; |
|||
color: #8c939d; |
|||
width: 178px; |
|||
height: 178px; |
|||
line-height: 178px; |
|||
text-align: center; |
|||
} |
|||
.avatar { |
|||
width: 178px; |
|||
height: 178px; |
|||
display: block; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,107 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false"> |
|||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|||
<el-tree |
|||
:data="deptData" |
|||
show-checkbox |
|||
default-expand-all |
|||
node-key="id" |
|||
ref="tree" |
|||
highlight-current |
|||
:props="defaultProps"> |
|||
</el-tree> |
|||
</el-form> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import debounce from 'lodash/debounce' |
|||
export default { |
|||
data () { |
|||
return { |
|||
visible: false, |
|||
dataForm: { |
|||
id: '', |
|||
gridId: '', |
|||
menuId: '', |
|||
deptList: [] |
|||
}, |
|||
defaultProps: { |
|||
children: 'children', |
|||
label: 'name' |
|||
}, |
|||
deptData: [] |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
gridId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
menuId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.visible = true |
|||
this.getDeptInfo(); |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
getDeptInfo () { |
|||
this.$http.get(`/sys/dept/list`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.deptData = res.data |
|||
}).catch(() => {}) |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.$http.get(`/news/gridmenurelation/tree/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.$refs.tree.setCheckedKeys(res.data.deptList); |
|||
}).catch(() => {}) |
|||
}, |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
let deptList =this.$refs.tree.getCheckedNodes().map(item=>item.id); |
|||
this.dataForm.deptList = deptList; |
|||
this.dataForm.menuId = this.dataForm.id; |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http['post']('/news/gridmenurelation/relation', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
} |
|||
}) |
|||
}).catch(() => {}) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }) |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,103 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-__gridmenurelation}"> |
|||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
|||
<el-form-item label="归属栏目" |
|||
prop="businessId"> |
|||
<el-select v-model="dataForm.businessId" |
|||
placeholder="归属栏目" clearable> |
|||
<el-option v-for="item in options" |
|||
:key="item.id" |
|||
:label="item.title" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button @click="getDataList()">{{ $t('query') }}</el-button> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button type="primary" @click="initMenu()">初始化菜单</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;"> |
|||
<el-table-column prop="title" label="菜单名称" header-align="center" align="center"></el-table-column> |
|||
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button> |
|||
<el-button type="text" size="small" @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 './gridmenurelation-add-or-update' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/news/gridmenurelation/menuPage', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/news/gridmenurelation', |
|||
deleteIsBatch: true |
|||
}, |
|||
options: [], |
|||
dataForm: { |
|||
id: '', |
|||
businessId: '' |
|||
} |
|||
} |
|||
}, |
|||
components: { |
|||
AddOrUpdate |
|||
}, |
|||
mounted() { |
|||
// 获取业务下拉菜单 |
|||
this.getBusinessOptions() |
|||
}, |
|||
methods: { |
|||
initMenu () { |
|||
this.$http.get(`/news/gridmenurelation/initPage`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { |
|||
...this.dataForm, |
|||
...res.data |
|||
} |
|||
this.getDataList() |
|||
}).catch(() => { }) |
|||
}, |
|||
getBusinessOptions () { |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,169 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false"> |
|||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|||
<el-form-item label="菜单名称" prop="title"> |
|||
<el-input v-model="dataForm.title" placeholder="菜单名称"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="菜单编码" prop="title"> |
|||
<el-input v-model="dataForm.code" placeholder="菜单编码"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="图标" |
|||
v-loading="loading" |
|||
prop="imgUrl"> |
|||
<el-upload class="avatar-uploader" |
|||
:action="this.uploadUrl" |
|||
:show-file-list="false" |
|||
:on-success="handleAvatarSuccess" |
|||
:on-error="handelError" |
|||
:before-upload="beforeAvatarUpload"> |
|||
<img v-if="dataForm.imgUrl" |
|||
:src="dataForm.imgUrl" |
|||
class="avatar"> |
|||
<i v-else |
|||
class="el-icon-plus avatar-uploader-icon"></i> |
|||
</el-upload> |
|||
</el-form-item> |
|||
<el-form-item label="备注" prop="description"> |
|||
<el-input v-model="dataForm.description" type="textarea" maxlength="1000" placeholder="备注"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="排序" prop="sort"> |
|||
<el-input-number v-model="dataForm.sort" controls-position="right" :min="0" label="显示顺序" max=1-00></el-input-number> |
|||
</el-form-item> |
|||
</el-form> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import debounce from 'lodash/debounce' |
|||
import Cookies from "js-cookie"; |
|||
export default { |
|||
data () { |
|||
return { |
|||
visible: false, |
|||
loading: false, |
|||
dataForm: { |
|||
id: '', |
|||
type: '0', |
|||
newsReleaseState: '', |
|||
title: '', |
|||
sort: '', |
|||
imgUrl: '', |
|||
description: '', |
|||
revision: '', |
|||
createdBy: '', |
|||
createdTime: '', |
|||
updatedBy: '', |
|||
updatedTime: '', |
|||
delFlag: '' |
|||
} |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
type: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
title: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
code: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
sort: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
imgUrl: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.$http.get(`/news/newsappmenu/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { |
|||
...this.dataForm, |
|||
...res.data |
|||
} |
|||
}).catch(() => {}) |
|||
}, |
|||
// 上传图片 |
|||
handleAvatarSuccess (res, file) { |
|||
this.dataForm.imgUrl = res.data.url |
|||
this.loading = false |
|||
}, |
|||
beforeAvatarUpload (file) { |
|||
this.loading = true |
|||
}, |
|||
handelError () { |
|||
this.loading = false |
|||
}, |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http[!this.dataForm.id ? 'post' : 'put']('/news/newsappmenu/', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
} |
|||
}) |
|||
}).catch(() => {}) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }) |
|||
} |
|||
} |
|||
</script> |
|||
<style scoped> |
|||
.avatar-uploader .el-upload { |
|||
border: 1px dashed #d9d9d9; |
|||
border-radius: 6px; |
|||
cursor: pointer; |
|||
position: relative; |
|||
overflow: hidden; |
|||
} |
|||
.avatar-uploader .el-upload:hover { |
|||
border-color: #409eff; |
|||
} |
|||
.avatar-uploader-icon { |
|||
font-size: 28px; |
|||
color: #8c939d; |
|||
width: 178px; |
|||
height: 178px; |
|||
line-height: 178px; |
|||
text-align: center; |
|||
} |
|||
.avatar { |
|||
width: 178px; |
|||
height: 178px; |
|||
display: block; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,74 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-__newsappmenu}"> |
|||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
|||
<el-form-item label="菜单名称"> |
|||
<el-input v-model="dataForm.title" placeholder="菜单名称" clearable></el-input> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button @click="getDataList()">{{ $t('query') }}</el-button> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</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" width="50"></el-table-column> |
|||
<el-table-column prop="title" label="菜单名称" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="imgUrl" |
|||
label="图标" |
|||
header-align="center" |
|||
width="100" |
|||
align="center"> |
|||
<template slot-scope="scope"> |
|||
<img :src="scope.row.imgUrl" |
|||
width="40" |
|||
height="40" /> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="description" label="备注" header-align="center" align="center"></el-table-column> |
|||
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150"> |
|||
<template slot-scope="scope"> |
|||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button> |
|||
<el-button type="text" size="small" @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 './newsappmenu-add-or-update' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/news/newsappmenu/page', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/news/newsappmenu', |
|||
deleteIsBatch: true |
|||
}, |
|||
dataForm: { |
|||
id: '' |
|||
} |
|||
} |
|||
}, |
|||
components: { |
|||
AddOrUpdate |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,433 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" |
|||
:title="!dataForm.id ? $t('add') : $t('update')" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
@close="visible= false"> |
|||
<el-form :model="dataForm" |
|||
:rules="dataRule" |
|||
ref="dataForm" |
|||
:label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|||
<el-form-item label="新闻模块" |
|||
prop="businessId"> |
|||
<el-select v-model="dataForm.businessId" @change="businessChange" ref="businessName" |
|||
placeholder="请选择类别"> |
|||
<el-option v-for="item in options" |
|||
:key="item.code" |
|||
:label="item.title" |
|||
:value="item.code"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="类别" |
|||
prop="newsCateroryId"> |
|||
<el-select v-model="dataForm.newsCateroryId" :disabled="!dataForm.businessId" |
|||
@change="categoryChange" ref="newsCateroryName" |
|||
placeholder="请选择类别"> |
|||
<el-option v-for="item in categorys" |
|||
:key="item.id" |
|||
:label="item.categoryName" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="栏目" |
|||
prop="newsSubCateroryId"> |
|||
<el-select v-model="dataForm.newsSubCateroryId" :disabled="!dataForm.newsCateroryId" |
|||
placeholder="请选择类别" ref="newsSubCateroryName"> |
|||
<el-option v-for="item in subCategorys" |
|||
:key="item.id" |
|||
:label="item.categoryName" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="新闻标题" |
|||
prop="newsTitle"> |
|||
<el-form-item> |
|||
<el-input v-model="dataForm.newsTitle" |
|||
maxlength="50" |
|||
show-word-limit |
|||
placeholder="请输入标题" |
|||
clearable></el-input> |
|||
</el-form-item> |
|||
</el-form-item> |
|||
<el-form-item prop="newsContent" |
|||
label="正文编辑"> |
|||
<!-- 富文本编辑器, 容器 --> |
|||
<div id="J_quillEditor"></div> |
|||
<!-- 自定义上传图片功能 (使用element upload组件) --> |
|||
<el-upload :action="uploadUrl" |
|||
:show-file-list="false" |
|||
:before-upload="uploadBeforeUploadHandle" |
|||
:on-success="uploadSuccessHandle" |
|||
style="display: none;"> |
|||
<el-button ref="uploadBtn" |
|||
type="primary" |
|||
size="small">{{ $t('upload.button') }}</el-button> |
|||
</el-upload> |
|||
</el-form-item> |
|||
<el-form-item v-if="dataForm.newsApprovalState === '1'" label="驳回原因" |
|||
prop="approvalReason"> |
|||
<el-form-item> |
|||
{{dataForm.approvalReason}} |
|||
</el-form-item> |
|||
</el-form-item> |
|||
</el-form> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" |
|||
@click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|||
<el-button v-if="dataForm.newsReleaseState === '1'" type="primary" @click="dataFormReleaseHandle()">提报</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import Cookies from 'js-cookie' |
|||
import debounce from 'lodash/debounce' |
|||
import 'quill/dist/quill.snow.css' |
|||
import Quill from 'quill' |
|||
import mixinViewModule from '@/mixins/view-module' |
|||
import AddOrUpdate from './newshonest-add-or-update' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/news/newshonest/page', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/news/newshonest', |
|||
deleteIsBatch: true |
|||
}, |
|||
dataForm: { |
|||
id: '', |
|||
businessId: '', |
|||
newsCateroryId: '', |
|||
newsSubCateroryId: '', |
|||
newsProperty: '', |
|||
newsColumn: '', |
|||
newsTitle: '', |
|||
newsReleaseStartTime: '', |
|||
newsReleaseEndTime: '', |
|||
newsContent: '', |
|||
newsImageUrl: '', |
|||
allDeptIdsShow: [] |
|||
}, |
|||
time: [], |
|||
streetList: [], |
|||
communityList: [], |
|||
gridList: [], |
|||
options: [], |
|||
categorys: [], |
|||
subCategorys: [], |
|||
loading: false, |
|||
// 富文本 |
|||
quillEditor: null, |
|||
quillEditorToolbarOptions: [ |
|||
['bold', 'italic', 'underline', 'strike'], |
|||
['blockquote', 'code-block', 'image'], |
|||
[{ 'header': 1 }, { 'header': 2 }], |
|||
[{ 'list': 'ordered' }, { 'list': 'bullet' }], |
|||
[{ 'script': 'sub' }, { 'script': 'super' }], |
|||
[{ 'indent': '-1' }, { 'indent': '+1' }], |
|||
[{ 'direction': 'rtl' }], |
|||
[{ 'size': ['small', false, 'large', 'huge'] }], |
|||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }], |
|||
[{ 'color': [] }, { 'background': [] }], |
|||
[{ 'font': [] }], |
|||
[{ 'align': [] }], |
|||
['clean'] |
|||
], |
|||
uploadUrl: '', |
|||
// 富文本end |
|||
fileList: [], |
|||
visible: false |
|||
} |
|||
}, |
|||
created () { |
|||
this.getListCategory() |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
// 富文本 |
|||
this.hideUpload = false |
|||
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
|||
if (this.quillEditor) { |
|||
this.quillEditor.deleteText(0, this.quillEditor.getLength()) |
|||
} else { |
|||
this.quillEditorHandle() |
|||
} |
|||
// 富文本end |
|||
}) |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
businessId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsTitle: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsSubCateroryId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsCateroryId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsContent: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
businessChange (item) { |
|||
this.dataForm.newsCateroryId = '' |
|||
this.dataForm.newsSubCateroryId = '' |
|||
// 类别 |
|||
this.$http |
|||
.get(`/news/newssection/options/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.categorys = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
categoryChange (item) { |
|||
this.dataForm.newsSubCateroryId = '' |
|||
// 栏目 |
|||
this.$http |
|||
.get(`/news/newssection/suboptions/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.subCategorys = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.$http.get(`/news/newshonest/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { ...this.dataForm, ...res.data } |
|||
this.resetRegistTime() |
|||
this.quillEditor.root.innerHTML = res.data.newsContent |
|||
// 类别 |
|||
this.$http |
|||
.get(`/news/newssection/options/` + this.dataForm.businessId) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.categorys = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
// 栏目 |
|||
this.$http |
|||
.get(`/news/newssection/suboptions/` + this.dataForm.newsCateroryId) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.subCategorys = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}).catch(() => { }) |
|||
}, |
|||
// 获取部门列表 |
|||
getDeptInfoList (dataReceiver, faDeptId) { |
|||
if (!faDeptId) { |
|||
return |
|||
} |
|||
this.$http.get(`/sys/dept/sublist/` + faDeptId).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
if (dataReceiver === 'street') { |
|||
let all = [{ id: '1', name: '全部' }] |
|||
this.streetList = all.concat(res.data) |
|||
} else if (dataReceiver === 'community') { |
|||
this.communityList = res.data |
|||
} else if (dataReceiver === 'grid') { |
|||
this.gridList = res.data |
|||
} |
|||
}).catch(() => { }) |
|||
}, |
|||
changeStreet (event) { |
|||
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.dataForm.grid = null |
|||
this.communityList = this.gridList = [] |
|||
this.getDeptInfoList('community', event) |
|||
}, |
|||
changeCommunity (event) { |
|||
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) { |
|||
let choosenItem = this.gridList.filter(item => item.id === this.dataForm.gridId)[0] |
|||
this.dataForm.grid = choosenItem.name |
|||
}, |
|||
changeCaterory () { |
|||
// 给新闻类别变量赋值 |
|||
let choosenItem = this.categorys.filter(item => item.id === this.dataForm.newsCateroryId)[0] |
|||
this.dataForm.newsProperty = choosenItem.name |
|||
}, |
|||
getListCategory () { |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
// 富文本编辑器 |
|||
quillEditorHandle () { |
|||
this.quillEditor = new Quill('#J_quillEditor', { |
|||
modules: { |
|||
toolbar: this.quillEditorToolbarOptions |
|||
}, |
|||
theme: 'snow' |
|||
}) |
|||
this.quillEditor.container.style.height = `${300}px` |
|||
// // 自定义上传图片功能 (使用element upload组件) |
|||
this.quillEditor.getModule('toolbar').addHandler('image', () => { |
|||
this.$refs.uploadBtn.$el.click() |
|||
}) |
|||
// 监听内容变化,动态赋值 |
|||
this.quillEditor.on('text-change', () => { |
|||
this.dataForm.newsContent = this.quillEditor.root.innerHTML |
|||
if ((this.dataForm.newsContent).length > 10000) { |
|||
return this.$message.error('您输入的的内容已超过字数不能提交') |
|||
} |
|||
}) |
|||
}, |
|||
// 上传图片之前 (富文本) |
|||
uploadBeforeUploadHandle (file) { |
|||
if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') { |
|||
this.$message.error(this.$t('upload.tip', { 'format': 'jpg、png、gif' })) |
|||
return false |
|||
} |
|||
}, |
|||
// 上传图片成功 (富文本) |
|||
uploadSuccessHandle (res, file, fileList) { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.url) |
|||
}, |
|||
// 上传图片 |
|||
handleAvatarSuccess (res, file) { |
|||
this.loading = false |
|||
this.dataForm.newsImageUrl = res.data.url |
|||
}, |
|||
beforeAvatarUpload (file) { |
|||
this.loading = true |
|||
}, |
|||
setRegistTime () { |
|||
this.dataForm.newsReleaseStartTime = this.time[0] |
|||
this.dataForm.newsReleaseEndTime = this.time[1] |
|||
}, |
|||
resetRegistTime () { |
|||
this.time = [this.dataForm.newsReleaseStartTime.substr(0, 10), this.dataForm.newsReleaseEndTime.substr(0, 10)] |
|||
}, |
|||
// 上传图片end |
|||
dataFormReleaseHandle () { |
|||
this.dataForm.newsReleaseState = 0 |
|||
this.dataFormSubmitHandle() |
|||
}, |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
this.dataForm.newsProperty = this.$refs.newsCateroryName.selectedLabel |
|||
this.dataForm.newsColumn = this.$refs.newsSubCateroryName.selectedLabel |
|||
// if ((this.dataForm.newsContent).length > 10000) { |
|||
// return this.$message.error('您输入的的内容已超过字数不能提交') |
|||
// } |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http['put']('/news/newshonest/', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
}).catch(() => { }) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }) |
|||
}, |
|||
components: { |
|||
AddOrUpdate |
|||
} |
|||
} |
|||
</script> |
|||
<style> |
|||
.avatar-uploader .el-upload { |
|||
border: 1px dashed #d9d9d9; |
|||
border-radius: 6px; |
|||
cursor: pointer; |
|||
position: relative; |
|||
overflow: hidden; |
|||
} |
|||
.avatar-uploader .el-upload:hover { |
|||
border-color: #409eff; |
|||
} |
|||
.avatar-uploader-icon { |
|||
font-size: 28px; |
|||
color: #8c939d; |
|||
width: 178px; |
|||
height: 178px; |
|||
line-height: 178px; |
|||
text-align: center; |
|||
} |
|||
.avatar { |
|||
width: 178px; |
|||
height: 178px; |
|||
display: block; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,195 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-__newshonest}"> |
|||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
|||
<el-form-item label="新闻标题"> |
|||
<el-input v-model="dataForm.newsTitle" placeholder="新闻标题" clearable></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="新闻模块" |
|||
prop="businessId"> |
|||
<el-select v-model="dataForm.businessId" @change="businessChange" |
|||
placeholder="新闻模块" clearable> |
|||
<el-option v-for="item in options" |
|||
:key="item.code" |
|||
:label="item.title" |
|||
:value="item.code"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="新闻类别" |
|||
prop="newsCateroryId"> |
|||
<el-select v-model="dataForm.newsCateroryId" :disabled="!dataForm.businessId" |
|||
placeholder="新闻类别" clearable @change="categoryChange"> |
|||
<el-option v-for="item in newsCateroryIds" |
|||
:key="item.id" |
|||
:label="item.categoryName" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="新闻栏目" |
|||
prop="newsSubCateroryId"> |
|||
<el-select v-model="dataForm.newsSubCateroryId" :disabled="!dataForm.newsCateroryId" |
|||
placeholder="新闻栏目" clearable> |
|||
<el-option v-for="item in newsSubCateroryIds" |
|||
:key="item.id" |
|||
:label="item.title" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button @click="getDataList()">{{ $t('query') }}</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;"> |
|||
<el-table-column prop="newsTitle" label="新闻标题" header-align="center" width="400" align="center"></el-table-column> |
|||
<el-table-column prop="newsProperty" label="新闻类别" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="newsColumn" label="新闻栏目" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="newsApprovalState" label="审核状态" sortable="custom" header-align="center" align="center"> |
|||
<template slot-scope="scope"> |
|||
<el-tag v-if="scope.row.newsApprovalState === '0'" size="small" type="warn">未审核</el-tag> |
|||
<el-tag v-if="scope.row.newsApprovalState === '1'" size="small" type="danger">驳回</el-tag> |
|||
<el-tag v-if="scope.row.newsApprovalState === '2'" size="small" type="success">审核完成</el-tag> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="creatorName" label="创建人姓名" header-align="center" align="center"></el-table-column> |
|||
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150"> |
|||
<template slot-scope="scope"> |
|||
<el-button v-if="$hasPermission('honest:newshonest:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</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 './newshonest-add-or-update' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/news/newshonest/draftPage', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/news/newshonest', |
|||
deleteIsBatch: true |
|||
}, |
|||
dataForm: { |
|||
id: '', |
|||
newsUpDownState: '' |
|||
}, |
|||
newsCateroryIds: [], |
|||
newsSubCateroryIds: [], |
|||
options: [] |
|||
} |
|||
}, |
|||
components: { |
|||
AddOrUpdate |
|||
}, |
|||
mounted() { |
|||
// 获取业务下拉菜单 |
|||
this.getBusinessOptions() |
|||
}, |
|||
methods: { |
|||
businessChange (item) { |
|||
// 类别 |
|||
this.$http |
|||
.get(`/news/newssection/options/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.newsCateroryIds = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
categoryChange (item) { |
|||
// 类别 |
|||
this.$http |
|||
.get(`/news/newssection/options/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.newsCateroryIds = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
getBusinessOptions () { |
|||
// 归属栏目 |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
DownStateChange (id) { |
|||
this.dataForm.id = id |
|||
this.dataForm.newsUpDownState = 1 |
|||
this.$http['post']('/news/newshonest/review', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
this.getDataList() |
|||
}).catch(() => { }) |
|||
}, |
|||
UpStateChange (id) { |
|||
this.dataForm.id = id |
|||
this.dataForm.newsUpDownState = 0 |
|||
this.$http['post']('/news/newshonest/review', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
this.getDataList() |
|||
}).catch(() => { }) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,251 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-__newshonest}"> |
|||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
|||
<el-form-item label="新闻标题"> |
|||
<el-input v-model="dataForm.newsTitle" placeholder="新闻标题" @change="resetPage" clearable></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="新闻模块" |
|||
prop="businessId"> |
|||
<el-select v-model="dataForm.businessId" @change="businessChange" |
|||
placeholder="新闻模块" clearable> |
|||
<el-option v-for="item in options" |
|||
:key="item.code" |
|||
:label="item.title" |
|||
:value="item.code"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="新闻类别" |
|||
prop="newsCateroryId"> |
|||
<el-select v-model="dataForm.newsCateroryId" :disabled="!dataForm.businessId" |
|||
placeholder="新闻类别" clearable @change="categoryChange"> |
|||
<el-option v-for="item in newsCateroryIds" |
|||
:key="item.id" |
|||
:label="item.categoryName" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="新闻栏目" |
|||
prop="newsSubCateroryId"> |
|||
<el-select v-model="dataForm.newsSubCateroryId" :disabled="!dataForm.newsCateroryId" |
|||
placeholder="新闻栏目" @change="resetPage" clearable> |
|||
<el-option v-for="item in newsSubCateroryIds" |
|||
:key="item.id" |
|||
:label="item.title" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="审核状态" |
|||
prop="newsApprovalState"> |
|||
<el-select v-model="dataForm.newsApprovalState" |
|||
placeholder="审核状态" @change="resetPage" clearable> |
|||
<el-option v-for="item in approvalOptions" |
|||
:key="item.id" |
|||
:label="item.title" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button @click="getDataList()">{{ $t('query') }}</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;"> |
|||
<el-table-column prop="newsTitle" label="新闻标题" header-align="center" width="400" align="center"></el-table-column> |
|||
<el-table-column prop="newsProperty" label="新闻类别" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="newsColumn" label="新闻栏目" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="newsApprovalState" label="审核状态" sortable="custom" header-align="center" align="center"> |
|||
<template slot-scope="scope"> |
|||
<el-tag v-if="scope.row.newsApprovalState === '0'" size="small" type="warn">未审核</el-tag> |
|||
<el-tag v-if="scope.row.newsApprovalState === '1'" size="small" type="danger">驳回</el-tag> |
|||
<el-tag v-if="scope.row.newsApprovalState === '2'" size="small" type="success">审核完成</el-tag> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="newsUpDownState" label="上线状态" sortable="custom" header-align="center" align="center"> |
|||
<template slot-scope="scope"> |
|||
<el-tag v-if="scope.row.newsUpDownState === '1'" size="small" type="danger">下线</el-tag> |
|||
<el-tag v-else size="small" type="success">上线</el-tag> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="readingAmount" label="阅读量" header-align="center" width="80" align="center"></el-table-column> |
|||
<el-table-column prop="creatorName" label="创建人姓名" header-align="center" align="center"> |
|||
<template slot-scope="scope"> |
|||
<span v-if="scope.row.businessId === 'HONEST'">system</span> |
|||
<span v-else >{{ scope.row.creatorName }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150"> |
|||
<template slot-scope="scope"> |
|||
<el-button v-if="$hasPermission('honest:newshonest:review') && scope.row.newsApprovalState === '2' && scope.row.newsUpDownState === '1'" type="text" size="small" @click="UpStateChange(scope.row.id)">上线</el-button> |
|||
<el-button v-if="$hasPermission('honest:newshonest:review') && scope.row.newsUpDownState === '0'" type="text" size="small" @click="DownStateChange(scope.row.id)">下线</el-button> |
|||
<el-button v-if="$hasPermission('honest:newshonest:review') && scope.row.newsApprovalState === '0'" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">审核</el-button> |
|||
<el-button v-if="!$hasPermission('honest:newshonest:review') || ($hasPermission('honest:newshonest:review') && scope.row.newsApprovalState !== '0')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">查看</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 './allnewshonest-add-or-update' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/news/newshonest/list', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/news/newshonest', |
|||
deleteIsBatch: true |
|||
}, |
|||
dataForm: { |
|||
id: '', |
|||
newsUpDownState: '' |
|||
}, |
|||
approvalOptions: [ |
|||
{ |
|||
id: '0', |
|||
title: '未审核' |
|||
}, |
|||
{ |
|||
id: '1', |
|||
title: '驳回' |
|||
},{ |
|||
id: '2', |
|||
title: '审核完成' |
|||
} |
|||
], |
|||
newsCateroryIds: [], |
|||
newsSubCateroryIds: [], |
|||
options: [] |
|||
} |
|||
}, |
|||
components: { |
|||
AddOrUpdate |
|||
}, |
|||
mounted() { |
|||
// 获取业务下拉菜单 |
|||
this.getBusinessOptions() |
|||
}, |
|||
methods: { |
|||
resetPage () { |
|||
this.page = 1 |
|||
}, |
|||
businessChange (item) { |
|||
this.resetPage() |
|||
// 类别 |
|||
this.$http |
|||
.get(`/news/newssection/options/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.newsCateroryIds = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
categoryChange (item) { |
|||
this.resetPage() |
|||
// 类别 |
|||
this.$http |
|||
.get(`/news/newssection/options/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.newsCateroryIds = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
getBusinessOptions () { |
|||
// 归属栏目 |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
DownStateChange (id) { |
|||
this.$confirm(this.$t('prompt.info', { 'handle': '下线' }), this.$t('下线'), { |
|||
confirmButtonText: this.$t('confirm'), |
|||
cancelButtonText: this.$t('cancel'), |
|||
type: 'warning' |
|||
}).then(() => { |
|||
this.dataForm.id = id |
|||
this.dataForm.newsUpDownState = 1 |
|||
this.$http['post']('/news/newshonest/review', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
this.getDataList() |
|||
}).catch(() => { }) |
|||
}) |
|||
}, |
|||
UpStateChange (id) { |
|||
this.$confirm(this.$t('prompt.info', { 'handle': '上线' }), this.$t('上线'), { |
|||
confirmButtonText: this.$t('confirm'), |
|||
cancelButtonText: this.$t('cancel'), |
|||
type: 'warning' |
|||
}).then(() => { |
|||
this.dataForm.id = id |
|||
this.dataForm.newsUpDownState = 0 |
|||
this.$http['post']('/news/newshonest/review', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
this.getDataList() |
|||
}).catch(() => { }) |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,486 @@ |
|||
<template> |
|||
<el-card shadow="never" |
|||
class="aui-card--fill"> |
|||
<div class="mod-news__news}"> |
|||
<el-form :inline="true" |
|||
:model="dataForm" |
|||
:rules="dataRule" |
|||
ref="dataForm" |
|||
:label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|||
<el-row> |
|||
<el-form-item label="新闻模块" |
|||
prop="businessId"> |
|||
<el-select v-model="dataForm.businessId" @change="businessChange" ref="businessName" |
|||
placeholder="请选择类别"> |
|||
<el-option v-for="item in options" |
|||
:key="item.code" |
|||
:label="item.title" |
|||
:value="item.code"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
</el-row> |
|||
<el-row> |
|||
<el-form-item label="类别" |
|||
prop="newsCateroryId"> |
|||
<el-select v-model="dataForm.newsCateroryId" :disabled="!dataForm.businessId" |
|||
@change="categoryChange" ref="newsCateroryName" |
|||
placeholder="请选择类别"> |
|||
<el-option v-for="item in categorys" |
|||
:key="item.id" |
|||
:label="item.categoryName" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="栏目" |
|||
prop="newsSubCateroryId"> |
|||
<el-select v-model="dataForm.newsSubCateroryId" :disabled="!dataForm.newsCateroryId" |
|||
placeholder="请选择类别" ref="newsSubCateroryName"> |
|||
<el-option v-for="item in subCategorys" |
|||
:key="item.id" |
|||
:label="item.categoryName" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
</el-row> |
|||
<el-row> |
|||
<el-form-item label="新闻标题" |
|||
prop="newsTitle"> |
|||
<el-input v-model="dataForm.newsTitle" |
|||
type="text" |
|||
maxlength="50" |
|||
show-word-limit |
|||
placeholder="请输入标题" |
|||
clearable |
|||
style="width:500px"> |
|||
</el-input> |
|||
</el-form-item> |
|||
</el-row> |
|||
<el-row> |
|||
<el-form-item prop="newsContent" |
|||
label="正文编辑"> |
|||
<!-- 富文本编辑器, 容器 --> |
|||
<div id="J_quillEditor"></div> |
|||
<!-- 自定义上传图片功能 (使用element upload组件) --> |
|||
<el-upload :action="uploadUrl" |
|||
:show-file-list="false" |
|||
:before-upload="uploadBeforeUploadHandle" |
|||
:on-success="uploadSuccessHandle" |
|||
style="display: none;"> |
|||
<el-button ref="uploadBtn" |
|||
type="primary" |
|||
size="small">{{ $t('upload.button') }}</el-button> |
|||
</el-upload> |
|||
</el-form-item> |
|||
</el-row> |
|||
<el-row> |
|||
<el-form-item label-width="500px"> |
|||
<el-button type="primary" |
|||
@click="dataFormSubmitHandle()">提报</el-button> |
|||
<el-button type="primary" |
|||
@click="draftDataFormSubmitHandle()">暂存</el-button> |
|||
</el-form-item> |
|||
</el-row> |
|||
</el-form> |
|||
</div> |
|||
</el-card> |
|||
</template> |
|||
<script> |
|||
import Cookies from 'js-cookie' |
|||
import debounce from 'lodash/debounce' |
|||
import 'quill/dist/quill.snow.css' |
|||
import Quill from 'quill' |
|||
import AddOrUpdate from './newshonest-add-or-update' |
|||
export default { |
|||
data () { |
|||
return { |
|||
dataForm: { |
|||
id: '', |
|||
streetId: '', |
|||
communityId: null, |
|||
gridId: null, |
|||
newsCateroryId: '', |
|||
newsSubCateroryId: '', |
|||
newsTitle: '', |
|||
newsReleaseStartTime: '', |
|||
newsReleaseEndTime: '', |
|||
newsContent: '', |
|||
newsImageUrl: '', |
|||
street: '', |
|||
community: null, |
|||
grid: null, |
|||
newsProperty: '', |
|||
newsColumn: '', |
|||
allDeptIdsShow: [] |
|||
}, |
|||
time: [], |
|||
streetList: [], |
|||
communityList: [], |
|||
gridList: [], |
|||
options: [], |
|||
categorys: [], |
|||
subCategorys: [], |
|||
businessIds: [], |
|||
loading: false, |
|||
// 富文本 |
|||
quillEditor: null, |
|||
quillEditorToolbarOptions: [ |
|||
['bold', 'italic', 'underline', 'strike'], |
|||
['blockquote', 'code-block', 'image'], |
|||
[{ 'header': 1 }, { 'header': 2 }], |
|||
[{ 'list': 'ordered' }, { 'list': 'bullet' }], |
|||
[{ 'script': 'sub' }, { 'script': 'super' }], |
|||
[{ 'indent': '-1' }, { 'indent': '+1' }], |
|||
[{ 'direction': 'rtl' }], |
|||
[{ 'size': ['small', false, 'large', 'huge'] }], |
|||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }], |
|||
[{ 'color': [] }, { 'background': [] }], |
|||
[{ 'font': [] }], |
|||
[{ 'align': [] }], |
|||
['clean'] |
|||
], |
|||
uploadUrl: '', |
|||
// 富文本end |
|||
fileList: [] |
|||
} |
|||
}, |
|||
activated () { |
|||
this.getDeptInfoList('street', localStorage.getItem('street') === null ? '1169154711480528897' : localStorage.getItem('street')) |
|||
this.getListCategory() |
|||
}, |
|||
watch: { |
|||
'dataForm.allDeptIdsShow': function (val) { |
|||
console.log(this.dataForm.allDeptIdsShow) |
|||
} |
|||
}, |
|||
created () { |
|||
// 获取业务下拉菜单 |
|||
this.getBusinessOptions() |
|||
this.getListCategory() |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
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')}` |
|||
if (this.quillEditor) { |
|||
this.quillEditor.deleteText(0, this.quillEditor.getLength()) |
|||
} else { |
|||
this.quillEditorHandle() |
|||
} |
|||
// 富文本end |
|||
}) |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
businessId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsTitle: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsCateroryId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsSubCateroryId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsImageUrl: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsReleaseStartTime: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
newsContent: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
businessChange (item) { |
|||
this.dataForm.newsCateroryId = '' |
|||
this.dataForm.newsSubCateroryId = '' |
|||
// 类别 |
|||
this.$http |
|||
.get(`/news/newssection/options/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.categorys = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
categoryChange (item) { |
|||
this.dataForm.newsSubCateroryId = '' |
|||
// 栏目 |
|||
this.$http |
|||
.get(`/news/newssection/suboptions/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.subCategorys = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
getBusinessOptions () { |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
// 获取部门列表 |
|||
getDeptInfoList (dataReceiver, faDeptId) { |
|||
if (!faDeptId) { |
|||
return |
|||
} |
|||
this.$http.get(`/sys/dept/sublist/` + faDeptId).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
if (dataReceiver === 'street') { |
|||
let all = [{ id: '1', name: '全部' }] |
|||
this.streetList = all.concat(res.data) |
|||
} else if (dataReceiver === 'community') { |
|||
this.communityList = res.data |
|||
} else if (dataReceiver === 'grid') { |
|||
this.gridList = res.data |
|||
} |
|||
}).catch(() => { }) |
|||
}, |
|||
getListCategory () { |
|||
this.$http.get(`/news/newscategory/category`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.categorys = res.data |
|||
}).catch(() => { }) |
|||
}, |
|||
// 富文本编辑器 |
|||
quillEditorHandle () { |
|||
this.quillEditor = new Quill('#J_quillEditor', { |
|||
modules: { |
|||
toolbar: this.quillEditorToolbarOptions |
|||
}, |
|||
theme: 'snow' |
|||
}) |
|||
this.quillEditor.container.style.height = `${300}px` |
|||
// // 自定义上传图片功能 (使用element upload组件) |
|||
this.quillEditor.getModule('toolbar').addHandler('image', () => { |
|||
this.$refs.uploadBtn.$el.click() |
|||
}) |
|||
// 监听内容变化,动态赋值 |
|||
this.quillEditor.on('text-change', () => { |
|||
this.dataForm.newsContent = this.quillEditor.root.innerHTML |
|||
// if ((this.dataForm.newsContent).length > 10000) { |
|||
// return this.$message.error('您输入的的内容已超过字数') |
|||
// } |
|||
}) |
|||
}, |
|||
// 上传图片之前 (富文本) |
|||
uploadBeforeUploadHandle (file) { |
|||
if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') { |
|||
this.$message.error(this.$t('upload.tip', { 'format': 'jpg、png、gif' })) |
|||
return false |
|||
} |
|||
}, |
|||
// 上传图片成功 (富文本) |
|||
uploadSuccessHandle (res, file, fileList) { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.url) |
|||
}, |
|||
setRegistTime () { |
|||
this.dataForm.newsReleaseStartTime = this.time[0] |
|||
this.dataForm.newsReleaseEndTime = this.time[1] |
|||
}, |
|||
// 上传图片end |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
// this.$refs.businessName.selectedLabel |
|||
this.dataForm.newsProperty = this.$refs.newsCateroryName.selectedLabel |
|||
this.dataForm.newsColumn = this.$refs.newsSubCateroryName.selectedLabel |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http['post']('/news/newshonest/publish', this.dataForm).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.dataForm.id = '' |
|||
this.dataForm.streetId = '' |
|||
this.dataForm.communityId = null |
|||
this.dataForm.gridId = null |
|||
this.dataForm.newsCateroryId = '' |
|||
this.dataForm.newsSubCateroryId = '' |
|||
this.dataForm.newsTitle = '' |
|||
this.dataForm.newsReleaseStartTime = '' |
|||
this.dataForm.newsReleaseEndTime = '' |
|||
this.dataForm.newsContent = '' |
|||
this.dataForm.newsImageUrl = '' |
|||
this.dataForm.street = '' |
|||
this.dataForm.community = null |
|||
this.dataForm.grid = null |
|||
this.dataForm.newsProperty = '' |
|||
this.dataForm.newsColumn = '' |
|||
this.dataForm.businessId = '' |
|||
this.visible = false |
|||
this.time = [] |
|||
this.quillEditor.root.innerHTML = '' |
|||
this.dataForm.communityId = this.dataForm.streetId = this.dataForm.gridId = null |
|||
this.communityList = this.gridList = [] |
|||
} |
|||
}) |
|||
}).catch(() => { }) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }), |
|||
// 存草稿 |
|||
draftDataFormSubmitHandle: debounce(function () { |
|||
// if ((this.dataForm.newsContent).length > 10000) { |
|||
// return this.$message.error('您输入的的内容已超过字数不能提交') |
|||
// } |
|||
this.dataForm.newsProperty = this.$refs.newsCateroryName.selectedLabel |
|||
this.dataForm.newsColumn = this.$refs.newsSubCateroryName.selectedLabel |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http['post']('/news/newshonest/draft', this.dataForm).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.dataForm.id = '' |
|||
this.dataForm.streetId = '' |
|||
this.dataForm.communityId = null |
|||
this.dataForm.gridId = null |
|||
this.dataForm.newsCateroryId = '' |
|||
this.dataForm.newsSubCateroryId = '' |
|||
this.dataForm.newsTitle = '' |
|||
this.dataForm.newsReleaseStartTime = '' |
|||
this.dataForm.newsReleaseEndTime = '' |
|||
this.dataForm.newsContent = '' |
|||
this.dataForm.newsImageUrl = '' |
|||
this.dataForm.street = '' |
|||
this.dataForm.community = null |
|||
this.dataForm.grid = null |
|||
this.dataForm.newsProperty = '' |
|||
this.dataForm.newsColumn = '' |
|||
this.dataForm.businessId = '' |
|||
this.visible = false |
|||
this.time = [] |
|||
this.quillEditor.root.innerHTML = '' |
|||
this.dataForm.communityId = this.dataForm.streetId = this.dataForm.gridId = null |
|||
this.communityList = this.gridList = [] |
|||
} |
|||
}) |
|||
}).catch(() => { }) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }), |
|||
handleAvatarSuccess (res, file) { |
|||
this.loading = false |
|||
this.dataForm.newsImageUrl = res.data.url |
|||
}, |
|||
beforeAvatarUpload (file) { |
|||
this.loading = true |
|||
var that = this |
|||
return new Promise((resolve, reject) => { |
|||
const isJPG = file.type === 'image/jpeg' |
|||
const isPNG = file.type === 'image/png' |
|||
const isLt1M = file.size / 1024 / 1024 < 1 |
|||
let bool = false |
|||
// 判断是否符合格式要求 |
|||
if (isJPG || isPNG) { |
|||
bool = true |
|||
} else { |
|||
that.$message.error('上传文件必须是jpg、png格式!') |
|||
return false |
|||
} |
|||
// 如果格式符合要求,但是size过大,对图片进行处理 |
|||
if (bool && !isLt1M) { |
|||
let image = new Image() |
|||
let resultBlob = '' |
|||
image.src = URL.createObjectURL(file) |
|||
image.onload = () => { |
|||
resultBlob = that.compressUpload(image) |
|||
resolve(resultBlob) |
|||
} |
|||
} else if (bool && isLt1M) { |
|||
resolve(file) |
|||
} |
|||
}) |
|||
}, |
|||
compressUpload (image) { |
|||
// 创建画布元素 |
|||
let canvas = document.createElement('canvas') |
|||
let ctx = canvas.getContext('2d') |
|||
let { width } = image |
|||
let { height } = image |
|||
canvas.width = width |
|||
canvas.height = height |
|||
ctx.fillRect(0, 0, canvas.width, canvas.height) |
|||
ctx.drawImage(image, 0, 0, width, height) |
|||
// 等比压缩 |
|||
let compressData = canvas.toDataURL('image/jpeg', 0.8) |
|||
// base64转Blob |
|||
let blobImg = this.dataURItoBlob(compressData) |
|||
return blobImg |
|||
}, |
|||
dataURItoBlob (data) { |
|||
let byteString |
|||
if (data.split(',')[0].indexOf('base64') >= 0) { |
|||
// 转二进制 |
|||
byteString = atob(data.split(',')[1]) |
|||
} else { |
|||
byteString = unescape(data.split(',')[1]) |
|||
} |
|||
let mimeString = data |
|||
.split(',')[0] |
|||
.split(':')[1] |
|||
.split('')[0] |
|||
let ia = new Uint8Array(byteString.length) |
|||
for (let i = 0; i < byteString.length; i += 1) { |
|||
ia[i] = byteString.charCodeAt(i) |
|||
} |
|||
return new Blob([ia], { type: mimeString }) |
|||
}, |
|||
handelError () { |
|||
this.loading = false |
|||
} |
|||
}, |
|||
components: { |
|||
AddOrUpdate |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
@ -0,0 +1,238 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-__newshonest}"> |
|||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
|||
<el-form-item label="新闻标题"> |
|||
<el-input v-model="dataForm.newsTitle" placeholder="新闻标题" @change="resetPage" clearable></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="新闻模块" |
|||
prop="businessId"> |
|||
<el-select v-model="dataForm.businessId" @change="businessChange" |
|||
placeholder="新闻模块" clearable> |
|||
<el-option v-for="item in options" |
|||
:key="item.code" |
|||
:label="item.title" |
|||
:value="item.code"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="新闻类别" |
|||
prop="newsCateroryId"> |
|||
<el-select v-model="dataForm.newsCateroryId" :disabled="!dataForm.businessId" |
|||
placeholder="新闻类别" clearable @change="categoryChange"> |
|||
<el-option v-for="item in newsCateroryIds" |
|||
:key="item.id" |
|||
:label="item.categoryName" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="新闻栏目" |
|||
prop="newsSubCateroryId"> |
|||
<el-select v-model="dataForm.newsSubCateroryId" :disabled="!dataForm.newsCateroryId" |
|||
placeholder="新闻栏目" @change="resetPage" clearable> |
|||
<el-option v-for="item in newsSubCateroryIds" |
|||
:key="item.id" |
|||
:label="item.title" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button @click="getDataList()">{{ $t('query') }}</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;"> |
|||
<el-table-column prop="newsTitle" label="新闻标题" header-align="center" width="400" align="center"></el-table-column> |
|||
<el-table-column prop="newsProperty" label="新闻类别" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="newsColumn" label="新闻栏目" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="newsApprovalState" label="审核状态" sortable="custom" header-align="center" align="center"> |
|||
<template slot-scope="scope"> |
|||
<el-tag v-if="scope.row.newsApprovalState === '0'" size="small" type="warn">未审核</el-tag> |
|||
<el-tag v-if="scope.row.newsApprovalState === '1'" size="small" type="danger">驳回</el-tag> |
|||
<el-tag v-if="scope.row.newsApprovalState === '2'" size="small" type="success">审核完成</el-tag> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="newsUpDownState" label="上线状态" sortable="custom" header-align="center" align="center"> |
|||
<template slot-scope="scope"> |
|||
<el-tag v-if="scope.row.newsUpDownState === '1'" size="small" type="danger">下线</el-tag> |
|||
<el-tag v-else size="small" type="success">上线</el-tag> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="readingAmount" label="阅读量" header-align="center" width="80" align="center"></el-table-column> |
|||
<el-table-column prop="creatorName" label="创建人姓名" header-align="center" align="center"> |
|||
<template slot-scope="scope"> |
|||
<span v-if="scope.row.businessId === 'HONEST'">system</span> |
|||
<span v-else >{{ scope.row.creatorName }}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150"> |
|||
<template slot-scope="scope"> |
|||
<el-button v-if="$hasPermission('honest:newshonest:update') && scope.row.newsApprovalState === '2' && scope.row.newsUpDownState === '1'" type="text" size="small" @click="UpStateChange(scope.row.id)">上线</el-button> |
|||
<el-button v-if="$hasPermission('honest:newshonest:update') && scope.row.newsUpDownState === '0'" type="text" size="small" @click="DownStateChange(scope.row.id)">下线</el-button> |
|||
<el-button v-if="$hasPermission('honest:newshonest:update') && scope.row.newsApprovalState !== '2' && scope.row.businessId !== 'HONEST'" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button> |
|||
<el-button v-if="$hasPermission('honest:newshonest:delete')" type="text" size="small" @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> |
|||
<review v-if="reviewVisible" ref="review" @refreshDataList="getDataList"></review> |
|||
</div> |
|||
</el-card> |
|||
</template> |
|||
|
|||
<script> |
|||
import mixinViewModule from '@/mixins/view-module' |
|||
import AddOrUpdate from './newshonest-add-or-update' |
|||
import Review from './review-newshonest-add-or-update' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/news/newshonest/page', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/news/newshonest', |
|||
deleteIsBatch: true |
|||
}, |
|||
dataForm: { |
|||
id: '', |
|||
newsUpDownState: '' |
|||
}, |
|||
reviewVisible: false, |
|||
newsCateroryIds: [], |
|||
newsSubCateroryIds: [], |
|||
options: [] |
|||
} |
|||
}, |
|||
components: { |
|||
AddOrUpdate, |
|||
Review |
|||
}, |
|||
mounted() { |
|||
// 获取业务下拉菜单 |
|||
this.getBusinessOptions() |
|||
}, |
|||
methods: { |
|||
resetPage () { |
|||
this.page = 1 |
|||
}, |
|||
businessChange (item) { |
|||
this.resetPage() |
|||
// 类别 |
|||
this.$http |
|||
.get(`/news/newssection/options/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.newsCateroryIds = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
categoryChange (item) { |
|||
this.resetPage() |
|||
// 类别 |
|||
this.$http |
|||
.get(`/news/newssection/options/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.newsCateroryIds = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
getBusinessOptions () { |
|||
// 归属栏目 |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
reviewHandle (id) { |
|||
this.reviewVisible = true |
|||
this.$nextTick(() => { |
|||
this.$refs.review.dataForm.id = id |
|||
this.$refs.review.init() |
|||
}) |
|||
}, |
|||
DownStateChange (id) { |
|||
this.$confirm(this.$t('prompt.info', { 'handle': '下线' }), this.$t('下线'), { |
|||
confirmButtonText: this.$t('confirm'), |
|||
cancelButtonText: this.$t('cancel'), |
|||
type: 'warning' |
|||
}).then(() => { |
|||
this.dataForm.id = id |
|||
this.dataForm.newsUpDownState = 1 |
|||
this.$http['post']('/news/newshonest/review', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
this.getDataList() |
|||
}).catch(() => { }) |
|||
}) |
|||
}, |
|||
UpStateChange (id) { |
|||
this.$confirm(this.$t('prompt.info', { 'handle': '上线' }), this.$t('上线'), { |
|||
confirmButtonText: this.$t('confirm'), |
|||
cancelButtonText: this.$t('cancel'), |
|||
type: 'warning' |
|||
}).then(() => { |
|||
this.dataForm.id = id |
|||
this.dataForm.newsUpDownState = 0 |
|||
this.$http['post']('/news/newshonest/review', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
this.getDataList() |
|||
}).catch(() => { }) |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,193 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false"> |
|||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|||
<el-form-item label="类别名称" prop="categoryName"> |
|||
<el-input v-model="dataForm.categoryName" placeholder="类别名称"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="类别编码" prop="categoryCode"> |
|||
<el-input v-model="dataForm.categoryCode" placeholder="类别编码"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="归属栏目" |
|||
prop="businessId"> |
|||
<el-select v-model="dataForm.businessId" @change="getUpperOptions" |
|||
placeholder="归属栏目"> |
|||
<el-option v-for="item in options" |
|||
:key="item.code" |
|||
:label="item.title" |
|||
:value="item.code"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="上级菜单" |
|||
prop="pid"> |
|||
<el-select v-model="dataForm.pid" |
|||
placeholder="一级菜单" clearable ref="pid" @change="pidChange"> |
|||
<el-option v-for="item in upperOptions" |
|||
:key="item.id" |
|||
:label="item.categoryName" |
|||
:value="item.id"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="描述" prop="description"> |
|||
<el-input v-model="dataForm.description" placeholder="描述"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="排序" prop="sort"> |
|||
<el-input-number v-model="dataForm.sort" controls-position="right" :min="0" label="显示顺序"></el-input-number> |
|||
</el-form-item> |
|||
</el-form> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import debounce from 'lodash/debounce' |
|||
export default { |
|||
data () { |
|||
return { |
|||
visible: false, |
|||
options: [], |
|||
upperOptions: [ |
|||
{ |
|||
id: '0', |
|||
categoryName: '一级菜单' |
|||
} |
|||
], |
|||
dataForm: { |
|||
id: '', |
|||
pid: '0', |
|||
categoryName: '', |
|||
categoryCode: '', |
|||
businessId: '', |
|||
description: '', |
|||
sort: '', |
|||
delFlag: '', |
|||
revision: '', |
|||
createdBy: '', |
|||
createdTime: '', |
|||
updatedBy: '', |
|||
updatedTime: '' |
|||
} |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
pid: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
categoryName: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
categoryCode: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
businessId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
sort: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
// 获取业务下拉菜单 |
|||
this.getBusinessOptions() |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
pidChange () { |
|||
if (this.dataForm.pid == '') { |
|||
this.dataForm.pid = '0' |
|||
} |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.$http.get(`/news/newssection/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { |
|||
...this.dataForm, |
|||
...res.data |
|||
} |
|||
if (this.dataForm.pid === '0') { |
|||
return this.upperOptionsSetDefaultHandle() |
|||
} |
|||
}).catch(() => {}) |
|||
}, |
|||
// 上级菜单, 设置默认值 |
|||
upperOptionsSetDefaultHandle () { |
|||
this.dataForm.pid = '0' |
|||
this.upperOptions.push({ |
|||
id: '0', |
|||
categoryName: '一级菜单' |
|||
}) |
|||
}, |
|||
getBusinessOptions () { |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
getUpperOptions (item) { |
|||
this.$http |
|||
.get(`/news/newssection/options/` + item) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.upperOptions = res.data |
|||
this.upperOptions.push({ |
|||
id: '0', |
|||
categoryName: '一级菜单' |
|||
}) |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http[!this.dataForm.id ? 'post' : 'put']('/news/newssection/', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
} |
|||
}) |
|||
}).catch(() => {}) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }) |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,114 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-__newssection}"> |
|||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
|||
<el-form-item label="类别名称"> |
|||
<el-input v-model="dataForm.categoryName" placeholder="类别名称" clearable></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="归属栏目" |
|||
prop="businessId"> |
|||
<el-select v-model="dataForm.businessId" |
|||
placeholder="归属栏目" clearable> |
|||
<el-option v-for="item in options" |
|||
:key="item.code" |
|||
:label="item.title" |
|||
:value="item.code"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button @click="getDataList()">{{ $t('query') }}</el-button> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button> |
|||
</el-form-item> |
|||
<el-form-item v-if="dataForm.pid !=='0'"> |
|||
<el-button type="primary" @click="beforeGetDataList('0')">返回上级</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" width="50"></el-table-column> |
|||
<el-table-column prop="categoryName" label="类别名称" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="categoryCode" label="类别编码" header-align="center" align="center"></el-table-column> |
|||
<el-table-column prop="description" label="描述" header-align="center" align="center"></el-table-column> |
|||
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150"> |
|||
<template slot-scope="scope"> |
|||
<el-button v-if="scope.row.pid !== '0'" type="text" size="small" @click="beforeGetDataList('0')">查看一级类别</el-button> |
|||
<el-button v-if="scope.row.pid === '0'" type="text" size="small" @click="beforeGetDataList(scope.row.id)">查看二级类别</el-button> |
|||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button> |
|||
<el-button type="text" size="small" @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 './newssection-add-or-update' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/news/newssection/page', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/news/newssection', |
|||
deleteIsBatch: true |
|||
}, |
|||
options: [], |
|||
levelOptions: [ |
|||
{ |
|||
id: '0', |
|||
title: '一级类别' |
|||
} |
|||
], |
|||
level: true, |
|||
dataForm: { |
|||
id: '', |
|||
level: '', |
|||
pid: '0' |
|||
} |
|||
} |
|||
}, |
|||
components: { |
|||
AddOrUpdate |
|||
}, |
|||
mounted() { |
|||
// 获取业务下拉菜单 |
|||
this.getBusinessOptions() |
|||
}, |
|||
methods: { |
|||
beforeGetDataList (id) { |
|||
this.dataForm.pid = id |
|||
this.getDataList() |
|||
}, |
|||
getBusinessOptions () { |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,291 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" |
|||
title="查看" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
@close="visible= false"> |
|||
<el-form :model="dataForm" |
|||
:rules="dataRule" |
|||
ref="dataForm" |
|||
:label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|||
<el-form-item label="新闻模块" |
|||
prop="businessName"> |
|||
{{dataForm.businessName.title}} |
|||
</el-form-item> |
|||
<el-form-item label="类别" |
|||
prop="newsCateroryId"> |
|||
<el-form-item> |
|||
{{dataForm.newsProperty}} |
|||
</el-form-item> |
|||
</el-form-item> |
|||
<el-form-item label="栏目" |
|||
prop="newsSubCateroryId"> |
|||
<el-form-item> |
|||
{{dataForm.newsColumn}} |
|||
</el-form-item> |
|||
</el-form-item> |
|||
<el-form-item label="新闻标题" |
|||
prop="newsTitle"> |
|||
<el-form-item> |
|||
{{dataForm.newsTitle}} |
|||
</el-form-item> |
|||
</el-form-item> |
|||
<el-form-item prop="newsContent" |
|||
label="正文编辑"> |
|||
<!-- 富文本编辑器, 容器 --> |
|||
<div id="J_quillEditor"></div> |
|||
<!-- 自定义上传图片功能 (使用element upload组件) --> |
|||
<el-upload :action="uploadUrl" |
|||
:show-file-list="false" |
|||
:before-upload="uploadBeforeUploadHandle" |
|||
:on-success="uploadSuccessHandle" |
|||
style="display: none;"> |
|||
<el-button ref="uploadBtn" |
|||
type="primary" |
|||
size="small">{{ $t('upload.button') }}</el-button> |
|||
</el-upload> |
|||
</el-form-item> |
|||
</el-form> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import Cookies from 'js-cookie' |
|||
import debounce from 'lodash/debounce' |
|||
import 'quill/dist/quill.snow.css' |
|||
import Quill from 'quill' |
|||
import mixinViewModule from '@/mixins/view-module' |
|||
import AddOrUpdate from './newshonest-add-or-update' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/news/newshonest/page', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/news/newshonest', |
|||
deleteIsBatch: true |
|||
}, |
|||
dataForm: { |
|||
id: '', |
|||
businessId: '', |
|||
newsCateroryId: '', |
|||
newsSubCateroryId: '', |
|||
newsProperty: '', |
|||
newsColumn: '', |
|||
newsTitle: '', |
|||
newsReleaseStartTime: '', |
|||
newsReleaseEndTime: '', |
|||
newsContent: '', |
|||
newsImageUrl: '', |
|||
businessName: '', |
|||
allDeptIdsShow: [] |
|||
}, |
|||
time: [], |
|||
options: [], |
|||
categorys: [], |
|||
loading: false, |
|||
// 富文本 |
|||
quillEditor: null, |
|||
quillEditorToolbarOptions: [ |
|||
['bold', 'italic', 'underline', 'strike'], |
|||
['blockquote', 'code-block', 'image'], |
|||
[{ 'header': 1 }, { 'header': 2 }], |
|||
[{ 'list': 'ordered' }, { 'list': 'bullet' }], |
|||
[{ 'script': 'sub' }, { 'script': 'super' }], |
|||
[{ 'indent': '-1' }, { 'indent': '+1' }], |
|||
[{ 'direction': 'rtl' }], |
|||
[{ 'size': ['small', false, 'large', 'huge'] }], |
|||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }], |
|||
[{ 'color': [] }, { 'background': [] }], |
|||
[{ 'font': [] }], |
|||
[{ 'align': [] }], |
|||
['clean'] |
|||
], |
|||
uploadUrl: '', |
|||
// 富文本end |
|||
fileList: [], |
|||
visible: false, |
|||
reviewVisible: false |
|||
} |
|||
}, |
|||
created () { |
|||
this.$http |
|||
.get(`/sys/user/deptOptions/getByLoginUser`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.options = res.data.options |
|||
}) |
|||
.catch(() => { }) |
|||
this.getListCategory() |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
// 富文本 |
|||
this.hideUpload = false |
|||
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
|||
if (this.quillEditor) { |
|||
this.quillEditor.deleteText(0, this.quillEditor.getLength()) |
|||
} else { |
|||
this.quillEditorHandle() |
|||
} |
|||
// 富文本end |
|||
}) |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
|
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.dataForm.newsProperty = '' |
|||
this.dataForm.newsColumn = '' |
|||
this.$http.get(`/news/newshonest/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { ...this.dataForm, ...res.data } |
|||
this.quillEditor.root.innerHTML = res.data.newsContent |
|||
this.dataForm.businessName = this.options.find(item=>{ |
|||
return item.id = this.dataForm.businessId |
|||
}) |
|||
}).catch(() => { }) |
|||
}, |
|||
changeCaterory () { |
|||
// 给新闻类别变量赋值 |
|||
let choosenItem = this.categorys.filter(item => item.id === this.dataForm.newsCateroryId)[0] |
|||
this.dataForm.newsProperty = choosenItem.name |
|||
}, |
|||
getListCategory () { |
|||
this.$http |
|||
.get(`/news/newsappmenu/options/0`) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.loading = false |
|||
this.options = res.data |
|||
}) |
|||
.catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
// 富文本编辑器 |
|||
quillEditorHandle () { |
|||
this.quillEditor = new Quill('#J_quillEditor', { |
|||
modules: { |
|||
toolbar: this.quillEditorToolbarOptions |
|||
}, |
|||
readOnly: true, |
|||
theme: 'snow' |
|||
}) |
|||
this.quillEditor.container.style.height = `${300}px` |
|||
// // 自定义上传图片功能 (使用element upload组件) |
|||
this.quillEditor.getModule('toolbar').addHandler('image', () => { |
|||
this.$refs.uploadBtn.$el.click() |
|||
}) |
|||
// 监听内容变化,动态赋值 |
|||
this.quillEditor.on('text-change', () => { |
|||
this.dataForm.newsContent = this.quillEditor.root.innerHTML |
|||
if ((this.dataForm.newsContent).length > 10000) { |
|||
return this.$message.error('您输入的的内容已超过字数不能提交') |
|||
} |
|||
}) |
|||
}, |
|||
// 上传图片之前 (富文本) |
|||
uploadBeforeUploadHandle (file) { |
|||
if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') { |
|||
this.$message.error(this.$t('upload.tip', { 'format': 'jpg、png、gif' })) |
|||
return false |
|||
} |
|||
}, |
|||
// 上传图片成功 (富文本) |
|||
uploadSuccessHandle (res, file, fileList) { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.url) |
|||
}, |
|||
// 上传图片 |
|||
handleAvatarSuccess (res, file) { |
|||
this.loading = false |
|||
this.dataForm.newsImageUrl = res.data.url |
|||
}, |
|||
beforeAvatarUpload (file) { |
|||
this.loading = true |
|||
}, |
|||
// 上传图片end |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
if ((this.dataForm.newsContent).length > 10000) { |
|||
return this.$message.error('您输入的的内容已超过字数不能提交') |
|||
} |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http['put']('/news/newshonest/', this.dataForm).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.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.dataForm = {} |
|||
} |
|||
}) |
|||
}).catch(() => { }) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }) |
|||
}, |
|||
components: { |
|||
AddOrUpdate |
|||
} |
|||
} |
|||
</script> |
|||
<style> |
|||
.avatar-uploader .el-upload { |
|||
border: 1px dashed #d9d9d9; |
|||
border-radius: 6px; |
|||
cursor: pointer; |
|||
position: relative; |
|||
overflow: hidden; |
|||
} |
|||
.avatar-uploader .el-upload:hover { |
|||
border-color: #409eff; |
|||
} |
|||
.avatar-uploader-icon { |
|||
font-size: 28px; |
|||
color: #8c939d; |
|||
width: 178px; |
|||
height: 178px; |
|||
line-height: 178px; |
|||
text-align: center; |
|||
} |
|||
.avatar { |
|||
width: 178px; |
|||
height: 178px; |
|||
display: block; |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue