提交 a3d7fac1 编写于 作者: doc_wei's avatar doc_wei

默认添加多选题完成

上级 1bfb7d63
此差异已折叠。
此差异已折叠。
......@@ -176,4 +176,20 @@ public class DwSurveyDirectoryController {
dwSurveyDirectoryService.addQuRadioMation(inputObject, outputObject);
}
/**
*
* @Title: addQuCheckBoxMation
* @Description: 添加多选题
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/DwSurveyDirectoryController/addQuCheckBoxMation")
@ResponseBody
public void addQuCheckBoxMation(InputObject inputObject, OutputObject outputObject) throws Exception{
dwSurveyDirectoryService.addQuCheckBoxMation(inputObject, outputObject);
}
}
......@@ -52,4 +52,6 @@ public interface DwSurveyDirectoryDao {
public int addQuestionRadioMationList(List<Map<String, Object>> quRadio) throws Exception;
public int addQuestionCheckBoxMationList(List<Map<String, Object>> quCheckBox) throws Exception;
}
......@@ -25,4 +25,6 @@ public interface DwSurveyDirectoryService {
public void addQuRadioMation(InputObject inputObject, OutputObject outputObject) throws Exception;
public void addQuCheckBoxMation(InputObject inputObject, OutputObject outputObject) throws Exception;
}
......@@ -494,5 +494,79 @@ public class DwSurveyDirectoryServiceImpl implements DwSurveyDirectoryService{
}
outputObject.setBean(map);
}
/**
*
* @Title: addQuCheckBoxMation
* @Description: 添加多选题
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void addQuCheckBoxMation(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
map.put("quType", QuType.CHECKBOX.getIndex());
String quId = "";
if(ToolUtil.isBlank(map.get("quId").toString())){
quId = ToolUtil.getSurFaceId();
map.put("id", quId);
map.put("quTag", 1);
map.put("visibility", 1);
map.put("createTime", ToolUtil.getTimeAndToString());
dwSurveyDirectoryDao.addQuestionMation(map);
}else{
}
JSONArray checkbox = JSONArray.fromObject(map.get("checkboxTd").toString());//获取模板绑定信息
if(checkbox.size() > 0){
List<Map<String, Object>> quCheckbox = new ArrayList<>();
Map<String, Object> user = inputObject.getLogParams();
for(int i = 0; i < checkbox.size(); i++){
JSONObject object = (JSONObject) checkbox.get(i);
Map<String, Object> bean = new HashMap<>();
bean.put("optionId", object.getString("optionId"));
bean.put("orderById", object.getString("key"));
bean.put("optionName", object.getString("optionValue"));
bean.put("isNote", object.getString("isNote"));
bean.put("checkType", CheckType.valueOf(object.get("checkType").toString()).getIndex());
bean.put("isRequiredFill", object.getString("isRequiredFill"));
bean.put("quId", quId);
bean.put("visibility", 1);
bean.put("id", ToolUtil.getSurFaceId());
bean.put("createId", user.get("id"));
bean.put("createTime", ToolUtil.getTimeAndToString());
quCheckbox.add(bean);
}
dwSurveyDirectoryDao.addQuestionCheckBoxMationList(quCheckbox);
map.put("quItems", quCheckbox);
}
JSONArray array = JSONArray.fromObject(map.get("logic").toString());//获取模板绑定信息
if(array.size() > 0){
List<Map<String, Object>> quLogics = new ArrayList<>();
Map<String, Object> user = inputObject.getLogParams();
for(int i = 0; i < array.size(); i++){
JSONObject object = (JSONObject) array.get(i);
Map<String, Object> bean = new HashMap<>();
bean.put("quLogicId", object.getString("quLogicId"));
bean.put("cgQuItemId", object.getString("cgQuItemId"));
bean.put("skQuId", object.getString("skQuId"));
bean.put("visibility", object.getString("visibility"));
bean.put("logicType", object.getString("logicType"));
bean.put("title", object.getString("key"));
bean.put("id", ToolUtil.getSurFaceId());
bean.put("createId", user.get("id"));
bean.put("createTime", ToolUtil.getTimeAndToString());
quLogics.add(bean);
}
dwSurveyDirectoryDao.addQuestionLogicsMationList(quLogics);
map.put("quLogics", quLogics);
}
outputObject.setBean(map);
}
}
......@@ -366,4 +366,14 @@
</foreach>
</insert>
<insert id="addQuestionCheckBoxMationList" parameterType="java.util.Map">
insert into dw_qu_checkbox
(id, qu_id, option_id, option_name, option_title, check_type, is_note, is_required_fill, order_by_id, visibility, create_id, create_time)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.quId}, #{item.optionId}, #{item.optionName}, #{item.optionTitle}, #{item.checkType}, #{item.isNote},
#{item.isRequiredFill}, #{item.orderById}, #{item.visibility}, #{item.createId}, #{item.createTime})
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -103,6 +103,21 @@
<property id="radioTd" name="radioTd" ref="" var="单选题选项td json串"/>
<property id="logic" name="logic" ref="" var="逻辑设置json串"/>
</url>
<url id="dwsurveydirectory011" path="/post/DwSurveyDirectoryController/addQuCheckBoxMation" val="添加多选题" allUse="1">
<property id="quId" name="quId" ref="" var="问题id"/>
<property id="belongId" name="belongId" ref="required" var="问卷id"/>
<property id="quTitle" name="quTitle" ref="required" var="问题标题"/>
<property id="orderById" name="orderById" ref="required,num" var="序号"/>
<property id="tag" name="tag" ref="" var="表示题目是问卷题还是题库中题"/>
<property id="isRequired" name="isRequired" ref="required,num" var="是否必选"/>
<property id="contactsAttr" name="contactsAttr" ref="required,num" var="1关联到联系人属性 0不关联到联系人属性"/>
<property id="contactsField" name="contactsField" ref="required,num" var="关联的联系人字段"/>
<property id="hv" name="hv" ref="required,num" var="1水平显示 2垂直显示"/>
<property id="randOrder" name="randOrder" ref="required,num" var="选项随机排列 1随机排列 0不随机排列"/>
<property id="cellCount" name="cellCount" ref="required,num" var="按列显示时,列数"/>
<property id="checkboxTd" name="checkboxTd" ref="" var="多选题选项td json串"/>
<property id="logic" name="logic" ref="" var="逻辑设置json串"/>
</url>
<!-- 问卷调查结束 -->
</controller>
\ No newline at end of file
......@@ -125,6 +125,25 @@ layui.config({
str += '<div class="emptyTd"></div>';
return str;
});
hdb.registerHelper("cellCount002",function(v1, options){
var str = "";
var width = 600 / v1;
for(var i = 1; i <= v1; i++){
str += '<td width="' + width + 'px">' +
'<input type="checkbox"><label style="width:' + width + 'px;" class="editAble quCoOptionEdit">{{optionName}}</label>' +
'<input type="text" class="optionInpText" style="{{#compare2 isNote 0}}{{/compare2}}" />' +
'<div class="quItemInputCase">' +
'<input type="hidden" name="quItemId" value="{{id}}"><input type="hidden" name="quItemSaveTag" value="1">' +
'<input type="hidden" name="isNote" value="{{isNote}}">' +
'<input type="hidden" name="checkType" value="{{checkType}}">' +
'<input type="hidden" name="isRequiredFill" value="{{isRequiredFill}}">' +
'</div>' +
'</td>';
}
str += '<div class="emptyTd"></div>';
return str;
});
},
ajaxSendAfter:function(json){
......@@ -1560,7 +1579,7 @@ layui.config({
**/
function saveRadio(quItemBody, callback) {
var saveTag = quItemBody.find("input[name='saveTag']").val();
if(saveTag == 0) {
if(saveTag == 0 && isNull(quItemBody.find("input[name='quId']").val())) {
var data = {
belongId: parent.rowId,
orderById: quItemBody.find("input[name='orderById']").val(),
......@@ -1744,116 +1763,101 @@ layui.config({
//*******多选题*******//
/**
** 新保存多选题
* 新保存多选题
**/
function saveCheckbox(quItemBody, callback) {
var saveTag = quItemBody.find("input[name='saveTag']").val();
if(saveTag == 0) {
var url = reqBasePath + "/design/qu-checkbox!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 contactsAttr = quItemBody.find("input[name='contactsAttr']").val();
var contactsField = quItemBody.find("input[name='contactsField']").val();
var data = "belongId=" + questionBelongId + "&orderById=" + orderById + "&tag=" + svTag + "&quType=" + quType + "&quId=" + quId;
data += "&isRequired=" + isRequired + "&hv=" + hv + "&randOrder=" + randOrder + "&cellCount=" + cellCount;
data += "&contactsAttr=" + contactsAttr + "&contactsField=" + contactsField;
if(saveTag == 0 && isNull(quItemBody.find("input[name='quId']").val())) {
var data = {
belongId: parent.rowId,
orderById: quItemBody.find("input[name='orderById']").val(),
tag: svTag,
quId: quItemBody.find("input[name='quId']").val(),
isRequired: quItemBody.find("input[name='isRequired']").val(),
hv: quItemBody.find("input[name='hv']").val(),
randOrder: quItemBody.find("input[name='randOrder']").val(),
cellCount: quItemBody.find("input[name='cellCount']").val(),
contactsAttr: quItemBody.find("input[name='contactsAttr']").val(),
contactsField: quItemBody.find("input[name='contactsField']").val(),
quTitle: '',
};
var quTitleSaveTag = quItemBody.find("input[name='quTitleSaveTag']").val();
if(quTitleSaveTag == 0) {
var quTitle = quItemBody.find(".quCoTitleEdit").html();
quTitle = escape(encodeURIComponent(quTitle));
data += "&quTitle=" + quTitle;
data.quTitle = encodeURI(quTitle);
}
var quItemOptions = null;
if(hv == 3) {
if(quItemBody.find("input[name='hv']").val() == 3) {
//还有是table的情况需要处理
quItemOptions = quItemBody.find(".quCoItem table.tableQuColItem tr td");
} else {
quItemOptions = quItemBody.find(".quCoItem li.quCoItemUlLi");
}
var checkboxTd = [];
$.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();
var isNote = $(this).find(".quItemInputCase input[name='isNote']").val();
var checkType = $(this).find(".quItemInputCase input[name='checkType']").val();
var isRequiredFill = $(this).find(".quItemInputCase input[name='isRequiredFill']").val();
if(quItemSaveTag == 0) {
optionValue = escape(encodeURIComponent(optionValue));
data += "&optionValue_" + i + "=" + optionValue;
data += "&optionId_" + i + "=" + optionId;
data += "&isNote_" + i + "=" + isNote;
data += "&checkType_" + i + "=" + checkType;
data += "&isRequiredFill_" + i + "=" + isRequiredFill;
var s = {
optionValue: encodeURI($(this).find("label.quCoOptionEdit").html()),
optionId: $(this).find(".quItemInputCase input[name='quItemId']").val(),
isNote: $(this).find(".quItemInputCase input[name='isNote']").val(),
checkType: $(this).find(".quItemInputCase input[name='checkType']").val(),
isRequiredFill: $(this).find(".quItemInputCase input[name='isRequiredFill']").val(),
key: i,
};
checkboxTd.push(s);
}
//更新 字母 title标记到选项上.
$(this).addClass("quOption_" + i);
});
data.checkboxTd = JSON.stringify(checkboxTd);
//逻辑选项
var quLogicItems = quItemBody.find(".quLogicItem");
var list = [];
$.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();
}
var s = {
quLogicId: $(this).find("input[name='quLogicId']").val(),
cgQuItemId: $(this).find("input[name='cgQuItemId']").val(),
skQuId: $(this).find("input[name='skQuId']").val(),
visibility: $(this).find("input[name='visibility']").val(),
logicType: $(this).find("input[name='logicType']").val(),
key: $(this).attr("class").replace("quLogicItem quLogicItem_", ""),
};
list.push(s);
}
});
data.logic = JSON.stringify(list);
AjaxPostUtil.request({url:reqBasePath + "dwsurveydirectory011", params:data, type:'json', callback:function(json){
if(json.returnCode == 0){
var quId = json.bean.id;
quItemBody.find("input[name='saveTag']").val(1);
quItemBody.find(".quCoTitle input[name='quTitleSaveTag']").val(1);
quItemBody.find("input[name='quId']").val(quId);
var quItems = json.bean.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 = json.bean.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);
});
//执行保存下一题
saveQus(quItemBody.next(), callback);
//同步-更新题目排序号
quCBNum2++;
exeQuCBNum();
}else{
top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
}
}});
} else {
saveQus(quItemBody.next(), callback);
}
......
......@@ -234,69 +234,51 @@
<input type="hidden" name="quTitleSaveTag" value="1">
</div>
<div class="quCoItem">
<c:choose>
<c:when test="{{hv eq 3}}">
{{#if hv}}
{{#compare1 hv '3'}}
<table class='tableQuColItem'>
<c:forEach begin="0" end="${fn:length(en.quCheckboxs)-1}}" var="j" step="{{cellCount}}">
{{#each questionCheckBox}}
<tr>
<c:forEach begin="1" end="{{cellCount}}" var="k">
<td width="${600/en.cellCount}}">
<!-- 判断不为空,访止数组越界 -->
<c:set var="quOptionIndex" value="${(j+k-1)}}"></c:set>
<c:choose>
<c:when test="${quOptionIndex < fn:length(en.quCheckboxs)}}">
<!-- <input type="checkbox"><label style="width:${600/en.cellCount-10}}px;" class="editAble quCoOptionEdit">${quCheckboxs[quOptionIndex].optionName}}</label>-->
<!-- <input type='text' class='optionInpText' style="${isNote eq 1 ? '':'display: none;'}" />-->
<div class="quItemInputCase">
<!-- <input type="hidden" name="quItemId" value="${quCheckboxs[quOptionIndex].id}}"><input type="hidden" name="quItemSaveTag" value="1">-->
<input type="hidden" name="isNote" value="{{isNote}}">
<input type="hidden" name="checkType" value="{{checkType}}">
<input type="hidden" name="isRequiredFill" value="{{isRequiredFill}}">
</div>
</c:when>
<c:otherwise>
<div class="emptyTd"></div>
</c:otherwise>
</c:choose>
</td>
</c:forEach>
{{#cellCount002 cellCount}}{{/cellCount002}}
</tr>
</c:forEach>
{{/each}}
</table>
</c:when>
<c:when test="{{hv eq 1}}">
<ul class="transverse">
<c:forEach items="{{quCheckboxs}}" var="item">
<li class="quCoItemUlLi">
<input type="checkbox"><label class="editAble quCoOptionEdit">{{optionName}}</label>
<!-- <input type='text' class='optionInpText' style="${isNote eq 1 ? '':'display: none;'}" />-->
<div class="quItemInputCase">
<input type="hidden" name="quItemId" value="{{id}}"><input type="hidden" name="quItemSaveTag" value="1">
<input type="hidden" name="isNote" value="{{isNote}}">
<input type="hidden" name="checkType" value="{{checkType}}">
<input type="hidden" name="isRequiredFill" value="{{isRequiredFill}}">
</div>
</li>
</c:forEach>
</ul>
</c:when>
<c:otherwise>
<ul>
<c:forEach items="{{quCheckboxs}}" var="item">
<li class="quCoItemUlLi">
<input type="checkbox"><label class="editAble quCoOptionEdit">{{optionName}}</label>
<!-- <input type='text' class='optionInpText' style="${isNote eq 1 ? '':'display: none;'}" />-->
<div class="quItemInputCase">
<input type="hidden" name="quItemId" value="{{id}}"><input type="hidden" name="quItemSaveTag" value="1">
<input type="hidden" name="isNote" value="{{isNote}}">
<input type="hidden" name="checkType" value="{{checkType}}">
<input type="hidden" name="isRequiredFill" value="{{isRequiredFill}}">
</div>
</li>
</c:forEach>
</ul>
</c:otherwise>
</c:choose>
{{else}}
{{#if hv}}
{{#compare1 hv '1'}}
<ul class="transverse">
{{#each questionCheckBox}}
<li class="quCoItemUlLi">
<input type="checkbox"><label class="editAble quCoOptionEdit">{{optionName}}</label>
<input type='text' class='optionInpText' style="{{#compare2 isNote 0}}{{/compare2}}" />
<div class="quItemInputCase">
<input type="hidden" name="quItemId" value="{{id}}"><input type="hidden" name="quItemSaveTag" value="1">
<input type="hidden" name="isNote" value="{{isNote}}">
<input type="hidden" name="checkType" value="{{checkType}}">
<input type="hidden" name="isRequiredFill" value="{{isRequiredFill}}">
</div>
</li>
{{/each}}
</ul>
{{else}}
<ul>
{{#each questionCheckBox}}
<li class="quCoItemUlLi">
<input type="checkbox"><label class="editAble quCoOptionEdit">{{optionName}}</label>
<input type='text' class='optionInpText' style="{{#compare2 isNote 0}}{{/compare2}}" />
<div class="quItemInputCase">
<input type="hidden" name="quItemId" value="{{id}}"><input type="hidden" name="quItemSaveTag" value="1">
<input type="hidden" name="isNote" value="{{isNote}}">
<input type="hidden" name="checkType" value="{{checkType}}">
<input type="hidden" name="isRequiredFill" value="{{isRequiredFill}}">
</div>
</li>
{{/each}}
</ul>
{{/compare1}}
{{/if}}
{{/compare1}}
{{/if}}
</div>
<div class="quCoBottomTools">
<ul class="quCoBottomToolsUl">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册