";
}
}
if(nextLi!=null){
if(prevLi[0]){
$(nextLi).after(nextLiAfterHtml);
prevLi.hide();
prevLi.remove();
var editOffset=nextLi.find("label.editAble").offset();
$("#dwCommonEditRoot").show();
$("#dwCommonEditRoot").offset({top:editOffset.top,left:editOffset.left});
bindQuHoverItem();
$(curEditObj).click();
$(nextLi).find("input[name='quItemSaveTag']").val(0);
$(nextLi).next().find("input[name='quItemSaveTag']").val(0);
var quItemBody=$(curEditObj).parents(".surveyQuItemBody");
quItemBody.find("input[name='saveTag']").val(0);
}else{
alert("已经是第一个了!");
}
}
}
return false;
});
function dwOptionUp(prevTd,nextTd){
var prevTdHtml=prevTd.html();
$(nextTd).after("
"+prevTdHtml+"
");
prevTd.hide();
prevTd.remove();
var editOffset=nextTd.find("label.editAble").offset();
$("#dwCommonEditRoot").show();
$("#dwCommonEditRoot").offset({top:editOffset.top,left:editOffset.left});
bindQuHoverItem();
$(curEditObj).click();
$(nextTd).find("input[name='quItemSaveTag']").val(0);
$(nextTd).next().find("input[name='quItemSaveTag']").val(0);
var quItemBody=$(curEditObj).parents(".surveyQuItemBody");
quItemBody.find("input[name='saveTag']").val(0);
}
function dwOptionUp_1(prevTr,nextTr){
var prevTd=prevTr.find("td").last();
var nextTd=nextTr.find("td").first();
var prevTdHtml=prevTd.html();
var nextTdHtml=nextTd.html();
prevTd.before("
"+nextTdHtml+"
");
$(nextTd).after("
"+prevTdHtml+"
");
prevTd.hide();
prevTd.remove();
nextTd.hide();
nextTd.remove();
prevTd=prevTr.find("td").last();
nextTd=nextTr.find("td").first();
curEditObj=prevTd.find("label.editAble");
var editOffset=prevTd.find("label.editAble").offset();
$("#dwCommonEditRoot").show();
$("#dwCommonEditRoot").offset({top:editOffset.top,left:editOffset.left});
bindQuHoverItem();
$(curEditObj).click();
$(prevTd).find("input[name='quItemSaveTag']").val(0);
$(nextTd).find("input[name='quItemSaveTag']").val(0);
var quItemBody=$(curEditObj).parents(".surveyQuItemBody");
quItemBody.find("input[name='saveTag']").val(0);
}
$(".dwOptionDown").unbind();
$(".dwOptionDown").click(function(){
//判断类型区别table跟ul中的排序
var quItemBody=$(curEditObj).parents(".surveyQuItemBody");
var quType=quItemBody.find("input[name='quType']").val();
var hv=quItemBody.find("input[name='hv']").val();
if(hv==3){
var prevTd=$(curEditObj).parents("td");
var nextTd=prevTd.next();
if(nextTd[0]){
dwOptionDown(prevTd, nextTd);
}else{
var nextTr=$(curEditObj).parents("tr");
var prevTr=nextTr.prev();
if(prevTr[0]){
prevTd=prevTr.find("td").last();
dwOptionUp_1(prevTr, nextTr);
}else{
alert("已经是第一个了!");
}
}
}else{
var prevLi=null;
var nextLi=null;
var prevLiBeforeHtml="";
if(quType==="RADIO" || quType==="CHECKBOX" || quType==="ORDERQU"){
prevLi=$(curEditObj).parents("li.quCoItemUlLi");
nextLi=prevLi.next();
var nextLiHtml=nextLi.html();
prevLiBeforeHtml="
"+nextLiHtml+"
";
}else if(quType==="SCORE"){
prevLi=$(curEditObj).parents("tr.quScoreOptionTr");
nextLi=prevLi.next();
var nextLiHtml=nextLi.html();
prevLiBeforeHtml="
"+nextLiHtml+"
";
}else if(quType==="MULTIFILLBLANK"){
prevLi=$(curEditObj).parents("tr.mFillblankTableTr");
nextLi=prevLi.next();
var nextLiHtml=nextLi.html();
prevLiBeforeHtml="
");
}
}
});
quItemBody.find("input[name='saveTag']").val(0);
newEditObj=quCoChenTable.find("tr:first .editAble:last");
newEditObj.text(itemText);
if(itemText==""){
newEditObj.css("display","inline");
}
return newEditObj;
}
//添加矩阵单选题行选项
function addChenRowItem(quItemBody,itemText){
//得判断是否是table类型
var newEditObj=null;
//ul li处理
var quChenRowHtml=$("#quChenRowModel").html();
var quCoChenTable=quItemBody.find("table.quCoChenTable");
var quCoChenTableTds=quCoChenTable.find("tr:first td");
var quType=quItemBody.find("input[name='quType']").val();
var appendTrHtml="
");
quItemBody.find("input[name='saveTag']").val(0);
var scoreNumTableTr = quCoItemTable.find("tr.quScoreOptionTr:last .scoreNumTable tr");
var paramInt02 = quItemBody.find("input[name='paramInt02']").val();
scoreNumTableTr.empty();
for(var i = 1; i <= paramInt02; i++) {
scoreNumTableTr.append("
" + i + "
");
}
quCoItemTable.find("tr.quScoreOptionTr:last input[name='quItemSaveTag']").val(0);
newEditObj = quCoItemTable.find("tr.quScoreOptionTr:last .editAble");
newEditObj.text(itemText);
if(itemText == "") {
newEditObj.css("display", "inline");
}
return newEditObj;
}
/** 删除评分Score选项 **/
function deleteScoreOption() {
var optionParent = null;
optionParent = $(curEditObj).parents("tr.quScoreOptionTr");
var quOptionId = $(optionParent).find("input[name='quItemId']").val();
if(quOptionId != "" && quOptionId != "0") {
var url = reqBasePath + "/design/qu-score!ajaxDelete.action";
var data = "quItemId=" + quOptionId;
$.ajax({
url: url,
data: data,
type: "post",
success: function(msg) {
if(msg == "true") {
delQuOptionCallBack(optionParent);
}
}
});
} else {
delQuOptionCallBack(optionParent);
}
}
//*****排序题****//
/**
** 新保存排序题
**/
function saveOrderqu(quItemBody, callback) {
var saveTag = quItemBody.find("input[name='saveTag']").val();
if(saveTag == 0) {
var url = reqBasePath + "/design/qu-orderqu!ajaxSave.action";
var quType = quItemBody.find("input[name='quType']").val();
var quId = quItemBody.find("input[name='quId']").val();
var orderById = quItemBody.find("input[name='orderById']").val();
var isRequired = quItemBody.find("input[name='isRequired']").val();
var hv = quItemBody.find("input[name='hv']").val();
var randOrder = quItemBody.find("input[name='randOrder']").val();
var cellCount = quItemBody.find("input[name='cellCount']").val();
var data = "belongId=" + questionBelongId + "&orderById=" + orderById + "&tag=" + svTag + "&quType=" + quType + "&quId=" + quId;
data += "&isRequired=" + isRequired + "&hv=" + hv + "&randOrder=" + randOrder + "&cellCount=" + cellCount;
var quTitleSaveTag = quItemBody.find("input[name='quTitleSaveTag']").val();
if(quTitleSaveTag == 0) {
var quTitle = quItemBody.find(".quCoTitleEdit").html();
quTitle = escape(encodeURIComponent(quTitle));
data += "&quTitle=" + quTitle;
}
//评分题选项td
var quItemOptions = quItemBody.find(".quCoItem .quOrderByLeft li.quCoItemUlLi");
$.each(quItemOptions, function(i) {
var optionValue = $(this).find("label.quCoOptionEdit").html();
var optionId = $(this).find(".quItemInputCase input[name='quItemId']").val();
var quItemSaveTag = $(this).find(".quItemInputCase input[name='quItemSaveTag']").val();
if(quItemSaveTag == 0) {
optionValue = escape(encodeURIComponent(optionValue));
data += "&optionValue_" + i + "=" + optionValue;
data += "&optionId_" + i + "=" + optionId;
}
//更新 字母 title标记到选项上.
$(this).addClass("quOption_" + i);
});
//逻辑选项
var quLogicItems = quItemBody.find(".quLogicItem");
$.each(quLogicItems, function(i) {
var thClass = $(this).attr("class");
thClass = thClass.replace("quLogicItem quLogicItem_", "");
var quLogicId = $(this).find("input[name='quLogicId']").val();
var cgQuItemId = $(this).find("input[name='cgQuItemId']").val();
var skQuId = $(this).find("input[name='skQuId']").val();
var logicSaveTag = $(this).find("input[name='logicSaveTag']").val();
var visibility = $(this).find("input[name='visibility']").val();
var logicType = $(this).find("input[name='logicType']").val();
var itemIndex = thClass;
if(logicSaveTag == 0) {
data += "&quLogicId_" + itemIndex + "=" + quLogicId;
data += "&cgQuItemId_" + itemIndex + "=" + cgQuItemId;
data += "&skQuId_" + itemIndex + "=" + skQuId;
data += "&visibility_" + itemIndex + "=" + visibility;
data += "&logicType_" + itemIndex + "=" + logicType;
}
});
$.ajax({
url: url,
data: data,
type: 'post',
success: function(msg) {
if(msg != "error") {
var jsons = eval("(" + msg + ")");
var quId = jsons.id;
quItemBody.find("input[name='quId']").val(quId);
var quItems = jsons.quItems;
$.each(quItems, function(i, item) {
var quItemOption = quItemBody.find(".quOption_" + item.title);
quItemOption.find("input[name='quItemId']").val(item.id);
quItemOption.find(".quItemInputCase input[name='quItemSaveTag']").val(1);
});
//同步logic Id信息
var quLogics = jsons.quLogics;
$.each(quLogics, function(i, item) {
var logicItem = quItemBody.find(".quLogicItem_" + item.title);
logicItem.find("input[name='quLogicId']").val(item.id);
logicItem.find("input[name='logicSaveTag']").val(1);
});
quItemBody.find("input[name='saveTag']").val(1);
quItemBody.find(".quCoTitle input[name='quTitleSaveTag']").val(1);
//执行保存下一题
saveQus(quItemBody.next(), callback);
//同步-更新题目排序号
quCBNum2++;
exeQuCBNum();
}
}
});
} else {
saveQus(quItemBody.next(), callback);
}
}
/** 添加选项 **/
/** 添加排序项 **/
function addOrderquItem(quItemBody, itemText) {
//得判断是否是table类型
var newEditObj = null;
//ul li处理
var quOrderItemLeftHtml = $("#quOrderItemLeftModel").html();
var quOrderItemRightHtml = $("#quOrderItemRightModel").html();
var quOrderItemLeftUl = quItemBody.find(".quOrderByLeft ul");
var quOrderByRightTable = quItemBody.find(".quOrderByRight table.quOrderByTable");
quOrderItemLeftUl.append("
" + quOrderItemLeftHtml + "
");
quOrderByRightTable.append("
" + quOrderItemRightHtml + "
");
quItemBody.find("input[name='saveTag']").val(0);
newEditObj = quOrderItemLeftUl.find("li:last .editAble");
newEditObj.text(itemText);
if(itemText == "") {
newEditObj.css("display", "inline");
}
//quOrderyTableTd
refquOrderTableTdNum(quOrderByRightTable);
return newEditObj;
}
function refquOrderTableTdNum(quOrderByRightTable) {
var quOrderyTableTds = quOrderByRightTable.find(".quOrderyTableTd");
$.each(quOrderyTableTds, function(i) {
$(this).text(i + 1);
});
}
/** 删除排序选项 **/
function deleteOrderquOption() {
var optionParent = null;
optionParent = $(curEditObj).parents("li.quCoItemUlLi");
var quItemBody = $(curEditObj).parents(".surveyQuItemBody");
var rmQuOrderTableTr = quItemBody.find(".quOrderByRight table.quOrderByTable tr:last");
var quOptionId = $(optionParent).find("input[name='quItemId']").val();
if(quOptionId != "" && quOptionId != "0") {
var url = reqBasePath + "/design/qu-orderqu!ajaxDelete.action";
var data = "quItemId=" + quOptionId;
$.ajax({
url: url,
data: data,
type: "post",
success: function(msg) {
if(msg == "true") {
delQuOptionCallBack(optionParent);
rmQuOrderTableTr.remove();
}
}
});
} else {
delQuOptionCallBack(optionParent);
rmQuOrderTableTr.remove();
}
}
//*******分页标记*******//
/**
** 新保存分页标记
**/
function savePagetag(quItemBody, callback) {
var saveTag = quItemBody.find("input[name='saveTag']").val();
if(saveTag == 0) {
var url = reqBasePath + "/design/qu-pagetag!ajaxSave.action";
var quType = quItemBody.find("input[name='quType']").val();
var quId = quItemBody.find("input[name='quId']").val();
var orderById = quItemBody.find("input[name='orderById']").val();;
var isRequired = quItemBody.find("input[name='isRequired']").val();
var hv = quItemBody.find("input[name='hv']").val();
var randOrder = quItemBody.find("input[name='randOrder']").val();
var cellCount = quItemBody.find("input[name='cellCount']").val();
var data = "belongId=" + questionBelongId + "&orderById=" + orderById + "&tag=" + svTag + "&quType=" + quType + "&quId=" + quId;
data += "&isRequired=" + isRequired + "&hv=" + hv + "&randOrder=" + randOrder + "&cellCount=" + cellCount;
var quTitleSaveTag = quItemBody.find("input[name='quTitleSaveTag']").val();
if(quTitleSaveTag == 0) {
var quTitle = quItemBody.find(".quCoTitleEdit").html();
quTitle = escape(encodeURIComponent(quTitle));
data += "&quTitle=" + quTitle;
}
//逻辑选项
var quLogicItems = quItemBody.find(".quLogicItem");
$.each(quLogicItems, function(i) {
var thClass = $(this).attr("class");
thClass = thClass.replace("quLogicItem quLogicItem_", "");
var quLogicId = $(this).find("input[name='quLogicId']").val();
var cgQuItemId = $(this).find("input[name='cgQuItemId']").val();
var skQuId = $(this).find("input[name='skQuId']").val();
var logicSaveTag = $(this).find("input[name='logicSaveTag']").val();
var visibility = $(this).find("input[name='visibility']").val();
var logicType = $(this).find("input[name='logicType']").val();
var itemIndex = thClass;
if(logicSaveTag == 0) {
data += "&quLogicId_" + itemIndex + "=" + quLogicId;
data += "&cgQuItemId_" + itemIndex + "=" + cgQuItemId;
data += "&skQuId_" + itemIndex + "=" + skQuId;
data += "&visibility_" + itemIndex + "=" + visibility;
data += "&logicType_" + itemIndex + "=" + logicType;
}
});
$.ajax({
url: url,
data: data,
type: 'post',
success: function(msg) {
if(msg != "error") {
var jsons = eval("(" + msg + ")");
var quId = jsons.id;
quItemBody.find("input[name='quId']").val(quId);
//同步logic Id信息
var quLogics = jsons.quLogics;
$.each(quLogics, function(i, item) {
var logicItem = quItemBody.find(".quLogicItem_" + item.title);
logicItem.find("input[name='quLogicId']").val(item.id);
logicItem.find("input[name='logicSaveTag']").val(1);
});
quItemBody.find("input[name='saveTag']").val(1);
quItemBody.find(".quCoTitle input[name='quTitleSaveTag']").val(1);
//执行保存下一题
saveQus(quItemBody.next(), callback);
//同步-更新题目排序号
quCBNum2++;
exeQuCBNum();
}
}
});
} else {
saveQus(quItemBody.next(), callback);
}
}
//*******段落说明题*******//
/**
** 新保存段落题
**/
function saveParagraph(quItemBody, callback) {
var saveTag = quItemBody.find("input[name='saveTag']").val();
if(saveTag == 0) {
var url = reqBasePath + "/design/qu-paragraph!ajaxSave.action";
var quType = quItemBody.find("input[name='quType']").val();
var quId = quItemBody.find("input[name='quId']").val();
var orderById = quItemBody.find("input[name='orderById']").val();;
var isRequired = quItemBody.find("input[name='isRequired']").val();
var hv = quItemBody.find("input[name='hv']").val();
var randOrder = quItemBody.find("input[name='randOrder']").val();
var cellCount = quItemBody.find("input[name='cellCount']").val();
var data = "belongId=" + questionBelongId + "&orderById=" + orderById + "&tag=" + svTag + "&quType=" + quType + "&quId=" + quId;
data += "&isRequired=" + isRequired + "&hv=" + hv + "&randOrder=" + randOrder + "&cellCount=" + cellCount;
var quTitleSaveTag = quItemBody.find("input[name='quTitleSaveTag']").val();
if(quTitleSaveTag == 0) {
var quTitle = quItemBody.find(".quCoTitleEdit").html();
quTitle = escape(encodeURIComponent(quTitle));
data += "&quTitle=" + quTitle;
}
//逻辑选项
var quLogicItems = quItemBody.find(".quLogicItem");
$.each(quLogicItems, function(i) {
var thClass = $(this).attr("class");
thClass = thClass.replace("quLogicItem quLogicItem_", "");
var quLogicId = $(this).find("input[name='quLogicId']").val();
var cgQuItemId = $(this).find("input[name='cgQuItemId']").val();
var skQuId = $(this).find("input[name='skQuId']").val();
var logicSaveTag = $(this).find("input[name='logicSaveTag']").val();
var visibility = $(this).find("input[name='visibility']").val();
var logicType = $(this).find("input[name='logicType']").val();
var itemIndex = thClass;
if(logicSaveTag == 0) {
data += "&quLogicId_" + itemIndex + "=" + quLogicId;
data += "&cgQuItemId_" + itemIndex + "=" + cgQuItemId;
data += "&skQuId_" + itemIndex + "=" + skQuId;
data += "&visibility_" + itemIndex + "=" + visibility;
data += "&logicType_" + itemIndex + "=" + logicType;
}
});
$.ajax({
url: url,
data: data,
type: 'post',
success: function(msg) {
//alert(msg);// resultJson quItemId
if(msg != "error") {
var jsons = eval("(" + msg + ")");
//alert(jsons);
var quId = jsons.id;
quItemBody.find("input[name='quId']").val(quId);
//同步logic Id信息
var quLogics = jsons.quLogics;
$.each(quLogics, function(i, item) {
var logicItem = quItemBody.find(".quLogicItem_" + item.title);
logicItem.find("input[name='quLogicId']").val(item.id);
logicItem.find("input[name='logicSaveTag']").val(1);
});
quItemBody.find("input[name='saveTag']").val(1);
quItemBody.find(".quCoTitle input[name='quTitleSaveTag']").val(1);
//执行保存下一题
saveQus(quItemBody.next(), callback);
//同步-更新题目排序号
quCBNum2++;
exeQuCBNum();
}
}
});
} else {
saveQus(quItemBody.next(), callback);
}
}
/** 多项填空题 **/
/**
** 新保存多项填空题
**/
function saveMultiFillblank(quItemBody, callback) {
var saveTag = quItemBody.find("input[name='saveTag']").val();
if(saveTag == 0) {
var url = reqBasePath + "/design/qu-multi-fillblank!ajaxSave.action";
var quType = quItemBody.find("input[name='quType']").val();
var quId = quItemBody.find("input[name='quId']").val();
var orderById = quItemBody.find("input[name='orderById']").val();
var isRequired = quItemBody.find("input[name='isRequired']").val();
var hv = quItemBody.find("input[name='hv']").val();
var randOrder = quItemBody.find("input[name='randOrder']").val();
var cellCount = quItemBody.find("input[name='cellCount']").val();
var paramInt01 = quItemBody.find("input[name='paramInt01']").val();
var paramInt02 = quItemBody.find("input[name='paramInt02']").val();
var data = "belongId=" + questionBelongId + "&orderById=" + orderById + "&tag=" + svTag + "&quType=" + quType + "&quId=" + quId;
data += "&isRequired=" + isRequired + "&hv=" + hv + "&randOrder=" + randOrder + "&cellCount=" + cellCount;
data += "¶mInt01=" + paramInt01 + "¶mInt02=" + paramInt02;
var quTitleSaveTag = quItemBody.find("input[name='quTitleSaveTag']").val();
if(quTitleSaveTag == 0) {
var quTitle = quItemBody.find(".quCoTitleEdit").html();
quTitle = escape(encodeURIComponent(quTitle));
data += "&quTitle=" + quTitle;
}
//评分题选项td
var quItemOptions = quItemBody.find(".quCoItem table.mFillblankTable tr td.mFillblankTableEditTd");
$.each(quItemOptions, function(i) {
var optionValue = $(this).find("label.quCoOptionEdit").html();
var optionId = $(this).find(".quItemInputCase input[name='quItemId']").val();
var quItemSaveTag = $(this).find(".quItemInputCase input[name='quItemSaveTag']").val();
if(quItemSaveTag == 0) {
optionValue = escape(encodeURIComponent(optionValue));
data += "&optionValue_" + i + "=" + optionValue;
data += "&optionId_" + i + "=" + optionId;
}
//更新 字母 title标记到选项上.
$(this).addClass("quOption_" + i);
});
//逻辑选项
var quLogicItems = quItemBody.find(".quLogicItem");
$.each(quLogicItems, function(i) {
var thClass = $(this).attr("class");
thClass = thClass.replace("quLogicItem quLogicItem_", "");
var quLogicId = $(this).find("input[name='quLogicId']").val();
var cgQuItemId = $(this).find("input[name='cgQuItemId']").val();
var skQuId = $(this).find("input[name='skQuId']").val();
var logicSaveTag = $(this).find("input[name='logicSaveTag']").val();
var visibility = $(this).find("input[name='visibility']").val();
var logicType = $(this).find("input[name='logicType']").val();
var itemIndex = thClass;
if(logicSaveTag == 0) {
data += "&quLogicId_" + itemIndex + "=" + quLogicId;
data += "&cgQuItemId_" + itemIndex + "=" + cgQuItemId;
data += "&skQuId_" + itemIndex + "=" + skQuId;
data += "&visibility_" + itemIndex + "=" + visibility;
data += "&logicType_" + itemIndex + "=" + logicType;
}
});
$.ajax({
url: url,
data: data,
type: 'post',
success: function(msg) {
if(msg != "error") {
var jsons = eval("(" + msg + ")");
var quId = jsons.id;
quItemBody.find("input[name='quId']").val(quId);
var quItems = jsons.quItems;
$.each(quItems, function(i, item) {
var quItemOption = quItemBody.find(".quOption_" + item.title);
quItemOption.find("input[name='quItemId']").val(item.id);
quItemOption.find(".quItemInputCase input[name='quItemSaveTag']").val(1);
});
//同步logic Id信息
var quLogics = jsons.quLogics;
$.each(quLogics, function(i, item) {
var logicItem = quItemBody.find(".quLogicItem_" + item.title);
logicItem.find("input[name='quLogicId']").val(item.id);
logicItem.find("input[name='logicSaveTag']").val(1);
});
quItemBody.find("input[name='saveTag']").val(1);
quItemBody.find(".quCoTitle input[name='quTitleSaveTag']").val(1);
//执行保存下一题
saveQus(quItemBody.next(), callback);
//同步-更新题目排序号
quCBNum2++;
exeQuCBNum();
}
}
});
} else {
saveQus(quItemBody.next(), callback);
}
}
/** 添加选项 **/
/** 添加多项填空题项 **/
function addMultiFillblankItem(quItemBody, itemText) {
//得判断是否是table类型
var newEditObj = null;
//ul li处理
var quScoreItemHtml = $("#mFillblankTableModel").html();
var quCoItemTable = quItemBody.find("table.mFillblankTable");
quCoItemTable.append("
" + quScoreItemHtml + "
");
quItemBody.find("input[name='saveTag']").val(0);
newEditObj = quCoItemTable.find("tr.mFillblankTableTr:last .editAble");
newEditObj.text(itemText);
if(itemText == "") {
newEditObj.css("display", "inline");
}
return newEditObj;
}
/** 删除多项填空题选项 **/
function deleteMultiFillblankOption() {
var optionParent = null;
optionParent = $(curEditObj).parents("tr.mFillblankTableTr");
var quOptionId = $(optionParent).find("input[name='quItemId']").val();
if(quOptionId != "" && quOptionId != "0") {
var url = reqBasePath + "/design/qu-multi-fillblank!ajaxDelete.action";
var data = "quItemId=" + quOptionId;
$.ajax({
url: url,
data: data,
type: "post",
success: function(msg) {
if(msg == "true") {
delQuOptionCallBack(optionParent);
}
}
});
} else {
delQuOptionCallBack(optionParent);
}
}
/** 矩阵单选题 **/
/**
** 新保存矩阵单选题
**/
function saveChen(quItemBody, callback) {
var saveTag = quItemBody.find("input[name='saveTag']").val();
if(saveTag == 0) {
var url = reqBasePath + "/design/qu-chen!ajaxSave.action";
var quType = quItemBody.find("input[name='quType']").val();
var quId = quItemBody.find("input[name='quId']").val();
var orderById = quItemBody.find("input[name='orderById']").val();
var isRequired = quItemBody.find("input[name='isRequired']").val();
var hv = quItemBody.find("input[name='hv']").val();
var randOrder = quItemBody.find("input[name='randOrder']").val();
var cellCount = quItemBody.find("input[name='cellCount']").val();
var data = "belongId=" + questionBelongId + "&orderById=" + orderById + "&tag=" + svTag + "&quType=" + quType + "&quId=" + quId;
data += "&isRequired=" + isRequired + "&hv=" + hv + "&randOrder=" + randOrder + "&cellCount=" + cellCount;
var quTitleSaveTag = quItemBody.find("input[name='quTitleSaveTag']").val();
if(quTitleSaveTag == 0) {
var quTitle = quItemBody.find(".quCoTitleEdit").html();
quTitle = escape(encodeURIComponent(quTitle));
data += "&quTitle=" + quTitle;
}
//矩阵列选项td
var quColumnOptions = quItemBody.find(".quCoItem table.quCoChenTable tr td.quChenColumnTd");
$.each(quColumnOptions, function(i) {
var optionValue = $(this).find("label.quCoOptionEdit").html();
var optionId = $(this).find(".quItemInputCase input[name='quItemId']").val();
var quItemSaveTag = $(this).find(".quItemInputCase input[name='quItemSaveTag']").val();
if(quItemSaveTag == 0) {
optionValue = escape(encodeURIComponent(optionValue));
data += "&columnValue_" + i + "=" + optionValue;
data += "&columnId_" + i + "=" + optionId;
}
//更新 字母 title标记到选项上.
$(this).addClass("quColumnOption_" + i);
});
//矩阵行选项td
var quColumnOptions = quItemBody.find(".quCoItem table.quCoChenTable tr td.quChenRowTd");
$.each(quColumnOptions, function(i) {
var optionValue = $(this).find("label.quCoOptionEdit").html();
var optionId = $(this).find(".quItemInputCase input[name='quItemId']").val();
var quItemSaveTag = $(this).find(".quItemInputCase input[name='quItemSaveTag']").val();
if(quItemSaveTag == 0) {
optionValue = escape(encodeURIComponent(optionValue));
data += "&rowValue_" + i + "=" + optionValue;
data += "&rowId_" + i + "=" + optionId;
}
//更新 字母 title标记到选项上.
$(this).addClass("quRowOption_" + i);
});
//逻辑选项
var quLogicItems = quItemBody.find(".quLogicItem");
$.each(quLogicItems, function(i) {
var thClass = $(this).attr("class");
thClass = thClass.replace("quLogicItem quLogicItem_", "");
var quLogicId = $(this).find("input[name='quLogicId']").val();
var cgQuItemId = $(this).find("input[name='cgQuItemId']").val();
var skQuId = $(this).find("input[name='skQuId']").val();
var logicSaveTag = $(this).find("input[name='logicSaveTag']").val();
var visibility = $(this).find("input[name='visibility']").val();
var logicType = $(this).find("input[name='logicType']").val();
var itemIndex = thClass;
if(logicSaveTag == 0) {
data += "&quLogicId_" + itemIndex + "=" + quLogicId;
data += "&cgQuItemId_" + itemIndex + "=" + cgQuItemId;
data += "&skQuId_" + itemIndex + "=" + skQuId;
data += "&visibility_" + itemIndex + "=" + visibility;
data += "&logicType_" + itemIndex + "=" + logicType;
}
});
$.ajax({
url: url,
data: data,
type: 'post',
success: function(msg) {
if(msg != "error") {
var jsons = eval("(" + msg + ")");
//alert(jsons);
var quId = jsons.id;
quItemBody.find("input[name='quId']").val(quId);
//列选项
var quColumnItems = jsons.quColumnItems;
$.each(quColumnItems, function(i, item) {
var quItemOption = quItemBody.find(".quColumnOption_" + item.title);
quItemOption.find("input[name='quItemId']").val(item.id);
quItemOption.find(".quItemInputCase input[name='quItemSaveTag']").val(1);
});
//行选项
var quRowItems = jsons.quRowItems;
$.each(quRowItems, function(i, item) {
var quItemOption = quItemBody.find(".quRowOption_" + item.title);
quItemOption.find("input[name='quItemId']").val(item.id);
quItemOption.find(".quItemInputCase input[name='quItemSaveTag']").val(1);
});
//同步logic Id信息
var quLogics = jsons.quLogics;
$.each(quLogics, function(i, item) {
var logicItem = quItemBody.find(".quLogicItem_" + item.title);
logicItem.find("input[name='quLogicId']").val(item.id);
logicItem.find("input[name='logicSaveTag']").val(1);
});
quItemBody.find("input[name='saveTag']").val(1);
quItemBody.find(".quCoTitle input[name='quTitleSaveTag']").val(1);
//执行保存下一题
saveQus(quItemBody.next(), callback);
//同步-更新题目排序号
quCBNum2++;
exeQuCBNum();
}
}
});
} else {
saveQus(quItemBody.next(), callback);
}
}
/** 添加列选项 **/
function addChenItem(eventObj, quItemBody, itemText) {
var eventObjClass = eventObj.attr("class");
if(eventObjClass.indexOf("Column") >= 0) {
return addChenColumnItem(quItemBody, itemText);
} else {
return addChenRowItem(quItemBody, itemText);
}
}
/** 添加矩阵单选题列选项 **/
function addChenColumnItem(quItemBody, itemText) {
//得判断是否是table类型
var newEditObj = null;
//ul li处理
var quRadioColumnHtml = $("#quChenColumnModel").html();
var quCoChenTable = quItemBody.find("table.quCoChenTable");
var quCoChenTableTrs = quCoChenTable.find("tr");
var quType = quItemBody.find("input[name='quType']").val();
$.each(quCoChenTableTrs, function(i) {
if(i == 0) {
$(this).append(quRadioColumnHtml);
} else {
if(quType == "CHENRADIO") {
$(this).append("