Browse Source

共建联盟,增加首图、详情页

master
zhangyongzhangyong 4 years ago
parent
commit
ee89cdaca0
  1. 225
      src/views/modules/heart/volunteerunion-add-or-update.vue
  2. 245
      src/views/modules/heart/volunteerunion-detail.vue
  3. 27
      src/views/modules/heart/volunteerunion.vue

225
src/views/modules/heart/volunteerunion-add-or-update.vue

@ -1,6 +1,26 @@
<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-row>
<el-form-item label="联盟图片"
v-loading="loading"
prop="headPic">
<el-upload class="avatar-uploader"
:action="uploadUrl"
:show-file-list="false"
:on-success="handleAvatarActSuccess"
:on-error="handelError"
:before-upload="beforeAvatarUpload">
<img v-if="dataForm.headPic"
:src="dataForm.headPic"
class="avatar">
<i v-else
class="el-icon-plus avatar-uploader-icon"></i>
<div slot="tip"
class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</el-upload>
</el-form-item>
</el-row>
<el-form-item label="联盟名称" prop="unionName">
<el-input v-model="dataForm.unionName" placeholder="联盟名称" style="width: 260px"></el-input>
</el-form-item>
@ -14,7 +34,7 @@
<el-input-number v-model="dataForm.sort" controls-position="right" :min="0" label="排序" style="width: 260px"></el-input-number>
</el-form-item>
<el-form-item prop="content"
label="团队介绍">
label="联盟简介">
<el-row style="height: 400px;">
<tinymce-editor v-model="dataForm.content"></tinymce-editor>
</el-row>
@ -28,6 +48,7 @@
</template>
<script>
import Cookies from 'js-cookie'
import debounce from 'lodash/debounce'
import TinymceEditor from '@/components/tinymce-editor'
export default {
@ -46,8 +67,11 @@ export default {
createdTime: '',
updatedBy: '',
updatedTime: '',
delFlag: ''
}
delFlag: '',
headPic: ''
},
loading: false,
uploadUrl: ''
}
},
computed: {
@ -61,18 +85,27 @@ export default {
],
phone: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
], content: [
],
content: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
sort: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
sort: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
headPic: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
]
}
}
},
components: {
TinymceEditor
},
components: {
TinymceEditor
},
created () {
this.$nextTick(() => {
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}`
})
},
methods: {
init () {
this.visible = true
@ -116,7 +149,177 @@ export default {
})
}).catch(() => {})
})
}, 1000, { 'leading': true, 'trailing': false })
}, 1000, { 'leading': true, 'trailing': false }),
handleAvatarActSuccess (res, file) {
this.loading = false
this.dataForm.headPic = res.data.url
},
beforeAvatarUpload (file) {
this.loading = true
},
handelError () {
this.loading = false
}
}
}
</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>
<style lang="scss">
.project-handle {
.el-timeline {
padding-left: 9px;
font-size: 13px;
}
.el-textarea {
width: 600px !important;
}
.el-input {
width: 600px !important;
}
}
.el-form-item__label {
font-weight: bold;
}
</style>
<style lang="scss" scoped>
.project-handle {
width: 100%;
height: calc(100vh - 120px);
background: #ffffff;
box-sizing: border-box;
padding: 10px;
.project-detail {
width: 100%;
height: 49%;
border: 2px solid #ccc;
box-sizing: border-box;
padding: 10px;
padding-top: 20px;
float: left;
margin-bottom: 1%;
position: relative;
.project-detail-tip {
position: absolute;
top: 0;
left: 0;
width: 80px;
height: 30px;
line-height: 30px;
color: #ffffff;
background: #4ac38b;
text-align: center;
}
.el-form {
width: 58%;
height: 100%;
float: left;
overflow-y: auto;
&::-webkit-scrollbar {
width: 5px;
height: 1px;
}
&::-webkit-scrollbar-thumb {
border-radius: 5px;
background: #ccc;
}
&::-webkit-scrollbar-track {
border-radius: 10px;
background: #fff;
}
}
.container {
width: 40%;
height: 100%;
float: right;
.location {
height: 30px;
line-height: 30px;
}
#map {
width: 100%;
height: calc(100% - 30px);
}
}
}
.project-progress {
width: 20%;
height: 100%;
float: right;
border: 2px solid #ccc;
box-sizing: border-box;
margin-left: 1%;
padding-top: 20px;
overflow-y: auto;
&::-webkit-scrollbar {
width: 5px;
height: 1px;
}
&::-webkit-scrollbar-thumb {
border-radius: 5px;
background: #aaa;
}
&::-webkit-scrollbar-track {
border-radius: 10px;
background: #ccc;
}
}
.handle-operation {
padding-top: 30px;
box-sizing: border-box;
width: 100%;
height: 49%;
box-sizing: border-box;
border: 2px solid #ccc;
float: left;
position: relative;
overflow-y: auto;
&::-webkit-scrollbar {
width: 5px;
height: 1px;
}
&::-webkit-scrollbar-thumb {
border-radius: 5px;
background: #aaa;
}
&::-webkit-scrollbar-track {
border-radius: 10px;
background: #ccc;
}
.handle-operation-tip {
position: absolute;
top: 0;
left: 0;
width: 80px;
height: 30px;
line-height: 30px;
color: #ffffff;
background: #ff7600;
text-align: center;
}
}
}
</style>

245
src/views/modules/heart/volunteerunion-detail.vue

@ -0,0 +1,245 @@
<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' ? '120px' : '80px'">
<el-row>
<el-form-item label="联盟图片">
<img v-if="dataForm.headPic"
:src="dataForm.headPic"
class="avatar">
</el-form-item>
</el-row>
<el-form-item label="联盟名称">
{{dataForm.unionName}}
</el-form-item>
<el-form-item label="联系人">
{{dataForm.contacts}}
</el-form-item>
<el-form-item label="联系电话">
{{dataForm.phone}}
</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>
<template slot="footer">
<el-button @click="visible = false">返回</el-button>
</template>
</el-dialog>
</template>
<script>
import TinymceEditor from '@/components/tinymce-editor'
export default {
data () {
return {
visible: false,
dataForm: {
id: '',
unionName: '',
contacts: '',
phone: '',
content: '',
sort: '',
headPic: ''
}
}
},
computed: {
dataRule () {
return {
}
}
},
components: {
TinymceEditor
},
methods: {
init () {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.getInfo()
}
})
},
//
getInfo () {
this.$http.get(`/heart/volunteerunion/${this.dataForm.id}`).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.dataForm = {
...this.dataForm,
...res.data
}
}).catch(() => {})
}
}
}
</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>
<style lang="scss">
.project-handle {
.el-timeline {
padding-left: 9px;
font-size: 13px;
}
.el-textarea {
width: 600px !important;
}
.el-input {
width: 600px !important;
}
}
.el-form-item__label {
font-weight: bold;
}
</style>
<style lang="scss" scoped>
.project-handle {
width: 100%;
height: calc(100vh - 120px);
background: #ffffff;
box-sizing: border-box;
padding: 10px;
.project-detail {
width: 100%;
height: 49%;
border: 2px solid #ccc;
box-sizing: border-box;
padding: 10px;
padding-top: 20px;
float: left;
margin-bottom: 1%;
position: relative;
.project-detail-tip {
position: absolute;
top: 0;
left: 0;
width: 80px;
height: 30px;
line-height: 30px;
color: #ffffff;
background: #4ac38b;
text-align: center;
}
.el-form {
width: 58%;
height: 100%;
float: left;
overflow-y: auto;
&::-webkit-scrollbar {
width: 5px;
height: 1px;
}
&::-webkit-scrollbar-thumb {
border-radius: 5px;
background: #ccc;
}
&::-webkit-scrollbar-track {
border-radius: 10px;
background: #fff;
}
}
.container {
width: 40%;
height: 100%;
float: right;
.location {
height: 30px;
line-height: 30px;
}
#map {
width: 100%;
height: calc(100% - 30px);
}
}
}
.project-progress {
width: 20%;
height: 100%;
float: right;
border: 2px solid #ccc;
box-sizing: border-box;
margin-left: 1%;
padding-top: 20px;
overflow-y: auto;
&::-webkit-scrollbar {
width: 5px;
height: 1px;
}
&::-webkit-scrollbar-thumb {
border-radius: 5px;
background: #aaa;
}
&::-webkit-scrollbar-track {
border-radius: 10px;
background: #ccc;
}
}
.handle-operation {
padding-top: 30px;
box-sizing: border-box;
width: 100%;
height: 49%;
box-sizing: border-box;
border: 2px solid #ccc;
float: left;
position: relative;
overflow-y: auto;
&::-webkit-scrollbar {
width: 5px;
height: 1px;
}
&::-webkit-scrollbar-thumb {
border-radius: 5px;
background: #aaa;
}
&::-webkit-scrollbar-track {
border-radius: 10px;
background: #ccc;
}
.handle-operation-tip {
position: absolute;
top: 0;
left: 0;
width: 80px;
height: 30px;
line-height: 30px;
color: #ffffff;
background: #ff7600;
text-align: center;
}
}
}
</style>

27
src/views/modules/heart/volunteerunion.vue

@ -31,21 +31,14 @@
<el-table-column type="index"
width="50"
label="序号" align="center"></el-table-column>
<!-- <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>-->
<!-- <el-table-column prop="id" label="主键" header-align="center" align="center"></el-table-column>-->
<el-table-column prop="unionName" label="联盟名称" header-align="center" align="center"></el-table-column>
<el-table-column prop="contacts" label="联系人" header-align="center" align="center"></el-table-column>
<el-table-column prop="phone" 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 prop="content" label="团队介绍" header-align="center" align="center"></el-table-column>-->
<!-- <el-table-column prop="revision" label="乐观锁" header-align="center" align="center"></el-table-column>-->
<!-- <el-table-column prop="createdBy" label="创建人" header-align="center" align="center"></el-table-column>-->
<el-table-column prop="createdTime" label="创建时间" header-align="center" align="center"></el-table-column>
<!-- <el-table-column prop="updatedBy" label="更新人" header-align="center" align="center"></el-table-column>-->
<!-- <el-table-column prop="updatedTime" label="更新时间" header-align="center" align="center"></el-table-column>-->
<!-- <el-table-column prop="delFlag" 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>
@ -62,6 +55,8 @@
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
<!-- 详情 -->
<volunteerunion-detail v-if="detailVisible" ref="volunteerunionDetail" @refreshDataList="getDataList"></volunteerunion-detail>
</div>
</el-card>
</template>
@ -69,6 +64,7 @@
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './volunteerunion-add-or-update'
import volunteerunionDetail from './volunteerunion-detail'
export default {
mixins: [mixinViewModule],
data () {
@ -81,11 +77,22 @@ export default {
},
dataForm: {
id: ''
}
},
detailVisible: false
}
},
methods: {
detailHandle (id) {
this.detailVisible = true
this.$nextTick(() => {
this.$refs.volunteerunionDetail.dataForm.id = id
this.$refs.volunteerunionDetail.init()
})
}
},
components: {
AddOrUpdate
AddOrUpdate,
volunteerunionDetail
}
}
</script>

Loading…
Cancel
Save