Browse Source

活动管理 增加 新闻发稿功能

feature/syp_points
zhangyongzhangyong 5 years ago
parent
commit
7b44e4df9c
  1. 18
      src/views/modules/heart/actinfo-list.vue
  2. 154
      src/views/modules/heart/actinfo-pull.vue

18
src/views/modules/heart/actinfo-list.vue

@ -58,7 +58,9 @@
<el-button v-if="$hasPermission('heart:actinfo:join')" type="text" size="small" @click="joinManage(scope.row.id)">报名管理</el-button> <el-button v-if="$hasPermission('heart:actinfo:join')" type="text" size="small" @click="joinManage(scope.row.id)">报名管理</el-button>
<el-button v-if="$hasPermission('heart:actinfo:clock')" type="text" :disabled="scope.row.actStatus ==='0'? true :false" size="small" @click="clockManage(scope.row.id)">打卡积分</el-button> <el-button v-if="$hasPermission('heart:actinfo:clock')" type="text" :disabled="scope.row.actStatus ==='0'? true :false" size="small" @click="clockManage(scope.row.id)">打卡积分</el-button>
</div> </div>
<div>
<el-button v-if="$hasPermission('heart:actinfo:pull')" type="text" size="small" @click="pullHandle(scope.row)">新闻发稿 </el-button>
</div>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -77,7 +79,7 @@
<actuserrelation v-if="actUserRelationVisible" ref="actUserRelation" @refreshDataList="getDataList"></actuserrelation> <actuserrelation v-if="actUserRelationVisible" ref="actUserRelation" @refreshDataList="getDataList"></actuserrelation>
<actinfo-cancel v-if="actInfoCancelVisible" ref="actinfoCancel" @refreshDataList="getDataList"></actinfo-cancel> <actinfo-cancel v-if="actInfoCancelVisible" ref="actinfoCancel" @refreshDataList="getDataList"></actinfo-cancel>
<actuserclocklog v-if="actUserClockLogVisible" ref="actUserClockLog" @refreshDataList="getDataList"></actuserclocklog> <actuserclocklog v-if="actUserClockLogVisible" ref="actUserClockLog" @refreshDataList="getDataList"></actuserclocklog>
<actinfo-pull v-if="actinfoPullVisible" ref="actinfoPull" @refreshDataList="getDataList"></actinfo-pull>
</div> </div>
</el-card> </el-card>
</template> </template>
@ -89,6 +91,7 @@ import ActinfoDetailView from './actinfo-detail-view'
import ActUserRelation from './actuserrelation' import ActUserRelation from './actuserrelation'
import ActinfoCancel from './actinfo-cancel' import ActinfoCancel from './actinfo-cancel'
import ActUserClockLog from './actuserclocklog' import ActUserClockLog from './actuserclocklog'
import ActinfoPull from './actinfo-pull'
export default { export default {
mixins: [mixinViewModule], mixins: [mixinViewModule],
name: 'ActInfoList', name: 'ActInfoList',
@ -108,6 +111,7 @@ export default {
actUserRelationVisible: false, actUserRelationVisible: false,
actInfoCancelVisible: false, actInfoCancelVisible: false,
actUserClockLogVisible: false, actUserClockLogVisible: false,
actinfoPullVisible: false,
pickerBeginDateBefore: { pickerBeginDateBefore: {
disabledDate: (time) => { disabledDate: (time) => {
let beginDateVal = this.dataForm.startTime let beginDateVal = this.dataForm.startTime
@ -131,7 +135,8 @@ export default {
ActinfoDetailView, ActinfoDetailView,
ActUserRelation, ActUserRelation,
ActinfoCancel, ActinfoCancel,
ActUserClockLog ActUserClockLog,
ActinfoPull
}, },
created: function () { created: function () {
this.getDataList() this.getDataList()
@ -172,6 +177,13 @@ export default {
this.$refs.actinfoCancel.init() this.$refs.actinfoCancel.init()
}) })
} }
},
pullHandle (row) {
this.actinfoPullVisible = true
this.$nextTick(() => {
this.$refs.actinfoPull.dataForm.id = row.id
this.$refs.actinfoPull.init()
})
} }
} }
} }

154
src/views/modules/heart/actinfo-pull.vue

@ -0,0 +1,154 @@
<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="120px">
<el-form-item prop="actNewsContent" 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>
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</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'
export default {
data () {
return {
visible: 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: '',
dataForm: {
id: '',
actNewsContent: ''
}
}
},
computed: {
dataRule () {
var validateContent = (rule, value, callback) => {
if (this.quillEditor.getLength() <= 1) {
return callback(new Error(this.$t('validate.required')))
}
callback()
}
return {
actNewsContent: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' },
{ validator: validateContent, trigger: 'blur' }
]
}
}
},
methods: {
init () {
this.visible = true
this.$nextTick(() => {
if (this.quillEditor) {
this.quillEditor.deleteText(0, this.quillEditor.getLength())
} else {
this.quillEditorHandle()
}
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.getInfo()
}
})
},
//
quillEditorHandle () {
this.quillEditor = new Quill('#J_quillEditor', {
modules: {
toolbar: this.quillEditorToolbarOptions
},
theme: 'snow'
})
// (使element upload)
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}`
this.quillEditor.getModule('toolbar').addHandler('image', () => {
this.$refs.uploadBtn.$el.click()
})
//
this.quillEditor.on('text-change', () => {
this.dataForm.actNewsContent = this.quillEditor.root.innerHTML
})
},
//
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)
},
//
getInfo () {
this.$http.get(`/heart/actinfo/${this.dataForm.id}`).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.dataForm = res.data
this.quillEditor.root.innerHTML = this.dataForm.actNewsContent
}).catch(() => {})
},
//
dataFormSubmitHandle: debounce(function () {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false
}
this.$http[!this.dataForm.id ? 'post' : 'put']('/heart/actinfo/', 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>
Loading…
Cancel
Save