|
|
@@ -1,29 +1,115 @@
|
|
|
<template>
|
|
|
- <el-card :body-style="{ padding: '5px' }" class="card">
|
|
|
- <el-input
|
|
|
- v-model="textarea"
|
|
|
- type="textarea"
|
|
|
- maxlength="200"
|
|
|
- @blur="handleBlur"
|
|
|
- :rows="3"
|
|
|
- placeholder="有什么新鲜事想分享给大家?"
|
|
|
- style="padding: 5px"
|
|
|
- />
|
|
|
-<!-- <el-upload
|
|
|
- :action="actionUrl"
|
|
|
- style="padding: 5px"
|
|
|
- >
|
|
|
- </el-upload>-->
|
|
|
- <el-button style="padding: 5px" icon="el-icon-picture" @click="onImage">图片</el-button>
|
|
|
- <el-button style="padding: 5px" icon="el-icon-tickets" @click="onVote">投票</el-button>
|
|
|
- <el-row style="text-align: right">
|
|
|
- <el-button round type="submit" @click="onSubmit">发送</el-button>
|
|
|
- </el-row>
|
|
|
+ <div style="padding: 5px">
|
|
|
+ <el-card style="padding: 5px">
|
|
|
+ <el-input
|
|
|
+ v-model="textarea"
|
|
|
+ type="textarea"
|
|
|
+ maxlength="200"
|
|
|
+ :rows="3"
|
|
|
+ placeholder="有什么新鲜事想分享给大家?"
|
|
|
+ style="padding: 5px"
|
|
|
+ @blur="handleBlur"
|
|
|
+ />
|
|
|
+ <!-- <el-upload
|
|
|
+ :action="actionUrl"
|
|
|
+ style="padding: 5px"
|
|
|
+ >
|
|
|
+ </el-upload>-->
|
|
|
+ <el-button style="padding: 5px" icon="el-icon-picture" @click="onImage">图片</el-button>
|
|
|
+ <el-button style="padding: 5px" icon="el-icon-tickets" @click="createVote">投票</el-button>
|
|
|
+ <el-row style="text-align: right">
|
|
|
+ <el-button round type="submit" @click="onSubmit">发送</el-button>
|
|
|
+ </el-row>
|
|
|
|
|
|
- <el-dialog :visible.sync="dialogVisible">
|
|
|
- <img width="100%" :src="dialogImageUrl" alt="">
|
|
|
- </el-dialog>
|
|
|
- </el-card>
|
|
|
+ <el-dialog :visible.sync="dialogVisible">
|
|
|
+ <img width="100%" :src="dialogImageUrl" alt="">
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ title="创建投票"
|
|
|
+ :visible.sync="showVoteDialog"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ width="50%"
|
|
|
+ center
|
|
|
+ @close="onCloseDialog"
|
|
|
+ >
|
|
|
+ <el-card>
|
|
|
+ <el-form ref="voteForm" :model="voteForm" :rules="voteFormRules">
|
|
|
+ <el-form-item label="投票名称" label-width="120px" prop="title">
|
|
|
+ <el-input
|
|
|
+ v-model="voteForm.title"
|
|
|
+ style="margin-left: 5px"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="结束时间" label-width="120px" prop="endTime">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="voteForm.endTime"
|
|
|
+ type="date"
|
|
|
+ style="margin-left: 5px"
|
|
|
+ placeholder="选择结束时间"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="预期人数" label-width="120px" prop="expectNum">
|
|
|
+ <el-input-number v-model="voteForm.expectNum" :min="2" :max="10000" style="margin-left: 5px" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ size="small"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ style="margin-left: 40px"
|
|
|
+ @click="addVoteOption"
|
|
|
+ >
|
|
|
+ 添加投票选项
|
|
|
+ </el-button>
|
|
|
+ <!--存放答案表单的信息-->
|
|
|
+ <el-form-item prop="options">
|
|
|
+ <el-table :data="voteForm.options" border style="width: 96%;margin-left: 40px;margin-top: 10px">
|
|
|
+ <el-table-column label="选项内容">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input
|
|
|
+ v-model="scope.row.name"
|
|
|
+ style="margin-left: 5px"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button type="danger" icon="el-icon-delete" size="mini" circle @click="delVoteOption(scope.row)" />
|
|
|
+ <el-button type="danger" icon="el-icon-plus" size="mini" circle @click="addVoteOption" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-card>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="addVote">添 加</el-button>
|
|
|
+ <el-button @click="showVoteDialog = false">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </el-card>
|
|
|
+ <el-card v-if="vote !== null" style="padding: 5px">
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <span>{{ vote.title }}</span>
|
|
|
+ <el-button style="float: right; padding: 5px; color: blue" type="text" @click="submit">提交投票</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="text item">
|
|
|
+ <el-radio-group
|
|
|
+ v-for="(voteOption, index1) in vote.options"
|
|
|
+ :key="index1"
|
|
|
+ v-model="checkedRadio"
|
|
|
+ class="movie-list"
|
|
|
+ @change="singleCheckChange(voteOption)"
|
|
|
+ >
|
|
|
+ <el-radio :label="voteOption.value" border size="medium">
|
|
|
+ <span>{{ voteOption.name }}</span>
|
|
|
+ </el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
@@ -34,7 +120,43 @@ export default {
|
|
|
actionUrl: process.env.VUE_APP_SERVER_URL + '/api/content/timeline',
|
|
|
textarea: '',
|
|
|
dialogImageUrl: '',
|
|
|
- dialogVisible: false
|
|
|
+ dialogVisible: false,
|
|
|
+ // 表单
|
|
|
+ voteForm: {
|
|
|
+ title: '',
|
|
|
+ endTime: null,
|
|
|
+ expectNum: 0,
|
|
|
+ options: []
|
|
|
+ },
|
|
|
+ // 表单的验证规则
|
|
|
+ voteFormRules: {
|
|
|
+ title: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入投票名称',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ endTime: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请选择投票的结束时间',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ expectNum: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请选择期望投票的人数',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ showVoteDialog: false,
|
|
|
+ vote: null,
|
|
|
+ checkedRadio: '',
|
|
|
+ selectedOption: null,
|
|
|
+ showVoteCard: false
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -45,17 +167,70 @@ export default {
|
|
|
this.dialogImageUrl = file.url
|
|
|
this.dialogVisible = true
|
|
|
},
|
|
|
+ handleBlur() {
|
|
|
+ this.$message.info(this.textarea)
|
|
|
+ },
|
|
|
onSubmit() {
|
|
|
console.log('发送状态')
|
|
|
},
|
|
|
onImage() {
|
|
|
this.$message.info('image')
|
|
|
},
|
|
|
- onVote() {
|
|
|
- this.$message.info('vote')
|
|
|
+ createVote() {
|
|
|
+ this.showVoteDialog = true
|
|
|
},
|
|
|
- handleBlur() {
|
|
|
- this.$message.info(this.textarea)
|
|
|
+ onCloseDialog() {
|
|
|
+ this.showVoteDialog = false
|
|
|
+ },
|
|
|
+ addVoteOption() {
|
|
|
+ this.voteForm.options.push({
|
|
|
+ optionId: this.voteForm.options.length,
|
|
|
+ name: '',
|
|
|
+ value: this.voteForm.options.length + 1,
|
|
|
+ pos: this.voteForm.options.length
|
|
|
+ })
|
|
|
+ },
|
|
|
+ delVoteOption(row) {
|
|
|
+ const id = row.optionId
|
|
|
+ this.voteForm.options.map((item, index) => {
|
|
|
+ if (item.pos === id) this.voteForm.options.splice(index, 1)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addVote() {
|
|
|
+ console.log(this.voteForm)
|
|
|
+ this.vote = this.voteForm
|
|
|
+ this.showVoteDialog = false
|
|
|
+ this.voteForm = {
|
|
|
+ title: '',
|
|
|
+ endTime: null,
|
|
|
+ expectNum: 0,
|
|
|
+ options: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ singleCheckChange(val) {
|
|
|
+ this.selectedOption = val
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ if (this.selectedOption === null) {
|
|
|
+ this.$message.info('请先选择')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const confirmText = '确认选择 [' + this.selectedOption.name + ']?'
|
|
|
+ this.$confirm(confirmText, '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ this.$message.info('已投票')
|
|
|
+ console.log(this.selectedOption)
|
|
|
+ this.vote = null
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '已取消'
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|