mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-20 16:26:43 +08:00
2022年5月29日从svn移到git
This commit is contained in:
765
src/components/ExamPaper/simple.vue
Normal file
765
src/components/ExamPaper/simple.vue
Normal file
@@ -0,0 +1,765 @@
|
||||
<template>
|
||||
<div style="position: relative;">
|
||||
<div style="position: absolute;z-index: 10;width: 100%;right: 0px; height: 42px; background-color: #FFFFFF;">
|
||||
<div style="height: 40px; ">
|
||||
<div style="float: right;">
|
||||
<el-button type="success">保存</el-button>
|
||||
<el-button icon="el-icon-view" type="warning"></el-button>
|
||||
</div>
|
||||
<div style="height: 40px;text-align: center;">
|
||||
<el-button-group>
|
||||
<el-button @click="insertItem(201)" type="primary">单选题</el-button>
|
||||
<el-button @click="insertItem(202)" type="primary">多选题</el-button>
|
||||
<el-button @click="insertItem(203)" type="primary">判断</el-button>
|
||||
<el-button @click="insertItem(102)" type="primary">文本块</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style="height: 40px;"></div>
|
||||
<div class="survey-design" style="width: 800px; margin: auto; padding: 10px; border: 1px solid #cccccc; margin-top: 20px; min-height: 800px;">
|
||||
<div class="xp-title">
|
||||
<div class="xp-title-preview" v-show="editItem!='title'" @click="editClick('title',-1)">
|
||||
<h1 v-if="tplInfo.title!=''"> {{tplInfo.title}} </h1>
|
||||
<h1 v-if="tplInfo.title==''"> 点击编辑问题标题 </h1>
|
||||
</div>
|
||||
<div class="xp-title-edit" v-show="editItem=='title'">
|
||||
<div class=""><input maxlength="80" class="form-control" type="text" v-model="tplInfo.title"></div>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="xp-subtitle">
|
||||
<div v-show="editItem!='subTitle'" @click="editClick('subTitle',-1)">
|
||||
<div class="text" style="min-height: 30px;" v-html="tplInfo.subTitle"></div>
|
||||
</div>
|
||||
<div v-show="editItem=='subTitle'">
|
||||
<div><textarea maxlength="200" placeholder="可以在这里加一些关于问卷的详细描述" v-model="tplInfo.subTitle" rows="5" class="form-control"></textarea></div>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--遍历问题-->
|
||||
<div class="xp-q" v-for="(item,index) in paper.items">
|
||||
<div @mouseenter="qitemMouseenter(index)" @mouseleave="qitemMouseout" class="xq-preview" @click="editClick(item.id,index)" v-show="editItem!=item.id">
|
||||
<div v-if="item.type==101">
|
||||
<div class="xq-body">
|
||||
<h2 style="font-size: 1.3em; font-weight: 500;">{{item.body}}</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type==102">
|
||||
<div class="xq-body">
|
||||
<div style="font-size: 14px; font-weight: 400; text-indent:25px">{{item.body}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type>200 && item.type<210">
|
||||
<div class="xq-body">
|
||||
<div style="font-weight: 700;">{{item.number}}. {{item.body}}</div>
|
||||
<div v-if="item.tips!=''" style="font-weight: 400; padding: 10px;color:#858585">{{item.tips}}</div>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<table style="clear:all;width:auto">
|
||||
<tr v-if="item.options.length>0" v-for="(opt,optIdx) in item.options">
|
||||
<td>
|
||||
<input v-if="item.type==201 || item.type==203" type="radio" :name="'radio'+item.id" />
|
||||
<input v-if="item.type==202" type="checkbox" :name="'cb'+item.id" />
|
||||
<span>【{{optIdx+1}}】</span>
|
||||
</td>
|
||||
<td>{{opt.content}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type>210 && item.type<220">
|
||||
<div class="xq-body">
|
||||
<div style="font-weight: 700;">{{item.number}}. {{item.body}}</div>
|
||||
<div v-if="item.tips!=''" style="font-weight: 400;padding: 10px;color:#858585">{{item.tips}}</div>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<table class="tp-table">
|
||||
<tr class="trhead">
|
||||
<th></th><th v-for="score in item.scores">{{score.title}}</br>{{score.value}}</th>
|
||||
</tr>
|
||||
<tr v-for="(qone,qidx) in item.qlist">
|
||||
<td class="tq-table-tdlabel"> {{qone.content}}</td>
|
||||
<td style="text-align: center;" v-for="score in item.scores">
|
||||
<input type="radio" value="score.value">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type==301">
|
||||
<div class="xq-body">
|
||||
<div style="font-weight: 700;">{{item.number}}. {{item.body}}</div>
|
||||
<div v-if="item.tips!=''" style="font-weight: 400;padding: 10px;color:#858585">{{item.tips}}</div>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 60px;padding-right: 10px;"><input :id="'show-'+index+'--1'" style="width: 50px; height: 40px; font-size: 18px; text-align: center;" type="text"></td>
|
||||
<td><input type="range" @click.stop="" value="0" @change="rangeChange($event,index,-1)" :step="item.scores.step" :min="item.scores.min" :max="item.scores.max">
|
||||
<div style="width: 100%;height: 25px;">
|
||||
<div style="width:50px; float: right; text-align: right;">{{item.scores.max}}</div>
|
||||
<div style="width:50px; float: left; ">{{item.scores.min}}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type==302">
|
||||
<div class="xq-body">
|
||||
<div style="font-weight: 700;">{{item.number}}. {{item.body}}</div>
|
||||
<div v-if="item.tips!=''" style="font-weight: 400;padding: 10px;color:#858585">{{item.tips}}</div>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<table style="width: 100%;" v-for="(qone,qidx) in item.qlist">
|
||||
<tr>
|
||||
<td colspan="2">{{qone.content}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 60px;padding-right: 10px;"><input :id="'show-'+index+'-'+qidx" style="width: 50px; height: 40px; font-size: 18px; text-align: center;" type="text"></td>
|
||||
<td><input type="range" @click.stop="" value="0" @change="rangeChange($event,index,qidx)" :step="item.scores.step" :min="item.scores.min" :max="item.scores.max">
|
||||
<div style="width: 100%;height: 25px;">
|
||||
<div style="width:50px; float: right; text-align: right;">{{item.scores.max}}</div>
|
||||
<div style="width:50px; float: left; ">{{item.scores.min}}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type==303">
|
||||
<div class="xq-body">
|
||||
<div style="font-weight: 700;">{{item.number}}. {{item.body}}<span style="color: #C0C0C0;"> [满分{{item.scores.total}}]</span></div>
|
||||
<div v-if="item.tips!=''" style="font-weight: 400;padding: 10px;color:#858585">{{item.tips}}</div>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<table style="width: 100%;" v-for="(qone,qidx) in item.qlist">
|
||||
<tr>
|
||||
<td colspan="2">{{qone.content}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 60px;padding-right: 10px;"><input :id="'show-'+index+'-'+qidx" style="width: 50px; height: 40px; font-size: 18px; text-align: center;" type="text"></td>
|
||||
<td><input type="range" @click.stop="" value="0" @change="rangeChange($event,index,qidx)" :step="item.scores.step" min="0" :max="qone.max">
|
||||
<div style="width: 100%;height: 25px;">
|
||||
<div style="width:50px; float: right; text-align: right;">{{qone.max}}</div>
|
||||
<div style="width:50px; float: left; ">0</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type==501">
|
||||
<div class="xq-body">
|
||||
<div style="font-weight: 700;">{{item.number}}. {{item.body}}</div>
|
||||
<div v-if="item.tips!=''" style="font-weight: 400;padding: 10px;color:#858585">{{item.tips}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-show="mouseIndex==index" style="height: 30px; margin-top: 5px; border-top: 1px solid #f0f0f0 ;">
|
||||
<div style="float: right;">
|
||||
<el-button @click.stop="moveItem(index,true)" class="btn btn-warning">上移</el-button>
|
||||
<el-button @click.stop="moveItem(index,false)" class="btn btn-warning">下移</el-button>
|
||||
<el-button @click.stop="cloneItem(index)" class="btn btn-warning">复制</el-button>
|
||||
<el-button @click.stop="delItem(index)" class="btn btn-warning">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="xq-edit" v-show="editItem==item.id">
|
||||
<div v-if="item.type==101">
|
||||
<div class="xq-body">
|
||||
<input class="form-control" v-model="item.body" placeholder="问题的内容"/>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type==102">
|
||||
<div class="xq-body">
|
||||
<textarea rows="5" class="form-control" v-model="item.body" placeholder="问题的内容"></textarea>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type>200 && item.type<210">
|
||||
<div class="xq-body">
|
||||
<textarea class="form-control" v-model="item.body" placeholder="问题的内容" style="width: 100%; height: 50px;"></textarea>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<div v-if="item.options && item.options.length>0">
|
||||
<div style="color: red; padding: 5px;">问题的选项,一行一个选项</div>
|
||||
<textarea v-model="item.textOptions" class="form-control" rows="6" placeholder="一行代表一个选项"></textarea>
|
||||
</div>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type>210 && item.type<220">
|
||||
<div class="xq-body">
|
||||
<textarea class="form-control" v-model="item.body" placeholder="问题的内容" style="width: 100%; height: 50px;"></textarea>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<div style="width: 59%;display: inline-block;">
|
||||
<div style="color: red; padding: 5px;">左边是问题列表,一行一个问题</div>
|
||||
<textarea v-model="item.textOptions" class="form-control" rows="6" placeholder="一行代表一个选项"></textarea>
|
||||
</div>
|
||||
<div style="width: 39%; display: inline-block;padding-left: 10px;">
|
||||
<div style="color: red; padding-top: 5px;">
|
||||
<span>选项的数量:</span>
|
||||
<select v-model="scoresSelect" @change="scoreNumChange">
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
<option value="9">9</option>
|
||||
<option value="10">10</option>
|
||||
</select>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th>选项标题</th>
|
||||
<th>选项分值</th>
|
||||
</tr>
|
||||
<tr v-for="score in item.scores">
|
||||
<td><input v-model="score.title" style="width: 100%;" /> </td>
|
||||
<td><input v-model="score.value" style="width: 100%;" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="item.type==301">
|
||||
<div class="xq-body">
|
||||
<textarea class="form-control" v-model="item.body" placeholder="问题的内容" style="width: 100%; height: 50px;"></textarea>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<table style="margin-top: 20px;"><tr>
|
||||
<td>最小值:<input type="text" v-model="item.scores.min" style="width: 50px;"></td>
|
||||
<td>最大值:<input type="text" v-model="item.scores.max" style="width: 50px;"></td>
|
||||
<td>步长:<input type="text" v-model="item.scores.step" style="width: 50px;"></td>
|
||||
<td>默认值:<input type="text" v-model="item.answer" style="width: 50px;"></td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
|
||||
</div>
|
||||
<div v-if="item.type==302">
|
||||
<div class="xq-body">
|
||||
<textarea class="form-control" v-model="item.body" placeholder="问题的内容" style="width: 100%; height: 50px;"></textarea>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<div v-if="item.qlist && item.qlist">
|
||||
<div style="color: red; padding: 5px;">问题的选项,一行一个选项</div>
|
||||
<textarea v-model="item.textOptions" class="form-control" rows="6" placeholder="一行代表一个选项"></textarea>
|
||||
</div>
|
||||
<table style="margin-top: 20px;"><tr>
|
||||
<td>最小值:<input type="text" v-model="item.scores.min" style="width: 50px;"></td>
|
||||
<td>最大值:<input type="text" v-model="item.scores.max" style="width: 50px;"></td>
|
||||
<td>步长:<input type="text" v-model="item.scores.step" style="width: 50px;"></td>
|
||||
<td>默认值:<input type="text" v-model="item.scores.value" style="width: 50px;"></td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
</div>
|
||||
<div v-if="item.type==303">
|
||||
<div class="xq-body">
|
||||
<textarea class="form-control" v-model="item.body" placeholder="问题的内容" style="width: 100%; height: 50px;"></textarea>
|
||||
</div>
|
||||
<div class="xq-opts">
|
||||
<table class="table table-condensed" style="margin-top: 20px;">
|
||||
<tr>
|
||||
<td>
|
||||
<label>总分:</label>
|
||||
<input type="text" v-model="item.scores.total" style="width:100px;">
|
||||
</td>
|
||||
<td colspan="2">
|
||||
<el-button @click="addQlist(index,{'max':0})" class="btn btn-default">增加评分项</el-button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="(qone,qIdx) in item.qlist">
|
||||
<td><input type="text" v-model="qone.content" style="width: 100%;"> </td>
|
||||
<td>满分值:<input type="text" v-model="qone.max" style="width: 50px;"></td>
|
||||
<td><el-button v-if="qIdx>1" @click="delQlist(index,qIdx)" class="btn btn-danger btn-sm">删除</el-button> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
|
||||
</div>
|
||||
<div v-if="item.type==501">
|
||||
<div class="xq-body">
|
||||
<textarea class="form-control" v-model="item.body" placeholder="问题的内容" style="width: 100%; height: 50px;"></textarea>
|
||||
<div class="btn-edit-finish"><el-button class="btn btn-primary btn-block" @click="editFinish" type="el-button">完成编辑</el-button> </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--遍历完成-->
|
||||
</div>
|
||||
<div style="height: 100px;"></div>
|
||||
<Remark>
|
||||
1、课程问卷,问卷调查
|
||||
</Remark>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import survey from '@/api/modules/survey.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
paper:{items:[]},
|
||||
tplInfo:{id:'',title:'',subTitle:''},
|
||||
editItem:'',
|
||||
currentItem:null,
|
||||
scoresSelect:0,
|
||||
mouseIndex:-1,
|
||||
publicShow:false,
|
||||
tipsShow:false,
|
||||
currentTips:'',
|
||||
currentTipsIndex:-1,
|
||||
flags:[]
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
var $vue=this;
|
||||
|
||||
},
|
||||
methods:{
|
||||
toback:function(){
|
||||
location.href = this.webBaseUrl + "/papers";
|
||||
},
|
||||
qitemMouseenter:function(idx){
|
||||
this.mouseIndex=idx;
|
||||
},
|
||||
rangeChange:function(obj,index,qidx){
|
||||
var el = obj.currentTarget;
|
||||
$('#show-'+index+'-'+qidx).val(el.value);
|
||||
obj.stopPropagation();
|
||||
},
|
||||
qitemMouseout:function(){
|
||||
this.mouseIndex=-1;
|
||||
},
|
||||
editClick:function(flag,idx){
|
||||
this.editItem=flag;
|
||||
if(idx>-1){
|
||||
this.currentItem=this.paper.items[idx];
|
||||
var t=this.currentItem.type;
|
||||
if(this.currentItem.type==301){
|
||||
return;
|
||||
}
|
||||
var txt='';
|
||||
if(this.currentItem.qlist){
|
||||
this.currentItem.qlist.forEach(function(q){
|
||||
if(txt.length>1){
|
||||
txt+='\n';
|
||||
}
|
||||
txt+=q.content;
|
||||
});
|
||||
}else if(this.currentItem.options){
|
||||
this.currentItem.options.forEach(function(opt){
|
||||
if(txt.length>1){
|
||||
txt+='\n';
|
||||
}
|
||||
txt+=opt.content;
|
||||
});
|
||||
}
|
||||
this.currentItem.textOptions=txt;
|
||||
if(this.currentItem.scores){
|
||||
this.scoresSelect=this.currentItem.scores.length;
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
editFinish:function(flag){
|
||||
var $vue=this;
|
||||
this.editItem='';
|
||||
if(this.currentItem==null){
|
||||
return;
|
||||
}
|
||||
if(!this.currentItem.textOptions){
|
||||
return;
|
||||
}
|
||||
var txt = this.currentItem.textOptions;
|
||||
var txtArray=txt.split("\n");
|
||||
var index=1;
|
||||
var checkType='201,202,203';
|
||||
var t=this.currentItem.type;
|
||||
if(checkType.indexOf(t)>-1){
|
||||
if(t==202){
|
||||
this.currentItem.answer=[];
|
||||
}
|
||||
|
||||
this.currentItem.options=[];
|
||||
txtArray.forEach(function(t,i){
|
||||
if(t.length>0){
|
||||
$vue.currentItem.options.push({idx:$vue.currentItem.type+''+index,content:t});
|
||||
index++;
|
||||
}
|
||||
});
|
||||
}else if($vue.currentItem.type>210 && $vue.currentItem.type<220){
|
||||
$vue.currentItem.qlist=[];
|
||||
txtArray.forEach(function(t,i){
|
||||
if(t.length>0){
|
||||
$vue.currentItem.qlist.push({idx:$vue.currentItem.type+''+index,content:t});
|
||||
index++;
|
||||
}
|
||||
});
|
||||
}else if($vue.currentItem.type==302){
|
||||
$vue.currentItem.qlist=[];
|
||||
txtArray.forEach(function(t,i){
|
||||
if(t.length>0){
|
||||
$vue.currentItem.qlist.push({idx:$vue.currentItem.type+''+index,content:t,answer:0});
|
||||
index++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
insertItem:function(type){
|
||||
var size=this.paper.items.length;
|
||||
size=size+1;
|
||||
var rnum=Math.floor(Math.random()*10);
|
||||
//var sflake=new Snowflake(19, 19, 0);
|
||||
//var newId=sflake.nextId().substring(1);
|
||||
var newId=Math.round(Math.random()*999999);
|
||||
//对列表序号重置
|
||||
var num=1;
|
||||
this.paper.items.forEach(function(pitem,idx){
|
||||
if(pitem.type>200){
|
||||
pitem.number=num;
|
||||
num++;
|
||||
}
|
||||
});
|
||||
|
||||
var item={"id":newId,"answer":"","number":num,"type":type,"body":"段落标题内容","tips":""};
|
||||
if(type==101){
|
||||
item.body="段落标题内容";
|
||||
}else if(type==102){
|
||||
item.body="段落内容";
|
||||
}else if(type==201){
|
||||
item.body="问题内容";
|
||||
item.options=[
|
||||
{"idx":type+"1", "content":"选项内容"},
|
||||
{"idx":type+"2", "content":"选项内容"}
|
||||
];
|
||||
}else if(type==202){
|
||||
item.body="问题内容";
|
||||
item.answer=[];
|
||||
item.options=[
|
||||
{"idx":type+"1", "content":"选项内容"},
|
||||
{"idx":type+"2", "content":"选项内容"},
|
||||
{"idx":type+"3", "content":"选项内容"}
|
||||
];
|
||||
}else if(type==203){
|
||||
item.body="问题内容";
|
||||
item.options=[
|
||||
{"idx":type+"1", "content":"正确"},
|
||||
{"idx":type+"2", "content":"错误"}
|
||||
];
|
||||
}else if(type==211){
|
||||
item.body="请选择您对以下陈述的认可程度,分值越大代表认可程序越高1-5";
|
||||
item.scores=[
|
||||
{"title":"完全不同意","value":1},
|
||||
{"title":"不太同意","value":2},
|
||||
{"title":"同意","value":3},
|
||||
{"title":"很是同意","value":4},
|
||||
{"title":"非常认可","value":5}
|
||||
];
|
||||
item.qlist=[
|
||||
{"answer":"", "content":"问题1","tips":""},
|
||||
{"answer":"", "content":"问题2","tips":""}
|
||||
];
|
||||
}else if(type==301){
|
||||
item.body="评分内容";
|
||||
item.tips="";
|
||||
item.answer=0;
|
||||
//item.qlist=[];
|
||||
item.scores={"min":0,"step":1,"max":100,"value":0};
|
||||
}else if(type==302){
|
||||
item.body="评分内容";
|
||||
item.qlist=[
|
||||
{"idx":type+"1","answer":0, "content":"评分项"},
|
||||
{"idx":type+"2", "content":"评分项","answer":0}
|
||||
];
|
||||
item.scores={"min":0,"step":1,"max":100,"answer":0};
|
||||
}else if(type==303){
|
||||
item.body="评分内容";
|
||||
item.qlist=[
|
||||
{"idx":type+"1", "content":"评分项","max":50,"answer":0},
|
||||
{"idx":type+"2", "content":"评分项","max":50,"answer":0}
|
||||
];
|
||||
item.scores={"total":100,"step":1};
|
||||
}else if(type==501){
|
||||
item.body="问题内容";
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
this.paper.items.push(item);
|
||||
},
|
||||
resetNumber:function(){
|
||||
var num=1;
|
||||
this.paper.items.forEach(function(item){
|
||||
if(item.type>200){
|
||||
item.number=num;
|
||||
num++;
|
||||
}
|
||||
});
|
||||
},
|
||||
cloneItem:function(idx){
|
||||
var oldItem=this.paper.items[idx];
|
||||
var newItem = JSON.parse(JSON.stringify(oldItem));
|
||||
var rnum=Math.floor(Math.random()*10);
|
||||
//var sflake=new Snowflake(19, 19, 0);
|
||||
//var newId=sflake.nextId().substring(1);
|
||||
var newId=Math.round(Math.random()*999999);
|
||||
newItem.id=newId;
|
||||
this.paper.items.splice(idx,0,newItem);
|
||||
this.resetNumber();
|
||||
},
|
||||
addQlist:function(indx,fields){
|
||||
if(this.currentItem==null){
|
||||
return;
|
||||
}
|
||||
var idx=this.currentItem.type+""+(this.currentItem.qlist.length+1);
|
||||
var optItem={"idx":idx, "content":"评分项","answer":"0"};
|
||||
if(fields){
|
||||
$.extend(true, optItem, fields);
|
||||
}
|
||||
this.paper.items[indx].qlist.push(optItem);
|
||||
//signData.currentItem.qlist.push(optItem);
|
||||
},
|
||||
delQlist:function(indx,qIdx){
|
||||
if(this.currentItem==null){
|
||||
return;
|
||||
}
|
||||
//signData.currentItem.qlist.splice(optIdx,1);
|
||||
this.paper.items[indx].qlist.splice(qIdx,1);
|
||||
},
|
||||
delItem:function(indx){
|
||||
var $vue=this;
|
||||
//需要增加删除提示
|
||||
$vue.paper.items.splice(indx,1);
|
||||
//重新计算序号
|
||||
var num=1;
|
||||
$vue.paper.items.forEach(function(item){
|
||||
if(item.type>200){
|
||||
item.number=num;
|
||||
num++;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
moveItem:function(indx,updown){
|
||||
var qitems=this.paper.items;
|
||||
var temp=qitems[indx];
|
||||
if(updown){
|
||||
if(indx>0){
|
||||
Vue.set(qitems, indx, qitems[indx-1]);
|
||||
Vue.set(qitems, indx-1, temp);
|
||||
}
|
||||
}else{
|
||||
if((indx+1)!=qitems.length){
|
||||
Vue.set(qitems, indx, qitems[indx+1]);
|
||||
Vue.set(qitems, indx+1, temp);
|
||||
}
|
||||
}
|
||||
this.resetNumber();
|
||||
},
|
||||
scoreNumChange:function(){
|
||||
var $vue=this;
|
||||
if(this.scoresSelect>1 && this.currentItem!=null && this.currentItem.scores){
|
||||
var len=this.currentItem.scores.length;
|
||||
if(len>this.scoresSelect){
|
||||
this.currentItem.scores.length=this.scoresSelect;
|
||||
}else{
|
||||
for(var i=0;i<(this.scoresSelect-len);i++){
|
||||
$vue.currentItem.scores.push({"title":"","value":1});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
autoSave:function(){
|
||||
//自动保存,就是间隔2分钟保存一次
|
||||
},
|
||||
published:function(){
|
||||
var $vue=this;
|
||||
|
||||
// XUI.Popup.confirm("您确定要发布此问卷吗?发布后不能再修改删除",function(){
|
||||
|
||||
// });
|
||||
},
|
||||
finishSave:function(){
|
||||
var $vue=this;
|
||||
//去掉textOptions
|
||||
if($vue.paper.items){
|
||||
$vue.paper.items.forEach(function(it){
|
||||
delete it.textOptions;
|
||||
});
|
||||
}
|
||||
if($vue.tplInfo.title==""){
|
||||
this.message({message:'标题不能为空',type:'error'});
|
||||
return;
|
||||
}
|
||||
//console.log($vue.paper);
|
||||
$vue.tplInfo.paperJson=JSON.stringify($vue.paper);
|
||||
//保存对象 $vue.tplInfo
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
input.form-control{
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 34px;
|
||||
padding: 6px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 1.42857143;
|
||||
color: #555;
|
||||
background-color: #fff;
|
||||
background-image: none;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
textarea.form-control{
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
padding: 6px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 1.42857143;
|
||||
color: #555;
|
||||
background-color: #fff;
|
||||
background-image: none;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.tp-q{
|
||||
display: block;
|
||||
padding: 10px 0px 10px 10px;
|
||||
margin: 0px 10px 15px 0px;
|
||||
clear: both;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
}
|
||||
.tp-q-opts{
|
||||
padding:10px 0px 0px 0px;
|
||||
}
|
||||
.tp-q-opt{
|
||||
border-bottom: #cccccc dotted 1px;
|
||||
}
|
||||
.tp-q-body{
|
||||
font-weight: bold;
|
||||
border-bottom: #cccccc dotted 1px;
|
||||
}
|
||||
.tp-q-text{
|
||||
font-size:0.875em;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
.tp-table{
|
||||
border: 1px solid #f0f0f0;
|
||||
width: 100%;
|
||||
border-collapse:collapse;
|
||||
/**table-layout: fixed;**/
|
||||
}
|
||||
|
||||
.tp-table .trhead{
|
||||
background: #e5e5e5;
|
||||
font-size: 1.1em;
|
||||
color: #444;
|
||||
|
||||
}
|
||||
.tp-table th{
|
||||
padding: 5px;
|
||||
border:1px solid #cccccc;
|
||||
text-align: center;
|
||||
}
|
||||
.tp-table td{
|
||||
border:1px solid #cccccc;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.tq-table-tdlabel{
|
||||
padding: 4px 0 6px 16px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.tq-table-tdinput{
|
||||
height: 30px;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.tp-choose-text{
|
||||
color: green;
|
||||
font-size: 16px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
/**以下是用于编辑的处理*/
|
||||
.xp-box{}
|
||||
.survey-design{}
|
||||
.btn-edit-finish{margin-top: 10px;}
|
||||
.xp-title{
|
||||
background-color: rgba(255,255,255,0.9);
|
||||
padding: 20px 10px 12px;
|
||||
width: 100%;
|
||||
color: #1ea0fa;
|
||||
}
|
||||
.xp-title-preview{}
|
||||
.xp-title-preview>h1{
|
||||
font-size: 1.5em;
|
||||
line-height: 1.5em;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
.xp-title-edit{}
|
||||
.xp-subtitle{
|
||||
display: block;
|
||||
padding: 10px 0 26px;
|
||||
margin: 0 10px 16px;
|
||||
clear: both;
|
||||
border-bottom: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
.xp-subtitle div.text{
|
||||
font-size: 14px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.xp-q{
|
||||
display: block;
|
||||
padding: 10px 0px 10px 10px;
|
||||
margin: 0px 10px 15px 0px;
|
||||
clear: both;
|
||||
border-bottom: 1px dotted #cccccc;
|
||||
}
|
||||
/**以下是用于试题编辑的页面*/
|
||||
.xq-preview{padding: 10px;}
|
||||
.xq-preview .xq-body{ font-size: 14px; font-weight: bold; margin-bottom: 10px;}
|
||||
.xq-preview:hover{border: 1px solid #fdb553;}
|
||||
.xq-preview>.xq-opts{padding-left: 20px;}
|
||||
.xq-preview>.xq-opts>.xq-opt{}
|
||||
.xq-preview>.xq-opts>.xq-opt>.xq-opt-tag{display: inline-block;width: 50px;}
|
||||
.xq-preview>.xq-opts>.xq-opt>.xq-opt-text{display: inline-block;}
|
||||
|
||||
.xq-edit{}
|
||||
|
||||
/**统计百分比样式*/
|
||||
.percent-bar{
|
||||
width:300px;
|
||||
background-color: #f0f0f0;
|
||||
height: 20px;
|
||||
}
|
||||
.percent-bar-inner{
|
||||
background-color: #1EA0FA; height: 20px; text-align: right;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user