/** * 只读预览功能 @Methods Name forLook @Create In 2009-3-13 By sa * * @param request * @return String */ private String forLook(HttpServletRequest request) { String json = ""; String id = request.getParameter("id"); String modelName = request.getParameter("modelname"); String panelName = request.getParameter("panelname"); PagePanel panel = pagePanelService.findPagePanel(panelName); List<PagePanelColumn> pagePanelColumns = pageManager.getUserPagePanelColumn(panelName); Map<String, Object> dataMap = null; if (StringUtils.isNotBlank(id)) { List<Map<String, Object>> listMap = pageManager.getPagePanelDataForLook(modelName, panelName, id); if (listMap != null && !listMap.isEmpty()) { if (panel.getXtype().getName().equals("form")) { dataMap = listMap.iterator().next(); json = CoderForLook.encode(pagePanelColumns, dataMap, true); } else if (panel.getXtype().getName().equals("editorgrid")) { int total = listMap.size(); json = CoderForList.encode(pagePanelColumns, listMap, Long.valueOf(total)); } } } else { dataMap = pageManager.getPagePanelDataForAdd(panelName); json = CoderForLook.encode(pagePanelColumns, dataMap, false); } return json; }
private String genPagePanelJson(PageModelPanel pmp) { String json = ""; PagePanel panel = pmp.getPagePanel(); String divFloat = pmp.getDivFloat(); String fcolumnPropName = ""; String pcolumnPropName = ""; json += "{"; json += "\"panelname\":\"" + panel.getName() + "\","; json += "\"title\":\"" + panel.getTitle() + "\","; if (panel.getGroupFlag() != null && panel.getGroupFlag().intValue() == 0) { json += "\"panelTableName\":\"" + panel.getSystemMainTable().getTableCnName() + "\","; json += "\"clazz\":\"" + panel.getSystemMainTable().getClassName() + "\","; // 如果model根面板属于可编辑面板,如财务面板改成editorGrid,它就引用配置项 if (panel.getXtype().getName().equalsIgnoreCase("editorgrid") || panel.getXtype().getName().equalsIgnoreCase("grid")) { SystemMainTable subTable = panel.getSystemMainTable(); List<PageModelPanelTable> pmpts = this.pageModelService.findPageModelPanelTableBySub(pmp.getPageModel(), panel, subTable); for (PageModelPanelTable pmpt : pmpts) { // 配置项面板 PagePanel parentPanel = pmpt.getParentPagePanel(); // 配置项父表 SystemMainTable parentTable = parentPanel.getSystemMainTable(); SystemMainTableColumn parentPanelTablePColumn = pmpt.getParentPanelTablePColumn(); // ConfigItem$id pcolumnPropName = parentTable.getTableName() + "$" + parentPanelTablePColumn.getPropertyName(); SystemMainTableColumn subFc = pmpt.getSubPanelTableFColumn(); fcolumnPropName = subFc.getPropertyName(); } } } json += "\"fcolumnName\":\"" + fcolumnPropName + "\","; json += "\"pcolumnName\":\"" + pcolumnPropName + "\","; json += "\"xtype\":\"" + panel.getXtype().getName() + "\","; json += "\"groupFlag\":\"" + panel.getGroupFlag() + "\","; Integer readonlyFlag = pmp.getReadonly(); if (readonlyFlag == null) readonlyFlag = 0; json += "\"readonlyFlag\":\"" + readonlyFlag + "\","; json += "\"queryFlag\":\"" + panel.getQueryFlag() + "\","; json += "\"divFloat\":\"" + divFloat + "\","; json += "\"order\":\"" + pmp.getOrder() + "\""; Set<PagePanelRelation> childpprs = panel.getChildPagePanels(); if (!childpprs.isEmpty()) { // 遍历分组面板下面的面板 json += ",\"childPagePanels\":["; for (PagePanelRelation ppr : childpprs) { json += this.genPagePanelJson(ppr); json += ","; } json = json.substring(0, json.length() - 1); json += "]"; } json += "}"; return json; }
/** * 获取单Form面板元数据 @Methods Name forSaveSingleFormForLook @Create 2009-4-20 By daijf * * @param request * @return @ReturnType String */ private String forSaveSingleFormForLook(HttpServletRequest request) { String json = ""; String id = request.getParameter("id"); String panelName = request.getParameter("panelname"); PagePanel panel = pagePanelService.findPagePanel(panelName); SystemMainTable smt = panel.getSystemMainTable(); String tableName = smt.getTableName(); String className = smt.getClassName(); Class clazz = null; try { clazz = Class.forName(className); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<PagePanelColumn> pagePanelColumns = pageManager.getUserPagePanelColumn(panelName); Map<String, Object> dataMap = null; if (StringUtils.isNotBlank(id)) { if (panel.getXtype().getName().equals("form")) { Object obj = service.find(clazz, id, true); dataMap = metaDataManager.getEntityDataForLook(obj, tableName); json = CoderForLook.encode(pagePanelColumns, dataMap, true); } else { json = null; } } else { dataMap = pageManager.getPagePanelDataForAdd(panelName); json = CoderForLook.encode(pagePanelColumns, dataMap, false); } return json; }
public void initPagePanelBtn(PagePanel pagePanel) { // PagePanelType xtype = super.get(PagePanelType.class, pagePanel.getXtype().getId()); PagePanelType xtype = pagePanel.getXtype(); xtype = super.get(PagePanelType.class, xtype.getId()); String xtypeName = xtype.getName(); if (xtypeName.equals("editorgrid")) { // 可编辑表单 PagePanelBtn addButton = new PagePanelBtn(); addButton.setBtnName("添加"); addButton.setMethod("addByColumn"); addButton.setImageUrl("add"); addButton.setPagePanel(pagePanel); super.save(addButton); PagePanelBtn delButton = new PagePanelBtn(); delButton.setBtnName("删除"); delButton.setMethod("removeByColumn"); delButton.setImageUrl("remove"); delButton.setPagePanel(pagePanel); super.save(delButton); PagePanelBtn saveButton = new PagePanelBtn(); saveButton.setBtnName("保存"); saveButton.setMethod("saveForGridPanel"); saveButton.setImageUrl("save"); saveButton.setPagePanel(pagePanel); super.save(saveButton); // PagePanelBtn upLoadButton = new PagePanelBtn(); // upLoadButton.setBtnName("上传"); // upLoadButton.setMethod("upload"); // upLoadButton.setImageUrl("upload"); // upLoadButton.setPagePanel(pagePanel); // super.save(upLoadButton); // // PagePanelBtn exportButton = new PagePanelBtn(); // exportButton.setBtnName("导出"); // exportButton.setMethod("export"); // exportButton.setImageUrl("export"); // exportButton.setPagePanel(pagePanel); // super.save(exportButton); } else if (xtypeName.equals("form")) { PagePanelBtn saveButton = new PagePanelBtn(); saveButton.setBtnName("保存"); saveButton.setMethod("saveForFormPanel"); saveButton.setImageUrl("save"); saveButton.setPagePanel(pagePanel); super.save(saveButton); PagePanelBtn resetButton = new PagePanelBtn(); resetButton.setBtnName("重置"); resetButton.setMethod("resetPanel"); resetButton.setImageUrl("reset"); resetButton.setPagePanel(pagePanel); super.save(resetButton); } }
private String genPagePanelJson(PagePanelRelation pmp) { String json = ""; PagePanel panel = pmp.getPagePanel(); String fcolumnPropName = ""; String pcolumnPropName = ""; json += "{"; json += "\"panelname\":\"" + panel.getName() + "\","; json += "\"title\":\"" + panel.getTitle() + "\","; if (panel.getGroupFlag() != null && panel.getGroupFlag().intValue() == 0) { json += "\"panelTableName\":\"" + panel.getSystemMainTable().getTableCnName() + "\","; json += "\"clazz\":\"" + panel.getSystemMainTable().getClassName() + "\","; List<PageGroupPanelTable> list = this.pgps.findGroupPanelTableBySub(pmp.getParentPagePanel(), panel); PageGroupPanelTable pgpt = null; if (list != null && !list.isEmpty()) { pgpt = list.iterator().next(); } if (pgpt != null) { SystemMainTableColumn fcolumn = pgpt.getSubPanelTableFColumn(); fcolumnPropName = fcolumn.getPropertyName(); SystemMainTable parentPanelTable = pgpt.getParentPanelTable(); String pptableName = parentPanelTable.getTableName(); SystemMainTableColumn pc = pgpt.getParentPanelTablePColumn(); pcolumnPropName = pc.getPropertyName(); pcolumnPropName = pptableName + "$" + pcolumnPropName; } } json += "\"fcolumnName\":\"" + fcolumnPropName + "\","; json += "\"pcolumnName\":\"" + pcolumnPropName + "\","; json += "\"xtype\":\"" + panel.getXtype().getName() + "\","; Integer readonlyFlag = pmp.getReadonly(); if (readonlyFlag == null) readonlyFlag = 0; json += "\"readonlyFlag\":\"" + readonlyFlag + "\","; json += "\"groupFlag\":\"" + panel.getGroupFlag() + "\","; json += "\"queryFlag\":\"" + panel.getQueryFlag() + "\","; json += "\"order\":\"" + pmp.getOrder() + "\""; Set<PagePanelRelation> childpprs = panel.getChildPagePanels(); if (!childpprs.isEmpty()) { json += ",\"childPagePanels\":["; for (PagePanelRelation ppr : childpprs) { json += this.genPagePanelJson(ppr); json += ","; } json = json.substring(0, json.length() - 1); json += "]"; } json += "}"; return json; }