window.rmmAPI = { /** * 打开动态视图。 * moduleId/moduleName, 指定应用; * navigateId/navigateName/navigateIds/navigateNames, 指定导航,推荐使用导航名称; * parentLibraryId/parentLibraryName, 父记录库,仅用于显示关联记录时,可选; * parentRecordId, 父记录ID,仅用于显示关联记录时,可选; * relationName, 与父记录库的关联,仅用于显示关联记录时,可选; * parameters, 视图初始化参数,最终合并到ViewContext中,在动态视图的脚本中可以访问; * expandPath, 展开到指定节点(例如: 1#01/2#12,双击导航树节点,在浏览器的控制台即可显示节点ID); * hideNavigate, 隐藏左侧导航,默认为false; * hideViewButton, 隐藏按钮工具栏 ,默认为false; * includeChild, 勾选包含下级, 默认为false; * showNavCount, 显示导航数量, 默认为5; * activeView, 激活的视图序号, 默认为0; * title, 视图标题,可选; * width, 视图宽度,默认1200,可选; * height, 视图高度,默认600,可选; * openMode, 打开方式(dialog/window),默认dialog,可选; * close,回调函数,可选; */ openView: function(options) { var params = []; if (options.moduleId) params.push("moduleId=" + options.moduleId); if (options.moduleName) params.push("moduleName=" + encodeURIComponent(encodeURIComponent(options.moduleName))); if (options.navigateId) params.push("navigateId=" + options.navigateId); if (options.navigateIds) params.push("navigateIds=" + encodeURIComponent(options.navigateIds)); if (options.navigateName) params.push("navigateName=" + encodeURIComponent(encodeURIComponent(options.navigateName))); if (options.navigateNames) params.push("navigateNames=" + encodeURIComponent(encodeURIComponent(options.navigateNames))); if (options.parentLibraryId) params.push("parentLibraryId=" + options.parentLibraryId); if (options.parentLibraryName) params.push("parentLibraryName=" + encodeURIComponent(encodeURIComponent(options.parentLibraryName))); if (options.parentRecordId) params.push("parentRecordId=" + options.parentRecordId); if (options.relationName) params.push("relationName=" + encodeURIComponent(encodeURIComponent(options.relationName))); if (options.parameters) params.push("parameters=" + encodeURIComponent(encodeURIComponent(JSON.stringify(options.parameters)))); if (options.expandPath) params.push("expandPath=" + encodeURIComponent(encodeURIComponent(options.expandPath))); if (options.hideNavigate != null) params.push("hideNavigate=" + options.hideNavigate); if (options.hideViewButton != null) params.push("hideViewButton=" + options.hideViewButton); if (options.includeChild != null) params.push("includeChild=" + options.includeChild); if (options.showNavCount != null) params.push("showNavCount=" + options.showNavCount); if (options.activeView != null) params.push("activeView=" + options.activeView); if (options.title) params.push("title=" + encodeURIComponent(encodeURIComponent(options.title))); if (options.width) params.push("width=" + options.width); if (options.height) params.push("height=" + options.height); if (options.openMode && options.openMode == "window") { var url = "/compliance/rmm/display/view/DynaView.jsp?" + params.join("&"); var win = window.open(url, "_blank "); //监听窗口关闭事件。此处必须延时,否则会触发两次。 setTimeout(function() { win.addEventListener("unload", function() { options.close && options.close(); }); }, 400); } else { var url = "/compliance/rmm/display/view/DynaView.jsp?" + params.join("&"); art.dialog.open(url, { id: "openView" + new Date().getTime(), //避免窗口宽度不正常 left: 0, top: 0, lock: true, resize: true, init: function() { this.size(this.config.width, this.config.height); this.position("50%", "40%"); }, close: function() { options.close && options.close(); } }); } }, /** * 选择记录。 * moduleId/moduleName, 指定应用; * navigateId/navigateName/navigateIds/navigateNames, 指定导航,推荐使用导航名称; * parentLibraryId/parentLibraryName, 父记录库,仅用于显示关联记录时,可选; * parentRecordId, 父记录ID,仅用于显示关联记录时,可选; * relationName, 与父记录库的关联,仅用于显示关联记录时,可选; * parameters, 视图初始化参数,最终合并到ViewContext中,在动态视图的脚本中可以访问; * expandPath, 展开到指定节点(例如: 1#01/2#12,双击导航树节点,在浏览器的控制台即可显示节点ID); * hideNavigate, 隐藏左侧导航,默认是false; * hideViewButton, 隐藏按钮工具栏 ,默认为false; * includeChild, 勾选包含下级, 默认为false; * showNavCount, 显示导航数量, 默认为5; * activeView, 激活的视图序号, 默认为0; * title, 视图标题,可选; * width, 视图宽度,默认1200,可选; * height, 视图高度,默认600,可选; * required, 是否必选,默认是false,可选; * multiple, 是否支持多选,默认是false,可选; * selectedIds, 被选中的记录ID(字符串,逗号分隔); * selectedRecords, 被选中的记录列表(包括:id/title/bo(或row)/relationProperty); * close,回调函数(status: 对话框状态,records:记录列表(包含id/title/relationProperty/row)); */ chooseRecord: function(options) { var params = []; if (options.moduleId) params.push("moduleId=" + options.moduleId); if (options.moduleName) params.push("moduleName=" + encodeURIComponent(encodeURIComponent(options.moduleName))); if (options.navigateId) params.push("navigateId=" + options.navigateId); if (options.navigateIds) params.push("navigateIds=" + options.navigateIds); if (options.navigateName) params.push("navigateName=" + encodeURIComponent(encodeURIComponent(options.navigateName))); if (options.navigateNames) params.push("navigateNames=" + encodeURIComponent(encodeURIComponent(options.navigateNames))); if (options.parentLibraryId) params.push("parentLibraryId=" + options.parentLibraryId); if (options.parentLibraryName) params.push("parentLibraryName=" + encodeURIComponent(encodeURIComponent(options.parentLibraryName))); if (options.parentRecordId) params.push("parentRecordId=" + options.parentRecordId); if (options.relationName) params.push("relationName=" + encodeURIComponent(encodeURIComponent(options.relationName))); if (options.parameters) params.push("parameters=" + encodeURIComponent(encodeURIComponent(JSON.stringify(options.parameters)))); if (options.expandPath) params.push("expandPath=" + encodeURIComponent(encodeURIComponent(options.expandPath))); if (options.hideNavigate != null) params.push("hideNavigate=" + options.hideNavigate); if (options.hideViewButton != null) params.push("hideViewButton=" + options.hideViewButton); if (options.includeChild != null) params.push("includeChild=" + options.includeChild); if (options.showNavCount != null) params.push("showNavCount=" + options.showNavCount); if (options.activeView != null) params.push("activeView=" + options.activeView); if (options.title) params.push("title=" + encodeURIComponent(encodeURIComponent(options.title))); if (options.width) params.push("width=" + options.width); if (options.height) params.push("height=" + options.height); var param2 = { required: (options.required != null ? options.required : false), multiple: (options.multiple != null ? options.multiple : false), selectedIds: options.selectedIds, selectedRecords: options.selectedRecords, }; art.dialog.open("/compliance/rmm/common/ChooseRecord.jsp?" + params.join("&"), { id: "chooseRecord" + new Date().getTime(), //避免窗口宽度不正常 left: 0, top: 0, lock: true, resize: true, params: param2, init: function() { this.size(this.config.width, this.config.height); this.position("50%", "40%"); }, close: function() { var status = this.config.DialogResult; var records = this.config.records; setTimeout(function() { options.close && options.close(status, records); }, 200); } }); }, /** * 打开动态表单。 * moduleId/moduleName, 指定应用; * libraryId/libraryName,指定记录库,推荐使用记录库名称; * parentLibraryId/parentLibraryName,父记录库,仅用于打开子表单时,可选; * parentRecordId,父记录ID(用于打开子表单),可选; * relationName,与父记录库的关联,仅用于打开子表单时,可选; * formType, 表单类型(参见表单属性); * recordType, 记录类型(参见通用原型的recordType属性),可选; * formMode,表单模式("normal": 正常提交,"subform": 通过对话框返回),默认是"normal",可选; * commitable,是否可以提交,默认是true,可选; * recordId, 记录ID(新建时可忽略),可选; * parentFormData,父表单数据,可选; * formData,表单数据,可选; * parameters,自定义参数(对应FormContext的parameters),可选; * close,回调函数(status: 对话框状态,formData:表单数据,changed:数据是否改变),可选。 */ openForm: function(options) { var params = []; if (options.moduleId) params.push("moduleId=" + options.moduleId); if (options.moduleName) params.push("moduleName=" + encodeURIComponent(encodeURIComponent(options.moduleName))); if (options.libraryId) params.push("libraryId=" + options.libraryId); if (options.libraryName) params.push("libraryName=" + encodeURIComponent(encodeURIComponent(options.libraryName))); if (options.parentLibraryId) params.push("parentLibraryId=" + options.parentLibraryId); if (options.parentLibraryName) params.push("parentLibraryName=" + encodeURIComponent(encodeURIComponent(options.parentLibraryName))); if (options.relationName) params.push("relationName=" + encodeURIComponent(encodeURIComponent(options.relationName))); if (options.formType) params.push("formType=" + encodeURIComponent(encodeURIComponent(options.formType))); if (options.recordType) params.push("recordType=" + encodeURIComponent(encodeURIComponent(options.recordType))); if (options.formMode) params.push("formMode=" + options.formMode); if (options.commitable != null) params.push("commitable=" + options.commitable); if (options.parentRecordId) params.push("parentRecordId=" + options.parentRecordId); if (options.recordId) params.push("recordId=" + options.recordId); //清除动态视图的垃圾数据(参见动态表单的参数处理)。 window.FunctionContext = null; art.dialog.data("FunctionContext", null); art.dialog.open("/compliance/rmm/display/form/DynaForm.jsp?" + params.join("&"), { id: "openForm" + new Date().getTime(), lock: true, resize: true, params: { parameters: options.parameters, parentFormData: options.parentFormData, formData: options.formData, }, init: function() { this.size(this.config.width, this.config.height); this.position("50%", "40%"); }, close: function() { var status = this.config.DialogResult; var formData = this.config.formData; var changed = this.config.changed; setTimeout(function() { options.close && options.close(status, formData, changed); }, 200); } }); }, /** * 选择分类。 * moduleId, 应用ID; * catalogId/catalogName,指定分类,推荐使用分类名称; * levelType 树加载方式(1加载整个分类树, 4加载到第N层节点); * level 树加载层级(对应levelType == 4); * required 是否必选; * multiple 是否多选; * editable 允许修改分类 * selectLeaf 只能选择叶子节点 * rootId,指定根节点ID,支持多值,分号分隔; * selectedIds 已选择的条目ID,数组; * condition 查询条件,可选; * parameters 查询参数, 英文分号分隔,可选; * close,回调函数(status: 对话框状态,ids: 条目ID, names:条目名称, rows: 条目对象) */ chooseCatalog: function(options) { art.dialog.open("/compliance/rmm/common/ChooseCatalog.jsp", { lock: true, resize: false, params: options, init: function() { this.size(this.config.width, this.config.height); this.position("50%", "40%"); }, close: function() { var status = this.config.DialogResult; var result = (status == "ok" ? this.config.result : {}); setTimeout(function() { options.close && options.close(status, result.ids, result.names, result.rows); }, 200); } }); }, /** * 选择字典条。 * moduleId, 应用ID; * dictionaryId/dictionaryName,指定字典,推荐使用字典名称; * levelType 树加载方式(1加载整个分类树, 4加载到第N层节点); * level 树加载层级(对应levelType == 4); * required 是否必选; * multiple 是否多选; * editable 允许修改字典 * selectLeaf 只能选择叶子节点 * rootCode: 指定根节点编码,支持多值,分号分隔; * selectedCodes 已选择的条目编码,数组; * condition 查询条件,可选; * parameters 查询参数, 英文分号分隔,可选; * close,回调函数(status: 对话框状态,codes: 条目编码,names: 条目名称,rows: 条目对象) */ chooseDictionary: function(options) { art.dialog.open("/compliance/rmm/common/ChooseDictionary.jsp", { lock: true, resize: false, params: options, init: function() { this.size(this.config.width, this.config.height); this.position("50%", "40%"); }, close: function() { var status = this.config.DialogResult; var result = (status == "ok" ? this.config.result : {}); setTimeout(function() { options.close && options.close(status, result.codes, result.names, result.rows); }, 200); } }); }, /** * 选择常量 。 * moduleId, 应用ID; * constantId,指定常量,推荐使用常量名称; * required 是否必选; * multiple 是否多选; * selectedValues 已选择的常量值,数组; * close,回调函数(status: 对话框状态,values: 常量值) */ chooseConstant: function(options) { art.dialog.open("/compliance/rmm/common/ChooseConstant.jsp", { lock: true, resize: false, params: options, init: function() { this.size(this.config.width, this.config.height); this.position("50%", "40%"); }, close: function() { var status = this.config.DialogResult; var result = (status == "ok" ? this.config.result : {}); setTimeout(function() { options.close(status, result.values); }, 200); } }); }, /** * 查看记录附件列表。 * libraryId, 记录库ID。 * recordId, 记录ID。 * fieldId, 附件字段ID,0表示自由附件。 * editable, 是否可以删除/上传附件。 */ openAttachmentList: function(libraryId, recordId, fieldId, editable, callback) { art.dialog.open("/compliance/rmm/function/record/AttachmentList.jsp", { lock: true, resize: false, params: { libraryId: libraryId, recordId: recordId, fieldId: fieldId, editable: editable, }, init: function() { this.size(this.config.width, this.config.height); this.position("50%", "40%"); }, close: function() { callback && callback(); } }); }, /** * 浏览单个附件。 * attachmentId, 附件ID。 * mode, 打开模式,'self'表示当前窗口,其他表示新页签。 */ openAttachment: function(attachmentId, mode) { var url = "/compliance/rmm/function/record/browser/OpenAttachment.jsp?attachmentId=" + attachmentId; if (mode && mode == 'self') { window.location.href = url; } else { window.open(url); } }, /** * 调用服务脚本(同步请求)。 * moduleId: 应用ID, * service: 服务名称, * parameters: 自定义参数,例如: {value: 123} */ callService: function(moduleId, service, parameters) { var params = { moduleId: moduleId, service: service, parameters: JSON.stringify(parameters) } var url = "/compliance/rmm/design/service/callService.action"; return zr.basic.httpSync(url, params, null); } }