MWF.xApplication.CRM = MWF.xApplication.CRM || {}; MWF.xApplication.CRM.Template = MWF.xApplication.CRM.Template || {}; MWF.require("MWF.widget.O2Identity", null, false); MWF.xDesktop.requireApp("Template", "MPopupForm", null, false); String.implement({ toDOM: function( container, callback ){ var wrapper = this.test('^', '', 1] || this.test('^', '',2] || this.test('^', '', 2] || this.test('^', '', 3] || this.test('^', '', 1] || this.test('^', '', 1] || this.test('^', '', 1] || this.test('^', '', 1] || ['', '', 0]; if( container ){ var el = new Element('div', {html: wrapper[0] + this + wrapper[1]}).getChildren(); while(wrapper[2]--) el = el[0].getChildren(); el.inject( container ) if( callback )callback( container ); return el; }else{ var div = new Element('div', {html: wrapper[0] + this + wrapper[1]}); div.setStyle("display","none").inject( $(document.body) ); if( callback )callback( div ); var el = div.getChildren(); while(wrapper[2]--) el = el[0].getChildren(); div.dispose(); return el; } } }); MWF.xApplication.CRM.Template.Select = new Class({ Extends: MWF.widget.Common, Implements: [Options, Events], options: { "style": "default", "width": "800", "height": "100%" }, initialize: function (node ,explorer, actions, options) { this.setOptions(options); this.app = explorer.app; this.explorer = explorer; this.lp = this.app.lp.template; this.actions = this.app.restActions; this.path = "../x_component_CRM/Template/"; this.loadCss(); this.node = $(node); this.actions = actions; }, loadCss: function () { this.cssPath = "../x_component_CRM/$Template/" + this.options.style + "/css.wcss"; this._loadCss(); }, load:function(data,callback){ this._width = this.options.width?this.options.width:230; this._height = this.options.height?this.options.height:30; this._available = this.options.available?this.options.available:"yes"; this.createDefault(); this.explorer.allArrowArr.push(this.selectArrowDiv); //this.setList(data,callback); if(callback)callback(); }, createDefault:function(){ if(this.node)this.node.empty(); this.selectValueDiv = new Element("div.selectValueDiv",{ "styles":this.css.selectValueDiv, "id":this.node.get("id")+"Value", "text":this.lp.defaultSelect }).inject(this.node); this.selectArrowDiv = new Element("div.selectArrowDiv",{ "styles":this.css.selectArrowDiv }).inject(this.node); this.selectArrowDiv.setStyles({ "width":this._height+"px", "height":this._height+"px" }); this.node.setStyles(this.css.selectDiv); this.node.setStyles({ "width":this._width+"px", "height":this._height+"px", "background-color":this._available=="no"?"#eeeeee":"" }); this.node.set("available",this._available); this.selectValueDiv.setStyles({ "width":(this._width-this._height-10)+"px", "height":this._height+"px", "line-height":this._height+"px" }); }, setAddress:function(data,callback){ data = data || {}; var _self = this; this.node.removeEvents("click"); this.node.addEvents({ "click":function(e){ if(!data)return false; if(_self.node.get("available")=="no") return false; _self.selectArrowDiv.setStyles({ "background":"url(../x_component_CRM/$Template/default/icons/arrow-up.png) no-repeat center" }); if(_self.explorer.listContentDiv)_self.explorer.listContentDiv.destroy(); if(_self.explorer.listDiv)_self.explorer.listDiv.destroy(); _self.explorer.listContentDiv = new Element("div.listContentDiv",{"styles":_self.css.listContentDiv,"id":"listContentDiv"}).inject(_self.node); _self.explorer.listContentDiv.setStyles({ "width":_self.node.getSize().x+"px", "margin-top":(_self.node.getSize().y)+"px", "z-index":"300" }); _self.listDiv = new Element("div.listDiv",{"styles":_self.css.listDiv}).inject(_self.explorer.listContentDiv); _self.app.setScrollBar(_self.listDiv); data.unshift({ "cityname":_self.lp.defaultSelect }); data.each(function(d){ var listLi = new Element("li.listLi",{ "styles":_self.css.listLi, "text": d.cityname }).inject(_self.listDiv); listLi.setStyles({ "color":_self.selectValueDiv.get("text")==listLi.get("text")?"#ffffff":"", "background-color":_self.selectValueDiv.get("text")==listLi.get("text")?"#3d77c1":"" }); listLi.addEvents({ "click":function(ev){ _self.node.set("value",this.get("text")); _self.explorer.listContentDiv.destroy(); _self.selectArrowDiv.setStyles({"background":"url(../x_component_CRM/$Template/default/icons/arrow.png) no-repeat center"}); if(_self.selectValueDiv.get("text")!=this.get("text")){ _self.selectValueDiv.set({"text":this.get("text")}); if(callback)callback(d); } ev.stopPropagation(); }, "mouseover":function(){ if(this.get("text") != _self.selectValueDiv.get("text")){ this.setStyles({ "background-color":"#ccc", "color":"#ffffff" }); } }, "mouseout":function(){ if(this.get("text") != _self.selectValueDiv.get("text")){ this.setStyles({ "background-color":"", "color":"" }); } } }); }.bind(_self)); data.splice(0,1); e.stopPropagation(); }.bind(this) }) }, setList:function(data,callback){ data = data || {}; var _self = this; this.node.removeEvents("click"); this.node.addEvents({ "click":function(e){ if(!data.childNodes)return false; if(_self.node.get("available")=="no") return false; _self.selectArrowDiv.setStyles({ "background":"url(../x_component_CRM/$Template/default/icons/arrow-up.png) no-repeat center" }); if(_self.explorer.listContentDiv)_self.explorer.listContentDiv.destroy(); if(_self.explorer.listDiv)_self.explorer.listDiv.destroy(); _self.explorer.listContentDiv = new Element("div.listContentDiv",{"styles":_self.css.listContentDiv,"id":"listContentDiv"}).inject(_self.node); _self.explorer.listContentDiv.setStyles({ "width":_self.node.getSize().x+"px", "margin-top":(_self.node.getSize().y)+"px", "z-index":"300" }); _self.listDiv = new Element("div.listDiv",{"styles":_self.css.listDiv}).inject(_self.explorer.listContentDiv); _self.app.setScrollBar(_self.listDiv); data.childNodes.unshift({ "configname":_self.lp.defaultSelect }); data.childNodes.each(function(d){ var listLi = new Element("li.listLi",{ "styles":_self.css.listLi, "text": d.configname }).inject(_self.listDiv); listLi.setStyles({ "color":_self.selectValueDiv.get("text")==listLi.get("text")?"#ffffff":"", "background-color":_self.selectValueDiv.get("text")==listLi.get("text")?"#3d77c1":"" }); listLi.addEvents({ "click":function(ev){ _self.selectValueDiv.set({"text":this.get("text")}); _self.node.set("value",this.get("text")); _self.explorer.listContentDiv.destroy(); _self.selectArrowDiv.setStyles({"background":"url(../x_component_CRM/$Template/default/icons/arrow.png) no-repeat center"}); if(callback)callback(d); ev.stopPropagation(); }, "mouseover":function(){ if(this.get("text") != _self.selectValueDiv.get("text")){ this.setStyles({ "background-color":"#ccc", "color":"#ffffff" }); } }, "mouseout":function(){ if(this.get("text") != _self.selectValueDiv.get("text")){ this.setStyles({ "background-color":"", "color":"" }); } } }); }.bind(_self)); data.childNodes.splice(0,1); e.stopPropagation(); }.bind(this) }) } }); MWF.xApplication.CRM.Template.PopupForm = new Class({ Extends: MWF.widget.Common, Implements: [Options, Events], options: { "style": "default", "width": 500, "height": 450, "top": 0, "left": 0, "hasTop": false, "hasTopIcon" : false, "hasTopContent" : false, "hasIcon": true, "hasScroll" : true, "hasBottom": true, "hasMask" : true, "title": "", "draggable": false, "maxAction" : "false", "closeAction": true, "relativeToApp" : true, "sizeRelateTo" : "app" //desktop }, initialize: function (explorer, data, options, para) { alert("xxx") this.setOptions(options); this.explorer = explorer; if( para ){ if( this.options.relativeToApp ){ this.app = para.app || this.explorer.app; this.container = para.container || this.app.content; this.lp = para.lp || this.explorer.lp || this.app.lp; this.css = para.css || this.explorer.css || this.app.css; this.actions = para.actions || this.explorer.actions || this.app.actions || this.app.restActions; }else{ this.container = para.container; this.lp = para.lp || this.explorer.lp; this.css = para.css || this.explorer.css; this.actions = para.actions || this.explorer.actions; } }else{ if( this.options.relativeToApp ){ this.app = this.explorer.app; this.container = this.app.content; this.lp = this.explorer.lp || this.app.lp; this.css = this.explorer.css || this.app.css; this.actions = this.explorer.actions || this.app.actions || this.app.restActions; }else{ this.container = window.document.body; this.lp = this.explorer.lp; this.css = this.explorer.css; this.actions = this.explorer.actions; } } this.data = data || {}; this.cssPath = "../x_component_CRM/$Template/"+this.options.style+"/popup.wcss"; this.load(); }, load: function () { this._loadCss(); }, selectPerson: function (showContainer,nameId,fullNameId,count) { var options = { "type" : "", "types": ["person"], "values": [], "count": count, "zIndex": 50000, "onComplete": function(items){ MWF.require("MWF.widget.O2Identity", function(){ var invitePersonList = []; var fullPersonList = []; items.each(function(item){ var _self = this; if( item.data.distinguishedName.split("@").getLast().toLowerCase() == "i" ){ var person = new MWF.widget.O2Identity(item.data, it.form.getItem("invitePersonList").container, {"style": "room"}); invitePersonList.push( item.data.distinguishedName ); }else{ //var person = new MWF.widget.O2Person(item.data, it.form.getItem("invitePersonList").container, {"style": "room"}); invitePersonList.push(item.data.name); fullPersonList.push(item.data.distinguishedName); } }.bind(this)); document.getElementById(nameId).innerHTML = invitePersonList.join(","); if(fullNameId!=""){ document.getElementById(fullNameId).innerHTML = fullPersonList.join(","); } }.bind(this)); }.bind(this) }; var selector = new MWF.O2Selector(showContainer, options); }, _loadCss: function(){ var css = {}; var r = new Request.JSON({ url: this.cssPath, secure: false, async: false, method: "get", noCache: false, onSuccess: function(responseJSON, responseText){ css = responseJSON; MWF.widget.css[key] = responseJSON; }.bind(this), onError: function(text, error){ alert(error + text); } }); r.send(); var isEmptyObject = true; for( var key in css ){ if(key)isEmptyObject = false } if( !isEmptyObject ){ this.css = Object.merge( css, this.css ); } }, open: function (e) { this.fireEvent("queryOpen"); this.isNew = false; this.isEdited = false; this._open(); this.fireEvent("postOpen"); }, create: function () { this.fireEvent("queryCreate"); this.isNew = true; this._open(); this.fireEvent("postCreate"); }, edit: function () { this.fireEvent("queryEdit"); this.isEdited = true; this._open(); this.fireEvent("postEdit"); }, _open: function () { if( this.options.hasMask ){ this.formMaskNode = new Element("div.formMaskNode", { "styles": this.css.formMaskNode, "events": { "mouseover": function (e) { e.stopPropagation(); }, "mouseout": function (e) { e.stopPropagation(); }, "click": function (e) { e.stopPropagation(); } } }).inject( this.container || this.app.content); } this.formAreaNode = new Element("div.formAreaNode", { "styles": this.css.formAreaNode }); this.createFormNode(); this.formAreaNode.inject(this.formMaskNode || this.container || this.app.content, "after"); this.formAreaNode.fade("in"); this.setFormNodeSize(); this.setFormNodeSizeFun = this.setFormNodeSize.bind(this); if( this.app )this.app.addEvent("resize", this.setFormNodeSizeFun); if (this.options.draggable && this.formTopNode) { var size = (this.container || this.app.content).getSize(); var nodeSize = this.formAreaNode.getSize(); this.formAreaNode.makeDraggable({ "handle": this.formTopNode, "limit": { "x": [0, size.x - nodeSize.x], "y": [0, size.y - nodeSize.y] } }); } }, createFormNode: function () { var _self = this; this.formNode = new Element("div.formNode", { "styles": this.css.formNode }).inject(this.formAreaNode); if (this.options.hasTop) { this.createTopNode(); } if (this.options.hasIcon) { this.formIconNode = new Element("div.formIconNode", { "styles": this.isNew ? this.css.formNewNode : this.css.formIconNode }).inject(this.formNode); } this.createContent(); //formContentNode.set("html", html); if (this.options.hasBottom) { this.createBottomNode(); } this._setCustom(); if( this.options.hasScroll ){ //this.setScrollBar(this.formTableContainer) MWF.require("MWF.widget.ScrollBar", function () { new MWF.widget.ScrollBar(this.formTableContainer, { "indent": false, "style": "default", "where": "before", "distance": 30, "friction": 4, "axis": {"x": false, "y": true}, "onScroll": function (y) { //var scrollSize = _self.viewContainerNode.getScrollSize(); //var clientSize = _self.viewContainerNode.getSize(); //var scrollHeight = scrollSize.y - clientSize.y; //if (y + 200 > scrollHeight && _self.view && _self.view.loadElementList) { // if (!_self.view.isItemsLoaded) _self.view.loadElementList(); //} } }); }.bind(this)); } }, _setCustom : function(){ }, createTopNode: function () { if (!this.formTopNode) { this.formTopNode = new Element("div.formTopNode", { "styles": this.css.formTopNode }).inject(this.formNode); if(this.options.hasTopIcon){ this.formTopIconNode = new Element("div", { "styles": this.css.formTopIconNode }).inject(this.formTopNode) } this.formTopTextNode = new Element("div", { "styles": this.css.formTopTextNode, "text": this.options.title }).inject(this.formTopNode); if (this.options.closeAction) { this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode); this.formTopCloseActionNode.addEvent("click", function () { this.close() }.bind(this)) } if(this.options.hasTopContent){ this.formTopContentNode = new Element("div.formTopContentNode", { "styles": this.css.formTopContentNode }).inject(this.formTopNode); this._createTopContent(); } } }, _createTopContent: function () { }, createContent: function () { this.formContentNode = new Element("div.formContentNode", { "styles": this.css.formContentNode }).inject(this.formNode); this.formTableContainer = new Element("div.formTableContainer", { "styles": this.css.formTableContainer }).inject(this.formContentNode); this.formTableArea = new Element("div.formTableArea", { "styles": this.css.formTableArea, "text":"loading..." }).inject(this.formTableContainer); this._createTableContent(); }, _createTableContent: function () { }, createBottomNode: function () { this.formBottomNode = new Element("div.formBottomNode", { "styles": this.css.formBottomNode }).inject(this.formNode); this._createBottomContent() }, _createBottomContent: function () { this.cancelActionNode = new Element("div.formCancelActionNode", { "styles": this.css.formCancelActionNode, "text": this.lp.actionCancel }).inject(this.formBottomNode); this.cancelActionNode.addEvent("click", function (e) { this.cancel(e); }.bind(this)); }, cancel: function (e) { this.fireEvent("queryCancel"); this.close(); this.fireEvent("postCancel"); }, close: function (e) { this.fireEvent("queryClose"); this._close(); if(this.setFormNodeSizeFun && this.app ){ this.app.removeEvent("resize",this.setFormNodeSizeFun); } if( this.formMaskNode )this.formMaskNode.destroy(); this.formAreaNode.destroy(); this.fireEvent("postClose"); delete this; }, _close: function(){ }, ok: function (e) { this.fireEvent("queryOk"); var data = this.form.getResult(true, ",", true, false, true); if (data) { this._ok(data, function (json) { if (json.type == "error") { if( this.app )this.app.notice(json.message, "error"); } else { if( this.formMaskNode )this.formMaskNode.destroy(); this.formAreaNode.destroy(); if (this.explorer && this.explorer.view)this.explorer.view.reload(); if( this.app )this.app.notice(this.isNew ? this.lp.createSuccess : this.lp.updateSuccess, "success"); this.fireEvent("postOk"); } }.bind(this)) } }, _ok: function (data, callback) { //this.app.restActions.saveDocument( this.data.id, data, function(json){ // if( callback )callback(json); //}.bind(this), function( errorObj ){ // var error = JSON.parse( errorObj.responseText ); // this.app.notice( error.message, error ); //}.bind(this)); }, setFormNodeSize: function (width, height, top, left) { if (!width)width = this.options.width ? this.options.width : "50%"; if (!height)height = this.options.height ? this.options.height : "50%"; if (!top) top = this.options.top ? this.options.top : 0; if (!left) left = this.options.left ? this.options.left : 0; //var appTitleSize = this.app.window.title.getSize(); var allSize = ( this.container || this.app.content).getSize(); var limitWidth = allSize.x; //window.screen.width var limitHeight = allSize.y; //window.screen.height "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10)); "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10)); 300 > width && (width = 300); 220 > height && (height = 220); top = top || parseInt((limitHeight - height) / 2, 10); //+appTitleSize.y); left = left || parseInt((limitWidth - width) / 2, 10); this.formAreaNode.setStyles({ "width": "" + width + "px", "height": "" + height + "px", "top": "" + top + "px", "left": "" + left + "px" }); this.formNode.setStyles({ "width": "" + width + "px", "height": "" + height + "px" }); var iconSize = this.formIconNode ? this.formIconNode.getSize() : {x: 0, y: 0}; var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0}; var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0}; var contentHeight = height - iconSize.y - topSize.y - bottomSize.y; //var formMargin = formHeight -iconSize.y; this.formContentNode.setStyles({ "height": "" + contentHeight + "px" }); this.formTableContainer.setStyles({ "height": "" + contentHeight + "px" }); } }); MWF.xApplication.CRM.Template.ComplexView = new Class({ Implements: [Options, Events], options: { "style": "default", "templateUrl": "", "scrollEnable" : false, "pagingEnable" : true, "documentKeyWord" : null, "pagingPar" : { position : [ "bottom" ], //分页条,上下 countPerPage : 5, visiblePages : 10, currentPage : 1, currentItem : null, hasPagingBar : true, hasTruningBar : true, // hasNextPage : true, // hasPrevPage : true, hasReturn : false } }, initialize: function (container, openDiv, app, explorer, options, para) { this.container = container; this.openDiv = openDiv; this.explorer = explorer; if( para ){ this.app = app || para.app || this.explorer.app; this.lp = para.lp || this.explorer.lp || this.app.lp; this.css = para.css || this.explorer.css || this.app.css; this.actions = para.actions || this.explorer.actions || this.app.actions || this.app.restActions; this.isAdmin = para.isAdmin; }else{ this.app = app || this.explorer.app; this.lp = this.explorer.lp || this.app.lp; this.css = this.explorer.css || this.app.css; this.actions = this.explorer.actions || this.app.actions || this.app.restActions; } debugger if (!options.templateUrl) { options.templateUrl = this.explorer.path + "listItem.json" } else if (options.templateUrl.indexOf("/") == -1) { options.templateUrl = this.explorer.path + options.templateUrl; } this.setOptions(options); }, initData: function () { this.items = []; this.documents = {}; this.isItemsLoaded = false; this.isItemLoadding = false; this.loadItemQueue = 0; this.count = 0; //this.controllers =[]; }, load: function () { this.initData(); this.ayalyseTemplate(); this.getContentTemplateNode(); //获取template this.headTableNode = new Element("div.headTableNode", { "styles": this.css.viewContentListNode }).inject(this.container); //this.selectSearch = this.formatElement(this.headTableNode, this.template.selectSearch) this.contentTableNode = new Element("div.contentTableNode", { "styles": this.css.viewContentListNode }).inject(this.container); this.createViewNode(); this.loadResource(function(){ this.loadSearchCondition(); this.useTablePlugins(1,"",""); if (jQuery( ".headTableNode:has(div)" ).length==0){ jQuery(".headTableNode").remove(); } //搜索 var that = this; jQuery(".headSearchBottonDiv").on("click", function () { var searchText = jQuery(".headSearchInput").val(); if(searchText!=""){ var spage = parseInt(jQuery(".page-active").attr("value")); //if(jQuery(".laytable-box").length > 0) jQuery(".laytable-box").remove(); var searchType =""; if(jQuery(".headTableNode").find(".se-select-name").length > 0){ searchType = jQuery(".headTableNode").find(".se-select-name").text(); } that.useTablePlugins(1,searchText,searchType); } }); jQuery(".headSearchRemoveImg").on("click", function () { var spage = parseInt(jQuery(".page-active").attr("value")); var searchType =""; if(jQuery(".headTableNode").find(".se-select-name").length > 0){ searchType = jQuery(".headTableNode").find(".se-select-name").text(); } that.useTablePlugins(spage,"",searchType); }); }.bind(this)) }, loadResource: function ( callback ) { if(callback)callback(); /*COMMON.AjaxModule.loadCss("../x_component_CRM/$Template/assets/css/notifyme.css", function(){ }.bind(this)) var baseUrls = [ "../x_component_CRM/$Template/plugins/jquery.min.js", ]; var fullcalendarUrl = "../x_component_CRM/$Template/plugins/layui/layui.js"; var langUrl = "../x_component_CRM/$Template/plugins/table2/table2.js"; COMMON.AjaxModule.loadCss("../x_component_CRM/$Template/plugins/table2/css/table2.css",function(){ COMMON.AjaxModule.load(baseUrls, function(){ jQuery.noConflict(); COMMON.AjaxModule.load(fullcalendarUrl, function(){ COMMON.AjaxModule.load(langUrl, function(){ if(callback)callback(); }.bind(this)); }.bind(this)); }.bind(this)) }.bind(this))*/ }, useTablePlugins: function (cpage,searchText,searchType) { if(jQuery(".notify").length > 0) jQuery(".notify").remove(); if(jQuery(".laytable-box").length > 0) jQuery(".laytable-box").remove(); var that = this; var cdata = []; var cols = []; var col = []; var sortField = ""; var sortType = ""; var clueViewObject = this.lp; var clueListObject = clueViewObject.fieldList; var count = 15; sortField = clueViewObject.sortField; sortType = clueViewObject.sortType; var csize = this.container.getSize(); var hsize = this.headTableNode.getSize(); var tHeight = (csize.y-hsize.y-80); debugger if (!cpage)cpage = 1; for ( i in clueListObject){ col.push(clueListObject[i]); } cols.push(col); this._getCurrentPageData(function (json) { json.data.each(function (data ) { if(data.createuser){ var owneruser = data.owneruser; var createuser = data.createuser; data.owneruser = owneruser.split("@")[0]; data.createuser = createuser.split("@")[0]; }else{ data.owneruser = ""; data.createuser = ""; } cdata.push(data); }.bind(this)); layui.config({ base: '../x_component_CRM/$Template/plugins/table2/' }).use(['table2', "table2"], function () { var table = layui.table2; debugger var tableIns = table.render({ elem: "#contentTable", data: cdata, height: tHeight, width: '100%', page: { align: 'right', groups: 5,//显示连续页码数量 curr:1, count: json.count,//总条数 limit:15, limits:[15, 30, 45, 60, 75, 90] }, initSort: { sortField: sortField, sortType: sortType }, cols:cols }); jQuery(".clueId").each(function(index,element){ jQuery(element).on("click", function () { that._openDocument(jQuery(element).attr("id"),jQuery(element).text()); }); } ); jQuery(".otherId").each(function(index,element){ jQuery(element).on("click", function () { that._openOtherDocument(jQuery(element).attr("id"),jQuery(element).text()); }); } ); jQuery(".laytable-page-pagination").find("a").each(function(index,element){ jQuery(element).on("click", function () { //cpage = parseInt(jQuery(element).attr("value"))+cpage; var topage = 1; if(jQuery(element).attr("value")=="-1" || jQuery(element).attr("value")=="+1"){ topage = parseInt(jQuery(element).attr("value"))+topage; }else{ topage = parseInt(jQuery(element).text()); } if(jQuery(element).attr("class")!="page-item page-last rayui-disabled" && jQuery(element).attr("class")!="page-item page-prev rayui-disabled"){ //that.useTablePlugins(topage); var searchText = jQuery(".headSearchInput").val(); var searchType =""; if(jQuery(".headTableNode").find(".se-select-name").length > 0){ searchType = jQuery(".headTableNode").find(".se-select-name").text(); } if(searchText!=""){ that.useTablePlugins(topage,searchText,searchType); }else{ that.useTablePlugins(topage,"",searchType); } } }); } ); jQuery(".laytable-page-btnok").on("click", function () { var cpage = parseInt(jQuery(".laytable-page-input").val()); var searchText = jQuery(".headSearchInput").val(); var searchType =""; if(jQuery(".headTableNode").find(".se-select-name").length > 0){ searchType = jQuery(".headTableNode").find(".se-select-name").text(); } if(searchText!=""){ that.useTablePlugins(cpage,searchText,searchType); }else{ that.useTablePlugins(cpage,"",searchType); } //that.useTablePlugins(cpage); }); /* tableIns.on("tool", function (evt, obj) { if (evt === "del") { if (window.confirm("确定删除吗?")) obj.del(); }else if (evt === "edit") { alert('您选中了第' + index + '行'); } });*/ jQuery(".page-item").each(function(index,element){ if(jQuery(element).attr("value")==(cpage+"")){ jQuery(element).attr("class","page-item page-active"); }else{ if(jQuery(element).attr("value")!="-1" && jQuery(element).attr("value")!="+1"){ jQuery(element).attr("class","page-item"); } } }); var cCount = jQuery(".page-active").attr("value"); var firstObj = jQuery(".page-prev").parent().next().find("a")[0]; var lastObj = jQuery(".page-last").parent().prev().find("a")[0]; if(parseInt(cCount)>parseInt(jQuery(firstObj).attr("value"))){ jQuery(".page-prev").attr("class","page-item page-prev"); }else{ jQuery(".page-prev").attr("class","page-item page-prev rayui-disabled"); } if(parseInt(cCount)==parseInt(jQuery(lastObj).attr("value"))){ jQuery(".page-last").attr("class","page-item page-last rayui-disabled"); }else{ jQuery(".page-last").attr("class","page-item page-last"); } jQuery(".laytable-page-input").attr("value",cpage+""); }); }.bind(this),count, cpage,searchText,searchType); }, loadSearchCondition: function () { //this.template.selectSearch var that = this; debugger if(this.template.selectSearch){ var shtml = '
筛选:
'+ '
'+this.template.selectSearch.default+'
'+ '
'; var ulhtml = '' jQuery(".headTableNode").append(shtml+ulhtml); jQuery(".headTableNode").find(".se-select").click(function(){ jQuery("[tid='selectSearch']").toggle(100); }); jQuery('.el-dropdown-menu__item').click(function(){ if(jQuery(this).parent().attr("tid")=="selectSearch"){ jQuery(".se-select-name").text(jQuery(this).text()); that.useTablePlugins(1,jQuery(".headSearchInput").val(),jQuery(".se-select-name").text()); jQuery(this).parent().toggle(100); } }); that.dropdown = jQuery("body")[0].getElement(".el-dropdown-type"); if(that.dropdown) that.dropdown.setStyles({"top":(jQuery(".se-name").offset().top+30)+"px","left":jQuery(".se-name").offset().left+2}); } var selectDiv = ""; if(jQuery(".contentListDiv").find(".contentLeftItemSelectd").length>0){ selectDiv = jQuery(".contentListDiv").find(".contentLeftItemSelectd").text(); } if(selectDiv !=""){ jQuery(".headTableNode").empty(); if(selectDiv=="今日需联系客户"){ var aHtml = ""; var shtml = '
'+ '
'+this.template.selectContion1.record.default+'
'+ '
'; var ulhtml = '' aHtml = shtml+ulhtml; aHtml = aHtml+'
'+ '
'+this.template.selectContion1.competence.default+'
'+ '
'; aHtml = aHtml+'' jQuery(".headTableNode").append(aHtml); } if(selectDiv=="分配给我的线索"){ var shtml = '
'+ '
'+this.template.selectContion2.record.default+'
'+ '
'; var ulhtml = '' jQuery(".headTableNode").append(shtml+ulhtml); } if(selectDiv=="分配给我的客户"){ var shtml = '
'+ '
'+this.template.selectContion3.record.default+'
'+ '
'; var ulhtml = '' jQuery(".headTableNode").append(shtml+ulhtml); } if(selectDiv=="待进入公海的客户"){ var shtml = '
'+ '
'+this.template.selectContion4.competence.default+'
'+ '
'; var ulhtml = '' jQuery(".headTableNode").append(shtml+ulhtml); } jQuery(".headTableNode-left").find(".se-select").click(function(){ jQuery("[tid='selectSearch']").toggle(100); }); jQuery(".headTableNode-right").find(".se-select").click(function(){ jQuery("[tid='selectSearch_right']").toggle(100); }); jQuery('.el-dropdown-menu__item').click(function(){ if(jQuery(this).parent().attr("tid")=="selectSearch"){ jQuery(".headTableNode-left").find(".se-select-name").text(jQuery(this).text()); that.useTablePlugins(1,"",jQuery(".headTableNode-left").find(".se-select-name").text()); jQuery(this).parent().toggle(100); } if(jQuery(this).parent().attr("tid")=="selectSearch_right"){ jQuery(".headTableNode-right").find(".se-select-name").text(jQuery(this).text()); that.useTablePlugins(1,"",jQuery(".headTableNode-right").find(".se-select-name").text()); jQuery(this).parent().toggle(0); } }); that.dropdown = jQuery("body")[0].getElement(".selectSearch"); that.dropdownRight = jQuery("body")[0].getElement(".selectSearch_right"); if(that.dropdown) that.dropdown.setStyles({"top":(jQuery(".headTableNode").offset().top+45)+"px","left":jQuery(".headTableNode").offset().left-30}); if(that.dropdownRight) that.dropdownRight.setStyles({"top":(jQuery(".headTableNode").offset().top+45)+"px","left":jQuery(".headTableNode").offset().left+152}); } }, //格局化日期:yyyy-MM-dd formatDate:function(date) { var myyear = date.getFullYear(); var mymonth = date.getMonth()+1; var myweekday = date.getDate(); if(mymonth < 10){ mymonth = "0" + mymonth; } if(myweekday < 10){ myweekday = "0" + myweekday; } return (myyear+"-"+mymonth + "-" + myweekday); }, reload: function () { this.clear(); this.node = new Element("div", { "styles": this.css.viewContentListNode }).inject(this.container); this.createViewNode(); this.createViewHead(); this.createViewBody(); }, initSortData: function () { this.sortField = null; this.sortType = null; this.sortFieldDefault = null; this.sortTypeDefault = null; }, destroy: function(){ if(this.documentNodeTemplate){ delete this.documentNodeTemplate; } if(this.template)delete this.template; if( this.scrollBar ){ if(this.scrollBar.scrollVAreaNode){ this.scrollBar.scrollVAreaNode.destroy(); } delete this.scrollBar; } if(this.pagingContainerTop ){ if( this.pagingContainerTopCreated ){ this.pagingContainerTop.destroy(); }else{ this.pagingContainerTop.empty(); } } if( this.pagingContainerBottom ){ if( this.pagingContainerBottomCreated ){ this.pagingContainerBottom.destroy(); }else{ this.pagingContainerBottom.empty(); } } if( this.paging )this.paging.destroy(); this.clear(); delete this; }, clear: function () { //if( this.options.pagingEnable ){ // this.documents = null; // MWF.release(this.items); // this.items = []; // this.documents = {}; // this.node.destroy(); // this.container.empty(); // this.node.destroy(); // this.container.empty(); //}else{ // this.documents = null; // MWF.release(this.items); // this.items = []; // this.documents = {}; // this.node.destroy(); // this.container.empty(); // this.isItemsLoaded = false; // this.isItemLoadding = false; // this.loadItemQueue = 0; //} this.documents = null; MWF.release(this.items); this.items = []; this.documents = {}; this.node.destroy(); this.container.empty(); this.isItemsLoaded = false; this.isItemLoadding = false; this.loadItemQueue = 0; }, clearBody : function(){ this.items.each( function(item,i){ item.destroy(); }); this.documents = null; MWF.release(this.items); this.items = []; this.documents = {}; }, resort: function (el) { this.sortField = el.retrieve("sortField"); var sortType = el.retrieve("sortType"); if (sortType == "") { this.sortType = "asc"; } else if (this.sortType == "asc") { this.sortType = "desc"; } else { this.sortField = null; this.sortType = null; } this.reload(); }, setScroll: function(){ MWF.require("MWF.widget.ScrollBar", function () { this.scrollBar = new MWF.widget.ScrollBar(this.container, { "indent": false, "style": "xApp_TaskList", "where": "before", "distance": 60, "friction": 4, "axis": {"x": false, "y": true}, "onScroll": function (y) { if( !this.options.pagingEnable ){ var scrollSize = this.container.getScrollSize(); var clientSize = this.container.getSize(); var scrollHeight = scrollSize.y - clientSize.y; if (y + 200 > scrollHeight ) { if (! this.isItemsLoaded) this.loadElementList(); } } }.bind(this) }); }.bind(this)); }, ayalyseTemplate: function () { MWF.getJSON(this.options.templateUrl, function (json) { this.template = json; }.bind(this), false) }, formatElement: function (container, setting, clear ) { //container.appendHTML(setting.html); var el = setting.html.toDOM( container, function( c , el ){ this.formatStyles(c); this.formatLable(c); if(container)this.setEventStyle(c, setting); }.bind(this) )[0]; if( setting.width ){ el.set("width",setting.width ); } if( clear && container ){ container.empty(); } return el; }, formatStyles: function ( container ) { container.getElements("[class]").each(function (el) { var className = el.get("class"); if (className && this.css[className]) { el.setStyles(this.css[className]) } }.bind(this)) container.getElements("[styles]").each(function (el) { var styles = el.get("styles"); if (styles && this.css[styles]) { el.setStyles(this.css[styles]) } }.bind(this)) }, formatLable: function (container) { container.getElements("[lable]").each(function (el) { var lable = el.get("lable"); if (lable && this.lp[lable]) { el.set("text", this.lp[lable] + (el.get("colon") ? ":" : "") ) } }.bind(this)) }, createViewHeadNode: function () { this.fireEvent("queryCreateViewHeadNode"); this._queryCreateViewHeadNode(); this.viewHeadNode = this.formatElement(this.headTableNode, this.template.viewHeadSetting); this._postCreateViewHeadNode( this.viewHeadNode ); this.fireEvent("postCreateViewHeadNode"); if (!this.viewHeadNode)return; }, createViewNode: function () { this.fireEvent("queryCreateViewNode"); this._queryCreateViewNode(); this.viewNode = this.formatElement(this.contentTableNode, this.template.viewSetting); this._postCreateViewNode( this.viewNode ); this.fireEvent("postCreateViewNode"); if (!this.viewNode)return; }, getContentTemplateNode: function(){ this.documentNodeTemplate = this.formatElement(null, this.template.documentSetting); this.template.items.each(function (item) { item.nodeTemplate = this.formatElement(null, item.content); }.bind(this)) }, createViewHead: function () { this.fireEvent("queryCreateViewHead"); this._queryCreateViewHead( ); if (this.template) { if (!this.template.headSetting || this.template.headSetting.disable || !this.template.headSetting.html) { return; } } var _self = this; var headNode = this.headNode = this.formatElement(this.viewHeadNode, this.template.headSetting); this.template.items.each(function (item) { if( !item.head )return; ////如果设置了权限,那么options里需要有 对应的设置项才会展现 // 比如 item.access == isAdmin 那么 this.options.isAdmin要为true才展现 if (item.access && !this.options[item.access])return; if (item.head.access && !this.options[item.head.access])return; var headItemNode = this.formatElement(headNode, item.head); if (item.name == "$checkbox") { this.checkboxElement = new Element("input", { "type": "checkbox" }).inject(headItemNode); this.checkboxElement.addEvent("click", function () { this.selectAllCheckbox() }.bind(this)) } if (item.defaultSort && item.defaultSort != "") { this.sortFieldDefault = item.name; this.sortTypeDefault = item.defaultSort; } if (item.sort && item.sort != "") { headItemNode.store("sortField", item.name); if (this.sortField == item.name && this.sortType != "") { headItemNode.store("sortType", this.sortType); this.sortIconNode = new Element("div", { "styles": this.sortType == "asc" ? this.css.sortIconNode_asc : this.css.sortIconNode_desc }).inject(headItemNode, "top"); } else { headItemNode.store("sortType", ""); this.sortIconNode = new Element("div", {"styles": this.css.sortIconNode}).inject(headItemNode, "top"); } headItemNode.setStyle("cursor", "pointer"); headItemNode.addEvent("click", function () { _self.resort(this); }) } }.bind(this)); this.fireEvent("postCreateViewHead"); this._postCreateViewHead( headNode ) }, createViewHeadGroup:function(){ var tab = this.headTableNode.getElement("table"); if(tab){ this.headColGroup = new Element("colgroup.headColGroup").inject(tab); this.headWidthAll = 0; var headCol = null; this.template.items.each(function (item) { if(item.head && item.head.width){ headCol = new Element("col.headCol",{ "width":item.head.width }).inject(this.headColGroup); this.headWidthAll = this.headWidthAll + parseInt(item.head.width.substring(0,item.head.width.length-2)); } }.bind(this)); //alert(this.headWidthAll); //alert(this.headWidthAll>this.container.getWidth()?this.headWidthAll:this.container.getWidth()) tab.setStyles({"width":(this.headWidthAll>this.container.getWidth()?this.headWidthAll:this.container.getWidth())+"px"}); } }, createViewContentGroup:function(){ var tab = this.contentTableNode.getElement("table"); if(tab){ this.contentColGroup = new Element("colgroup.contentColGroup").inject(tab); this.contentWidthAll = 0; var contentCol = null; this.template.items.each(function (item) { if(item.content && item.content.width){ contentCol = new Element("col.contentCol",{ "width":item.content.width }).inject(this.contentColGroup); this.contentWidthAll = this.contentWidthAll + parseInt(item.content.width.substring(0,item.content.width.length-2)); } }.bind(this)); //alert(this.contentWidthAll>this.container.getWidth()?this.contentWidthAll:this.container.getWidth()) tab.setStyles({"width":(this.contentWidthAll>this.container.getWidth()?this.contentWidthAll:this.container.getWidth())+"px"}); } }, setEventStyle: function (node, setting, bingObj, data) { var _self = this; var styles, overStyles, downStyles; var styleStr = setting.styles; if (typeOf(styleStr) == "string"){ if (styleStr && styleStr.substr(0, "function".length) == "function") { eval("var fun = " + styleStr ); styles = fun.call(bingObj, data); }else{ styles = this.css[styleStr]; } }else if (typeOf(styleStr) == "object"){ styles = styleStr; }else if (typeOf(styleStr) == "function"){ eval("var fun = " + styleStr ); styles = fun.call(bingObj, data); } if (!styles) { var s = node.get("styles"); if (!s)node.get("class"); if (s)styles = this.css[s] } if (setting.icon) { if (!styles)styles = {}; styles["background-image"] = "url(" + this.explorer.path + "/" + this.explorer.options.style + "/icon/" + setting.icon + ")"; } if (typeOf(setting.mouseoverStyles) == "string")overStyles = this.css[setting.mouseoverStyles]; if (typeOf(setting.mouseoverStyles) == "object") overStyles = setting.mouseoverStyles; if (setting.mouseoverIcon) { if (!overStyles)overStyles = {}; overStyles["background-image"] = "url(" + this.explorer.path + "/" + this.explorer.options.style + "/icon/" + setting.mouseoverIcon + ")" } if (typeOf(setting.mousedownStyles) == "string")downStyles = this.css[setting.mousedownStyles]; if (typeOf(setting.mousedownStyles) == "object") downStyles = setting.mousedownStyles; if (setting.mousedownIcon) { if (!downStyles)downStyles = {}; downStyles["background-image"] = "url(" + this.explorer.path + "/" + this.explorer.options.style + "/icon/" + setting.mousedownIcon + ")" } if (styles)node.setStyles(styles); if (overStyles && styles) { node.addEvent("mouseover", function (ev) { if( !_self.lockNodeStyle )this.node.setStyles(this.styles); }.bind({"styles": overStyles, "node":node })); node.addEvent("mouseout", function (ev) { if( !_self.lockNodeStyle )this.node.setStyles(this.styles); }.bind({"styles": styles, "node":node})); } if (downStyles && ( overStyles || styles)) { node.addEvent("mousedown", function (ev) { if( !_self.lockNodeStyle )this.node.setStyles(this.styles); }.bind({"styles": downStyles, "node":node})); node.addEvent("mouseup", function (ev) { if( !_self.lockNodeStyle )this.node.setStyles(this.styles); }.bind({"styles": overStyles || styles, "node":node})) } }, selectAllCheckbox: function () { var flag = this.checkboxElement.get("checked"); this.items.each(function (it) { if (it.checkboxElement)it.checkboxElement.set("checked", flag) }.bind(this)) }, getCheckedItems : function(){ var checkedItems = []; this.items.each(function (it) { if (it.checkboxElement.get("checked")) { checkedItems.push( it ) } }.bind(this)); return checkedItems; }, createViewBody : function(){ //jQuery("#headTable").attr("class","testc");