Publicseas.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. MWF.xApplication.CRM = MWF.xApplication.CRM || {};
  2. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  3. MWF.xDesktop.requireApp("CRM", "Template", null,false);
  4. MWF.xDesktop.requireApp("Template", "Explorer", null,false);
  5. MWF.require("MWF.widget.Identity", null,false);
  6. /*MWF.xDesktop.requireApp("Forum", "Actions.RestActions", null, false);*/
  7. MWF.xApplication.CRM.Publicseas = new Class({
  8. Extends: MWF.widget.Common,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "default"
  12. },
  13. initialize: function (node, app, actions, options) {
  14. this.setOptions(options);
  15. this.app = app;
  16. this.lp = app.lp.publicseas;
  17. this.path = "../x_component_CRM/$Publicseas/";
  18. this.loadCss();
  19. this.actions = actions;
  20. this.node = $(node);
  21. debugger
  22. },
  23. loadCss: function () {
  24. this.cssPath = "../x_component_CRM/$Publicseas/" + this.options.style + "/css.wcss";
  25. this._loadCss();
  26. },
  27. load: function () {
  28. //this.testActions = new MWF.xApplication.Forum.Actions.RestActions();
  29. if(this.formContentArr)this.formContentArr.empty();
  30. this.formContentArr = [];
  31. if(this.formMarkArr)this.formMarkArr.empty();
  32. this.formMarkArr = [];
  33. this.rightContentDiv = this.app.rightContentDiv;
  34. this.createHeadContent();
  35. //this.createToolBarContent();
  36. this.createPublicseasContent();
  37. this.resizeWindow();
  38. this.app.addEvent("resize", function(){
  39. this.resizeWindow();
  40. }.bind(this));
  41. },
  42. reload:function(){
  43. this.createPublicseasContent();
  44. this.resizeWindow();
  45. },
  46. createHeadContent:function(){
  47. debugger
  48. if(this.headContentDiv) this.headContentDiv.destroy();
  49. this.headContentDiv = new Element("div.headContentDiv",{"styles":this.css.headContentDiv}).inject(this.rightContentDiv);
  50. this.headTitleDiv = new Element("div.headTitleDiv",{
  51. "styles":this.css.headTitleDiv,
  52. "text":this.lp.head.headTitle
  53. }).inject(this.headContentDiv);
  54. //search
  55. this.headSearchDiv = new Element("div.headSearchDiv",{"styles":this.css.headSearchDiv}).inject(this.headContentDiv);
  56. this.headSearchTextDiv = new Element("div.headSearchTextDiv",{"styles":this.css.headSearchTextDiv}).inject(this.headSearchDiv);
  57. this.headSearchImg = new Element("img.headSearchImg",{
  58. "styles":this.css.headSearchImg,
  59. "src": this.path+"default/icons/search.png"
  60. }).inject(this.headSearchTextDiv);
  61. this.headSearchInput = new Element("input.headSearchInput",{
  62. "styles":this.css.headSearchInput,
  63. "placeholder":this.lp.head.searchText
  64. }).inject(this.headSearchTextDiv);
  65. this.headSearchInput.addEvents({
  66. "keyup":function(){
  67. if(this.headSearchInput.get("value")!=""){
  68. this.headSearchRemoveImg.setStyles({"display":"inline-block"})
  69. }
  70. }.bind(this)
  71. });
  72. this.headSearchRemoveImg = new Element("img.headSearchRemoveImg",{
  73. "styles":this.css.headSearchRemoveImg,
  74. "src": this.path+"default/icons/remove.png"
  75. }).inject(this.headSearchTextDiv);
  76. this.headSearchRemoveImg.addEvents({
  77. "click":function(){
  78. this.headSearchInput.set("value","")
  79. }.bind(this)
  80. });
  81. this.headSearchBottonDiv = new Element("div.headSearchBottonDiv",{
  82. "styles":this.css.headSearchBottonDiv,
  83. "text":this.lp.head.search
  84. }).inject(this.headSearchDiv);
  85. this.headBottonDiv = new Element("div.headBottonDiv",{"styles":this.css.headBottonDiv}).inject(this.headContentDiv);
  86. this.headMoreBottonDiv = new Element("div.headMoreBottonDiv",{
  87. "styles":this.css.headMoreBottonDiv,
  88. "text" :this.lp.head.moreAction
  89. }).inject(this.headBottonDiv);
  90. this.headMoreBottonDiv.addEvents({
  91. "click":function(){
  92. }.bind(this)
  93. });
  94. this.headMoreImg = new Element("img.headMoreImg",{
  95. "styles": this.css.headMoreImg,
  96. "src" : this.path+"default/icons/arrow.png"
  97. }).inject(this.headMoreBottonDiv);
  98. },
  99. createToolBarContent:function(){
  100. },
  101. createPublicseasContent:function(){
  102. if(this.contentListDiv) this.contentListDiv.destroy();
  103. this.contentListDiv = new Element("div.contentListDiv",{"styles":this.css.contentListDiv}).inject(this.rightContentDiv);
  104. if(this.contentListInDiv) this.contentListInDiv.destroy();
  105. this.contentListInDiv = new Element("div.contentListInDiv",{"styles":this.css.contentListInDiv}).inject(this.contentListDiv);
  106. var size = this.rightContentDiv.getSize();
  107. if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px"});
  108. if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px","width":"100%"});
  109. if(this.PublicseasView) delete this.PublicseasView;
  110. var templateUrl = this.path+"publicseasView.json";
  111. var filter = {};
  112. ////this.publicseasView = new MWF.xApplication.CRM.publicseas.View(this.contentListInDiv, this.app, {lp : this.app.lp.curtomerView, css : this.css, actions : this.actions }, { templateUrl : templateUrl,filterData:filter} );
  113. this.publicseasView = new MWF.xApplication.CRM.Publicseas.View(
  114. this.contentListInDiv,
  115. this.openDiv,
  116. this.app,
  117. this,
  118. { templateUrl : templateUrl,filterData:filter},
  119. {
  120. lp:this.app.lp.publicseasView,
  121. isAdmin:this.options.isAdmin
  122. }
  123. );
  124. this.publicseasView.load();
  125. },
  126. resizeWindow:function(){
  127. var size = this.rightContentDiv.getSize();
  128. var rSize = this.headTitleDiv.getSize();
  129. var lSize = this.headBottonDiv.getSize();
  130. if(this.headSearchDiv){
  131. var x = this.headSearchDiv.getSize().x;
  132. this.headSearchDiv.setStyles({"margin-left":(size.x-rSize.x-lSize.x)/2-(x/2)+"px"});
  133. }
  134. //alert(JSON.stringify(size))
  135. if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px"});
  136. if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px"});
  137. }
  138. });
  139. MWF.xApplication.CRM.Publicseas.View = new Class({
  140. Extends: MWF.xApplication.CRM.Template.ComplexView,
  141. _createDocument: function(data){
  142. return new MWF.xApplication.CRM.Clue.Document(this.viewNode, data, this.explorer, this);
  143. },
  144. _getCurrentPageData: function(callback, count, page, searchText,searchType){
  145. var category = this.category = this.options.category;
  146. if (!count)count = 15;
  147. if (!page)page = 1;
  148. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  149. //if(id=="(0)")this.app.createShade();
  150. var filter = this.options.filterData || {};
  151. filter={key: searchText?searchText.trim():"",
  152. orderFieldName: "updateTime",
  153. orderType: "desc"
  154. };
  155. if (!searchType)searchType = "全部客户";
  156. if(false&&!this.isAdmin){
  157. debugger
  158. if(searchType=="我负责的客户"){
  159. this.actions.ListMyDuty_publicseas(page, count, filter, function (json) {
  160. if (callback)callback(json);
  161. }.bind(this));
  162. }
  163. if(searchType=="下属负责的客户"){
  164. this.actions.ListNestedSubPerson_publicseas(page, count, filter, function (json) {
  165. if (callback)callback(json);
  166. }.bind(this));
  167. }
  168. if(searchType=="我参与的客户"){
  169. this.actions.ListMyParticipate_publicseas(page, count, filter, function (json) {
  170. if (callback)callback(json);
  171. }.bind(this));
  172. }
  173. if(searchType=="全部客户"){
  174. this.actions.ListAllMy_publicseas(page, count, filter, function (json) {
  175. if (callback)callback(json);
  176. }.bind(this));
  177. }
  178. }else{
  179. this.actions.getPublicseasByPage(page, count, filter, function (json) {
  180. if (callback)callback(json);
  181. }.bind(this));
  182. }
  183. },
  184. _create: function(){
  185. },
  186. _openDocument: function(openId ,openName){
  187. /*MWF.xDesktop.requireApp("CRM", "ClueEdit", function(){
  188. this.explorer = new MWF.xApplication.CRM.ClueEdit(this, this.actions,{},{
  189. "clueId":clueId,
  190. "onReloadView" : function( ){
  191. //alert(JSON.stringify(data))
  192. this.reload();
  193. }.bind(this)
  194. });
  195. this.explorer.load();
  196. }.bind(this))*/
  197. MWF.xDesktop.requireApp("CRM", "PublicseasOpen", function(){
  198. this.explorer = new MWF.xApplication.CRM.PublicseasOpen(this, this.actions,{},{
  199. "openId":openId,
  200. "openName":openName,
  201. "openType":"single",
  202. "onReloadView" : function( ){
  203. //alert(JSON.stringify(data))
  204. this.reload();
  205. }.bind(this)
  206. });
  207. this.explorer.load();
  208. }.bind(this))
  209. },
  210. _queryCreateViewNode: function(){
  211. },
  212. _postCreateViewNode: function( viewNode ){
  213. },
  214. _queryCreateViewHead:function(){
  215. },
  216. _postCreateViewHead: function( headNode ){
  217. }
  218. });
  219. MWF.xApplication.CRM.Publicseas.Document = new Class({
  220. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  221. _queryCreateDocumentNode:function( itemData ){
  222. },
  223. _postCreateDocumentNode: function( itemNode, itemData ){
  224. this.view.template.items.each(function (item,i) {
  225. if(item.head.width){
  226. itemNode.getElements("td")[i].set("width",item.head.width);
  227. }
  228. if(i == itemNode.getElements("td").length-1){
  229. itemNode.getElements("td")[i].set("width",this.view.lastTdWidth);
  230. }
  231. }.bind(this));
  232. },
  233. open: function (e) {
  234. this.view._openDocument(this.data, this.index);
  235. },
  236. edit : function(){
  237. var appId = "ForumDocument"+this.data.id;
  238. if (this.app.desktop.apps[appId]){
  239. this.app.desktop.apps[appId].setCurrent();
  240. }else {
  241. this.app.desktop.openApplication(null, "ForumDocument", {
  242. "sectionId" : this.data.sectionId,
  243. "id" : this.data.id,
  244. "appId": appId,
  245. "isEdited" : true,
  246. "isNew" : false,
  247. "index" : this.index
  248. });
  249. }
  250. }
  251. })
  252. //
  253. //MWF.xApplication.CRM.Publicseas.View = new Class({
  254. // Extends: MWF.xApplication.Template.Explorer.ComplexView,
  255. //
  256. // _createDocument: function(data){
  257. // return new MWF.xApplication.CRM.Publicseas.Document(this.viewNode, data, this.explorer, this);
  258. // },
  259. //
  260. // _getCurrentPageData: function(callback, count){
  261. // var category = this.category = this.options.category;
  262. //
  263. // if (!count)count = 20;
  264. // var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  265. //
  266. // if(id=="(0)")this.app.createShade();
  267. //
  268. // var filter = this.options.filterData || {};
  269. //
  270. // this.actions.getPublicseasListNext(id, count, filter, function (json) {
  271. // if (callback)callback(json);
  272. // this.app.destroyShade();
  273. // }.bind(this));
  274. //
  275. // },
  276. // _create: function(){
  277. //
  278. // },
  279. // _openDocument: function( documentData ){
  280. //
  281. // //if(this.publicseasRead){
  282. // // this.publicseasRead.load(documentData)
  283. // //}else{
  284. // MWF.xDesktop.requireApp("CRM", "PublicseasRead", function(){
  285. // this.publicseasRead = new MWF.xApplication.CRM.PublicseasRead(this.explorer.contentListDiv,this.app, this.explorer,this.actions,{
  286. // "width":1000,
  287. // "onReloadView" : function(){
  288. // this.explorer.reloadPublicseasView();
  289. // }.bind(this)
  290. // } );
  291. // this.publicseasRead.load(documentData);
  292. // this.explorer.formContentArr.push(this.publicseasRead);
  293. // this.explorer.formMarkArr.push(this.publicseasRead.formMaskNode);
  294. //
  295. // }.bind(this));
  296. // //}
  297. //
  298. // },
  299. // _queryCreateViewNode: function(){
  300. //
  301. // },
  302. // _postCreateViewNode: function( viewNode ){
  303. //
  304. // },
  305. // _queryCreateViewHead:function(){
  306. //
  307. // },
  308. // _postCreateViewHead: function( headNode ){
  309. //
  310. // }
  311. //
  312. //});
  313. //
  314. //MWF.xApplication.CRM.Publicseas.Document = new Class({
  315. // Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  316. //
  317. // "viewActionReturn":function(){
  318. // return false
  319. // }
  320. //
  321. //});