Index: ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableView.js =================================================================== diff -u -r15072 -r22783 --- ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableView.js (.../satisfactionSurveyTableView.js) (revision 15072) +++ ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableView.js (.../satisfactionSurveyTableView.js) (revision 22783) @@ -49,7 +49,7 @@ function renderCallModifyFunction(v, p, record){ var data = record.data; - return "" + v + ""; + return "" + v + ""; } @@ -89,14 +89,7 @@ {name : 'staffNum'} ]; - var tbar = [ { - text : '添加', - hidden : true, - iconCls : 'btn_ext_application_add', - handler : function() { - addSatisfactionSurveyTable(''); - } - }, '-', { + var tbar = [{ text : '修改', hidden : SSTS_SatisfactionSurveyTable_Update, iconCls : 'btn_ext_application_edit', @@ -112,7 +105,7 @@ return false; } var d = records[0]; - addSatisfactionSurveyTable(d.data['id']); + addSatisfactionSurveyTable(d.data['id'], true, null, null); } }, '-', { text : '删除', Index: ssts-satisfactionsurvey/src/main/java/com/forgon/disinfectsystem/satisfactionsurvey/action/SatisfactionSurveyTableAction.java =================================================================== diff -u -r22745 -r22783 --- ssts-satisfactionsurvey/src/main/java/com/forgon/disinfectsystem/satisfactionsurvey/action/SatisfactionSurveyTableAction.java (.../SatisfactionSurveyTableAction.java) (revision 22745) +++ ssts-satisfactionsurvey/src/main/java/com/forgon/disinfectsystem/satisfactionsurvey/action/SatisfactionSurveyTableAction.java (.../SatisfactionSurveyTableAction.java) (revision 22783) @@ -3,7 +3,6 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -13,7 +12,6 @@ import com.google.gson.reflect.TypeToken; import net.sf.json.JSONArray; import net.sf.json.JSONObject; -import net.sf.json.JsonConfig; import org.apache.commons.collections4.CollectionUtils; import com.forgon.tools.StrutsResponseUtils; @@ -32,10 +30,10 @@ import com.forgon.disinfectsystem.satisfactionsurvey.service.SatisfactionSurveyTableManager; import com.forgon.disinfectsystem.satisfactionsurvey.service.SatisfactionSurveyTemplateManager; import com.forgon.tools.StrutsParamUtils; -import com.forgon.tools.date.DateTools; -import com.forgon.tools.json.JsonPropertyFilter; import com.opensymphony.xwork2.ModelDriven; import com.opensymphony.xwork2.Preparable; +import com.forgon.tools.util.ForgonDateUtils; +import com.forgon.tools.db.DatabaseUtil; /** * @@ -54,8 +52,6 @@ private SatisfactionSurveyTableManager satisfactionSurveyTableManager; - private Map resultMap = new HashMap(); - public void setSatisfactionSurveyTemplateManager( SatisfactionSurveyTemplateManager satisfactionSurveyTemplateManager) { this.satisfactionSurveyTemplateManager = satisfactionSurveyTemplateManager; @@ -66,287 +62,208 @@ this.satisfactionSurveyTableManager = satisfactionSurveyTableManager; } - private void responseJson(String[] filter){ - JsonConfig config = new JsonConfig(); - if(filter != null){ - config.setJsonPropertyFilter(new JsonPropertyFilter(filter)); - } - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setContentType("text/javascript;charset=UTF-8"); - response.setHeader("Content-Type", "text/json; charset=UTF-8"); - PrintWriter pw; - try { - JSONObject jsonObject = JSONObject.fromObject(resultMap, config); - String jsonStr = jsonObject.toString(); - pw = response.getWriter(); - pw.print(jsonStr); - pw.flush(); - pw.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public String loadSatisfactionSurveyTable(){ - Long templateId = satisfactionSurveyTable.getSatisfactionSurveyTemplateId(); - SatisfactionSurveyTemplate template = satisfactionSurveyTemplateManager.getById(templateId+""); - //说明该调查表对应的表定义已经结束了,也就是说,此时再修改调查表已经没有意义啦 - if(template.getStatus().equals(SatisfactionSurveyTemplate.STATUS_END) && template.getEndDate()!=null){ - resultMap.put("alreadyEnd", true); - } - resultMap.put("success", true); - resultMap.put("data", satisfactionSurveyTable); - resultMap.put("template", template); - responseJson(new String[]{"answerItem"}); - return null; - } - /** - * 加载“满意度调查表(实例)”的内容. + * 加载“满意度调查表实例”的数据. * @return */ - public String loadSatisfactionSurveyTableItem() { - String templateId = StrutsParamUtils.getPraramValue("templateId", ""); //满意度调查表定义的id - StringBuffer jsonStr = new StringBuffer(); - if(StringUtils.isNotBlank(templateId)){ - convertTemplateItemToJsonTreeByTemplateItemId(templateId, jsonStr); - }else{ - convertAnswerItemToJsonTree(jsonStr); + public void loadSatisfactionSurveyTable(){ + JSONObject result = JSONUtil.buildJsonObject(false, "加载失败!"); + Long templateId = StrutsParamUtils.getPraramLongValue("templateId", 0L); + if (satisfactionSurveyTable != null && DatabaseUtil.isPoIdValid(satisfactionSurveyTable.getId())) { //修改 + result = JSONUtil.buildJsonObject(true, "加载成功!"); + result.put("data", buildSatisfactionSurveyTableJson(satisfactionSurveyTable)); + } else if (DatabaseUtil.isPoIdValid(templateId)) { //新增 + SatisfactionSurveyTemplate satisfactionSurveyTemplate = satisfactionSurveyTemplateManager.getById(templateId+""); + result = JSONUtil.buildJsonObject(true, "加载成功!"); + result.put("data", buildSatisfactionSurveyTableJson(satisfactionSurveyTemplate)); } - StrutsResponseUtils.output("[" + jsonStr.toString() + "]"); - return null; + StrutsResponseUtils.output(result); } - - private String replaceStr(String content){ - return content.replaceAll("\\\\", "\\\\\\\\").replaceAll("'", "\\\\\'").replaceAll("\"", "\\\\\""); - } - + /** - * 加载“满意度调查表(实例)”的内容-用于修改. - * @param jsonStr 输出对象 + * 根据“满意度调查表定义”获取数据(新增). + * @param satisfactionSurveyTable 满意度调查表实例 * @return */ - private void convertAnswerItemToJsonTree(StringBuffer jsonStr) { - List itemList = satisfactionSurveyTable.getAnswerItem(); - if(itemList != null){ - String iconFile = StrutsParamUtils.getServletContext().getContextPath()+"/images/btn_enrol.gif"; - int seqNum = 1; - for(SatisfactionSurveyTableItem pItem:itemList){ - if (jsonStr.length() != 0) { - jsonStr.append(","); - } - String content = pItem.getContent(); - if(StringUtils.isNotBlank(content)){ - content = replaceStr(content); - } - boolean isLeaf = true; - if(pItem.getChildren() != null && pItem.getChildren().size() > 0){ - isLeaf = false; - } - jsonStr.append("{id:") - .append(pItem.getId()) - .append(",content:'") - .append(content) - .append("',seqNum:'") - .append(seqNum) - .append("'"); - - if(isLeaf){ - jsonStr.append(",satisfaction:'").append(pItem.getSatisfaction().name()) - .append("',uiProvider:'col',leaf:true,icon:'").append(iconFile).append("'}"); - }else{ - jsonStr.append(",leaf:false,uiProvider:'col',cls:'master-task',iconCls:'task-folder',children:["); - for (int i = 0,len =pItem.getChildren().size(); i < len; i++) { - SatisfactionSurveyTableItem cItem = pItem.getChildren().get(i); - String ccontent = cItem.getContent(); - if(StringUtils.isNotBlank(ccontent)){ - ccontent = replaceStr(ccontent); + private Object buildSatisfactionSurveyTableJson( + SatisfactionSurveyTemplate satisfactionSurveyTemplate) { + JSONObject data = new JSONObject(); + if (satisfactionSurveyTemplate != null) { + /** + * 1、对应的满意度调查表定义已经结束了,此时再修改调查表已经没有意义,并且设置自定义表单定义的id + */ + data.put("alreadyEnd", SatisfactionSurveyTemplate.STATUS_END.equals(satisfactionSurveyTemplate.getStatus()) && satisfactionSurveyTemplate.getEndDate() != null); + data.put("formDefinitionId", satisfactionSurveyTemplate.getFormDefinition_id()); + data.put("formInstance_id", ""); + + data.put("satisfactionSurveyTemplateId", satisfactionSurveyTemplate.getId()); + data.put("satisfactionSurveyTemplateName", satisfactionSurveyTemplate.getName()); + data.put("instructions", satisfactionSurveyTemplate.getInstructions()); + data.put("surveyDate", ForgonDateUtils.safelyFormatDate(new Date(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMM, "")); + data.put("depart", AcegiHelper.getCurrentOrgUnitName()); + data.put("departCoding", AcegiHelper.getCurrentOrgUnitCode()); + data.put("userName", AcegiHelper.getLoginUser().getUserFullName()); + data.put("staffNum", AcegiHelper.getLoginUser().getUserName()); + data.put("remark", ""); + + Integer seqNum = 0; + JSONArray itemArr = new JSONArray(); + List items = satisfactionSurveyTemplate.getItemList(); + if (CollectionUtils.isNotEmpty(items)) { + for (SatisfactionSurveyTemplateItem item : items) { + JSONObject obj = new JSONObject(); +// obj.put("id", item.getId()); + obj.put("nodeId", item.getId()); + obj.put("content", item.getContent()); + obj.put("seqNum", ++ seqNum); + + List children = item.getChildren(); + if (CollectionUtils.isNotEmpty(children)) { + Integer seqNum2 = 0; + JSONArray childrenArr = new JSONArray(); + for (SatisfactionSurveyTemplateItem child : children) { + JSONObject childObj = new JSONObject(); +// childObj.put("id", child.getId()); + childObj.put("nodeId", child.getId()); + childObj.put("content", child.getContent()); + childObj.put("seqNum", String.format("%s.%s", seqNum, ++ seqNum2)); + childObj.put("satisfaction", ""); + childObj.put("leaf", true); + childrenArr.add(childObj); } - jsonStr.append("{id:") - .append(cItem.getId()) - .append(",content:'") - .append(ccontent) - .append("',seqNum:'") - .append(seqNum) - .append(".") - .append(i+1) - .append("',satisfaction:'").append(cItem.getSatisfaction().name()) - .append("',uiProvider:'col',leaf:true,icon:'").append(iconFile).append("'}"); - if (i != len - 1) { - jsonStr.append(","); - } + obj.put("children", childrenArr); + } else { + obj.put("satisfaction", ""); + obj.put("leaf", true); } - jsonStr.append("]}"); + itemArr.add(obj); } - seqNum++; } + data.put("answerItems", itemArr); } + return data; } /** - * 加载“满意度调查表(实例)”的内容-用于新增. - * @param templateId 满意度调查表(定义)的id - * @param jsonStr 输出对象 + * 根据“满意度调查表实例”获取数据(修改). + * @param satisfactionSurveyTable 满意度调查表实例 * @return */ - private void convertTemplateItemToJsonTreeByTemplateItemId(String templateId, - StringBuffer jsonStr) { - SatisfactionSurveyTemplate template = satisfactionSurveyTemplateManager.getById(templateId); - if(template != null){ - List itemList = template.getItemList(); - if(itemList != null){ - int seqNum = 1; - String iconFile = StrutsParamUtils.getServletContext().getContextPath()+"/images/btn_enrol.gif"; - for(SatisfactionSurveyTemplateItem pItem:itemList){ - if (jsonStr.length() != 0) { - jsonStr.append(","); + private JSONObject buildSatisfactionSurveyTableJson( + SatisfactionSurveyTable satisfactionSurveyTable) { + JSONObject data = new JSONObject(); + + /** + * 1、对应的满意度调查表定义已经结束了,此时再修改调查表已经没有意义,并且设置自定义表单定义的id + */ + Boolean alreadyEnd = false; + Long satisfactionSurveyTemplateId = satisfactionSurveyTable.getSatisfactionSurveyTemplateId(); + if (satisfactionSurveyTemplateId != null) { + SatisfactionSurveyTemplate satisfactionSurveyTemplate = satisfactionSurveyTemplateManager.getById(satisfactionSurveyTemplateId+""); + if(SatisfactionSurveyTemplate.STATUS_END.equals(satisfactionSurveyTemplate.getStatus()) && satisfactionSurveyTemplate.getEndDate() != null){ + alreadyEnd = true; + } + data.put("formDefinitionId", satisfactionSurveyTemplate.getFormDefinition_id()); + } + data.put("alreadyEnd", alreadyEnd); + + /** + * 2、设置其他属性 + */ + data.put("depart", satisfactionSurveyTable.getDepart()); + data.put("departCoding", satisfactionSurveyTable.getDepartCoding()); + data.put("formInstance_id", satisfactionSurveyTable.getFormInstance_id()); + data.put("id", satisfactionSurveyTable.getId()); + data.put("instructions", satisfactionSurveyTable.getInstructions()); + data.put("remark", satisfactionSurveyTable.getRemark()); + data.put("satisfactionSurveyTemplateId", satisfactionSurveyTable.getSatisfactionSurveyTemplateId()); + data.put("satisfactionSurveyTemplateName", satisfactionSurveyTable.getSatisfactionSurveyTemplateName()); + data.put("surveyDate", ForgonDateUtils.safelyFormatDate(satisfactionSurveyTable.getSurveyDate(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMM, "")); + data.put("userName", satisfactionSurveyTable.getUserName()); + data.put("staffNum", satisfactionSurveyTable.getStaffNum()); + + /** + * 3、设置调查的项 + */ + JSONArray answerItemArr = new JSONArray(); + Integer seqNum = 0; + List answerItems = satisfactionSurveyTable.getAnswerItem(); + if (CollectionUtils.isNotEmpty(answerItems)) { + for (SatisfactionSurveyTableItem item : answerItems) { + JSONObject obj = new JSONObject(); + obj.put("nodeId", item.getId()); + obj.put("id", item.getId()); + obj.put("content", item.getContent()); + obj.put("seqNum", ++ seqNum); + + List children = item.getChildren(); + if (CollectionUtils.isNotEmpty(children)) { + Integer seqNum2 = 0; + JSONArray childrenArr = new JSONArray(); + for (SatisfactionSurveyTableItem child : children) { + JSONObject childObj = new JSONObject(); + childObj.put("nodeId", child.getId()); + childObj.put("id", child.getId()); + childObj.put("content", child.getContent()); + childObj.put("satisfaction", child.getSatisfaction().name()); + childObj.put("seqNum", String.format("%s.%s", seqNum, ++ seqNum2)); + childObj.put("leaf", true); + childrenArr.add(childObj); } - String content = pItem.getContent(); - if(StringUtils.isNotBlank(content)){ - content = replaceStr(content); - } - boolean isLeaf = true; - if(pItem.getChildren() != null && pItem.getChildren().size() > 0){ - isLeaf = false; - } - jsonStr.append("{id:") - .append(pItem.getId()) - .append(",content:'") - .append(content) - .append("',seqNum:'") - .append(seqNum) - .append("'"); - - if(isLeaf){ - jsonStr.append(",uiProvider:'col',leaf:true,icon:'").append(iconFile).append("'}"); - }else{ - jsonStr.append(",leaf:false,uiProvider:'col',cls:'master-task',iconCls:'task-folder',children:["); - for (int i = 0,len =pItem.getChildren().size(); i < len; i++) { - SatisfactionSurveyTemplateItem cItem = pItem.getChildren().get(i); - String ccontent = cItem.getContent(); - if(StringUtils.isNotBlank(ccontent)){ - ccontent = replaceStr(ccontent); - } - JSONObject item = new JSONObject(); - item.put("id", cItem.getId()); - item.put("content", ccontent); - item.put("seqNum", seqNum+"."+i+1); - item.put("uiProvider", "col"); - item.put("leaf", true); - item.put("icon", iconFile); - - item.put("option_1", ""); - item.put("content", ccontent); -// jsonStr.append("{id:") -// .append(cItem.getId()) -// .append(",content:'") -// .append(ccontent) -// .append("',seqNum:'") -// .append(seqNum) -// .append(".") -// .append(i+1) -// .append("',uiProvider:'col',leaf:true,icon:'").append(iconFile).append("'}"); - jsonStr.append(item.toString()); - if (i != len - 1) { - jsonStr.append(","); - } - } - jsonStr.append("]}"); - } - seqNum++; + obj.put("children", childrenArr); + } else { + obj.put("satisfaction", item.getSatisfaction().name()); + obj.put("leaf", true); } + answerItemArr.add(obj); } } + data.put("answerItems", answerItemArr); + return data; } - @SuppressWarnings("unchecked") - private List jsonStrToJavaList(String jsonList){ - List itemList = null; - try{ - JSONArray ja = JSONArray.fromObject(jsonList); - Map map = new HashMap(2); - map.put("children", SatisfactionSurveyTableItem.class); - map.put("satisfaction", Satisfaction.class); - JsonConfig json = new JsonConfig(); - json.setClassMap(map); - json.setRootClass(SatisfactionSurveyTableItem.class); - itemList = (List) JSONArray.toCollection(ja, json); - }catch (Exception e) { - e.printStackTrace(); - } - return itemList; - } - /** - * 初始化“满意度调查表(实例)”的五个属性(即:remark、satisfactionSurveyTemplateName、instructions、satisfactionSurveyTemplateId、surveyDate) + * 保存或者更新“满意度调查表实例”. + * @return */ - private void initSatisfactionSurveyTable(){ - String remark = StrutsParamUtils.getPraramValue("remark", ""); - satisfactionSurveyTable.setRemark(remark); - - String satisfactionSurveyTemplateName = StrutsParamUtils.getPraramValue("satisfactionSurveyTemplateName", ""); - satisfactionSurveyTable.setSatisfactionSurveyTemplateName(satisfactionSurveyTemplateName); - - String instructions = StrutsParamUtils.getPraramValue("instructions", ""); - satisfactionSurveyTable.setInstructions(instructions); - - String satisfactionSurveyTemplateIdStr = StrutsParamUtils.getPraramValue("satisfactionSurveyTemplateId", ""); - satisfactionSurveyTable.setSatisfactionSurveyTemplateId(Long.parseLong(satisfactionSurveyTemplateIdStr)); - - if(satisfactionSurveyTable.getId() == null){ - String surveyDateStr = StrutsParamUtils.getPraramValue("surveyDateStr", ""); - Date currentDate = null; - if(StringUtils.isNotBlank(surveyDateStr)){ - currentDate = DateTools.coverStrToDate(surveyDateStr, "yyyy-MM-dd HH:mm"); + public void saveSatisfactionSurveyTable() { + JSONObject result = JSONUtil.buildJsonObject(true, "保存成功!"); + try { + /** + * 1、设置每一个项的“sequenceNumber”属性和满意度情况 + */ + String treeItemData = StrutsParamUtils.getPraramValue("treeItemData", ""); + List answerItem = null; + if(StringUtils.isNotBlank(treeItemData)){ + answerItem = JSONUtil.fromJson(treeItemData, new TypeToken>(){}); } - if(currentDate == null){ - currentDate = new Date(); - } - satisfactionSurveyTable.setSurveyDate(currentDate); - } - } - - public String saveSatisfactionSurveyTable() throws Exception{ - - /** - * 1、设置每一个项的“sequenceNumber”属性和满意度情况 - */ - String treeItemData = StrutsParamUtils.getPraramValue("treeItemData", ""); - List answerItem = null; - if(StringUtils.isNotBlank(treeItemData)){ - answerItem = JSONUtil.fromJson(treeItemData, new TypeToken>(){}); - } - if(CollectionUtils.isNotEmpty(answerItem)){ - long pSeq = 1; - for(SatisfactionSurveyTableItem item : answerItem){//最多只有两层 - item.setSequenceNumber(pSeq++); - List children = item.getChildren(); - if(CollectionUtils.isNotEmpty(children)){ - long cSeq = 1; - for(SatisfactionSurveyTableItem citem : children){ - citem.setSequenceNumber(cSeq++); - setSatifyCount(citem); + if(CollectionUtils.isNotEmpty(answerItem)){ + long pSeq = 1; + for(SatisfactionSurveyTableItem item : answerItem){//最多只有两层 + item.setSequenceNumber(pSeq++); + List children = item.getChildren(); + if(CollectionUtils.isNotEmpty(children)){ + long cSeq = 1; + for(SatisfactionSurveyTableItem citem : children){ + citem.setSequenceNumber(cSeq++); + setSatifyCount(citem); + } + }else{//只有一层 + setSatifyCount(item); } - }else{//只有一层 - setSatifyCount(item); } } - } - /** - * 2、初始化“满意度调查表实例”的五个属性(即:remark、satisfactionSurveyTemplateName、instructions、satisfactionSurveyTemplateId、surveyDate) - */ - initSatisfactionSurveyTable(); - - /** - * 3、保存初始化“满意度调查表实例”和“自定义表单实例” - */ - Map parameters = StrutsParamUtils.getParameters(); - Long id = satisfactionSurveyTable.getId(); - satisfactionSurveyTableManager.saveOrUpdateSatisfactionSurveyTableAndFormInstance(satisfactionSurveyTable, parameters, answerItem, id == null); - resultMap.put("success", true); - responseJson(null); - return null; + /** + * 2、保存初始化“满意度调查表实例”和“自定义表单实例” + */ + Map parameters = StrutsParamUtils.getParameters(); + satisfactionSurveyTableManager.saveOrUpdateSatisfactionSurveyTableAndFormInstance(satisfactionSurveyTable, parameters, answerItem); + } catch (Exception e) { + e.printStackTrace(); + result = JSONUtil.buildJsonObject(false, "保存失败!"); + } + StrutsResponseUtils.output(result); } /** Index: ssts-satisfactionsurvey/src/main/java/com/forgon/disinfectsystem/satisfactionsurvey/service/SatisfactionSurveyTableManagerImpl.java =================================================================== diff -u -r22745 -r22783 --- ssts-satisfactionsurvey/src/main/java/com/forgon/disinfectsystem/satisfactionsurvey/service/SatisfactionSurveyTableManagerImpl.java (.../SatisfactionSurveyTableManagerImpl.java) (revision 22745) +++ ssts-satisfactionsurvey/src/main/java/com/forgon/disinfectsystem/satisfactionsurvey/service/SatisfactionSurveyTableManagerImpl.java (.../SatisfactionSurveyTableManagerImpl.java) (revision 22783) @@ -19,6 +19,8 @@ import com.forgon.disinfectsystem.entity.satisfactionsurvey.SatisfactionSurveyTable; import com.forgon.disinfectsystem.entity.satisfactionsurvey.SatisfactionSurveyTableItem; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.directory.acegi.tools.AcegiHelper; import com.forgon.tools.hibernate.ObjectDao; /** @@ -98,34 +100,24 @@ /** - * 保存满意度调查表下的“自定义表单实例” + * 保存满意度调查表下的“自定义表单实例”. * @param satisfactionSurveyTable 满意度调查表实例对象 * @param items 前台传过来的参数对象 - * @param isSave 保存还是更新 */ - private void saveOrUpdateFormInstance(SatisfactionSurveyTable satisfactionSurveyTable, Map items, boolean isSave) { + private void saveOrUpdateFormInstance(SatisfactionSurveyTable satisfactionSurveyTable, Map items) { HibernateTemplate ht = objectDao.getHt(); - SatisfactionSurveyTemplate satisfactionSurveyTemplate = ht.get(SatisfactionSurveyTemplate.class, satisfactionSurveyTable.getSatisfactionSurveyTemplateId()); - Long formDefinition_id = satisfactionSurveyTemplate.getFormDefinition_id(); - if (formDefinition_id == null){ - //如果自定义表单关联id为空,则不保存自定义表单 - return; - } - FormDefinition formDefinition = objectDao.getHt().get(FormDefinition.class, formDefinition_id); - //因为旧的模板可能没有formDefinition,所以保存前这里要判断一下 - if (formDefinition == null){ - logger.warn("formDefinition为空,satisfactionSurveyTemplate的formDefinitionId为:" + satisfactionSurveyTemplate.getFormDefinition_id()); - return; - } - items.put("formDefinitionId", formDefinition.getId().toString()); - Long formInstance_id = satisfactionSurveyTable.getFormInstance_id(); - FormInstance formInstance; - if (isSave || formInstance_id == null || (formInstance = ht.get(FormInstance.class, formInstance_id)) == null){ + ht.clear(); + String formInstance_id = items.get("formInstance_id"); + FormInstance formInstance = null; + if (DatabaseUtil.isPoIdValid(formInstance_id)){ + formInstance = formInstanceManager.getFormInstanceById(formInstance_id); + } else { formInstance = new FormInstance(); + formInstance.setCreateUserName(AcegiHelper.getLoginUser().getUserFullName()); + formInstance.setOrgUnitCoding(AcegiHelper.getCurrentOrgUnitCode()); + formInstance.setOrgUnit(AcegiHelper.getCurrentOrgUnitName()); } - formInstance.setCreateUserName(formDefinition.getCreateUserName()); - formInstance.setOrgUnitCoding(formDefinition.getOrgUnitCoding()); - formInstance.setOrgUnit(formDefinition.getOrgUnit()); + formInstanceManager.saveFormInstance(formInstance, items); // 更新或者插入formInstance后关联satisfactionSurveyTable表的formInstance_id satisfactionSurveyTable.setFormInstance_id(formInstance.getId()); @@ -134,8 +126,8 @@ @Transactional(propagation = Propagation.REQUIRED) @Override - public void saveOrUpdateSatisfactionSurveyTableAndFormInstance(SatisfactionSurveyTable satisfactionSurveyTable, Map items, List answerItem, boolean isSave) { + public void saveOrUpdateSatisfactionSurveyTableAndFormInstance(SatisfactionSurveyTable satisfactionSurveyTable, Map items, List answerItem) { this.saveOrUpdate(satisfactionSurveyTable, answerItem); - this.saveOrUpdateFormInstance(satisfactionSurveyTable, items, isSave); + this.saveOrUpdateFormInstance(satisfactionSurveyTable, items); } } Index: ssts-web/src/main/webapp/homepage/portalPage.jsp =================================================================== diff -u -r22697 -r22783 --- ssts-web/src/main/webapp/homepage/portalPage.jsp (.../portalPage.jsp) (revision 22697) +++ ssts-web/src/main/webapp/homepage/portalPage.jsp (.../portalPage.jsp) (revision 22783) @@ -9,6 +9,7 @@ <%@ page import="java.util.Date"%> <%@ include file="/common/taglibs.jsp"%> <%@page import="java.io.File" %> +<%@page import="com.forgon.disinfectsystem.entity.satisfactionsurvey.Satisfaction"%> <%long l = System.currentTimeMillis(); PortalPageAction portalPageAction = (PortalPageAction)SpringBeanManger.getBean("portalPageAction"); @@ -129,8 +130,9 @@ - + + @@ -168,7 +170,13 @@ + - + Index: ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableCustomFormHelper.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableCustomFormHelper.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableCustomFormHelper.js (revision 22783) @@ -0,0 +1,436 @@ +//满意度调查表自定义表单类(可以被继承,用来做通用的自定义表单) +var satisfactionSurveyCustomForm = { + + extObj: top.Ext, + + customItemElementObj: null, + + /** + * 设置ext对象 + * @param self_ext + */ + setExtObj: function (self_ext) { + this.extObj = self_ext; + }, + + /** + * 获取ext对象 + * @param self_ext + * @returns {*} + */ + getExtObj: function () { + return this.extObj; + }, + + /** + * 初始化customItemElementObj对象 + * @returns {null} + */ + getOrInitCustomItemElementObj: function () { + var me = this; + me.customItemElementObj = me.customItemElementObj ? me.customItemElementObj : new CustomItemElementObj(me.getExtObj()); + return me.customItemElementObj; + }, + + /** + * 把构建好的表单添加到对应的form中,重新渲染 + * @param customItems 自定义的表单元素结合 + * @param formId 要添加到哪个form + * @param config 表单的相关配置 + */ + buildSatisfactionSurveyCustomForm: function (customItems, formId, config) { + if (customItems.length > 0) { + var satisfactionSurveyForm = this.getExtObj().getCmp(formId); + satisfactionSurveyForm.add({ + id: 'myCustom', + xtype: "fieldset", + labelAlign: 'left', + title: config['title'] || "满意度自定义项", + layout: 'column', + autoHeight: true, + width: config['width'] || 670, + items: customItems + }); + satisfactionSurveyForm.doLayout(); + this.getExtObj().getCmp('myCustom').doLayout(); + } + }, + + /** + * 加载自定义的表单定义的表单元素 + * @param item 某个表单元素的数据(里面除了“showAnswer”属性其他都,这个属性很关键,其他属性都是FormDefinitionItem的属性) + * @param items 表单元素集合 + */ + loadInstanceItems: function (item, items) { + var me = this; + items.push(me.customItemElementObj.createCustomItemElement({ + hideElement: item.hideElement, + id: item.id, + name: item.name, + value: item.showAnswer, //自定义的表单实例的全部表单元素填写的数据 + allowBlank: item.requirement == '必填' ? false : true, + options: item.optionsJson, //单选或者多选配置的选项数据 + isTriggerItem: item.isTriggerItem, + type: item.type + })); + if (item.type === '多选') { //如果是都选的需要空一行为了美观 + items.push({ + columnWidth: 1, + xtype: "label", + html: ' ', + anchor: '95%' + }); + } + }, + + /** + * 初始化自定义表单(主要入口) + * @param formDefinition_id 自定义表单定义id + * @param formId 表单的id + * @param formInstance_id 自定义表单实例id + * @param config 自定义表单定义配置的项 + * @param callBackFn 初始化完要执行的回调函数 + */ + initCustomItems: function (formDefinition_id, formId, formInstance_id, config, callBackFn) { + var me = this; + config = config ? config : {}; + var para = {id: formDefinition_id}; + if (formInstance_id) { + para['formInstance_id'] = formInstance_id; + } + this.getExtObj().Ajax.request({ + url: WWWROOT + '/disinfectSystem/formDefinitionAction!loadFormDefinition.do', + params: para, + success: function (response, options) { + var result = me.getExtObj().decode(response.responseText); + if (result.success) { + var items = []; + var formInstanceItems = result.formInstance; //自定义表单实例的配置表单元素 + me.getOrInitCustomItemElementObj(); //初始化customItemElementObj + //如果存在formInstanceItems,则表示这个是从满意度调查页面打开的,所以加载formInstance的数据 + if (formInstanceItems) { + me.getExtObj().each(formInstanceItems, function (re) { + var item = re.definitionItem; + item['showAnswer'] = re.showAnswer; + satisfactionSurveyCustomForm.loadInstanceItems(item, items); + }); + } else { + //如果不存在,则表示这个是通过首页打开的,直接用自定义表单定义里面配置的表单元素 + var list = result.data.items; + me.getExtObj().each(list, function (item) { + satisfactionSurveyCustomForm.loadInstanceItems(item, items); + }); + } + me.buildSatisfactionSurveyCustomForm(items, formId, config); + if (callBackFn) { + callBackFn(); + } + } + }, + failure: function (response, options) { + showResultQM('系统加载出错,请稍候再试'); + } + }); + } +} + + +/** + * 自定义表单控件类,用于在模板使用了自定义表单,页面要加载出这个自定义表单 + * @constructor + */ +var CustomItemElementObj = function (extObj) { + var myExtObj = extObj || top.Ext4; + + /** + * 创建文本(私有方法) + */ + createText = function (configValue) { + return { + xtype: 'textfield', + columnWidth: .5, + labelWidth: 90, + fieldLabel: configValue.name, + id: 'configItemOption' + configValue.id, + name: 'configItemOption' + configValue.id, + allowBlank: configValue.allowBlank, + value: configValue.value + } + }; + + /** + * 创建单选框(私有方法) + */ + createSingleOption = function (configValue) { + var optionsArrays = new Array(); + if (configValue.options != "") { + var optionsJson = myExtObj.decode(configValue.options); + for (var j = 0; j < optionsJson.length; j++) { + var optionsArray = new Array(); + optionsArray.push(optionsJson[j].name); + optionsArrays.push(optionsArray); + } + } + + var combo = new myExtObj.form.field.ComboBox({ + xtype: 'combo', + columnWidth: 1, + labelWidth: 414, + fieldLabel: configValue.name, + id: 'configItemOption' + configValue.id, + name: 'configItemOption' + configValue.id, + valueField: 'value', + displayField: 'value', + value: configValue.value, + allowBlank: configValue.allowBlank, + editable: false, + forceSelection: true, + triggerAction: 'all', + queryMode: 'local', + store: new myExtObj.data.ArrayStore({ + fields: ['value'], + data: optionsArrays + }) + }); + return combo; + }; + + /** + * 创建多选(私有方法) + */ + createMultiOption = function (configValue) { + var id = configValue.id; + var options = configValue.options; //配置的项 + var value = myExtObj.isEmpty(configValue.value) ? '' : configValue.value; //勾选的值 + var optionsArray = new Array(); + optionsArray.push({ + id: 'configItemOption' + id, + name: 'configItemOption' + id, + xtype: 'hidden', + value: value + }); + + if (options != "") { + var optionsJson = myExtObj.decode(options); + for (var j = 0; j < optionsJson.length; j++) { + var option = optionsJson[j]; + var optionStr = JSON.stringify(option); + var checked = false; + if (value != null && value.indexOf(optionStr) != -1) { + checked = true; + } + optionsArray.push({ + columnWidth: 0.5, + labelWidth: 200, + name: 'cconfigItemOption' + id, // + fieldLabel: option.name, + xtype: 'checkbox', + checked: checked, + columnWidth: .5, + inputValue: optionStr, + listeners: { + change: function (thiz, checked) { + /** + * 点击事件需要联动隐藏域的值 + */ + var elementId = thiz.getName().substring(1); + var elementObj = myExtObj.getCmp(elementId); + if (!myExtObj.isEmpty(elementObj)) { + var oldElementValue = elementObj.getValue(); + var checkedValue = thiz.inputValue; + if (checked) { + if (oldElementValue.indexOf(checkedValue) == -1) { + oldElementValue += ","; + oldElementValue += checkedValue; + elementObj.setValue(oldElementValue); + } + }else { + var newValue = oldElementValue.replace("," + checkedValue, ''); + elementObj.setValue(newValue); + } + } + } + } + }); + } + } + return { + columnWidth: 1, + xtype: "fieldset", + title: configValue.name, + id: 'hideElement' + id, + layout: 'column', + hidden: configValue.hideElement, + autoHeight: true, + items: optionsArray + }; + }; + + /** + * 创建日期或者时间(私有方法) + * 日期的format是Y-m-d,时间的format是Y-m-d H:i + */ + createDateTime = function (configValue) { + return { + xtype: 'datefield', + columnWidth: .5, + labelWidth: 90, + fieldLabel: configValue.name, + id: 'configItemOption' + configValue.id, + name: 'configItemOption' + configValue.id, + format: configValue.format, + value: configValue.value, +// readOnly: true, +// editable: false, + allowBlank: configValue.allowBlank, + anchor: '95%' + }; + } + + /** + * 创建时间段(私有方法) + */ + createDateArea = function (configValue) { + var value = configValue.value; + if (value == null || value == '') { + value = '00:00'; + } + return { + xtype: 'textfield', + columnWidth: .5, + labelWidth: 90, + fieldLabel: configValue.name, + maxLength: '16', + id: 'configItemOption' + configValue.id, + name: 'configItemOption' + configValue.id, + regex: /^\d*:\d\d$/, + regexText: '请按照"小时:分钟"的格式填写', + allowBlank: configValue.allowBlank, + value: value, + anchor: '95%' + }; + }; + + /** + * 创建数字(私有方法) + */ + createNumber = function (configValue) { + return { + xtype: 'numberfield', + columnWidth: .5, + labelWidth: 90, + fieldLabel: configValue.name, + id: 'configItemOption' + configValue.id, + name: 'configItemOption' + configValue.id, + allowBlank: configValue.allowBlank, + allowDecimals: true, + value: configValue.value, + anchor: '95%' + }; + }; + + /** + * 创建文本框(私有方法) + */ + createTextArea = function (configValue) { + return { + xtype: 'textarea', + columnWidth: .9, + labelWidth: 90, + fieldLabel: configValue.name, + maxLength: '300', + id: 'configItemOption' + configValue.id, + name: 'configItemOption' + configValue.id, + allowBlank: configValue.allowBlank, + value: configValue.value, + anchor: '95%' + }; + }; + + /** + * 创建自定义表单的组件(公共方法) + */ + this.createCustomItemElement = function (configValue) { + var me = this; + configValue.hideElement = '是' === configValue.isTriggerItem && (myExtObj.isEmpty(configValue.value)) ? true : false; + var type = configValue.type; + if (type === '文本') { + return createText(configValue); + } + if (type === '文本框') { + return createTextArea(configValue); + } + if (type === '数字') { + return createNumber(configValue); + } + if (type === '时间') { + configValue.format = 'Y-m-d H:i'; + return createDateTime(configValue); + } + if (type === '日期') { + configValue.format = 'Y-m-d'; + return createDateTime(configValue); + } + if (type === '时间段') { + return createDateArea(configValue); + } + if (type === '单选') { + return createSingleOption(configValue); + } + if (type === '多选') { + return createMultiOption(configValue); + } + }; + + /** + * 选中的时候处理(公共方法) + * @param checkedValue 触发的表单元素 + * @param action 动作 + */ + this.handleCheckAction = function (checkedValue, action) { + var me = this; + if (checkedValue != null) { + var valueTriggerItemIds = checkedValue.valueTriggerItemIds; + me.triggerItemAction(valueTriggerItemIds, action); + } + }; + + this.triggerItemAction = function (valueTriggerItemIds, action) { + var eObj = myExtObj; + if (!eObj.isEmpty(valueTriggerItemIds)) { + var itemIdArray = valueTriggerItemIds.split(","); + var len = itemIdArray.length; + for (var n = 0; n < len; n++) { + var triggerItemId = itemIdArray[n]; + if (!eObj.isEmpty(triggerItemId)) { + var triggerItem = eObj.getCmp("hideElement" + triggerItemId); + if ("show" == action) { + triggerItem.show(); + continue; + } + var xtype = triggerItem.getXType(); + if (xtype == 'fieldset') { + triggerItem.items.each(function (fsItem) { + var itemType = fsItem.getXType(); + if (itemType == "panel") { + fsItem.items.each(function (item, index, length) { + item.setValue(false); + }); + } + else if (itemType == "hidden") { + fsItem.setValue(""); + } + }); + } + else if (xtype == 'panel') { + var panel = triggerItem; + panel.items.each(function (item, index, length) { + item.setValue(""); + }); + } + triggerItem.hide(); + } + } + } + } +} Index: ssts-satisfactionsurvey/src/main/java/com/forgon/disinfectsystem/satisfactionsurvey/service/SatisfactionSurveyTableManager.java =================================================================== diff -u -r22745 -r22783 --- ssts-satisfactionsurvey/src/main/java/com/forgon/disinfectsystem/satisfactionsurvey/service/SatisfactionSurveyTableManager.java (.../SatisfactionSurveyTableManager.java) (revision 22745) +++ ssts-satisfactionsurvey/src/main/java/com/forgon/disinfectsystem/satisfactionsurvey/service/SatisfactionSurveyTableManager.java (.../SatisfactionSurveyTableManager.java) (revision 22783) @@ -37,7 +37,6 @@ * @param satisfactionSurveyTable 满意度调查表实例对象 * @param items 前台传过来的参数对象(自定义表单实例) * @param answerItem 满意度调查表填写好的答案 - * @param isSave 保存还是更新 */ - void saveOrUpdateSatisfactionSurveyTableAndFormInstance(SatisfactionSurveyTable satisfactionSurveyTable, Map items, List answerItem, boolean isSave); + void saveOrUpdateSatisfactionSurveyTableAndFormInstance(SatisfactionSurveyTable satisfactionSurveyTable, Map items, List answerItem); } Index: ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableWinForm.js =================================================================== diff -u -r19062 -r22783 --- ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableWinForm.js (.../satisfactionSurveyTableWinForm.js) (revision 19062) +++ ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableWinForm.js (.../satisfactionSurveyTableWinForm.js) (revision 22783) @@ -1,438 +1,9 @@ -function setSatisfaction(nodeId, thiz){ - var clickNode = satisfactionSurveyWinTree.getNodeById(nodeId); - var satisfactionVal = thiz.checked?thiz.value:""; - clickNode.attributes.satisfaction=satisfactionVal; - var optionArr = top.document.getElementsByName("option_"+nodeId); - for(var i=0,len=optionArr.length;i"; - }; - satisfactionSurveyWinTree = new top.Ext.tree.ColumnTree({ - rootVisible:false, - autoScroll:true, - bodyStyle : 'border:1px solid #afd7af', - containerScroll : true, - height:210, - columns:[{ - header:'序号', - width:80, - dataIndex:'seqNum' - },{ - header:'项目内容', - width:310, - dataIndex:'content' - },{ - header:'满意度', - dataIndex:'satisfaction', - hidden : true - },{ - header:'满意', - width:40, - dataIndex:'option_1', - renderer:function(v,p,record){ - if(record.leaf){ - return createSatisfactionCheckBox(record, "SATISFACTION"); - } - } - },{ - header:'较满意', - width:50, - dataIndex:'option_2', - renderer:function(v,p,record){ - if(record.leaf){ - return createSatisfactionCheckBox(record, "MORESATISFACTION"); - } - } - },{ - header:'基本满意', - width:60, - dataIndex:'option_3', - renderer:function(v,p,record){ - if(record.leaf){ - return createSatisfactionCheckBox(record, "BASICSATISFACTION"); - } - } - },{ - header:'不太满意', - width:60, - dataIndex:'option_4', - renderer:function(v,p,record){ - if(record.leaf){ - return createSatisfactionCheckBox(record, "NOTVERYSATISFACTION"); - } - } - },{ - header:'不满意', - width:50, - dataIndex:'option_5', - renderer:function(v,p,record){ - if(record.leaf){ - return createSatisfactionCheckBox(record, "NOSATISFACTION"); - } - } - }], - - loader: new top.Ext.tree.TreeLoader({ - url : WWWROOT + '/disinfectSystem/satisfactionsurvey/satisfactionSurveyTableAction!loadSatisfactionSurveyTableItem.do', - baseParams : {id:'',templateId:templateId}, - uiProviders:{ - 'col': top.Ext.tree.ColumnNodeUI - } - }), - - root: new top.Ext.tree.AsyncTreeNode({ - text:'满意度调查项' - }) - }); - - var form = new top.Ext.FormPanel({ - id : 'statisfactionSurveyForm', - frame : true, - border : 0, - labelSeparator : ':', - bodyStyle : 'padding:5px 5px 0px 5px', - width : 670, - labelAlign:'right', - height : 600, - autoScroll:true, - // autoHeight : true, - items : [{ - xtype:"fieldset", - layout:'column', - title :'基础信息', - height:300, - items:[{ - layout : 'column', - items : [{ - xtype : 'hidden', - name : 'id', - id : 'id' - },{ - xtype : 'hidden', - name : 'treeItemData', - id : 'treeItemData' - },{ - xtype : 'hidden', - name : 'satisfactionSurveyTemplateId', - id : 'satisfactionSurveyTemplateId', - value:templateId - },{ - columnWidth : 1, - layout : 'form', - hideLabels : true, - items : [{ - xtype : 'textfield', - fieldLabel : '满意度调查表名称', - id : 'satisfactionSurveyTemplateName', - name : 'satisfactionSurveyTemplateName', - allowBlank : false, - style:'color:red;font-weight: bold;', - readOnly:true, - value:templateName, - cls:'fieldReadOnlyNoRemove', - anchor : '98%' - }] - },{ - columnWidth : 1, - layout : 'form', - labelWidth : 100, - items : [{ - xtype : 'textarea', - fieldLabel : '描述说明', - id : 'instructions', - name : 'instructions', -// style:'margin-left:90px;text-align:center;', - maxLength : 2000, - height : 100, - allowBlank : true, - readOnly:true, - value:instructions, - cls:'fieldReadOnlyNoRemove', - anchor : '90%' - }] - },{ - columnWidth : 0.5, - layout : 'form', - labelWidth : 100, - items : [{ - xtype : 'textfield', - fieldLabel : '用户名', - maxLength : '16', - id : 'userName', - name : 'userName', - allowBlank : false, - anchor : '98%', - readOnly:true, - value:userName, - cls:'fieldReadOnlyNoRemove' - }] - },{ - columnWidth : 0.5, - layout : 'form', - labelWidth : 100, - items : [{ - xtype : 'textfield', - fieldLabel : '填表时间', - maxLength : '16', - id : 'surveyDateStr', - name : 'surveyDateStr', - allowBlank : false, - anchor : '98%', - readOnly:true, - value:currentDate, - cls:'fieldReadOnlyNoRemove' - }] - },{ - columnWidth : 1, - layout : 'form', - labelWidth : 100, - items : [{ - xtype : 'textfield', - fieldLabel : '所属科室', - maxLength : '100', - id : 'depart', - name : 'depart', - allowBlank : false, - anchor : '98%', - readOnly:true, - value:departName, - cls:'fieldReadOnlyNoRemove' - }] - },{ - columnWidth : 1, - layout : 'form', - labelWidth : 100, - items : [{ - xtype : 'textarea', - fieldLabel : '意见或建议', - id : 'remark', - name : 'remark', - maxLength : 200, - height : 80, - allowBlank : true, - anchor : '90%' - }] - }] - }] - },{ - xtype:"fieldset", - // autoScroll:true, - title :'满意度调查项', - height:250, - items:[ - satisfactionSurveyWinTree - ] - }], - buttonAlign :'center', - buttons : [{ - text : '保存', - id :'saveBtn', - handler : function(){ - if(!form.getForm().isValid()){ - showResult('请正确填写表单各值'); - return false; - } - - //获取columnTreePanel数据 - var treeData = getItemTreeData(satisfactionSurveyWinTree); - if(treeData == false){ - return false; - }else if(treeData==""){ - showResult('满意度调查项不能为空!'); - return false; - } - top.Ext.getCmp("treeItemData").setValue("["+treeData+"]"); - - var b = this; - top.Ext.MessageBox.confirm("请确认","是否提交满意调查表信息?",function(btn) { - if(btn=='yes') { - b.disable(); - if(submitForm(form,window,callBack)==false){ - b.enable(); - } - } - }); - } - },{ - text : '取消', - handler : function() { - window.close(); - } - }] - }); - - var window = new top.Ext.Window( { - id : 'satisfactionSurveyApplicationWin', - layout : 'border', - title : '满意度调查表', - width : 710, - height : 710, - border : false, - plain : true, - modal :true, - items : [{ - region:'center', - width : 200, - layout :'fit', - items:[form] - }] - }); - satisfactionSurveyCustomForm.initCustomItems(formDefinition_id, 'statisfactionSurveyForm'); - - satisfactionSurveyWinTree.root.on("load",function(){ - satisfactionSurveyWinTree.expandAll(); - }); - window.show(); -} - -function replaceStr(str){ - var replaceV = ""; - if(str){ - replaceV = str.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,"\""); - } - return replaceV; -} - -/** - */ -function getItemTreeData(satisfactionSurveyWinTree){ - var rootNode = satisfactionSurveyWinTree.getRootNode(); - var valArr = new Array(); - var isCheckedAll = true, alertTips = ""; - rootNode.eachChild(function(pNode){ - if(!isCheckedAll){ - return false; - } - valArr.push("{id:'"); - valArr.push("'"); - valArr.push(",content:'"); - valArr.push(replaceStr(pNode.attributes.content)); - valArr.push("'"); - if(!pNode.isLeaf()){//父节点 - valArr.push(",children:["); - pNode.eachChild(function(cNode){ - if(!cNode.attributes.satisfaction){ - isCheckedAll = false; - alertTips = "请为“"+cNode.attributes.content+"”内容项选择满意度!"; - return false; - } - valArr.push("{id:'"); - valArr.push("'"); - valArr.push(",satisfaction:'"); - valArr.push(cNode.attributes.satisfaction); - //如果选择了不满意,需要写明为啥不满意 - if(pNode.attributes.satisfaction=="NOSATISFACTION"){ - var adviser = Ext.get('remark').getValue(); - if(adviser==null||adviser.length==0||adviser.trim().length==0){ - isCheckedAll = false; - alertTips = "请在意见或建议栏填写不满意的具体原因,以便改进!"; - return false; - } - } - //如果选择了不太满意,需要写明为啥不太满意 - else if(pNode.attributes.satisfaction=="NOTVERYSATISFACTION"){ - var adviser = Ext.get('remark').getValue(); - if(adviser==null||adviser.length==0||adviser.trim().length==0){ - isCheckedAll = false; - alertTips = "请在意见或建议栏填写不太满意的具体原因,以便改进!"; - return false; - } - } - valArr.push("'"); - valArr.push(",content:'"); - valArr.push(replaceStr(cNode.attributes.content)); - valArr.push("'}"); - if(!cNode.isLast()){ - valArr.push(","); - } - }); - valArr.push("]"); - }else{ - if(!pNode.attributes.satisfaction){ - isCheckedAll = false; - alertTips = "请为“"+pNode.attributes.content+"”内容项选择满意度!"; - return false; - } - valArr.push(",satisfaction:'"); - valArr.push(pNode.attributes.satisfaction); - //如果选择了不满意,需要写明为啥不满意 - if(pNode.attributes.satisfaction=="NOSATISFACTION"){ - var adviser = Ext.get('remark').getValue(); - if(adviser==null||adviser.length==0||adviser.trim().length==0){ - isCheckedAll = false; - alertTips = "请在意见或建议栏填写不满意的具体原因,以便改进!"; - return false; - } - } - //如果选择了不太满意,需要写明为啥不太满意 - else if(pNode.attributes.satisfaction=="NOTVERYSATISFACTION"){ - var adviser = Ext.get('remark').getValue(); - if(adviser==null||adviser.length==0||adviser.trim().length==0){ - isCheckedAll = false; - alertTips = "请在意见或建议栏填写不太满意的具体原因,以便改进!"; - return false; - } - } - valArr.push("'"); - } - valArr.push("}"); - - if(!pNode.isLast()){ - valArr.push(","); - } - }); - if(!isCheckedAll){ - showResult(alertTips); - return false; - } - return valArr.join(""); -} - -function submitForm(form,window,callBack){ - form.form.submit({ - url : WWWROOT + '/disinfectSystem/satisfactionsurvey/satisfactionSurveyTableAction!saveSatisfactionSurveyTable.do', - method : 'POST', - waitMsg : '正在保存数据,请稍候', - waitTitle : '提交表单', - success : function(form, action) { - window.close(); - if(action.result.success){ - showResult("保存成功!"); - }else{ - showResult("保存失败!"); - } - callBack(); - }, - failure : function(form, action) { - showResult(action.failureType); - callBack(); - } - }); - return true; -} - - - function rendererHrefLink(v, p, record){ var instructions = record.data['instructions']; instructions = instructions.replace('\n',''); //替换回车符,避免js函数的参数传值导致代码执行不成功 instructions = instructions.replace('\r',''); var formDefinition_id = Ext.isEmpty(record.data['formDefinition_id']) ? null : record.data['formDefinition_id']; - return ""+v+""; - //showSatisfactionSurveyTableWin(poId, name, instructions, function(){reloadSatisfactionSurveyTemplateTableTips()}); + return ""+v+""; } /** @@ -510,3 +81,34 @@ }); } } + + + + +/** + * 添加“满意度调查表实例”. + * @param formDefinition_id 自定义表单定义 + * @param templateId 满意度调查表定义id + * @param templateName 满意度调查表名称 + * @param instructions 满意度调查表说明 + * @param callBack 添加完成的回调函数 + */ +function showSatisfactionSurveyTableWin(formDefinition_id, templateId, templateName, instructions, callBack){ + tipsWindow.close(); + addSatisfactionSurveyTable('', false, templateId, callBack); +} + + + + + + + + + + + + + + + Fisheye: Tag 22783 refers to a dead (removed) revision in file `ssts-web/src/main/webapp/disinfectsystem/satisfactionsurvey/satisfactionSurveyTableWinCustomForm.js'. Fisheye: No comparison available. Pass `N' to diff?