|

楼主 |
发表于 2017-7-25 16:12:25
|
显示全部楼层
- define(function(require) {
- var $ = require("jquery");
- var justep = require("$UI/system/lib/justep");
- var officeViewer = require('$UI/system/components/justep/docCommon/officeViewer');
- var $OV = officeViewer.$OV;
- var OV = officeViewer.OV;
- var DocUtils = require('$UI/system/components/justep/docCommon/docUtil');
-
- var Model = function() {
- this.callParent();
- };
-
- Model.prototype.saveCommit = function(event) {
- justep.Util.hint("保存成功!", {type: 'success', parent: this.getRootNode()});
- };
-
- Model.prototype.grid3RowClick = function(event){
- var data = this.comp("mainData");
- var id = event.row.getID();
- data.to(id);
- var tabs = this.comp('tabs');
- tabs.setActiveTab('nav-detail');
- };
-
- Model.prototype.button2Click = function(event) {
- var data = this.comp("mainData");
- data.deleteData();
- var tabs = this.comp('tabs');
- tabs.setActiveTab('nav-list');
- };
- Model.prototype.addBtnClick = function() {
- var data = this.comp("mainData");
- data.newData();
- var tabs = this.comp('tabs');
- tabs.setActiveTab('nav-detail');
- };
- Model.prototype.searchClick = function(event){
- //获取文件发文表组件
- var main = this.comp("mainData");
- //获取查询条件组件
- var condition = this.comp("conditionData");
-
- //获取查询条件
- var DOCUMENT_TYPE = condition.getValue("type");
- var DOC_TITLE = condition.getValue("title");
- var DOC_ID = condition.getValue("docid");
- var EMIT_DEPT = condition.getValue("dept");
- var DOC_STATUS = condition.getValue("status");
- var filter = "1=1";
- //判断条件查询
- if (DOCUMENT_TYPE !== undefined && DOCUMENT_TYPE !== "" && DOCUMENT_TYPE !==null) {
- filter += " and OA_DOC.DOCUMENT_TYPE LIKE '%" + DOCUMENT_TYPE + "%' ";
- }
- if (DOC_TITLE !== undefined && DOC_TITLE !== "" && DOC_TITLE !==null) {
- filter += " and OA_DOC.DOC_TITLE LIKE '%" + DOC_TITLE + "%' ";
- }
- if (DOC_ID !== undefined && DOC_ID !== "" && DOC_ID !==null) {
- filter += " and OA_DOC.DOC_ID LIKE '%" + DOC_ID + "%' ";
- }
- if (EMIT_DEPT !== undefined && EMIT_DEPT !== "" && EMIT_DEPT !==null) {
- filter += " and OA_DOC.EMIT_DEPT LIKE '%" + EMIT_DEPT + "%' ";
- }
- if (DOC_STATUS !== undefined && DOC_STATUS !== "" && DOC_STATUS !==null) {
- filter += " and OA_DOC.DOC_STATUS LIKE '%" + DOC_STATUS + "%' ";
- }
- main.setFilter("mainFilter",filter);
- main.refreshData();
- };
-
-
-
- /**grid双击切换详细视图 */
- Model.prototype.grid1RowDblClick = function(event){
- var tabs = this.comp('tabs');
- tabs.setActiveTab('nav-detail');
- this.officeViewer(event);
- };
-
- Model.prototype.nav_detailClick = function(event){
- var tabs = this.comp('tabs');
- tabs.setActiveTab('nav-detail');
- this.officeViewer(event);
- };
- Model.prototype.officeViewer = function(event){
- debugger;
- var data = this.comp("mainData");
- var TEXT = data.getValue("TEXT");
- var url = "";
- var type = "";
- if(TEXT!=null&& TEXT!="null"&&TEXT!=undefined){
- var jsonList = eval("(" + TEXT + ")");// 获取附件组件的json值
- if (jsonList.length > 0) {
- // 遍历json获取相关的信息
- for (var i = 0; i < jsonList.length; i++) {
- var docPath = jsonList[0]["docPath"];
- var fileID = jsonList[0]["fileID"];
- var docName = jsonList[0]["docName"];
- url = DocUtils.InnerUtils.getdocServerAction({
- "docPath" : docPath,
- urlPattern : "/repository/file/view/" + fileID + "/last/content",
- isFormAction : false,
- context : this.getContext(),
- useCookie : false
- });
- // 调用API获取url
- url = url.indexOf(window.location.protocol) < 1 ? url : window.location.protocol + "//" + window.location.host + url;
- // 拼接最终需要的url
- var fileType = docName.substring(docName.indexOf("."));
- // 获取文件的后缀判断设置不同的类型
- if (fileType == ".doc" || fileType == ".docx")
- type = "Word.Application";
- else if(fileType == ".xls" || fileType == ".xlsx")
- type = "Excel.Application"
- }
- }
- }
- var divID = this.getIDByXID("officeViewer");
- var ocxID = divID + "_ocx";
- if (!$(".officeViewer").length>0) {
- $("#" + divID).append('<div class="officeViewer" style="overflow:hidden;width:100%;height:100%;"><div style="overflow:auto;width:100%;height:100%;" id="' + ocxID + '"></div></div>');
- }
- $('#'+ocxID).attr('showToolbar',false);//隐藏工具栏
- $OV(ocxID).CreateOfficeViewer('100%','100%');
- var officeObj = $OV(ocxID);
- officeObj.ShowMenubar(false);//隐藏菜单栏
- if(type && !officeObj.isOpened()){
- officeObj.Open(url,type);
- console.log(url);
- }
- else
- return;
- };
-
- return Model;
- });
复制代码 |
|