|
@@ -1,26 +1,26 @@
|
|
|
<template>
|
|
|
<div class="component-vote-form">
|
|
|
- <Form ref="hwForm" :model="hwForm" label-position="top" :rules="ruleValidate" :disabled="!voteFormEdit">
|
|
|
+ <Form ref="voteForm" :model="voteForm" label-position="top" :rules="ruleValidate" :disabled="!voteFormEdit">
|
|
|
<FormItem label="投票名称" prop="name">
|
|
|
- <Input :class="!voteFormEdit ? 'vote-form-disabled':''" v-model="hwForm.name" placeholder="请输入投票名称"></Input>
|
|
|
+ <Input :class="!voteFormEdit ? 'vote-form-disabled':''" v-model="voteForm.name" placeholder="请输入投票名称"></Input>
|
|
|
</FormItem>
|
|
|
<FormItem label="投票对象" prop="targetClassIds">
|
|
|
<div v-if="!voteFormEdit && curVoteItem" class="vote-class">
|
|
|
<span v-for="item in curVoteItem.targetClassIds" class="vote-class-item">{{ getTargetName(item) }}</span>
|
|
|
</div>
|
|
|
- <Select multiple v-model="hwForm.targetClassIds" :class="!voteFormEdit ? 'vote-form-disabled':''" placeholder="请选择投票发布对象" v-else>
|
|
|
+ <Select multiple v-model="voteForm.targetClassIds" :class="!voteFormEdit ? 'vote-form-disabled':''" placeholder="请选择投票发布对象" v-else>
|
|
|
<Option v-for="item in classRooms" :value="item.id" :key="item.id">{{ item.name }}</Option>
|
|
|
</Select>
|
|
|
</FormItem>
|
|
|
|
|
|
- <FormItem label="起止时间" prop="startTime">
|
|
|
- <!-- <DatePicker type="datetime" :class="!voteFormEdit ? 'vote-form-disabled':''" :editable="isDateEdit" placeholder="请选择投票结束时间" v-model="hwForm.endTime" :options="endTimeOptions"></DatePicker> -->
|
|
|
- <DatePicker type="datetimerange" @on-change="onChangeRange" format="yyyy-MM-dd HH:mm" :class="!voteFormEdit ? 'vote-form-disabled':''" :editable="isDateEdit" :value="[hwForm.startTime,hwForm.endTime]" placeholder="请选择投票结束时间"></DatePicker>
|
|
|
+ <FormItem label="起止时间" prop="rangeTime">
|
|
|
+ <!-- <DatePicker type="datetime" :class="!voteFormEdit ? 'vote-form-disabled':''" :editable="isDateEdit" placeholder="请选择投票结束时间" v-model="voteForm.endTime" :options="endTimeOptions"></DatePicker> -->
|
|
|
+ <DatePicker type="datetimerange" @on-change="onChangeRange" format="yyyy-MM-dd HH:mm" :class="!voteFormEdit ? 'vote-form-disabled':''" :editable="isDateEdit" :value="[voteForm.startTime,voteForm.endTime]" placeholder="请选择投票结束时间"></DatePicker>
|
|
|
</FormItem>
|
|
|
|
|
|
<FormItem label="投票描述" prop="description">
|
|
|
<div ref="descriptionEditor" style="text-align:left" v-show="voteFormEdit"></div>
|
|
|
- <div v-html="hwForm.description" v-show="!voteFormEdit" style="margin:10px;font-size:16px;font-weight:bold;color:#fff"></div>
|
|
|
+ <div v-html="voteForm.description" v-show="!voteFormEdit" style="margin:10px;font-size:16px;font-weight:bold;color:#fff"></div>
|
|
|
</FormItem>
|
|
|
|
|
|
<FormItem label="选项设置" prop="attachment" ref="optionsBox">
|
|
@@ -41,25 +41,25 @@
|
|
|
</FormItem>
|
|
|
|
|
|
<!--<FormItem label="投票记录" prop="isReset" v-show="editable && isEdit">
|
|
|
- <CheckboxGroup v-model="hwForm.isReset">
|
|
|
+ <CheckboxGroup v-model="voteForm.isReset">
|
|
|
<Checkbox label="reset">清空投票提交记录</Checkbox>
|
|
|
</CheckboxGroup>
|
|
|
</FormItem>-->
|
|
|
|
|
|
<FormItem label="可投票数" prop="selectMax">
|
|
|
- <!--<Input :class="!voteFormEdit ? 'vote-form-disabled':''" v-model="hwForm.count" placeholder="请输入投票名称"></Input>-->
|
|
|
- <InputNumber :max="10" :min="1" v-model="hwForm.selectMax"></InputNumber>
|
|
|
+ <!--<Input :class="!voteFormEdit ? 'vote-form-disabled':''" v-model="voteForm.count" placeholder="请输入投票名称"></Input>-->
|
|
|
+ <InputNumber :max="10" :min="1" v-model="voteForm.selectMax"></InputNumber>
|
|
|
</FormItem>
|
|
|
|
|
|
<FormItem label="其他" prop="secret">
|
|
|
- <CheckboxGroup v-model="hwForm.secret">
|
|
|
+ <CheckboxGroup v-model="voteForm.secret">
|
|
|
<Checkbox label="secret">开启匿名投票</Checkbox>
|
|
|
</CheckboxGroup>
|
|
|
</FormItem>
|
|
|
|
|
|
<FormItem v-show="voteFormEdit">
|
|
|
- <Button type="primary" class="btn-save" @click="handleSubmit('hwForm')" :loading="isBtnLoading">保存</Button>
|
|
|
- <Button @click="handleCancel('hwForm')" class="btn-reset" style="margin-left: 8px">取消</Button>
|
|
|
+ <Button type="primary" class="btn-save" @click="handleSubmit('voteForm')" :loading="isBtnLoading">保存</Button>
|
|
|
+ <Button @click="handleCancel('voteForm')" class="btn-reset" style="margin-left: 8px">取消</Button>
|
|
|
</FormItem>
|
|
|
</Form>
|
|
|
</div>
|
|
@@ -98,13 +98,13 @@
|
|
|
},
|
|
|
voteOptions: [...new Array(2).keys()], // 默认四个选项,
|
|
|
voteOptionsContent:[],
|
|
|
- hwForm: {
|
|
|
+ voteForm: {
|
|
|
name: '',
|
|
|
targetClassIds: [],
|
|
|
endTime: '',
|
|
|
publishModel:'0',
|
|
|
startTime:'',
|
|
|
- rangeTime:[],
|
|
|
+ rangeTime:null,
|
|
|
description: '',
|
|
|
isReset: [],
|
|
|
selectMax:1,
|
|
@@ -149,9 +149,12 @@
|
|
|
startTime: [
|
|
|
{ required: true, type: 'date', message: '请设置起止时间', trigger: 'change' }
|
|
|
],
|
|
|
- // rangeTime: [
|
|
|
- // { required: true, message: '请设置起止时间', trigger: 'change' }
|
|
|
- // ]
|
|
|
+ rangeTime: [{
|
|
|
+ required: true,
|
|
|
+ message: '日期不能为空!',
|
|
|
+ trigger: 'change',
|
|
|
+ type: 'array'
|
|
|
+ }]
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -162,9 +165,15 @@
|
|
|
},
|
|
|
methods: {
|
|
|
|
|
|
- onChangeRange(arr){
|
|
|
- this.hwForm.startTime = this.getTimestampByString(arr[0])
|
|
|
- this.hwForm.endTime = this.getTimestampByString(arr[1])
|
|
|
+ onChangeRange(arr) {
|
|
|
+ if(arr[0] === ''){
|
|
|
+ this.voteForm.rangeTime = null
|
|
|
+ }else{
|
|
|
+ this.voteForm.startTime = this.getTimestampByString(arr[0])
|
|
|
+ this.voteForm.endTime = this.getTimestampByString(arr[1])
|
|
|
+ this.voteForm.rangeTime = arr
|
|
|
+ }
|
|
|
+ console.log(this.rangeTime)
|
|
|
},
|
|
|
|
|
|
getTimestampByString(str){
|
|
@@ -180,25 +189,25 @@
|
|
|
async handleSubmit(name) {
|
|
|
this.isBtnLoading = true
|
|
|
this.$refs[name].validate(async (valid) => {
|
|
|
- if (valid && this.getSimpleText(this.hwForm.description) && this.voteOptionsContent.length) {
|
|
|
- console.log(this.hwForm)
|
|
|
+ if (valid && this.getSimpleText(this.voteForm.description) && this.voteOptionsContent.length) {
|
|
|
+ console.log(this.voteForm)
|
|
|
let params = Object.assign({}, this.defaultParams)
|
|
|
let target = []
|
|
|
let fileName = this.$tools.guid()
|
|
|
- let isReset = this.hwForm.isReset.length > 0
|
|
|
+ let isReset = this.voteForm.isReset.length > 0
|
|
|
params.code = this.getCurCode,
|
|
|
params.scope = this.getCurScope,
|
|
|
- params.name = this.hwForm.name
|
|
|
- params.startTime = this.hwForm.startTime
|
|
|
- params.endTime = this.hwForm.endTime
|
|
|
- params.description = this.hwForm.description
|
|
|
- params.selectMax = this.hwForm.selectMax
|
|
|
- params.secret = this.hwForm.secret.indexOf('secret') > -1
|
|
|
+ params.name = this.voteForm.name
|
|
|
+ params.startTime = this.voteForm.startTime
|
|
|
+ params.endTime = this.voteForm.endTime
|
|
|
+ params.description = this.voteForm.description
|
|
|
+ params.selectMax = this.voteForm.selectMax
|
|
|
+ params.secret = this.voteForm.secret.indexOf('secret') > -1
|
|
|
params.options = this.voteOptionsContent
|
|
|
if (this.isEdit && this.editInfo.id && this.editInfo.code) {
|
|
|
params.id = this.editInfo.id
|
|
|
}
|
|
|
- params.targetClassIds = this.hwForm.targetClassIds
|
|
|
+ params.targetClassIds = this.voteForm.targetClassIds
|
|
|
console.log(params)
|
|
|
/* 保存BLOB以及COSMOS */
|
|
|
this.saveorUpdateVote({ vote: params, reset: isReset }).then(res => {
|
|
@@ -365,7 +374,7 @@
|
|
|
* @param name
|
|
|
*/
|
|
|
handleCancel() {
|
|
|
- console.log(this.curVoteItem)
|
|
|
+ // 如果是新增的问卷点击取消编辑 则需要进行特殊处理
|
|
|
if(!this.curVoteItem.id){
|
|
|
this.$emit('onCancelVote')
|
|
|
}
|
|
@@ -411,12 +420,13 @@
|
|
|
this.voteOptionsContent = []
|
|
|
this.voteOptions = []
|
|
|
this.initEditors()
|
|
|
- this.hwForm = {
|
|
|
+ this.voteForm = {
|
|
|
name: item.name,
|
|
|
code:item.code,
|
|
|
targetClassIds: item.targetClassIds || [],
|
|
|
startTime: item.startTime,
|
|
|
endTime: item.endTime,
|
|
|
+ rangeTime: item.endTime ? [item.startTime,item.endTime] : null,
|
|
|
description: item.description,
|
|
|
secret: item.secret ? ['secret'] : [],
|
|
|
selectMax: item.selectMax,
|
|
@@ -447,7 +457,7 @@
|
|
|
//this.initEditors()
|
|
|
let descriptionEditor = new E(this.$refs.descriptionEditor)
|
|
|
descriptionEditor.customConfig = this.defaultConfig
|
|
|
- descriptionEditor.customConfig.onchange = (html) => { this.hwForm.description = html }
|
|
|
+ descriptionEditor.customConfig.onchange = (html) => { this.voteForm.description = html }
|
|
|
descriptionEditor.create()
|
|
|
this.descriptionEditor = descriptionEditor
|
|
|
|
|
@@ -463,7 +473,7 @@
|
|
|
},
|
|
|
computed:{
|
|
|
getDisableDays(){
|
|
|
- return this.hwForm.startTime
|
|
|
+ return this.voteForm.startTime
|
|
|
},
|
|
|
getCurCode(){
|
|
|
return this.$route.name === 'personalVote' ? this.$store.state.userInfo.TEAMModelId : this.$store.state.userInfo.schoolCode
|
|
@@ -486,7 +496,7 @@
|
|
|
} else {
|
|
|
/** 新增 */
|
|
|
console.log(newValue)
|
|
|
- this.handleReset('hwForm')
|
|
|
+ this.handleReset('voteForm')
|
|
|
this.isEdit = false
|
|
|
this.editInfo = null
|
|
|
}
|