diff --git a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar index 92c58616..8067cc50 100644 Binary files a/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar and b/com.actionsoft.apps.coe.pal/lib/com.actionsoft.apps.coe.pal.jar differ diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/PALRepositoryQueryAPIManager.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/PALRepositoryQueryAPIManager.java index 9d3de3bb..ba9f266e 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/PALRepositoryQueryAPIManager.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/PALRepositoryQueryAPIManager.java @@ -99,6 +99,8 @@ import com.actionsoft.exception.AWSException; import com.actionsoft.i18n.I18nRes; import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.api.AppAPI; +import com.actionsoft.sdk.local.api.BOAPI; +import com.actionsoft.sdk.local.api.BOQueryAPI; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -3631,6 +3633,17 @@ public class PALRepositoryQueryAPIManager { } + /** + * 流程发布门户详情页面(移动端) + * + * @return + */ + public String getPublishMobilePortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish) { + return getPublishMobilePortalHtml(uc, uuid, taskId, checkPublish, true); + } + + + /** * 流程发布门户详情页面 * @@ -3695,6 +3708,82 @@ public class PALRepositoryQueryAPIManager { return web.getPortalDesignerHtml(uuid, upVisit, taskId);// 返回页面 } + + + + + /** + * 流程发布门户详情页面 + * + * @return + */ + public String getPublishMobilePortalHtml(UserContext uc, String uuid, String taskId, boolean checkPublish, boolean upVisit) { + + //权限校验 +// if (!CoeCooperationAPIManager.getInstance().hasRepositoryPermision(uuid)) { +// return AlertWindow.getWarningMessagePage("打开失败", "无该文件查看权限"); +// } + + //三员管理,文件密级权限校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ + CoeProcessLevelWeb web = new CoeProcessLevelWeb(uc); + ResponseObject responseObject = web.checkFilePemission(uuid); + if (responseObject.isErr()){ + return AlertWindow.getWarningMessagePage("打开失败", responseObject.getMsg()); + } + } + + PALRepositoryModel model = PALRepositoryCache.getCache().get(uuid); + if (model == null) { + throw new AWSException("该流程未找到,打开失败"); + } + if ("default".equals(model.getMethodId())) { + throw new AWSException("文件夹类型不支持打开"); + } + if (checkPublish) { + if (!model.isPublish()) { + throw new AWSException("该流程当前状态为未发布状态,不允许打开"); + } + } + + // 新的权限校验,若是该模型已发布,按照权限范围表中的权限控制是否可访问,若是该模型尚未发布(例如在发布过程中、已停用等),则不进行权限控制,都可访问 + if (model.isPublish()) { + if (!hasAccessPortalDesignerPerm(uc, model)) { + return AlertWindow.getWarningMessagePage("打开失败", "无该文件查看权限"); + } + } + + if (UtilString.isEmpty(taskId)) {// 停用或已发布状态查询流程手册 + taskId = getProcessReportTaskId(model); + } + CoeDesignerWeb web = new CoeDesignerWeb(uc); + // 操作行为日志记录 + if (SDK.getAppAPI().getPropertyBooleanValue(CoEConstant.APP_ID, "IS_RECORD_OP_LOG", false)) { + CoEOpLogAPI.auditOkOp(uc, CoEOpLogConst.MODULE_CATEGORY_REPOSITORY, CoEOpLogConst.OP_ACCESS, CoEOpLogConst.INFO_REPOSITORY_ACCESS); + } + + + + + BOAPI boAPI = SDK.getBOAPI(); + BOQueryAPI BoQuAPI = boAPI.query("BO_ACT_EXPENSE", true); + BoQuAPI.addQuery("APPLYUSER in ('admin','test')", null); + BoQuAPI.addQuery("user = ","3"); + List lists = BoQuAPI.list(); + for (BO bo:lists){ + String bindid=bo.getString("bindid");//获取流程实例ID + String msg= bo.getString("MSG");//MSG是大文本类型,且UI组件是HTML排版 + System.out.println("输出MSG的值为:"+msg); + String amount= bo.getString("AMOUNT");//AMOUNT是数值类型,且UI组件是货币 + System.out.println("输出AMOUNT的值为:"+amount); + } + + return web.getMobilePortalDesignerHtml(uuid, upVisit, taskId);// 返回页面 + } + + + + public boolean hasAccessPortalDesignerPerm(UserContext uc, PALRepositoryModel model) { String newBoName = "BO_ACT_PUBLISH_PERM_SCOPE"; BO bo = SDK.getBOAPI().query(newBoName).addQuery("PALVERSIONID=", model.getVersionId()).detail(); diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java index 4f03af71..83297c7d 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/web/CoeDesignerWeb.java @@ -3310,6 +3310,458 @@ public class CoeDesignerWeb extends ActionWeb { } + + + + + + + + /** + * 门户流程详情详情 (移动端) + * @param rUUID 流程ID + * @param upVisit 记录访问量+1,true:记录 ;false:不记录 + * @param taskId 流程手册id + * @return + */ + public String getMobilePortalDesignerHtml(String rUUID, boolean upVisit, String taskId) { + String processDefId = ""; + Map macroLibraries = new HashMap(); + macroLibraries.put("selectedElementId", ""); + macroLibraries.put("js", ""); + PALRepositoryModelImpl plModel = (PALRepositoryModelImpl) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(rUUID); + + if (plModel == null) { + return AlertWindow.getNotFoundMessagePage("未找到文件", "该文件已被删除"); + } + + macroLibraries.put("taskId", taskId); + // 增加三员管理模式taskid为new,change判断 + if ("process".equals(plModel.getMethodCategory()) && !UtilString.isEmpty(taskId) && !"submit_create".equals(taskId) && !"new".equals(taskId) && !"change".equals(taskId)) { + macroLibraries.put("outputFileName", plModel.getName() + ".doc"); + macroLibraries.put("taskId", taskId); + // 压缩包名称 和 手册模板 + OutputTaskModel taskModel = new OutputTask().getTaskReportById(taskId); + if(taskModel!=null){ + // 压缩包名称 + macroLibraries.put("taskName", taskModel.getTaskName() + ".zip"); + OutputAppProfile appFile = OutputAppManager.getProfile(taskModel.getProfileId()); + // 手册模板(com.actionsoft.apps.coe.pal.output.pr) + macroLibraries.put("taskProfile", appFile.getAppContext().getId()); + } + } + + String type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; + if (plModel.getMethodId() != null && plModel.getMethodId().indexOf(CoeDesignerConstant.DESIGNER_DIFINITION_BPMN) != -1) { + type = CoeDesignerConstant.DESIGNER_DIFINITION_BPMN; + } else { + type = CoeDesignerConstant.DESIGNER_DIFINITION_DEFAULT; + } + + boolean isCorrelateBpms = PALRepositoryQueryAPIManager.getInstance().isCorrelateBpms(plModel.getId(), true); + macroLibraries.put("isMarked", false); + //默认排序 + List defaultAttrSort; + if (CoeDesignerConstant.DESIGNER_DIFINITION_BPMN.equals(type)) { + // 删除与BPMS关联的无效关联关系 + CoeProcessLevelUtil.deleteInvalidCorrelate(plModel.getId()); + if (isCorrelateBpms) { + processDefId = PALRepositoryQueryAPIManager.getInstance().queryBpmsProcessDefIdByPalId(plModel.getId(), true); + } else { + processDefId = ""; + } + getBpmnDesginerUI(plModel, macroLibraries, true, true); + defaultAttrSort = getBpmnParams(plModel, processDefId, macroLibraries); + macroLibraries.put("isMarked", CoeProcessLevelUtil.hasMarked(plModel.getId())); + } else { + getCoeDesginerUI(plModel, macroLibraries, true, true); + defaultAttrSort = getCoeParams(plModel, macroLibraries); + } + int state = 0;// 版本状态:设计、运行、停用 + if (isCorrelateBpms) { + ProcessDefinition definition = ProcessDefCache.getInstance().get(processDefId); + if (definition != null) { + state = definition.getVersionStatus(); + } + } + macroLibraries.put("BPMNSupport", AWSServerEngineConfiguration.getEngineBPMNSupport()); + macroLibraries.put("BPMNLevel0", AWSServerEngineConfiguration.getEngineBPMNLevel0()); + macroLibraries.put("BPMNLevel1", AWSServerEngineConfiguration.getEngineBPMNLevel1()); + macroLibraries.put("BPMNLevel2", AWSServerEngineConfiguration.getEngineBPMNLevel2()); + String userUrl = SDK.getPortalAPI().getUserPhoto(_uc, _uc.getUID()); + getMoreSharpe(plModel.getMethodId(), plModel.getId(), macroLibraries);// 获取更多图形 + macroLibraries.put("ver", 0); + macroLibraries.put("methodId", plModel.getMethodId()); + macroLibraries.put("sid", _uc.getSessionId()); + macroLibraries.put("wsId", plModel.getWsId()); + macroLibraries.put("uuid", rUUID);// definition的UUID + macroLibraries.put("parentChartId", plModel.getParentId()); + macroLibraries.put("uid", _uc.getUID()); + macroLibraries.put("userUrl", userUrl); + macroLibraries.put("userName", _uc.getUserModel().getUserName()); + macroLibraries.put("schema", getSchema(plModel.getId(), plModel.getMethodId(), PALMethodUtil.getCustom(plModel.getMethodId(), plModel.getId()))); + macroLibraries.put("sessionId", _uc.getSessionId()); + macroLibraries.put("fileName", ShapeUtil.replaceBlank(plModel.getName())); + macroLibraries.put("typeName", I18nRes.findValue(CoEConstant.APP_ID, plModel.getMethodCategory()) + "图"); + macroLibraries.put("openType", 0); + macroLibraries.put("teamId", ""); + macroLibraries.put("perms", "");// 该流程权限(w,d,v) + macroLibraries.put("filePerms", "");// 所有具有权限的流程Id + macroLibraries.put("isPublish", plModel.isPublish()); + CoeUserModel userModel = (CoeUserModel) CoeUserDaoFactory.createUser().getInstanceByUserId(_uc.getUID()); + boolean isAdmin = (userModel != null && (userModel.getIsAdmin() == 1)); + macroLibraries.put("isAdmin", isAdmin); + // 更多特性权限 + String moreAttrRight = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "MOREATTR_RIGHT");// 1普通用户有设置更多特性权限, + if ("2".equals(moreAttrRight)) {// 只有admin显示 + if ("admin".equals(_uc.getUID())) { + macroLibraries.put("moreAttrRight", true); + } else { + macroLibraries.put("moreAttrRight", false); + } + } else if ("0".equals(moreAttrRight)) {// 0只有管理员用户有权限 + if (isAdmin) {// 管理员用户 + macroLibraries.put("moreAttrRight", true); + } else{// 普通用户 + macroLibraries.put("moreAttrRight", false); + } + } else { + macroLibraries.put("moreAttrRight", true); + } + // 自动保存 + String isSysAutoSave = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "SYS_AUTOSAVE"); + macroLibraries.put("isAutoSave", isSysAutoSave); + macroLibraries.put("checkoutTip", ""); + macroLibraries.put("isView", true);// 是否只读打开 + + // 是否允许用户自定义模板,0:不允许;1:允许。 + AppAPI appApi = SDK.getAppAPI(); + String isCustomDefine = appApi.getProperty(CoEConstant.APP_ID, CoEConstant.PROPERTY_CUSTOM_DEFINE_SCHEMA); + macroLibraries.put("isCustomDefine", isCustomDefine); + macroLibraries.put("openAppType", "0"); + + macroLibraries.put("editable", "0"); + + if (plModel.isPublish()) { + long viewCount = plModel.getViewCount(); + plModel.setViewCount(viewCount + 1); + PALRepository dao = new PALRepository(); + dao.update(plModel); + } + + getDesginerDefaultParams(macroLibraries);// 获取默认参数配置 + + macroLibraries.put("usersPhoto", ""); + macroLibraries.put("userNum", ""); + DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); + Map> shapeMap = relationShapeCache.getShapemap(); + boolean isExistCopy = shapeMap.get(_uc.getUID()) != null; + boolean isAppearCopy = shapeMap.get(_uc.getUID()) == null || shapeMap.get(_uc.getUID()).get("shapeCopyContent") == null; + // 默认为定义复制 + macroLibraries.put("isExistCopy", isExistCopy); + macroLibraries.put("isAppearCopy", isAppearCopy); + + macroLibraries.put("diagram", ""); + macroLibraries.put("state", state); + // DockBtnBar中的各功能是否显示 + macroLibraries.put("attributeView", ""); + macroLibraries.put("messageView", ""); + macroLibraries.put("printView", ""); + macroLibraries.put("publishView", ""); + + String riskStyle = "display:none;"; + // risk应用已下架 +// if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.risk") && SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.risk")) { +// riskStyle = ""; +// } +// if (plModel.getMethodId().equals("process.epc") || plModel.getMethodId().equals("process.bpmn2") || plModel.getMethodId().equals("process.flowchart")) { +// riskStyle = UtilString.isEmpty(riskStyle) ? "" : "display:none;"; +// } else { +// riskStyle = "display:none;"; +// } + macroLibraries.put("riskStyle", riskStyle); + String processOnIsInstall = "false"; + if (SDK.getAppAPI().isInstalled("com.actionsoft.apps.coe.pal.processon")) { + processOnIsInstall = "true"; + } + String processOnIsActive = "false"; + if (SDK.getAppAPI().isActive("com.actionsoft.apps.coe.pal.processon")) { + processOnIsActive = "true"; + } + macroLibraries.put("processOnIsInstall", processOnIsInstall); + macroLibraries.put("processOnIsActive", processOnIsActive); + + + JSONObject relationShapeIds = new JSONObject(); + JSONObject relationShapeModels = new JSONObject(); + + + + String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(_uc, plModel.getId()); + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + for (String id: elements.keySet()) { + JSONObject shapeObj = elements.getJSONObject(id); + String name = shapeObj.getString("name"); + if ("linker".equals(name)) { + continue; + } + Iterator modelIterator = DesignerShapeRelationCache.getByShapeId(plModel.getId(), id); + if (modelIterator != null) { + while (modelIterator.hasNext()) { + DesignerShapeRelationModel shapeRelationModel = modelIterator.next(); + PALRepositoryModel relationPalModel = PALRepositoryCache.getCache().get(shapeRelationModel.getRelationFileId()); + if (relationPalModel != null) { + relationShapeIds.put(shapeRelationModel.getRelationShapeId(), shapeRelationModel); + } + } + } + Map map = PALRepositoryQueryAPIManager.getInstance().queryRepositoryShapeAttributeById(plModel.getId(), id, shapeObj, "|"); + for (Entry entry : map.entrySet()) { + JSONObject object = entry.getValue(); + if (object == null || object.isEmpty()) { + continue; + } + relationShapeModels.put(id + "_" + entry.getKey(), Arrays.asList(object.getString("text").split("\\|"))); + } + } + + macroLibraries.put("relationShapes", relationShapeIds); + macroLibraries.put("relationShapeModels", relationShapeModels); + + if (defaultAttrSort != null && defaultAttrSort.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < defaultAttrSort.size(); i++) { + if (i == defaultAttrSort.size() - 1) { + sb.append(defaultAttrSort.get(i)); + } else { + sb.append(defaultAttrSort.get(i) + "|"); + } + } + macroLibraries.put("defaultAttrSort", sb.toString()); + } else { + macroLibraries.put("defaultAttrSort", ""); + } + macroLibraries.put("importShapeStyle", "display:none"); + StringBuilder sb = new StringBuilder(); + Set ids = new HashSet<>(); + sb.append(plModel.getName()); + ids.add(plModel.getId()); + getFilePath(sb, ids, plModel); + macroLibraries.put("toolbarName", sb.toString()); + + List shapeIds = new ArrayList<>();// 当前流程所有节点 + List> shapeList = CoeDesignerUtil.getShapeMessageJson2(rUUID);//获取所有节点 + if (shapeList != null && shapeList.size() > 0) { + for (Map map : shapeList) { + shapeIds.add((String)map.get("id")); + } + } + + getPalProcessLinkTag(plModel, macroLibraries); + /********************附件************************/ + // 文件或节点自身附件 + com.alibaba.fastjson.JSONObject upFileObject = new com.alibaba.fastjson.JSONObject(); + upFileObject.put("file", new JSONArray()); + for (String shape : shapeIds) { + upFileObject.put(shape, new JSONArray()); + } + UpFileDao upFileDao = new UpFileDao(); + StringBuilder sqlWhere = new StringBuilder(); + sqlWhere.append(" and PALREPOSITORYID ='").append(rUUID).append("'"); + List fileList = upFileDao.search(sqlWhere.toString()); + + //三员管理下,过滤当前用户与文件密级显示 + if(HighSecurityUtil.isON()){ + macroLibraries.put("isHighSecurity", true); + PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc,fileList); + } + if (fileList != null && fileList.size() > 0) { + for (UpfileModel upfileModel : fileList) { + com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); + object.put("id", upfileModel.getUuid()); + object.put("name", upfileModel.getFileName()); + object.put("type", "self"); + if ("f".equals(upfileModel.getType())) { + upFileObject.getJSONArray("file").add(object); + } + if ("s".equals(upfileModel.getType())) { + if (upFileObject.getJSONArray(upfileModel.getShape_uuid()) == null) { + continue; + } + + + String filename=upfileModel.getFileName().substring(upfileModel.getFileName().lastIndexOf(".")); + + if(!filename.equals(".xml")){ + upFileObject.getJSONArray(upfileModel.getShape_uuid()).add(object); + } + + } + } + } + + // 文件或节点的关联节点的附件 + //查询流程和节点附件 + List relationList = null; + // 查询关联的节点 + DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); + relationList = relationDao.getModelListByFileId(rUUID); + + //关联文件list + List relationUpfFileList = new ArrayList<>(); + /*if (relationList != null && relationList.size() > 0) { + for (int i = 0; i < relationList.size(); i++) { + DesignerShapeRelationModel model = relationList.get(i); + if (UtilString.isEmpty(model.getRelationShapeId())) {// 关联的模型文件 + List files = upFileDao.search(model.getRelationFileId(), null, "file"); + relationUpfFileList.addAll(files); + }else { + //关联的图形文件 + List files = upFileDao.search(model.getRelationFileId(), model.getRelationShapeId(), null); + relationUpfFileList.addAll(files); + } + } + }*/ + + if (relationUpfFileList != null && relationUpfFileList.size() > 0) { + //三员管理,过滤关联文件密级显示 + if(HighSecurityUtil.isON()){ + PALRepositoryQueryAPIManager.getInstance().upFileSecurityFilter(this._uc,relationUpfFileList); + } + for (UpfileModel relationUpFile : relationUpfFileList) { + com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); + object.put("id", relationUpFile.getUuid()); + object.put("name", relationUpFile.getFileName()); + object.put("type", "relation"); + upFileObject.getJSONArray("file").add(object);// 文件 + } + } + macroLibraries.put("upfileData", upFileObject); + /********************附件************************/ + /********************步骤说明************************/ + // 获取所有关联属性 + JSONObject relationShapes = new JSONObject(); + if (shapeList != null && shapeList.size() > 0) { + for (Map map : shapeList) { + String shapeId1 = (String)map.get("id"); + relationShapes.put(shapeId1, new JSONObject()); + String shapeName = (String) map.get("type"); + String shapeCategory = (String) map.get("category"); + String shapeMethod = shapeCategory.replace("_", "."); + List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(plModel.getWsId(), shapeMethod, shapeName, plModel.getMethodId()); + Map refMap = new HashMap(); + Map attrTypeMap = new HashMap<>(); + for (PALMethodAttributeModel model : attributeModelList) { + if (!model.getUse()) { + continue; + } + if ("relation".equals(model.getType()) || "awsorg".equals(model.getType())) { + refMap.put(model.getKey(), JSON.parseObject(model.getRef())); + } + attrTypeMap.put(model.getKey(), model.getType()); + } + List list = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(plModel.getId(), shapeId1, null, null); + List modelList = new ArrayList<>(); + for (DesignerShapeRelationModel model : list) { + String attrId = model.getAttrId(); + if (attrTypeMap.containsKey(attrId)) { + if ("relation".equals(attrTypeMap.get(attrId))) { + if (refMap.containsKey(attrId)) { + String relationType = refMap.get(attrId).getString("type"); + if ("file".equals(relationType)) {// 关联的文件 + List list2 = PALRepositoryCache.getByVersionId(plModel.getWsId(), model.getRelationFileId()); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + model.setRelationShapeText(model2.getName()); + model.setRelationFileId(model2.getId()); + break; + } + } + modelList.add(model); + } else { + modelList.add(model); + } + } + } else if ("awsorg".equals(attrTypeMap.get(attrId))) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + String id = object.getString("id"); + HashSet keys = new HashSet<>(); + if (!keys.contains(id)) { + // 查询最新名称 + if ("department".equals(object.getString("type"))) { + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); + if (dept == null) continue; + object.put("name", dept.getName()); + } + if ("position".equals(object.getString("type"))) { + RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); + if (roleModel == null) continue; + object.put("name", roleModel.getName()); + } + if ("user".equals(object.getString("type"))) { + UserModel user = SDK.getORGAPI().getUser(object.getString("id")); + if (user == null) continue; + object.put("name", user.getUserName()); + } + if ("role".equals(object.getString("type"))) { + RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); + if (roleModel == null) continue; + object.put("name", roleModel.getName()); + } + modelList.add(model); + keys.add(id); + } + } + + } + + } + // 去重 + List tempList = new ArrayList(); + Set keys = new HashSet<>(); + for (DesignerShapeRelationModel model : modelList) { + String key = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId() + model.getRelationShapeText(); + if (!keys.contains(key)) { + tempList.add(model); + keys.add(key); + } + } + modelList = tempList; + modelList.sort((m1, m2) -> {return m1.getId().compareTo(m2.getId());}); + for (DesignerShapeRelationModel model : modelList) { + if (attrTypeMap.containsKey(model.getAttrId())) { + if ("relation".equals(attrTypeMap.get(model.getAttrId()))) { + if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + model.getRelationShapeText()); + } else { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), model.getRelationShapeText()); + } + } else if ("awsorg".equals(attrTypeMap.get(model.getAttrId()))) { + if (relationShapes.getJSONObject(shapeId1).containsKey(model.getAttrId())) { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), relationShapes.getJSONObject(shapeId1).getString(model.getAttrId()) + "," + JSONObject.parseObject(model.getRelationShapeText()).getString("name")); + } else { + relationShapes.getJSONObject(shapeId1).put(model.getAttrId(), JSONObject.parseObject(model.getRelationShapeText()).getString("name")); + } + } + } + } + } + } + macroLibraries.put("relationShapesData", relationShapes); + /********************步骤说明************************/ + /********************描述************************/ + // 自定义属性 + JSONObject object = CoeProcessLevelUtil.getProcessLevelPropertyVal(plModel.getId()); + macroLibraries.put("processDesc", object); + if (upVisit) { + PALRepositoryQueryAPIManager.getInstance().UpDatePublishCount(plModel); + } + /********************描述************************/ + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.view.portal.mobile.html", macroLibraries); + } + + /** * 根据method获取当前文件所定义的自定义属性 * @param model diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/CoeProcessLevelUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/CoeProcessLevelUtil.java index b0cc742a..d02d1630 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/CoeProcessLevelUtil.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/util/CoeProcessLevelUtil.java @@ -2285,7 +2285,7 @@ public class CoeProcessLevelUtil { JSONArray jsonValue = jsonObjectMap.get(attributeModel.getKey()).getJSONArray("value"); if(jsonValue.size()>0){ - String sessionId = new SSOUtil().registerClientSessionNoPassword(plModel.getCreateUser(), LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); + String sessionId = new SSOUtil().registerClientSessionNoPassword("admin", LoginConst.DEFAULT_LANG, "localhost", LoginConst.DEVICE_PC); for(int i=0;i() { @Override public String mapRow(ResultSet rs, int arg1) throws SQLException { diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java index da1404fb..4d742198 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java @@ -9062,6 +9062,7 @@ public class CoeProcessLevelWeb extends ActionWeb { } } } + if (!methodAttributeModelMap.containsKey(shapeName + "-" + attrId)) { continue;// 没有配置到形状的属性,不处理 } @@ -9077,6 +9078,7 @@ public class CoeProcessLevelWeb extends ActionWeb { flag2 = UtilString.isNotEmpty(value); }*/ if (!flag2) { + sb2.append("【"+o.get("text")+"】"+"''"+attrModel.getNewTitle()+"''").append(","); } diff --git a/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.html b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.html index e3042039..a7f13ebb 100755 --- a/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.html +++ b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.html @@ -907,7 +907,6 @@ color: #999999!important; background-color: #ffffff!important; } - diff --git a/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.mobile.html b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.mobile.html new file mode 100644 index 00000000..b464532a --- /dev/null +++ b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.view.portal.mobile.html @@ -0,0 +1,1242 @@ + + + + + <#fileName>(<#versionNum>) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <#js> + + + + + + + + + + + <#processlink_ete_js> + + + + + + + + +
+
+ + +
+ <#toolbarName> +
+
+
评论
+
+
+
+ +
+ +
+ +
+
+ + +
+ +
+
+
+ +
+
+
+
+
+
+ 您的浏览器不支持HTML5,请使用IE9及以上版本,或Chrome、Firefox等浏览器 +
+
+
+
+
+ +
+ +
+ + + + + + + + + + + +
+ +
+
+
+
+
+
+
+
+
+ + + + + + +
+
+ +
+ +
+ +
活动属性 x
+ + +
+
+
+
+ + + + + + + +
+
+ + + +
+
+ +
+ + + + + + + + + + + + +
+ + + + + + + +
+ + + + diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.link.view.portal.mobile.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.link.view.portal.mobile.js new file mode 100644 index 00000000..bb5fa30f --- /dev/null +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.link.view.portal.mobile.js @@ -0,0 +1,2264 @@ +/** + * @author wangyh 与插入链接,属性,关系相关的js内容 + */ +var selectedShapes = []; +var linkType; // 链接类型:custom:自定义链接;file:文件链接 +$(document).ready(function() { + showPainting(); + + setTimeout(function() { + Designer.hotkey.init();// 解决快捷健绑定不成功 + DesignerCopyPaste.changeTitleListen(); + if (selectedElementId && selectedElementId != "") { + Utils.selectShape(selectedElementId); + }// 复制粘贴形状内容同步的监听 + }, 1000); + //initShapeAttribute('0'); + //changeArributeByShape('portalAttrShow') +}); + +/** + * 兼容1024*768画布显示 + * + * @param {} + * + */ + +function showPainting() { + var width = screen.width; + if (width == 1024) { + $("#toolbar_wfversion_info").addClass("showPainting"); + if (parent.getWidthToolbar() > 750) { + $(".toolbar").removeClass("heightCssToolbar") + .addClass("toolbarExtend"); + $("#bar_back").removeClass("cssToolbar"); + + } else { + $(".toolbar").addClass("heightCssToolbar") + .removeClass("toolbarExtend"); + $("#bar_back").addClass("cssToolbar"); + } + } +} + +/** + * 重写单击图形时的触发的事件 + * + * @param {} + * + * @returns {} + */ +Designer.op.shapeSelectable = function(a) { + console.log(000) + var b = $("#designer_canvas"); + b.bind("mousedown.select", function(d) { + Designer.op.changeState("seelcting_shapes"); + var e = a.id; + var c = []; + if (d.ctrlKey) { + var c = Utils.getSelectedIds(); + if (Utils.isSelected(e)) { + Utils.removeFromArray(c, e); + } else { + c.push(e); + } + + Utils.unselect(); + if (c.length > 0) { + Utils.selectShape(c); + } + } else { + if (Utils.selectIds.indexOf(e) < 0) { + + Utils.unselect(); + Utils.selectShape(e); + } + } + console.log(111) + $(document).bind("mouseup.select", function() { + Designer.op.resetState(); + b.unbind("mousedown.select"); + $(document).unbind("mouseup.select"); + console.log(222) + }); + // selectedShapes + DesignerCopyPaste.selectedShapeId = Utils.getSelected()[0].id; + if ($("div.dock_view_attribute").is(":visible")) { + showShapeRelationTab(null); + attributeShowTabContent(null); + shapeCopyAndPasteCount(null); + showRelevanceShapesContent(); + console.log(333) + } + + }); +}; +var myshapeLink = ""; +var linkIndex = 0; +var selectShape = Utils.getSelected()[0]; +/** + * 功能:去除字符串中所有空格 传参:需要处理的字符串 返回值:去除空格后的字符串 + */ +function trimSpaces(Str) { + var ResultStr = ""; + Temp = Str.split(/\s/); + for (i = 0; i < Temp.length; i++) { + ResultStr += Temp[i]; + } + return ResultStr; +} + +//风险控制 +UI.showRiskDlg = function(){ + var shape = Utils.getSelected()[0]; + var number; + if (shape.dataAttributes != undefined) { + for (var i = 0; i < shape.dataAttributes.length; i++) { + if (shape.dataAttributes[i].privateAttributeContent != null) { + var privateAttributeContent = shape.dataAttributes[i].privateAttributeContent; + if (typeof(privateAttributeContent) == "string") { + privateAttributeContent = eval("(" + privateAttributeContent + ")"); + } + number = privateAttributeContent.number; + } + } + } + if (number == undefined || number == "") { + $.simpleAlert("请先维护该节点编号"); + return; + } + var riskDlg = FrmDialog.open({ + width:800, + height:700, + url:"./w?sid=" + $("#sid").val() + "&cmd=com.actionsoft.apps.coe.pal.risk_pal_designer_risk", + data:{"plId":ruuid, "taskId": shape.id, "taskNum": number} + }); +} + +//流程节点的风险控制不为空,重新渲染shape +function renderShapeRisks(risk, control) { + var shape = Utils.getSelected()[0]; + if (shape.dataAttributes != undefined) { + var riskFlag = false; + var controlFlag = false; + for (var i = 0; i < shape.dataAttributes.length; i++) { + if (shape.dataAttributes[i].risk != undefined) { + shape.dataAttributes[i].risk = risk; + riskFlag = true; + } + if (shape.dataAttributes[i].control != undefined) { + shape.dataAttributes[i].control = control; + controlFlag = true; + } + } + if (!riskFlag) { + var index = shape.dataAttributes.length -1; + shape.dataAttributes[index].risk = risk; + } + if (!controlFlag) { + var index = shape.dataAttributes.length -1; + shape.dataAttributes[index].control = control; + } + } + Designer.painter.renderShape(shape); +} + +// 判断给定的对象是不是数组 +function isArray(o) { + return Object.prototype.toString.call(o) === '[object Array]'; +} + + +// 出现复制图形的统计 + +function shapeCopyAndPasteCount(shape) { + if (!$("#tagContent2").is(":visible")) { + return; + } + if (shape == null) + shape = Utils.getSelected()[0]; + $("#tagContentTableTitleContent2").empty(); + var shapeGroupId = ""; + var isCopy = ""; + var shapeId = shape.id; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.shapeGroupId) { + shapeGroupId = attr.shapeGroupId; + isCopy = attr.isCopy; + break; + } + } + var data = "shapeGroupId=" + shapeGroupId + "&shapeId=" + shapeId + + "&isCopy=" + isCopy; +} + +function showRelevanceShapesContent() { + if (!$("#tagContent3").is(":visible")) { + return; + } + $.ajax({ + type : "POST", + url : "./jd?sid=" + + CLB.sid + + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_relevance_show", + data : { + shapeId : Utils.getSelected()[0].id, + fileId: ruuid + }, + success : function(msg) { + $("#tagContentTableTitleContent3").empty(); + if (msg.data.result == "ok") { + var shapesObj = msg.data.list; + var mouseover = "onmouseout=\"hideRemoveTrAttribute(this);\""; + var mouseout = "onmouseover=\"showRemoveTrAttribute(this);\""; + if (role == "viewer") { + mouseover = ""; + mouseout = ""; + } + for (var i = 0; i < shapesObj.length; i++) { + var style = ""; + var onclick = ""; + if (editable || filePerms == "-" || filePerms.indexOf(shapesObj[i].fileVersionId) > -1) { + style = "cursor:pointer;color:blue;"; + if (parent.openDesginerFromAttr) { + onclick = 'parent.openDesginerFromAttr(\'' + + shapesObj[i].fileId + + '\',0,\'' + + shapesObj[i].fileName + + '\',\'\',\'\',false,\'' + + shapesObj[i].shapeId + + '\')'; + } else if (window.opener.openDesginer) { + var obj = { + id: shapesObj[i].fileId, + processDefId: '' + } + onclick = 'window.opener.openDesginer({id:\'' + shapesObj[i].fileId + '\', processDefId:\'\'})'; + } + + } + var content = '' + + '
' + + shapesObj[i].fileName + + '(V ' + shapesObj[i].fileVersion + '.0)' + + '
' + + '
' + + shapesObj[i].shapeText + + '
'; + + $("#tagContentTableTitleContent3").append(content); + } + } + } + }); + +} + +function getPrivateAttributeHtml(attributesJsonArray, tbodyId, shape) { + + // 属性排序 + var defaultMoreAttr = $('#defaultMoreAttrSort').val(); + if(defaultMoreAttr.length > 0) { + var arr = defaultMoreAttr.split('|'); + var tempAttrArray = []; + for(var i = 0; i < arr.length; i++) { + for(var j = 0; j < attributesJsonArray.length; j++) { + if(attributesJsonArray[j] == undefined || attributesJsonArray[j] == null) { + continue; + } + if(arr[i] == attributesJsonArray[j].id) { + tempAttrArray.push(attributesJsonArray[j]); + } + } + } + //取新添加的属性 + if (tempAttrArray.length > 0) { + var newAttrArray = []; + newAttrArray = tempAttrArray.concat(attributesJsonArray).filter(function(v, i, arr) { + return arr.indexOf(v) === arr.lastIndexOf(v); + });; + attributesJsonArray = tempAttrArray.concat(newAttrArray); + } + } + var flag = false; + var objIds = []; + var selectFlag = false; + var selectValues = []; + var mouseover = "onmouseout=\"hideRemoveTrAttribute(this);\""; + var mouseout = "onmouseover=\"showRemoveTrAttribute(this);\""; + if (role == "viewer") { + mouseover = ""; + mouseout = ""; + } + var userAddress = false; + var deptAddress = false; + var userObjIds = new Array(); + var deptObjIds = new Array(); + var deptIds = ""; + for (var index = 0; index < attributesJsonArray.length; index++) { + var obj = attributesJsonArray[index]; + if (obj != null && obj != undefined && obj.value != undefined) { + if(obj.name=="活动序号"){ + continue; + } + var constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + obj.name + ': ' +obj.value+ ''; + constr += ''; + if ((!obj.readonly && obj.type == "string") + || (!obj.readonly && obj.type == "list")) { + // 目前支持到文本的输入 ,需求定下了再改 + constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + '【' + obj.name + '】'+' '+ obj.value + ''; + constr += ''; + } else if (!obj.readonly && obj.type == "link") { + constr = ''; + /*constr += '' + obj.name + '';*/ + // constr += '' + obj.value + ''; + constr += '' + '【' + obj.name + '】'+' ' + '' + obj.value + '' + ''; + constr += ''; + } else if (!obj.readonly && obj.type == "number") { + constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + '【' + obj.name + '】'+' '+ obj.value + ''; + constr += ''; + } else if (!obj.readonly && obj.type == "boolean") { + constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + '【' + obj.name + '】'+' '+''; + constr += ''; + } else if (!obj.readonly && obj.type == "textarea") { + constr = ''; + /*constr += '' + obj.name + '';*/ + if (obj.value == undefined) { + obj.value = ''; + } + constr += '' + '【' + obj.name + '】'+' '+ obj.value.replace(/\n/g, '
') +''; + constr += ''; + } else if (obj.readonly && obj.type == "relation") { + var relationValue = ""; + if (relationShapesData[shape.id] !== null && relationShapesData[shape.id][obj.id] != null) { + relationValue = relationShapesData[shape.id][obj.id]; + } + constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + '【' + obj.name + '】'+' '+ relationValue +''; + constr += ''; + } else if (obj.type == "select" || obj.type == "select_m") { + constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + '【' + obj.name + '】'+ ' '+ obj.value +''; + constr += ''; + + selectFlag = true; + var selectValue = { + "objId": obj.id, + "objValue": obj.value, + "objType": obj.type + }; + selectValues.push(selectValue); + } else if (obj.readonly && obj.type == "userAddress") { + userAddress = true; + userObjIds.push(obj.id); + var relationValue = ""; + if (relationShapesData[shape.id] !== null && relationShapesData[shape.id][obj.id] != null) { + relationValue = relationShapesData[shape.id][obj.id]; + } + constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + '【' + obj.name +'】'+ ' '+ relationValue +''; + constr += ''; + } else if (obj.readonly && obj.type == "deptAddress") { + deptAddress = true; + deptObjIds.push(obj.id); + deptIds += "," + obj.value; + var relationValue = ""; + if (relationShapesData[shape.id] !== null && relationShapesData[shape.id][obj.id] != null) { + relationValue = relationShapesData[shape.id][obj.id]; + } + constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + '【' + obj.name +'】'+ ' '+ relationValue +''; + constr += ''; + } else if (obj.readonly && obj.type == "awsorg") { + var relationValue = ""; + if (relationShapesData[shape.id] !== null && relationShapesData[shape.id][obj.id] != null) { + relationValue = relationShapesData[shape.id][obj.id]; + } + constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + '【' + obj.name +'】'+ ' '+ relationValue +''; + constr += ''; + } else if (obj.readonly && obj.type == "hidden") { + constr = '' + + ' ' + obj.name + '' + + ' ' + + ' ' + //+ '
' + + ''; + } else if (obj.type == "table") { + let tableInput = '请输入' + if (obj.value.table.length > 1) { + tableInput = '请查看' + } + constr = ''; + /*constr += '' + obj.name + '';*/ + constr += '' + '【' + obj.name +'】'+ ' ' + tableInput + '' +''; + constr += ''; + } + $('#' + tbodyId + ' table[name=' + shape.id + ']').append(constr); + } + + } + if (selectFlag) { + getSelectOptions(shape.category, selectValues); //处理select类型 + } +} + +// table表格 +function openDialog(obj) { + let tableName = obj.name + let dialogTable = obj.table + $("#attribute-table-content2").empty() + let thead = + '' + + '' + dialogTable[0].name + '' + + '' + dialogTable[0].desc + '' + +'' + $('#attribute-table-content2').append(thead) + for ( let i = 1; i < dialogTable.length; i++) { + let str = + '' + + '' + dialogTable[i].name + '' + + '' + dialogTable[i].desc + '' + +'' + $('#attribute-table-content2').append(str) + } + + $("#attribute-table-window2").dialog({ + title: tableName, + draggable: true, + buttons : [{ + text : '确定', + cls : "blue", + handler : function() { + $("#attribute-table-window2").dialog('close'); + } + }, { + text : '取消', + handler : function() { + $("#attribute-table-window2").dialog('close'); + } + }] + }) +} + +Array.prototype.unique = function(){ + var res = []; + var json = {}; + for(var i = 0; i < this.length; i++){ + if(!json[this[i]]){ + res.push(this[i]); + json[this[i]] = 1; + } + } + return res; +} + + +// 得到不同属性值关联的形状 +function getAttributeByAttrId(shape, objId, relationShapes) { + //objId 属性的key值 + var exitAttributesJsonArray = []; + var attrArr = []; //修改后的属性值 + + for (var i = 0; i < relationShapes.length; i++) { + var shapeObjT = relationShapes[i]; + attrArr.push(shapeObjT.relationShapeId); + } + attrArr = attrArr.unique(); //属性值去重 + if (attrArr.length > 0) { + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + exitAttributesJsonArray = attr.attributesJsonArray; + break; + } + } + for (var c = 0; c < exitAttributesJsonArray.length; c++) { + var el = exitAttributesJsonArray[c]; + if(el == null) continue; + if (el.id == objId) { + el.value = attrArr.join(","); + break; + } + } + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attr.attributesJsonArray = exitAttributesJsonArray; + break; + } + } + for (var j = 0, len = attrArr.length; j < len; j++) { + var attrShapeId = attrArr[j]; + relationShapesObject[attrShapeId] = {"relationShapeId" : attrShapeId}; + } + $("input[objid_shapeId='" + objId + "']").val(attrArr.join(",")); + } else { + $("input[objid_shapeId='" + objId + "']").val(""); + } + + return shape; +} +Array.prototype.notDistinct = function() { + var newArr = [], obj = {}; + for (var i = 0, len = this.length; i < len; i++) { + if (!obj[this[i]]) { + newArr.push(this[i]); + obj[this[i]] = 'new'; + } + } + return newArr; +} + +// 删除掉关联形状 +function removeTrRelevanceShapes(obj) { + var options = { + title : "提示", + content : "确定删除吗?", + model : false, + onConfirm : function() { + // 确定删除 + var shape = Utils.getSelected()[0]; + var tempArray = new Array(); + var count = 0; + if (shape) { + var relevanceShapes = []; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.relevanceShapes) { + relevanceShapes = attr.relevanceShapes; + break; + } + } + for (var index = 0; index < relevanceShapes.length; index++) { + var tempObj = relevanceShapes[index]; + if (tempObj.id == $(obj).attr("objid")) { + continue; + } + tempArray[count++] = tempObj; + } + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.relevanceShapes) { + attr.relevanceShapes = tempArray; + break; + } + } + Model.update(shape); + } + $(obj).hide(); + $(obj).parent().parent().remove(); + $.ajax({ + type : "POST", + url : "./jd?sid=" + + CLB.sid + + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_relevance_remove", + data : { + uuid : $(obj).attr("objid"), + }, + success : function(msg) { + } + }); + } + }; + window.top.$.confirm(options); +} + +// 过虑 掉重复的图形 +function filterRepeatShapes(arr1, shape) { + var arr2 = []; + var arr = []; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.relevanceShapes) { + arr2 = attr.relevanceShapes; + break; + } + } + var flag = false; + for (var a = 0; a < arr1.length; a++) { + var arrEle1 = arr1[a]; + for (var b = 0; b < arr2.length; b++) { + var arrEle2 = arr2[b]; + if (arrEle1.id == arrEle2.id) { + flag = true; + break; + } + } + if (flag) { + flag = false; + continue; + } + arr2.push(arrEle1); + } + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.relevanceShapes) { + attr.relevanceShapes = arr2; + break; + } + } + + return shape; +} + +function updateModelElementsAttribute(selectedShape, nodes) { + var shapes = Model.define.elements; + for (var shapeId in shapes) { + var obj = nodes; + var shape = shapes[shapeId]; + if(shape.name != "linker" && shape.id != selectedShape.id && shape.name == selectedShape.name){ + var exitAttributesJsonArray = []; + var attrIndex = 0; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + exitAttributesJsonArray = attr.attributesJsonArray; + attrIndex = i; + break; + } + } + var arrJsontemp = []; + for (var t = 0; t < exitAttributesJsonArray.length; t++) { + if(exitAttributesJsonArray[t] == null) { + continue; + } + arrJsontemp.push(exitAttributesJsonArray[t]); + } + obj = filterRepeatAttribute(obj, exitAttributesJsonArray, shape.dataAttributes[attrIndex].attributesJsonArray); + for (var a = 0; a < obj.length; a++) { + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attr.attributesJsonArray.push(obj[a]); + break; + } + } + } + if (arrJsontemp.length != 0) { + var tempArr = removeShepeAttributeAndReturnDifferent(arrJsontemp, filterNotCheckedAttribute(nodes, arrJsontemp)); + var tempArray = new Array(); + for (var e = 0; e < tempArr.length; e++) { + if (tempArr[e] != 0 && tempArr[e] != "0") { + removeNotCheckedAttribute(shape, tempArr[e]); + } + } + if (tempArray.length != 0) { + shape.attributesJsonArray = tempArray; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attr.attributesJsonArray = tempArray; + break; + } + } + } + } + Model.update(shape); + //修改属性时,后台查询是否有关联属性,如果删除的属性有关联属性,需要删除关联表中的数据 + var attrIds = ","; + if (nodes != undefined) { + for (var i = 0; i < nodes.length; i++) { + if (nodes[i].type) { + attrIds += nodes[i].id + ","; + } + } + awsui.ajax.request({ + url : "./jd", + method : "POST", + data : { + sid:sid, + cmd:"com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_relevance_check", + fileId: ruuid, + shapeId: shape.id, + attrIds: attrIds + }, + ok : function(r) { + }, + err:function(r){ + } + }); + } + } + } +} + +// 过虑出当在节点上不选中时的属性 + +function filterNotCheckedAttribute(checkedObj, exitObj) { + var result1 = []; + if (checkedObj.length == 0) { + return []; + } else { + var flag = false; + for (var b = 0; b < checkedObj.length; b++) { + var checkedArr1 = checkedObj[b]; + for (var a = 0; a < exitObj.length; a++) { + var exitArr1 = exitObj[a]; + if (exitArr1.id == checkedArr1.id) { + result1.push(checkedArr1); + break; + } + } + } + return result1; + } +} + +// 移除图形属性中部分已存在的元素并返回不同元素 + +function removeShepeAttributeAndReturnDifferent(exitObj, newObj1) { + var result1 = []; + for (var a = 0; a < newObj1.length; a++) { + var obj1 = newObj1[a]; + for (var i = 0, n = 0; i < exitObj.length; i++) { + if (exitObj[i].id == obj1.id) { + result1.push(i); + break; + } + } + } + for (var i = 0; i < result1.length; i++) { + exitObj[result1[i]] = 0; + } + return exitObj; +} +// 删除没有选中的元素 + +function removeNotCheckedAttribute(shape, obj1) { + var tempArray = new Array(); + var attributesJsonArray1 = []; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attributesJsonArray1 = attr.attributesJsonArray; + break; + } + } + for (var index = 0; index < attributesJsonArray1.length; index++) { + if(attributesJsonArray1[index] == null) { + continue; + } + var tempObj1 = attributesJsonArray1[index]; + if (tempObj1.id == obj1.id) { + continue; + } + tempArray.push(tempObj1); + } + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attr.attributesJsonArray = tempArray; + break; + } + } + // shape.attributesJsonArray = tempArray; + // Model.update(shape); + $("#" + shape.id + " name=[tagContentTable0] tr[objid='" + obj1.id + "']").remove(); +} +// 过滤掉重复的属性生成新的数组 + +function filterRepeatAttribute(arr1, arr2, shape) { + var result = []; + var flag = false; + for (var a = 0; a < arr1.length; a++) { + var arrEle1 = arr1[a]; + for (var b = 0; b < arr2.length; b++) { + var arrEle2 = arr2[b]; + if(arrEle2 == null) { + continue; + } + if (arrEle1.id == arrEle2.id) { + shape[b].name = arrEle1.name; + flag = true; + break; + } + } + if (flag) { + flag = false; + continue; + } + result.push(arrEle1); + } + + return result; +} + +// 当属性为可编辑时,编辑时自动保存 + +function showEditButton(obj) { + $(obj).siblings("span::contains('...')").show(); +} + +function saveInputContent(obj) { + // 按钮 + // $(obj).siblings("span::contains('...')").hide(); + var objValue = $(obj).val(); + if ($(obj).attr("inputType") == "number") { + var val = $(obj).val(); + if (/\D/.test(val)) { + $.simpleAlert("此处只能输入数字", "info", 2000); + $("#simplealert>.msg").css("top", "15px"); + return; + } + } + updateAttributeById($(obj).attr("objid"), objValue); +} + +function saveSelectContent(objAttr,objValue){ + updateAttributeById(objAttr, objValue); +} + +// 显示select下拉框 + +function showSelectOption(obj) { + var str = $(obj).attr("ty"); + if (str == "td") { + $(obj).children("select").show(); + $(obj).children("span").hide(); + } else { + updateAttributeById($(obj).attr("objid"), $(obj) + .find("option:selected").text()); + $(obj).hide(); + $(obj).siblings("span").text($(obj).find("option:selected").text()) + .show(); + } +} + +// 属性编辑打开窗口 + +function showAttributedEditWindow(obj) { + var objId = $(obj).attr("objid"); + var shape = Utils.getSelected()[0]; + if (shape) { + if (objId == "desc") { + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.shapeDesc != undefined) { + $("#attribute-edit-title").text("描述/定义"); + $("#attribute-edit-content").html(attr.shapeDesc == undefined ? "" : attr.shapeDesc.replace(/\n/g,'
')); + break; + } + } + } else { + var attributesJsonArray = []; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attributesJsonArray = attr.attributesJsonArray; + break; + } + } + for (var index = 0; index < attributesJsonArray.length; index++) { + var tempObj = attributesJsonArray[index]; + if (tempObj.id == objId) { + $("#attribute-edit-title").text(tempObj.name); + $("#attribute-edit-content").val(tempObj.value); + break; + } + } + } + } + $("#attribute-edit-window").dialog({ + draggable: false, + buttons : [{ + text : '确定', + cls : "blue", + handler : function() { + var str = $("#attribute-edit-content").val(); + if (objId == "desc") { + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.shapeDesc != undefined) { + shape.dataAttributes[i].shapeDesc = str; + break; + } + } + Model.update(shape); + } else { + updateAttributeById($(obj).attr("objid"), str); + } + $(obj).val(str); + $("#attribute-edit-window").dialog('close'); + } + }, { + text : '关闭', + handler : function() { + $("#attribute-edit-window").dialog('close'); + } + }] + }); +} + +// 对单个属性的更新操作 + +function updateAttributeById(objId, va) { + // var shape = Utils.getSelected()[0]; + var shape = selectShape; + var tempArray = new Array(); + var count = 0; + if (shape) { + /* + * for (var i = 0; i < shape.dataAttributes.length; i++) { var attr = + * shape.dataAttributes[i]; if (attr.attributesContent) { + * attr.attributesContent = $("#" + shape.id + " tbody[name=tagContentTable0]").html(); break; } } + */ + var attributesJsonArray = shape.attributesJsonArray; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attributesJsonArray = attr.attributesJsonArray; + break; + } + } + for (var index = 0; index < attributesJsonArray.length; index++) { + var tempObj = attributesJsonArray[index]; + if(tempObj == null) { + continue; + } + if (tempObj.id == objId) { + tempObj.value = va; + tempArray[count++] = tempObj; + continue; + } + tempArray[count++] = tempObj; + } + if (tempArray.length > 0) { + shape.attributesJsonArray = tempArray; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attr.attributesJsonArray = tempArray; + break; + } + } + if ("isAutoSave" == 1) { + CLB.cmdList = [{ + "type" : "message", + "cmd" : "com.actionsoft.apps.coe.pal_pl_repository_designer_message" + }]; + } + Model.update(shape); + } + } +} + +// 删除行上的属性 +function removeTrAttribute(obj) { + var options = { + title : "提示", + content : "确定删除吗?", + model : false, + onConfirm : function() { + // 确定删除 + var shape = Utils.getSelected()[0]; + var tempArray = new Array(); + var count = 0; + if (shape) { + // shape.attributesContent = $("#" + shape.id + " tbody[name=tagContentTable0]").html(); + var attributesJsonArray = []; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attributesJsonArray = attr.attributesJsonArray; + break; + } + } + for (var index = 0; index < attributesJsonArray.length; index++) { + var tempObj = attributesJsonArray[index]; + if (tempObj.id == $(obj).attr("objid")) { + continue; + } + tempArray[count++] = tempObj; + } + // if (tempArray.length >= 0) { + shape.attributesJsonArray = tempArray; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attr.attributesJsonArray = tempArray; + break; + } + } + Model.update(shape); + // } + } + $(obj).hide(); + $(obj).parent().parent().remove(); + $.ajax({ + type : "POST", + url : "./jd?sid=" + + CLB.sid + + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_relevance_remove", + data : { + uuid : $(obj).attr("objid"), + shapeId : Utils.getSelected()[0].id, + fileId : ruuid + }, + success : function(msg) { + } + }); + } + }; + window.top.$.confirm(options); +} +// 显示删除按钮 + +function showRemoveTrAttribute(obj) { + $(obj).addClass("attr_bg_color_tr"); + $("input[name=attribute_name_input_" + $(obj).attr("objid") + "]") + .addClass("attr_bg_color_tr"); + $("input[name=attribute_name_input_" + $(obj).attr("objid") + "]").parent() + .addClass("attr_bg_color_tr"); + $(obj).children("td").children(".ico_attribute_delete").show(); + if ($(obj).attr("ty") == "sel") { + $(obj).children("td").children("select").show(); + $(obj).children("td").children("span").hide(); + } +} +// 隐藏删除按钮 + +function hideRemoveTrAttribute(obj) { + $(obj).removeClass("attr_bg_color_tr"); + $("input[name=attribute_name_input_" + $(obj).attr("objid") + "]") + .removeClass("attr_bg_color_tr"); + $("input[name=attribute_name_input_" + $(obj).attr("objid") + "]").parent() + .removeClass("attr_bg_color_tr"); + $(obj).children("td").children(".ico_attribute_delete").hide(); + if ($(obj).attr("ty") == "sel") { + $(obj).children("td").children("select").hide(); + $(obj).children("td").children("span").show(); + } +} +// 经常用的是通过遍历,重构数组. +Array.prototype.remove = function(dx) { + if (isNaN(dx) || dx > this.length) { + return false; + } + for (var i = 0, n = 0; i < this.length; i++) { + if (this[i] != this[dx]) { + this[n++] = this[i]; + } + } + this.length -= 1; +}; +function removeElementFromArr(dx, obj) { + if (isNaN(dx) || dx > obj.length) { + return false; + } + for (var i = 0, n = 0; i < obj.length; i++) { + if (obj[i] != obj[dx]) { + obj[n++] = obj[i]; + } + } + obj.length -= 1; + return obj; +} + +// 在数组中获取指定值的元素索引 +Array.prototype.getIndexByValue = function(value) { + var index = -1; + for (var i = 0; i < this.length; i++) { + if (this[i].url == value) { + index = i; + break; + } + } + return index; +}; +Array.prototype.getIndexByValueById = function(value) { + var index = -1; + for (var i = 0; i < this.length; i++) { + if (this[i] == value) { + index = i; + break; + } + } + return index; +}; +// 重写链接创建后的事件 +Designer.events.addEventListener("linkerCreated", function(linker) { + /** + * var toId = linker.to.id; //当前选中的图形 var fromShape = + * Utils.getSelected()[0]; //目标图形 var toShape = + * Model.getShapeById(toId); var toShapeTemp = []; for (var index = + * 0; index < linkerRelationship.length; index++) { var shapes = + * linkerRelationship[index]; var fromShapeId = shapes.fromShapeId; + * var toShapeIds = shapes.toShapeId; if (fromShape.name == + * fromShapeId) { if (toShapeIds != "*") { //判断是针对哪些图形有效 if + * (toShapeIds.indexOf(",") > 0) { toShapeTemp = + * toShapeIds.split(","); } else { toShapeTemp.push(toShapeIds); } } } } + * if (toShapeTemp.length != 0) { for (var index = 0; index < + * toShapeTemp.length; index++) { var tempShapeId = + * toShapeTemp[index]; //删除这条线 if (toShape.name != tempShapeId) { + * $.simpleAlert("不支持所选对象与目标对象的这种关系", "error", 2500); //待续未完 + * deleteLinkerSelected(linker); } } } // if (toShape.name == "xxx") { // + * linker.to.id = null; //} //获取选中的链接线 var outlinkers = + * Utils.getOutlinkers(fromShape); var l = linker; // + * consloe.log(l); + */ + // 判断是不是支持这种关系类型 + // isObjectRelationshipModel(linker, true); + // showShapeRelationTab(null); + // attributeShowTabContent(null); + // showRelevanceShapesContent(); + // shapeCopyAndPasteCount(null); +}); + +/** + * 图形创建后重写 + */ +Designer.events.addEventListener("created", function(shape) { + + if (Designer.status == "demo" && !demoCreatedTiped) { + UI.showStartStep("created", $("#" + shape.id)); + demoCreatedTiped = true; + } + /*************************************************************************** + * var selectedShape = Utils.getSelected()[0]; var linkerIds = + * Model.getShapeLinkers(selectedShape.id); + * if(linkerIds&&linkerIds.length>0){ var linker = + * Model.getShapeById(linkerIds[0]); isObjectRelationshipModel(linker, + * true); } + **************************************************************************/ + showShapeRelationTab(shape); + if(shape.category == "control_risk") { + initPrivateAttribute(shape, "control_risk"); // 创建节点后编号提供默认值 + } + if(shape.category == "process_flowchart" || shape.category == "process_bpmn2") {// 流程flowchar编号初始化编号 + if (!IsGroupChild(shape)) {// 不在组内部或者新建立的节点为组节点 + // 获取最大编号 + initPrivateAttribute(shape, shape.category); + } + if(shape.name == "group") {// 组置于最底层 + // Designer.layerShapes("back"); + var start = Model.orderList[0].zindex; //取到最小的zindex + start -= 1; + shape.props.zindex = start; + } + } + attributeShowTabContent(shape); + // shapeCopyAndPasteCount(shape); +}); + +// 设置编号属性默认值 +function initPrivateAttribute(newShape, type) { + if (type == "control_risk") { + var shapes = Model.define.elements; + var max = 0; + for (var shapeId in shapes) { + var shape = shapes[shapeId]; + if(shape.category == "control_risk") { // 过滤其他模型图形 + var dataAttr = shape.dataAttributes[0]; + var number = typeof dataAttr.privateAttributeContent == "string" ? JSON.parse(dataAttr.privateAttributeContent.replace(/'/g,'"')).number : dataAttr.privateAttributeContent.number; + if(typeof number == 'string') number = number.replace(/^\s+|\s+$/g,""); + if(!isNaN(number)) if(number > max) max = number; + } + } + max = Math.floor(max) + 1; + newShape.dataAttributes[0].privateAttributeContent = {'number': max }; + } else { + var shapes = Model.define.elements; + var max = 0; + for (var shapeId in shapes) { + var shape = shapes[shapeId]; + if (shape.dataAttributes != undefined) { + for (var i = 0; i < shape.dataAttributes.length; i++) { + if (shape.dataAttributes[i].privateAttributeContent != null) { + var privateAttributeContent = shape.dataAttributes[i].privateAttributeContent; + if (typeof(privateAttributeContent) == "string") { + privateAttributeContent = eval("(" + privateAttributeContent + ")"); + } + var number = privateAttributeContent.number; + if(number != undefined && number != null && number != "") { + if(typeof number == 'string') number = number.replace(/^\s+|\s+$/g,""); + if(!isNaN(number)) if(parseInt(number) > parseInt(max)) max = number; + } + } + } + } + } + // 设置最大编号为max+1 + + var json = "{'number':'编号'}"; + // var json2 = "{'number':'" + (parseInt(max)+1) + "'}"; + String.prototype.padLeft = Number.prototype.padLeft = function(total, pad) { + return (Array(total).join(pad || 0) + this).slice(-total); + } + var no = ((parseInt(parseInt(max)/10) + 1)*10); + if(no < 1000) { + no = no.padLeft(3); + } + var json2 = "{'number':'" + no + "'}"; + var shapeName = newShape.name; + if (shapeName.indexOf("_custom") > -1) { + shapeName = shapeName.substring(0, shapeName.indexOf("_")); + } + if (shapeName == "control" || shapeName == "risk" || shapeName == "item" + || shapeName == "regulation" || shapeName == "procedure" + || shapeName == "method" || shapeName == "manualOperation" + || shapeName == "predefinedProcess" + || shapeName == "callActivityCallingProcess" + || shapeName == "businessRuleTask" || shapeName == "scriptTask" + || shapeName == "sendTask" || shapeName == "userTask" + || shapeName == "serviceTask" || shapeName == "manualTask" + || shapeName == "receiveTask" || shapeName == "process" + || shapeName == "decision" || shapeName == "group") { + for (var i = 0; i < newShape.dataAttributes.length; i++) { + var attr = newShape.dataAttributes[i]; + if (attr.privateAttribute) { + attr.privateAttribute = json; + } + if(attr.privateAttributeContent) { + attr.privateAttributeContent = json2; + } + } + } + } +} + +//判断新建立的节点是否在shapeName为group的组内部 +function IsGroupChild(newShape) { + var result = false; + var newObj = newShape.props; + var x2 = parseInt(newObj.x); + var y2 = parseInt(newObj.y); + var w2 = parseInt(newObj.w); + var h2 = parseInt(newObj.h); + if (newShape.name == "group") { + return false; + } else { // 是否在组内部 + var shapes = Model.define.elements; + for (var shapeId in shapes) { + if (newShape.id == shapeId) continue; + var shape = shapes[shapeId]; + if (shape.name == "group") {// 存在组节点 + var obj = shape.props; + var x1 = parseInt(obj.x); + var y1 = parseInt(obj.y); + var w1 = parseInt(obj.w); + var h1 = parseInt(obj.h); + if (x1y2+h2 && x1+w1>x2+w2 && x1+w1>x2+w2 && y1+h1>y2+h2) { // 新建立节点在组内部 + result = true; + break; + } + } + } + } + return result; +} + +// 当不符合配置的关系时删除链接线 + +function deleteLinkerSelected(linker) { + // moveShape移除图片 moveLinker移除链线 shapeMultiSelectable图形选中事件 designer.core.js + var d = linker; + if (d.length > 0) { + Utils.unselect(); + var e = Utils.getAttachedShapes(d); + d = d.concat(e); + var c = []; + for (var b = 0; b < d.length; b++) { + var a = Utils.getChildrenShapes(d[b]); + c = c.concat(a) + } + d = d.concat(c); + Model.remove(d) + } +} +// 显示图形关系特性 + +function showShapeRelationTab(currentShape) { + + if (!$("#tagContent0").is(":visible")) { + return; + } + // 拿到所选的图形 + var selectedShape = Utils.getSelected()[0]; + if (!selectedShape) + return; + if (currentShape) { + selectedShape = currentShape + } + var linkers = Model.getShapeLinkers(selectedShape.id); + var outlinkers = Utils.getOutlinkers(Utils.getSelected()); + var l = linkers; + $("#tagContentTable1").empty(); + if (linkers != undefined) { + for (var a = 0; a < linkers.length; a++) { + // 根据连线的id拿到连线图形这个对象,再根据这个对象来找到他所关联的图形 + var element = linkers[a]; + var linkerObjs = Model.getShapeById(element); + // 来自哪个图形 的id + var fromId = linkerObjs.from.id; + var toId = linkerObjs.to.id; + var fromShape = Model.getShapeById(fromId); + var toShape = Model.getShapeById(toId); + if (fromShape != undefined && toShape != undefined) { + // 此处判断的是从本图形出去的连线 + if (fromShape.id == selectedShape.id) { + for (var b = 0; b < linkerRelationship.length; b++) { + var shapes = linkerRelationship[b]; + var fromShapeId = shapes.fromShapeId; + var toShapeIds = shapes.toShapeId; + if (fromShape.name == fromShapeId) { + if (toShapeIds != "*") { + // 判断是针对哪些图形有效 + if (toShapeIds.indexOf(",") > 0) { + var toShapeTemp = toShapeIds.split(","); + for (var c = 0; c < toShapeTemp.length; c++) { + var josnShapeId = toShapeTemp[c]; + if (josnShapeId == toShape.name) { + addtagContentTableContent( + fromShape, + shapes.outcomingName, + toShape); + } + } + } else { + if (toShapeIds == toShape.name) { + addtagContentTableContent(fromShape, + shapes.outcomingName, toShape); + } + } + } else { + // 当没有限制的时候 + addtagContentTableContent(fromShape, + shapes.outcomingName, toShape); + } + } + } + } else if (toShape.id == selectedShape.id) { + // 此处需要完善当不扶持 对像关系类型时下面的代码 不执行 + // 判断进来的链线开始 + for (var b = 0; b < linkerRelationship.length; b++) { + var shapes = linkerRelationship[b]; + var fromShapeId = shapes.fromShapeId; + var toShapeIds = shapes.toShapeId; + // if (toShape.name == fromShapeId) { + // 判断这两种图形中是否有这种关系 + // if (isObjectRelationshipModel(linkerObjs, false)) + // addtagContentTableContent(fromShape, + // shapes.incomingName); + // } + if (fromShape.name == fromShapeId) { + if (toShapeIds != "*") { + // 判断是针对哪些图形有效 + if (toShapeIds.indexOf(",") > 0) { + var toShapeTemp = toShapeIds.split(","); + for (var c = 0; c < toShapeTemp.length; c++) { + var josnShapeId = toShapeTemp[c]; + if (josnShapeId == selectedShape.name) { + addtagContentTableContent(toShape, + shapes.incomingName, + fromShape); + } + } + } else { + if (toShapeIds == selectedShape.name) { + addtagContentTableContent(toShape, + shapes.incomingName, fromShape); + } + } + } else { + // 当没有限制的时候 + addtagContentTableContent(toShape, + shapes.incomingName, fromShape); + } + + } + + } + // 判断进来的线结束 + } + } + var e = element; + } + } +} +// 给关系类型增加内容 + +function addtagContentTableContent(shape1, str, obj) { + if (obj.text == "") { + obj.text = obj.title; + } + var constr = '' + // + shape1.text + + str + + '
' + + obj.text + + '
'; + $("#tagContentTable1").append(constr); +} +// 判断是不是支持对象的关系类型 + +function isObjectRelationshipModel(linker, isAlert) { + var flag = false; + var toId = linker.to.id; + if (toId == null) + return false; + // 当前选中的图形 + var fromShape = Utils.getSelected()[0]; + // 目标图形 + var toShape = Model.getShapeById(toId); + var toShapeTemp = []; + for (var index = 0; index < linkerRelationship.length; index++) { + var shapes = linkerRelationship[index]; + var fromShapeId = shapes.fromShapeId; + var toShapeIds = shapes.toShapeId; + if (fromShape) { + if (fromShape.name == fromShapeId) { + if (toShapeIds != "*") { + // 判断是针对哪些图形有效 + if (toShapeIds.indexOf(",") > 0) { + toShapeTemp = toShapeIds.split(","); + } else { + toShapeTemp.push(toShapeIds); + } + } + } + } + } + if (toShapeTemp.length != 0) { + for (var index = 0; index < toShapeTemp.length; index++) { + var tempShapeId = toShapeTemp[index]; + // 删除这条线 + if (toShape && toShape.name == tempShapeId) { + // 画线时的操作 + // 显示关系类型里的操作 + flag = true; + break; + // 待续未完 + } + } + } else { + flag = true; + } + if (!flag) { + if (isAlert) { + // $.simpleAlert("不支持所选对象与目标对象的这种关系", "error", 2000); + // deleteLinkerSelected(linker); + } + } + return flag; +} + + +// 文件属性的处理 +function initProcessDesc() { + var length = Object.keys(processDesc).length; + var t = ''; + var b=''; + for(var i = 1; i <= length; i++) { + var obj = processDesc[i]; + //判断如果为相关文件/支持文件显示在右侧区域 + if(obj.name=="相关文件" || obj.name=="支持文件"){ + b += ''; + b += ''; + b += ''; + b += ''; + b += '
' + "【"+obj.name +"】"+ '
'; + var fileArry=obj.value.split(","); + for(var k=0;k'; + b += ''; + b += ''; + } + + }else{ + t += ''; + t += '' + "【"+obj.name +"】"+ ''; + + var value = obj.value; + if (value == undefined) { + value = ''; + t += ''+ value + ''; + t += ''; + } else if(obj.type == 'table') { + if(value == '') { + t += '' + value + ''; + t += ''; + } else { + let tableValue = JSON.parse(value.replace(/"/g,'\"')) + let tableFlag = '请输入' + if (tableValue.table.length > 1) { + tableFlag = '请查看' + } + t += '' +''+tableFlag+''+''; + t += ''; + } + } else { + value = value.replace(/\n/g,'
') + t += '' + value + ''; + t += ''; + } + } + + // t += '' + value + ''; + // t += ''; + } + + if(b.length>0){ + $('#relevantDocument').append(b); + } + + $('#portalDescDock').find('table').append(t); + // $('#portalDescDock').append('
 
'); +} + +function autoClickAttr() { + // 属性自动切换 + if ($('#openTab').is(':hidden')) { + var name = ''; + if (Utils.getSelected()[0] == null) { + name = 'processDesc'; + } else { + name = 'processAttr'; + } + $('#tab').find('div').removeClass('selected'); + $('#' + name).addClass('selected'); + $('.newadd_portalAttr').hide(); + if(name == "processDesc") { + dockShowView('portalDescShow'); + } + /*if(name == "processAttr") { + dockShowView('portalAttrShow'); + }*/ + if(name == "processFile") { + dockShowView('portalFileShow'); + } + if(name == 'fileheaderTab'){ + dockShowView('portalwjFileShow'); + } + + } +} + +function dockShowView(name) { + if ($("#dock_btn_" + name).button("isDisabled")) { + return; + } + $(".dock_view").hide(); + $(".dock_view_" + name).show(); + $(".dock_buttons").children().removeClass("selected"); + $("#dock_btn_" + name).addClass("selected"); + if (Dock.currentView == "history" && name != "history") { + Dock.closeHistory(); + } + Dock.currentView = name; +} + +// 点击页面时变更显示内容 +function changeArributeByShape(name) { + /*if(!name){ + $('.newadd_wen').show() + }*/ + if(!isClickTab) { + autoClickAttr(); + } + isClickTab = false; + var lastTable = '
 
'; + //节点属性和附件的处理,文件属性见initProcessDesc() + if(Utils.getSelected()[0] == undefined){ + console.log(111) + } + if (Utils.getSelected()[0] == null) { + initShapeAttribute('0'); + initUpfileData('0'); + ProcessManual('0'); + $('table[name=lastTable]').remove(); + if($('#portalAttrDock').children('table').length > 0) { + $('#portalAttrDock').append(lastTable); + } + if($('#portalFileDock').children('table').length > 0) { + // $('#portalFileDock').append(lastTable); + } + } else { + selectShape = Utils.getSelected()[0]; + initShapeAttribute(Utils.getSelected()[0].id); + initUpfileData(Utils.getSelected()[0].id); + ProcessManual(Utils.getSelected()[0].id); + $('table[name=lastTable]').remove(); + if ($('#portalAttrDock table[name=' + Utils.getSelected()[0].id + ']').length > 0) { + // $('#portalAttrDock').append(lastTable); + } + if ($('#portalFileDock table[name=' + Utils.getSelected()[0].id + ']').length > 0) { + // $('#portalFileDock').append(lastTable); + } + } +} + + +function ProcessManual(obj) { + var manualName; + if(methodId=="data.form"){ + manualName="表单手册 :"; + }else if (methodId=="process.epc"){ + manualName="EPC手册 :"; + }else if (methodId=="process.bpmn2"){ + manualName="BPMN手册 :"; + }else if (methodId=="process.flowchart"){ + manualName="泳道手册 :"; + }else if (methodId=="process.evc"){ + manualName="架构手册 :"; + }else if (methodId=="org.normal"){ + manualName="组织手册 :"; + }else if (methodId=="itsystem.normal"){ + manualName="IT系统手册 :"; + }else if (methodId=="control.policy"){ + manualName="制度手册 :"; + }else if (methodId=="control.risk"){ + manualName="风险控制手册 :"; + }else if(methodId=="control.kpi"){ + manualName="流程绩效手册 :"; + } + $('#processFileDock').empty(); + var t = ''; + /*t += ''; + t += ''; + t += '
'; + t += '
'+manualName+'
'; + t += '
'+ fileName +''; + t +=''; + t +='
'; + t += '
';*/ + + + t += '
'; + t +=''+manualName+''; + t += ''; + t +=''; + t += ''; + t += ''; + t += ''; + t +=''; + t += '
'; + t += '
'+ fileName +''; + t +=''; + + t +='
'; + + t += '
'; + t +='
'; + + $('#processFileDock').append(t); + + //相关文件/相关附件 + initUpfileData(obj); + +} + + + + +function openOutputFile(taskId) { + // 打开流程手册 + $.simpleAlert('正在打开', 'loading'); + $.ajax({ + type : "POST", + url : "./jd?sid=" + sid + + "&cmd=com.actionsoft.apps.coe.pal_outputreport_output_process_preview", + data : { + taskId : taskId + }, + success : function(msg) { + if (msg.result == "ok") { + $.simpleAlert("close"); + if (msg['data']) { + var url = msg['data']['url']; + window.open(url); + } + } else { + $.simpleAlert("close"); + $.simpleAlert(msg['msg'], 'info'); + } + } + }); +} + + +function downloadProcessFile(taskId) { + $.ajax({ + type : "POST", + url : "./jd?sid=" + sid + + "&cmd=com.actionsoft.apps.coe.pal_outputreport_output_process_download", + data : { + taskId : taskId + }, + success : function(msg) { + if (msg.result == "ok") { + window.location.href = msg.data.url; + }else{ + $.simpleAlert("请确认是否已生成流程手册", 'info'); + } + } + }); +} + + +/** + * 相关文件/制度文件下载 + * @param uuid + */ +function downloadZipFile(splitId,toolbarname) { + $.ajax({ + type : "POST", + url : "./jd?sid=" + sid + + "&cmd=com.actionsoft.apps.coe.pal_outputreport_output_downloadZipfile", + data : { + splitId : splitId, + toolbarname:toolbarname, + taskIdParams:taskId, + methodId:methodId + }, + success : function(msg) { + if (msg.result == "ok") { + window.location.href = msg.data.url; + } + } + }); +} + +// 初始化上传附件 +function initUpfileData(obj) { + $('#alertMessage').remove(); + if (obj == undefined || obj == '0') { + $('#portalFileDock').empty(); + var t = ''; + var splitId=''; + var processFile = upfileData['file']; + if(processFile.length > 0) { + /*t += ''; + t += '
'; + t += '
文件附件:
'; + for(var i = 0; i < processFile.length; i++) { + var obj = processFile[i]; + t += '
'+ obj.name +''; + /!*t +='';*!/ + t +='
'; + + }*/ + + t += '
'; + t +='文件附件:'; + for(var i = 0; i < processFile.length; i++) { + var obj = processFile[i]; + t += ''; + t +=''; + t += ''; + t += ''; + t += ''; + t +=''; + t += '
'; + t += '
'+ obj.name +''; + t +='
'; + t += '
'; + splitId+=obj.id+','; + } + + + t += '
'; + } + + var elements = Model.define.elements; + for(var e in elements) { + var ele = elements[e]; + if(ele.name == 'linker') { + continue; + } + var processShape = upfileData[ele.id]; + if(processShape != null && processShape.length > 0) { + + t += '
'; + t +=''+'节点附件:'+''+ele.text; + for(var i = 0; i < processShape.length; i++) { + t += ''; + t +=''; + t += ''; + t += ''; + t += ''; + t +=''; + t += '
'; + var obj = processShape[i]; + t += '
'+ obj.name +''; + t +='
'; + + t += '
'; + splitId+=obj.id+','; + + } + + } + t += '
'; + + } + + t += '
'; + + + $('#processFileDock').append(t); + + + var toolbarname=$("#toolbarname").text(); + if(splitId.length>0){ + var str=''; + splitId=splitId.substring(0,splitId.length-1); + str +=''; + $('#dabao').html(str); + } + + } else { + $('#processFileDock table').show(); + $('#portalFileDock table[name=' + obj + ']').show(); + } + var isHidden = true; + $('#processFileDock table').each(function(){ + if ($(this).css('display') != 'none') { + isHidden = false; + } + }); + if (isHidden) { + var $noContent = $('#noContent').clone(true); + $noContent.attr('id', 'alertMessage'); + $('#processFileDock').append($noContent); + $('#alertMessage').show(); + } +} + +//附件在线预览 +function readFile(uuid) { + $.simpleAlert("文件正在处理", "loading"); + awsui.ajax.request({ + type: "POST", + url: "./jd?sid=" + encodeURIComponent(sid) + "&cmd=com.actionsoft.apps.coe.pal_processlevel_upfile_read", + data: {uuid: uuid}, + ok: function(msg) { + $.simpleAlert("close"); + var url = msg.data.url; + if (msg.data.noSupport) { + window.location.href = url; + } else { + window.open(url); + } + }, + err: function(msg) { + } + }); +} + +function sortModelByNumber() { + + // 序号升序,无序号在后面 + var recordId = []; + var hasNumArr = []; + /*for (var shapeId in Model.define.elements) { + var shape = Model.define.elements[shapeId]; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attrArr = shape.dataAttributes[i]; + if (attrArr.attributesJsonArray && attrArr.attributesJsonArray.length > 0) { + for (var j = 0; j < attrArr.attributesJsonArray.length; j++) { + var attr = attrArr.attributesJsonArray[j]; + if (attr != null && attr.id && attr.id == 'number') { + var number = attr.value; + if(typeof number == 'string') { + number = number.replace(/^\s+|\s+$/g,"") + }; + if(number != undefined && number != null && number != "") { + var obj = {}; + obj.text = shape.text; + obj.id = shapeId; + obj.orderIndex = number; + hasNumArr.push(obj); + recordId.push(shapeId); + } + break; + } + + + + } + break; + } + } + }*/ + + /*******************************排序方法重构***by zhaolei**********************************************/ + for (var shapeId in Model.define.elements) { + var shape = Model.define.elements[shapeId]; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attrArr = shape.dataAttributes[i]; + if (attrArr.attributesJsonArray && attrArr.attributesJsonArray.length > 0) { + for (var j = 0; j < attrArr.attributesJsonArray.length; j++) { + var attr = attrArr.attributesJsonArray[j]; + + //根据活动序号排序 + if (attr != null && attr.id) { + + if(attr.id=="activity_number"){ + var number = attr.value; + var subNumer=number< 10 ? number.substr(1,1) : number; + + if(typeof subNumer == 'string') { + subNumer = subNumer.replace(/^\s+|\s+$/g,"") + }; + if(subNumer != undefined && subNumer != null && subNumer != "") { + var obj = {}; + obj.text = shape.text; + obj.id = shapeId; + obj.orderIndex = subNumer; + hasNumArr.push(obj); + recordId.push(shapeId); + } + } + } + + + + } + } + } + } + + // 有序号的元素升序排序 + var compare = function (prop) { + return function (obj1, obj2) { + var val1 = obj1[prop]; + var val2 = obj2[prop]; + if (!isNaN(Number(val1)) && !isNaN(Number(val2))) { + val1 = Number(val1); + val2 = Number(val2); + } + if (val1 < val2) { + return -1; + } else if (val1 > val2) { + return 1; + } else { + return 0; + } + } + } + + hasNumArr.sort(compare("orderIndex")); + /*for (var shapeId in Model.define.elements) { + if($.inArray(shapeId, recordId) == -1) { + var obj = {}; + obj.id = shapeId; + hasNumArr.push(obj); + } + }*/ + + return hasNumArr; +} + + + + +// 初始化流程步骤说明 +function initShapeAttribute(obj) { + if (obj == undefined || obj == '0') { + $('#portalAttrDock').empty(); + var elements = Model.define.elements; + var sortNumShapeArr = sortModelByNumber(); + for(var sortIndex = 0; sortIndex < sortNumShapeArr.length; sortIndex++) { + var temp = sortNumShapeArr[sortIndex]; + var shape = elements[temp.id]; + if(shape.name == 'linker') { + continue; + } + + // 属性弹出层显示的内容 + var attributesJsonArray = ""; + var attributesJsonArrayT = []; + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.attributesJsonArray) { + attributesJsonArrayT = attr.attributesJsonArray; + break; + } + } + // 属性排序 + var defaultMoreAttr = $('#defaultMoreAttrSort').val(); + if(defaultMoreAttr.length > 0) { + var arr = defaultMoreAttr.split('|'); + var tempAttrArray = []; + for(var i = 0; i < arr.length; i++) { + for(var j = 0; j < attributesJsonArrayT.length; j++) { + if(attributesJsonArrayT[j] == undefined || attributesJsonArrayT[j] == null) { + continue; + } + if(arr[i] == attributesJsonArrayT[j].id) { + tempAttrArray.push(attributesJsonArrayT[j]); + } + } + } + //取新添加的属性 + if (tempAttrArray.length > 0) { + var newAttrArray = []; + newAttrArray = tempAttrArray.concat(attributesJsonArrayT).filter(function(v, i, arr) { + return arr.indexOf(v) === arr.lastIndexOf(v); + }); + attributesJsonArrayT = tempAttrArray.concat(newAttrArray); + } + } + + //流程阅览只显示线上审批、线下审批、系统任务、人工审批 + if(shape.title=="线上审批" || shape.title=="线下审批" || shape.title=="系统任务" ||shape.title=="人工任务") { + var no = ""; + for (var i = 0; i < attributesJsonArrayT.length; i++) { + var id = attributesJsonArrayT[i].id; + if (id == "activity_number") { + var numberValue = attributesJsonArrayT[i].value; + if (numberValue != "") { + no = numberValue; + } + } + } + var novalue=no+"."+shape.text; + var t = ''; + t += '
'; + t += ''; + t += ''; + t += ''; + t += ''; + t += ''; + t += ''; + t += ''; + t += ''; + t += ''; + /*t += '';*/ + t += ''; + t += ''; + t += '
' +no+"."+shape.text +'
'; + $('#portalAttrDock').append(t); + if (shape && attributesJsonArrayT) { + // {}函数,改为图形创建时增加私有属性 + attributesJsonArray = attributesJsonArrayT; + var shapeTitle = shape.title == undefined ? "" : shape.title; + $("#" + shape.id + "type").text(shapeTitle); + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + if (attr.shapeDesc) { + $("#" + shape.id + "desc").html(attr.shapeDesc == undefined ? "" : attr.shapeDesc.replace(/\n/g, '
')); + break; + } + } + // 此处遍历attributesJsonArray输入 内容 + if (attributesJsonArray.length != 0) { + getPrivateAttributeHtml(attributesJsonArray, "portalAttrDock", shape); + } + } + } + } + } else { + $('#portalAttrDock table').hide(); + $('#portalAttrDock table[name=' + obj + ']').show(); + var elements = Model.define.elements; + var sortNumShapeArr = sortModelByNumber(); + for(var sortIndex = 0; sortIndex < sortNumShapeArr.length; sortIndex++) { + var temp = sortNumShapeArr[sortIndex]; + var shape = elements[temp.id]; + if(shape.title=="线上审批" || shape.title=="线下审批" || shape.title=="系统任务" ||shape.title=="人工任务") { + + if(obj==shape.id){ + continue; + } + document.getElementById("box"+shape.id).style.display="none"; + } + //document.getElementById("span"+shape.id).innerHTML=no+"."+shape.text; + } + } +} + +function searchChange(id,text) { + + if (document.getElementById("searchChangeFlg"+id).value == "1") { + document.getElementById(id+"change").style.display=""; + document.getElementById("searchChange"+id).innerHTML = ""; + document.getElementById("searchChangeFlg"+id).value = "0"; + document.getElementById("span"+id).innerHTML=""; + + } else { + document.getElementById(id+"change").style.display="none"; + document.getElementById("searchChange"+id).innerHTML = ""; + document.getElementById("searchChangeFlg"+id).value = "1"; + document.getElementById("span"+id).innerHTML=text; + } +} + + + +//获取select类型属性的option +var comboboxs = []; +function getSelectOptions(category, selectValues) { + $.ajax({ + type : "POST", + url : "./jd?sid=" + + CLB.sid + + "&cmd=com.actionsoft.apps.coe.pal_pl_attribute_option", + data : { + category : category + }, + success : function(msg) { + if (msg.result == "ok") { + var data = msg.data.data; + for (var i = 0; i < selectValues.length; i++) { + var objId = selectValues[i].objId; + var objValue = selectValues[i].objValue; + var objType = selectValues[i].objType; + var multiple = false; + var closeSelect = true; + if (objType == "select_m") { + multiple = true; + closeSelect = false; + } + var optionsData = data[objId]; + if (optionsData) { + optionsData = optionsData.split(","); + var selectData = []; + var selectedData = []; + if(objValue != null && objValue != ''){ + var selectedArr = objValue.split(','); + } + var y = 0; + if (optionsData.length > 0) { + for (var j = 0, len = optionsData.length; j < len; j++) { + var dataObj = { + id : j, + text : optionsData[j] + }; + selectData.push(dataObj); + if(objValue != null && objValue != ''){ + for(var x = 0; x < selectedArr.length; x++){ + if(selectedArr[x] == optionsData[j]){ + selectedData[y] = j; + y++; + } + } + } + } + } + $.fn.select2.defaults.set("language", "zh-CN"); + var opt1 = { + width : 244, + multiple:multiple, + closeOnSelect:closeSelect, + /*templateResult:formatState, + templateSelection:formatRepoSelection,*/ + placeholder:'请选择...' + }; + opt1.data = selectData; + $("#attribute_name_input_" + objId).parent().css("padding-left", "0px"); + var $obj = $("#attribute_name_input_" + objId).select2(opt1); + if(multiple){//多选 + $("#attribute_name_input_" + objId).val(selectedData).trigger("change"); + } else {//单选 + if(selectedData != null && selectedData != ''){ + $("#attribute_name_input_" + objId).val(selectedData[0]).trigger("change"); + } + } + $obj.off("select2:close").on("select2:close", function(e){//只能在关闭多选框时触发事件,close与unselect事件冲突,待完善 + var type = this.id.substring(this.id.lastIndexOf('_')+1); + var selectValue = []; + var selected = $('#' + this.id).select2('data'); + for(var j = 0; j < selected.length; j++){ + selectValue[j] = selected[j].text; + } + comboboxs[type] = selectValue.join(','); + saveSelectContent(type,comboboxs[type]); + }); + $("#attribute_name_input_" + objId + "_Tip").css({"float" : "left", "border" : "0"}); + } + } + } + } + }); +} + +function getScreenResolution() { + if (screen.width == 1024) { + + } +} +/** + * 图形创建后事件 + */ +/* + * Designer.events.addEventListener("created", function(a) { //alert(a.name) + * if(a.name != "linker"){ attributeShowTabContent(null); //Model.update(a); } + * if (Designer.status == "demo" && !demoCreatedTiped) { + * UI.showStartStep("created", $("#" + a.id)); demoCreatedTiped = true } }); + */ + +// 重构 +function openLinkUrlRewrite(type, url, target, uuid, obj, fileName, inspected) { + var sid=$("#sid").val(); + if (type == "custom") { + $("#link-dialog-normal_contextmenu").hide(); + if (target == "newTab" && parent.openTabCustom != undefined) { + parent.openTabCustom(uuid, url, fileName); + } else if (target == "_seft") { + if (parent.changeTabTitle) { + parent.changeTabTitle(chartId, fileName, uuid, "custom"); + } + window.location.href = url; + } else { + window.open(url+sid, target); + } + } else { + // 判断权限,判断是否存在文件 + // uuid 要打开的目标文件 + $.ajax({ + type:'POST', + url:'./jd?cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_viewer_portal_link_perm_check', + dataType : "JSON", + data:{ + sid : $("#sid").val(), + uuid:uuid + }, + success:function(r) { + switch(r.data.data) { + case 'ok': + window.open("./w?cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_viewer_portal_open_page&uuid=" + uuid + "&sid=" + sid); + break; + case 'noPerm': + $.simpleAlert('无权限访问', 'info'); + break; + case 'notFound': + $.simpleAlert('文件未找到', 'info'); + break; + case 'notPublish': + $.simpleAlert('文件未发布,无法访问', 'info'); + break; + default: + break; + } + } + }) + } +} diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.ui.mobile.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.ui.mobile.js new file mode 100644 index 00000000..f53e71d8 --- /dev/null +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.ui.mobile.js @@ -0,0 +1,489 @@ +$(function() { + // 版本管理 + // if ((isView == 1 || isView == true) && perms.indexOf("w") == -1 && process.processDefId == "") { + // $("#toolbar_designer_version_no").off("click.coe.openVersion").css({"cursor": "default"}); + // $("#toolbar_wfversion_info_status").off("click.coe.openVersion").css({"cursor": "default"}); + // } else { + // $("#toolbar_designer_version_no").on("click.coe.openVersion",function() {openDesignerVersionManager();}); + // $("#toolbar_wfversion_info_status").on("click.coe.openVersion",function() {openDesignerVersionManager();}); + // } + + $("div.selected").removeClass("selected"); + + //形状属性 + $("#toolbar-shape-attr").unbind("click").bind("click", function() { + if($("#toolbar-shape-attr").hasClass("disabled")) { + // + } else { + BPMNBiz.showPropertiesDialog(); //打开形状属性 + } + + }); + //流程属性 + $("#toolbar-global-prop").unbind("click").bind("click", function() { + BPMNBiz.showPropertiesDialog(true); //打开流程属性 + }); +}); +var aaa=true +/** + * 打开一个历史版本 + */ +Dock.openHistory = function(definition) { + if (this.currentDefinition == null) { + this.currentDefinition = $.extend(true, {}, Model.define); + } + Utils.unselect(); + Model.historyDefine = definition; + Designer.open(definition); + + // 取消快捷键 + Designer.hotkey.cancel(); + Designer.op.cancel(); + $("#menu_bar").children().addClass("readonly"); + $(".diagram_title").addClass("readonly"); + $(".dock_buttons").children().addClass("disabled"); + $("#dock_btn_history").removeClass("disabled"); + $(".panel_box").addClass("readonly"); + + // 禁用保存 + $("#bar_save").button("disable"); + $("#bar_save").unbind("click"); + // 禁用插入和视图 + $("#bar_view").button("disable"); + $("#bar_insert").button("disable"); + // 禁用校验 + $("#dock_btn_validate").unbind("click"); + // 中止监听 + // CLB.stopListen(); +}; + +/** + * 关闭历史版本 + */ +Dock.closeHistory = function() { + if (this.currentDefinition != null) { + Designer.open(this.currentDefinition); + this.currentDefinition = null; + this.activeOperation(); + } + + // 激活保存事件 + $("#bar_save").button("enable"); + $("#bar_save").unbind("click").bind("click", function() { + saveDesigner(); + }); + // 激活视图和插入 + $("#bar_view").button("enable"); + $("#bar_insert").button("enable"); + $("#moreShapes").removeAttr("disabled"); + // //激活校验事件 + // $("#dock_btn_validate").bind("click", function() { + // validateBPMN(false); + // }); +}; + +/** + * 加载历史版本 + */ +/**太费时间,暂时先注掉,后期优化 +Dock.loadHistorys = function() { + + $("#spinner_play_speed").spinner({ + min : 0.5, + max : 3.0, + unit : "s", + step : 0.5, + value : 5, + onChange : function(val) { + + } + }); + + $("#spinner_play_speed").spinner("setValue", "0.5s"); + + if (chartId == "") { + $("#history_container") + .html("
没有历史
"); + return; + } + // if($("#history_versions li").length > 0) { + // return; + // } + $.ajax({ + url : encodeURI("./jd?sid=" + + $("#sid").val() + + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_history_version_json_data"), + // 发送获取versions的请求 + data : { + type : type, + appId : appId, + chartId : chartId, + processDefId : process.processDefId + }, + dataType : "json", + success : function(resObj) { + if (resObj.result != "ok") { + // $.simpleAlert("历史版本获取失败", "error", 2000); + } + var data = resObj.data; + Dock.historyVersions = data; + + if (data.versions.length == 0) { + $("#history_container") + .html('
没有历史
'); + } else { + $("#history_container") + .html('
    '); + var users = data.users; + for (var i = 0, k = data.versions.length; i < data.versions.length; i++, k--) { + var v = data.versions[i]; + var num = i == 0 ? 0 : k; + var newVersion = $('
  • ' + '
    ' + + v.updateTimeAlias + + (v.interval ? (' 持续 ' + v.interval) : '') + + '
    ' + '
    ' + k + '
    ' + + '
    ' + + '
    ' + '
    ' + + '
  • ').appendTo($("#history_versions")); + var nameContainer = newVersion.children(".content") + .children(".version_name"); + for (var j = 0; j < v.userIds.length; j++) { + var userId = v.userIds[j]; + nameContainer.append("
    " + v.userNames + "
    "); // users[userId] + } + // var remarkContainer = $("") + // .appendTo($("li[vid="+v.versionId+"] .content")); + // if (v.remark) { + // remarkContainer.find(".remark_text").text(v.remark); + // } + // remarkContainer.append(""); + } + Dock.resetVersions(); + } + }, + beforeSend : function(xhr) { + // 显示正在加载的图片 + $("#history_container") + .html(''); + } + }); +}; + + +**/ +/* 显示右侧窗口 */ +Dock.showView = function(name) { + + //if (name == "attribute") { + changeArributeByShape(); +// } + if ($("#dock_btn_" + name).button("isDisabled")) { + return; + } + $(".dock_view").hide(); + $(".dock_view_" + name).show(); + // 记录页面用户的操作 + $(".dock_buttons").children().removeClass("selected"); + $("#dock_btn_" + name).addClass("selected"); + if (Dock.currentView == "history" && name != "history") { + Dock.closeHistory(); + } + if (name == "history") { + //Dock.loadHistorys(); + } + // if (name != "attribute") { + // this.currentView = name; + // } + this.currentView = name; + // setCookie(chartId, name+",true"); + this.update(true); + // AWS增加的内容 + // 强制显示导航小窗口 + // $(".dock_view_navigator").show(); +}; + +/** + * 展示历史版本 + */ +Dock.showHistoryVersion = function(defId) { + // AWS增加的内容开始 + var versionNo = $("#history_versions").children(".selected").attr("number"); + // AWS增加的内容结束 + $("#spinner_play_speed").button("disable"); + $("#btn_history_play").button("disable"); + $("#btn_history_restore").button("disable"); + $("#moreShapes").attr("disabled", "disabled"); + Dock.cancelHistoryRemark(); + $.ajax({ + url : encodeURI("./w?sid=" + + sessionId + + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_history_define_json_data"), + data : { + type : type, + chartId : chartId, + appId : appId, + processDefId : process.processDefId, + ver : versionNo + }, + dataType : "json", + success : function(resObj) { + if (resObj.result != "ok") { + // $.simpleAlert("历史版本获取失败", "error", 2000); + } + var definition = resObj.data; + Dock.openHistory(definition); + if ($("#history_versions").children(".selected").attr("ind") != "0") { + $("#spinner_play_speed").button("enable"); + $("#btn_history_play").button("enable"); + $("#btn_history_restore").button("enable"); + $("#moreShapes").removeAttr("disabled"); + } + } + }); +}; + +/** + * 播放一个版本 + */ +Dock.playOneVersion = function(index, msgIndex) { + var current = $("#history_versions").children("li[ind=" + index + "]"); + $("#history_versions").children(".selected").removeClass("selected"); + current.addClass("selected").addClass("playing"); + $(".ico_playing").remove(); + current.append("
    "); + + var top = current.position().top; + if (top < 0) { + $("#history_versions").scrollTop($("#history_versions").scrollTop() + + top); + } + + var time = $("#spinner_play_speed").spinner("getValue") * 1000; + var version = Dock.historyVersions.versions[index]; + if (version.messages.length != 0) { + var messageStr = version.messages[msgIndex]; + var messages = messageStr; + // JSON.parse(messageStr); + MessageSource.receive(messages); + if (index == 0 && msgIndex == version.messages.length - 1) { + this.pauseVersions(); + } else { + if (msgIndex < version.messages.length - 1) { + msgIndex++; + } else { + index = index - 1; + msgIndex = 0; + } + this.playingTimeout = setTimeout(function() { + Dock.playOneVersion(index, msgIndex); + }, time); + } + } else { // 如果不存在操作message(用户打开设计器后没有操作,直接保存) + if (index == 0) { + this.pauseVersions(); + } else { + index = index - 1; + this.playingTimeout = setTimeout(function() { + Dock.playOneVersion(index, msgIndex); + }, time); + } + } + +}; + +/** + * 编辑版本注释 + * + * @param {} + * event + */ +Dock.editHistoryRemark = function(event, versionId) { + event.stopPropagation(); + var versionDom = $("#history_versions").children("li[vid=" + versionId + + "]"); + versionDom.find(".remark_container").hide(); + var currentRemark = versionDom.find(".remark_text").text(); + var editContainer = versionDom.find(".edit_container"); + editContainer.show(); + editContainer.children("textarea").val(currentRemark).select(); + editContainer.children(".save").bind("click", function(e) { + e.stopPropagation(); + var newRemark = editContainer.children("textarea").val(); + versionDom.find(".remark_text").text(newRemark); + versionDom.find(".remark_container").show(); + editContainer.hide(); + if (newRemark != currentRemark) { + $.ajax({ + url : encodeURI("./w?sid=" + sessionId + + "&appId=" + $("#appId").val() + + "&cmd=CONSOLE_M_PROCESS_DESIGNER_REMARK_UPDATE" + + "&processDefId=" + process.processDefId + + "&versionId=" + versionId + + "&remark=" + newRemark), + success : function(data) { + + } + }); + } + }); + editContainer.children(".cancel").bind("click", function(e) { + e.stopPropagation(); + Dock.cancelHistoryRemark(); + }); +}; +/** + * 恢复版本 + */ +Dock.restoreVersion = function() { + $.confirm({ + content : "确定将选中的历史记录恢复为新的版本吗?", + + onConfirm : function() { + var selected = $("#history_versions").children(".selected"); + if (selected.length) { + coeBiz.restoreVersion(selected.attr("number")); + } + } + }); +}; + +/** + * 进入演示视图 + */ +Dock.enterPresentation = function() { + if (document.fullscreenElement || document.webkitFullscreenElement + || document.mozFullScreenElement) { + $.simpleAlert("当前为全屏状态不能进入演示,请退出全屏状态后重试", "info", 2000); + $("#simplealert>.msg").css("top", "15px"); + return; + } + $("#designer").bind('webkitfullscreenchange', function(e) { + Dock.manageFullScreen(true); + }); + $(document).bind('mozfullscreenchange', function(e) { + Dock.manageFullScreen(true); + }).bind('fullscreenchange', function(e) { + Dock.manageFullScreen(true); + }); + Dock.fullScreen(Utils.getDomById("designer"), true); + +}; + +/** + * 进入全屏视图 + */ +Dock.enterFullScreen = function() { + if (document.fullscreenElement || document.webkitFullscreenElement + || document.mozFullScreenElement) { + $.simpleAlert("当前已为全屏状态", "info", 2000); + $("#simplealert>.msg").css("top", "15px"); + return; + } + Dock.fullScreen(document.documentElement); +}; + +Dock.manageFullScreen = function(presentation) { + var designer = Utils.getDomById("designer"); + if (document.fullscreenElement || document.webkitFullscreenElement + || document.mozFullScreenElement) { + // 如果进入全屏状态 + $("#shape_panel").addClass("readonly"); + $("#designer_viewport").addClass("readonly"); + $(window).unbind("resize.designer"); + $("#designer_layout").height(window.screen.height); + // 取消快捷键 + Designer.hotkey.cancel(); + Designer.op.cancel(); + // 隐藏Dock + $("#dock").hide(); + $(".dock_view").hide(); + Designer.contextMenu.destroy(); + Designer.op.canvasFreeDraggable(); + + if (presentation) { + $("#dock").show(); + $("#dock_btn_validate").hide(); + $("#btn_history_restore").hide(); + } + } else { + $("#shape_panel").removeClass("readonly"); + $("#designer_viewport").removeClass("readonly"); + Designer.initialize.initLayout(); + Designer.hotkey.init(); + Designer.op.init(); + $("#dock").show(); + if (Dock.currentView != "") { + Dock.showView(Dock.currentView); + } + Designer.contextMenu.init(); + $("#designer").unbind('webkitfullscreenchange'); + $(document).unbind('mozfullscreenchange').unbind('fullscreenchange'); + if (presentation) { + $("#dock_btn_validate").show(); + $("#btn_history_restore").show(); + } + } +}; + +/** + * 进入全屏 + */ +Dock.fullScreen = function(element, presentation) { + if (element.requestFullscreen) { + element.requestFullscreen(); + } else if (element.mozRequestFullScreen) { + element.mozRequestFullScreen(); + } else if (element.webkitRequestFullscreen) { + element.webkitRequestFullscreen(); + } else if (element.msRequestFullscreen) { + element.msRequestFullscreen(); + } else { + // 无法进入全屏,提示错误 + if (presentation) { + $("#fullscreen_tip").find(".t").text("由于您的浏览器限制,无法进入演示视图。"); + } else { + $("#fullscreen_tip").find(".t").text("无法进入全屏视图,您可以按(F11)进入。"); + } + $("#fullscreen_tip").fadeIn(); + } +}; + +// coeUI修改 +var CoeUI = { + initNavigationEye : function() { + var layoutW = $("#designer_layout").width(); + var desiger = $("#designer").width(); + var designerHeight = $("#designer").height(); + var viewHeight = $("#navigation_view").height(); + // 总宽度减去可视区域的宽度,得到滚动条宽度 + var navleft = 0;// layoutW-desiger; + var navtop = designerHeight - viewHeight; + var dockLeft = navleft - 164; + var dockTop = navtop - 2; + $("#navigation_view").css("left", dockLeft); + $("#navigation_view").css("top", dockTop); + $("#navigation_view").css("width", 162); + $("#navigation_view").css("height", 255); + } +} + +// UI更多图形管理 +// UI.showShapesManage = function(){ +// $("#shapes_dialog").dialog({ +// buttons:[ +// {text:'确定',cls:"blue",handler:function(){alert(88);}}, +// {text:'取消',handler:function(){alert(22);}} +// ] +// }); +// } + diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.ui.mobile.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.ui.mobile.js new file mode 100644 index 00000000..b0fdbaa7 --- /dev/null +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.ui.mobile.js @@ -0,0 +1,4586 @@ +/** + * 用户界面JS + */ + +var UI = { + init : function() { + // 修改标题 + $(".diagram_title").bind("click", function() { + if ($(this).hasClass("readonly")) { + return; + } + var title = $(this).text(); + $(this).hide(); + $("#title_container").append(""); + $("#title_container").children("input").val(title.replace(/(^\s+)|(\s+$)/g, "")).select(); + $("#title_container").children("input").bind("blur", + function() { + changeTitle(); + }).bind("keydown", function(e) { + if (e.keyCode == 13) { + changeTitle(); + } + }); + }); + function changeTitle() { + var newTitle = $.trim($("#title_container").children("input").val()); + newTitle = newTitle.replace(/(^\s+)|(\s+$)/g, ""); + var oldTitle = $(".diagram_title").text(); + oldTitle = oldTitle.replace(/(^\s+)|(\s+$)/g, ""); + if (newTitle != oldTitle && chartId != "") { + var msgObj = { + action : "changeTitle", + title : newTitle + }; + CLB.send(msgObj); + } + var title = newTitle != "" ? newTitle : oldTitle; + $("title").text(title); + $(".diagram_title").text(title).show(); + $("#title_container").children("input").remove(); + // 更新父级的相关数据 + awsui.ajax.request({ + url : './jd?cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_updatetitle&sid=' + + encodeURIComponent(sid) + + '&uuid=' + + ruuid + + '&title=' + + encodeURIComponent(title) + + '&processDefId=' + + process.processDefId + + '&appId=' + + appId, + async : false,// 同步,默认为异步 + ok : function(msg) { + //同步设置文件属性中的流程名称 + $("#file_attribute").contents().find("input[id='plName']").val(title); + try { + window.opener.parent.window.top.document.main_iframe.teamAppFrame.contentWindow._d157b007c785d2d988d3d81c8ddcb1b8.contentWindow.refresh(); + } catch(e) { + try { + window.opener.parent.window.top.document.main_iframe.teamAppFrame.contentWindow._d157b007c785d2d988d3d81c8ddcb1b8.contentWindow.refresh(); + + } catch(e) {} + } + if (parent.repositoryTree) { + parent.repositoryTree.refreshNodeById({ + id : ruuid, + name : title + }); + } + if (parent.awsTabs) { + parent.awsTabs.setTitle(ruuid, title); + } + if(Model.define.coeProperties ){ + Model.define.coeProperties.fileName = title; + } + } + }) + } + /** ############################Toolbar列表############################ */ + // 撤销 + $("#bar_undo").button({ + onClick : function() { + MessageSource.undo(); + } + }); + // 恢复 + $("#bar_redo").button({ + onClick : function() { + MessageSource.redo(); + } + }); + // 格式刷 + $("#bar_brush").button({ + onClick : function() { + if ($("#bar_brush").button("isSelected")) { + // 取消格式刷 + $("#bar_brush").button("unselect"); + $("#designer_op_help").hide(); + $(document).unbind("keydown.cancelbrush"); + Utils.selectCallback = null; + } else { + Designer.clipboard.brush(); + } + } + }); + // 字体 + $("#bar_font_family").button({ + onMousedown : function() { + $("#font_list").dropdown({ + target : $("#bar_font_family"), + onSelect : function(item) { + var font = item.text(); + Designer.setFontStyle({ + fontFamily : font + }); + $("#bar_font_family").button("setText", + font); + } + }); + // 选中 + var family = $("#bar_font_family").text().trim(); + $("#font_list").children().each(function() { + if ($(this).text() == family) { + $("#font_list").dropdown("select", + $(this)); + return false; + } + }); + } + }); + // 字号 + $("#bar_font_size").spinner({ + min : 12, + max : 100, + step : 1, + unit : "px", + onChange : function(val) { + Designer.setFontStyle({ + size : val + }); + } + }); + $("#bar_font_size").spinner("setValue", "13px"); + // 加粗 + $("#bar_font_bold").button({ + onClick : function() { + var bold = !$("#bar_font_bold").button("isSelected"); + Designer.setFontStyle({ + bold : bold + }); + $("#bar_font_bold").toggleClass("selected"); + } + }); + // 斜体 + $("#bar_font_italic").button({ + onClick : function() { + var italic = !$("#bar_font_italic") + .button("isSelected"); + Designer.setFontStyle({ + italic : italic + }); + $("#bar_font_italic").toggleClass("selected"); + } + }); + // 下划线 + $("#bar_font_underline").button({ + onClick : function() { + var underline = !$("#bar_font_underline") + .button("isSelected"); + Designer.setFontStyle({ + underline : underline + }); + $("#bar_font_underline").toggleClass("selected"); + } + }); + // 字体颜色 + $("#bar_font_color").button({ + onMousedown : function() { + var color = $("#bar_font_color").button("getColor"); + $.colorpicker({ + target : $("#bar_font_color"), + onSelect : function(color) { + Designer.setFontStyle({ + color : color + }); + $("#bar_font_color").button("setColor", + color) + }, + color : color + }); + } + }); + // 文本对齐 + $("#bar_font_align").button({ + onMousedown : function() { + $("#font_align_list").dropdown({ + target : $("#bar_font_align"), + onSelect : function(item) { + var align = {}; + align[item.attr("cate")] = item + .attr("al"); + Designer.setFontStyle(align); + } + }); + } + }); + // 填充 + $("#bar_fill").button({ + onMousedown : function() { + var color = $("#bar_fill").button("getColor"); + $.colorpicker({ + target : $("#bar_fill"), + onSelect : function(color) { + Designer.setFillStyle({ + type : "solid", + color : color + }); + $("#bar_fill").button("setColor", color) + }, + color : color, + extend : "
    " + }); + $("#bar_fill_gradient").unbind().bind("click", function() { + Designer.setFillStyle({ + type : "gradient" + }); + $("#color_picker").dropdown("close"); + }); + $("#bar_fill_img").unbind().bind("click", function() { + UI.showImageSelect(function(fileId, w, h) { + Designer.setFillStyle({ + type : "image", + fileId : fileId, + imageW : w, + imageH : h + }); + }); + $("#color_picker").dropdown("close"); + }); + $("#bar_fill_more").unbind().bind("click", function() { + Dock.showView("graphic"); + $("#color_picker").dropdown("close"); + }); + } + }); + // 线条颜色 + $("#bar_line_color").button({ + onMousedown : function() { + var color = $("#bar_line_color").button("getColor"); + $.colorpicker({ + target : $("#bar_line_color"), + onSelect : function(color) { + Designer.setLineStyle({ + lineColor : color + }); + $("#bar_line_color").button("setColor", + color) + }, + color : color + }); + } + }); + // 线条宽度 + $("#bar_line_width").button({ + onMousedown : function() { + $("#line_width_list").dropdown({ + target : $("#bar_line_width"), + onSelect : function(item) { + var width = parseInt(item.text()); + Designer.setLineStyle({ + lineWidth : width + }); + } + }); + // 选中 + var width = Utils.getSelected()[0].lineStyle.lineWidth; + $("#line_width_list").children().each(function() { + if (parseInt($(this).text()) == width) { + $("#line_width_list").dropdown("select", + $(this)); + } + }); + } + }); + // 线条样式 + $("#bar_line_style").button({ + onMousedown : function() { + $("#line_style_list").dropdown({ + target : $("#bar_line_style"), + onSelect : function(item) { + var lineStyle = item.attr("line"); + Designer.setLineStyle({ + lineStyle : lineStyle + }); + } + }); + // 选中 + var style = Utils.getSelected()[0].lineStyle.lineStyle; + var item = $("#line_style_list").children("li[line=" + style + + "]"); + $("#line_style_list").dropdown("select", item); + } + }); + // 连接线类型 + $("#bar_linkertype").button({ + onMousedown : function() { + $("#line_type_list").dropdown({ + target : $("#bar_linkertype"), + onSelect : function(item) { + var type = item.attr("tp"); + Designer.setLinkerType(type); + var cls = item.children("div").attr("class"); + $("#bar_linkertype").children("div:eq(0)").attr( + "class", cls); + } + }); + } + }); + // 开始箭头 + $("#bar_beginarrow").button({ + onMousedown : function() { + $("#beginarrow_list").dropdown({ + target : $("#bar_beginarrow"), + onSelect : function(item) { + var arrow = item.attr("arrow"); + Designer.setLineStyle({ + beginArrowStyle : arrow + }); + var cls = item.children("div").attr("class"); + $("#bar_beginarrow").children("div:eq(0)").attr( + "class", cls); + } + }); + // 选中 + var style = Utils.getSelectedLinkers()[0].lineStyle.beginArrowStyle; + var item = $("#beginarrow_list").children("li[arrow=" + style + + "]"); + $("#beginarrow_list").dropdown("select", item); + } + }); + // 结束箭头 + $("#bar_endarrow").button({ + onMousedown : function() { + $("#endarrow_list").dropdown({ + target : $("#bar_endarrow"), + onSelect : function(item) { + var arrow = item.attr("arrow"); + Designer.setLineStyle({ + endArrowStyle : arrow + }); + var cls = item.children("div").attr("class"); + $("#bar_endarrow").children("div:eq(0)").attr("class", + cls); + } + }); + // 选中 + var style = Utils.getSelectedLinkers()[0].lineStyle.endArrowStyle; + var item = $("#endarrow_list").children("li[arrow=" + style + + "]"); + $("#endarrow_list").dropdown("select", item); + } + }); + // 顶层底层 + $("#bar_front").button({ + onClick : function() { + Designer.layerShapes("front"); + } + }); + $("#bar_back").button({ + onClick : function() { + Designer.layerShapes("back"); + } + }); + // 加解锁 + $("#bar_lock").button({ + onClick : function() { + Designer.lockShapes(); + } + }); + $("#bar_unlock").button({ + onClick : function() { + Designer.unlockShapes(); + } + }); + $("#bar_link").button({ + onClick : function() { + UI.showInsertLink(); + } + }); + $("#bar_risk").button({ + onClick : function() { + UI.showRiskDlg(); + } + }); + $("#bar_importShape").button({ + onClick : function() { + UI.showImportShapeDlg(); + } + }); + $("#bar_import").button({ + onClick : function() { + UI.showImportDlg(); + } + }); + //by bzp 上传制度附件 + $("#bar_importPolicyFile").button({ + onClick : function() { + UI.showImportPolicyFileDlg(); + } + }); + //by bzp end + $("#bar_upfile").button({ + onClick: function() { + openUpFile() + } + }); + $("#bar_activityNo").button({//节点按照编号排序 + onClick: function() { + UI.activityNoDlg(); + } + }); + /** ##############AWS新增工具栏菜单开始############# */ + // 排列 + $("#bar_arrange").button({ + onMousedown : function() { + $("#bar_list_arrange").dropdown({ + target : $("#bar_arrange"), + onSelect : function(item) { + menuSelected(item); + } + }); + } + }); + // 视图 + $("#bar_view").button({ + onMousedown : function() { + $("#bar_list_view").dropdown({ + target : $("#bar_view"), + onSelect : function(item) { + menuSelected(item); + } + }); + } + }); + // 插入 + /* + * $("#bar_insert").button({ onMousedown : function() { + * $("#bar_list_insert").dropdown({ target : $("#bar_insert"), onSelect : + * function(item) { menuSelected(item); } }); } }); + */ + /** ##############AWS新增工具栏菜单结束############# */ + + /** ##############菜单列表############## */ + $("#menu_bar").children().bind("mousedown", function(e) { + var tar = $(this); + showMenuBarList(tar); + e.stopPropagation(); + }); + $("#menu_bar").children().bind("mouseenter", function() { + var tar = $(this); + if ($("#ui_container").find(".options_menu:visible").length > 0) { + showMenuBarList(tar); + } + }); + + function showMenuBarList(menuBar) { + var menuId = menuBar.attr("menu"); + // 只读 + if (menuBar.hasClass("readonly")) { + return; + } + $("#" + menuId).dropdown({ + target : menuBar, + onSelect : function(item) { + menuSelected(item); + } + }); + if (menuId == "bar_list_page") { + if (Model.define.page.showGrid) { + $("#bar_list_page").dropdown( + "select", + $("#bar_list_page") + .children("li[ac=set_page_showgrid]")); + } else { + $("#bar_list_page").dropdown( + "unselect", + $("#bar_list_page") + .children("li[ac=set_page_showgrid]")); + } + var item = $("#bar_list_pagesize li[w=" + + Model.define.page.width + "][h=" + + Model.define.page.height + "]"); + if (item.length > 0) { + $("#bar_list_pagesize").dropdown("select", item); + } else { + $("#bar_list_pagesize").dropdown("select", + $("#page_size_custom")); + } + $("#page_size_w").spinner("setValue", + Model.define.page.width + "px"); + $("#page_size_h").spinner("setValue", + Model.define.page.height + "px"); + item = $("#bar_list_padding").children("li[p=" + + Model.define.page.padding + "]"); + $("#bar_list_padding").dropdown("select", item); + item = $("#bar_list_gridsize").children("li[s=" + + Model.define.page.gridSize + "]"); + $("#bar_list_gridsize").dropdown("select", item); + } else if (menuId == "bar_list_view") { + var item = $("#bar_list_view").children(".static[zoom='" + + Designer.config.scale + "']"); + if (item.length) { + $("#bar_list_page").dropdown("select", item); + } + } + } + + function menuSelected(item) { + var action = item.attr("ac"); + // 编辑菜单 + if (action == "rename") { + $(".diagram_title").trigger("click"); + } else if (action == "close") { + if (parent.closeTabById) { + parent.closeTabById(chartId); + } else { + window.close(); + } + + } else if (action == "saveAs") { + UI.showSaveAs(); + } else if (action == "preview") {//在线预览流程图片 + UI.doPreview(); + } else if (action == "saveImage") {//生成图片和缩略图 + UI.saveImage(); + } else if (action == "versionCompare") { + UI.showVersionCompare(); + } else if (action == "output") {// 导出流程手册并预览 + UI.doOutputProcess(); + } else if (action == "export") { + $("#export_dialog").dlg(); + } else if (action == "processExport") { + UI.processExport(); + } else if (action == "undo") { + MessageSource.undo(); + } else if (action == "redo") { + MessageSource.redo(); + } else if (action == "cut") { + Designer.clipboard.cut(); + } else if (action == "copy") { + Designer.clipboard.copy(); + } else if (action == "paste") { + Designer.clipboard.paste(); + } else if (action == "duplicate") { + Designer.clipboard.duplicate(); + } else if (action == "brush") { + Designer.clipboard.brush(); + } else if (action == "selectall") { + Designer.selectAll(); + } else if (action == "openNewPage") { + UI.openNewPage();//新页面打开 + } else if (action == "batchreplace") { + UI.batchReplace(); + } else if (action == "delete") { + Designer.op.removeShape(); + // 视图缩放 + } else if (action == "zoom") { + var zoom = item.attr("zoom"); + if (zoom == "in") { + Designer.zoomIn(); + } else if (zoom == "out") { + Designer.zoomOut(); + } else { + var zoomScale = parseFloat(zoom); + Designer.setZoomScale(zoomScale); + } + // 插入 + } else if (action == "insert") { + var insertType = item.attr("in"); + if (insertType == "text") { + Designer.op.changeState("creating_free_text"); + } else if (insertType == "image") { + UI.showImageSelect(function(fileId, w, h) { + UI.insertImage(fileId, w, h); + }); + } else if (insertType == "line") { + Designer.op.changeState("creating_free_linker"); + } + // 页面 + } else if (action == "set_page_size") { + var w = parseInt(item.attr("w")); + var h = parseInt(item.attr("h")); + Designer.setPageStyle({ + width: w, + height: h + }); + } else if (action == "set_page_padding") { + var p = parseInt(item.attr("p")); + Designer.setPageStyle({ + padding: p + }) + } else if (action == "set_page_showgrid") { + if (item.menuitem("isSelected")) { + item.menuitem("unselect"); + Designer.setPageStyle({ + showGrid: false + }); + } else { + item.menuitem("select"); + Designer.setPageStyle({ + showGrid: true + }); + } + } else if (action == "set_page_gridsize") { + var s = parseInt(item.attr("s")); + Designer.setPageStyle({ + gridSize: s + }) + } + // 排列 + else if (action == "front") { + Designer.layerShapes("front"); + } else if (action == "back") { + Designer.layerShapes("back"); + } else if (action == "forward") { + Designer.layerShapes("forward"); + } else if (action == "backward") { + Designer.layerShapes("backward"); + } else if (action == "align_shape") { + var align = item.attr("al"); + Designer.alignShapes(align); + } else if (action == "distribute_shape") { + var type = item.attr("dis"); + Designer.distributeShapes(type); + } else if (action == "match_size") { + if (item.attr("custom")) { + Dock.showView("metric"); + } else { + var type = {}; + var w = item.attr("w"); + var h = item.attr("h"); + if (w) { + type.w = w; + } + if (h) { + type.h = h; + } + Designer.matchSize(type); + } + } else if (action == "lock") { + Designer.lockShapes(); + } else if (action == "unlock") { + Designer.unlockShapes(); + } else if (action == "group") { + Designer.group(); + } else if (action == "ungroup") { + Designer.ungroup(); + } else if (action == "hotkey") { + UI.showHotKey(); + } else if (action == "feedback") { + UI.showFeedBack(); + } else if (action == "getting_started") { + UI.gettingStart(); + } + } + $("#page_size_w").spinner({ + min : 200, + unit : "px", + step : 100, + onChange : function(val) { + Designer.setPageStyle({ + width : val + }); + } + }); + $("#page_size_h").spinner({ + min : 200, + unit : "px", + step : 100, + onChange : function(val) { + Designer.setPageStyle({ + height : val + }); + } + }); + // 给设置页面背景色,放一个colorpicker + var pickerHtml = $("#color_picker").html(); + var newPicker = $("").appendTo($("#bar_page_color")); + newPicker.css("right", "-179px"); + newPicker.children(".color_items").children("div").unbind().bind( + "click", function() { + var color = $(this).css("background-color"); + color = color.replace(/\s/g, ""); + color = color.substring(4, color.length - 1); + Designer.setPageStyle({ + backgroundColor : color + }); + $("#bar_list_page").dropdown("close"); + }); + // 抛出事件,控制状态 + Designer.events.push("selectChanged", 0); + Designer.events.push("clipboardChanged", 0); + Designer.events.push("undoStackChanged", 0); + Designer.events.push("redoStackChanged", 0); + }, + /** + * 更新UI + */ + update : function() { + var selectedIds = Utils.getSelectedIds(); + var count = selectedIds.length; + var linkerIds = Utils.getSelectedLinkerIds(); + var linkerCount = linkerIds.length; + var shapeIds = Utils.getSelectedShapeIds(); + var shapeCount = shapeIds.length; + var lockedCount = Utils.getSelectedLockedIds().length; + var groupCount = Utils.getSelectedGroups().length; + // 排列菜单 + var arrangeMenu = $("#bar_list_arrange"); + if (count == 0) { + $(".toolbar").find(".selected").removeClass("selected"); + // 没有选中,让某些按钮失效 + if ($("#designer_op_help").is(":visible")) { + $("#bar_brush").button("enable"); + $("#bar_brush").button("select"); + } else { + $("#bar_brush").button("disable"); + } + // 字体 + $("#bar_font_family").button("disable"); + $("#bar_font_size").button("disable"); + $("#bar_font_bold").button("disable"); + $("#bar_font_italic").button("disable"); + $("#bar_font_underline").button("disable"); + $("#bar_font_color").button("disable"); + $("#bar_font_align").button("disable"); + // 线条 + $("#bar_line_color").button("disable"); + $("#bar_line_width").button("disable"); + $("#bar_line_style").button("disable"); + // 顶层底层 + $("#bar_front").button("disable"); + $("#bar_back").button("disable"); + // 锁定 + $("#bar_lock").button("disable"); + // 编辑菜单 + var editMenu = $("#bar_list_edit"); + editMenu.children("li[ac=cut]").menuitem("disable"); + editMenu.children("li[ac=copy]").menuitem("disable"); + editMenu.children("li[ac=duplicate]").menuitem("disable"); + editMenu.children("li[ac=brush]").menuitem("disable"); + editMenu.children("li[ac=delete]").menuitem("disable"); + // 排列菜单 + arrangeMenu.children("li[ac=front]").menuitem("disable"); + arrangeMenu.children("li[ac=back]").menuitem("disable"); + arrangeMenu.children("li[ac=forward]").menuitem("disable"); + arrangeMenu.children("li[ac=backward]").menuitem("disable"); + arrangeMenu.children("li[ac=lock]").menuitem("disable"); + // 节点编号排序 + $("#bar_activityNo").button("enable"); + $("#bar_activityNo div").removeClass('extend_activityNoDisable'); + $("#bar_activityNo div").addClass('extend_activityNo'); + } else { + if (editable) { + // 选中,让某些按钮激活 + $("#bar_brush").button("enable"); + if ($("#designer_op_help").is(":visible")) { + $("#bar_brush").button("select"); + } + $("#bar_font_family").button("enable"); + $("#bar_font_size").button("enable"); + $("#bar_font_bold").button("enable"); + $("#bar_font_italic").button("enable"); + $("#bar_font_underline").button("enable"); + $("#bar_font_color").button("enable"); + $("#bar_font_align").button("enable"); + // 线条 + $("#bar_line_color").button("enable"); + $("#bar_line_width").button("enable"); + $("#bar_line_style").button("enable"); + // 顶层底层 + $("#bar_front").button("enable"); + $("#bar_back").button("enable"); + // 锁定 + $("#bar_lock").button("enable"); + // 编辑菜单 + var editMenu = $("#bar_list_edit"); + editMenu.children("li[ac=cut]").menuitem("enable"); + editMenu.children("li[ac=copy]").menuitem("enable"); + editMenu.children("li[ac=duplicate]").menuitem("enable"); + editMenu.children("li[ac=brush]").menuitem("enable"); + editMenu.children("li[ac=delete]").menuitem("enable"); + // 排列菜单 + arrangeMenu.children("li[ac=front]").menuitem("enable"); + arrangeMenu.children("li[ac=back]").menuitem("enable"); + arrangeMenu.children("li[ac=forward]").menuitem("enable"); + arrangeMenu.children("li[ac=backward]").menuitem("enable"); + arrangeMenu.children("li[ac=lock]").menuitem("enable"); + // 设置Toolbar样式 + var shape = Model.getShapeById(selectedIds[0]); + $("#bar_font_family").button("setText", shape.fontStyle.fontFamily); + $("#bar_font_size") + .spinner("setValue", shape.fontStyle.size + "px"); + if (shape.fontStyle.bold) { + $("#bar_font_bold").button("select"); + } else { + $("#bar_font_bold").button("unselect"); + } + if (shape.fontStyle.italic) { + $("#bar_font_italic").button("select"); + } else { + $("#bar_font_italic").button("unselect"); + } + if (shape.fontStyle.underline) { + $("#bar_font_underline").button("select"); + } else { + $("#bar_font_underline").button("unselect"); + } + $("#bar_font_color").button("setColor", shape.fontStyle.color); + $("#bar_line_color").button("setColor", shape.lineStyle.lineColor); + + // 节点编号排序 + $("#bar_activityNo").button("disable"); + $("#bar_activityNo div").removeClass('extend_activityNo'); + $("#bar_activityNo div").addClass('extend_activityNoDisable'); + } + } + + // AWS增加的按钮需要被控制开始 + if (count == 0) { + $("#toolbar-data-attr").button("disable"); + // 节点属性 + $("#toolbar-data-attr").unbind("click"); + $("#bar_arrange").button("disable"); + } else { + $("#toolbar-data-attr").button("enable"); + // 节点属性 + $("#toolbar-data-attr").bind("click", function() { + showPropertiesDialog(); + }); + $("#bar_arrange").button("enable"); + } + // AWS增加的按钮需要被控制完毕 + + // 通过图形的数量,判读是否可以填充 + if (shapeCount == 0) { + $("#bar_fill").button("disable"); + $("#toolbar-shape-attr").button("disable"); //形状属性 + } else { + if (editable) { + $("#bar_fill").button("enable"); + } + var shape = Model.getShapeById(shapeIds[0]); + // 图形填充 + if (shape.fillStyle.type == "solid") { + $("#bar_fill").button("setColor", shape.fillStyle.color); + } else if (shape.fillStyle.type == "gradient") { + $("#bar_fill").button("setColor", shape.fillStyle.endColor); + } + if(shapeCount == 1 && shape.name == BPMN_TYPE_USER_TASK) { //控制值选择一个人工任务时形状属性可用 + $("#toolbar-shape-attr").button("enable"); //形状属性 + } else { + $("#toolbar-shape-attr").button("disable"); //形状属性 + } + } + if (shapeCount != 1) { + $("#bar_link, #bar_risk").button("disable"); + $("#dock_btn_shapeConfig").button("disable"); + $("#dock_btn_shapeConfig").bind('click', function() { + $.simpleAlert("请选择形状"); + }); + } else { + $("#dock_btn_shapeConfig").unbind('click'); + $("#dock_btn_shapeConfig").button("enable"); + if (editable) { + $("#bar_link").button("enable"); + } + // 关联/推送文件不显示 + if ($('#bar_rmark').length == 0 && $('#bar_cancel_aws_correlate').length == 0) { + $("#bar_risk").button("enable"); + } else { + $("#bar_risk").button("disable"); + } + } + // 通过连接线的数量,判断是否可以修改箭头等 + if (linkerCount == 0) { + $("#bar_linkertype").button("disable"); + $("#bar_beginarrow").button("disable"); + $("#bar_endarrow").button("disable"); + } else { + $("#bar_linkertype").button("enable"); + $("#bar_beginarrow").button("enable"); + $("#bar_endarrow").button("enable"); + var shape = Model.getShapeById(linkerIds[0]); + // 设置Toolbar的线条样式 + $("#bar_linkertype").children("div:eq(0)").attr("class", + "ico linkertype_" + shape.linkerType.toLowerCase()); + if ( typeof shape.lineStyle.beginArrowStyle != "undefined") { + $("#bar_beginarrow").children("div:eq(0)").attr( + "class", + "ico ico_arrow larrow_" + + shape.lineStyle.beginArrowStyle.toLowerCase()); + } + if ( typeof shape.lineStyle.endArrowStyle != "undefined") { + $("#bar_endarrow").children("div:eq(0)").attr( + "class", + "ico ico_arrow rarrow_" + + shape.lineStyle.endArrowStyle.toLowerCase()); + } + + + } + // 通过锁定的数量,判断是否可以解除锁定 + if (lockedCount == 0) { + $("#bar_unlock").button("disable"); + arrangeMenu.children("li[ac=unlock]").menuitem("disable"); + } else { + $("#bar_unlock").button("enable"); + arrangeMenu.children("li[ac=unlock]").menuitem("enable"); + } + // 是否激活组合、对齐,条件是选中图形要不少于2个 + if (count < 2) { + arrangeMenu.children("li[ac=group]").menuitem("disable"); + $("#bar_arrange_align").menuitem("disable"); + } else { + arrangeMenu.children("li[ac=group]").menuitem("enable"); + $("#bar_arrange_align").menuitem("enable"); + } + // 是否激活匹配大小,条件是选中形状要不少于2个 + if (shapeCount < 2) { + $("#bar_arrange_match").menuitem("disable"); + } else { + $("#bar_arrange_match").menuitem("enable"); + } + // 是否激活排列图形菜单,条件是选中图形要不少于3个 + if (count < 3) { + $("#bar_arrange_dist").menuitem("disable"); + } else { + $("#bar_arrange_dist").menuitem("enable"); + } + // 通过组合的数量,判断是否可以取消组合 + if (groupCount == 0) { + arrangeMenu.children("li[ac=ungroup]").menuitem("disable"); + } else { + arrangeMenu.children("li[ac=ungroup]").menuitem("enable"); + } + //文件串联分析工具在未选择图形的时候有效 + if($("#dock_btn_eteanalysis").length != 0) { + if (count == 0) { + $("#dock_btn_eteanalysis").find(".awsui-iconfont").css("color","black"); + $("#dock_btn_eteanalysis").button("enable"); + $("#dock_btn_eteanalysis").removeAttr("onclick"); + $("#dock_btn_eteanalysis").off("click").on("click", function(){ + var f = $('#eteCascadeAnalysisForm'); + f.find(':input[name=uuid]').val(ruuid); + f.submit(); + }); + } else { + $("#dock_btn_eteanalysis").find(".awsui-iconfont").css("color","gray"); + $("#dock_btn_eteanalysis").button("disable"); + $("#dock_btn_eteanalysis").removeAttr("onclick"); + $("#dock_btn_eteanalysis").off("click"); + } + } + }, + /** + * 打开插入链接 + */ + showInsertLink : function() { + $("#link_dialog").dlg(); + var addr = Utils.getSelected()[0].link; + if (!addr) { + addr = ""; + } + $("#linkto_addr").val(addr).select(); + $("#linkto_addr").unbind().bind("keydown", function(e) { + if (e.keyCode == 13) { + UI.setLink(); + } + }); + }, + /** + * 设置连接 + */ + setLink : function() { + var newLink = $("#linkto_addr").val(); + var shape = Utils.getSelected()[0]; + shape.link = newLink; + Model.update(shape); + $('#link_dialog').dlg('close'); + }, + /** + * 选中图片后的回调 + * + * @type {} + */ + imageSelectedCallback : null, + /** + * 打开图片选择 + */ + showImageSelect : function(callback) { + if (callback) { + this.imageSelectedCallback = callback; + } else { + this.imageSelectedCallback = null; + } + this.fetchingRequest = null; + var height = $(window).height() - 200; + if (height > 550) { + height = 550; + } else if (height < 200) { + height = 200; + } + $(".image_list").height(height); + // this.showImageSelectContent("upload"); + $("#image_dialog").dlg({ + onClose : function() { + if (UI.fetchingRequest) { + UI.fetchingRequest.abort(); + } + } + }); + // 加载用户图片 + if ($("#image_select_upload").is(":visible")) { + UI.loadUserImages(); + }; + // 左侧分类绑定事件 + $(".image_sources").children().unbind().bind("click", function() { + UI.showImageSelectContent($(this).attr("ty")); + }); + // 上传 + $("#upload_img_res").empty(); + $("#input_upload_image").unbind().bind("change", function() { + $("#upload_img_res") + .html("上传中..."); + $("#frm_upload_image").submitForm({ + success : function(result) { + if (result.result == "type_wrong") { + $("#upload_img_res").html("此文件不是图片,请重新选择"); + } else if (result.result == "size_wrong") { + $("#upload_img_res").html("文件大小超出要求,最大2M"); + } else if (result.result == "exception") { + $("#upload_img_res").html("无法使用此图片,请选择其他图片"); + } else { + var img = result.image; + UI.setShapeImage(img.fileId, img.imageW, + img.imageH); + } + } + }); + }); + // 输入URL + $("#input_img_url").val(""); + $("#img_url_area").empty(); + var oldUrl = ""; + function urlChanged() { + var url = $("#input_img_url").val().trim(); + if (url != oldUrl) { + oldUrl = url + if (url != "") { + if (url.indexOf("http") < 0) { + url = "http://" + url; + } + $("#img_url_area") + .html("正在加载预览..."); + var newImage = $("").appendTo("#img_url_area"); + newImage.unbind().bind("load", function() { + newImage.show().addClass("img_url_loaded"); + $(".img_url_loading_tip").remove(); + }).bind("error", function() { + $("#img_url_area") + .html("
    无法在此地址下加载图片。
    • 请检查图片地址是否输入正确。
    • 确保图片地址是公开的。
      "); + }); + } + } + } + $("#input_img_url").unbind().bind("paste", function() { + urlChanged(); + }).bind("keyup", function() { + urlChanged(); + }); + // 搜索 + $("#input_img_search").unbind().bind("keydown", function(e) { + if (e.keyCode == 13) { + UI.searchImgByGoogle(); + } + }); + $("#btn_img_search").unbind().bind("click", function() { + UI.searchImgByGoogle(); + }); + // 完成按钮 + $("#set_image_submit").button("enable"); + $("#set_image_submit").button({ + onClick : function() { + var currentTab = $(".image_sources").children(".active") + .attr("ty"); + if (currentTab == "upload") { + var selectedImg = $("#user_image_items") + .children(".image_item_selected"); + if (selectedImg.length > 0) { + var fileId = selectedImg.attr("fileId"); + var imageW = selectedImg.attr("w"); + var imageH = selectedImg.attr("h"); + UI.setShapeImage(fileId, imageW, imageH); + } else { + $("#image_dialog").dlg("close"); + } + } else if (currentTab == "url") { + if ($(".img_url_loaded").length > 0) { + var url = $(".img_url_loaded").attr("src"); + UI.setShapeImageByURL(url); + } else { + $("#image_dialog").dlg("close"); + } + } else { + // 搜索 + var selectedImg = $("#google_image_items") + .children(".image_item_selected"); + if (selectedImg.length > 0) { + var url = selectedImg.attr("u"); + UI.setShapeImageByURL(url); + } else { + $("#image_dialog").dlg("close"); + } + } + } + }); + // 取消按钮 + $("#set_image_cancel").button({ + onClick : function() { + $("#image_dialog").dlg("close"); + } + }); + $("#set_image_text").empty(); + }, + /** + * 显示图片设置类型 + */ + showImageSelectContent : function(type) { + $(".image_list").hide(); + $("#image_select_" + type).show().find("input[type=text]").select(); + $(".image_sources").children().removeClass("active"); + $(".image_sources").children("li[ty=" + type + "]").addClass("active"); + }, + /** + * 加载用户图片 + */ + loadUserImages : function(refresh) { + $("#user_image_items").empty(); + $.ajax({ + url : "/user_image/list", + success : function(data) { + if (data.images) { + for (var i = 0; i < data.images.length; i++) { + var img = data.images[i]; + UI.appendUserImage(img); + } + $("#user_image_items") + .append("
      "); + } + } + }); + $("#user_image_items").attr("loaded", "true"); + }, + searchIndex : 0, + searchKeywords : "", + /** + * 通过Google搜索图片 + */ + searchImgByGoogle : function() { + var keywords = $("#input_img_search").val(); + if (keywords.trim() != "") { + $("#google_image_items").empty(); + this.searchKeywords = encodeURI(keywords); + this.searchIndex = 0; + this.loadGoogleImg(); + } else { + $("#input_img_search").focus(); + } + }, + /** + * 加载Google图片 + */ + loadGoogleImg : function() { + $ + .getScript("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=" + + this.searchKeywords + + "&rsz=8&start=" + + (this.searchIndex * 16) + + "&callback=UI.googleImgCallback"); + $ + .getScript("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=" + + this.searchKeywords + + "&rsz=8&start=" + + (this.searchIndex * 16 + 8) + + "&callback=UI.googleImgCallback"); + $(".gg_img_more").remove(); + $("#google_image_items") + .append("
      正在加载图片...
      "); + this.searchIndex++; + }, + /** + * Google搜索回调 + * + * @param {} + * data + */ + googleImgCallback : function(data) { + var responseData = data.responseData; + var results = responseData.results; + for (var i = 0; i < results.length; i++) { + var item = results[i]; + UI.appendGoogleImage(item); + } + $("#google_image_items").append("
      "); + $(".img_gg_loading_tip").remove(); + $(".gg_img_more").remove(); + if (this.searchIndex <= 3) { + $("#google_image_items") + .append("
      显示更多结果...
      "); + } + }, + /** + * 添加一个用户图片 + */ + appendUserImage : function(img) { + var box = $("
      ").appendTo($("#user_image_items")); + box.unbind().bind("click", function() { + $(".image_item_selected") + .removeClass('image_item_selected'); + $(this).addClass('image_item_selected'); + }).bind("mouseenter", function() { + var target = $(this); + var remove = $("
      ") + .appendTo(target); + var id = target.attr("id"); + remove.bind("click", function() { + target.fadeOut(); + $.ajax({ + url : "/user_image/remove", + data : { + imageId : id + } + }); + }); + }).bind("mouseleave", function() { + $(this).find(".ico_remove_red").remove(); + }); + var location = img.fileId; + var newImage = $("").appendTo(box); + newImage.bind("load", function() { + $(this).css("margin-top", (140 - $(this).height()) / 2); + }); + }, + /** + * 添加一个Google搜索的图片 + */ + appendGoogleImage : function(img) { + var title = img.title + " (" + img.width + " × " + img.height + ")"; + var box = $("
      ").appendTo($("#google_image_items")); + box.unbind().bind("click", function() { + $(".image_item_selected") + .removeClass('image_item_selected'); + $(this).addClass('image_item_selected'); + }); + var newImage = $("").appendTo(box); + newImage.bind("load", function() { + $(this).css("margin-top", (140 - $(this).height()) / 2); + }); + }, + /** + * 设置形状的背景图片 + * + * @param {} + * source + */ + setShapeImage : function(fileId, w, h) { + if (this.imageSelectedCallback) { + this.imageSelectedCallback(fileId, w, h); + } + $("#image_dialog").dlg("close"); + }, + /** + * 加载URL图片的ajax请求对象 + * + * @type {} + */ + fetchingRequest : null, + /** + * 通过URL设置图片 + * + * @param {} + * url + */ + setShapeImageByURL : function(url) { + $("#set_image_text").removeClass("errored").text("正在应用图片,请稍候..."); + $("#set_image_submit").button("disable"); + UI.fetchingRequest = $.ajax({ + url : "/user_image/reference", + data : { + url : url + }, + success : function(result) { + if (result.result == "exception") { + $("#set_image_text").addClass("errored") + .html("无法使用此图片,请选择其他图片"); + } else { + $("#set_image_text").empty(); + var img = result.image; + UI + .setShapeImage(img.fileId, img.imageW, + img.imageH); + } + } + }); + }, + /** + * 插入图片 + * + * @param {} + * source + * @param {} + * location + * @param {} + * w + * @param {} + * h + */ + insertImage : function(fileId, w, h) { + w = parseInt(w); + h = parseInt(h); + var layout = $("#designer_layout"); + var centerX = layout.width() / 2 + layout.offset().left; + var centerY = layout.height() / 2 + layout.offset().top; + var pos = Utils.getRelativePos(centerX, centerY, $("#designer_canvas")); + var shape = Model.create("standardImage", pos.x.restoreScale() - w / 2, + pos.y.restoreScale() - h / 2); + shape.props.w = w; + shape.props.h = h; + shape.fillStyle = { + type : "image", + fileId : fileId, + display : "fill", + imageW : w, + imageH : h + }; + Model.add(shape); + Designer.painter.renderShape(shape); + Utils.unselect(); + Utils.selectShape(shape.id); + }, + /** + * 导出流程手册 + */ + doOutputProcess: function () { + }, + /** + * 加载预览数据 + */ + doPreview: function () { + if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { + if (editable) { + $.simpleAlert('页面中有未保存的内容,请先保存'); + return; + } + } + $.simpleAlert('请稍后', 'loading'); + $.post("./jd", { + cmd: "com.actionsoft.apps.coe.pal_pl_repository_df", + sid: sid, + "uuid": chartId + }, function t(msg) { + $("#previewContent .procImg").remove(); + if (typeof(msg) == "string") { + msg = eval('(' + msg + ')'); + } + msg = msg.data.url; + if (msg == "") { + alert("请您先保存一个版本!"); + } else { + var img = $(""); + var hh = img.width(); + $("#previewContent").append(img); + } + $("#previewDialog").dialog({ + title: "预览", + width: window.innerWidth * 0.9, + height: window.innerHeight * 0.92 + }); + $.simpleAlert("close"); + }, "text"); + }, + /** + * 生成图片和缩略图 + */ + saveImage : function() { + if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { + if (editable) { + $.simpleAlert('页面中有未保存的内容,请先保存'); + return; + } + } + $.simpleAlert('请稍后', 'loading'); + $.ajax({ + type: "POST", + url: "./jd", + data: { + sid: sid, + cmd: "com.actionsoft.apps.coe.pal_pl_repository_image_save", + uuid: chartId + }, + success: function (r, textStatus, jqXHR) { + if(r.result == 'ok' ) { + $.simpleAlert("close"); + $.simpleAlert('图片创建完成', 'ok', 2000, {callback:function() { + var options = { + title : "提示", + content:"是否打开图片预览", + onConfirm: function(){ + $.simpleAlert("close"); + UI.doPreview();// 预览 + }, + onCancel : function(){ + } + }; + $.confirm(options); + }}); + } else { + console.log(r); + $.simpleAlert("close"); + $.simpleAlert(r.data.desc, 'error'); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + $.simpleAlert(errorThrown, 'err'); + console.log(jqXHR) + console.log(textStatus) + console.log(errorThrown) + } + }); + }, + showVersionCompare : function() { + $("#dialog_version_compare").dialog({ + buttons:[ + {text:'确定',cls:"blue",handler:function(){ + var checkboxs = $("input[name='version']:checked"); + var numCheck = checkboxs.length; + if (numCheck != 2) { + $.simpleAlert("请选择两个需要对比的版本", "warning"); + return; + } + var firstId; + var secondId; + var values = []; + var names = []; + checkboxs.each(function (){ + values.push($(this).val()); + names.push($(this).data("name")); + }); + firstId = values[0]; + secondId = values[1]; + awsui.ajax.post("./jd?sid="+sid+"&cmd=com.actionsoft.apps.coe.pal_pl_version_compare", { firstId: firstId, secondId: secondId}, function(data) { + $("#dialog_version_compare").dialog("close"); + var fileAttrCompare = data.fileAttrCompare; + var shapeAttrCompare = data.shapeAttrCompare; + var fileHtml = ""; + var shapeHtml = ""; + if (fileAttrCompare.length > 0) { + for (var i = 0; i < fileAttrCompare.length; i++) { + fileHtml += fileAttrCompare[i] + "
      "; + } + $("#fileAttr").html(fileHtml); + } + if (shapeAttrCompare.length > 0) { + for (var i = 0; i < shapeAttrCompare.length; i++) { + shapeHtml += shapeAttrCompare[i] + "
      "; + } + $("#shapeAttr").html(shapeHtml); + } + $("#versionCompareResult").show(); + $("#dialog_version_compare_result").dialog({ + + }); + }, 'json'); + } + } + ] + }); + }, + /** + * 流程导出 + */ + processExport : function() { + //先处理准备好导出的流程数据 + if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { + if (editable) { + $.simpleAlert('页面中有未保存的内容,请先保存'); + return; + } + } + var repositoryIds = []; + repositoryIds.push(ruuid); + var options = { + title : "提示", + content:"确定导出并下载文件吗?", + onConfirm: function(){ + $.simpleAlert('正在导出', 'loading'); + $.ajax({ + type: "POST", + url: "./jd", + data: { + sid: sid, + cmd: "com.actionsoft.apps.coe.pal_pl_export_handle", + repositoryIds: JSON.stringify(repositoryIds) + }, + success: function (r, textStatus, jqXHR) { + if(r.result == 'ok' ) { + $.simpleAlert("close"); + $.simpleAlert('导出完成', 'ok', 2000, {callback:function() { + $.simpleAlert("close"); + // 下载 + $.ajax({ + type: "POST", + url: "./jd", + data: { + sid: sid, + cmd: "com.actionsoft.apps.coe.pal_pl_export", + exportTitle: r.data.exportTitle, + exportCount: r.data.exportCount, + dcId: r.data.dcId, + }, + success: function (r, textStatus, jqXHR) { + if(r.result == 'ok' ) { + window.location.href = r.data.downLoadUrl; + } else { + console.log(r); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + $.simpleAlert(errorThrown, 'err'); + console.log(jqXHR) + console.log(textStatus) + console.log(errorThrown) + } + }); + }}); + } else { + console.log(r); + $.simpleAlert("close"); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + $.simpleAlert(errorThrown, 'err'); + console.log(jqXHR) + console.log(textStatus) + console.log(errorThrown) + } + }); + }, + onCancel : function(){ + } + }; + $.confirm(options); + }, + openNewPage : function() { + window.open(location.href); + }, + /** + * 执行导出 + */ + doExport : function() { + // var definition = JSON.stringify(Model.define); + // $("#export_definition").val(definition); + // $("#export_title").val($(".diagram_title").text()); + // $("#export_form").submit(); + if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { + if (editable) { + $.simpleAlert('页面中有未保存的内容,请先保存'); + return; + } + } + $.simpleAlert('请稍后', 'loading'); + var type = $('input[name="type"]:checked').val(); + $.post("./jd", { + cmd : "com.actionsoft.apps.coe.pal_pl_repository_download_png", + sid : sid, + "uuid" : chartId, + type : type + }, function t(msg) { + if (typeof(msg) == "string") { + msg = eval('(' + msg + ')'); + } + msg = msg.data.url; + if (msg == "") { + alert("请您先保存一个版本!"); + } else { + //window.open(msg); + $("#export_iframe").attr("src", msg); + } + $.simpleAlert("close"); + }, "text"); + $('#export_dialog').dlg('close'); + }, + /** + * 展示hotkey列表 + */ + showHotKey : function() { + var height = $(window).height() - 175; + if (height > 500) { + height = 500 + "px"; + } + $("#hotkey_list").dlg(); + $("#hotkey_list").css({ + "top" : "28px" + }); + $("#hotkey_list .dialog_content").css({ + "height" : height + }); + }, + /** + * 显示反馈dialog + */ + showFeedBack : function() { + $("#send_feedback").css({ + width : "auto", + height : "auto" + }); + var sendFeedBack = $("#send_feedback"); + sendFeedBack.dlg(); + $("#feedback_email").focus(); + $("#feedback_message").val(""); + $(".feedback_error_email_format").hide(); + $(".feedback_error_msg").hide(); + }, + /** + * 发送反馈 + */ + sendFeedBack : function(dom) { + $(".feedback_error_email_format").hide(); + $(".feedback_error_msg").hide(); + var email = $.trim($("#feedback_email").val()); + var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/; + if (!reg.test(email)) { + $("#feedback_email").focus(); + $(".feedback_error_email_format").show(); + return; + } + var feedbackMessage = $.trim($("#feedback_message").val()); + if (feedbackMessage == "") { + $("#feedback_message").val("").focus(); + $(".feedback_error_msg").show(); + return; + } + Util.ajax({ + url : "/support/save_ask", + data : { + content : feedbackMessage, + username : $("#feedback_name").val(), + email : email, + url : location.href + }, + success : function(data) { + $(".dlg_mask").remove(); + $("#send_feedback").animate({ + left : $(window).width(), + top : $(window).height(), + width : 0, + height : 0, + opacty : 0.2 + }); + } + }); + }, + /** + * 打开开始向导 + */ + gettingStart : function(delay) { + this.showStartStep(1); + }, + showStartStep : function(step, dom) { + $(".mark_content").hide(); + var content = $(".mark" + step + "_content"); + content.show(); + var top; + var left; + if (step == 1) { + top = $("#shape_panel").offset().top + 70; + left = $("#shape_panel").offset().left + $("#shape_panel").width() + + 10; + } else if (step == 2) { + top = $(".row2").offset().top + 30; + left = $("#menu_bar_insert").offset().left + + $("#menu_bar_insert").width() - content.outerWidth() / 2; + } else if (step == 3) { + top = $(".toolbar").offset().top + 40; + left = 270; + } else if (step == 4) { + top = $("#dock").offset().top + 10; + left = $("#dock").offset().left - content.outerWidth() - 10 + } else if (step == "created") { + top = dom.offset().top + dom.height() / 2 - content.outerHeight() + / 2; + if (top <= 0) { + top = 0; + } + if (top + content.outerHeight() > $(window).height()) { + top = $(window).height() - content.outerHeight(); + } + left = dom.offset().left + dom.width() + 10; + } + content.css({ + top : top, + left : left + }); + }, + /** + * 关闭开始向导 + * + * @param {} + * dom + */ + closeGettingStart : function(dom) { + $(".mark_content").hide(); + }, + /** + * Getting Start END-- + */ + + showAddColla : function() { + Util.ajax({ + url : "/collaboration/get_colla_role_list", + data : { + chartId : chartId + }, + success : function(data) { + $("#colla_dialog").find(".role_list").html(data).scrollTop(999); + $("#colla_dialog").removeClass("_update"); + $("#colla_dialog").css({ + "top" : ($(window).height() - $("#colla_dialog") + .outerHeight()) + * 0.5 + "px" + }); + $("#colla_dialog").dlg(); + $("#colla_suggest_box").empty(); + $("#add_prompt4").hide(); + $("#add_prompt3").hide(); + $("#add_prompt2").hide(); + $("#add_prompt1").show(); + } + }); + + var lastVal = ""; + $("#input_add_colla").val("").unbind().bind("keyup", function() { + // 加载信息 + var value = $(this).val(); + if (value == lastVal) { + return; + } + lastVal = value; + if (value == "") { + $("#colla_suggest_box").empty(); + $("#add_prompt4").hide(); + $("#add_prompt3").hide(); + $("#add_prompt2").hide(); + $("#add_prompt1").show(); + return; + } + Util.ajax({ + url : "/collaboration/get_new_members", + data : { + value : value + }, + success : function(data) { + $("#colla_suggest_box").html(data); + if ($("#colla_suggest_box").find("ul").length > 0) { + $("#add_prompt4").hide(); + $("#add_prompt3").hide(); + $("#add_prompt2").show(); + $("#add_prompt1").hide(); + } else { + $("#add_prompt4").hide(); + $("#add_prompt3").hide(); + $("#add_prompt2").hide(); + $("#add_prompt1").show(); + } + $(".colla_suggest").find("li").unbind().bind("click", + function() { + $("#add_prompt4").hide(); + $("#add_prompt3").hide(); + $("#add_prompt2").show(); + $("#add_prompt1").hide(); + var value = $.trim($("#input_add_colla").val()); + $(".colla_suggest").find("li") + .removeClass("seled"); + $(this).addClass("seled"); + var type = $(this).attr("joinType"); + var target = $(this).attr("target"); + if (type == "user") { + var userName = $(this).attr("username"); + $("#input_add_colla").val(userName); + $("#add_userid").val(target); + } else { + $("#input_add_colla").val(target); + $("#add_userid").val(target); + } + $("#add_type").val(type); + }); + } + }); + }); + }, + doAddCollaboration : function() { + if ($(".colla_suggest").length > 0) { + if ($(".colla_suggest").find(".seled").length == 0) { + $("#add_prompt1").hide(); + $("#add_prompt2").show(); + $("#add_prompt3").hide(); + $("#add_prompt4").hide(); + var top = ($(window).outerHeight() - 104) * 0.5 + 100; + var left = ($(window).outerWidth() - 272) * 0.5; + $("#confirm_dlg").removeClass("newSize").css({ + top : top + "px", + left : left + "px" + }); + $("#confirm_dlg").addClass("newSize").css({ + top : ($(window).outerHeight() - $("#confirm_dlg").height()) + * 0.5 + "px", + left : ($(window).outerWidth() - $("#confirm_dlg").width()) + * 0.5 + "px", + display : "block" + }); + } else { + var imgSrc = $(".colla_suggest").find(".seled").find("img") + .attr("src"); + var userFullName = $("#input_add_colla").val(); + if (userFullName.length > 30) { + userFullName = userFullName.substr(0, 30) + "..."; + } + var target = $("#add_userid").val(); + var role = $("#invit_role").val(); + var type = $("#add_type").val(); + $(".add_new_button") + .find(".designer_button") + .text("<@i18n resource='diagraming.collaboation_sending'/>"); + var target_item = null; + if (type == "email") { + $(".role_list").find(".role_item").each(function() { + if ($(this).attr("type") == type + && $(this).attr("target") == target) { + target_item = $(this); + $(this) + .find(".inviting_") + .text("<@i18n resource='diagraming.collaboation_inviting_again'/>"); + } + }); + } + + var paramOuter = { + type : type, + target : target, + role : role, + chartId : chartId + }; + Util.ajax({ + url : "/collaboration/add", + data : paramOuter, + success : function(data) { + var result = data.result; + if (result == "exists") { + $("#add_prompt2").hide(); + $("#add_prompt1").hide(); + $("#add_prompt4").hide(); + $("#add_prompt3").show(); + } else { + Util.ajax({ + url : "/collaboration/get_colla_role_list", + data : { + chartId : chartId + }, + success : function(data) { + $(".role_list").html(data) + .scrollTop(999); + } + }); + } + $(".add_new_button") + .find(".designer_button") + .text("<@i18n resource='diagraming.collaboation_send_invitation'/>"); + $("#colla_dialog").addClass("_update").css({ + top : ($(window).height() - $("#colla_dialog") + .outerHeight()) + * 0.5 + "px" + }); + if (result != "exists") { + setTimeout(function() { + $("#add_prompt3").hide(); + $("#add_prompt2").hide(); + $("#add_prompt1").hide(); + $("#add_prompt4").show(); + }, 400); + } + setTimeout(function() { + $("#add_prompt3").hide(); + $("#add_prompt2").hide(); + $("#add_prompt4").hide(); + $("#add_prompt1").show(); + $("#input_add_colla").val(""); + $("#colla_suggest_box").html(""); + }, 1000); + } + }); + } + } + }, + deleteCollaRole : function(dom) { + var parent = $(dom).parent(".role_item"); + var collaborationId = parent.attr("collaborationId"); + Util.ajax({ + url : "/collaboration/delete", + data : { + collaborationId : collaborationId + }, + success : function(data) { + if (data.result == "success") + parent.remove(); + } + }); + + $("#colla_dialog").addClass("_update").css({ + top : ($(window).height() - $("#colla_dialog").outerHeight()) * 0.5 + + "px" + }); + }, + changeCollaRole : function(collaborationId, dom) { + Util.ajax({ + url : "/collaboration/set_role", + data : { + collaborationId : collaborationId, + role : $(dom).val() + }, + success : function(data) { + if (data.result == "success") { + $(dom).parent(".given_role") + .find(".change_success").stop().animate({ + "left" : "-38px" + }, 200).delay(400).animate({ + "left" : "0px" + }, 200); + } + } + }); + }, + /** + * 打开图形管理 + */ + showShapesManage : function() { + var $dialog = $("#shapes_dialog").dialog({ + buttons : [{ + text : '确定', + cls : "blue", + handler : UI.saveShapesManage + }, { + text : '关闭', + handler : function() { + $dialog.dialog("close"); + } + }] + }); + $("#shape_manage_list").children("li").unbind().bind("click", + function() { + var chkbox = $(this).find("input"); + var checked = !chkbox.is(":checked"); + chkbox.attr("checked", checked); + cateChanged(chkbox); + }); + $("#shape_manage_list").find("input").unbind().bind("click", + function(e) { + e.stopPropagation(); + cateChanged($(this)); + }); + // .each(function(){ + // var categorys = $(this).val(); + // var arr = categorys.split(","); + // var exists = true; + // for(var i = 0; i < arr.length; i++){ + // var cate = arr[i]; + // if(!CategoryMapping[cate]){ + // //此分类下的图形,没有在当前使用中 + // exists = false; + // break; + // } + // } + // $(this).attr("checked", exists); + // }); + + function cateChanged(chk) { + var value = chk.val(); + var arr = value.split(","); + var chked = chk.is(":checked"); + if (arr.length > 1) { + // 是父级节点 + $("#shape_manage_list").find("input").each(function() { + var cate = $(this).val(); + if (arr.indexOf(cate) >= 0) { + // 是选择父级的子节点 + $(this).attr("checked", chked); + } + }); + } else { + // 选择的是子节点 + $("#shape_manage_list").find(".cate_parent").each(function() { + // 获取所有的父节点,判断子节点是否都全部选中了 + var cates = $(this).val().split(","); + var allChked = true; + for (var i = 0; i < cates.length; i++) { + var cate = cates[i]; + if (!$("#shape_manage_list").find("input[value=" + cate + + "]").is(":checked")) { + allChked = false; + break; + } + } + $(this).attr("checked", allChked); + }); + } + } + }, + /** + * 保存图形管理 + */ + saveShapesManage : function() { + var checked = $("#shape_manage_list") + .find("input:checked:not(.cate_parent)").map(function() { + return $(this).val(); + }).get(); + var a = ""; + var messages = { + categories : checked.join(",") + }; + // //发送消息 + // var msgObj = { + // action: "changeSchema", + // messages: JSON.stringify(messages) + // }; + // CLB.send(msgObj); + Designer.setSchema(checked.join(","), function() { + $("#shapes_dialog").dialog("close"); + }); + }, + /** + * 打开用户菜单 + */ + showUserMenu : function(e) { + e.stopPropagation(); + $("#user_menu").dropdown({ + target : $(".user"), + position : "right", + onSelect : function(item) { + var action = item.attr("ac"); + if (action == "dia") { + location.href = "/diagrams"; + } else if (action == "net") { + location.href = "/network"; + } else if (action == "out") { + location.href = "/login/out"; + } + } + }); + }, + /** + * 打开另存为 + */ + showSaveAs : function() { + $("#saveas_dialog").dlg(); + $("#saveas_title").val($(".diagram_title").text()).select(); + }, + doSaveAs : function() { + if ($("#saveas_title").val().trim() == "") { + $("#saveas_title").focus(); + return; + } + $("#hid_saveas_id").val(chartId); + $("#saveas_form").submit(); + $("#btn_dosaveas").removeAttr("onclick"); + }, + activityNoDlg : function() { + //创建Dialog的DOM,关闭时销毁 + var dialogHTML = ''; + /*计算dialog高度,规则 + 1、最小值340 + 2、每行26px,1条件出现纵向滚动条时(行>8),需要根据高度行数扩大 + 3、最大window.height-40 + */ + //获取当前节点号数组 + // var filterNames = 'timerIntermediateCatchEvent,messageIntermediateCatchEvent,signalIntermediateCatchEvent,messageIntermediateThrowingEvent,signalIntermediateThrowingEvent,compensateIntermediateThrowingEvent,userTask,serviceTask,scriptTask,manualTask,businessRuleTask,sendTask,receiveTask,callActivityCallingProcess,'; + var filterNames = undefined; + var taskList = UI.getTasksList(filterNames); + var dialogHeight = 340; + if (taskList.length > 8) { + dialogHeight = 340 + (taskList.length - 8) * 26 + } + if (dialogHeight > ($(window).height() - 80)) { + dialogHeight = ($(window).height() - 80); + } + dialogHTML += ''; + $(document.body).append(dialogHTML); + //显示Dialog + $("#activityNoDialog").dialog({ + onClose: function () { + $('#activityNoDialog').remove(); + $('#row-drag-obj').remove();//grid拖动时产生的行,鼠标拖动到document外时,该div一直显示 + }, + buttons: [ + { + text: '确定', cls: "blue", + handler: function () { + if (activityNoArr.length > 0) { + //将节点号重新设置 + var allRows = activityNoGrid.awsGrid('getAllRows'); + for (var shapeId in Model.define.elements) { + var shape = Model.getShapeById(shapeId); + for(var x = 0; x < allRows.length; x++) { + var obj = allRows[x]; + if(obj.id == shape.id) { + if (shape.dataAttributes != undefined) { + for (var i = 0; i < shape.dataAttributes.length; i++) { + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attrArr = shape.dataAttributes[i]; + if (attrArr.attributesJsonArray && attrArr.attributesJsonArray.length > 0) { + for (var j = 0; j < attrArr.attributesJsonArray.length; j++) { + var attr = attrArr.attributesJsonArray[j]; + if (attr.id == 'number') { + attr.value = parseInt(obj.no); + break; + } + } + break; + } + } + } + } + } + } + } + if (isAutoSave == "0" ){ + $("#saving_tip").css("color", "rgb(255, 0, 0)"); + $("#saving_tip").text("文件已修改,未保存"); + } + } + $("#activityNoDialog").dialog('close'); + } + }, + { + text: '取消', handler: function () { + $("#activityNoDialog").dialog('close'); + } + } + ] + }); + var activityNoArr = [];//JSON数组 + for (var i = 0; i < taskList.length; i++) { + var task = taskList[i]; + var activityNoObj = {}; + activityNoObj.id = task.id; + if (task.text) { + activityNoObj.name = task.text; + } else { + activityNoObj.name = '(无名称)' + task.title; + } + activityNoObj.no = task.orderIndex; + activityNoArr[i] = activityNoObj; + } + if (activityNoArr.length == 0) { + $('#activityNoGrid').height(dialogHeight - 100); + $('#activityNoGrid').width(317); + $('#activityNoAlert').remove(); + $('#activityNoGrid').append($('
      '+ + '
      '+ + ''+ + '不支持编号排序'+ + '画布没有形状或者形状没有编号属性'+ + '
      '+ + '
      ')); + awsuiMessagePage(); + return; + } + //渲染Grid + var activityNoGridOptions = { + width: 317, + height: dialogHeight - 100, + flexWidth: false, + flexHeight: false, + resizable: false, + selectionModel: { + type: "none", + model: "single" + }, + scrollModel: { + vertical: true, + horizontal: false + }, + bottomVisible: false, + rowDrag: true + }; + activityNoGridOptions.colModel = [ + {title: "名称", width: 200, align: 'left', dataType: 'string', dataIndx: 'name', resizable: false, sortable: false}, + {title: "节点号", width: 80, align: 'center', dataType: 'integer', dataIndx: 'no', resizable: false, sortable: false} + ]; + activityNoGridOptions.dataModel = { + data: activityNoArr, + location: "local", + sorting: "local", + sortIndx: "no", + sortDir: "up" + }; + var activityNoGrid = $("#activityNoGrid").awsGrid(activityNoGridOptions); + activityNoGrid.awsGrid('option', 'rowDragCallback', function (source, target) { + return true; + }); + activityNoGrid.awsGrid('option', 'rowDragSuccessCallback', function (source, target) { + //重新排列序号 + var allRows = activityNoGrid.awsGrid('getAllRows'); + for (var i = 0; i < allRows.length; i++) { + allRows[i].no = (i + 1); + } + activityNoGrid.awsGrid('refreshDataAndView'); + }); + }, + getTasksList: function (filterNames) { + var filterNode = []; + var nodes = Model.define.elements; + if (filterNames == undefined) { + return UI.getALLTasksList(); + } + }, + getALLTasksList: function () { + var filterNode = []; + for (var shapeId in Model.define.elements) { + var shape = Model.getShapeById(shapeId); + if (shape.dataAttributes != undefined) { + for (var i = 0; i < shape.dataAttributes.length; i++) { + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attrArr = shape.dataAttributes[i]; + if (attrArr.attributesJsonArray && attrArr.attributesJsonArray.length > 0) { + for (var j = 0; j < attrArr.attributesJsonArray.length; j++) { + var attr = attrArr.attributesJsonArray[j]; + if (attr.id == 'number') { + var tempNumber = 0; + var number = attr.value; + if(typeof number == 'string') number = number.replace(/^\s+|\s+$/g,""); + if(!isNaN(number) && number != '') { + tempNumber = number; + } + var obj = {}; + obj.text = shape.text; + obj.id = shapeId; + obj.orderIndex = tempNumber; + filterNode.push(obj); + break; + } + } + break; + } + } + } + } + } + return filterNode; + }, + batchReplace: function() { + if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") { + if (editable) { + $.simpleAlert('页面中有未保存的内容,请先保存'); + return; + } + } + // 打开批量处理框 + initWizardByDesinger(); + } +}; + +/** + * 右侧的Dock控件 + * + * @type {} + */ +var Dock = { + init : function() { + var layoutW = $("#designer_layout").width(); + var viewW = $("#layout_block").width(); + // 总宽度减去可视区域的宽度,得到滚动条宽度 + var navRight = layoutW - viewW; + $("#dock").css("right", navRight); + var dockRight = navRight + $("#dock").outerWidth() - 1; + $(".dock_view").css("right", dockRight); + if ($("#demo_signup").length) { + var signupH = $("#demo_signup").outerHeight(); + $("#dock").css("top", signupH); + $(".dock_view").css("top", signupH + 10); + } + $(".ico_dock_collapse").bind("click", function() { + $(".dock_view").hide(); + $(".dock_buttons").children().removeClass("selected"); + if (Dock.currentView == "history") { + Dock.closeHistory(); + } + Dock.currentView = ""; + }); + $(window).bind("resize.dock", function() { + if (Dock.currentView == "attribute") { + Dock.fitAttrList(); + } + }); + // 缩放 + $("#dock_zoom").spinner({ + min : 50, + max : 200, + unit : "%", + step : 10, + onChange : function(val) { + Designer.setZoomScale(val / 100); + } + }); + // 线条颜色 + $("#dock_line_color").colorButton({ + onSelect : function(color) { + Designer.setLineStyle({ + lineColor : color + }); + } + }); + // 线条类型 + $("#dock_line_style").button({ + onMousedown : function() { + $("#line_style_list").dropdown({ + target : $("#dock_line_style"), + onSelect : function(item) { + var lineStyle = item.attr("line"); + Designer.setLineStyle({ + lineStyle : lineStyle + }); + var cls = item.children("div").attr("class"); + $("#dock_line_style").children(".linestyle").attr( + "class", cls); + } + }); + var style = Utils.getSelected()[0].lineStyle.lineStyle; + var item = $("#line_style_list").children("li[line=" + style + + "]"); + $("#line_style_list").dropdown("select", item); + } + }); + // 线条宽度 + $("#dock_line_width").spinner({ + min : 0, + max : 10, + unit : "px", + step : 1, + onChange : function(val) { + Designer.setLineStyle({ + lineWidth : val + }); + } + }); + // 填充类型 + $("#dock_fill_type").button({ + onMousedown : function() { + $("#dock_fill_list").dropdown({ + target : $("#dock_fill_type"), + onSelect : function(item) { + var type = item.attr("ty"); + $("#dock_fill_type").button("setText", + item.text()); + if (type == "image") { + UI.showImageSelect(function(fileId, w, h) { + Designer.setFillStyle({ + type : "image", + fileId : fileId, + imageW : w, + imageH : h + }); + }); + } else { + Designer.setFillStyle({ + type : type + }); + var shapeIds = Utils.getSelectedShapeIds(); + var shape = Model.getShapeById(shapeIds[0]); + Dock.setFillStyle(shape.fillStyle); + } + } + }); + var type = $("#dock_fill_type").text(); + $("#dock_fill_list").children().each(function() { + if ($(this).text() == type) { + $("#dock_fill_list") + .dropdown("select", $(this)); + return false; + } + }); + } + }); + // 填充颜色 + $("#fill_solid_btn").colorButton({ + onSelect : function(color) { + Designer.setFillStyle({ + color : color + }); + } + }); + // 渐变开始颜色 + $("#fill_gradient_begin").colorButton({ + onSelect : function(color) { + Designer.setFillStyle({ + beginColor : color + }); + $("#fill_gradient_begin").attr("c", color); + } + }); + // 渐变结束颜色 + $("#fill_gradient_end").colorButton({ + onSelect : function(color) { + Designer.setFillStyle({ + endColor : color + }); + $("#fill_gradient_end").attr("c", color) + } + }); + // 渐变颜色交换 + $("#gradient_swap").button({ + onClick : function() { + var begin = $("#fill_gradient_begin").attr("c"); + var end = $("#fill_gradient_end").attr("c"); + $("#fill_gradient_begin").attr("c", end).colorButton( + "setColor", end); + $("#fill_gradient_end").attr("c", begin).colorButton( + "setColor", begin); + Designer.setFillStyle({ + beginColor : end, + endColor : begin + }); + } + }); + // 渐变类型 + $("#gradient_type").button({ + onMousedown : function() { + $("#gradient_type_list").dropdown({ + target : $("#gradient_type"), + onSelect : function(item) { + var type = item.attr("ty"); + $("#gradient_type").button("setText", item.text()); + Designer.setFillStyle({ + gradientType : type + }); + $(".gradient_details").hide(); + $("#gradient_type_" + type).show(); + var shapeIds = Utils.getSelectedShapeIds(); + var shape = Model.getShapeById(shapeIds[0]); + var fillStyle = shape.fillStyle; + if (type == "linear") { + $("#gradient_angle").spinner( + "setValue", + Math.round(fillStyle.angle / Math.PI * 180) + + "°"); + } else { + $("#gradient_radius").spinner("setValue", + Math.round(fillStyle.radius * 100) + "%"); + } + } + }); + var type = $("#gradient_type").text().trim(); + $("#gradient_type_list").children().each(function() { + if ($(this).text() == type) { + $("#gradient_type_list").dropdown("select", + $(this)); + return false; + } + }); + } + }); + // 线性渐变角度 + $("#gradient_angle").spinner({ + min : 0, + max : 360, + unit : "°", + step : 15, + onChange : function(val) { + var angle = val / 180 * Math.PI; + Designer.setFillStyle({ + angle : angle + }); + } + }); + // 径向渐变半径 + $("#gradient_radius").spinner({ + min : 0, + max : 100, + unit : "%", + step : 5, + onChange : function(val) { + Designer.setFillStyle({ + radius : val / 100 + }); + } + }); + // 改变背景图片 + $("#fill_change_img").button({ + onClick : function() { + UI.showImageSelect(function(fileId, w, h) { + Designer.setFillStyle({ + type : "image", + fileId : fileId, + imageW : w, + imageH : h + }); + }); + } + }); + // 背景图片显示 + $("#fill_img_display").button({ + onMousedown : function() { + $("#img_display_list").dropdown({ + target : $("#fill_img_display"), + onSelect : function(item) { + var type = item.attr("ty"); + $("#fill_img_display").button("setText", + item.text()); + Designer.setFillStyle({ + display : type + }); + } + }); + } + }); + // 透明度 + $("#spinner_opacity").spinner({ + min : 0, + max : 100, + unit : "%", + step : 5, + onChange : function(val) { + Designer.setShapeStyle({ + alpha : val / 100 + }); + } + }); + // X坐标 + $("#dock_metric_x").spinner({ + min : -800, + unit : "px", + step : 5, + onChange : function(val) { + Designer.setShapeProps({ + x : val + }); + } + }); + $("#dock_metric_x").spinner("setValue", "0px"); + // 宽度 + $("#dock_metric_w").spinner({ + min : 20, + unit : "px", + step : 5, + onChange : function(val) { + Designer.setShapeProps({ + w : val + }); + } + }); + // Y坐标 + $("#dock_metric_y").spinner({ + min : -800, + unit : "px", + step : 5, + onChange : function(val) { + Designer.setShapeProps({ + y : val + }); + } + }); + $("#dock_metric_y").spinner("setValue", "0px"); + // 高度 + $("#dock_metric_h").spinner({ + min : 20, + unit : "px", + step : 5, + onChange : function(val) { + Designer.setShapeProps({ + h : val + }); + } + }); + // 角度 + $("#dock_metric_angle").spinner({ + min : 0, + max : 360, + unit : "°", + step : 15, + onChange : function(val) { + var angle = val / 180 * Math.PI; + Designer.setShapeProps({ + angle : angle + }); + } + }); + // 画布尺寸 + $("#dock_page_size").button({ + onMousedown : function() { + $("#page_size_list").dropdown({ + target : $("#dock_page_size"), + onSelect : function(item) { + var w = parseInt(item.attr("w")); + var h = parseInt(item.attr("h")); + Designer.setPageStyle({ + width : w, + height : h + }); + $("#dock_page_size").button("setText", + item.text()); + } + }); + var item = $("#page_size_list").children("li[w=" + + Model.define.page.width + "][h=" + + Model.define.page.height + "]"); + if (item.length > 0) { + $("#page_size_list").dropdown("select", item); + } else { + $("#page_size_list").dropdown("select", + $("#dock_size_custom")); + } + $("#dock_size_w").spinner("setValue", + Model.define.page.width + "px"); + $("#dock_size_h").spinner("setValue", + Model.define.page.height + "px"); + } + }); + $("#dock_size_w").spinner({ + min : 200, + unit : "px", + step : 100, + onChange : function(val) { + Designer.setPageStyle({ + width : val + }); + } + }); + $("#dock_size_h").spinner({ + min : 200, + unit : "px", + step : 100, + onChange : function(val) { + Designer.setPageStyle({ + height : val + }); + } + }); + // 页面边距 + $("#dock_page_padding").button({ + onMousedown : function() { + $("#page_padding_list").dropdown({ + target : $("#dock_page_padding"), + onSelect : function(item) { + var p = parseInt(item.attr("p")); + Designer.setPageStyle({ + padding : p + }) + $("#dock_page_padding").button("setText", + item.text()); + } + }); + var item = $("#page_padding_list").children("li[p=" + + Model.define.page.padding + "]"); + $("#page_padding_list").dropdown("select", item); + } + }); + // 画布背景颜色 + $("#dock_page_color").colorButton({ + position : "center", + onSelect : function(color) { + Designer.setPageStyle({ + backgroundColor : color + }); + } + }); + // 是否显示网格 + $("#dock_page_showgrid").bind("change", function() { + var showGrid = $(this).is(":checked"); + Designer.setPageStyle({ + showGrid : showGrid + }); + if (showGrid) { + $("#dock_gridsize_box").show(); + } else { + $("#dock_gridsize_box").hide(); + } + }); + // 网格大小 + $("#dock_page_gridsize").button({ + onMousedown : function() { + $("#page_gridsize_list").dropdown({ + target : $("#dock_page_gridsize"), + onSelect : function(item) { + var s = parseInt(item.attr("s")); + Designer.setPageStyle({ + gridSize : s + }) + $("#dock_page_gridsize").button("setText", item.text()); + } + }); + var item = $("#page_gridsize_list").children("li[s=" + + Model.define.page.gridSize + "]"); + $("#page_gridsize_list").dropdown("select", item); + } + }); + // 播放速度 + $("#spinner_play_speed").spinner({ + min : 1, + max : 30, + unit : "s", + step : 1, + value : 5, + onChange : function(val) { + + } + }); + $("#spinner_play_speed").spinner("setValue", "2s"); + // 版本播放 + $("#btn_history_play").button({ + onClick : function() { + if ($("#btn_history_play").children() + .hasClass("ico_pause")) { + Dock.pauseVersions(); + } else { + Dock.playVersions(); + } + } + }); + $("#btn_history_restore").button({ + onClick : function() { + Dock.restoreVersion(); + } + }); + }, + /** + * 当前Dock窗口 + * + * @type {String} + */ + currentView : "", + /** + * 打开一个Dock窗口 + * + * @param {} + * name + */ + showView : function(name) { + if ($("#dock_btn_" + name).button("isDisabled")) { + return; + } + $(".dock_view").hide(); + $(".dock_view_" + name).show(); + $(".dock_buttons").children().removeClass("selected"); + $("#dock_btn_" + name).addClass("selected"); + if (Dock.currentView == "history" && name != "history") { + Dock.closeHistory(); + } + this.currentView = name; + this.update(true); + }, + /** + * 设置Dock的填充样式 + * + * @param {} + * fillStyle + */ + setFillStyle : function(fillStyle) { + $("#dock_fill_type").button( + "setText", + $("#dock_fill_list").children("li[ty=" + fillStyle.type + "]") + .text()); + $(".fill_detail").hide(); + if (fillStyle.type == "solid") { + $(".fill_detail_solid").show(); + $("#fill_solid_btn").colorButton("setColor", fillStyle.color); + } else if (fillStyle.type == "gradient") { + $(".fill_detail_gradient").show(); + // 渐变颜色 + $("#fill_gradient_begin").attr("c", fillStyle.beginColor) + .colorButton("setColor", fillStyle.beginColor); + $("#fill_gradient_end").attr("c", fillStyle.endColor).colorButton( + "setColor", fillStyle.endColor); + // 渐变类型 + $("#gradient_type").button( + "setText", + $("#gradient_type_list").children("li[ty=" + + fillStyle.gradientType + "]").text()); + $(".gradient_details").hide(); + if (fillStyle.gradientType == "linear") { + $("#gradient_type_linear").show(); + $("#gradient_angle").spinner("setValue", + Math.round(fillStyle.angle / Math.PI * 180) + "°"); + } else { + $("#gradient_type_radial").show(); + $("#gradient_radius").spinner("setValue", + Math.round(fillStyle.radius * 100) + "%"); + } + } else if (fillStyle.type == "image") { + $(".fill_detail_image").show(); + var display = "fill"; + if (fillStyle.display) { + display = fillStyle.display; + } + $("#fill_img_display").button( + "setText", + $("#img_display_list").children("li[ty=" + display + "]") + .text()); + } + }, + /** + * 更新Dock + */ + update : function(drawNav) { + if(drawNav == true){ + //图形点击 + $('.newadd_wen').hide(); + $('#pinglunfix').hide() + }else{ + $('#pinglunfix').show() + $('.newadd_wen').show(); + changeArributeByShape(); + } + if (this.currentView == "portalDescShow" || this.currentView == "portalFileShow" || this.currentView == "portalwjFileShow") { + changeArributeByShape(); + } + if (this.currentView == "navigator") { + if (drawNav) { + Navigator.draw(); + } + $("#dock_zoom").spinner("setValue", + Math.round(Designer.config.scale * 100) + "%"); + } else if (this.currentView == "graphic") { + var selectedIds = Utils.getSelectedIds(); + var count = selectedIds.length; + var shapeIds = Utils.getSelectedShapeIds(); + var shapeCount = shapeIds.length; + if (count == 0) { + $("#dock_line_color").button("disable"); + $("#dock_line_style").button("disable"); + $("#dock_line_width").button("disable"); + } else { + $("#dock_line_color").button("enable"); + $("#dock_line_style").button("enable"); + $("#dock_line_width").button("enable"); + var shape = Model.getShapeById(selectedIds[0]); + $("#dock_line_color").colorButton("setColor", + shape.lineStyle.lineColor); + var lineStyleCls = $("#line_style_list").children("li[line=" + + shape.lineStyle.lineStyle + "]").children() + .attr("class"); + $("#dock_line_style").children(".linestyle").attr("class", + lineStyleCls); + $("#dock_line_width").spinner("setValue", + shape.lineStyle.lineWidth + "px"); + } + if (shapeCount == 0) { + $("#dock_fill_type").button("disable"); + $("#spinner_opacity").button("disable"); + Dock.setFillStyle({ + type : "none" + }); + } else { + $("#dock_fill_type").button("enable"); + $("#spinner_opacity").button("enable"); + var shape = Model.getShapeById(shapeIds[0]); + Dock.setFillStyle(shape.fillStyle); + $("#spinner_opacity").spinner("setValue", + Math.round(shape.shapeStyle.alpha / 1 * 100) + "%"); + } + } else if (this.currentView == "metric") { + var shapeIds = Utils.getSelectedShapeIds(); + var shapeCount = shapeIds.length; + if (shapeCount == 0) { + $("#dock_metric_x").button("disable"); + $("#dock_metric_w").button("disable"); + $("#dock_metric_y").button("disable"); + $("#dock_metric_h").button("disable"); + $("#dock_metric_angle").button("disable"); + } else { + var shape = Model.getShapeById(shapeIds[0]); + $("#dock_metric_x").button("enable").spinner("setValue", + Math.round(shape.props.x) + "px"); + $("#dock_metric_w").button("enable").spinner("setValue", + Math.round(shape.props.w) + "px"); + $("#dock_metric_y").button("enable").spinner("setValue", + Math.round(shape.props.y) + "px"); + $("#dock_metric_h").button("enable").spinner("setValue", + Math.round(shape.props.h) + "px"); + $("#dock_metric_angle").button("enable").spinner("setValue", + Math.round(shape.props.angle / Math.PI * 180) + "°"); + } + } else if (this.currentView == "page") { + var page = Model.define.page; + var w = page.width; + var h = page.height; + var sizeItem = $("#page_size_list").children("li[w=" + w + "][h=" + + h + "]"); + var sizeText = ""; + if (sizeItem.length > 0) { + sizeText = sizeItem.text(); + } else { + sizeText = $("#dock_size_custom").text(); + } + $("#dock_page_size").button("setText", sizeText); + $("#dock_page_padding").button("setText", page.padding + "px"); + $("#dock_page_color").colorButton("setColor", page.backgroundColor); + $("#dock_page_showgrid").attr("checked", page.showGrid); + if (page.showGrid) { + $("#dock_gridsize_box").show(); + } else { + $("#dock_gridsize_box").hide(); + } + var gridText = ""; + var gridItem = $("#page_gridsize_list").children("li[s=" + + page.gridSize + "]"); + if (gridItem.length > 0) { + var gridText = gridItem.text(); + } + $("#dock_page_gridsize").button("setText", gridText); + } else if (this.currentView == "attribute") { + if (!inputUpdate) {// input类型的属性值更新时不重绘所有属性 + changeArributeByShape(); + } + if(role == "viewer") { + $("#dock_page_attribute table input").prop("disabled", true); + $("#tagContent1 table input, #tagContent1 table textarea").prop("disabled", true); + } + } else if (this.currentView == "message") { + $.ajax({ + url: "./jd?sid=" + $("#sid").val() + + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_commentlist" + + "&repositoryId=" + ruuid + "&openAppType=" + openAppType, + success: function(msg){ + var html = ""; + var array; + if (typeof(msg) == "string") { + array = eval('(' + msg + ')').msg; + } else { + array = msg.msg; + } + if (typeof(array) == "string") { + array = eval('(' + array + ')'); + } + for (var i = 0; i < array.length; i++) { + var obj = array[i]; + html += getHtml(obj); + } + $("#messageContent").html(html); + } + }); + } else if (this.currentView == "publish") { + $.ajax({ + url: "./jd?sid=" + $("#sid").val() + + "&cmd=com.actionsoft.apps.coe.pal_publish_history_of_repository&wsId=" + $("#wsId").val() + + "&repositoryId=" + ruuid, + success: function(msg){ + var array; + if (typeof(msg) == "string") { + array = eval('(' + msg + ')').msg; + } else { + array = msg.msg; + } + if (typeof(array) == 'string') { + array = eval('(' + array + ')'); + } + var html = ""; + if (array != null && array.length > 0) { + for (var i = 0; i < array.length; i++) { + var data = array[i]; + var type = data.publishType; + var style = ""; + var info = ""; + if (type == "N") { + style = "green"; + info = "新发布"; + } else if (type == "C") { + style = "blue"; + info = "变更"; + } else if (type == "S") { + style = "red"; + info = "停用"; + } + var clickHtml = ""; + if (data.plId != undefined) { + clickHtml = " style='cursor: pointer;' onclick=\"openFileLink('" + data.plId + "', '_seft', '" + data.plName + "')\""; + } + html += "
      " + + " " + + " " + + " " + + "
      "; + } + + } else { + html = "
      暂无发布历史
      "; + } + $("#sidePublishListDiv article").html(html); + } + }); + } else if (this.currentView == "link") { + $.ajax({ + url: "./jd?sid=" + $("#sid").val() + + "&cmd=com.actionsoft.apps.coe.pal_link_of_repository&wsId=" + $("#wsId").val() + + "&plId=" + ruuid, + success: function(r){ + var links = r.data.links; + var customLinks = r.data.customLInks; + var html = ""; + var flag1 = false; + var flag2 = false; + if (links != null && links.length > 0) { + html += '

      文件链接

      '; + for (var i = 0; i < links.length; i++) { + html += ''; + } + } else { + flag1 = true; + } + if (customLinks != null && customLinks.length > 0){ + html += '

      自定义链接

      '; + html += ''; + } else { + flag2 = true; + } + if (flag1 && flag2) { + html = "
      暂无链接
      "; + } + $("#linkContent").empty().html(html); + } + }); + } + else if(this.currentView == 'diff') { + // var html = "
      暂无版本差异
      "; + var html = '' + $.ajax({ + url: "./jd?sid=" + $("#sid").val() + + "&cmd=com.actionsoft.apps.coe.pal_repository_model_version_diff_query&wsId=" + $("#wsId").val() + + "&id=" + ruuid, + success: function (ro) { + // console.log("历史差异结果: " + JSON.stringify(ro)) + if (ro.result == "ok") { + var diffContent = ro.data; + for (var i = 0; i < diffContent.length; i++) { + var diffCount = 0 + var content = diffContent[i].updateContent + var diffListHtml = '' + for (var j = 0; j < content.length; j++) { + var diffDetailHtml = '' + var listDetail = content[j].detail + if (listDetail.length == 0) { + diffCount += 1 + } + for (var k = 0; k < listDetail.length; k++) { + diffCount += 1 + diffDetailHtml += '
      ' + '·' + listDetail[k] + '
      ' + } + diffListHtml += '
      ' + content[j].title + '
      ' + + '
      ' + diffDetailHtml + '
      ' + + } + html += '' + + '' + diffContent[i].versionName + '' + + '' + diffContent[i].updateTime + '' + '(' + diffCount + '处修改)' + '' + '' + + '' + + '' + + '' + + '' + diffListHtml + '' + + '' + + } + $("#diffTable").empty().html(html) + } else { + html = '' + + ro.msg + + '' + $("#diffTable").empty().html(html) + } + } + }); + } + if (this.currentView == "history") { + if (drawNav && Dock.historyVersions == null) { + this.loadHistorys(); + } + } + }, + /** + * 历史版本暂存 + * + * @type {} + */ + historyVersions : null, + /** + * 加载历史版本 + */ + loadHistorys : function() {/* + if (chartId == "") { + $("#history_container") + .html("
      <@i18n resource='diagraming.demo.nohistory'/>
      ") + return; + } + $.ajax({ + url : "/diagraming/history", + data : { + chartId : chartId + }, + success : function(data) { + Dock.historyVersions = data; + if (data.versions.length == 0) { + $("#history_container") + .html('
      <@i18n resource="diagraming.nohistory"/>
      '); + } else { + $("#history_container") + .html('
        '); + var users = data.users; + for (var i = 0; i < data.versions.length; i++) { + var v = data.versions[i]; + var newVersion = $('
      • ' + v.updateTime + + '
      • ') + .appendTo($("#history_versions")); + var nameContainer = newVersion + .children(".version_name"); + for (var j = 0; j < v.userIds.length; j++) { + var userId = v.userIds[j]; + nameContainer.append("
        " + users[userId] + + "
        "); + } + var remarkContainer = $("") + .appendTo(newVersion); + if (v.remark) { + remarkContainer.find(".remark_text").text(v.remark); + } + remarkContainer + .append("") + } + Dock.resetVersions(); + } + } + }); + */}, + /** + * 重置版本历史 + */ + resetVersions : function() { + $("#history_versions").children("li").unbind().bind("click", + function() { + if (Dock.playingTimeout != null) { + return; + } + if ($(this).hasClass("selected")) { + Dock.closeHistory(); + } else { + $("#history_versions").children(".selected") + .removeClass("selected"); + $(this).addClass("selected"); + var defId = $(this).attr("def"); + Dock.showHistoryVersion(defId); + } + var current = $("#history_versions").children(".selected"); + if (current.length != 0 && current.attr("ind") != "0") { + $("#spinner_play_speed").button("enable"); + $("#btn_history_play").button("enable"); + $("#btn_history_restore").button("enable"); + } else { + $("#spinner_play_speed").button("disable"); + $("#btn_history_play").button("disable"); + $("#btn_history_restore").button("disable"); + } + }); + $("#history_versions").height("auto"); + var top = $("#history_versions").offset().top; + var bottom = top + $("#history_versions").height() + 75; + if (bottom > $(window).height()) { + var height = $(window).height() - top - 75; + if (height < 140) { + height = 140; + } + $("#history_versions").height(height); + } else { + $("#history_versions").height("auto"); + } + }, + /** + * 编辑版本注释 + * + * @param {} + * event + */ + editHistoryRemark : function(event, versionId) { + event.stopPropagation(); + var versionDom = $("#history_versions").children("li[vid=" + versionId + + "]"); + versionDom.find(".remark_container").hide(); + var currentRemark = versionDom.find(".remark_text").text(); + var editContainer = versionDom.find(".edit_container"); + editContainer.show(); + editContainer.children("textarea").val(currentRemark).select(); + editContainer.children(".save").bind("click", function(e) { + e.stopPropagation(); + var newRemark = editContainer.children("textarea").val(); + versionDom.find(".remark_text").text(newRemark); + versionDom.find(".remark_container").show(); + editContainer.hide(); + if (newRemark != currentRemark) { + CLB.send({ + action : "versionRemark", + remark : newRemark, + versionId : versionId + }); + } + }); + editContainer.children(".cancel").bind("click", function(e) { + e.stopPropagation(); + Dock.cancelHistoryRemark(); + }); + }, + /** + * 取消版本注释的编辑 + */ + cancelHistoryRemark : function() { + $(".remark_container").show(); + $(".edit_container").hide(); + }, + /** + * 展示历史版本 + */ + showHistoryVersion : function(defId) { + $("#spinner_play_speed").button("disable"); + $("#btn_history_play").button("disable"); + $("#btn_history_restore").button("disable"); + Dock.cancelHistoryRemark(); + $.ajax({ + url : "/diagraming/getdefinition", + data : { + definitionId : defId + }, + success : function(data) { + Dock.openHistory(data.definition); + if ($("#history_versions").children(".selected").attr("ind") != "0") { + $("#spinner_play_speed").button("enable"); + $("#btn_history_play").button("enable"); + $("#btn_history_restore").button("enable"); + } + } + }); + }, + /** + * 播放版本历史 + */ + playVersions : function() { + var current = $("#history_versions").children(".selected"); + // if(current.length == 0){ + // return; + // } + var index = parseInt(current.attr("ind")); + Dock.playOneVersion(index--, 0); + $("#btn_history_play").children().attr("class", "ico ico_pause"); + $("#btn_history_play").attr("title", "暂停").trigger("mouseenter"); + $("#btn_history_restore").button("disable"); + }, + /** + * 终止播放 + */ + pauseVersions : function() { + if (this.playingTimeout) { + clearTimeout(this.playingTimeout); + } + this.playingTimeout = null; + $("#btn_history_play").children().attr("class", "ico ico_play"); + $("#btn_history_play").attr("title", "从此版本播放"); + $(".ico_playing").remove(); + var current = $("#history_versions").children(".selected"); + $("#history_versions").children(".playing").removeClass("playing"); + if (current.length != 0 && current.attr("ind") != "0") { + $("#spinner_play_speed").button("enable"); + $("#btn_history_play").button("enable"); + $("#btn_history_restore").button("enable"); + } else { + $("#spinner_play_speed").button("disable"); + $("#btn_history_play").button("disable"); + $("#btn_history_restore").button("disable"); + } + }, + playingTimeout : null, + /** + * 播放一个版本 + */ + playOneVersion : function(index, msgIndex) { + var current = $("#history_versions").children("li[ind=" + index + "]"); + $("#history_versions").children(".selected").removeClass("selected"); + current.addClass("selected").addClass("playing"); + $(".ico_playing").remove(); + current.append("
        "); + + var version = Dock.historyVersions.versions[index]; + var messageStr = version.messages[msgIndex]; + var messages = JSON.parse(messageStr); + MessageSource.receive(messages); + var top = current.position().top; + if (top < 0) { + $("#history_versions").scrollTop($("#history_versions").scrollTop() + + top); + } + var time = $("#spinner_play_speed").spinner("getValue") * 1000; + if (index == 0 && msgIndex == version.messages.length - 1) { + this.pauseVersions(); + } else { + if (msgIndex < version.messages.length - 1) { + msgIndex++; + } else { + index = index - 1; + msgIndex = 0; + } + this.playingTimeout = setTimeout(function() { + Dock.playOneVersion(index, msgIndex); + }, time); + } + + }, + currentDefinition : null, + /** + * 打开一个历史版本 + */ + openHistory : function(definition) { + if (this.currentDefinition == null) { + this.currentDefinition = $.extend(true, {}, Model.define); + } + Utils.unselect(); + Designer.open(definition); + // 取消快捷键 + Designer.hotkey.cancel(); + Designer.op.cancel(); + $("#menu_bar").children().addClass("readonly"); + $(".diagram_title").addClass("readonly"); + $(".dock_buttons").children().addClass("disabled"); + $("#dock_btn_history").removeClass("disabled"); + $(".panel_box").addClass("readonly"); + // 中止监听 + CLB.stopListen(); + }, + /** + * 关闭历史版本 + */ + closeHistory : function() { + if (this.currentDefinition != null) { + Designer.open(this.currentDefinition); + this.currentDefinition = null; + this.activeOperation(); + } + }, + /** + * 激活操作 + */ + activeOperation : function() { + // 重新初始化快捷键 + Designer.hotkey.init(); + Designer.op.init(); + $("#menu_bar").children().removeClass("readonly"); + $(".diagram_title").removeClass("readonly"); + $(".dock_buttons").children().removeClass("disabled"); + $("#dock_btn_history").removeClass("disabled"); + $(".panel_box").removeClass("readonly"); + $("#history_versions").children(".selected").removeClass("selected"); + // 继续监听 + CLB.listen(); + Dock.loadHistorys(); + }, + /** + * 恢复版本 + */ + restoreVersion : function() { + var selected = $("#history_versions").children(".selected"); + if (selected.length) { + MessageSource.beginBatch(); + var elements = Dock.currentDefinition.elements; + // 删除当前的所有 + var removed = []; + if (elements) { + for (var id in elements) { + removed.push(elements[id]); + } + } + MessageSource.send("remove", removed); + // 更新画布 + var updatePageMsg = { + page : Utils.copy(Dock.currentDefinition.page), + update : Utils.copy(Model.define.page) + }; + MessageSource.send("updatePage", updatePageMsg); + // 添加新图形 + var newElements = Model.define.elements; + var added = []; + if (newElements) { + for (var id in newElements) { + added.push(newElements[id]); + } + } + MessageSource.send("create", added); + MessageSource.commit(); + Dock.activeOperation(); + } + }, + /** + * 设置数据属性列表 + */ + setAttributeList : function() { + var selectedIds = Utils.getSelectedIds(); + var shape = Model.getShapeById(selectedIds[0]); + $(".clearfix").empty(); + if (shape.dataAttributes) { + for (var i = 0; i < shape.dataAttributes.length; i++) { + var attr = shape.dataAttributes[i]; + var typeText = $("#attr_add_type").children("option[value=" + + attr.type + "]").text(); + var item = $("
      • " + attr.name + + "
        " + typeText + + "
        " + attr.value + + "
      • ") + .appendTo($(".attr_list")); + if (attr.category != "default") { + item.append("
        "); + } + } + } + this.fitAttrList(); + }, + /** + * 让数据属性列表适应 + */ + fitAttrList : function() { + var scroll = $("#tagContent").scrollTop(); + $("#tagContent").height("auto"); + var top = $("#tagContent").offset().top; + var bottom = top + $(".clearfix").height() + 10; + if (bottom > $(window).height()) { + var height = $(window).height() - top - 10; + if (height < 140) { + height = 140; + } + $("#tagContent").height(height); + } else { + $("#tagContent").height("auto"); + } + $("#tagContent").scrollTop(scroll); + }, + /** + * 打开数据属性添加 + */ + showAttrAdd : function() { + $("#attr_add_btn").hide(); + $(".attr_add_items").show(); + $("#attr_add_name").val("").focus(); + $("#attr_add_type").val("string"); + $("#attr_add_type").unbind().bind("change", function() { + Dock.setAttrValueInput(null, $(this).val()); + }); + Dock.setAttrValueInput(null, "string"); + this.fitAttrList(); + }, + /** + * 保存数据属性添加 + */ + saveAttrAdd : function() { + var name = $("#attr_add_name").val(); + if (name == "") { + $("#attr_add_name").focus(); + return; + } + var type = $("#attr_add_type").val(); + var value = $("#attr_add_value_arera").children().val(); + var newAttr = { + name : name, + type : type, + value : value + }; + Designer.addDataAttribute(newAttr); + this.setAttributeList(); + // 初始化添加区域 + this.showAttrAdd(); + }, + /** + * 取消数据属性添加 + */ + cancelAttrAdd : function() { + $("#attr_add_btn").show(); + $(".attr_add_items").hide(); + this.fitAttrList(); + }, + /** + * 编辑数据属性 + * + * @param {} + * attrId + */ + editAttr : function(attrId) { + var item = $(".attr_item_" + attrId); + if (item.hasClass("attr_editing")) { + return; + } + if ($(".attr_editing").length > 0) { + var editingId = $(".attr_editing").attr("id"); + this.saveAttrEdit(editingId); + } + item = $(".attr_item_" + attrId); + item.addClass("attr_editing"); + var attr = Designer.getDataAttrById(attrId); + // 属性值输入 + var input = this.setAttrValueInput(attr, attr.type); + input.val(attr.value).select(); + if (attr.category != "default") { + // 属性名和类型输入 + var nameDiv = item.children(".attr_name"); + nameDiv.empty(); + var nameInput = $("") + .appendTo(nameDiv); + nameInput.val(attr.name).select(); + var typeDiv = item.children(".attr_type"); + typeDiv.empty(); + var select = $("") + .appendTo(typeDiv); + select.html($("#attr_add_type").html()).val(attr.type); + select.bind("change", function() { + Dock.setAttrValueInput(attr, $(this).val()); + }); + } + // 添加显示设置 + var displayArea = $("
        ") + .appendTo(item); + // 显示为的按钮 + displayArea + .append("
        <@i18n resource='diagraming.addattr.displayas'/>
        "); + displayArea + .append("
        "); + displayArea.append("
        "); + // 显示参数区域 + displayArea.append("
        "); + this.appendDisplayItems(); + var showType = "none"; + if (attr.showType) { + showType = attr.showType; + } + this.setAttrDisplay(showType); + $("#attr_edit_showtype").attr("ty", showType).button({ + onMousedown : function() { + $("#attr_display_list").dropdown({ + target : $("#attr_edit_showtype"), + onSelect : function(item) { + var type = item.attr("ty"); + $("#attr_edit_showtype").attr("ty", type).button( + "setText", item.text()); + Dock.setAttrDisplay(type); + } + }); + var type = $("#attr_edit_showtype").text().trim(); + $("#attr_display_list").children().each(function() { + if ($(this).text() == type) { + $("#attr_display_list").dropdown("select", + $(this)); + return false; + } + }); + } + }); + $("#attr_edit_showtype").attr("ty", showType).button( + "setText", + $("#attr_display_list").children("li[ty=" + showType + "]") + .html()); + if (showType != "none") { + $("#attr_display_name").attr("checked", attr.showName); + if (showType == "icon") { + this.setAttrIcon(attr.icon); + } + } + var horizontal = "mostright"; + if (attr.horizontal) { + horizontal = attr.horizontal; + } + var vertical = "mostbottom"; + if (attr.vertical) { + vertical = attr.vertical; + } + $("#attr_location_h").button( + "setText", + $("#attr_location_h_list").children("li[loc=" + horizontal + + "]").html()); + $("#attr_location_h").attr("loc", horizontal); + $("#attr_location_v").button( + "setText", + $("#attr_location_v_list").children("li[loc=" + vertical + "]") + .html()); + $("#attr_location_v").attr("loc", vertical); + // 添加保存按钮 + item + .append("
        <@i18n resource='global.ok'/>
        <@i18n resource='global.cancel'/>
        "); + $("#save_edit_attr").bind("click", function(e) { + e.stopPropagation(); + Dock.saveAttrEdit(attrId); + }); + $("#cancel_edit_attr").bind("click", function(e) { + e.stopPropagation(); + Dock.setAttributeList(); + }) + }, + /** + * 设置数据属性值的输入 + * + * @param {} + * attr + * @param {} + * type + */ + setAttrValueInput : function(attr, type) { + var valueArea; + if (attr != null) { + // 如果为null,则是添加时调用,否则为修改 + valueArea = $(".attr_editing").children(".attr_value"); + } else { + valueArea = $("#attr_add_value_arera"); + } + valueArea.empty(); + var result; + if (type == "boolean") { + result = $("") + .appendTo(valueArea);; + } else if (type == "list") { + result = $("") + .appendTo(valueArea); + if (attr.listItems) { + for (var i = 0; i < attr.listItems.length; i++) { + var listItem = attr.listItems[i]; + result.append(""); + } + } + } else { + result = $("") + .appendTo(valueArea); + } + if (attr == null) { + valueArea.children().css("width", "260px"); + } else { + valueArea.children().css("width", "128px"); + } + return result; + }, + /** + * 添加数据显示的编辑项 + */ + appendDisplayItems : function() { + var optionsArea = $(".attr_display_options"); + // 详细区域,包括是否显示name,图标 + var detailArea = $("
        ") + .appendTo(optionsArea); + detailArea + .append(""); + // 选择图标的Button + var iconButtonArea = $("
        ") + .appendTo(detailArea); + iconButtonArea + .append("
        <@i18n resource='diagraming.addattr.icon'/>
        "); + iconButtonArea + .append("
        "); + iconButtonArea.append("
        "); + if ($("#attr_icon_list").children("li").html() == "") { + // 初始化图标选择 + var html = ""; + var index = 1; + while (index <= 49) { + if (index == 30) { + // 30时,要空出一格 + html += "
        "; + } + html += "
        "; + index++; + } + $("#attr_icon_list").children("li").html(html); + } + // 位置设置区域 + var locationArea = $("
        ") + .appendTo(optionsArea); + locationArea + .append("
        <@i18n resource='diagraming.addattr.display.location'/>
        "); + locationArea + .append("
        <@i18n resource='diagraming.addattr.display.h'/>
        "); + locationArea + .append("
        Most Right
        "); + locationArea.append("
        "); + locationArea + .append("
        <@i18n resource='diagraming.addattr.display.v'/>
        "); + locationArea + .append("
        Most Bottom
        "); + locationArea.append("
        "); + optionsArea.append("
        "); + $("#attr_display_icon").button({ + onMousedown : function() { + $("#attr_icon_list").dropdown({ + target : $("#attr_display_icon") + }); + } + }); + $("#attr_location_h").button({ + onMousedown : function() { + $("#attr_location_h_list").dropdown({ + target : $("#attr_location_h"), + onSelect : function(item) { + $("#attr_location_h").button("setText", + item.html()); + $("#attr_location_h").attr("loc", + item.attr("loc")); + } + }); + } + }); + $("#attr_location_v").button({ + onMousedown : function() { + $("#attr_location_v_list").dropdown({ + target : $("#attr_location_v"), + onSelect : function(item) { + $("#attr_location_v").button("setText", + item.html()); + $("#attr_location_v").attr("loc", + item.attr("loc")); + } + }); + } + }); + }, + /** + * 根据数据属性显示类型,设置操作界面 + * + * @param {} + * type + */ + setAttrDisplay : function(type) { + if (type == "none") { + $(".attr_display_options").hide(); + } else { + $(".attr_display_options").show(); + if (type == "icon") { + $("#attr_icon_area").show(); + } else { + $("#attr_icon_area").hide(); + } + } + }, + /** + * 设置数据属性的显示图标 + * + * @param {} + * icon + */ + setAttrIcon : function(icon) { + $("#attr_display_icon").attr("ico", icon).button("setText", ""); + if (icon) { + $("#attr_display_icon").button("setText", + ""); + } + }, + /** + * 保存数据属性编辑 + * + * @param {} + * attrId + */ + saveAttrEdit : function(attrId) { + var item = $(".attr_item_" + attrId); + if (!item.hasClass("attr_editing")) { + return; + } + var attr = Designer.getDataAttrById(attrId); + if (attr.category != "default") { + var name = item.children(".attr_name").children("input").val(); + if (name == "") { + item.children(".attr_name").children("input").focus(); + return; + } + attr.name = name; + attr.type = item.children(".attr_type").children("select").val(); + } + attr.value = item.children(".attr_value").children().val(); + var showType = $("#attr_edit_showtype").attr("ty"); + attr.showType = showType; + if (showType != "none") { + attr.showName = $("#attr_display_name").is(":checked"); + attr.horizontal = $("#attr_location_h").attr("loc"); + attr.vertical = $("#attr_location_v").attr("loc"); + if (showType == "icon") { + attr.icon = $("#attr_display_icon").attr("ico"); + } + } + // BPMN数据属性规则 + var selectedIds = Utils.getSelectedIds(); + var shape = Model.getShapeById(selectedIds[0]); + if (attr.category == "default" && shape.category == "bpmn") { + if (!shape.attribute) { + shape.attribute = {}; + } + if (!shape.attribute.markers) { + shape.attribute.markers = []; + } + var markers = shape.attribute.markers; + if (attr.name == "loopCharacteristics") { + Utils.removeFromArray(markers, "loop"); + Utils.removeFromArray(markers, "sequential"); + Utils.removeFromArray(markers, "parallel"); + if (attr.value == "StandardLoopCharacteristics") { + // 显示循环 + Utils.addToArray(markers, "loop"); + } else if (attr.value == "MultipleLoopCharacteristics") { + var sequantial = Designer + .getDefaultDataAttrByName("isSequantial"); + if (sequantial != null) { + if (sequantial.value == "true") { + // 显示三条横线 + Utils.addToArray(markers, "sequential"); + } else { + // 显示三条竖线 + Utils.addToArray(markers, "parallel"); + } + } + } + } else if (attr.name == "isSequantial") { + Utils.removeFromArray(markers, "sequential"); + Utils.removeFromArray(markers, "parallel"); + var loop = Designer + .getDefaultDataAttrByName("loopCharacteristics"); + if (loop != null && loop.value == "MultipleLoopCharacteristics") { + if (attr.value == "true") { + // 显示三条横线 + Utils.addToArray(markers, "sequential"); + } else { + // 显示三条竖线 + Utils.addToArray(markers, "parallel"); + } + } + } else if (attr.name == "isForCompensation") { + // 显示两个左箭头 + Utils.removeFromArray(markers, "compensation"); + if (attr.value == "true") { + Utils.addToArray(markers, "compensation"); + } + } else if (attr.name == "isCollection" + || attr.name == "ParticipantMultiplicity") { + Utils.removeFromArray(markers, "parallel"); + if (attr.value == "true") { + // 显示三条竖线 + Utils.addToArray(markers, "parallel"); + } + } else if (attr.name == "loopType") { + Utils.removeFromArray(markers, "loop"); + Utils.removeFromArray(markers, "sequential"); + Utils.removeFromArray(markers, "parallel"); + if (attr.value == "Standard") { + // 显示循环 + Utils.addToArray(markers, "loop"); + } else if (attr.value == "MultiInstanceSequential") { + // 显示三条横线 + Utils.addToArray(markers, "sequential"); + } else if (attr.value == "MultiInstanceParallel") { + // 显示三条竖线 + Utils.addToArray(markers, "parallel"); + } + } + } + Designer.updateDataAttribute(attr); + this.setAttributeList(); + }, + /** + * 删除数据属性 + * + * @param {} + * attrId + */ + deleteAttr : function(attrId, event) { + event.stopPropagation(); + var item = $(".attr_item_" + attrId); + item.remove(); + this.fitAttrList(); + Designer.deleteDataAttribute(attrId); + }, + /** + * 进入全屏 + */ + fullScreen : function(element, presentation) { + if (element.requestFullscreen) { + element.requestFullscreen(); + } else if (element.mozRequestFullScreen) { + element.mozRequestFullScreen(); + } else if (element.webkitRequestFullscreen) { + element.webkitRequestFullscreen(); + } else { + // 无法进入全屏,提示错误 + if (presentation) { + $("#fullscreen_tip").find(".t").text("由于您的浏览器限制,无法进入演示视图。"); + } else { + $("#fullscreen_tip").find(".t").text("无法进入全屏视图,您可以按(F11)进入。"); + } + $("#fullscreen_tip").fadeIn(); + } + }, + /** + * 进入演示视图 + */ + enterPresentation : function() { + $("#designer").bind('webkitfullscreenchange', function(e) { + Dock.manageFullScreen(); + }); + $(document).bind('mozfullscreenchange', function(e) { + Dock.manageFullScreen(); + }).bind('fullscreenchange', function(e) { + Dock.manageFullScreen(); + }); + this.fullScreen(Utils.getDomById("designer"), true); + + }, + /** + * 进入全屏视图 + */ + enterFullScreen : function() { + this.fullScreen(document.documentElement); + }, + manageFullScreen : function() { + var designer = Utils.getDomById("designer"); + if (document.fullscreenElement || document.webkitFullscreenElement + || document.mozFullScreenElement) { + // 如果进入全屏状态 + $("#shape_panel").addClass("readonly"); + $("#designer_viewport").addClass("readonly"); + $(window).unbind("resize.designer"); + $("#designer_layout").height(window.screen.height); + // 取消快捷键 + Designer.hotkey.cancel(); + Designer.op.cancel(); + // 隐藏Dock + $("#dock").hide(); + $(".dock_view").hide(); + Designer.contextMenu.destroy(); + Designer.op.canvasFreeDraggable(); + } else { + $("#shape_panel").removeClass("readonly"); + $("#designer_viewport").removeClass("readonly"); + Designer.initialize.initLayout(); + Designer.hotkey.init(); + Designer.op.init(); + $("#dock").show(); + if (Dock.currentView != "") { + Dock.showView(Dock.currentView); + } + Designer.contextMenu.init(); + $("#designer").unbind('webkitfullscreenchange'); + $("#designer").unbind('mozfullscreenchange') + .unbind('fullscreenchange'); + } + } +}; + +/** + * 鹰眼导航 + * + * @type {} + */ +var Navigator = { + /** + * 初始化 + */ + init : function() { + $("#designer_layout").bind("scroll", function() { + Navigator.setView(); + }); + // 绑定拖动 + $("#navigation_eye").bind("mousedown", function(downE) { + var eye = $(this); + var beginPos = eye.position(); + // 先取消滚动事件 + $("#designer_layout").unbind("scroll"); + var layout = $("#designer_layout"); + var beginTop = layout.scrollTop(); + var beginLeft = layout.scrollLeft(); + // 设计器画布 + var designerCanvas = $("#designer_canvas"); + var canvasW = designerCanvas.width(); + var canvasH = designerCanvas.height(); + // 鹰眼视图画布 + var canvas = $("#navigation_canvas"); + var navW = canvas.width(); + var navH = canvas.height(); + // 宽高比例 + var scaleW = canvasW / navW; + var scaleH = canvasH / navH; + $(document).bind("mousemove.navigator", function(moveE) { + var offsetX = moveE.pageX - downE.pageX; + var offsetY = moveE.pageY - downE.pageY; + var newLeft = beginLeft + offsetX * scaleW; + layout.scrollLeft(newLeft); + var newTop = beginTop + offsetY * scaleH; + layout.scrollTop(newTop); + eye.css({ + left : beginPos.left + offsetX, + top : beginPos.top + offsetY + }); + }); + $(document).bind("mouseup.navigator", function(moveE) { + $(document).unbind("mousemove.navigator"); + $(document).unbind("mouseup.navigator"); + Navigator.setView(); + // 重新绑定 + $("#designer_layout").bind("scroll", + function() { + Navigator.setView(); + }); + }); + }); + $("#navigation_canvas").bind("click", function(e) { + var pos = Utils.getRelativePos(e.pageX, e.pageY, $(this)); + // 设计器画布 + var designerCanvas = $("#designer_canvas"); + var canvasW = designerCanvas.width(); + var canvasH = designerCanvas.height(); + // 鹰眼视图画布 + var canvas = $("#navigation_canvas"); + var navW = canvas.width(); + var navH = canvas.height(); + // 宽高比例 + var scaleW = canvasW / navW; + var scaleH = canvasH / navH; + // 得到点击位置,相对于设计器画布的坐标 + var canvasX = pos.x * scaleW; + var canvasY = pos.y * scaleH; + // 把点击坐标,置于屏幕中心 + var layout = $("#designer_layout"); + var margin = Designer.config.pageMargin; + layout.scrollLeft(canvasX + margin - layout.width() / 2); + layout.scrollTop(canvasY + margin - layout.height() / 2); + }); + this.setView(); + }, + /** + * 绘制鹰眼视图 + */ + draw : function() { + if (this.drawNavigationTimeout) { + window.clearTimeout(this.drawNavigationTimeout); + } + this.drawNavigationTimeout = setTimeout(function() { + var canvas = $("#navigation_canvas"); + var ctx = canvas[0].getContext("2d"); + ctx.save(); + ctx.clearRect(0, 0, canvas.width(), canvas.height()); + ctx.scale(canvas.width() / Model.define.page.width, canvas + .height() + / Model.define.page.height); + // 从最底层开始绘制图形 + for (var i = 0; i < Model.orderList.length; i++) { + var shapeId = Model.orderList[i].id; + var shape = Model.getShapeById(shapeId); + ctx.save(); + if (shape.name != "linker") { + // 对图形执行绘制 + var p = shape.props; + var style = shape.lineStyle; + ctx.translate(p.x, p.y); + ctx.translate(p.w / 2, p.h / 2); + ctx.rotate(p.angle); + ctx.translate(-(p.w / 2), -(p.h / 2)); + ctx.globalAlpha = shape.shapeStyle.alpha; + Designer.painter.renderShapePath(ctx, shape); + } else { + var linker = shape; + var style = linker.lineStyle; + var points = linker.points; + var from = linker.from; + var to = linker.to; + ctx.beginPath(); + ctx.moveTo(from.x, from.y); + if (linker.linkerType == "curve") { + var cp1 = points[0]; + var cp2 = points[1]; + ctx.bezierCurveTo(cp1.x, cp1.y, cp2.x, cp2.y, + to.x, to.y); + } else { + for (var j = 0; j < points.length; j++) { + // 如果是折线,会有折点 + var linkerPoint = points[j]; + ctx.lineTo(linkerPoint.x, linkerPoint.y); + } + ctx.lineTo(to.x, to.y); + } + ctx.lineWidth = style.lineWidth; + ctx.strokeStyle = "rgb(" + style.lineColor + ")"; + ctx.stroke(); + } + ctx.restore(); + } + ctx.restore(); + Navigator.setView(); + this.drawNavigationTimeout = null; + }, 100); + }, + /** + * 设置鹰眼视图 + */ + setView : function() { + var navigator = $("#navigation_eye"); + // 设计器可见视图 + var layout = $("#designer_layout"); + var viewW = layout.width(); + var viewH = layout.height(); + // 鹰眼视图画布 + var canvas = $("#navigation_canvas"); + var navW = canvas.width(); + var navH = canvas.height(); + // 设计器画布 + var designerCanvas = $("#designer_canvas"); + var canvasW = designerCanvas.width(); + var canvasH = designerCanvas.height(); + var margin = Designer.config.pageMargin; + // 得到设计器画布在可视窗口中的left, top + var visibleLeft = margin - layout.scrollLeft(); + var visibleRight = visibleLeft + canvasW; + if (visibleLeft < 0) { + visibleLeft = 0; + } else if (visibleLeft > viewW) { + visibleLeft = viewW; + } + if (visibleRight > viewW) { + visibleRight = viewW; + } else if (visibleRight < 0) { + visibleRight = 0; + } + var visibleTop = margin - layout.scrollTop(); + var visibleBottom = visibleTop + canvasH; + if (visibleTop < 0) { + visibleTop = 0; + } else if (visibleTop > viewH) { + visibleTop = viewH; + } + if (visibleBottom > viewH) { + visibleBottom = viewH; + } else if (visibleBottom < 0) { + visibleBottom = 0; + } + var visibleW = visibleRight - visibleLeft; + var visibleH = visibleBottom - visibleTop; + if (visibleW == 0 || visibleH == 0) { + // 画布已经不可见 + navigator.hide(); + } else { + // 换算成鹰眼视图中的left, top + var navLeft = layout.scrollLeft() - margin; + if (navLeft < 0) { + navLeft = 0; + } + navLeft = navLeft * (navW / canvasW); + var navTop = layout.scrollTop() - margin; + if (navTop < 0) { + navTop = 0; + } + navTop = navTop * (navH / canvasH); + var navViewW = visibleW * (navW / canvasW); + var navViewH = visibleH * (navH / canvasH); + navigator.css({ + left : navLeft - 1, + top : navTop - 1, + width : navViewW, + height : navViewH + }).show(); + } + } +}; +/** + * jQuery的扩展 + */ +(function($) { + /** + * 按钮 + */ + $.fn.button = function(options) { + if (typeof options == "string") { + if (options == "disable") { + $(this).addClass("disabled"); + $(this).find("input").attr("disabled", true); + } else if (options == "enable") { + $(this).removeClass("disabled"); + $(this).find("input").attr("disabled", false); + } else if (options == "isDisabled") { + return $(this).hasClass("disabled"); + } else if (options == "isSelected") { + return $(this).hasClass("selected"); + } else if (options == "unselect") { + $(this).removeClass("selected"); + } else if (options == "select") { + $(this).addClass("selected"); + } else if (options == "setText") { + $(this).children(".text_content").html(arguments[1]); + } else if (options == "setColor") { + $(this).children(".btn_color").css("background-color", + "rgb(" + arguments[1] + ")"); + } else if (options == "getColor") { + var color = $(this).children(".btn_color") + .css("background-color").replace(/\s/g, ""); + return color.substring(4, color.length - 1); + } + return $(this); + } + var target = $(this); + target.unbind("click"); + target.unbind("mousedown") + if (options.onClick) { + target.bind("click", function() { + if (target.button("isDisabled")) { + return; + } + options.onClick(); + }); + } + if (options.onMousedown) { + target.bind("mousedown", function(e) { + if (target.button("isDisabled")) { + return; + } + options.onMousedown(); + e.stopPropagation(); + }); + } + }; + var currentMenu = null; + // 下拉控件 + $.fn.dropdown = function(options) { + var menu = $(this); + menu.find(".ico_selected").remove(); + if (typeof options == "string") { + if (options == "close") { + menu.hide(); + currentMenu.target.removeClass("selected"); + $(document).unbind("mousedown.ui_dropdown"); + currentMenu = null; + } else if (options == "select") { + arguments[1].prepend("
        "); + } + return; + } + if (currentMenu != null) { + /** + * 如果当前有其他菜单是打开的,则要先关闭 + */ + currentMenu.menu.dropdown("close"); + } + var menu = $(this); + var tar = options.target; + currentMenu = { + target : tar, + menu : menu + }; + var offset = tar.offset(); + tar.addClass("selected"); + menu.show(); + var left; + if (options.position == "center") { + left = offset.left + tar.outerWidth() / 2 - menu.outerWidth() / 2; + } else if (options.position == "right") { + left = offset.left + tar.outerWidth() - menu.outerWidth(); + } else { + left = offset.left; + } + var top = offset.top + tar.outerHeight(); + if (top + menu.outerHeight() > $(window).height()) { + top = $(window).height() - menu.outerHeight(); + } + menu.css({ + top : top, + left : left + }); + if (typeof options.zindex != "undefined") { + menu.css("z-index", options.zindex); + } + menu.unbind("mousedown").bind("mousedown", function(e) { + e.stopPropagation(); + }); + if (typeof options.bind == "undefined" || options.bind == true) { + menu.find("li:not(.devider,.menu_text)").unbind().bind("click", + function() { + var item = $(this); + if (!item.menuitem("isDisabled") + && item.children(".extend_menu").length == 0) { + if (options.onSelect) { + options.onSelect(item); + } + menu.dropdown("close"); + } + }); + } + $(document).bind("mousedown.ui_dropdown", function() { + menu.dropdown("close"); + }); + }; + // 调色板 + $.colorpicker = function(options) { + var picker = $("#color_picker"); + picker.find(".selected").removeClass("selected"); + if (!picker.attr("init")) { + // 没有经过初始化 + picker.find("div").each(function() { + var color = $(this).css("background-color"); + color = color.replace(/\s/g, ""); + color = color.substring(4, color.length - 1); + $(this).attr("col", color); + }); + picker.attr("init", true); + } + var opt = $.extend({}, options, { + bind : false + }); + picker.dropdown(opt); + picker.children(".color_items").children("div").unbind().bind("click", + function() { + if (options.onSelect) { + var color = $(this).css("background-color"); + color = color.replace(/\s/g, ""); + color = color.substring(4, color.length - 1); + options.onSelect(color); + } + $("#color_picker").dropdown("close"); + }); + if (options.color) { + picker.find("div[col='" + options.color + "']") + .addClass("selected"); + } + $("#color_picker").children(".color_extend").remove(); + if (options.extend) { + $("#color_picker").append("
        " + + options.extend + "
        ") + } + }; + // 颜色按钮 + $.fn.colorButton = function(opt) { + var tar = $(this); + if (typeof opt == "string") { + if (opt == "setColor") { + tar.children(".picker_btn_holder").css("background-color", + "rgb(" + arguments[1] + ")"); + } + return; + } + tar + .html("
        "); + tar.bind("mousedown", function(e) { + if (tar.button("isDisabled")) { + return; + } + e.stopPropagation(); + var options = $.extend({}, opt); + options.target = tar; + options.onSelect = function(color) { + tar.colorButton("setColor", color); + if (opt.onSelect) { + opt.onSelect(color); + } + }; + var color = $(this).children(".picker_btn_holder") + .css("background-color"); + color = color.replace(/\s/g, ""); + color = color.substring(4, color.length - 1); + options.color = color; + $.colorpicker(options); + }); + }; + /** + * 数字框 min: 0, max: 360, unit: "°", step: 15, + */ + $.fn.spinner = function(opt) { + var spinner = $(this); + if (typeof opt == "string") { + if (opt == "getValue") { + var result = spinner.find("input").val(); + result = parseFloat(result); + return result; + } else if (opt == "setValue") { + spinner.find("input").val(arguments[1]); + spinner.attr("old", arguments[1]); + } + return; + } + spinner.html("
        "); + var defaults = { + min : 0, + max : Number.MAX_VALUE, + step : 1, + unit : "" + }; + opt = $.extend(defaults, opt); + var inputBox = spinner.children(".spinner_input"); + var input = inputBox.find("input"); + spinner.spinner("setValue", opt.min + opt.unit); + spinner.find(".spinner_up").bind("click", function() { + if (spinner.button("isDisabled")) { + return; + } + var now = spinner.spinner("getValue"); + var newVal = now + opt.step; + setSpinnerValue(spinner, newVal, opt); + }); + spinner.find(".spinner_down").bind("click", function() { + if (spinner.button("isDisabled")) { + return; + } + var now = spinner.spinner("getValue"); + var newVal = now - opt.step; + setSpinnerValue(spinner, newVal, opt); + }); + input.bind("keydown", function(e) { + if (e.keyCode == 13) { + var newVal = parseInt($(this).val()); + if (isNaN(newVal)) { + newVal = opt.min; + } + setSpinnerValue(spinner, newVal, opt); + } + }).bind("focus", function(e) { + $(this).select(); + $(this).bind("mouseup", function(e) { + e.preventDefault(); + $(this).unbind("mouseup"); + }); + var box = $(this).parent().parent(); + if (!box.hasClass("active")) { + box.addClass("active inset"); + } + }).bind("blur", function(e) { + var box = $(this).parent().parent(); + if (box.hasClass("inset")) { + box.removeClass("active inset"); + } + }); + }; + function setSpinnerValue(spinner, value, opt) { + if (value > opt.max) { + value = opt.max; + } + if (value < opt.min) { + value = opt.min; + } + var oldValue = spinner.attr("old"); + var newValue = value + opt.unit; + if (oldValue != newValue) { + if (opt.onChange) { + opt.onChange(value); + } + } + spinner.spinner("setValue", value + opt.unit); + } + /** + * 菜单项 + */ + $.fn.menuitem = function(options) { + var target = $(this); + if (typeof options == "string") { + if (options == "disable") { + target.addClass("disabled"); + } else if (options == "enable") { + target.removeClass("disabled"); + } else if (options == "isDisabled") { + return target.hasClass("disabled"); + } else if (options == "isSelected") { + return target.children(".ico_selected").length > 0; + } else if (options == "unselect") { + return target.children(".ico_selected").remove(); + } else if (options == "select") { + return target.prepend("
        ") + } + } + }; + /** + * 窗口 + */ + $.fn.dlg = function(options) { + var dlg = $(this); + if (typeof options == "string") { + if (options == "close") { + dlg.children(".dlg_close").trigger("click"); + } + return; + } + var defaults = { + closable : true + }; + options = $.extend(defaults, options); + var close = dlg.children(".dlg_close"); + if (close.length == 0) { + close = $("
        ").appendTo(dlg); + } + if (options.closable == false) { + close.hide(); + } else { + close.show(); + } + $(".dlg_mask").remove(); + $("body").append("
        ") + close.unbind().bind("click", function() { + dlg.hide(); + $(".dlg_mask").remove(); + if (options && options.onClose) { + options.onClose(); + } + $(document).unbind("keydown.closedlg"); + dlg.find("input,textarea,select") + .unbind("keydown.closedlg"); + }); + dlg.css({ + left : ($(window).width() - dlg.outerWidth()) / 2, + top : ($(window).height() - dlg.outerHeight()) / 2 + }); + dlg.show(); + if (options.closable) { + dlg.find("input,textarea,select").unbind("keydown.closedlg").bind( + "keydown.closedlg", function(e) { + if (e.keyCode == 27) { + dlg.children(".dlg_close").trigger("click"); + } + }); + $(document).unbind("keydown.closedlg").bind("keydown.closedlg", + function(e) { + if (e.keyCode == 27) { + dlg.children(".dlg_close").trigger("click"); + } + }); + } + dlg.children(".dialog_header").unbind("mousedown.drag_dlg").bind( + "mousedown.drag_dlg", function(e) { + var target = $(this).parent(); + var downX = e.pageX; + var downY = e.pageY; + var downLeft = target.offset().left; + var downTop = target.offset().top; + $(document).bind("mousemove.drag_dlg", function(e) { + var left = e.pageX - downX + downLeft; + var top = e.pageY - downY + downTop; + target.offset({ + left : left, + top : top + }); + }); + $(document).bind("mouseup.drag_dlg", function(e) { + $(document).unbind("mousemove.drag_dlg"); + $(document).unbind("mouseup.drag_dlg"); + }); + }); + }; +})(jQuery);