|
@@ -1,41 +1,36 @@
|
|
<template>
|
|
<template>
|
|
- <div class="component-vote-form">
|
|
|
|
|
|
+ <div class="component-vote-form light-iview-form light-el-input">
|
|
<Form ref="voteForm" :model="voteForm" label-position="top" :rules="ruleValidate" :disabled="!voteFormEdit"
|
|
<Form ref="voteForm" :model="voteForm" label-position="top" :rules="ruleValidate" :disabled="!voteFormEdit"
|
|
- hide-required-mark>
|
|
|
|
|
|
+ hide-required-mark>
|
|
<FormItem :label="$t('vote.form.name')" prop="name">
|
|
<FormItem :label="$t('vote.form.name')" prop="name">
|
|
- <Input :class="!voteFormEdit ? 'vote-form-disabled':''" v-model="voteForm.name" :placeholder="$t('vote.form.namePlace')"></Input>
|
|
|
|
|
|
+ <Input :class="!voteFormEdit ? 'vote-form-disabled':''" v-model="voteForm.name"
|
|
|
|
+ :placeholder="$t('vote.form.namePlace')"></Input>
|
|
</FormItem>
|
|
</FormItem>
|
|
<FormItem :label="$t('vote.form.target')" prop="classes">
|
|
<FormItem :label="$t('vote.form.target')" prop="classes">
|
|
- <!-- <RadioGroup v-model="classType" @on-change="onClassTypeChange" v-if="voteFormEdit">
|
|
|
|
- <Radio label="private" v-if="getCurScope === 'private'">{{ $t('vote.form.privateClass') }}</Radio>
|
|
|
|
- <Radio label="school">{{ $t('vote.form.schoolClass') }}</Radio>
|
|
|
|
- </RadioGroup> -->
|
|
|
|
|
|
+ <!-- 预览状态 -->
|
|
<div v-if="!voteFormEdit && curVoteItem" class="vote-class">
|
|
<div v-if="!voteFormEdit && curVoteItem" class="vote-class">
|
|
<span v-for="item in classNameArr" class="vote-class-item">{{ item.name }}</span>
|
|
<span v-for="item in classNameArr" class="vote-class-item">{{ item.name }}</span>
|
|
</div>
|
|
</div>
|
|
- <!-- <Select multiple v-model="voteForm.classes" :class="!voteFormEdit ? 'vote-form-disabled':''" :placeholder="$t('vote.form.targetPlace')"
|
|
|
|
- :not-found-text="$t('vote.form.noFoundText')" v-else>
|
|
|
|
- <Option v-for="(item,index) in classRooms.filter(i=>i.scope === classType)" :value="item.id" :key="index">{{ item.name }}</Option>
|
|
|
|
- </Select> -->
|
|
|
|
|
|
+ <!-- 编辑状态 -->
|
|
<div v-else>
|
|
<div v-else>
|
|
- <BaseClassSelect :classes="classTargets" :type="targetType" @onChange="onTargetChange" ref="classSelectRef" v-if="getCurScope === 'school' && curVoteItem"></BaseClassSelect>
|
|
|
|
- <BaseClassSelectPri :classes="classTargets" :scope="classType" @onChange="onTargetChange" ref="classSelectRef" v-if="getCurScope === 'private' && curVoteItem"></BaseClassSelectPri>
|
|
|
|
|
|
+ <!-- 区级选学校 -->
|
|
|
|
+ <div v-if="isAreaVote">
|
|
|
|
+ <el-cascader size="small" :show-all-levels="false" clearable filterable v-model="schoolTarget"
|
|
|
|
+ :options="csOptions" :props="props" @change="treeChange" style="width:100%;">
|
|
|
|
+ </el-cascader>
|
|
|
|
+ </div>
|
|
|
|
+ <div v-else>
|
|
|
|
+ <!-- 校级选教研组或者学生名单 -->
|
|
|
|
+ <BaseClassSelect :classes="classTargets" :type="targetType" @onChange="onTargetChange"
|
|
|
|
+ ref="classSelectRef" v-if="getCurScope === 'school' && curVoteItem"></BaseClassSelect>
|
|
|
|
+ <BaseClassSelectPri :classes="classTargets" :scope="classType" @onChange="onTargetChange"
|
|
|
|
+ ref="classSelectRef" v-if="getCurScope === 'private' && curVoteItem"></BaseClassSelectPri>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- <!-- <el-cascader size="small" :show-all-levels="false" clearable filterable v-model="voteForm.classes" :options="csOptions" :props="props" @change="treeChange" style="width:100%;">
|
|
|
|
- </el-cascader> -->
|
|
|
|
</FormItem>
|
|
</FormItem>
|
|
-
|
|
|
|
- <!-- <FormItem :label="$t('vote.form.time')" prop="rangeTime">
|
|
|
|
- <DatePicker type="datetimerange" transfer @on-change="onChangeRange" @on-open-change="onOpenChange" :options="options3" format="yyyy-MM-dd HH:mm"
|
|
|
|
- :class="!voteFormEdit ? 'vote-form-disabled':''" :editable="isDateEdit" :value="[voteForm.startTime,voteForm.endTime]"
|
|
|
|
- :placeholder="$t('vote.form.endTimePlace')"></DatePicker>
|
|
|
|
- </FormItem> -->
|
|
|
|
-
|
|
|
|
- <FormItem :label="$t('learnActivity.createEv.publishType')" prop="publishModel" v-show="voteFormEdit">
|
|
|
|
|
|
+ <FormItem :label="$t('learnActivity.createEv.publishType')" prop="publishModel" v-show="voteFormEdit && !isAreaVote">
|
|
<Checkbox v-model="isImmediate">{{$t('global.publishType1')}}</Checkbox>
|
|
<Checkbox v-model="isImmediate">{{$t('global.publishType1')}}</Checkbox>
|
|
</FormItem>
|
|
</FormItem>
|
|
-
|
|
|
|
<FormItem :label="$t('learnActivity.createEv.startTime')" v-if="!isImmediate || !voteFormEdit"
|
|
<FormItem :label="$t('learnActivity.createEv.startTime')" v-if="!isImmediate || !voteFormEdit"
|
|
prop="startTime">
|
|
prop="startTime">
|
|
<DatePicker v-show="voteFormEdit" type="datetime" :options="startOption" format="yyyy/MM/dd HH:mm"
|
|
<DatePicker v-show="voteFormEdit" type="datetime" :options="startOption" format="yyyy/MM/dd HH:mm"
|
|
@@ -45,10 +40,10 @@
|
|
{{ $tools.formatTime(voteForm.startTime,'yyyy-MM-dd hh:mm') }}
|
|
{{ $tools.formatTime(voteForm.startTime,'yyyy-MM-dd hh:mm') }}
|
|
</div>
|
|
</div>
|
|
</FormItem>
|
|
</FormItem>
|
|
-
|
|
|
|
- <FormItem :label="$t('learnActivity.createEv.endTime')" prop="endTime">
|
|
|
|
- <DatePicker v-show="voteFormEdit" type="datetime" :options="endOption" format="yyyy/MM/dd HH:mm" v-model="voteForm.endTime"
|
|
|
|
- split-panels @on-change="onChangeEndTime" :placeholder="$t('learnActivity.createEv.eTimeHolder')" style="width:100%"></DatePicker>
|
|
|
|
|
|
+ <FormItem :label="$t('learnActivity.createEv.endTime')" prop="endTime">
|
|
|
|
+ <DatePicker v-show="voteFormEdit" type="datetime" :options="endOption" format="yyyy/MM/dd HH:mm"
|
|
|
|
+ v-model="voteForm.endTime" split-panels @on-change="onChangeEndTime"
|
|
|
|
+ :placeholder="$t('learnActivity.createEv.eTimeHolder')" style="width:100%"></DatePicker>
|
|
<div v-show="!voteFormEdit" style="margin:10px;font-size:16px;font-weight:bold;">
|
|
<div v-show="!voteFormEdit" style="margin:10px;font-size:16px;font-weight:bold;">
|
|
{{ $tools.formatTime(voteForm.endTime,'yyyy-MM-dd hh:mm') }}
|
|
{{ $tools.formatTime(voteForm.endTime,'yyyy-MM-dd hh:mm') }}
|
|
</div>
|
|
</div>
|
|
@@ -56,7 +51,8 @@
|
|
|
|
|
|
<FormItem :label="$t('vote.form.description')" prop="description">
|
|
<FormItem :label="$t('vote.form.description')" prop="description">
|
|
<div ref="descriptionEditor" style="text-align:left" v-show="voteFormEdit"></div>
|
|
<div ref="descriptionEditor" style="text-align:left" v-show="voteFormEdit"></div>
|
|
- <div v-html="voteForm.description" v-show="!voteFormEdit" style="margin:10px;font-size:16px;font-weight:bold;"></div>
|
|
|
|
|
|
+ <div v-html="voteForm.description" v-show="!voteFormEdit"
|
|
|
|
+ style="margin:10px;font-size:16px;font-weight:bold;"></div>
|
|
</FormItem>
|
|
</FormItem>
|
|
|
|
|
|
<FormItem :label="$t('vote.form.optionSetting')" prop="attachment" ref="optionsBox">
|
|
<FormItem :label="$t('vote.form.optionSetting')" prop="attachment" ref="optionsBox">
|
|
@@ -64,18 +60,24 @@
|
|
<div v-for="(item,index) in voteOptions" :key="index" class="option-editor-wrap">
|
|
<div v-for="(item,index) in voteOptions" :key="index" class="option-editor-wrap">
|
|
<div v-show="voteFormEdit" style="display: flex;">
|
|
<div v-show="voteFormEdit" style="display: flex;">
|
|
<span class="option-order">{{ index + 1 }}
|
|
<span class="option-order">{{ index + 1 }}
|
|
- <Icon type="md-trash" @click="deleteOption(index)" /></span>
|
|
|
|
- <div :ref="'voteOption'+index" style="text-align:left" class="option-editor" @click="optionClick(index)"></div>
|
|
|
|
|
|
+ <Icon type="md-trash" @click="deleteOption(index)" />
|
|
|
|
+ </span>
|
|
|
|
+ <div :ref="'voteOption'+index" style="text-align:left" class="option-editor"
|
|
|
|
+ @click="optionClick(index)"></div>
|
|
</div>
|
|
</div>
|
|
<div v-show="!voteFormEdit">
|
|
<div v-show="!voteFormEdit">
|
|
<span style="margin-left: 10px;">{{ index + 1 }} .</span>
|
|
<span style="margin-left: 10px;">{{ index + 1 }} .</span>
|
|
- <div v-html="(voteOptionsContent[index]) ? voteOptionsContent[index].value : ''" v-show="!voteFormEdit" style="margin:10px;font-size:16px;font-weight:bold;display: inline-block;vertical-align: middle;"></div>
|
|
|
|
|
|
+ <div v-html="(voteOptionsContent[index]) ? voteOptionsContent[index].value : ''"
|
|
|
|
+ v-show="!voteFormEdit"
|
|
|
|
+ style="margin:10px;font-size:16px;font-weight:bold;display: inline-block;vertical-align: middle;">
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <p style="float:right;color:#BDBDBD;cursor:pointer" @click="onAddOption" v-show="voteFormEdit">
|
|
|
|
- <Icon type="md-add" />{{ $t('vote.form.addOption') }}</p>
|
|
|
|
|
|
+ <p style="float:right;color:#757575;cursor:pointer" @click="onAddOption" v-show="voteFormEdit">
|
|
|
|
+ <Icon type="md-add" />{{ $t('vote.form.addOption') }}
|
|
|
|
+ </p>
|
|
</FormItem>
|
|
</FormItem>
|
|
|
|
|
|
<FormItem :label="$t('vote.form.times')">
|
|
<FormItem :label="$t('vote.form.times')">
|
|
@@ -103,8 +105,10 @@
|
|
</FormItem>
|
|
</FormItem>
|
|
|
|
|
|
<FormItem v-show="voteFormEdit">
|
|
<FormItem v-show="voteFormEdit">
|
|
- <Button type="primary" class="btn-save" @click="handleSubmit('voteForm')" :loading="isBtnLoading">{{ $t('vote.form.save') }}</Button>
|
|
|
|
- <Button @click="handleCancel('voteForm')" class="btn-reset" style="margin-left: 8px">{{ $t('vote.form.cancel') }}</Button>
|
|
|
|
|
|
+ <Button type="primary" class="btn-save" @click="handleSubmit('voteForm')"
|
|
|
|
+ :loading="isBtnLoading">{{ $t('vote.form.save') }}</Button>
|
|
|
|
+ <Button @click="handleCancel('voteForm')" class="btn-reset"
|
|
|
|
+ style="margin-left: 8px">{{ $t('vote.form.cancel') }}</Button>
|
|
</FormItem>
|
|
</FormItem>
|
|
</Form>
|
|
</Form>
|
|
</div>
|
|
</div>
|
|
@@ -123,10 +127,16 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
data(vm) {
|
|
data(vm) {
|
|
- const _this = this
|
|
|
|
|
|
+ const _this = this
|
|
return {
|
|
return {
|
|
- classTargets:[],
|
|
|
|
- classNameArr:[],
|
|
|
|
|
|
+ props: {
|
|
|
|
+ multiple: true,
|
|
|
|
+ value: 'id',
|
|
|
|
+ label: 'name',
|
|
|
|
+ },
|
|
|
|
+ schoolTarget: [],
|
|
|
|
+ classTargets: [],
|
|
|
|
+ classNameArr: [],
|
|
classType: 'private',
|
|
classType: 'private',
|
|
curVoteItem: null,
|
|
curVoteItem: null,
|
|
isAdd: true,
|
|
isAdd: true,
|
|
@@ -185,11 +195,11 @@
|
|
message: vm.$t('vote.form.ruleName'),
|
|
message: vm.$t('vote.form.ruleName'),
|
|
trigger: 'blur'
|
|
trigger: 'blur'
|
|
}],
|
|
}],
|
|
- description: [{
|
|
|
|
- required: true,
|
|
|
|
- message: vm.$t('vote.form.ruleDescription'),
|
|
|
|
- trigger: 'blur'
|
|
|
|
- }],
|
|
|
|
|
|
+ // description: [{
|
|
|
|
+ // // required: true,
|
|
|
|
+ // message: vm.$t('vote.form.ruleDescription'),
|
|
|
|
+ // trigger: 'blur'
|
|
|
|
+ // }],
|
|
startTime: [{
|
|
startTime: [{
|
|
required: true,
|
|
required: true,
|
|
type: 'date',
|
|
type: 'date',
|
|
@@ -205,18 +215,21 @@
|
|
},
|
|
},
|
|
startOption: {
|
|
startOption: {
|
|
disabledDate(date) {
|
|
disabledDate(date) {
|
|
- return date && date.valueOf() < Date.now() - 86400000
|
|
|
|
|
|
+ return date && date.valueOf() < Date.now() - 86400000
|
|
}
|
|
}
|
|
},
|
|
},
|
|
endOption: {
|
|
endOption: {
|
|
disabledDate(date) {
|
|
disabledDate(date) {
|
|
let data = _this.voteForm.startTime ? _this.voteForm.startTime : Date.now()
|
|
let data = _this.voteForm.startTime ? _this.voteForm.startTime : Date.now()
|
|
- return data && data > date.valueOf() + 86400000
|
|
|
|
|
|
+ return data && data > date.valueOf() + 86400000
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- classIds:[],
|
|
|
|
- groupList:[],
|
|
|
|
- targetType:''
|
|
|
|
|
|
+ classIds: [],
|
|
|
|
+ groupList: [],
|
|
|
|
+ targetType: '',
|
|
|
|
+ schList: [],
|
|
|
|
+ csOptions: [],
|
|
|
|
+ areaId: sessionStorage.getItem('areaId'),
|
|
}
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
@@ -225,29 +238,72 @@
|
|
console.log(res)
|
|
console.log(res)
|
|
this.classRooms = res
|
|
this.classRooms = res
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+
|
|
this.findResearchList()
|
|
this.findResearchList()
|
|
|
|
+ if (this.isAreaVote) {
|
|
|
|
+ this.getAreaTargets()
|
|
|
|
+ }
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ treeChange(data) {
|
|
|
|
+ console.log('选择数据', this.schoolTarget)
|
|
|
|
+ },
|
|
|
|
+ getAreaTargets() {
|
|
|
|
+ this.$api.ability.findAreaGroup({
|
|
|
|
+ id: this.areaId
|
|
|
|
+ }).then(
|
|
|
|
+ res => {
|
|
|
|
+ if (res.gr && res.gr.length) {
|
|
|
|
+ this.schList = res.gr
|
|
|
|
+ this.csOptions = []
|
|
|
|
+ res.gr.forEach(sItem => {
|
|
|
|
+ let i = {
|
|
|
|
+ id: sItem.id,
|
|
|
|
+ name: sItem.sname,
|
|
|
|
+ children: []
|
|
|
|
+ }
|
|
|
|
+ sItem.name.forEach((gItem,gIndex) => {
|
|
|
|
+ i.children.push({
|
|
|
|
+ id: sItem.sname + '-' + gItem,
|
|
|
|
+ name: sItem.sname + '-' + gItem,
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ if (!i.children.length) {
|
|
|
|
+ i.children.push({
|
|
|
|
+ id: sItem.sname + '-' + '所有老师(未分组)',
|
|
|
|
+ name: sItem.sname + '-' + '所有老师(未分组)'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ this.csOptions.push(i)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ console.log(this.schList)
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ err => {
|
|
|
|
+ console.log(err)
|
|
|
|
+ }
|
|
|
|
+ )
|
|
|
|
+ },
|
|
onClassTypeChange(val) {
|
|
onClassTypeChange(val) {
|
|
this.voteForm.classes = []
|
|
this.voteForm.classes = []
|
|
},
|
|
},
|
|
-
|
|
|
|
- onTargetChange(data){
|
|
|
|
|
|
+
|
|
|
|
+ onTargetChange(data) {
|
|
this.voteForm.classes = this.getCurScope === 'school' ? data : data.map(i => i.split('/')[1])
|
|
this.voteForm.classes = this.getCurScope === 'school' ? data : data.map(i => i.split('/')[1])
|
|
this.voteForm.targets = this.getCurScope === 'school' ? [] : data
|
|
this.voteForm.targets = this.getCurScope === 'school' ? [] : data
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
onChangeSTime(val) {
|
|
onChangeSTime(val) {
|
|
let endTime = this.voteForm.endTime || Date.now()
|
|
let endTime = this.voteForm.endTime || Date.now()
|
|
if (new Date(val).getTime() >= new Date(endTime).getTime()) {
|
|
if (new Date(val).getTime() >= new Date(endTime).getTime()) {
|
|
this.voteForm.endTime = null
|
|
this.voteForm.endTime = null
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
- onChangeEndTime(val){
|
|
|
|
|
|
+
|
|
|
|
+ onChangeEndTime(val) {
|
|
if (val.indexOf('00:00') > 0) {
|
|
if (val.indexOf('00:00') > 0) {
|
|
- val = val.replace('00:00', '23:59')
|
|
|
|
|
|
+ val = val.replace('00:00', '23:59')
|
|
this.voteForm.endTime = val
|
|
this.voteForm.endTime = val
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -257,25 +313,31 @@
|
|
*/
|
|
*/
|
|
async handleSubmit(name) {
|
|
async handleSubmit(name) {
|
|
this.isBtnLoading = true
|
|
this.isBtnLoading = true
|
|
|
|
+ let hasTargets = (!this.isAreaVote && this.voteForm.classes.length) || (this.isAreaVote && this.schoolTarget.length)
|
|
|
|
+ let optionComplete = this.voteOptionsContent.length && this.voteOptionsContent.every(i => i.value !== '')
|
|
this.$refs[name].validate(async (valid) => {
|
|
this.$refs[name].validate(async (valid) => {
|
|
- if (valid && this.getSimpleText(this.voteForm.description) && this.voteOptionsContent.length && this.voteForm.classes.length) {
|
|
|
|
- if(this.voteForm.selectMax > this.voteOptionsContent.length && this.voteForm.repeat.indexOf('repeat') === -1){
|
|
|
|
|
|
+ if (valid && this.getSimpleText(this.voteForm.description) && optionComplete && hasTargets) {
|
|
|
|
+ if (this.voteForm.selectMax > this.voteOptionsContent.length && this.voteForm
|
|
|
|
+ .repeat.indexOf('repeat') === -1) {
|
|
this.$Message.warning(this.$t('vote.optionMaxTip'))
|
|
this.$Message.warning(this.$t('vote.optionMaxTip'))
|
|
this.isBtnLoading = false
|
|
this.isBtnLoading = false
|
|
- }else{
|
|
|
|
- if(this.voteForm.selectMax === 1){
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if (this.voteForm.selectMax === 1) {
|
|
this.voteForm.repeat = []
|
|
this.voteForm.repeat = []
|
|
}
|
|
}
|
|
console.log(this.voteForm)
|
|
console.log(this.voteForm)
|
|
- let classSelectScope = this.$refs.classSelectRef.evaluationInfo.scope
|
|
|
|
- let isSchoolClass = this.$refs.classSelectRef.evaluationInfo.scope === 'school' && this.$refs.classSelectRef.privateClassType === 'school'
|
|
|
|
|
|
+ let classSelectScope = this.isAreaVote ? 'school' : this.$refs.classSelectRef
|
|
|
|
+ .evaluationInfo.scope
|
|
|
|
+ let isSchoolClass = this.isAreaVote ? false : (this.$refs.classSelectRef.evaluationInfo.scope === 'school' && this.$refs.classSelectRef.privateClassType === 'school')
|
|
let params = Object.assign({}, this.defaultParams)
|
|
let params = Object.assign({}, this.defaultParams)
|
|
|
|
+ let areaParams = null
|
|
let target = []
|
|
let target = []
|
|
let fileName = this.$tools.guid()
|
|
let fileName = this.$tools.guid()
|
|
let isReset = this.voteForm.isReset.length > 0
|
|
let isReset = this.voteForm.isReset.length > 0
|
|
- let isPersonal = this.$route.name === 'personalVote' && classSelectScope === 'private'
|
|
|
|
|
|
+ let isPersonal = this.$route.name === 'personalVote' && classSelectScope ===
|
|
|
|
+ 'private'
|
|
let isSchool = this.$route.name === 'manageVote'
|
|
let isSchool = this.$route.name === 'manageVote'
|
|
-
|
|
|
|
|
|
+
|
|
params.code = this.getCurCode
|
|
params.code = this.getCurCode
|
|
params.scope = isPersonal ? 'private' : 'school'
|
|
params.scope = isPersonal ? 'private' : 'school'
|
|
params.name = this.voteForm.name
|
|
params.name = this.voteForm.name
|
|
@@ -292,28 +354,70 @@
|
|
params.creatorId = this.$store.state.userInfo.TEAMModelId
|
|
params.creatorId = this.$store.state.userInfo.TEAMModelId
|
|
params.voteNum = this.voteForm.selectMax
|
|
params.voteNum = this.voteForm.selectMax
|
|
params.times = this.voteForm.times
|
|
params.times = this.voteForm.times
|
|
- params.school = params.scope === 'school' ? this.$store.state.userInfo.schoolCode : null
|
|
|
|
|
|
+ params.school = params.scope === 'school' ? this.$store.state.userInfo.schoolCode : null
|
|
params.tchLists = []
|
|
params.tchLists = []
|
|
params.classes = []
|
|
params.classes = []
|
|
params.stuLists = []
|
|
params.stuLists = []
|
|
if (this.isEdit && this.editInfo.id && this.editInfo.code) {
|
|
if (this.isEdit && this.editInfo.id && this.editInfo.code) {
|
|
params.id = this.editInfo.id
|
|
params.id = this.editInfo.id
|
|
}
|
|
}
|
|
- // 如果是校本投票 则需要进一步确定发布对象是教研组还是学生名单
|
|
|
|
- if(isSchool && this.$refs.classSelectRef.targetType === 'research'){
|
|
|
|
- params.tchLists = this.voteForm.classes
|
|
|
|
- params.targetType = 'research'
|
|
|
|
- }else if(isSchoolClass){
|
|
|
|
- params.classes = this.voteForm.classes
|
|
|
|
- params.targetType = 'student'
|
|
|
|
|
|
+
|
|
|
|
+ // 如果是发布的区级投票 则需要修改保存参数
|
|
|
|
+ if (this.curVoteItem.owner === 'area') {
|
|
|
|
+ let schArr = [...new Set(this.schoolTarget.map(i => i[0]))]
|
|
|
|
+ let para = []
|
|
|
|
+ schArr.forEach((i, index) => {
|
|
|
|
+ para.push({
|
|
|
|
+ sId: i,
|
|
|
|
+ sName: this.schList.find(j => j.id === i).sname,
|
|
|
|
+ gName: [],
|
|
|
|
+ gId:[]
|
|
|
|
+ })
|
|
|
|
+ // 如果是区级活动 需要拼接学校加教研组信息
|
|
|
|
+ this.schoolTarget.forEach(j => {
|
|
|
|
+ if (j[0] === i) {
|
|
|
|
+ let groupName = j[1].split('-')[1]
|
|
|
|
+ if (groupName === '所有老师(未分组)') {
|
|
|
|
+ para[index].gName = []
|
|
|
|
+ para[index].gId = ['default']
|
|
|
|
+ } else {
|
|
|
|
+ let curSch = this.schList.find(sch => sch.id === i)
|
|
|
|
+ let groupId = curSch.gId[curSch.name.indexOf(groupName)]
|
|
|
|
+ para[index].gName.push(groupName)
|
|
|
|
+ para[index].gId.push(groupId)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ delete this.voteForm.classes
|
|
|
|
+ delete this.voteForm.targets
|
|
|
|
+ delete this.voteForm.teachers
|
|
|
|
+ delete this.voteForm.stuLists
|
|
|
|
+ areaParams = {
|
|
|
|
+ "id": this.areaId,
|
|
|
|
+ "para": para,
|
|
|
|
+ "vote": params
|
|
|
|
+ }
|
|
}else{
|
|
}else{
|
|
- params.stuLists = this.voteForm.classes
|
|
|
|
- params.targetType = 'student'
|
|
|
|
|
|
+ // 如果是校本投票 则需要进一步确定发布对象是教研组还是学生名单
|
|
|
|
+ if (isSchool && this.$refs.classSelectRef.targetType === 'research') {
|
|
|
|
+ params.tchLists = this.voteForm.classes
|
|
|
|
+ params.targetType = 'research'
|
|
|
|
+ } else if (isSchoolClass) {
|
|
|
|
+ params.classes = this.voteForm.classes
|
|
|
|
+ params.targetType = 'student'
|
|
|
|
+ } else {
|
|
|
|
+ params.stuLists = this.voteForm.classes
|
|
|
|
+ params.targetType = 'student'
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- console.log('提交的投票对象',params)
|
|
|
|
|
|
+
|
|
|
|
+ let finalParams = this.isAreaVote ? areaParams : params
|
|
|
|
+ console.log('提交的投票对象', finalParams)
|
|
/* 保存BLOB以及COSMOS */
|
|
/* 保存BLOB以及COSMOS */
|
|
- this.saveorUpdateVote(params).then(res => {
|
|
|
|
- this.$Message.success((this.isEdit && this.editInfo.id) ? this.$t('vote.form.editSuc') : this.$t(
|
|
|
|
|
|
+ this.saveorUpdateVote(finalParams).then(res => {
|
|
|
|
+ this.$Message.success((this.isEdit && this.editInfo.id) ? this.$t(
|
|
|
|
+ 'vote.form.editSuc') : this.$t(
|
|
'vote.form.addSuc'))
|
|
'vote.form.addSuc'))
|
|
this.$emit('onAddSuccess')
|
|
this.$emit('onAddSuccess')
|
|
this.isBtnLoading = false
|
|
this.isBtnLoading = false
|
|
@@ -324,12 +428,14 @@
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
this.isBtnLoading = false
|
|
this.isBtnLoading = false
|
|
- if (!this.voteOptionsContent.length) {
|
|
|
|
- this.$Message.error(this.$t('vote.form.noCompleteTip'))
|
|
|
|
- } else if(!this.voteForm.classes.length){
|
|
|
|
- this.$Message.error(this.$t('vote.form.ruleClasses'))
|
|
|
|
- } else{
|
|
|
|
|
|
+ if (!optionComplete) {
|
|
this.$Message.error(this.$t('vote.form.noOptionTip'))
|
|
this.$Message.error(this.$t('vote.form.noOptionTip'))
|
|
|
|
+ } else if (!hasTargets) {
|
|
|
|
+ this.$Message.error(this.$t('vote.form.ruleClasses'))
|
|
|
|
+ } else if(!this.getSimpleText(this.voteForm.description)){
|
|
|
|
+ this.$Message.error('投票详情不能为空!')
|
|
|
|
+ } else {
|
|
|
|
+ this.$Message.error(this.$t('vote.form.noCompleteTip'))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -463,13 +569,13 @@
|
|
}).then(res => {
|
|
}).then(res => {
|
|
if (!res.error && res.courses) {
|
|
if (!res.error && res.courses) {
|
|
this.$store.dispatch('user/getSchoolProfile').then(schoolProfile => {
|
|
this.$store.dispatch('user/getSchoolProfile').then(schoolProfile => {
|
|
- // let schoolClasses = schoolProfile.school_classes
|
|
|
|
|
|
+ // let schoolClasses = schoolProfile.school_classes
|
|
// console.log(schoolClasses)
|
|
// console.log(schoolClasses)
|
|
r(res.courses)
|
|
r(res.courses)
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
r([])
|
|
r([])
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
j(500)
|
|
j(500)
|
|
this.$Message.error(this.$t('vote.form.getDataFailTip'))
|
|
this.$Message.error(this.$t('vote.form.getDataFailTip'))
|
|
@@ -526,13 +632,23 @@
|
|
*/
|
|
*/
|
|
saveorUpdateVote(data) {
|
|
saveorUpdateVote(data) {
|
|
return new Promise((r, j) => {
|
|
return new Promise((r, j) => {
|
|
- this.$api.learnActivity.SaveorUpdataVote(data).then(res => {
|
|
|
|
- if (!res.error) {
|
|
|
|
- r(res)
|
|
|
|
- } else {
|
|
|
|
- j(res.error)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ if (this.curVoteItem.owner === 'school') {
|
|
|
|
+ this.$api.learnActivity.SaveorUpdataVote(data).then(res => {
|
|
|
|
+ if (!res.error) {
|
|
|
|
+ r(res)
|
|
|
|
+ } else {
|
|
|
|
+ j(res.error)
|
|
|
|
+ }
|
|
|
|
+ }).catch(e => j(e))
|
|
|
|
+ } else {
|
|
|
|
+ this.$api.ability.saveAreaVote(data).then(res => {
|
|
|
|
+ if (!res.error) {
|
|
|
|
+ r(res)
|
|
|
|
+ } else {
|
|
|
|
+ j(res.error)
|
|
|
|
+ }
|
|
|
|
+ }).catch(e => j(e))
|
|
|
|
+ }
|
|
})
|
|
})
|
|
|
|
|
|
},
|
|
},
|
|
@@ -542,22 +658,38 @@
|
|
* @param item
|
|
* @param item
|
|
*/
|
|
*/
|
|
async doRender(item) {
|
|
async doRender(item) {
|
|
- console.log('需要渲染的投票对象',item)
|
|
|
|
- if(item.targetType === 'research'){
|
|
|
|
- console.log(this.groupList);
|
|
|
|
- let groupNameArr = []
|
|
|
|
- item.tchLists.forEach(i => {
|
|
|
|
- let findObj = this.groupList.find(j => j.id === i)
|
|
|
|
- if(findObj){
|
|
|
|
- groupNameArr.push(findObj)
|
|
|
|
|
|
+ console.log('需要渲染的投票对象', item)
|
|
|
|
+
|
|
|
|
+ // 如果是区级投票
|
|
|
|
+ if(this.isAreaVote){
|
|
|
|
+ this.classNameArr = item.targets.map(i => {
|
|
|
|
+ return {
|
|
|
|
+ name:i
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- this.classNameArr = groupNameArr
|
|
|
|
}else{
|
|
}else{
|
|
- this.classNameArr = item.classes.length ? await this.getClassNameByIds(item.classes) : item.stuLists.length ? await this.getClassNameByIds(item.stuLists) : []
|
|
|
|
|
|
+ if (item.targetType === 'research') {
|
|
|
|
+ console.log(this.groupList);
|
|
|
|
+ let groupNameArr = []
|
|
|
|
+ item.tchLists.forEach(i => {
|
|
|
|
+ let findObj = this.groupList.find(j => j.id === i)
|
|
|
|
+ if (findObj) {
|
|
|
|
+ groupNameArr.push(findObj)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ this.classNameArr = groupNameArr
|
|
|
|
+ } else {
|
|
|
|
+ this.classNameArr = item.classes.length ? await this.getClassNameByIds(item.classes) : item
|
|
|
|
+ .stuLists.length ? await this.getClassNameByIds(item.stuLists) : []
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ console.log(this.classNameArr);
|
|
|
|
+
|
|
|
|
+
|
|
this.classType = item.classes.length ? 'school' : 'private'
|
|
this.classType = item.classes.length ? 'school' : 'private'
|
|
- this.classTargets = item.targetType === 'research' ? item.tchLists : this.getCurScope === 'school' ? item.classes : item.targets
|
|
|
|
|
|
+ this.classTargets = item.targetType === 'research' ? item.tchLists : this.getCurScope === 'school' ?
|
|
|
|
+ item.classes : item.targets
|
|
this.targetType = item.targetType
|
|
this.targetType = item.targetType
|
|
console.log(this.classNameArr)
|
|
console.log(this.classNameArr)
|
|
this.voteForm = null
|
|
this.voteForm = null
|
|
@@ -568,7 +700,8 @@
|
|
name: item.name,
|
|
name: item.name,
|
|
code: item.code,
|
|
code: item.code,
|
|
targets: item.targets,
|
|
targets: item.targets,
|
|
- classes: item.targetType === 'research' ? item.tchLists : item.classes.length ? item.classes : item.stuLists,
|
|
|
|
|
|
+ classes: item.targetType === 'research' ? item.tchLists : item.classes.length ? item.classes :
|
|
|
|
+ item.stuLists,
|
|
startTime: item.startTime ? new Date(item.startTime) : '',
|
|
startTime: item.startTime ? new Date(item.startTime) : '',
|
|
endTime: item.endTime ? new Date(item.endTime) : '',
|
|
endTime: item.endTime ? new Date(item.endTime) : '',
|
|
description: item.description,
|
|
description: item.description,
|
|
@@ -579,11 +712,11 @@
|
|
voteNum: item.voteNum || 1,
|
|
voteNum: item.voteNum || 1,
|
|
isReset: []
|
|
isReset: []
|
|
}
|
|
}
|
|
- this.isImmediate = false
|
|
|
|
|
|
+ this.isImmediate = item.isImmediate || false
|
|
this.descriptionEditor.txt.html(item.description)
|
|
this.descriptionEditor.txt.html(item.description)
|
|
this.voteOptionsContent = item.options
|
|
this.voteOptionsContent = item.options
|
|
this.voteOptions = item.options.map((item, index) => index)
|
|
this.voteOptions = item.options.map((item, index) => index)
|
|
-
|
|
|
|
|
|
+
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
this.initEditors()
|
|
this.initEditors()
|
|
this.curVoteItem = JSON.parse(JSON.stringify(item))
|
|
this.curVoteItem = JSON.parse(JSON.stringify(item))
|
|
@@ -592,18 +725,18 @@
|
|
this.$refs.voteForm.validateField('description')
|
|
this.$refs.voteForm.validateField('description')
|
|
})
|
|
})
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
/* 根据班级ID集合换取班级名称 */
|
|
/* 根据班级ID集合换取班级名称 */
|
|
- getClassNameByIds(ids){
|
|
|
|
- return new Promise((r,j) => {
|
|
|
|
|
|
+ getClassNameByIds(ids) {
|
|
|
|
+ return new Promise((r, j) => {
|
|
this.$api.learnActivity.getClassNameByIds({
|
|
this.$api.learnActivity.getClassNameByIds({
|
|
- classes:ids,
|
|
|
|
- school:this.$store.state.userInfo.schoolCode
|
|
|
|
|
|
+ classes: ids,
|
|
|
|
+ school: this.$store.state.userInfo.schoolCode
|
|
}).then(res => {
|
|
}).then(res => {
|
|
- if(!res.error){
|
|
|
|
|
|
+ if (!res.error) {
|
|
r(res.classInfos)
|
|
r(res.classInfos)
|
|
}
|
|
}
|
|
- }).catch(e =>{
|
|
|
|
|
|
+ }).catch(e => {
|
|
j(e)
|
|
j(e)
|
|
})
|
|
})
|
|
})
|
|
})
|
|
@@ -620,16 +753,17 @@
|
|
// })
|
|
// })
|
|
// }
|
|
// }
|
|
console.log(classId);
|
|
console.log(classId);
|
|
- return this.classNameArr.find(i => i.id === classId) ? this.classNameArr.find(i => i.id === classId).name : this.$t('vote.form.noMatchDataTip')
|
|
|
|
|
|
+ return this.classNameArr.find(i => i.id === classId) ? this.classNameArr.find(i => i.id === classId).name :
|
|
|
|
+ this.$t('vote.form.noMatchDataTip')
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+
|
|
/* 查找学校检验组信息 */
|
|
/* 查找学校检验组信息 */
|
|
- findResearchList(){
|
|
|
|
|
|
+ findResearchList() {
|
|
this.$api.schoolUser.getResearchGroup({
|
|
this.$api.schoolUser.getResearchGroup({
|
|
- code:this.$store.state.userInfo.schoolCode,
|
|
|
|
- scope:'school'
|
|
|
|
|
|
+ code: this.$store.state.userInfo.schoolCode,
|
|
|
|
+ scope: 'school'
|
|
}).then(res => {
|
|
}).then(res => {
|
|
- this.groupList = res.stuList
|
|
|
|
|
|
+ this.groupList = res.tchLists
|
|
})
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -639,10 +773,10 @@
|
|
descriptionEditor.config.onchange = (html) => {
|
|
descriptionEditor.config.onchange = (html) => {
|
|
this.voteForm.description = html
|
|
this.voteForm.description = html
|
|
}
|
|
}
|
|
- this.$editorTools.initSimpleEditor(descriptionEditor,this)
|
|
|
|
|
|
+ this.$editorTools.initSimpleEditor(descriptionEditor, this)
|
|
descriptionEditor.create()
|
|
descriptionEditor.create()
|
|
this.descriptionEditor = descriptionEditor
|
|
this.descriptionEditor = descriptionEditor
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
if (this.editItem && this.editItem.name) {
|
|
if (this.editItem && this.editItem.name) {
|
|
console.log(this.editItem)
|
|
console.log(this.editItem)
|
|
@@ -655,69 +789,19 @@
|
|
|
|
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
|
|
+ isAreaVote() {
|
|
|
|
+ return this.$route.name === 'manageAreaVote'
|
|
|
|
+ },
|
|
getDisableDays() {
|
|
getDisableDays() {
|
|
return this.voteForm.startTime
|
|
return this.voteForm.startTime
|
|
},
|
|
},
|
|
getCurCode() {
|
|
getCurCode() {
|
|
- return this.$route.name === 'personalVote' ? this.$store.state.userInfo.TEAMModelId : this.$store.state.userInfo.schoolCode
|
|
|
|
|
|
+ return this.$route.name === 'personalVote' ? this.$store.state.userInfo.TEAMModelId : this.$store.state
|
|
|
|
+ .userInfo.schoolCode
|
|
},
|
|
},
|
|
getCurScope() {
|
|
getCurScope() {
|
|
return this.$route.name === 'personalVote' ? 'private' : 'school'
|
|
return this.$route.name === 'personalVote' ? 'private' : 'school'
|
|
},
|
|
},
|
|
- //级联选择年级班级
|
|
|
|
- csOptions() {
|
|
|
|
- let data = []
|
|
|
|
- //填充行政班数据
|
|
|
|
- if (this.evaluationInfo.period.id && this.schoolBase.period.length && this.schoolClasses.length) {
|
|
|
|
- let curPd = this.schoolBase.period.find((item) => {
|
|
|
|
- return item.id == this.evaluationInfo.period.id
|
|
|
|
- })
|
|
|
|
- data = [
|
|
|
|
- {
|
|
|
|
- id: 'class',
|
|
|
|
- name: '行政班',
|
|
|
|
- children: []
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: 'stulist',
|
|
|
|
- name: '教学班',
|
|
|
|
- disabled: true,
|
|
|
|
- children: []
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- if (curPd) {
|
|
|
|
- //计算学级逻辑
|
|
|
|
- let date = new Date()
|
|
|
|
- let curYear = date.getFullYear()
|
|
|
|
- let month = date.getMonth() + 1
|
|
|
|
- let start = curPd.semesters.find(item => {
|
|
|
|
- return item.start == 1
|
|
|
|
- })
|
|
|
|
- // 根据入学月份确定当前年级和学级的关系
|
|
|
|
- if (start && month < start.month) {
|
|
|
|
- curYear--
|
|
|
|
- }
|
|
|
|
- curPd.grades.forEach((item, index) => {
|
|
|
|
- let dataItem = {
|
|
|
|
- id: index, //年级使用index
|
|
|
|
- name: `${item}(${curYear - index}级)`,
|
|
|
|
- year: curYear - index,
|
|
|
|
- children: []
|
|
|
|
- }
|
|
|
|
- let child = this.schoolClasses.filter(classItem => {
|
|
|
|
- return (classItem.year == curYear - index) && classItem.periodId == this.evaluationInfo.period.id
|
|
|
|
- })
|
|
|
|
- dataItem.children = child
|
|
|
|
- data[0].children.push(dataItem)
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- // 填充教学班数据
|
|
|
|
- data[1].children.push(...this.stuList)
|
|
|
|
- console.log('data数据', data)
|
|
|
|
- }
|
|
|
|
- return data
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
editItem: {
|
|
editItem: {
|