批量录入的修改
组合题的实现
在require-form.js里修改和新增两个组件
fieldlist: function (form) {
//绑定fieldlist
if ($(".fieldlist", form).size() > 0) {
require(['dragsort', 'template'], function (undefined, Template) {
// 引入函数
// Template.defaults.imports.log = console.log;
//刷新隐藏textarea的值
var refresh = function (name) {
// console.log(name);
if(name=='row[selectdata5]'){
// 在这里组装json
var data = {};
var subnum=$('.sub_timu_zong_tihao').length
// console.log(subnum)
var arrfen=[]
var arrzong=[]
for(i=0;i<subnum;i++){
var arrfen_xd=[]
var arrzong_xd=[]
var tixing=$('#tixing-'+i).val()
var tigan=$('#tigan-'+i).val()
var jiexi=$('#jiexi-'+i).val()
for(j=0;j<5;j++){
// 每个小题都push五个
var xuanda=$('#xuanda-'+i+'-'+j).val()
xuanda=JSON.parse(xuanda)
// console.log(xuanda)
arrfen_xd=xuanda
arrzong_xd.push(arrfen_xd)
}
// arrzong_xd=arrzong_xd.slice(i*5,i*5+5)
// console.log(arrzong_xd)
// 每一题都push一个数组。push两次
arrfen=[{'key':'xuanda5','value':arrzong_xd},{'key':'tixing',value:tixing},{'key':'tigan',value:tigan},{'key':'jiexi','value':jiexi}]
arrzong.push(arrfen)
}
// console.log(arrzong);
var textarea = $("textarea[name='row[selectdata5]']", form);
textarea.val(JSON.stringify(arrzong));
}else{
var data = {};
// 这里内容区,texta的数据管辖范围
var container = $(".fieldlist[data-name='" + name + "']");
// 获取管辖范围里定义的模板
var template = container.data("template");
// 目的是,管辖范围内,每个输入的内容,转化成数组
$.each($("input,select,textarea", container).serializeArray(), function (i, j) {
// 这里是定义了name的命名规则
var reg = /[(w+)][(w+)]$/g;
// match是数组把
var match = reg.exec(j.name);
// console.log(j.name)
// console.log(match);
// 如果命名不规则,就跳出循环?
if (!match)
return true;
match[1] = "x" + parseInt(match[1]);
if (typeof data[match[1]] == 'undefined') {
data[match[1]] = {};
}
data[match[1]][match[2]] = j.value;
});
// 这里返回的data是json对象
// console.dir(data);
var result = template ? [] : {};
//根据是否设置了模板,返回最终的kv数据
$.each(data, function (i, j) {
if (j) {
if (!template) {
if (j.key != '') {
result[j.key] = j.value;
}
} else {
result.push(j);
}
}
});
// 定位texta
var textarea = $("textarea[name='" + name + "']", form);
textarea.val(JSON.stringify(result));
}
};
//监听文本框改变事件
$(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () {
refresh($(this).closest(".fieldlist").data("name"));
});
//追加控制
$(".fieldlist", form).on("click", ".btn-append,.append", function (e, row) {
// console.log('开始追加大题')
var container = $(this).closest(".fieldlist");
var tagName = container.data("tag") || "dd";
var index = container.data("index");
var name = container.data("name");
var template = container.data("template");
var data = container.data();
index = index ? parseInt(index) : 0;
container.data("index", index + 1);
row = row ? row : {};
// data是什么,row是什么,artjs中的row的数据源是什么
var vars = {index: index, name: name, data: data, row: row};
// console.log(vars)
var html = template ? Template(template, vars) : Template.render(Form.config.fieldlisttpl, vars);
$(html).insertBefore($(tagName + ":last", container));
$(this).trigger("fa.event.appendfieldlist", $(this).closest(tagName).prev());
});
// 非组合题的移除按钮
$(".fieldlist", form).on("click", ".btn-remove", function () {
var container = $(this).closest(".fieldlist");
var tagName = container.data("tag") || "dd";
$(this).closest(tagName).remove();
refresh(container.data("name"));
});
//组合题题号的移除按钮
$(".fieldlist", form).on("click", ".sub_timu_sum .btn-remove-tihao", function () {
// console.log('移除小题的预览')
// 必须先重置一下各种name
var container = $(this).closest(".fieldlist");
var tagName = container.data("tag") || "dd";
// 移除父级
$(this).closest(tagName).parent('.sub_timu_zong_tihao').remove();
// $(this).closest(tagName).remove();
change_tihao()
// console.log($('.fieldlistsub.fieldlist_sub1').data('name'))
refresh(container.data("name"));
});
// 组合题小题的移除,在下面fieldlistsub了
//渲染数据&拖拽排序
$(".fieldlist", form).each(function () {
var container = this;
var tagName = $(this).data("tag") || "dd";
$(this).dragsort({
itemSelector: tagName,
dragSelector: ".btn-dragsort",
dragEnd: function () {
refresh($(this).closest(".fieldlist").data("name"));
},
placeHolderTemplate: $("<" + tagName + "/>")
});
var textarea = $("textarea[name='" + $(this).data("name") + "']", form);
if (textarea.val() == '') {
return true;
}
var template = $(this).data("template");
var json = {};
try {
json = JSON.parse(textarea.val());
} catch (e) {
}
$.each(json, function (i, j) {
// console.log('准备追加大题')
$(".btn-append,.append", container).trigger('click', template ? j : {
key: i,
value: j
});
});
});
// 指定位置替换函数
function changeStr(str,index,changeStr){
return str.substr(0, index) + changeStr+ str.substr(index + changeStr.length);
}
// 修改页面题号
function change_tihao(){
$('.sub_timu_zong_tihao').each(function(i){
// 修改input的题号
$(this).find('input').each(function(){
var index=$(this).data('pos')
i=i.toString()
if(index){
// console.log(i)
// console.log(index)
var old=$(this).attr('name')
var now=changeStr(old,index,i)
// console.log(now)
$(this).attr('name',now)
}
})
// 修改textarea的题号
$(this).find('textarea').each(function(){
var index=$(this).data('pos')
i=i.toString()
if(index){
// console.log(i)
// console.log(index)
var old=$(this).attr('name')
var now=changeStr(old,index,i)
// console.log(now)
$(this).attr('name',now)
}
})
// 修改id中的题号
$(this).find('*[id]').each(function(){
var index=$(this).data('idpos')
i=i.toString()
if(index){
// console.log(i)
// console.log(index)
var old=$(this).attr('id')
var now=changeStr(old,index,i)
// console.log(now)
$(this).attr('id',now)
}
})
// 修改dl中data-name的tihao
$(this).find('dl').each(function(){
// console.log('修改dl中data-name的tihao')
var index=$(this).data('pos')
i=i.toString()
if(index){
// console.log(i)
// console.log(index)
var old=$(this).attr('data-name')
var now=changeStr(old,index,i)
// console.log(now)
$(this).attr('data-name',now)
}
})
// // 必须触发一下页面的改变事件,最后不需要触发事件,获取最新的data-name就好了,需要用特殊的方法
// $(".fieldlistsub input.neibu").trigger("change");
})
}
function change_bianhao(){
// 渲染完成,开始修改ansewer的name属性
$('.sub_timu_zong_tihao').each(function(i){
$(this).find('input[name*=bianhao]').each(function(){
// 首先获取name的值,对
console.log('正在修改bianhao')
var old=$(this).attr('name')
var now=old.replace('bianhao',i)
$(this).attr('name',now)
})
})
}
});
}
},
fieldlistsub: function (form) {
//绑定fieldlist_sub
if ($(".fieldlistsub", form).size() > 0) {
require(['dragsort', 'template'], function (undefined, Template) {
//刷新隐藏textarea的值
var refresh = function (name) {
console.log('准备刷新sub了')
// console.log(name)
var data = {};
var textarea = $("textarea[name='" + name + "']", form);
// console.log(textarea);
var container = $(".fieldlistsub[data-name='" + name + "']");
// console.log(container);
var template = container.data("template");
$.each($("input.neibu,select.neibu,textarea.neibu", container).serializeArray(), function (i, j) {
var reg = /[(w+)][(w+)]$/g;
var match = reg.exec(j.name);
if (!match)
return true;
match[1] = "x" + parseInt(match[1]);
if (typeof data[match[1]] == 'undefined') {
data[match[1]] = {};
}
data[match[1]][match[2]] = j.value;
});
var result = template ? [] : {};
$.each(data, function (i, j) {
if (j) {
if (!template) {
if (j.key != '') {
result[j.key] = j.value;
}
} else {
result.push(j);
}
}
});
textarea.val(JSON.stringify(result));
};
//监听文本框改变事件,如何获取增加删除后的name呢
$(document).on('change keyup changed', ".fieldlistsub input.neibu,.fieldlistsub textarea.neibu,.fieldlistsub select.neibu", function () {
// 获取动态生成的data数据
var nowdata=$(this).closest(".fieldlistsub")
// console.dir(nowdata)
var shuaxin_name=nowdata[0].dataset.name
// console.dir(shuaxin_name)
change_tihao()
refresh(shuaxin_name);
});
//追加控制--->渲染数据--->最新dom
$('body').on("click", ".btn-append-sub", function (e, row) {
// console.log('开始追加小题选项')
var container = $(this).closest(".fieldlistsub");
// console.dir(container)
var tagName = container.data("tag") || "dd";
// var index = container.data("index");
// console.log(index)
var index=$(this).closest('dl').find('dd').length-1
// console.log(index)
var name = container.data("name");
var template = container.data("template");
var data = container.data();
index = index ? parseInt(index) : 0;
// console.log(index)
container.data("index", index + 1);
row = row ? row : {};
var vars = {index: index, name: name, data: data, row: row};
var html = template ? Template(template, vars) : Template.render(Form.config.fieldlisttpl, vars);
$(html).insertBefore($(tagName + ":last", container));
$(this).trigger("fa.event.appendfieldlist", $(this).closest(tagName).prev());
});
//移除控制
$('body').on("click", ".btn-remove-sub", function () {
console.log('准备移除小题选项')
var container = $(this).closest(".fieldlistsub");
var tagName = container.data("tag") || "dd";
$(this).closest(tagName).remove();
init_tihao()
// refresh(container.data("name"));
var shuaxin_name=container[0].dataset.name
// console.dir(shuaxin_name)
refresh(shuaxin_name);
});
//渲染数据&拖拽排序
$(".fieldlistsub", form).each(function () {
// console.log('准备追加小题')
var container = this;
var tagName = $(this).data("tag") || "dd";
$(this).dragsort({
itemSelector: tagName,
dragSelector: ".btn-dragsort",
dragEnd: function () {
refresh($(this).closest(".fieldlistsub").data("name"));
},
placeHolderTemplate: $("<" + tagName + "/>")
});
var textarea = $("textarea[name='" + $(this).data("name") + "']", form);
// console.log(textarea)
if (textarea.val() == '') {
return true;
}
var template = $(this).data("template");
var json = {};
try {
json = JSON.parse(textarea.val());
} catch (e) {
}
$.each(json, function (i, j) {
console.log('准备追加小题')
$(".btn-append-sub", container).trigger('click', template ? j : {
key: i,
value: j
});
});
});
// 渲染完成,开始修改ansewer的name属性
$('.sub_timu_zong_tihao').each(function(i){
$(this).find('input[name*=bianhao]').each(function(){
// 首先获取name的值,对
console.log('正在修改bianhao')
var old=$(this).attr('name')
var now=old.replace('bianhao',i)
$(this).attr('name',now)
})
})
init_tihao()
// 渲染完成,触发sub的change事件,目的是去掉textdate里的checked
$('.fieldlistsub input.neibu').trigger('change')
// 渲染完成,修改单选的checked
$(document).ready(function(){
$("input[type='radio']").each(function(){
if(typeof($(this).attr("checked"))!=="undefined"){
$(this).click()
}
})
})
function init_tihao(){
// 渲染完成,开始初始化name中的tihao
$('.sub_timu_zong_tihao').each(function(i){
$(this).find('input[name*=tihao]').each(function(){
console.log('正在初始化input中的tihao')
var old=$(this).attr('name')
var now=old.replace('tihao',i)
$(this).attr('name',now)
})
$(this).find('textarea[name*=tihao]').each(function(){
// 首先获取name的值,对
console.log('正在初始化textarea中的tihao')
var old=$(this).attr('name')
var now=old.replace('tihao',i)
$(this).attr('name',now)
})
$(this).find('*[id*=tihao]').each(function(){
// 首先获取name的值
console.log('正在初始化id中的tihao')
var old=$(this).attr('id')
var now=old.replace('tihao',i)
$(this).attr('id',now)
})
$(this).find('dl[data-name*=tihao]').each(function(){
// 首先获取name的值,对
console.log('正在初始化id中的tihao')
var old=$(this).attr('data-name')
var now=old.replace('tihao',i)
$(this).attr('data-name',now)
})
})
}
// 指定位置替换函数
function changeStr(str,index,changeStr){
return str.substr(0, index) + changeStr+ str.substr(index + changeStr.length);
}
// 修改页面题号
function change_tihao(){
$('.sub_timu_zong_tihao').each(function(i){
// 修改input的题号
$(this).find('input').each(function(){
var index=$(this).data('pos')
i=i.toString()
if(index){
// console.log(i)
// console.log(index)
var old=$(this).attr('name')
var now=changeStr(old,index,i)
// console.log(now)
$(this).attr('name',now)
}
})
// 修改textarea的题号
$(this).find('textarea').each(function(){
var index=$(this).data('pos')
i=i.toString()
if(index){
// console.log(i)
// console.log(index)
var old=$(this).attr('name')
var now=changeStr(old,index,i)
// console.log(now)
$(this).attr('name',now)
}
})
// 修改id中的题号
$(this).find('*[id]').each(function(){
var index=$(this).data('idpos')
i=i.toString()
if(index){
// console.log(i)
// console.log(index)
var old=$(this).attr('id')
var now=changeStr(old,index,i)
// console.log(now)
$(this).attr('id',now)
}
})
// 修改dl中data-name的tihao
$(this).find('dl').each(function(){
// console.log('修改dl中data-name的tihao')
var index=$(this).data('pos')
i=i.toString()
if(index){
// console.log(i)
// console.log(index)
var old=$(this).attr('data-name')
var now=changeStr(old,index,i)
// console.log(now)
$(this).attr('data-name',now)
}
})
// // 必须触发一下页面的改变事件,最后不需要触发事件,获取最新的data-name就好了,需要用特殊的方法
// $(".fieldlistsub input.neibu").trigger("change");
// 修改标题的题号信息
$(this).find("input[value='tihao']").each(function(){
var old=$(this).attr('value')
// console.log(old)
i=Number(i)+1
console.log(i)
var now=old.replace('tihao',i)
// console.log(now)
$(this).attr('value',now)
})
// 修改题型为汉字
var tixing_arr=['单选','多选','判断','填空','简答']
var tixing=$(this).find("input[id*=tixing]").val()
tixing=Number(tixing)
// console.log(tixing_arr[tixing])
$(this).find("input[id*=tixing]").attr("value",tixing_arr[tixing])
})
}
function change_bianhao(){
// 渲染完成,开始修改ansewer的name属性
$('.sub_timu_zong_tihao').each(function(i){
$(this).find('input[name*=bianhao]').each(function(){
// 首先获取name的值,对
console.log('正在修改bianhao')
var old=$(this).attr('name')
var now=old.replace('bianhao',i)
$(this).attr('name',now)
})
})
}
// 动态返回不同的模板
var temp=[]
var shengcheng=false
if(!shengcheng){
for(i=0;i<5;i++){
var str=`
<div class="sub_timu_zong_tihao">
<dd class="form-inline sub_timu_sum">
<!--题号 -->
<ins class="col-xs-12 col-sm-1"><input type="text" class="form-control neibu subnum" name="row[sub_item][0]" data-pos="14" value="tihao"></ins>
<!--题型-->
<ins class="col-xs-12 col-sm-1 hidden"><input type="text" class="form-control neibu hidden" name="row[selectdata5][0][1][key]" data-pos="17" value="tixing"></ins>
<ins class="col-xs-12 col-sm-1"><input type="text" class="form-control neibu" id="tixing-0" data-idpos="7" name="row[selectdata5][0][${i}][value]" data-pos="17" value=${i}></ins>
<!--题干-->
<ins class="col-xs-12 col-sm-8 hidden"><input type="text" name="row[selectdata5][0][2][key]" data-pos="17" class="form-control neibu hidden" placeholder="" value="tigan"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][2][value]" data-pos="17" class="form-control neibu" placeholder="" value="题干--只读---默认不填" readonly></ins>
<span class="btn btn-sm btn-danger btn-remove-tihao"><i class="fa fa-times"></i></span>
<span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
</dd>
<!--小提的具体信息-->
<dd class="sub_timu sub_timu_detail col-xs-12 col-sm-10"">
<div class="form-group">
<label for="tigan-tihao" class="control-label col-xs-12 col-sm-2">题干:</label>
<div class="col-xs-12 col-sm-9">
<input class="form-control neibu hidden" name="row[selectdata5][0][2][key]" data-pos="17" type="text" value="tigan">
<input id="tigan-0" data-idpos="6" class="form-control neibu myeditor" name="row[selectdata5][0][2][value]" data-pos="17" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">选答:</label>
<div class="col-xs-12 col-sm-9">
<!-- 判断当前的题型,进行展示 -->
<dl data-template="sub_answer0" class="fieldlistsub fieldlist_sub0 ${ i==0?'': 'hidden'} " data-name="row[selectdata5][0][0][value]" data-pos="17" data-listidx="0">
<dd class="form-inline row">
<ins class="col-xs-12 col-sm-1"><input type="radio" name="row[answer5][0][0]" data-pos="13" value="A"></ins>
<ins class="col-xs-12 col-sm-2"><input name="row[selectdata5][0][0][value][0][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="A"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][0][value][0][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove-sub"><i class="fa fa-times"></i></span>
</dd><dd class="form-inline row">
<ins class="col-xs-12 col-sm-1"><input type="radio" name="row[answer5][0][0]" data-pos="13" value="B"></ins>
<ins class="col-xs-12 col-sm-2"><input name="row[selectdata5][0][0][value][1][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="B"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][0][value][1][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove-sub"><i class="fa fa-times"></i></span>
</dd><dd class="form-inline row">
<ins class="col-xs-12 col-sm-1"><input type="radio" name="row[answer5][0][0]" data-pos="13" value="C"></ins>
<ins class="col-xs-12 col-sm-2"><input name="row[selectdata5][0][0][value][2][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="C"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][0][value][2][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove-sub"><i class="fa fa-times"></i></span>
</dd><dd class="form-inline row">
<ins class="col-xs-12 col-sm-1"><input type="radio" name="row[answer5][0][0]" data-pos="13" value="D"></ins>
<ins class="col-xs-12 col-sm-2"><input name="row[selectdata5][0][0][value][3][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="D"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][0][value][3][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove-sub"><i class="fa fa-times"></i></span>
</dd><dd><a href="javascript:;" class="btn btn-sm btn-success btn-append-sub"><i class="fa fa-plus"></i> 追加</a></dd>
<textarea name="row[selectdata5][0][0][key]" data-pos="17" class="form-control hidden" cols="30" rows="5" value="xuanda5">xuanda5</textarea>
<textarea name="row[selectdata5][0][0][value]" data-pos="17" id="xuanda-0-0" data-idpos="7" class="form-control hidden" cols="30" rows="5">[{"key":"A","value":""},{"key":"B","value":""},{"key":"C","value":""},{"key":"D","value":""}]</textarea>
</dl>
<!-- 判断当前的题型,进行展示 -->
<dl data-template="sub_answer1" class="fieldlistsub fieldlist_sub1 ${ i==1?'': 'hidden'}" data-name="row[selectdata5][0][1][value]" data-pos="17" data-listidx="0">
<dd class="form-inline">
<ins class="col-xs-12 col-sm-1"><input type="checkbox" name="row[answer5][0][1][]" data-pos="13" value="A"></ins>
<ins class="col-xs-12 col-sm-2"><input name="row[selectdata5][0][1][value][0][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="A"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][1][value][0][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove-sub"><i class="fa fa-times"></i></span>
</dd><dd class="form-inline">
<ins class="col-xs-12 col-sm-1"><input type="checkbox" name="row[answer5][0][1][]" data-pos="13" value="B"></ins>
<ins class="col-xs-12 col-sm-2"><input name="row[selectdata5][0][1][value][1][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="B"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][1][value][1][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove-sub"><i class="fa fa-times"></i></span>
</dd><dd class="form-inline">
<ins class="col-xs-12 col-sm-1"><input type="checkbox" name="row[answer5][0][1][]" data-pos="13" value="C"></ins>
<ins class="col-xs-12 col-sm-2"><input name="row[selectdata5][0][1][value][2][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="C"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][1][value][2][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove-sub"><i class="fa fa-times"></i></span>
</dd><dd class="form-inline">
<ins class="col-xs-12 col-sm-1"><input type="checkbox" name="row[answer5][0][1][]" data-pos="13" value="D" ></ins>
<ins class="col-xs-12 col-sm-2"><input name="row[selectdata5][0][1][value][3][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="D"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][1][value][3][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove-sub"><i class="fa fa-times"></i></span>
</dd><dd><a href="javascript:;" class="btn btn-sm btn-success btn-append-sub"><i class="fa fa-plus"></i> 追加</a></dd>
<textarea name="row[selectdata5][0][1][key]" data-pos="17" class="form-control hidden" cols="30" rows="5" value="xuanda5">xuanda5</textarea>
<textarea name="row[selectdata5][0][1][value]" data-pos="17" id="xuanda-0-1" data-idpos="7" class="form-control hidden" cols="30" rows="5">[{"key":"A","value":"","checked":""},{"key":"B","value":"","checked":""},{"key":"C","value":"","checked":""},{"key":"D","value":"","checked":""}]</textarea>
</dl>
<!-- 判断当前的题型,进行展示 -->
<dl data-template="sub_answer2" class="fieldlistsub fieldlist_sub2 ${ i==2?'': 'hidden'} " data-name="row[selectdata5][0][2][value]" data-pos="17" data-listidx="0">
<!--关于checked展示-->
<dd class="form-inline">
<ins class="col-xs-12 col-sm-1"><input type="radio" name="row[answer5][0][2]" data-pos="13" value="A"></ins>
<ins><input type="text" name="row[selectdata5][0][2][0][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="A" readonly=""></ins>
<ins><input type="text" name="row[selectdata5][0][2][0][value]" data-pos="17" class="form-control neibu" placeholder="" value="对" readonly=""></ins>
<!--下面的两个按钮务必保留-->
</dd>
<!--关于checked展示-->
<dd class="form-inline">
<ins class="col-xs-12 col-sm-1"><input type="radio" name="row[answer5][0][2]" data-pos="13" value="B"></ins>
<ins><input type="text" name="row[selectdata5][0][2][1][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="B" readonly=""></ins>
<ins><input type="text" name="row[selectdata5][0][2][1][value]" data-pos="17" class="form-control neibu" placeholder="" value="错" readonly=""></ins>
<!--下面的两个按钮务必保留-->
</dd>
<textarea name="row[selectdata5][0][2][key]" data-pos="17" class="form-control hidden" cols="30" rows="5" value="xuanda5">xuanda5</textarea>
<textarea name="row[selectdata5][0][2][value]" data-pos="17" id="xuanda-0-2" data-idpos="7" class="form-control hidden" cols="30" rows="5">[{"key":"A","value":"对"},{"key":"B","value":"错"}]</textarea>
</dl>
<!-- 判断当前的题型,进行展示 -->
<dl data-template="sub_answer3" class="fieldlistsub fieldlist_sub3 ${ i==3?'': 'hidden'} " data-name="row[selectdata5][0][3][value]" data-pos="17" data-listidx="0">
<dd class="form-inline">
<ins class="col-xs-12 col-sm-1 hidden"><input type="checkbox" name="row[answer5][0][3][]" data-pos="13" value="1" checked=""></ins>
<ins class="col-xs-12 col-sm-1"><input type="text" name="row[selectdata5][0][3][value][0][key]" data-pos="17" class="form-control neibu" placeholder="空格编号" size="10" value="1"></ins>
<ins class="col-xs-12 col-sm-8"><input type="text" name="row[selectdata5][0][3][value][0][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove-sub"><i class="fa fa-times"></i></span>
</dd><dd><a href="javascript:;" class="btn btn-sm btn-success btn-append-sub"><i class="fa fa-plus"></i> 追加</a></dd>
<textarea name="row[selectdata5][0][3][key]" data-pos="17" class="form-control hidden" cols="30" rows="5" value="xuanda5">xuanda5</textarea>
<textarea name="row[selectdata5][0][3][value]" data-pos="17" id="xuanda-0-3" data-idpos="7" class="form-control hidden" cols="30" rows="5">[{"key":"1","value":""}]</textarea>
</dl>
<!-- 判断当前的题型,进行展示 -->
<dl data-template="sub_answer4" class="fieldlistsub fieldlist_sub4 ${ i==4?'': 'hidden'} " data-name="row[selectdata5][0][4][value]" data-pos="17" data-listidx="0">
<dd class="form-inline">
<ins class="hidden"><input type="checkbox" name="row[answer5][0][4][]" data-pos="13" value="1" checked=""></ins>
<ins class="col-xs-12 col-sm-1"><input type="text" name="row[selectdata5][0][4][value][0][key]" data-pos="17" class="form-control neibu" placeholder="选项" size="10" value="1"></ins>
<ins class="col-xs-12 col-sm-10"><input type="text" name="row[selectdata5][0][4][value][0][value]" data-pos="17" class="form-control myeditor neibu" placeholder="" value=""></ins>
</dd><dd><a href="javascript:;" class="btn btn-sm btn-success btn-append-sub"><i class="fa fa-plus"></i> 追加</a></dd>
<textarea name="row[selectdata5][0][4][key]" data-pos="17" class="form-control hidden" cols="30" rows="5" value="xuanda5">xuanda5</textarea>
<textarea name="row[selectdata5][0][4][value]" data-pos="17" id="xuanda-0-4" data-idpos="7" class="form-control hidden" cols="30" rows="5">[{"key":"1","value":""}]</textarea>
</dl>
</div>
</div>
<div class="form-group">
<label for="jiexi-tihao" class="control-label col-xs-12 col-sm-2">解析:</label>
<div class="col-xs-12 col-sm-9">
<!-- <input id="c-jiexi-sub0" data-rule="" class="form-control myeditor neibu" name="" rows="15" value=""></input> -->
<input data-rule="" class="form-control neibu hidden" name="row[selectdata5][0][3][key]" data-pos="17" type="text" value="jiexi">
<input id="jiexi-0" data-idpos="6" data-rule="" class="form-control neibu myeditor" name="row[selectdata5][0][3][value]" data-pos="17" type="text" value="">
</div>
</div>
</dd>
</div>
<div style="clear:both"></div>
`
temp[i]=str
}
shengcheng=true
}
// console.log(temp)
$('body').on('click','.add-danxuan',function(){
// console.log('添加单选。。。。。')
$('.zuhe_zhuijia').before(temp[0])
change_tihao()
// 渲染完成,触发sub的change事件,目的是去掉textdate里的checked
$('.fieldlistsub input.neibu').trigger('change')
})
$('body').on('click','.add-duoxuan',function(){
// console.log('添加单选。。。。。')
$('.zuhe_zhuijia').before(temp[1])
change_tihao()
// 渲染完成,触发sub的change事件,目的是去掉textdate里的checked
$('.fieldlistsub input.neibu').trigger('change')
})
$('body').on('click','.add-panduan',function(){
// console.log('添加单选。。。。。')
$('.zuhe_zhuijia').before(temp[2])
change_tihao()
// 渲染完成,触发sub的change事件,目的是去掉textdate里的checked
$('.fieldlistsub input.neibu').trigger('change')
})
$('body').on('click','.add-tiankong',function(){
// console.log('添加单选。。。。。')
$('.zuhe_zhuijia').before(temp[3])
change_tihao()
// 渲染完成,触发sub的change事件,目的是去掉textdate里的checked
$('.fieldlistsub input.neibu').trigger('change')
})
$('body').on('click','.add-jianda',function(){
// console.log('添加单选。。。。。')
$('.zuhe_zhuijia').before(temp[4])
change_tihao()
// 渲染完成,触发sub的change事件,目的是去掉textdate里的checked
$('.fieldlistsub input.neibu').trigger('change')
})
});
}
},