3 changed files with 382 additions and 0 deletions
@ -0,0 +1,180 @@ |
|||||
|
<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="unionId"> |
||||
|
<el-select v-model="dataForm.unionId" filterable placeholder="请选择" style="width: 100%"> |
||||
|
<el-option v-for="item in options" |
||||
|
:key="item.value" |
||||
|
:label="item.label" |
||||
|
:value="item.value"> |
||||
|
</el-option> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="活动名称" prop="title"> |
||||
|
<el-input v-model="dataForm.title" placeholder="活动名称"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="活动时间" prop="actTime"> |
||||
|
<el-date-picker v-model="dataForm.actTime" |
||||
|
type="datetimerange" |
||||
|
range-separator="至" |
||||
|
start-placeholder="开始日期" |
||||
|
end-placeholder="结束日期"> |
||||
|
</el-date-picker> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="排序" prop="sort"> |
||||
|
<el-input-number v-model="dataForm.sort" :min="0" :max="9999999" label="排序" style="width: 260px"></el-input-number> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="简介" prop="content"> |
||||
|
<el-row style="height: 400px;"> |
||||
|
<tinymce-editor v-model="dataForm.content"></tinymce-editor> |
||||
|
</el-row> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="精彩瞬间"> |
||||
|
<el-upload accept="image/png, image/jpeg" |
||||
|
:action="uploadUrl" |
||||
|
list-type="picture-card" |
||||
|
:file-list="dataForm.images" |
||||
|
:limit="10" |
||||
|
:on-success="handleAvatarActSuccess" |
||||
|
:on-remove="removeImage" |
||||
|
:on-exceed="handleExceed"> |
||||
|
<i class="el-icon-plus"></i> |
||||
|
</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 debounce from 'lodash/debounce' |
||||
|
import Cookies from 'js-cookie' |
||||
|
import TinymceEditor from '@/components/tinymce-editor' |
||||
|
export default { |
||||
|
data () { |
||||
|
return { |
||||
|
visible: false, |
||||
|
dataForm: { |
||||
|
id: '', |
||||
|
unionId: '', |
||||
|
title: '', |
||||
|
actStartTime: '', |
||||
|
actEndTime: '', |
||||
|
content: '', |
||||
|
sort: '', |
||||
|
actTime: [], |
||||
|
images: [] |
||||
|
}, |
||||
|
uploadUrl: '', |
||||
|
imgSort: 0, |
||||
|
options: [] |
||||
|
} |
||||
|
}, |
||||
|
computed: { |
||||
|
dataRule () { |
||||
|
return { |
||||
|
unionId: [ |
||||
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
||||
|
], |
||||
|
title: [ |
||||
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
||||
|
], |
||||
|
actTime: [ |
||||
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
||||
|
], |
||||
|
content: [ |
||||
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
init () { |
||||
|
this.visible = true |
||||
|
this.getOptionVolunteerUnion() |
||||
|
this.$nextTick(() => { |
||||
|
this.$refs['dataForm'].resetFields() |
||||
|
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
||||
|
this.dataForm.images = [] |
||||
|
this.imgSort = 0 |
||||
|
if (this.dataForm.id) { |
||||
|
this.getInfo() |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
// 获取联盟下拉列表 |
||||
|
getOptionVolunteerUnion () { |
||||
|
this.$http.get(`/heart/volunteerunion/optionVolunteerUnion`).then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.options = res.data |
||||
|
}).catch(() => {}) |
||||
|
}, |
||||
|
// 获取信息 |
||||
|
getInfo () { |
||||
|
this.$http.get(`/heart/volunteerunionact/${this.dataForm.id}`).then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.dataForm = { |
||||
|
...this.dataForm, |
||||
|
...res.data |
||||
|
} |
||||
|
// 如果是追加图片,则赋值 imgSort |
||||
|
if (this.dataForm.images.length > 0) { |
||||
|
this.imgSort = this.dataForm.images[this.dataForm.images.length - 1].imgSort |
||||
|
} |
||||
|
console.log('this.imgSort:' + this.imgSort) |
||||
|
}).catch(() => {}) |
||||
|
}, |
||||
|
// 表单提交 |
||||
|
dataFormSubmitHandle: debounce(function () { |
||||
|
this.$refs['dataForm'].validate((valid) => { |
||||
|
if (!valid) { |
||||
|
return false |
||||
|
} |
||||
|
this.$http[!this.dataForm.id ? 'post' : 'put']('/heart/volunteerunionact/', 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 }), |
||||
|
// 图片处理 |
||||
|
handleAvatarActSuccess (res, file) { |
||||
|
let image = {} |
||||
|
image.name = Math.round(Math.random() * 5) |
||||
|
image.url = res.data.url |
||||
|
this.imgSort = this.imgSort + 1 |
||||
|
image.imgSort = this.imgSort |
||||
|
this.dataForm.images.push(image) |
||||
|
}, |
||||
|
removeImage (file, fileList) { |
||||
|
this.dataForm.images = fileList |
||||
|
}, |
||||
|
handleExceed () { |
||||
|
this.$message({ |
||||
|
showClose: true, |
||||
|
message: '精彩瞬间最多只能上传十张照片', |
||||
|
type: 'warning' |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
components: { |
||||
|
TinymceEditor |
||||
|
} |
||||
|
} |
||||
|
</script> |
@ -0,0 +1,98 @@ |
|||||
|
<template> |
||||
|
<el-dialog :visible.sync="visible" title="详情" :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' ? '160px' : '120px'"> |
||||
|
<el-form-item label="所属联盟"> |
||||
|
{{dataForm.unionName}} |
||||
|
</el-form-item> |
||||
|
<el-form-item label="活动名称"> |
||||
|
{{dataForm.title}} |
||||
|
</el-form-item> |
||||
|
<el-form-item label="活动开始时间"> |
||||
|
{{dataForm.actStartTime}} |
||||
|
</el-form-item> |
||||
|
<el-form-item label="活动结束时间"> |
||||
|
{{dataForm.actEndTime}} |
||||
|
</el-form-item> |
||||
|
<el-form-item label="排序"> |
||||
|
{{dataForm.sort}} |
||||
|
</el-form-item> |
||||
|
<el-form-item label="简介"> |
||||
|
<el-row style="height: 400px;"> |
||||
|
<tinymce-editor v-model="dataForm.content"></tinymce-editor> |
||||
|
</el-row> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="精彩瞬间" v-if="this.dataForm.images[0] !== ''"> |
||||
|
<el-image v-for="item in this.dataForm.images" |
||||
|
style="width: 100px; height: 100px; margin-right: 10px" |
||||
|
:key="item.url" |
||||
|
:src="item.url" |
||||
|
:preview-src-list="previewImgList" |
||||
|
@click="clickImg(item.url)"> |
||||
|
</el-image> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
<template slot="footer"> |
||||
|
<el-button @click="visible = false">返回</el-button> |
||||
|
</template> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import TinymceEditor from '@/components/tinymce-editor' |
||||
|
import 'element-ui/lib/theme-chalk/image.css' |
||||
|
export default { |
||||
|
data () { |
||||
|
return { |
||||
|
visible: false, |
||||
|
dataForm: { |
||||
|
id: '', |
||||
|
unionName: '', |
||||
|
unionId: '', |
||||
|
title: '', |
||||
|
actStartTime: '', |
||||
|
actEndTime: '', |
||||
|
content: '', |
||||
|
sort: '', |
||||
|
images: [] |
||||
|
}, |
||||
|
previewImgList: [] |
||||
|
} |
||||
|
}, |
||||
|
computed: { |
||||
|
dataRule () { |
||||
|
return { |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
components: { |
||||
|
TinymceEditor |
||||
|
}, |
||||
|
methods: { |
||||
|
init () { |
||||
|
this.visible = true |
||||
|
this.$nextTick(() => { |
||||
|
this.$refs['dataForm'].resetFields() |
||||
|
if (this.dataForm.id) { |
||||
|
this.getInfo() |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
clickImg (url) { |
||||
|
this.previewImgList = [] |
||||
|
this.previewImgList.push(url) |
||||
|
}, |
||||
|
// 获取信息 |
||||
|
getInfo () { |
||||
|
this.$http.get(`/heart/volunteerunionact/${this.dataForm.id}`).then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.dataForm = { |
||||
|
...this.dataForm, |
||||
|
...res.data |
||||
|
} |
||||
|
}).catch(() => {}) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
@ -0,0 +1,104 @@ |
|||||
|
<template> |
||||
|
<el-card shadow="never" class="aui-card--fill"> |
||||
|
<div class="mod-heart__volunteerunionact}"> |
||||
|
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
||||
|
<el-form-item label="所属联盟"> |
||||
|
<el-select v-model="dataForm.unionId" clearable filterable placeholder="请选择"> |
||||
|
<el-option v-for="item in options" |
||||
|
:key="item.value" |
||||
|
:label="item.label" |
||||
|
:value="item.value"> |
||||
|
</el-option> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
<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 prop="unionName" label="所属联盟" header-align="center" align="center"></el-table-column> |
||||
|
<el-table-column prop="title" label="活动名称" header-align="center" align="center"></el-table-column> |
||||
|
<el-table-column prop="actStartTime" label="活动开始时间" header-align="center" align="center"></el-table-column> |
||||
|
<el-table-column prop="actEndTime" label="活动结束时间" header-align="center" align="center"></el-table-column> |
||||
|
<el-table-column prop="sort" 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="detailHandle(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> |
||||
|
<!-- 详情 --> |
||||
|
<volunteerunionact-detail v-if="detailVisible" ref="volunteerunionactDetail" @refreshDataList="getDataList"></volunteerunionact-detail> |
||||
|
</div> |
||||
|
</el-card> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import mixinViewModule from '@/mixins/view-module' |
||||
|
import AddOrUpdate from './volunteerunionact-add-or-update' |
||||
|
import volunteerunionactDetail from './volunteerunionact-detail' |
||||
|
export default { |
||||
|
mixins: [mixinViewModule], |
||||
|
data () { |
||||
|
return { |
||||
|
mixinViewModuleOptions: { |
||||
|
getDataListURL: '/heart/volunteerunionact/page', |
||||
|
getDataListIsPage: true, |
||||
|
deleteURL: '/heart/volunteerunionact', |
||||
|
deleteIsBatch: true |
||||
|
}, |
||||
|
dataForm: { |
||||
|
id: '' |
||||
|
}, |
||||
|
options: [], |
||||
|
detailVisible: false |
||||
|
} |
||||
|
}, |
||||
|
created () { |
||||
|
this.getOptionVolunteerUnion() |
||||
|
}, |
||||
|
methods: { |
||||
|
// 获取联盟下拉列表 |
||||
|
getOptionVolunteerUnion () { |
||||
|
this.$http.get(`/heart/volunteerunion/optionVolunteerUnion`).then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.options = res.data |
||||
|
}).catch(() => {}) |
||||
|
}, |
||||
|
detailHandle (id) { |
||||
|
this.detailVisible = true |
||||
|
this.$nextTick(() => { |
||||
|
this.$refs.volunteerunionactDetail.dataForm.id = id |
||||
|
this.$refs.volunteerunionactDetail.init() |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
components: { |
||||
|
AddOrUpdate, |
||||
|
volunteerunionactDetail |
||||
|
} |
||||
|
} |
||||
|
</script> |
Loading…
Reference in new issue