WorkStat.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. MWF.xApplication.Execution = MWF.xApplication.Execution || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.require("MWF.widget.Identity", null,false);
  4. MWF.xApplication.Execution.WorkStat = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default"
  9. },
  10. initialize: function (node, app, actions, options) {
  11. this.app = app;
  12. this.lp = app.lp.workStat;
  13. this.path = "/x_component_Execution/$WorkStat/";
  14. this.actions = actions;
  15. this.options.style = this.getViewStyle();
  16. this.setOptions(options);
  17. this.loadCss();
  18. this.node = $(node);
  19. },
  20. loadCss: function () {
  21. this.cssPath = "/x_component_Execution/$WorkStat/" + this.options.style + "/css.wcss";
  22. this._loadCss();
  23. },
  24. load: function () {
  25. this.middleContent = this.app.middleContent;
  26. //this.middleContent.setStyles({"margin-top":"0px","border":"0px solid #f00"});
  27. this.createNaviContent();
  28. //this.createContentDiv();
  29. this.resizeWindow();
  30. this.app.addEvent("resize", function(){
  31. this.resizeWindow();
  32. }.bind(this));
  33. },
  34. resizeWindow: function(){
  35. var size = this.app.middleContent.getSize();
  36. this.naviDiv.setStyles({"height":(size.y-40)+"px"});
  37. this.naviContentDiv.setStyles({"height":(size.y-180)+"px"});
  38. this.contentDiv.setStyles({"height":(size.y-60)+"px"});
  39. if(this.deptStatContent){
  40. this.deptStatContent.setStyles({"height":(size.y-130)+"px"})
  41. }
  42. if(this.statViewListDiv){
  43. var y = this.contentDiv.getSize().y - this.dateToolbar.getSize().y - this.dateStatListDiv.getSize().y
  44. this.statViewListDiv.setStyles({"height":(y-40)+"px"})
  45. }
  46. },
  47. createNaviContent: function(){
  48. this.naviDiv = new Element("div.naviDiv",{
  49. "styles":this.css.naviDiv
  50. }).inject(this.middleContent);
  51. this.naviTitleDiv = new Element("div.naviTitleDiv",{
  52. "styles":this.css.naviTitleDiv,
  53. "text": this.lp.minderExplorerTitle
  54. }).inject(this.naviDiv);
  55. this.naviContentDiv = new Element("div.naviContentDiv",{"styles":this.css.naviContentDiv}).inject(this.naviDiv);
  56. this.naviBottomDiv = new Element("div.naviBottomDiv",{"styles":this.css.naviBottomDiv}).inject(this.naviDiv);
  57. this.createContentDiv();
  58. var jsonUrl = this.path+"navi.json";
  59. MWF.getJSON(jsonUrl, function(json){
  60. json.each(function(data, i){
  61. var naviContentLi = new Element("li.naviContentLi",{"styles":this.css.naviContentLi}).inject(this.naviContentDiv);
  62. naviContentLi.addEvents({
  63. "mouseover" : function(ev){
  64. if(this.bindObj.currentNaviItem != this.node)this.node.setStyles( this.styles )
  65. }.bind({"styles": this.css.naviContentLi_over, "node":naviContentLi, "bindObj": this }) ,
  66. "mouseout" : function(ev){
  67. if(this.bindObj.currentNaviItem != this.node)this.node.setStyles( this.styles )
  68. }.bind({"styles": this.css.naviContentLi, "node":naviContentLi, "bindObj": this }) ,
  69. "click" : function(ev){
  70. if( this.bindObj.currentNaviItem )this.bindObj.currentNaviItem.setStyles( this.bindObj.css.naviContentLi );
  71. this.node.setStyles( this.styles );
  72. this.bindObj.currentNaviItem = this.node;
  73. if( this.action && this.bindObj[this.action] ){
  74. this.bindObj[this.action]();
  75. }
  76. }.bind({"styles": this.css.naviContentLi_current, "node":naviContentLi, "bindObj": this, "action" : data.action }) ,
  77. })
  78. var naviContentImg = new Element("img.naviContentImg",{
  79. "styles":this.css.naviContentImg,
  80. "src":this.path+"default/icon/"+data.icon
  81. }).inject(naviContentLi);
  82. var naviContentSpan = new Element("span.naviContentSpan",{
  83. "styles":this.css.naviContentSpan,
  84. "text":data.title
  85. }).inject(naviContentLi);
  86. if( i == 0 ){
  87. naviContentLi.click();
  88. }
  89. }.bind(this));
  90. }.bind(this));
  91. },
  92. createContentDiv: function(){
  93. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.middleContent);
  94. },
  95. //*************************中心工作开始**************************************
  96. openCenterWork: function(){
  97. this.contentDiv.empty();
  98. this.loadCategoryBar();
  99. this.loadToolbar();
  100. //this.loadView();
  101. },
  102. loadCategoryBar : function(){
  103. var _self = this;
  104. this.categoryBar = new Element("div.categoryBar",{"styles":this.css.categoryBar}).inject(this.contentDiv);
  105. this.allCategoryNode = new Element("li.allCategoryNode", {
  106. "styles": this.css.categoryNode,
  107. "text" : this.lp.category.all
  108. }).inject(this.categoryBar)
  109. this.allCategoryNode.addEvents({
  110. "mouseover" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode_over) }.bind(this),
  111. "mouseout" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode) }.bind(this),
  112. "click":function(){
  113. if( this.currentCategoryNode )this.currentCategoryNode.setStyles(this.css.categoryNode);
  114. this.currentCategoryNode = this.allCategoryNode;
  115. this.allCategoryNode.setStyles(this.css.categoryNode_current);
  116. this.loadView( )
  117. }.bind(this)
  118. })
  119. this.actions.getCategoryCountAll( function( json ){
  120. json.data.each( function( d ){
  121. var categoryNode = new Element("li.categoryNode", {
  122. "styles": this.css.categoryNode,
  123. "text" : d.workTypeName + "(" + d.centerCount +")"
  124. }).inject(this.categoryBar);
  125. categoryNode.store( "workTypeName" , d.workTypeName );
  126. categoryNode.addEvents({
  127. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode_over) }.bind({node : categoryNode }),
  128. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode) }.bind({node : categoryNode }),
  129. "click":function(){
  130. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.categoryNode);
  131. _self.currentCategoryNode = this.node;
  132. this.node.setStyles(_self.css.categoryNode_current);
  133. _self.loadView( )
  134. }.bind({ name : d.workTypeName, node : categoryNode })
  135. })
  136. }.bind(this))
  137. }.bind(this), null, false
  138. )
  139. this.allCategoryNode.click();
  140. },
  141. loadToolbar: function(){
  142. this.toolbar = new Element("div.toolbar",{
  143. styles : this.css.toolbar
  144. }).inject(this.categoryBar)
  145. //this.toolbarTextNode = new Element("div",{
  146. // styles : this.css.toolbarTextNode,
  147. // text: this.lp.workTask.centerWork,
  148. //}).inject(this.toolbar);
  149. this.fileterNode = new Element("div.fileterNode",{
  150. styles : this.css.fileterNode
  151. }).inject(this.toolbar);
  152. this.loadFilter();
  153. },
  154. loadFilter: function () {
  155. var _self = this;
  156. var html = "<table bordr='0' cellpadding='5' cellspacing='0' styles='filterTable'>" +
  157. "<tr>" +
  158. //" <td styles='filterTableTitle' lable='year'></td>" +
  159. //" <td styles='filterTableValue' item='year'></td>" +
  160. //" <td styles='filterTableTitle' lable='workLevel'></td>" +
  161. //" <td styles='filterTableValue' item='workLevel'></td>" +
  162. //" <td styles='filterTableTitle' lable='workType'></td>" +
  163. //" <td styles='filterTableValue' item='workType'></td>" +
  164. //" <td styles='filterTableTitle' lable='star'></td>" +
  165. //" <td styles='filterTableValue' item='star'></td>" +
  166. " <td styles='filterTableValue' item='title'></td>" +
  167. " <td styles='filterTableValue' item='searchAction'></td>" +
  168. " <td styles='filterTableValue' item='returnAction' style='display:none;'></td>" +
  169. "</tr>" +
  170. "</table>"
  171. this.fileterNode.set("html", html);
  172. MWF.xDesktop.requireApp("Template", "MForm", function () {
  173. this.filter = new MForm(this.fileterNode, {}, {
  174. style: "execution",
  175. isEdited: true,
  176. itemTemplate: {
  177. //year: {
  178. // "text": this.lp.yearCount +":", "type": "select", "className": "inputSelectUnformatWidth",
  179. // "selectValue": function () {
  180. // var years = [], year = new Date().getFullYear();
  181. // for (var i = 0; i < 6; i++) years.push(year--);
  182. // return years;
  183. // }
  184. //},
  185. //workLevel: {
  186. // "text": this.lp.level +":", "type": "select","className": "inputSelectUnformatWidth",
  187. // "selectValue": this.lp.workForm.workLevelValue.split(",")
  188. //},
  189. //workType: {
  190. // "text": this.lp.type +":","type": "select","className": "inputSelectUnformatWidth",
  191. // "selectValue": this.lp.workForm.workTypeValue.split(",")
  192. //},
  193. //star: {"text": this.lp.starWork +":", "type": "select", "className": "inputSelectUnformatWidth", "selectValue": this.lp.starWorkText.split(",")},
  194. title: { "style":this.css.filterTitle , defaultValue : this.lp.searchText, "event" : {
  195. focus : function( item ){ if(item.get("value")==_self.lp.searchText)item.setValue("") },
  196. blur : function( item ){ if(item.get("value").trim()=="")item.setValue(_self.lp.searchText) },
  197. keydown: function( item, ev){
  198. if (ev.code == 13){ //回车,搜索
  199. _self.fileterNode.getElements("[item='returnAction']").setStyle("display","");
  200. _self.loadView( );
  201. }
  202. }.bind(this)
  203. }},
  204. searchAction: {
  205. "type": "button", "value": this.lp.search, "style": this.css.filterButton,
  206. "event": {
  207. "click": function () {
  208. _self.fileterNode.getElements("[item='returnAction']").setStyle("display","");
  209. _self.loadView( );
  210. }
  211. }
  212. },
  213. returnAction : {
  214. "type": "button", "value": this.lp.return, "style": this.css.filterButton,
  215. "event": {
  216. "click": function () {
  217. _self.filter.getItem("title").setValue( _self.lp.searchText );
  218. _self.fileterNode.getElements("[item='returnAction']").setStyle("display","none");
  219. _self.loadView();
  220. }
  221. }
  222. }
  223. }
  224. }, this.app, this.css);
  225. this.filter.load();
  226. }.bind(this), true);
  227. },
  228. loadView : function( ){
  229. var filterData = {};
  230. if( this.currentCategoryNode ){
  231. var value = this.currentCategoryNode.retrieve("workTypeName");
  232. if( value && value != "" ){
  233. filterData.defaultWorkTypes = [value];
  234. }
  235. }
  236. if( this.filter ){
  237. var fd = this.filter.getResult(true, ",", true, true, true);
  238. fd.title = fd.title.replace(this.lp.searchText,"");
  239. for( var key in fd ){
  240. if( fd[key] != "" ){
  241. filterData[key] = fd[key];
  242. }
  243. }
  244. }
  245. var flag = false;
  246. if( this.viewContainer ){
  247. flag = true;
  248. this.viewContainer.destroy();
  249. }
  250. this.viewContainer = Element("div",{
  251. "styles" : this.css.viewContainer
  252. }).inject(this.contentDiv);
  253. this.setViewSize();
  254. if( !flag ){
  255. this.setViewSizeFun = this.setViewSize.bind(this);
  256. this.app.addEvent("resize", this.setViewSizeFun );
  257. }
  258. if( this.view ){
  259. this.view.destroy();
  260. }
  261. this.getViewStyle();
  262. this.view = new MWF.xApplication.Execution.WorkStat.WorkView( this.viewContainer, this.app, this, {
  263. //templateUrl : this.path+ ( this.getViewStyle() == "default" ? "listItem.json" : "listItem_graph.json" ),
  264. templateUrl : this.path + "listItem_stat.json",
  265. "scrollEnable" : true
  266. }, {
  267. lp : this.lp.centerWorkView
  268. })
  269. if( filterData )this.view.filterData = filterData;
  270. this.view.load();
  271. },
  272. getViewStyle : function(){
  273. if( this.viewStyle ) return this.viewStyle;
  274. this.actions.getProfileByCode( { "configCode" : "MIND_LISTSTYLE"} ,function( json ){
  275. if( json.data ){
  276. this.viewStyle = ( json.data.configValue == "ICON" ? "graph" : "default");
  277. }else{
  278. this.viewStyle = "default";
  279. }
  280. }.bind(this), function(){
  281. this.viewStyle = "default";
  282. }.bind(this), false );
  283. return this.viewStyle || "default";
  284. },
  285. setViewSize: function(){
  286. var size = this.app.middleContent.getSize();
  287. var categoryBarSzie = this.categoryBar ? this.categoryBar.getSize() : {x:0, y:0};
  288. this.viewContainer.setStyles({"height":(size.y - categoryBarSzie.y - 56 )+"px"});
  289. },
  290. //*************************中心工作结束**************************************
  291. //*************************按部门统计开始**************************************
  292. statDepartment:function(){
  293. this.contentDiv.empty();
  294. this.deptToolbar = new Element("div.deptToolbar",{
  295. styles : this.css.deptToolbar
  296. }).inject(this.contentDiv)
  297. this.deptFileterNode = new Element("div.deptFileterNode",{
  298. styles : this.css.fileterNode
  299. }).inject(this.deptToolbar);
  300. this.loadDeptFilter();
  301. },
  302. loadDeptFilter: function () {
  303. var _self = this;
  304. _self.nowDate = new Date();
  305. _self.day = new Date(_self.nowDate.getFullYear(),(_self.nowDate.getMonth()+1),0);
  306. var html = "<table bordr='0' cellpadding='5' cellspacing='0' styles='filterTable'>" +
  307. "<tr>" +
  308. " <td styles='filterTableValue' item='beginDate'></td>" +
  309. " <td styles='filterTableValue' item='endDate'></td>" +
  310. " <td styles='filterTableValue' item='reportCycle'></td>" +
  311. " <td styles='filterTableValue' item='searchAction'></td>" +
  312. " <td styles='filterTableValue' item='returnAction' style='display:none;'></td>" +
  313. "</tr>" +
  314. "</table>"
  315. this.deptFileterNode.set("html", html);
  316. MWF.xDesktop.requireApp("Template", "MForm", function () {
  317. this.deptFilter = new MForm(this.deptFileterNode, {}, {
  318. style: "execution",
  319. isEdited: true,
  320. onPostLoad: function(){
  321. _self.loadDeptStat()
  322. }.bind(this),
  323. itemTemplate: {
  324. beginDate:{
  325. "style":this.css.filterTitle,
  326. tType:"date",
  327. name:"beginDate",
  328. readonly:true,
  329. notEmpty:true,
  330. defaultValue : _self.nowDate.getFullYear()+"-"+(_self.nowDate.getMonth()+1)+"-01",
  331. "event":{
  332. focus : function( item ){ if(item.get("value")==_self.lp.deptStat.beginDate)item.setValue("") },
  333. blur : function( item ){ if(item.get("value").trim()=="")item.setValue(_self.lp.deptStat.beginDate) },
  334. }
  335. },
  336. endDate:{
  337. "style":this.css.filterTitle,
  338. tType:"date",
  339. name:"endDate",
  340. readonly:true,
  341. notEmpty:true,
  342. defaultValue : _self.nowDate.getFullYear()+"-"+(_self.nowDate.getMonth()+1)+"-"+_self.day.getDate(),
  343. "event":{
  344. focus : function( item ){ if(item.get("value")==_self.lp.deptStat.endDate)item.setValue("") },
  345. blur : function( item ){ if(item.get("value").trim()=="")item.setValue(_self.lp.deptStat.endDate) },
  346. }
  347. },
  348. reportCycle: {
  349. text: this.lp.reportCycle + ":",
  350. type: "radio",
  351. notEmpty:true,
  352. //selectValue: lp.reportCycleValue.split(","),
  353. selectText: this.lp.reportCycleText.split(","),
  354. defaultValue: this.lp.reportCycleText.split(",")[0],
  355. event: {
  356. }
  357. },
  358. searchAction: {
  359. "type": "button", "value": this.lp.search, "style": this.css.filterButton,
  360. "event": {
  361. "click": function () {
  362. //_self.deptFileterNode.getElements("[item='returnAction']").setStyle("display","");
  363. _self.loadDeptStat()
  364. }
  365. }
  366. },
  367. returnAction : {
  368. "type": "button", "value": this.lp.return, "style": this.css.filterButton,
  369. "event": {
  370. "click": function () {
  371. _self.deptFilter.getItem("beginDate").setValue( _self.lp.deptStat.beginDate );
  372. _self.deptFilter.getItem("endDate").setValue( _self.lp.deptStat.endDate );
  373. _self.deptFileterNode.getElements("[item='returnAction']").setStyle("display","none");
  374. }
  375. }
  376. }
  377. }
  378. }, this.app, this.css);
  379. this.deptFilter.load();
  380. }.bind(this), true);
  381. },
  382. loadDeptStat:function(){
  383. if(this.deptStatContent){
  384. this.deptStatContent.set("text","loading...");
  385. this.deptStatContent.setStyles({"padding-left":"20px"})
  386. }
  387. this.bDate = this.deptFilter.getItem("beginDate").get("value");
  388. this.eDate = this.deptFilter.getItem("endDate").get("value");
  389. this.cycleType = this.deptFilter.getItem("reportCycle").get("value");
  390. if(this.bDate == "" || this.bDate == this.lp.deptStat.beginDate || this.eDate == "" || this.eDate == this.lp.deptStat.endDate){
  391. //this.app.notice("选择日期","error")
  392. }
  393. var filterData = {
  394. "cycleType":this.cycleType,
  395. "startDate":this.bDate,
  396. "endDate":this.eDate
  397. }
  398. this.actions.getStatType(filterData,function(json){
  399. if(json.type == "success"){
  400. this.deptStatData = json.data
  401. this.displayDeptStat();
  402. var y = this.contentDiv.getSize().y - this.deptToolbar.getSize().y
  403. this.deptStatContent.setStyles({"height":(y-20)+"px"})
  404. }
  405. }.bind(this),
  406. function(xhr,text,error){
  407. this.showErrorMessage(xhr,text,error)
  408. }.bind(this),true
  409. )
  410. },
  411. displayDeptStat: function() {
  412. if(this.deptStatContent) this.deptStatContent.destroy();
  413. this.deptStatContent = new Element("div.deptStatContent", {styles: this.css.deptStatContent}).inject(this.contentDiv);
  414. if(this.deptStatData){
  415. this.deptStatInfo = new Element("div.deptStatInfo",{
  416. "styles": this.css.deptStatInfo
  417. }).inject(this.deptStatContent)
  418. var htmlstr = "<span >已汇报:</span> <img src='"+this.path+"default/icon/Checkmark-24.png' style='vertical-align:middle;margin-right:20px; width:20px;' />";
  419. htmlstr += "<span>不需要汇报: </span><img src='"+this.path+"default/icon/Circle24.png' style='vertical-align:middle;margin-right:20px;width:20px;' />";
  420. htmlstr += "<span>未汇报:</span> <img src='"+this.path+"default/icon/Delete-24.png' style='vertical-align:middle;margin-right:20px;width:20px;' />";
  421. this.deptStatInfo.set("html",htmlstr);
  422. this.deptStatText = new Element("div.deptStatText",{"styles":this.css.deptStatText}).inject(this.deptStatInfo)
  423. this.deptStatText.set("html","统计类别: "+this.cycleType+" 统计周期: "+this.bDate+" --- " + this.eDate)
  424. if(this.deptStatData.header) cols = this.deptStatData.header.length
  425. this.deptStatTable = new Element("table.deptStatTable",{styles:this.css.deptStatTable}).inject(this.deptStatContent)
  426. this.deptStatHeadTr = new Element("tr.deptStatHeadTr",{styles:this.css.deptStatHeadTr}).inject(this.deptStatTable);
  427. this.deptStatData.header.each(function(d,i){
  428. this.tmpTd = new Element("td.deptStatTh",{
  429. "styles":this.css.deptStatTh,
  430. "text": d.title
  431. }).inject(this.deptStatHeadTr)
  432. if(i==0){
  433. this.tmpTd.setStyles({"width":"100px"})
  434. }else if(i==1 || i == 2){
  435. this.tmpTd.setStyles({
  436. "width":"300px",
  437. "height":"auto",
  438. "max-height":"50px",
  439. "overflow-y":"hidden"
  440. })
  441. }else{
  442. var bd = d.startDate;
  443. var ed = d.endDate;
  444. tmpstr = bd.split("-")[1]+"."+bd.split("-")[2]+"-" + ed.split("-")[1]+"."+ed.split("-")[2]
  445. this.tmpTd.set("text",tmpstr)
  446. }
  447. }.bind(this))
  448. this.deptStatTable.setStyles({"width":(cols * 50 + 680)+"px"})
  449. if(this.deptStatData.content){
  450. var curRow = 0;
  451. var rows1 = this.deptStatData.content.length; //多少部门
  452. this.deptStatData.content.each(function(d,i){
  453. if(d.array){
  454. var rows2 = d.array.length; //多少中心工作
  455. var rowsWork2 = d.rowCount;
  456. d.array.each(function(dd,ii){
  457. var rows3 = dd.array.length; //多少工作
  458. var rowsWork3 = dd.rowCount;
  459. if(dd.array){
  460. var _self = this
  461. dd.array.each(function(ddd,iii){
  462. _self.tmpTr = new Element("tr.deptStatTr",{styles:_self.css.deptStatTr}).inject(_self.deptStatTable);
  463. curRow ++
  464. if(iii==0){
  465. if(ii==0){
  466. _self.tmpTd = new Element("td.deptStatTd",{
  467. "styles":_self.css.deptStatTd,
  468. "rowspan": rowsWork2,
  469. "text": d.title
  470. }).inject(_self.tmpTr)
  471. _self.tmpTd.setStyles({"text-align":"center"})
  472. _self.tmpTd = new Element("td.deptStatTd",{
  473. "styles":_self.css.deptStatTd,
  474. "rowspan": rowsWork3,
  475. "text": dd.title
  476. }).inject(_self.tmpTr)
  477. }else{
  478. _self.tmpTd = new Element("td.deptStatTd",{
  479. "styles":_self.css.deptStatTd,
  480. "rowspan": rowsWork3,
  481. "text": dd.title
  482. }).inject(_self.tmpTr)
  483. }
  484. }
  485. _self.tmpTd = new Element("td.deptStatTd",{
  486. "styles":_self.css.deptStatTd,
  487. "text": ddd.title,
  488. "col":1,
  489. "row":curRow
  490. }).inject(_self.tmpTr)
  491. _self.tmpTd.setStyles({"cursor":"pointer","text-decoration":"underline"});
  492. _self.tmpTd.addEvents({
  493. "click":function(){
  494. MWF.xDesktop.requireApp("Execution", "WorkDetail", function(){
  495. var workform = new MWF.xApplication.Execution.WorkDetail(_self, _self.app.restActions,{id:ddd.id},{
  496. "isNew": false,
  497. "isEdited": false,
  498. "tabLocation":_self.category
  499. });
  500. workform.load();
  501. }.bind(_self));
  502. }.bind(_self),
  503. "mouseenter":function(e){
  504. _self.overStyles(e)
  505. }.bind(_self),
  506. "mouseleave":function(e){
  507. _self.outStyles(e)
  508. }.bind(_self)
  509. })
  510. if(ddd.fields){
  511. ddd.fields.each(function(dddd,iiii){
  512. _self.tmpTd = new Element("td.deptStatTd",{
  513. "styles":_self.css.deptStatTdStatus,
  514. "row":curRow,
  515. "col":iiii+2
  516. }).inject(_self.tmpTr);
  517. _self.tmpTd.addEvents({
  518. "mouseenter":function(e){
  519. _self.overStyles(e)
  520. }.bind(_self),
  521. "mouseleave":function(e){
  522. _self.outStyles(e)
  523. }.bind(_self)
  524. })
  525. var imgName = "";
  526. if(dddd.reportStatus == -1){
  527. imgName = "Circle24.png"
  528. }else if(dddd.reportStatus == 0){
  529. imgName = "Delete-24.png"
  530. }else if(dddd.reportStatus == 1){
  531. imgName = "Checkmark-24.png"
  532. }
  533. _self.deptStatStatusSpan = new Element("span.deptStatStatusSpan",{
  534. "styles":this.css.deptStatStatusSpan
  535. }).inject(_self.tmpTd)
  536. _self.deptStatStatusSpan.setStyles({
  537. "background":"url('"+_self.path+"default/icon/"+imgName+"')"
  538. })
  539. }.bind(_self))
  540. }
  541. }.bind(_self))
  542. }
  543. }.bind(this))
  544. }
  545. }.bind(this))
  546. }
  547. }
  548. },
  549. overStyles:function(e){
  550. var curRow = $(e.target).get("row");
  551. var curCol = $(e.target).get("col");
  552. //this.deptStatTable.getElements("[row='"+curRow+"']").setStyles({"border":"1px solid #cccccc","background-color":"#cccccc"})
  553. //this.deptStatTable.getElements("[col='"+curCol+"']").setStyles({"border":"1px solid #cccccc","background-color":"#cccccc"})
  554. //this.deptStatTable.getElements("[row='"+curRow+"']").setStyles({"background-color":"#ff0"})
  555. //this.deptStatTable.getElements("[col='"+curCol+"']").setStyles({"background-color":"#ff0"})
  556. },
  557. outStyles:function(e){
  558. var curRow = $(e.target).get("row");
  559. var curCol = $(e.target).get("col");
  560. //this.deptStatTable.getElements("[row='"+curRow+"']").setStyles({"border":"1px solid #000","background-color":""})
  561. //this.deptStatTable.getElements("[col='"+curCol+"']").setStyles({"border":"1px solid #000","background-color":""})
  562. //this.deptStatTable.getElements("[row='"+curRow+"']").setStyles({"background-color":""})
  563. //this.deptStatTable.getElements("[col='"+curCol+"']").setStyles({"background-color":""})
  564. },
  565. //*************************按部门统计结束**************************************
  566. //*************************按日期统计开始**************************************
  567. statDate:function(){
  568. this.contentDiv.empty();
  569. this.dateToolbar = new Element("div.dateToolbar",{
  570. styles : this.css.dateToolbar
  571. }).inject(this.contentDiv)
  572. this.dateFileterNode = new Element("div.dateFileterNode",{
  573. styles : this.css.fileterNode
  574. }).inject(this.dateToolbar);
  575. this.loadDateFilter();
  576. },
  577. loadDateFilter: function () {
  578. var _self = this;
  579. _self.nowDate = new Date();
  580. _self.day = new Date(_self.nowDate.getFullYear(),(_self.nowDate.getMonth()+1),0);
  581. var html = "<table bordr='0' cellpadding='5' cellspacing='0' styles='filterTable'>" +
  582. "<tr>" +
  583. " <td styles='filterTableValue' item='beginDate'></td>" +
  584. " <td styles='filterTableValue' item='endDate'></td>" +
  585. " <td styles='filterTableValue' item='reportCycle'></td>" +
  586. " <td styles='filterTableValue' item='searchAction'></td>" +
  587. " <td styles='filterTableValue' item='returnAction' style='display:none;'></td>" +
  588. " <td styles='filterTableValue' item='exportAction'></td>" +
  589. "</tr>" +
  590. "</table>"
  591. this.dateFileterNode.set("html", html);
  592. MWF.xDesktop.requireApp("Template", "MForm", function () {
  593. this.dateFilter = new MForm(this.dateFileterNode, {}, {
  594. style: "execution",
  595. isEdited: true,
  596. onPostLoad: function(){
  597. _self.loadDateStat()
  598. }.bind(this),
  599. itemTemplate: {
  600. beginDate:{
  601. "style":this.css.filterTitle,
  602. tType:"date",
  603. name:"beginDate",
  604. readonly:true,
  605. notEmpty:true,
  606. defaultValue : _self.nowDate.getFullYear()+"-"+(_self.nowDate.getMonth()+1)+"-01",
  607. "event":{
  608. focus : function( item ){ if(item.get("value")==_self.lp.dateStat.beginDate)item.setValue("") },
  609. blur : function( item ){ if(item.get("value").trim()=="")item.setValue(_self.lp.dateStat.beginDate) },
  610. }
  611. },
  612. endDate:{
  613. "style":this.css.filterTitle,
  614. tType:"date",
  615. name:"endDate",
  616. readonly:true,
  617. notEmpty:true,
  618. defaultValue : _self.nowDate.getFullYear()+"-"+(_self.nowDate.getMonth()+1)+"-"+_self.day.getDate(),
  619. "event":{
  620. focus : function( item ){ if(item.get("value")==_self.lp.dateStat.endDate)item.setValue("") },
  621. blur : function( item ){ if(item.get("value").trim()=="")item.setValue(_self.lp.dateStat.endDate) },
  622. }
  623. },
  624. reportCycle: {
  625. text: this.lp.reportCycle + ":",
  626. type: "radio",
  627. notEmpty:true,
  628. //selectValue: lp.reportCycleValue.split(","),
  629. selectText: this.lp.reportCycleText.split(","),
  630. defaultValue: this.lp.reportCycleText.split(",")[0],
  631. event: {
  632. }
  633. },
  634. searchAction: {
  635. "type": "button", "value": this.lp.search, "style": this.css.filterButton,
  636. "event": {
  637. "click": function () {
  638. //_self.deptFileterNode.getElements("[item='returnAction']").setStyle("display","");
  639. _self.loadDateStat()
  640. }
  641. }
  642. },
  643. returnAction : {
  644. "type": "button", "value": this.lp.return, "style": this.css.filterButton,
  645. "event": {
  646. "click": function () {
  647. _self.dateFilter.getItem("beginDate").setValue( _self.lp.dateStat.beginDate );
  648. _self.dateFilter.getItem("endDate").setValue( _self.lp.dateStat.endDate );
  649. _self.dateFileterNode.getElements("[item='returnAction']").setStyle("display","none");
  650. }
  651. }
  652. },
  653. exportAction : {
  654. "type": "button", "value": this.lp.export, "style": this.css.filterButton,
  655. "event": {
  656. "click": function () {
  657. _self.exportDateExcel()
  658. }
  659. }
  660. }
  661. }
  662. }, this.app, this.css);
  663. this.dateFilter.load();
  664. }.bind(this), true);
  665. },
  666. loadDateStat:function(){
  667. this.bDate = this.dateFilter.getItem("beginDate").get("value");
  668. this.eDate = this.dateFilter.getItem("endDate").get("value");
  669. this.cycleType = this.dateFilter.getItem("reportCycle").get("value");
  670. if(this.bDate == "" || this.bDate == this.lp.dateStat.beginDate || this.eDate == "" || this.eDate == this.lp.dateStat.endDate){
  671. //this.app.notice("选择日期","error")
  672. }
  673. if(this.dateStatListDiv) this.dateStatListDiv.destroy()
  674. if(this.statViewListDiv) this.statViewListDiv.destroy()
  675. var filterData = {
  676. "reportCycle":this.cycleType,
  677. "startDate":this.bDate,
  678. "endDate":this.eDate
  679. }
  680. this.actions.getStatDateList(filterData,function(json){
  681. if(json.type == "success"){
  682. this.dateStatListData = json.data
  683. this.displayDateStatList();
  684. }
  685. }.bind(this),
  686. function(xhr,text,error){
  687. this.showErrorMessage(xhr,text,error)
  688. }.bind(this),true
  689. )
  690. },
  691. displayDateStatList: function() {
  692. if(this.dateStatListDiv) this.dateStatListDiv.destroy();
  693. if(this.statViewListDiv) this.statViewListDiv.destroy()
  694. this.dateStatListDiv = new Element("div.dateStatListDiv", {
  695. "styles": this.css.dateStatListDiv
  696. }).inject(this.contentDiv);
  697. var dateStatListTitleDiv = new Element("div.dateStatListTitleDiv", {
  698. "styles": this.css.dateStatListTitleDiv,
  699. "text": this.lp.dateStatListTitle
  700. }).inject(this.dateStatListDiv);
  701. this.dateStatContentDiv = new Element("div.dateStatContentDiv", {
  702. "styles": this.css.dateStatContentDiv
  703. }).inject(this.dateStatListDiv);
  704. this.loadDateStatList();
  705. },
  706. loadDateStatList: function(){
  707. if(this.dateStatListData){
  708. this.dateStatListData.each(function(d,i){
  709. var tmpLi = new Element("li.dateStatContentLi",{
  710. "styles": this.css.dateStatContentLi,
  711. "text": d.datetime,
  712. "title": d.reportCycle
  713. }).inject(this.dateStatContentDiv)
  714. tmpLi.addEvents({
  715. "click":function(){
  716. this.dateStatContentDiv.getElements("li").setStyles({"background-color":"","color":""})
  717. tmpLi.setStyles({"background-color":"#3c76c1","color":"#ffffff"});
  718. this.currentDateData = d
  719. this.displayDateStat(d)
  720. }.bind(this)
  721. })
  722. }.bind(this))
  723. if(this.dateStatContentDiv.getElements("li"))this.dateStatContentDiv.getElements("li")[0].click()
  724. }
  725. },
  726. displayDateStat: function(d,id){
  727. if(this.statViewListDiv){
  728. this.statViewListDiv.empty()
  729. this.statViewListDiv.set("text","loading...");
  730. this.statViewListDiv.setStyles({"padding-left":"15px"})
  731. }
  732. if(d){
  733. var filterData = {
  734. "statisticTimeFlag": d.datetime,
  735. "reportCycle": d.reportCycle
  736. }
  737. if(id){
  738. filterData.centerId = id
  739. }
  740. this.actions.getStatDate(filterData,function(json){
  741. if(json.type == "success"){
  742. this.dateStatData = json.data
  743. this.displayDateStatTable()
  744. }
  745. }.bind(this),
  746. function(xhr,text,error){
  747. this.showErrorMessage(xhr,text,error)
  748. }.bind(this),true
  749. )
  750. }
  751. },
  752. displayDateStatTable:function(){
  753. if(this.statViewListDiv) this.statViewListDiv.empty()
  754. if(this.dateStatData){
  755. if(this.statViewListDiv) this.statViewListDiv.destroy()
  756. this.statViewListDiv = new Element("div.statViewListDiv", {
  757. "styles": this.css.statViewListDiv
  758. }).inject(this.contentDiv);
  759. var y = this.contentDiv.getSize().y - this.dateToolbar.getSize().y - this.dateStatListDiv.getSize().y
  760. this.statViewListDiv.setStyles({"height":(y-50)+"px"})
  761. this.statTable = new Element("table.statTable",{
  762. "styles":this.css.statTable
  763. }).inject(this.statViewListDiv)
  764. //this.statTable.set("border","1")
  765. this.statHeadTr = new Element("tr.statHeadTr",{
  766. "styles":this.css.statHeadTr
  767. }).inject(this.statTable);
  768. for(var o in this.lp.statTable){
  769. var statHeadTd = new Element("td.statHeadTd",{
  770. "styles": this.css.statHeadTd,
  771. "text":this.lp.statTable[o]
  772. }).inject(this.statHeadTr);
  773. }
  774. this.dateStatData.each(function(d,i){
  775. var centerTr = new Element("tr.centerTr").inject(this.statTable)
  776. var centerTd = new Element("td.dateStatCenterTd",{
  777. "styles": this.css.dateStatCenterTd,
  778. "colspan": 9,
  779. "text": d.title
  780. }).inject(centerTr)
  781. if(d.contents && d.contents.length>0){
  782. d.contents.each(function(dd,ii){
  783. var baseTr = new Element("tr.baseTr").inject(this.statTable)
  784. //var baseTd = new Element("td.dateStatBaseTd",{"styles":this.css.dateStatBaseTd,"text":(ii+1),"id":dd.workId}).inject(baseTr)
  785. //baseTd.setStyles({"width":"35px","text-align":"center"})
  786. for(var o in this.lp.statTable){
  787. //if(o!="order"){
  788. var val = "";
  789. if(o=="opinions") {
  790. if(dd[o]){
  791. dd[o].each(function(ddd){
  792. val = val + ddd.processorName + ":\n"+ ddd.opinion +"\n"
  793. })
  794. }
  795. }else{
  796. if(dd[o])val = dd[o]
  797. }
  798. var baseTd = new Element("td.dateStatBaseTd",{
  799. "styles": this.css.dateStatBaseTd,
  800. "html": val.length>50?val.substring(0,50)+"...":val,
  801. "title":val
  802. }).inject(baseTr);
  803. if(o=="serialNumber"){
  804. baseTd.setStyles({"width":"35px","padding-left":"15px","min-width":""})
  805. }
  806. if(o=="responsibilityOrganizationName"){
  807. baseTd.setStyles({"width":"87px"})
  808. }
  809. if(o=="workDetail"){
  810. //baseTd.setStyles({"cursor":"pointer","color":"#3d77c1","text-decoration":"underline"})
  811. //baseTd.addEvents({
  812. // "click":function(){
  813. // this.loadSubStat(id, dd.workId,baseTr);
  814. // //this.actions.getStatByWorkId(id, d.workId,function(json){
  815. // //
  816. // //}.bind(this),function(xhr,text,error){
  817. // // this.showErrorMsg(xhr,text,error)
  818. // //}.bind(this),false)
  819. // }.bind(this)
  820. //})
  821. }
  822. //}
  823. }
  824. }.bind(this))
  825. }
  826. }.bind(this))
  827. }
  828. },
  829. exportDateExcel : function(){
  830. if(this.currentDateData){
  831. var sendData = {}
  832. sendData.statisticTimeFlag = this.currentDateData.datetime;
  833. sendData.reportCycle = this.currentDateData.reportCycle
  834. this.actions.exportByCenterWork(sendData,function(json){
  835. if(json.data && json.data.id){
  836. var address = this.actions.action.address;
  837. var url = address + "/servlet/export/statisticreportcontent/"+json.data.id+"/stream"
  838. window.open(url)
  839. }
  840. }.bind(this),
  841. function(xhr,text,error){
  842. this.showErrorMsg(xhr,text,error)
  843. }.bind(this),false)
  844. }
  845. },
  846. //*************************按日期统计结束**************************************
  847. showErrorMessage:function(xhr,text,error){
  848. var errorText = error;
  849. if (xhr) errorMessage = xhr.responseText;
  850. if(errorMessage!=""){
  851. var e = JSON.parse(errorMessage);
  852. if(e.message){
  853. this.app.notice( e.message,"error");
  854. }else{
  855. this.app.notice( errorText,"error");
  856. }
  857. }else{
  858. this.app.notice(errorText,"error")
  859. }
  860. },
  861. setScrollBar: function(node, style, offset, callback){
  862. if (!style) style = "attachment";
  863. if (!offset){
  864. offset = {
  865. "V": {"x": 0, "y": 0},
  866. "H": {"x": 0, "y": 0}
  867. };
  868. };
  869. MWF.require("MWF.widget.ScrollBar", function(){
  870. new MWF.widget.ScrollBar(node, {
  871. "style": style,
  872. "offset": offset,
  873. "indent": false
  874. });
  875. if (callback) callback();
  876. });
  877. return false;
  878. }
  879. })
  880. MWF.xApplication.Execution.WorkStat.WorkView = new Class({
  881. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  882. _createDocument: function(data){
  883. return new MWF.xApplication.Execution.WorkStat.WorkDocument(this.viewNode, data, this.explorer, this);
  884. },
  885. _getCurrentPageData: function(callback, count){
  886. if (!count)count = 20;
  887. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  888. var filter = this.filterData || {};
  889. this.actions.getCenterWorkListNext(id, count, filter, function (json) {
  890. if (callback)callback(json);
  891. }.bind(this))
  892. },
  893. _removeDocument: function(documentData, all){
  894. //this.actions.deleteSchedule(documentData.id, function(json){
  895. // this.reload();
  896. // this.app.notice(this.app.lp.deleteDocumentOK, "success");
  897. //}.bind(this));
  898. },
  899. _create: function(){
  900. },
  901. _openDocument: function( documentData ){
  902. //var workMinder = new MWF.xApplication.Execution.WorkMinder( this.explorer, documentData, {});
  903. //workMinder.load();
  904. MWF.xDesktop.requireApp("Execution", "StatForm", function(){
  905. var statForm = new MWF.xApplication.Execution.StatForm( this,this.app.restActions, documentData, {
  906. "centerWorkId":documentData.id
  907. });
  908. statForm.load();
  909. }.bind(this),false);
  910. //MWF.xDesktop.requireApp("Execution", "WorkDeploy", function(){
  911. // this.workDeploy = new MWF.xApplication.Execution.WorkDeploy(this, this.actions,{"id":documentData.id},{
  912. // "isEdited":false,
  913. // "centerWorkId":documentData.id
  914. // } );
  915. // this.workDeploy.load();
  916. //
  917. //}.bind(this))
  918. },
  919. _queryCreateViewNode: function(){
  920. },
  921. _postCreateViewNode: function( viewNode ){
  922. },
  923. _queryCreateViewHead:function(){
  924. },
  925. _postCreateViewHead: function( headNode ){
  926. }
  927. })
  928. MWF.xApplication.Execution.WorkStat.WorkDocument = new Class({
  929. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  930. mouseoverDocument : function(){
  931. this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode_over"]);
  932. this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode_over"]);
  933. this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode_over"]);
  934. },
  935. mouseoutDocument : function(){
  936. this.node.getElements("[styles='documentItemTitleNode']").setStyles(this.css["documentItemTitleNode"]);
  937. this.node.getElements("[styles='documentItemIconNode']").setStyles(this.css["documentItemIconNode"]);
  938. this.node.getElements("[styles='documentItemStatNode']").setStyles(this.css["documentItemStatNode"]);
  939. },
  940. _queryCreateDocumentNode:function( itemData ){
  941. },
  942. _postCreateDocumentNode: function( itemNode, itemData ){
  943. },
  944. removeCenterWork : function(itemData){
  945. //如果是管理员有删除部署的中心工作的权限
  946. //if(isAdmin){
  947. // return true;
  948. //}
  949. return false;
  950. }
  951. })