test2.js 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830
  1. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  2. MWF.xDesktop.requireApp("cms.Module", "ExcelForm", null, false);
  3. this.define("dipatchNumberToCity", function(){
  4. var ids = this.getSelectedId();
  5. if( ids.length == 0 ){
  6. this.form.app.notice("先选择号码","error");
  7. return;
  8. }
  9. var units = this.getLevel1Unit();
  10. var unitList = [];
  11. units.each( function( u ){
  12. unitList.push({
  13. name : u.name,
  14. id : u.distinguishedName
  15. })
  16. });
  17. MWF.xDesktop.requireApp("Template", "Selector.Custom", null, false);
  18. var opt = {
  19. "count": 1,
  20. "title": "选择分配的组织",
  21. "selectableItems" : unitList,
  22. "values": [],
  23. "onComplete": function( array ){
  24. if( !array || array.length == 0 )return;
  25. var unit = array[0].data.id;
  26. if( !unit )return;
  27. this.saveDocList( ids, unit, "", "" );
  28. }.bind(this)
  29. };
  30. var selector = new MWF.xApplication.Template.Selector.Custom(this.form.app.content, opt );
  31. selector.load();
  32. }.bind(this));
  33. this.define("dipatchNumberToCounty", function( city, range ){
  34. var ids = this.getSelectedId();
  35. if( ids.length == 0 ){
  36. this.form.app.notice("先选择号码","error");
  37. return;
  38. }
  39. var units = [];
  40. if( city ){
  41. var unit = this.org.listSubUnit( city , false );
  42. unit.each( function( u ){
  43. units.push({
  44. name : u.name,
  45. id : u.distinguishedName
  46. })
  47. });
  48. }
  49. if( city ){
  50. MWF.xDesktop.requireApp("Template", "Selector.Custom", null, false);
  51. var opt = {
  52. "count": 1,
  53. "title": "选择分配的组织",
  54. "selectableItems" : units,
  55. "values": [],
  56. "onComplete": function( array ){
  57. if( !array || array.length == 0 )return;
  58. var unit = array[0].data.id;
  59. this.saveDocList(ids, city, unit, "" )
  60. }.bind(this)
  61. };
  62. var selector = new MWF.xApplication.Template.Selector.Custom(this.form.app.content, opt );
  63. selector.load();
  64. }else{
  65. MWF.xDesktop.requireApp("Selector", "package", null, false);
  66. var opt = {
  67. "count": 1,
  68. "title": "选择分配的组织",
  69. "type" : "unit",
  70. "values": [],
  71. "onComplete": function( array ){
  72. if( !array || array.length == 0 )return;
  73. var unit = array[0].data.distinguishedName;
  74. var levelName = array[0].data.levelName;
  75. if( levelName.split("/").length != 2 ){
  76. this.form.app.notice("请选择县级分公司", "error");
  77. return false;
  78. }
  79. this.getAllUnit();
  80. var c = this.name_dnName[levelName.split("/")[0]];
  81. this.saveDocList(ids, c, unit, "")
  82. }.bind(this)
  83. };
  84. if( range )opt.units = [range];
  85. var selector = new MWF.O2Selector(this.form.app.content, opt );
  86. }
  87. }.bind(this));
  88. this.define("dipatchNumberToBranch", function( county, range ){
  89. var ids = this.getSelectedId();
  90. if( ids.length == 0 ){
  91. this.form.app.notice("先选择号码","error");
  92. return;
  93. }
  94. var units = [];
  95. if( county ){
  96. var unit = this.org.listSubUnit( county , false );
  97. unit.each( function( u ){
  98. units.push({
  99. name : u.name,
  100. id : u.distinguishedName
  101. })
  102. });
  103. }
  104. if( county ){
  105. MWF.xDesktop.requireApp("Template", "Selector.Custom", null, false);
  106. var opt = {
  107. "count": 1,
  108. "title": "选择分配的组织",
  109. "selectableItems" : units,
  110. "values": [],
  111. "onComplete": function( array ){
  112. if( !array || array.length == 0 )return;
  113. var unit = array[0].data.id;
  114. this.getAllUnit();
  115. var levelName = this.dnName_levelName[unit];
  116. if( levelName.split("/").length != 3 ){
  117. this.form.app.notice("请选择网格", "error");
  118. return false;
  119. }
  120. var c = this.name_dnName[levelName.split("/")[0]];
  121. this.saveDocList(ids, c, county, unit )
  122. }.bind(this)
  123. };
  124. var selector = new MWF.xApplication.Template.Selector.Custom(this.form.app.content, opt );
  125. selector.load();
  126. }else{
  127. MWF.xDesktop.requireApp("Selector", "package", null, false);
  128. var opt = {
  129. "count": 1,
  130. "title": "选择分配的组织",
  131. "type" : "unit",
  132. "values": [],
  133. "onComplete": function( array ){
  134. if( !array || array.length == 0 )return;
  135. var unit = array[0].data.distinguishedName;
  136. this.getAllUnit();
  137. var levelName = this.dnName_levelName[unit];
  138. if( levelName.split("/").length != 3 ){
  139. this.form.app.notice("请选择网格", "error");
  140. return false;
  141. }
  142. var city2 = this.name_dnName[levelName.split("/")[0]];
  143. var county2 = this.name_dnName[levelName.split("/")[1]];
  144. this.saveDocList(ids, city2, county2, unit );
  145. }.bind(this)
  146. };
  147. if( range )opt.units = [range];
  148. var selector = new MWF.O2Selector(this.form.app.content, opt );
  149. }
  150. }.bind(this));
  151. this.define("saveDocList", function( ids, city, county, branch ){
  152. ids.each( function(id){
  153. var oldData = this.form.selectedItemJson[id];
  154. var newData = { docStatus : "published", city : city, county : county , branch : branch };
  155. if( !this.form.statJson ){
  156. this.form.statJson = new StatJson(this);
  157. }
  158. this.form.statJson.changeData( newData, oldData, oldData.batch );
  159. this.form.statJson.submit();
  160. }.bind(this));
  161. if( this.form.currentView.docStatus == "error" ){
  162. var changeCount = 0;
  163. ids.each( function( id ){
  164. this.saveDoc( id, city, county, branch, function(){
  165. changeCount++;
  166. if( changeCount == ids.length ){
  167. this.setUploadedUnit( function(){
  168. this.form.app.notice("分配成功","");
  169. this.createImportBatchDiv();
  170. this.loadStatTable( this.statTableOptions ? this.statTableOptions.container : this.form.get("statContaienr").node );
  171. this.form.view.reload();
  172. this.form.view.selectedItems = [];
  173. if( this.form.view_error ){
  174. this.form.view_error.reload();
  175. this.form.view_error.selectedItems = [];
  176. }
  177. }.bind(this));
  178. }
  179. }.bind(this))
  180. }.bind(this))
  181. }else{
  182. this.saveDcc(ids, ["city","county","branch"], [city,county,branch], function(){
  183. this.setUploadedUnit( function(){
  184. this.form.app.notice("分配成功","");
  185. this.createImportBatchDiv();
  186. this.loadStatTable( this.statTableOptions ? this.statTableOptions.container : this.form.get("statContaienr").node );
  187. this.form.currentView.reload();
  188. this.form.currentView.selectedItems = [];
  189. }.bind(this));
  190. }.bind(this))
  191. }
  192. }.bind(this));
  193. this.define("saveDoc", function( id, city, county, branch, callback ){
  194. MWF.Actions.get("x_cms_assemble_control").getDocument(id, function( json ){
  195. var docData = json.data;
  196. docData.data.city = city;
  197. docData.data.county = county;
  198. docData.data.branch = branch;
  199. docData.data.errorText = "";
  200. docData.data.docStatus = "published";
  201. docData.data.status = "成功";
  202. docData.data.title = docData.data.subject;
  203. delete docData.data.$document;
  204. delete docData.document.viewCount;
  205. delete docData.document.publishTime;
  206. delete docData.document.hasIndexPic;
  207. delete docData.document.readPersonList;
  208. delete docData.document.readUnitList;
  209. delete docData.document.readGroupList;
  210. delete docData.document.authorPersonList;
  211. delete docData.document.authorUnitList;
  212. delete docData.document.authorGroupList;
  213. delete docData.document.managerList;
  214. delete docData.document.pictureList;
  215. delete docData.documentLogList;
  216. delete docData.isAppAdmin;
  217. delete docData.isCategoryAdmin;
  218. delete docData.isManager;
  219. delete docData.isCreator;
  220. delete docData.isEditor;
  221. docData.document.docData = docData.data;
  222. delete docData.data;
  223. docData.document.docStatus = "published";
  224. docData.document.subject = docData.document.title;
  225. MWF.Actions.get("x_cms_assemble_control").updateDocument( docData.document , function(){
  226. if( callback )callback();
  227. }.bind(this));
  228. }.bind(this))
  229. }.bind(this));
  230. this.define("dipatchNumber", function(){
  231. // var flag = (this.workContext.getControl().allowSave && this.workContext.getActivity().alias == "draft") ;
  232. // if( !flag ){
  233. // this.form.app.notice( "发起节点才能分配号码","error" );
  234. // return;
  235. // }
  236. var ids = this.getSelectedId();
  237. if( ids.length == 0 ){
  238. this.form.app.notice("先选择号码","error");
  239. return;
  240. }
  241. var units = this.getSubUnit();
  242. if( units ){
  243. MWF.xDesktop.requireApp("Template", "Selector.Custom", null, false);
  244. var opt = {
  245. "count": 1,
  246. "title": "选择分配的组织",
  247. "selectableItems" : units,
  248. "values": [],
  249. "onComplete": function( array ){
  250. if( !array || array.length == 0 )return;
  251. var unit = array[0].data.id;
  252. this.setUnit(ids, unit )
  253. }.bind(this)
  254. };
  255. var selector = new MWF.xApplication.Template.Selector.Custom(this.form.app.content, opt );
  256. selector.load();
  257. }else{
  258. MWF.xDesktop.requireApp("Selector", "package", null, false);
  259. var opt = {
  260. "count": 1,
  261. "title": "选择分配的组织",
  262. "type" : "unit",
  263. "values": [],
  264. "onComplete": function( array ){
  265. if( !array || array.length == 0 )return;
  266. var unit = array[0].data.distinguishedName;
  267. this.setUnit(ids, unit)
  268. }.bind(this)
  269. };
  270. var selector = new MWF.O2Selector(this.form.app.content, opt );
  271. }
  272. });
  273. this.define("getSelectedId", function(){
  274. var ids = [];
  275. if( !this.form.currentView ){
  276. this.form.currentView = this.form.view;
  277. }
  278. this.form.selectedItemJson = {};
  279. this.form.currentView.selectedItems.each( function( item ){
  280. ids.push( item.data.bundle );
  281. this.form.selectedItemJson[ item.data.bundle ] = {
  282. batch : item.data.data.batch,
  283. city : item.data.data.city,
  284. county : item.data.data.county,
  285. branch : item.data.data.branch,
  286. docStatus : this.form.currentView.docStatus || "published"
  287. }
  288. }.bind(this));
  289. return ids;
  290. });
  291. this.define("getSubUnit", function(){
  292. var units = this.data.currentUnit;
  293. if( units ){
  294. var unit = this.org.listSubUnit( units , false );
  295. }else if( !this.data.newFlag ){
  296. var unit = this.getLevel1Unit(); //this.workContext.getWork().creatorUnitLevelName.split("/")[0];
  297. }else{
  298. return null;
  299. }
  300. //unit = unit.split("@")[0];
  301. var array = [];
  302. unit.each( function( u ){
  303. array.push({
  304. name : u.name,
  305. id : u.distinguishedName
  306. })
  307. });
  308. return array;
  309. });
  310. this.define("getLevel1Unit", function( callback){
  311. var array = [];
  312. var action = new this.Action("x_organization_assemble_express", {
  313. "lookup":{"uri": "/jaxrs/unit/list/level/object", "method": "POST"}
  314. });
  315. action.invoke({"name": "lookup","parameter": {}, "data": {"levelList":[ "1" ]}, "success": function(json){
  316. array = json.data;
  317. if(callback)callback(json);
  318. }.bind(this), async : false
  319. });
  320. return array;
  321. }.bind(this));
  322. this.define("setUnit", function(ids, unit){
  323. if( !unit )return;
  324. var flag = this.data.flag || this.data.newFlag;
  325. var f;
  326. if( !flag ){
  327. f = "city"
  328. }else if( flag == "city" ){
  329. f = "county"
  330. }else if( flag == "county" ){
  331. f = "branch"
  332. }
  333. this.saveDcc(ids, f, unit, function(){
  334. var value = this.data[f+"TaskPerson"];
  335. var array = [];
  336. ( value.length ? value : [] ).each( function( v ){
  337. array.push( typeOf( v ) == "string" ? v : v.distinguishedName )
  338. }.bind(this));
  339. array.push( unit );
  340. array = array.unique();
  341. this.data[f+"TaskPerson"] = array;
  342. this.form.app.notice("分配成功","");
  343. //this.context.data.save();
  344. this.form.save();
  345. this.form.view.reload();
  346. this.form.view.selectedItems = [];
  347. }.bind(this))
  348. });
  349. this.define("saveDcc", function( ids, field, value, callback){
  350. var action = new this.Action("x_cms_assemble_control", {
  351. "save":{"uri": "/jaxrs/document/batch/data/modify", "method": "PUT"}
  352. });
  353. var array = [];
  354. if( typeOf( field ) == "array" ){
  355. for( var i=0; i<field.length; i++ ){
  356. array.push({
  357. "dataPath": field[i],
  358. "dataType": "String",
  359. "dataString": value[i],
  360. "dataInteger": null,
  361. "dataBoolean": null,
  362. "dataDate": null
  363. })
  364. }
  365. }else{
  366. array.push({
  367. "dataPath": field,
  368. "dataType": "String",
  369. "dataString": value,
  370. "dataInteger": null,
  371. "dataBoolean": null,
  372. "dataDate": null
  373. })
  374. }
  375. action.invoke({"name": "save", "data": {
  376. "docIds" : ids,
  377. "dataChanges" : array
  378. }, "success": function(json){
  379. if(callback)callback(json);
  380. }.bind(this)
  381. });
  382. }.bind(this));
  383. MWF.require("MWF.xDesktop.Actions.RestActions", null, false);
  384. var ChannelTaskPhoneService = new Class({
  385. Extends: MWF.xDesktop.Actions.RestActions,
  386. initialize: function ( context, workId ) {
  387. this.context = context;
  388. this.serviceUrl = "http://localhost:8080/channeltask/";
  389. this.importUrl = this.serviceUrl + "import";
  390. this.phoneUrl = this.serviceUrl + "phone";
  391. this.importcheckUrl = this.serviceUrl + "importcheck";
  392. },
  393. import : function( formData, file, callback_success, callback_progress, async ){
  394. this.invoke( {
  395. method : "POST",
  396. uri: this.importUrl,
  397. async: async,
  398. enctype: "formdata", //formdata
  399. data: formData, // {}
  400. file: file,
  401. withCredentials : true,
  402. success: function( data ){ if(callback_success)callback_success(data) },
  403. failure: function(){}
  404. });
  405. if(callback_progress){
  406. window.setTimeout( function(){
  407. this.importcheck( callback_progress )
  408. }.bind(this), 1000 )
  409. }
  410. },
  411. importcheck : function( callback ){
  412. this.invoke( {
  413. method : "GET",
  414. uri: this.importUrl + "?workId" + this.workId ,
  415. async: true,
  416. withCredentials : true,
  417. success: function( data ){ if(callback)callback(data) },
  418. failure: function(){}
  419. })
  420. },
  421. listByImportbatchName : function(importbatchName ,start, end, docStatus, callback){
  422. this.phoneAction( "list", {
  423. importbatchName : importbatchName, start : start, end : end, docStatus: docStatus
  424. }, callback)
  425. },
  426. listByWork : function(start, end, docStatus, callback){
  427. this.phoneAction( "list", {
  428. workId : this.workId, start : start, end : end, docStatus : docStatus
  429. }, callback)
  430. },
  431. listByWorkAndCity : function(city, start, end, docStatus, callback){
  432. this.phoneAction( "list", {
  433. workId : this.workId, city : city, start : start, end : end, docStatus : docStatus
  434. }, callback)
  435. },
  436. listByWorkAndCounty : function(county, start, end, docStatus, callback){
  437. this.phoneAction( "list", {
  438. workId : this.workId, county : county, start : start, end : end, docStatus : docStatus
  439. }, callback)
  440. },
  441. listByWorkAndBranch : function(branch, start, end, docStatus, callback){
  442. this.phoneAction( "list", {
  443. workId : this.workId, branch : branch, start : start, end : end, docStatus : docStatus
  444. }, callback)
  445. },
  446. deleteByImportbatchName : function(importbatchName, callback){
  447. this.phoneAction( "delete", {
  448. importbatchName : importbatchName
  449. }, callback)
  450. },
  451. deleteByWorkId : function(callback){
  452. this.phoneAction( "delete", {
  453. workId : this.workId
  454. }, callback)
  455. },
  456. dispatch : function(branch, start, end, docStatus, callback){
  457. this.phoneAction( "dispatch", {
  458. workId : this.workId, branch : branch, start : start, end : end, docStatus : docStatus
  459. }, callback)
  460. },
  461. phoneAction : function( action, json, callback ){
  462. var param = "";
  463. for( var key in json ){
  464. if( json[key] )param = param + "&" + key + "=" + json[key];
  465. }
  466. this.invoke( {
  467. method : "GET",
  468. uri: this.phoneUrl + "?action=" + action + param,
  469. async: true,
  470. withCredentials : true,
  471. success: function( data ){ if(callback)callback(data) },
  472. failure: function(){}
  473. })
  474. },
  475. invoke: function(option){
  476. /*
  477. option = {
  478. method : "POST",
  479. uri: "",
  480. async: true,
  481. enctype: "", //formdata
  482. data: null, // {}
  483. file: null,
  484. withCredentials : true,
  485. success: function(){},
  486. failure: function(){}
  487. }
  488. */
  489. var method = option.method || "GET";
  490. var uri = option.uri;
  491. var async = (option.async===false) ? false : true;
  492. var callback = new MWF.xDesktop.Actions.RestActions.Callback(option.success, option.failure);
  493. if (option.enctype && (option.enctype.toLowerCase()=="formdata")){
  494. this.invokeFormData(method, uri, option.data, option.file, callback, async);
  495. }else{
  496. var data = (option.data) ? JSON.encode(option.data) : "";
  497. var credentials = true;
  498. if (option.withCredentials===false){
  499. credentials = false;
  500. }
  501. return MWF.restful(method, uri, data, callback, async, credentials);
  502. }
  503. }
  504. });
  505. var UploadExcelDialog = new Class({
  506. Extends: MWF.xApplication.cms.Module.ImportForm,
  507. Implements: [Options, Events],
  508. options: {
  509. "style": "minder",
  510. "width": "650",
  511. "height": "430",
  512. "hasTop": true,
  513. "hasIcon": false,
  514. "draggable": true,
  515. "maxAction" : true,
  516. "title" : "导入号码"
  517. },
  518. _createTableContent: function () {
  519. this.formTableContainer.setStyles({"margin":"0px auto 20px atuo"});
  520. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  521. "<tr><td styles='formTableTitle' width='20%'>说明:</td>" +
  522. " <td styles='formTableValue' colspan='3' width='80%' style='font-size:12px;color:#666;line-height:20px;'>"+
  523. " 您可以直接在Excel表格里填写地市分公司、区县分公司和网格的名称,系统会以您导入的分公司名称进行流转分发。<br/>"+
  524. "请注意填写的名称需要与系统内的分公司/组织名称一致。<div item='openUnit''></div>"+ "<div item='url2'></div>"+//如果名称有重名,请使用层次名。
  525. "</td></tr>" +
  526. "<tr><td styles='formTableTitle' lable='url' width='20%'></td>" +
  527. " <td styles='formTableValue' item='url' colspan='3' width='80%'></td></tr>" +
  528. "<tr><td styles='formTableTitle' lable='file' ></td>" +
  529. " <td styles='formTableValue' colspan='3'><div item='filename'></div><div item='file'></div></td></tr>" +
  530. "</table>";
  531. this.formTableArea.set("html", html);
  532. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  533. this.form = new MForm(this.formTableArea, {}, {
  534. isEdited: true,
  535. style : "cms",
  536. hasColon : true,
  537. itemTemplate: {
  538. openUnit : { type : "Innerhtml", value : "<a href='javascript:void(0)'>点击查看组织名称</a>",
  539. event : { click : function(item, ev){
  540. layout.desktop.openApplication(ev, "Org", {
  541. onQueryLoad : function(){
  542. this.status = { navi : 0 }
  543. }
  544. });
  545. }.bind(this)}
  546. },
  547. url2: { type : "Innerhtml", text : "下载模板", value : "<a target='_blank' href='/x_component_cms_Module/$ExcelForm/"+encodeURIComponent("Excel导入合法性说明.xls")+"'>点击查看校验说明</a>" },
  548. url: { type : "Innerhtml", text : "下载模板", value : "<a target='_blank' href='/x_component_cms_Module/$ExcelForm/"+encodeURIComponent("Excel模板下载.xls")+"'>Excel模板下载</a>" },
  549. file: { type : "button", value : "选择Excel文件",text : "选择文件", event :{
  550. click : function(){
  551. this.selectFile();
  552. }.bind(this)
  553. } }
  554. }
  555. }, this.app);
  556. this.form.load();
  557. },
  558. _setCustom : function(){
  559. this.formBottomNode.setStyles({
  560. "margin":"0px auto 0px auto",
  561. "width" : "300px"
  562. });
  563. },
  564. ok: function( callback ){
  565. if( !this.formData ){
  566. this.app.notice( "请先选择Excel文件", "error" );
  567. }else{
  568. var user = layout.desktop.session.user;
  569. var identity = ( user.identityList && user.identityList.length > 0 ) ? user.identityList[0] : {};
  570. var json = {
  571. workName : this.data.workName,
  572. workId : this.data.workId,
  573. jobId : this.data.jobId,
  574. creatorPerson : user.distinguishedName,
  575. creatorIdentity : identity.distinguishedName,
  576. creatorUnitName : identity.unitLevelName.replace(/[\/]/,"^^")
  577. };
  578. if( !this.isSetData ){
  579. for( var key in json ){
  580. this.formData.append( key, json[key] );
  581. }
  582. this.isSetData = true;
  583. }
  584. this.loadProgressBar();
  585. var import_success = function( data ){
  586. var _form = this.context.form;
  587. this.progressBar.setProgress(js.data.processTotal, js.data.dataTotal, "正在导入数据");
  588. var array = this.context.data.importBatchNames ? this.context.data.importBatchNames.split(",") : [];
  589. array.push( json.data.importBatchName );
  590. this.context.data.importBatchNames = array.toString();
  591. this.context.form.save();
  592. this.progressBar.gotoStep(3);
  593. this.setResult();
  594. if( !_form.statJson ){
  595. _form.statJson = new StatJson(this.context);
  596. }
  597. _form.statJson.addBatch(importBatchName, true);
  598. _form.statJson.submit();
  599. this.context.setUploadedUnit( function(){
  600. _form.view.reload();
  601. _form.view.selectedItems = [];
  602. if( _form.view_error ){
  603. _form.view_error.reload();
  604. _form.view_error.selectedItems = [];
  605. }
  606. this.context.createImportBatchDiv();
  607. this.context.loadStatTable( this.context.statTableOptions ? this.context.statTableOptions.container : this.context.form.get("statContaienr").node );
  608. }.bind(this));
  609. this.formData = null;
  610. this.file = null;
  611. }.bind(this);
  612. var importcheck_fun = function( data ){
  613. this.progressBar.setProgress(js.data.processTotal, js.data.dataTotal, "正在导入数据");
  614. }.bind(this);
  615. var service = new ChannelTaskPhoneService( this.context, this.data.workId );
  616. service.import(this.formData, this.file, import_success, importcheck_fun, true);
  617. //this.action.importDocumentFormExcel(this.data.categoryId, function (json) { //导入excel
  618. // checkImportStatus(json);
  619. //}.bind(this), null, this.formData, this.file);
  620. }
  621. },
  622. setResult : function(){
  623. this.formTableArea.empty();
  624. this.formTopCloseActionNode.setStyle("display","");
  625. this.formTopTextNode.set("text","导入结束");
  626. var data = this.importedResultJson.data;
  627. new Element("div", {
  628. styles : {
  629. "margin-top" : "10px",
  630. "font-size" : "14px",
  631. "margin-left" : "10px"
  632. },
  633. text : "本批次共导入"+data.dataTotal+"条数据,成功导入"+data.successTotal+"条数据,发生错误"+data.errorTotal+"条"
  634. }).inject(this.formTableArea);
  635. if( !this.context.form.statJson ){
  636. this.context.form.statJson = new StatJson(this.context);
  637. }
  638. this.context.form.statJson.loadTable(this.formTableArea, this.importBatchName );
  639. this.setFormNodeSize();
  640. },
  641. loadProgressBar : function(){
  642. this.formTableArea.empty();
  643. this.formBottomNode.setStyle("display","none");
  644. this.formTopCloseActionNode.setStyle("display","none");
  645. this.formTopTextNode.set("text","正在导入数据,请不要关闭窗口...");
  646. this.progressBar = new ProgressBar( this.formTableArea );
  647. this.progressBar.load();
  648. }
  649. });
  650. this.define("setNumberCount",function(){
  651. if( this.data.currentUnit ){
  652. if( !this.form.statJson ){
  653. this.form.statJson = new StatJson(this);
  654. }
  655. var count = this.form.statJson.getUnitCount( this.data.currentUnit );
  656. if( this.data.numberCount != count ){
  657. this.data.numberCount = count;
  658. this.form.save();
  659. }
  660. }
  661. }.bind(this));
  662. this.define("getErrorCount", function(){
  663. if( !this.form.statJson ){
  664. this.form.statJson = new StatJson(this);
  665. }
  666. return this.form.statJson.getErrorCount();
  667. }.bind(this));
  668. this.define("setUploadedUnit", function( callback ){
  669. if( !this.form.statJson ){
  670. this.form.statJson = new StatJson(this);
  671. }
  672. var unit = this.data.currentUnit;
  673. if( unit == "" && !this.data.newFlag ){
  674. //unit = this.workContext.getWork().creatorUnitLevelName.split("/")[0];
  675. var creatorUnitLevelName = this.workContext.getWork().creatorUnitLevelName;
  676. if( creatorUnitLevelName ){
  677. var u = creatorUnitLevelName.split("/")[0];
  678. var unit = this.org.getUnit( u );
  679. }
  680. }
  681. var flag = this.data.flag || this.data.newFlag;
  682. var array = [];
  683. if( !flag ){
  684. array = this.form.statJson.getCity();
  685. this.data.numberCount = this.form.statJson.getUnitCount();
  686. }else if( flag=="city" ){
  687. if( unit ){
  688. array = this.form.statJson.getCounty( unit );
  689. this.data.numberCount = this.form.statJson.getUnitCount(unit);
  690. }else{
  691. this.data.numberCount = this.form.statJson.getUnitCount();
  692. array = this.form.statJson.getAllCounty();
  693. }
  694. }else if( flag == "county" ){
  695. if( unit ){
  696. var city = this.data.city;
  697. if( !city ){
  698. var creatorUnitLevelName = this.workContext.getWork().creatorUnitLevelName;
  699. if( creatorUnitLevelName ){
  700. var u = creatorUnitLevelName.split("/")[0];
  701. city = this.org.getUnit( u );
  702. }else{
  703. var u = this.org.listSupUnit( unit );
  704. city = u[0].distinguishedName;
  705. }
  706. }
  707. this.data.numberCount = this.form.statJson.getUnitCount( unit );
  708. array = this.form.statJson.getBranch( city, unit );
  709. }else{
  710. this.data.numberCount = this.form.statJson.getUnitCount();
  711. array = this.form.statJson.getAllBranch();
  712. }
  713. }
  714. var f;
  715. if( !flag ){
  716. f = "city";
  717. }else if( flag=="city" ){
  718. f = "county";
  719. }else if( flag == "county" ){
  720. f = "branch"
  721. }
  722. this.data[f+"TaskPerson"] = array;
  723. this.form.save(function(){
  724. if(callback)callback()
  725. });
  726. });
  727. this.define( "loadView", function( status, isSetCurrent ){
  728. var workId = this.data.provinceWorkId || this.data.cityWorkId || this.data.countyWorkId;
  729. var unit = this.data.currentUnit;
  730. if( unit == "" && !this.data.newFlag ){
  731. unit = this.workContext.getWork().creatorUnitLevelName.split("/")[0];
  732. }
  733. //unit = unit.split("@")[0];
  734. var flag = this.data.flag || this.data.newFlag;
  735. var control = this.workContext.getControl();
  736. var viewName;
  737. if( status == "published" ){
  738. viewName = "手机号码-导入成功"
  739. }else if( status == "error" ){
  740. viewName = "手机号码-导入失败"
  741. }else{
  742. viewName = "手机号码"
  743. }
  744. var viewJson = {
  745. "application": "渠道-手机号码设置",
  746. "viewName": viewName,
  747. "isTitle": "yes",
  748. "select": control.allowSave ? "multi" : "none", //none , single, multi
  749. //"titleStyles": this.json.titleStyles,
  750. // "itemStyles": this.json.itemStyles,
  751. "isExpand": "no",
  752. "filter": [{
  753. "logic":"and",
  754. "path": "workId",
  755. "title": "workId",
  756. "comparison":"equals",
  757. "comparisonTitle":"等于",
  758. "value": workId,
  759. "formatType":"textValue"
  760. }]
  761. };
  762. if( flag && unit){
  763. viewJson.filter.push({
  764. "logic":"and",
  765. "path": flag,
  766. "title": flag,
  767. "comparison":"equals",
  768. "comparisonTitle":"等于",
  769. "value": unit,
  770. "formatType":"textValue"
  771. })
  772. }
  773. var container;
  774. if( status == "published" ){
  775. container = this.form.get("view_container_published").node
  776. }else if( status == "error" ){
  777. container = this.form.get("view_container_error").node
  778. }else{
  779. container = this.form.get("view_container").node
  780. }
  781. MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  782. var view = new MWF.xApplication.query.Query.Viewer(container, viewJson, {
  783. "resizeNode": true, //(this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  784. "onSelect": function(){
  785. //this.fireEvent("select");
  786. }.bind(this)
  787. });
  788. if( status == "published" ){
  789. view.docStatus = "published";
  790. this.form.view = view;
  791. }else if( status == "error" ){
  792. view.docStatus = "error";
  793. this.form.view_error = view;
  794. }else{
  795. this.form.view = view;
  796. }
  797. if( isSetCurrent )this.form.currentView = view;
  798. }.bind(this));
  799. });
  800. this.define("createImportBatchDiv", function(){
  801. if(!this.data.importBatchNames)return;
  802. if( !this.form.statJson ){
  803. this.form.statJson = new StatJson(this);
  804. }
  805. var _self = this;
  806. var div = this.form.get("importBatchDiv").node;
  807. div.empty();
  808. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  809. var table = new Element( "table", {
  810. "width":"90%",
  811. "border":"0",
  812. "cellpadding":"5",
  813. "cellspacing":"0",
  814. "styles" : {"border-top" : "1px solid #ccc", "border-left" : "1px solid #ccc", "margin" : "20px auto 10px auto"}
  815. }).inject( div );
  816. var tr = new Element("tr").inject( table );
  817. new Element("th", { "styles": tdCss, text : "导入时间" }).inject( tr );
  818. new Element("th", { "styles": tdCss, text : "校验通过条数" }).inject( tr );
  819. new Element("th", { "styles": tdCss, text : "校验未通过条数" }).inject( tr );
  820. new Element("th", { "styles": tdCss, text : "操作" }).inject( tr );
  821. this.data.importBatchNames.split(",").each( function(d){
  822. var timeStr = d.split("_")[1];
  823. var year = timeStr.substring(0,4);
  824. var month = timeStr.substring(4,6);
  825. var date = timeStr.substring(6,8);
  826. var hour = timeStr.substring(8,10);
  827. var minture = timeStr.substring(10,12);
  828. var second = timeStr.substring(12,14);
  829. var time = year+"-"+month+"-"+date + " " + hour + ":" + minture + ":" + second;
  830. var tr = new Element("tr").inject( table );
  831. new Element("td", { "styles": tdCss, text : time }).inject( tr );
  832. new Element("td", { "styles": tdCss, text : this.form.statJson.getPublishedCount( d ) }).inject( tr );
  833. new Element("td", { "styles": tdCss, text : this.form.statJson.getErrorCount( d ) }).inject( tr );
  834. var td = new Element("td", { "styles": tdCss }).inject( tr );
  835. var button = new Element("button", { styles : {
  836. "border-radius": "5px", "border": "1px solid rgb(204, 204, 204)", "height": "26px", "color": "rgb(119, 119, 119)", "cursor" : "pointer", "margin-right" : "20px"
  837. } , text : "只查看该批次导入的数据" }).inject(td);
  838. button.store("data",d);
  839. button.addEvent("click", function(e){
  840. var btn = e.target;
  841. var data = {
  842. "logic":"and",
  843. "path": "$document.importBatchName",
  844. "title": "workId",
  845. "comparison":"equals",
  846. "comparisonTitle":"等于",
  847. "value": btn.retrieve("data"),
  848. "formatType":"textValue"
  849. };
  850. if( this.form.view ){
  851. var view = this.form.view;
  852. var filter = view.json.filter ? view.json.filter.clone() : [];
  853. filter.push( data );
  854. var filterList = {"filterList": filter };
  855. view.createViewNode( filterList );
  856. }
  857. if( this.form.view_error ){
  858. var view_error = this.form.view_error;
  859. var filter = view_error.json.filter ? view_error.json.filter.clone() : [];
  860. filter.push( data );
  861. var filterList = {"filterList": filter };
  862. view_error.createViewNode( filterList );
  863. }
  864. this.loadStatTable( this.statTableOptions ? this.statTableOptions.contaier : this.form.get("statContaienr").node , btn.retrieve("data") );
  865. }.bind(this));
  866. var button = new Element("button", { styles : {
  867. "border-radius": "5px", "border": "1px solid rgb(204, 204, 204)", "height": "26px", "color": "rgb(119, 119, 119)", "cursor" : "pointer"
  868. } , text : "删除该批次导入的数据" }).inject(td);
  869. button.store("data",d);
  870. button.store("time",time);
  871. button.addEvent("click", function(e){
  872. this.form.app.confirm("infor", e, "删除确认", "删除后无法恢复,确定要删除"+e.target.retrieve("time")+"导入的数据?", 380, 150, function(){
  873. MWF.Actions.get("x_cms_assemble_control").deleteDocumentWithBatchName( e.target.retrieve("data"), function(){
  874. var array = _self.data.importBatchNames.split(",");
  875. var batch = e.target.retrieve("data");
  876. _self.form.statJson.deleteBatch( batch );
  877. _self.form.statJson.submit();
  878. array.erase( batch );
  879. _self.data.importBatchNames = array.toString();
  880. _self.form.save(function(){
  881. _self.setUploadedUnit( function(){
  882. _self.form.app.notice( "删除成功" );
  883. _self.form.loadErrorView = false;
  884. _self.form.app.refresh();
  885. });
  886. });
  887. });
  888. this.close();
  889. }, function(){
  890. this.close();
  891. });
  892. }.bind(this))
  893. }.bind(this));
  894. var tr = new Element("tr").inject( table );
  895. new Element("td", { "styles": tdCss, text : "总数" }).inject( tr );
  896. new Element("td", { "styles": tdCss, text : this.form.statJson.getPublishedCount() }).inject( tr );
  897. new Element("td", { "styles": tdCss, text : this.form.statJson.getErrorCount() }).inject( tr );
  898. var td = new Element("td", { "styles": tdCss }).inject( tr );
  899. var button = new Element("button", { styles : {
  900. "border-radius": "5px", "border": "1px solid rgb(204, 204, 204)", "height": "26px", "color": "rgb(119, 119, 119)", "cursor" : "pointer", "margin-right" : "20px"
  901. } , text : "查看全部" }).inject(td);
  902. button.addEvent("click", function(e){
  903. var btn = e.target;
  904. if( this.form.view ){
  905. var view = this.form.view;
  906. var filter = view.json.filter ? view.json.filter.clone() : [];
  907. var filterList = {"filterList": filter };
  908. view.createViewNode( filterList );
  909. }
  910. if( this.form.view_error ){
  911. var view_error = this.form.view_error;
  912. var filter = view_error.json.filter ? view_error.json.filter.clone() : [];
  913. var filterList = {"filterList": filter };
  914. view_error.createViewNode( filterList );
  915. }
  916. this.loadStatTable( this.statTableOptions ? this.statTableOptions.contaier : this.form.get("statContaienr").node );
  917. }.bind(this));
  918. });
  919. this.define("getAllUnit", function( callback){
  920. if( this.name_all ){
  921. if(callback)callback();
  922. }
  923. var array = this.name_all = [];
  924. this.name_levelName = {};
  925. this.dnName_levelName = {};
  926. this.name_dnName = {};
  927. var action = new this.Action("x_organization_assemble_express", {
  928. "lookup":{"uri": "/jaxrs/unit/list/all/object", "method": "GET"}
  929. });
  930. action.invoke({"name": "lookup","parameter": {}, data:null, "success": function(json){
  931. json.data.each( function(d){
  932. this.name_levelName[ d.name ] = d.levelName;
  933. this.dnName_levelName[ d.distinguishedName ] = d.levelName;
  934. this.name_dnName[ d.name ] = d.distinguishedName;
  935. array.push( d.name );
  936. array.push( d.distinguishedName );
  937. array.push( d.shortName );
  938. array.push( d.levelName );
  939. }.bind(this));
  940. if(callback)callback(json);
  941. }.bind(this), async : false
  942. });
  943. return array;
  944. }.bind(this));
  945. this.define("setWorkId", function(){
  946. if (this.workContext.getWork().activityName=="发起"){
  947. this.form.get("provinceWorkId").setData(this.workContext.getWork().id);
  948. this.form.get("currentWorkId").setData(this.workContext.getWork().id)
  949. }
  950. if (this.workContext.getWork().activityName=="市级接收单元负责人处理"){
  951. this.form.get("cityWorkId").setData(this.workContext.getWork().id);
  952. this.form.get("currentWorkId").setData(this.workContext.getWork().id)
  953. }
  954. if (this.workContext.getWork().activityName=="县级接收单元负责人处理"){
  955. this.form.get("countyWorkId").setData(this.workContext.getWork().id);
  956. this.form.get("currentWorkId").setData(this.workContext.getWork().id)
  957. }
  958. if (this.workContext.getWork().activityName=="网格接收单元负责人处理"){
  959. this.form.get("branchWorkId").setData(this.workContext.getWork().id);
  960. this.form.get("currentWorkId").setData(this.workContext.getWork().id)
  961. }
  962. });
  963. this.define("getUnitLevel", function(level, isObject){
  964. var identity = this.workContext.getWork().creatorIdentityDn;
  965. var topUnit;
  966. MWF.Actions.get("x_organization_assemble_express")[isObject ? "getUnitWithIdentityAndLevel" : "getUnitWithIdentityAndLevelValue" ]( {"identity":identity,"level":level}, function( json ){
  967. topUnit = json.data.unit;
  968. }.bind(this), null, false);
  969. return topUnit;
  970. }.bind(this));
  971. this.define("openMinder", function( workId ){
  972. var options = {
  973. pageId : "71acdde6-97cc-4c6d-abe2-817ea5afad4f",
  974. portalId : "b66420c3-dee9-4b4c-9d52-050fd0921864",
  975. workId : workId,
  976. "appId": "portal_"+workId
  977. };
  978. if( layout.desktop.openApplication ){
  979. layout.desktop.openApplication(null, "portal.Portal", options)
  980. }else{
  981. window.open( "/x_desktop/app.html?app=portal.Portal&option="+ JSON.stringify(options) );
  982. }
  983. });
  984. this.define("openUploadForm", function(){
  985. // var flag = (this.workContext.getControl().allowSave && this.workContext.getActivity().alias == "draft") ;
  986. // if( !flag ){
  987. // this.form.app.notice( "发起节点才能上传Excel","error" );
  988. // return;
  989. // }
  990. if( !this.data.subject ){
  991. this.form.app.notice( "请填写任务名称并保存","error" );
  992. return;
  993. }
  994. var dialog = this.form.uploadExcelDialog = new UploadExcelDialog( { app : this.form.app }, {
  995. workName : this.data.subject,
  996. workId : this.data.provinceWorkId || this.data.currentWorkId,
  997. jobId : this.workContext.getWork().job,
  998. categoryId:"288a0f05-78dd-4650-af79-236e33832a7e"
  999. }, {
  1000. });
  1001. dialog.contextForm = this.form;
  1002. dialog.context = this;
  1003. dialog.edit();
  1004. });
  1005. var ProgressBar = new Class({
  1006. initialize: function ( container ) {
  1007. this.container = container;
  1008. },
  1009. load : function(){
  1010. this.getCss();
  1011. this.loadSteps();
  1012. this.loadProgressBar();
  1013. },
  1014. setProgress : function( processed, total, text ){
  1015. var width = Math.floor(( processed / total ) * 100 );
  1016. this.progressFront.setStyles({ width: width+"%" });
  1017. this.textNode.set("text", text + ",共"+total+"条,已处理"+ processed + "条,进度" + width + "%" );
  1018. },
  1019. loadProgressBar : function(){
  1020. this.progressNode = new Element("div", { styles : this.css.progressNode }).inject( this.container );
  1021. this.progressBack = new Element("div.progressBack", { styles: this.css.progressBack }).inject(this.progressNode);
  1022. this.progressBack.setStyle("width", "100%");
  1023. this.progressFront = new Element("div.progressFront", { styles: this.css.progressFront, text : " " }).inject(this.progressBack);
  1024. this.progressFront.setStyle("width", "0px");
  1025. this.textNode = new Element("div", { styles : this.css.textNode }).inject( this.container );
  1026. },
  1027. getCss : function(){
  1028. this.css = {
  1029. "loadingNode" : {
  1030. },
  1031. "textNode" : {
  1032. "margin-top" : "10px",
  1033. "font-size" : "12px",
  1034. "margin-left" : "10px"
  1035. },
  1036. "progressNode" : {
  1037. "margin" : "10px 0px",
  1038. "overflow" : "hidden"
  1039. },
  1040. "progressBack" : {
  1041. "float":"left",
  1042. "border-radius" : "10px",
  1043. "background-color" : "#f4f4f4",
  1044. "height" : "16px"
  1045. },
  1046. "progressFront" : {
  1047. "height" : "16px",
  1048. "background-color" : "#4a9adb"
  1049. }
  1050. }
  1051. }
  1052. });
  1053. this.define("loadStatTable", function( container , batchName, unitLevel, unitName ){
  1054. container.empty();
  1055. if( !this.form.statJson ){
  1056. this.form.statJson = new StatJson(this);
  1057. }
  1058. if( !unitLevel && this.statTableOptions ){
  1059. unitLevel = this.statTableOptions.unitLevel
  1060. }
  1061. if( !unitName && this.statTableOptions ){
  1062. unitName = this.statTableOptions.unitName
  1063. }
  1064. this.form.statJson.loadTable( container, batchName, unitLevel, unitName );
  1065. });
  1066. var StatJson = new Class({
  1067. initialize: function ( context ) {
  1068. this.context = context;
  1069. if( this.context.data.statJson ){
  1070. this.json = JSON.parse(this.context.data.statJson);
  1071. }else{
  1072. this.json = {
  1073. total : {
  1074. publishedCount : 0,
  1075. errorCount : 0
  1076. },
  1077. batch: {}
  1078. }
  1079. }
  1080. },
  1081. submit : function(){
  1082. this.deleteEmptyUnit();
  1083. for( var key in this.json.batch ){
  1084. this.deleteEmptyUnit(key);
  1085. }
  1086. this.context.data.statJson = JSON.stringify(this.json);
  1087. },
  1088. addBatch : function( batchName, isSetCurrent ){
  1089. if( !this.json.batch[batchName] ){
  1090. this.json.batch[batchName] = {
  1091. publishedCount : 0,
  1092. errorCount : 0
  1093. };
  1094. }
  1095. if( isSetCurrent )this.currentBatch = this.json.batch[batchName];
  1096. },
  1097. deleteBatch : function( batchName ){
  1098. var json = this.json;
  1099. var batchData = json.batch[batchName];
  1100. if( batchData ){
  1101. if( batchData.publishedCount ){
  1102. json.total.publishedCount = json.total.publishedCount - batchData.publishedCount;
  1103. }
  1104. if( batchData.errorCount ){
  1105. json.total.errorCount = json.total.errorCount - batchData.errorCount;
  1106. }
  1107. this.reduceByBatchData( batchData );
  1108. delete this.json.batch[batchName];
  1109. }
  1110. },
  1111. reduceByBatchData : function( batchData ){
  1112. var totalData = this.json.total;
  1113. for( var key in batchData ){
  1114. if( key != "publishedCount" && key != "errorCount" ){
  1115. var totalD = totalData[key];
  1116. var batchD = batchData[key];
  1117. if( batchData.publishedCount )totalD.publishedCount = totalD.publishedCount - batchD.publishedCount;
  1118. if( batchData.errorCount )totalD.errorCount = totalD.errorCount - batchD.errorCount;
  1119. for( var key_2 in batchD ){
  1120. if( key_2 != "publishedCount" && key_2 != "errorCount" ){
  1121. var totalD_2 = totalD[key_2];
  1122. var batchD_2 = batchD[key_2];
  1123. if( batchD_2.publishedCount )totalD_2.publishedCount = totalD_2.publishedCount - batchD_2.publishedCount;
  1124. if( batchD_2.errorCount )totalD_2.errorCount = totalD_2.errorCount - batchD_2.errorCount;
  1125. for(var key_3 in batchD_2 ){
  1126. if( key_3 != "publishedCount" && key_3 != "errorCount" ) {
  1127. var totalD_3 = totalD_2[key_3];
  1128. var batchD_3 = batchD_2[key_3];
  1129. if( batchD_3.publishedCount )totalD_3.publishedCount = totalD_3.publishedCount - batchD_3.publishedCount;
  1130. if( batchD_3.errorCount )totalD_3.errorCount = totalD_3.errorCount - batchD_3.errorCount;
  1131. }
  1132. }
  1133. }
  1134. }
  1135. }
  1136. }
  1137. },
  1138. addData: function( cmsDocData ){
  1139. var d = cmsDocData;
  1140. var totalJson = this.json.total;
  1141. var batchJson = this.currentBatch;
  1142. if( d.docStatus == "published" ){
  1143. totalJson.publishedCount++;
  1144. batchJson.publishedCount++;
  1145. this.addCount( totalJson, d );
  1146. this.addCount( batchJson, d );
  1147. }else if( d.docStatus == "error" ){
  1148. totalJson.errorCount++;
  1149. batchJson.errorCount++;
  1150. }
  1151. },
  1152. addCount : function( json, d ){
  1153. if( d.city ){
  1154. var cityJson = json[ d.city ];
  1155. if( !cityJson ){
  1156. cityJson = json[ d.city ] = { publishedCount : 0 };
  1157. }
  1158. cityJson.publishedCount ++;
  1159. if( d.county ){
  1160. var countyJson = cityJson[ d.county ];
  1161. if( !countyJson ){
  1162. countyJson = cityJson[ d.county ] = { publishedCount : 0 };
  1163. }
  1164. countyJson.publishedCount ++;
  1165. if( d.branch ) {
  1166. var branchJson = countyJson[d.branch];
  1167. if (!branchJson) {
  1168. branchJson = countyJson[d.branch] = {publishedCount: 0};
  1169. }
  1170. branchJson.publishedCount++;
  1171. }
  1172. }
  1173. }else{
  1174. var city = "未设置组织";
  1175. var cityJson = json[ city ];
  1176. if( !cityJson ){
  1177. cityJson = json[ city ] = { publishedCount : 0 };
  1178. }
  1179. cityJson.publishedCount ++;
  1180. }
  1181. },
  1182. reduceCount : function( json, d ){
  1183. if( d.city ){
  1184. var cityJson = json[ d.city ];
  1185. if( !cityJson ){
  1186. cityJson = json[ d.city ] = { publishedCount : 0 };
  1187. }
  1188. cityJson.publishedCount --;
  1189. if( d.county ){
  1190. var countyJson = cityJson[ d.county ];
  1191. if( !countyJson ){
  1192. countyJson = cityJson[ d.county ] = { publishedCount : 0 };
  1193. }
  1194. countyJson.publishedCount --;
  1195. if( d.branch ) {
  1196. var branchJson = countyJson[d.branch];
  1197. if (!branchJson) {
  1198. branchJson = countyJson[d.branch] = {publishedCount: 0};
  1199. }
  1200. branchJson.publishedCount--;
  1201. }
  1202. }
  1203. }else{
  1204. var city = "未设置组织";
  1205. var cityJson = json[ city ];
  1206. if( !cityJson ){
  1207. cityJson = json[ city ] = { publishedCount : 0 };
  1208. }
  1209. cityJson.publishedCount--;
  1210. }
  1211. },
  1212. getCity : function(){
  1213. var totalJson = this.json.total;
  1214. var city = [];
  1215. for( var key in totalJson ){
  1216. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1217. if( totalJson[key].publishedCount > 0 ){
  1218. city.push(key);
  1219. }
  1220. }
  1221. }
  1222. return city;
  1223. },
  1224. getCounty : function( city ){
  1225. var totalJson = this.json.total;
  1226. var county = [];
  1227. if( totalJson[city] ){
  1228. var cityJson = totalJson[city];
  1229. for( var key in cityJson ){
  1230. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1231. if( cityJson[key].publishedCount > 0 ){
  1232. county.push(key);
  1233. }
  1234. }
  1235. }
  1236. }
  1237. return county;
  1238. },
  1239. getBranch : function( city, county ){
  1240. var totalJson = this.json.total;
  1241. var branch = [];
  1242. if( totalJson[city] ){
  1243. var cityJson = totalJson[city];
  1244. if( cityJson[county] ){
  1245. var countyJson = cityJson[county];
  1246. for( var key in countyJson ){
  1247. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1248. if( countyJson[key].publishedCount > 0 ){
  1249. branch.push(key);
  1250. }
  1251. }
  1252. }
  1253. }
  1254. }
  1255. return branch;
  1256. },
  1257. getAllCounty : function(){
  1258. var totalJson = this.json.total;
  1259. var county = [];
  1260. for(var key in totalJson ){
  1261. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1262. for( var key_2 in totalJson[key] ){
  1263. if( key_2 != "publishedCount" && key_2 != "errorCount" && key_2 != "未设置组织"){
  1264. if( totalJson[key][key_2].publishedCount > 0 ){
  1265. county.push(key_2);
  1266. }
  1267. }
  1268. }
  1269. }
  1270. }
  1271. return county;
  1272. },
  1273. getAllBranch : function(){
  1274. var totalJson = this.json.total;
  1275. var branch = [];
  1276. for(var key in totalJson ){
  1277. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1278. for( var key_2 in totalJson[key] ){
  1279. if( key_2 != "publishedCount" && key_2 != "errorCount" && key_2 != "未设置组织"){
  1280. for( var key_3 in totalJson[key][key_2] ){
  1281. if( key_3 != "publishedCount" && key_3 != "errorCount" && key_3 != "未设置组织"){
  1282. if( totalJson[key][key_2][key_3].publishedCount > 0 ){
  1283. branch.push(key_3);
  1284. }
  1285. }
  1286. }
  1287. }
  1288. }
  1289. }
  1290. }
  1291. return branch;
  1292. },
  1293. getUnitCount : function( unit, importBatchName ){
  1294. var data;
  1295. if( importBatchName && this.json.batch[importBatchName]) {
  1296. data = this.json.batch[importBatchName];
  1297. }else{
  1298. data = this.json.total;
  1299. }
  1300. if( !unit )return data.publishedCount;
  1301. for( var city in data ){
  1302. var cityData = data[city];
  1303. if( city == unit )return cityData.publishedCount;
  1304. for( var county in cityData ){
  1305. var countyData = cityData[county];
  1306. if( county == unit )return countyData.publishedCount;
  1307. for( var branch in countyData ){
  1308. var branchData = countyData[branch];
  1309. if( branch == unit )return branchData.publishedCount;
  1310. }
  1311. }
  1312. }
  1313. return 0;
  1314. },
  1315. changeData : function( newData, oldData, importBatchName ){
  1316. //var oldData = {
  1317. // status : "error",
  1318. // city : "",
  1319. // county : "",
  1320. // branch : ""
  1321. //};
  1322. var batchJson;
  1323. if( importBatchName && this.json.batch[importBatchName]) {
  1324. batchJson = this.json.batch[importBatchName];
  1325. }
  1326. var totalJson = this.json.total;
  1327. if( oldData.docStatus == "error" ){
  1328. totalJson.errorCount--;
  1329. if( batchJson )batchJson.errorCount--;
  1330. }
  1331. if( oldData.docStatus == "published" ){
  1332. totalJson.publishedCount--;
  1333. this.reduceCount( totalJson, oldData );
  1334. if( batchJson ){
  1335. batchJson.publishedCount--;
  1336. this.reduceCount( batchJson, oldData );
  1337. }
  1338. }
  1339. if( newData.docStatus == "error"){
  1340. totalJson.errorCount++;
  1341. if( batchJson )batchJson.errorCount++;
  1342. }
  1343. if( newData.docStatus == "published"){
  1344. totalJson.publishedCount++;
  1345. this.addCount( totalJson, newData );
  1346. if( batchJson ){
  1347. batchJson.publishedCount++;
  1348. this.addCount( batchJson, newData );
  1349. }
  1350. }
  1351. },
  1352. getPublishedCount : function( importBatchName ){
  1353. if( !importBatchName ){
  1354. return this.json.total.publishedCount;
  1355. }else{
  1356. if( this.json.batch[importBatchName]) {
  1357. var batchJson = this.json.batch[importBatchName];
  1358. return batchJson.publishedCount;
  1359. }
  1360. }
  1361. },
  1362. getErrorCount : function( importBatchName ){
  1363. if( !importBatchName ){
  1364. return this.json.total.errorCount;
  1365. }else{
  1366. if( this.json.batch[importBatchName]) {
  1367. var batchJson = this.json.batch[importBatchName];
  1368. return batchJson.errorCount;
  1369. }
  1370. }
  1371. },
  1372. deleteEmptyUnit : function( batchName ){
  1373. if( batchName ){
  1374. var data = this.json.batch[batchName];
  1375. }else{
  1376. var data = this.json.total;
  1377. }
  1378. for( var key in data ){
  1379. if( key != "publishedCount" && key != "errorCount" ){
  1380. var cityData = data[key];
  1381. if( !cityData.publishedCount && !cityData.errorCount ){
  1382. delete data[key]
  1383. }else{
  1384. for( var key_2 in cityData ){
  1385. if( key_2 != "publishedCount" && key_2 != "errorCount" ){
  1386. var countyData = cityData[key_2];
  1387. if( !countyData.publishedCount && !countyData.errorCount ){
  1388. delete data[key][key_2]
  1389. }else{
  1390. for(var key_3 in countyData ){
  1391. if( key_3 != "publishedCount" && key_3 != "errorCount" ) {
  1392. var branchData = countyData[key_3];
  1393. if( !branchData.publishedCount && !branchData.errorCount ) {
  1394. delete data[key][key_2][key_3]
  1395. }
  1396. }
  1397. }
  1398. }
  1399. }
  1400. }
  1401. }
  1402. }
  1403. }
  1404. },
  1405. getNoUnitJson : function( d ){
  1406. var data = Object.clone(d);
  1407. for( var key in data ){
  1408. if( key != "publishedCount" && key != "errorCount" ){
  1409. var cityData = data[key];
  1410. var cityCount = cityData.publishedCount;
  1411. var countyCount = 0;
  1412. for( var county in cityData ){
  1413. if( county != "publishedCount" && county != "errorCount" ){
  1414. var countyData = cityData[county];
  1415. countyCount = countyCount + countyData.publishedCount;
  1416. var branchCount = 0;
  1417. for( var branch in countyData ) {
  1418. if( branch != "publishedCount" && branch != "errorCount" ) {
  1419. var branchData = countyData[branch];
  1420. branchCount = branchCount + branchData.publishedCount
  1421. }
  1422. }
  1423. if( countyData.publishedCount > branchCount ){
  1424. countyData["未设置"] = { publishedCount : countyData.publishedCount - branchCount };
  1425. }
  1426. }
  1427. }
  1428. if( cityData.publishedCount > countyCount ){
  1429. cityData["未设置"] = { publishedCount : cityData.publishedCount - countyCount };
  1430. }
  1431. }
  1432. }
  1433. return data;
  1434. },
  1435. loadTable : function( container, batchName, unitLevel, unitName ){
  1436. if( !unitLevel ){
  1437. this._loadTable(container, batchName);
  1438. }else{
  1439. this._loadTableByUnit( container, batchName, unitLevel, unitName )
  1440. }
  1441. },
  1442. _loadTableByUnit : function(container, batchName, unitLevel, unitName ){
  1443. if (batchName) {
  1444. var d = this.json.batch[batchName];
  1445. } else {
  1446. var d = this.json.total;
  1447. }
  1448. var data = this.getNoUnitJson( d );
  1449. var table = this.table = new Element( "table", {
  1450. "width":"90%",
  1451. "border":"0",
  1452. "cellpadding":"5",
  1453. "cellspacing":"0",
  1454. "styles" : {"border-top" : "1px solid #ccc", "border-left" : "1px solid #ccc", "margin" : "20px auto 10px auto", "font-size":"14px"}
  1455. }).inject( container );
  1456. if( batchName ){
  1457. var timeStr = batchName.split("_")[1];
  1458. var year = timeStr.substring(0,4);
  1459. var month = timeStr.substring(4,6);
  1460. var date = timeStr.substring(6,8);
  1461. var hour = timeStr.substring(8,10);
  1462. var minture = timeStr.substring(10,12);
  1463. var second = timeStr.substring(12,14);
  1464. var title = year+"-"+month+"-"+date + " " + hour + ":" + minture + ":" + second + "批次数据统计"
  1465. }else{
  1466. var title = "数据统计";
  1467. }
  1468. if( unitLevel == "city" )this._loadTableByCity(title, data, table, unitName );
  1469. if( unitLevel == "county" )this._loadTableByCounty(title, data, table, unitName );
  1470. if( unitLevel == "branch" )this._loadTableByBranch(title, data, table, unitName );
  1471. },
  1472. _loadTableByCity : function(title, data, table, unitName){
  1473. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  1474. var tdTitleCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" , "font-size":"16px", "font-weight" : "bold"};
  1475. var tr = new Element("tr").inject( table );
  1476. new Element("td", { "styles": tdTitleCss, text : title, colspan:3 }).inject( tr );
  1477. var tr = new Element("tr").inject( table );
  1478. new Element("th", { "styles": tdCss, text : "市分" }).inject( tr );
  1479. new Element("th", { "styles": tdCss, text : "县分" }).inject( tr );
  1480. new Element("th", { "styles": tdCss, text : "网格" }).inject( tr );
  1481. for( var city in data ){
  1482. if( city != unitName )continue;
  1483. if( city != "publishedCount" && city!="errorCount" ){
  1484. var cityTr = new Element("tr").inject( table );
  1485. var cityData = data[city];
  1486. var cityShow = city == "未设置组织" ? "未设置" : city.split("@")[0];
  1487. var cityTd = new Element("td", { "styles": tdCss, text : cityShow + "(" + cityData.publishedCount + ")" }).inject( cityTr );
  1488. var citySpan = 1;
  1489. var countyIndex = 0;
  1490. var countyTr = null;
  1491. var countyTd = null;
  1492. var branchTd = null;
  1493. for( var county in cityData ){
  1494. if( county != "publishedCount" && county!="errorCount" ){
  1495. if( countyIndex != 0 ){
  1496. citySpan++;
  1497. countyTr = new Element("tr").inject( table );
  1498. }
  1499. countyIndex ++;
  1500. var countySpan = 1;
  1501. var countyData = cityData[county];
  1502. countyTd = new Element("td", { "styles": tdCss, text : county.split("@")[0] + "(" + countyData.publishedCount + ")" }).inject( countyTr || cityTr );
  1503. var branchIndex = 0;
  1504. var branchTr = null;
  1505. for( var branch in countyData ){
  1506. if( branch != "publishedCount" && branch!="errorCount" ) {
  1507. if( branchIndex != 0 ){
  1508. branchTr = new Element("tr").inject( table );
  1509. citySpan++;
  1510. countySpan++;
  1511. }
  1512. branchIndex++;
  1513. var branchData = countyData[branch];
  1514. branchTd = new Element("td", {"styles": tdCss, text: branch.split("@")[0]+ "(" + branchData.publishedCount + ")" }).inject( branchTr || countyTr || cityTr );
  1515. }
  1516. }
  1517. if( branchIndex == 0 ){
  1518. branchTd = new Element("td", { "styles": tdCss, text :"" }).inject( branchTr || countyTr || cityTr );
  1519. }
  1520. countyTd.set("rowspan",countySpan);
  1521. }
  1522. }
  1523. if( countyIndex == 0 ){
  1524. countyTd = new Element("td", { "styles": tdCss, text :"" }).inject( countyTr || cityTr );
  1525. }
  1526. if( !branchTd ){
  1527. new Element("td", { "styles": tdCss, text :"" }).inject( countyTr || cityTr );
  1528. }
  1529. cityTd.set("rowspan",citySpan);
  1530. }
  1531. }
  1532. },
  1533. _loadTableByCounty : function(title, data, table, unitName){
  1534. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  1535. var tdTitleCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" , "font-size":"16px", "font-weight" : "bold"};
  1536. var tr = new Element("tr").inject( table );
  1537. new Element("td", { "styles": tdTitleCss, text : title, colspan:2 }).inject( tr );
  1538. var tr = new Element("tr").inject( table );
  1539. new Element("th", { "styles": tdCss, text : "县分" }).inject( tr );
  1540. new Element("th", { "styles": tdCss, text : "网格" }).inject( tr );
  1541. for( var city in data ){
  1542. if( city != "publishedCount" && city!="errorCount" ){
  1543. var cityData = data[city];
  1544. var countyIndex = 0;
  1545. var countyTr = null;
  1546. var countyTd = null;
  1547. var branchTd = null;
  1548. for( var county in cityData ){
  1549. if( unitName != county )continue;
  1550. if( county != "publishedCount" && county!="errorCount" ){
  1551. countyTr = new Element("tr").inject( table );
  1552. countyIndex ++;
  1553. var countySpan = 1;
  1554. var countyData = cityData[county];
  1555. countyTd = new Element("td", { "styles": tdCss, text : county.split("@")[0] + "(" + countyData.publishedCount + ")" }).inject( countyTr );
  1556. var branchIndex = 0;
  1557. var branchTr = null;
  1558. for( var branch in countyData ){
  1559. if( branch != "publishedCount" && branch!="errorCount" ) {
  1560. if( branchIndex != 0 ){
  1561. branchTr = new Element("tr").inject( table );
  1562. countySpan++;
  1563. }
  1564. branchIndex++;
  1565. var branchData = countyData[branch];
  1566. branchTd = new Element("td", {"styles": tdCss, text: branch.split("@")[0]+ "(" + branchData.publishedCount + ")" }).inject( branchTr || countyTr );
  1567. }
  1568. }
  1569. if( branchIndex == 0 ){
  1570. branchTd = new Element("td", { "styles": tdCss, text :"" }).inject( branchTr || countyTr );
  1571. }
  1572. countyTd.set("rowspan",countySpan);
  1573. }
  1574. }
  1575. if( !branchTd && countyTr ){
  1576. new Element("td", { "styles": tdCss, text :"" }).inject( countyTr );
  1577. }
  1578. }
  1579. }
  1580. },
  1581. _loadTableByBranch : function(title, data, table, unitName){
  1582. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  1583. var tdTitleCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" , "font-size":"16px", "font-weight" : "bold"};
  1584. var tr = new Element("tr").inject( table );
  1585. new Element("td", { "styles": tdTitleCss, text : title }).inject( tr );
  1586. for( var city in data ){
  1587. if( city != "publishedCount" && city!="errorCount" ){
  1588. var cityData = data[city];
  1589. var branchTd = null;
  1590. for( var county in cityData ){
  1591. if( county != "publishedCount" && county!="errorCount" ){
  1592. var countyData = cityData[county];
  1593. for( var branch in countyData ){
  1594. if( branch != unitName )continue;
  1595. if( branch != "publishedCount" && branch!="errorCount" ) {
  1596. var branchTr = new Element("tr").inject( table );
  1597. var branchData = countyData[branch];
  1598. branchTd = new Element("td", {"styles": tdCss, text: branch.split("@")[0]+ "(" + branchData.publishedCount + ")" }).inject( branchTr );
  1599. }
  1600. }
  1601. }
  1602. }
  1603. }
  1604. }
  1605. },
  1606. _loadTable : function( container, batchName ) {
  1607. if (batchName) {
  1608. var d = this.json.batch[batchName];
  1609. } else {
  1610. var d = this.json.total;
  1611. }
  1612. var data = this.getNoUnitJson( d );
  1613. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  1614. var tdTitleCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" , "font-size":"16px", "font-weight" : "bold"};
  1615. var table = this.table = new Element( "table", {
  1616. "width":"90%",
  1617. "border":"0",
  1618. "cellpadding":"5",
  1619. "cellspacing":"0",
  1620. "styles" : {"border-top" : "1px solid #ccc", "border-left" : "1px solid #ccc", "margin" : "20px auto 10px auto", "font-size":"14px"}
  1621. }).inject( container );
  1622. var tr = new Element("tr").inject( table );
  1623. if( batchName ){
  1624. var timeStr = batchName.split("_")[1];
  1625. var year = timeStr.substring(0,4);
  1626. var month = timeStr.substring(4,6);
  1627. var date = timeStr.substring(6,8);
  1628. var hour = timeStr.substring(8,10);
  1629. var minture = timeStr.substring(10,12);
  1630. var second = timeStr.substring(12,14);
  1631. var title = year+"-"+month+"-"+date + " " + hour + ":" + minture + ":" + second + "批次数据统计"
  1632. }else{
  1633. var title = "数据统计";
  1634. }
  1635. new Element("td", { "styles": tdTitleCss, text : title, colspan:3 }).inject( tr );
  1636. var tr = new Element("tr").inject( table );
  1637. new Element("td", { "styles": tdCss, text : "校验未通过(条)" }).inject( tr );
  1638. new Element("td", { "styles": tdCss, colspan:2, text : data.errorCount || "" }).inject( tr );
  1639. var tr = new Element("tr").inject( table );
  1640. new Element("td", { "styles": tdCss, text : "校验通过(条)" }).inject( tr );
  1641. new Element("td", { "styles": tdCss, colspan:2, text : data.publishedCount || "" }).inject( tr );
  1642. var tr = new Element("tr").inject( table );
  1643. new Element("th", { "styles": tdCss, text : "市分" }).inject( tr );
  1644. new Element("th", { "styles": tdCss, text : "县分" }).inject( tr );
  1645. new Element("th", { "styles": tdCss, text : "网格" }).inject( tr );
  1646. for( var city in data ){
  1647. if( city != "publishedCount" && city!="errorCount" ){
  1648. var cityTr = new Element("tr").inject( table );
  1649. var cityData = data[city];
  1650. var cityShow = city == "未设置组织" ? "未设置" : city.split("@")[0];
  1651. var cityTd = new Element("td", { "styles": tdCss, text : cityShow + "(" + cityData.publishedCount + ")" }).inject( cityTr );
  1652. var citySpan = 1;
  1653. var countyIndex = 0;
  1654. var countyTr = null;
  1655. var countyTd = null;
  1656. var branchTd = null;
  1657. for( var county in cityData ){
  1658. if( county != "publishedCount" && county!="errorCount" ){
  1659. if( countyIndex != 0 ){
  1660. citySpan++;
  1661. countyTr = new Element("tr").inject( table );
  1662. }
  1663. countyIndex ++;
  1664. var countySpan = 1;
  1665. var countyData = cityData[county];
  1666. countyTd = new Element("td", { "styles": tdCss, text : county.split("@")[0] + "(" + countyData.publishedCount + ")" }).inject( countyTr || cityTr );
  1667. var branchIndex = 0;
  1668. var branchTr = null;
  1669. for( var branch in countyData ){
  1670. if( branch != "publishedCount" && branch!="errorCount" ) {
  1671. if( branchIndex != 0 ){
  1672. branchTr = new Element("tr").inject( table );
  1673. citySpan++;
  1674. countySpan++;
  1675. }
  1676. branchIndex++;
  1677. var branchData = countyData[branch];
  1678. branchTd = new Element("td", {"styles": tdCss, text: branch.split("@")[0]+ "(" + branchData.publishedCount + ")" }).inject( branchTr || countyTr || cityTr );
  1679. }
  1680. }
  1681. if( branchIndex == 0 ){
  1682. branchTd = new Element("td", { "styles": tdCss, text :"" }).inject( branchTr || countyTr || cityTr );
  1683. }
  1684. countyTd.set("rowspan",countySpan);
  1685. }
  1686. }
  1687. if( countyIndex == 0 ){
  1688. countyTd = new Element("td", { "styles": tdCss, text :"" }).inject( countyTr || cityTr );
  1689. }
  1690. if( !branchTd ){
  1691. new Element("td", { "styles": tdCss, text :"" }).inject( countyTr || cityTr );
  1692. }
  1693. cityTd.set("rowspan",citySpan);
  1694. }
  1695. }
  1696. }
  1697. });