Test.js 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273
  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. var UploadExcelDialog = new Class({
  384. Extends: MWF.xApplication.cms.Module.ImportForm,
  385. Implements: [Options, Events],
  386. options: {
  387. "style": "minder",
  388. "width": "650",
  389. "height": "430",
  390. "hasTop": true,
  391. "hasIcon": false,
  392. "draggable": true,
  393. "maxAction" : true,
  394. "title" : "导入号码"
  395. },
  396. _createTableContent: function () {
  397. this.formTableContainer.setStyles({"margin":"0px auto 20px atuo"});
  398. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  399. "<tr><td styles='formTableTitle' width='20%'>说明:</td>" +
  400. " <td styles='formTableValue' colspan='3' width='80%' style='font-size:12px;color:#666;line-height:20px;'>"+
  401. " 您可以直接在Excel表格里填写地市分公司、区县分公司和网格的名称,系统会以您导入的分公司名称进行流转分发。<br/>"+
  402. "请注意填写的名称需要与系统内的分公司/组织名称一致。<div item='openUnit''></div>"+ "<div item='url2'></div>"+//如果名称有重名,请使用层次名。
  403. "</td></tr>" +
  404. "<tr><td styles='formTableTitle' lable='url' width='20%'></td>" +
  405. " <td styles='formTableValue' item='url' colspan='3' width='80%'></td></tr>" +
  406. "<tr><td styles='formTableTitle' lable='file' ></td>" +
  407. " <td styles='formTableValue' colspan='3'><div item='filename'></div><div item='file'></div></td></tr>" +
  408. "</table>";
  409. this.formTableArea.set("html", html);
  410. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  411. this.form = new MForm(this.formTableArea, {}, {
  412. isEdited: true,
  413. style : "cms",
  414. hasColon : true,
  415. itemTemplate: {
  416. openUnit : { type : "Innerhtml", value : "<a href='javascript:void(0)'>点击查看组织名称</a>",
  417. event : { click : function(item, ev){
  418. layout.desktop.openApplication(ev, "Org", {
  419. onQueryLoad : function(){
  420. this.status = { navi : 0 }
  421. }
  422. });
  423. }.bind(this)}
  424. },
  425. url2: { type : "Innerhtml", text : "下载模板", value : "<a target='_blank' href='/x_component_cms_Module/$ExcelForm/"+encodeURIComponent("Excel导入合法性说明.xls")+"'>点击查看校验说明</a>" },
  426. url: { type : "Innerhtml", text : "下载模板", value : "<a target='_blank' href='/x_component_cms_Module/$ExcelForm/"+encodeURIComponent("Excel模板下载.xls")+"'>Excel模板下载</a>" },
  427. file: { type : "button", value : "选择Excel文件",text : "选择文件", event :{
  428. click : function(){
  429. this.selectFile();
  430. }.bind(this)
  431. } }
  432. }
  433. }, this.app);
  434. this.form.load();
  435. },
  436. _setCustom : function(){
  437. this.formBottomNode.setStyles({
  438. "margin":"0px auto 0px auto",
  439. "width" : "300px"
  440. });
  441. },
  442. ok: function( callback ){
  443. if( !this.formData ){
  444. this.app.notice( "请先选择Excel文件", "error" );
  445. }else{
  446. var json = {
  447. //"title": "新建数据的文档标题(前缀)",
  448. "title_column": "subject",
  449. "identity": "",
  450. "docType": "数据",
  451. "wiParameters": [
  452. {
  453. "dataPath": "workName",
  454. "dataType": "String",
  455. "dataString": this.data.workName,
  456. "dataInteger": "",
  457. "dataBoolean": "",
  458. "dataDate": ""
  459. },
  460. {
  461. "dataPath": "workId",
  462. "dataType": "String",
  463. "dataString": this.data.workId,
  464. "dataInteger": "",
  465. "dataBoolean": "",
  466. "dataDate": ""
  467. },
  468. {
  469. "dataPath": "jobId",
  470. "dataType": "String",
  471. "dataString": this.data.jobId,
  472. "dataInteger": "",
  473. "dataBoolean": "",
  474. "dataDate": ""
  475. }
  476. ]
  477. };
  478. this.formData.append("json_data", JSON.stringify(json) );
  479. var checkImportStatus = function( json ){
  480. this.action.checkImportStatus( json.data.importBatchName, function( js ){
  481. this.importedResultJson = js;
  482. this.importBatchName = json.data.importBatchName;
  483. if( js.data.dataTotal <= js.data.processTotal ){
  484. this.progressBar.setProgress(js.data.processTotal, js.data.dataTotal, "正在导入数据");
  485. var array = this.context.data.importBatchNames ? this.context.data.importBatchNames.split(",") : [];
  486. array.push( json.data.importBatchName );
  487. this.context.data.importBatchNames = array.toString();
  488. this.context.form.save();
  489. this.allUnit = this.getAllUnit();
  490. this.checkImportedData(true, json.data.importBatchName);
  491. this.formData = null;
  492. this.file = null;
  493. //this.app.notice("总共导入"+json.data.total+"条数据,成功"+json.data.success_count+"条数据,错误"+json.data.error_count+"条!");
  494. }else{
  495. setTimeout( function(){
  496. this.progressBar.setProgress(js.data.processTotal, js.data.dataTotal, "正在导入数据");
  497. checkImportStatus( json )
  498. }.bind(this), 500 );
  499. }
  500. }.bind(this)), function(){
  501. setTimeout( function(){
  502. this.progressBar.setProgress(js.data.processTotal, js.data.dataTotal, "正在导入数据");
  503. checkImportStatus( json )
  504. }.bind(this), 500 );
  505. }.bind(this);
  506. }.bind(this);
  507. this.loadProgressBar();
  508. this.action.importDocumentFormExcel(this.data.categoryId, function (json) { //导入excel
  509. checkImportStatus(json);
  510. }.bind(this), null, this.formData, this.file);
  511. }
  512. },
  513. checkImportedData : function( isFirst, importBatchName ){
  514. var _form = this.context.form;
  515. if( isFirst ){
  516. this.checked = 0;
  517. if( !_form.statJson ){
  518. _form.statJson = new StatJson(this.context);
  519. }
  520. _form.statJson.addBatch(importBatchName, true);
  521. }
  522. //http://ahpp.zoneland.net:20020/x_cms_assemble_control/jaxrs/document/filter/list/(0)/next/20?v=0.4.2&jio4cwnm
  523. this.action.listDocumentFilterNext( "(0)", 1000, {
  524. "importBatchNames" : [importBatchName],
  525. "categoryAliasList":["渠道-手机号码设置-手机号码"],
  526. "statusList":["checking"], //,"published","error"
  527. "orderField":null,"orderType":null,
  528. "documentType":"全部",
  529. "needData" : true
  530. }, function( json ){
  531. if( !this.totalCount ){
  532. this.totalCount = json.count;
  533. this.progressBar.gotoStep(2);
  534. this.progressBar.setProgress(0,this.totalCount,"正在校验导入数据");
  535. }
  536. var length = (json.data || []).length;
  537. var loaded = 0;
  538. ( json.data || [] ).each( function( d, i ){
  539. this.checkDocData( d , function(){
  540. this.checked ++;
  541. loaded ++;
  542. this.progressBar.setProgress(this.checked,this.totalCount,"正在校验导入数据");
  543. if( loaded == length && this.checked < this.totalCount ){
  544. window.setTimeout( function(){
  545. this.checkImportedData( false, importBatchName );
  546. }.bind(this), 1000 );
  547. }
  548. if( this.checked == this.totalCount ){
  549. this.progressBar.gotoStep(3);
  550. this.setResult();
  551. _form.statJson.submit();
  552. this.context.setUploadedUnit( function(){
  553. _form.view.reload();
  554. _form.view.selectedItems = [];
  555. if( _form.view_error ){
  556. _form.view_error.reload();
  557. _form.view_error.selectedItems = [];
  558. }
  559. this.context.createImportBatchDiv();
  560. this.context.loadStatTable( this.context.statTableOptions ? this.context.statTableOptions.container : this.context.form.get("statContaienr").node );
  561. }.bind(this));
  562. }
  563. }.bind(this), function(){
  564. this.checked ++;
  565. loaded ++;
  566. }.bind(this));
  567. }.bind(this));
  568. }.bind(this))
  569. },
  570. checkDocData : function( d, callback ){
  571. if( d.docStatus != "checking" ){
  572. if(callback)callback();
  573. return;
  574. }
  575. var data = d.data;
  576. var errorTexts = [];
  577. var cityDn, countyDn, branchDn;
  578. if( data.branch || data.county || data.city ){
  579. if(data.branch)data.branch = data.branch.trim();
  580. if(data.county)data.county = data.county.trim();
  581. if(data.city)data.city = data.city.trim();
  582. if( data.city ){
  583. cityDn = this.name_dnName[ data.city ];
  584. if( !cityDn )errorTexts.push( "未在系统中找到"+data.city +"。");
  585. }
  586. if( errorTexts.length == 0 && data.county ){
  587. countyDn = this.name_dnName[ data.county ];
  588. if( !countyDn ){
  589. errorTexts.push( "未在系统中找到"+data.county+"。");
  590. }else{
  591. if( data.city ){
  592. if( !this.allUnit.contains( data.city + "/" +data.county ) ){
  593. errorTexts.push( "未在系统中找到"+data.city + "/" +data.county +"。" );
  594. }
  595. }else{
  596. var levelName = this.name_levelName[ data.county ];
  597. if( !levelName ){
  598. errorTexts.push( "未在系统中找到"+data.county +"所在的市公司。" );
  599. }else{
  600. cityDn = this.name_dnName[ levelName.split("/")[0] ];
  601. if( !cityDn )errorTexts.push( "未在系统中找到"+data.county +"所在的市公司。" );
  602. }
  603. }
  604. }
  605. }
  606. if( errorTexts.length == 0 && data.branch ){
  607. branchDn = this.name_dnName[ data.branch ];
  608. if( !branchDn ){
  609. errorTexts.push( "未在系统中找到"+data.branch+"。");
  610. }else{
  611. if( data.city && data.county ){
  612. if( !this.allUnit.contains( data.city + "/" +data.county + "/" +data.branch ) ){
  613. errorTexts.push( "未在系统中找到"+data.city + "/" +data.county + "/" +data.branch );
  614. }
  615. }else{
  616. var levelName = this.name_levelName[ data.branch ];
  617. if( !levelName ){
  618. errorTexts.push( "未在系统中找到"+ data.branch +"所在的县公司。" );
  619. }else{
  620. if( !cityDn ){
  621. cityDn = this.name_dnName[ levelName.split("/")[0] ];
  622. if( !cityDn )errorTexts.push( "未在系统中找到"+data.branch +"所在的市公司。" );
  623. }
  624. if( !countyDn ){
  625. countyDn = this.name_dnName[ levelName.split("/")[1] ];
  626. if( !countyDn )errorTexts.push( "未在系统中找到"+data.branch +"所在的县公司。" );
  627. }
  628. }
  629. }
  630. }
  631. }
  632. }
  633. if( errorTexts.length == 0 ){
  634. d.docStatus = "published";
  635. data.docStatus = "published";
  636. data.status = "成功";
  637. if( cityDn ){
  638. data.city_import = data.city;
  639. data.city = cityDn;
  640. }
  641. if( countyDn ){
  642. data.county_import = data.county;
  643. data.county = countyDn;
  644. }
  645. if( branchDn ){
  646. data.branch_import = data.branch;
  647. data.branch = branchDn;
  648. }
  649. }else{
  650. d.docStatus = "error";
  651. data.docStatus = "error";
  652. data.status = "错误";
  653. data.errorText = errorTexts.join("");
  654. }
  655. d.docData = data;
  656. delete d.data;
  657. this.context.form.statJson.addData( data );
  658. this.action.updateDocument( d , function(){
  659. if( callback )callback();
  660. });
  661. //if( d.data.branch && )
  662. // if( d.data.city ){
  663. // }
  664. // if( d.data.branch && )
  665. // county
  666. // branch
  667. },
  668. setResult : function(){
  669. this.formTableArea.empty();
  670. //if(this.okActionNode)this.okActionNode.setStyle("display","none");
  671. //if( this.cancelActionNode ){
  672. // this.cancelActionNode.setStyles({
  673. // "display":"",
  674. // "width" : "200px"
  675. // });
  676. //
  677. //}
  678. //this.formBottomNode.setStyle("display","");
  679. this.formTopCloseActionNode.setStyle("display","");
  680. this.formTopTextNode.set("text","导入结束");
  681. var data = this.importedResultJson.data;
  682. //this.app.notice("总共导入"+json.data.total+"条数据,成功"+json.data.success_count+"条数据,错误"+json.data.error_count+"条!");
  683. new Element("div", {
  684. styles : {
  685. "margin-top" : "10px",
  686. "font-size" : "14px",
  687. "margin-left" : "10px"
  688. },
  689. text : "本批次共导入"+data.dataTotal+"条数据,成功导入"+data.successTotal+"条数据,发生错误"+data.errorTotal+"条"
  690. }).inject(this.formTableArea);
  691. if( !this.context.form.statJson ){
  692. this.context.form.statJson = new StatJson(this.context);
  693. }
  694. this.context.form.statJson.loadTable(this.formTableArea, this.importBatchName )
  695. this.setFormNodeSize();
  696. },
  697. loadProgressBar : function(){
  698. this.formTableArea.empty();
  699. this.formBottomNode.setStyle("display","none");
  700. this.formTopCloseActionNode.setStyle("display","none");
  701. this.formTopTextNode.set("text","正在导入数据,请不要关闭窗口...");
  702. this.progressBar = new ProgressBar( this.formTableArea );
  703. this.progressBar.load();
  704. },
  705. getAllUnit : function( callback){
  706. if( this.name_all ){
  707. if(callback)callback();
  708. }
  709. var array = this.name_all = [];
  710. this.name_levelName = {};
  711. this.dnName_levelName = {};
  712. this.name_dnName = {};
  713. var action = new this.context.Action("x_organization_assemble_express", {
  714. "lookup":{"uri": "/jaxrs/unit/list/all/object", "method": "GET"}
  715. });
  716. action.invoke({"name": "lookup","parameter": {}, data:null, "success": function(json){
  717. json.data.each( function(d){
  718. this.name_levelName[ d.name ] = d.levelName;
  719. this.dnName_levelName[ d.distinguishedName ] = d.levelName;
  720. this.name_dnName[ d.name ] = d.distinguishedName;
  721. array.push( d.name );
  722. array.push( d.distinguishedName );
  723. array.push( d.shortName );
  724. array.push( d.levelName );
  725. }.bind(this));
  726. if(callback)callback(json);
  727. }.bind(this), async : false
  728. });
  729. return array;
  730. }
  731. });
  732. this.define("setNumberCount",function(){
  733. if( this.data.currentUnit ){
  734. if( !this.form.statJson ){
  735. this.form.statJson = new StatJson(this);
  736. }
  737. var count = this.form.statJson.getUnitCount( this.data.currentUnit );
  738. if( this.data.numberCount != count ){
  739. this.data.numberCount = count;
  740. this.form.save();
  741. }
  742. }
  743. }.bind(this));
  744. this.define("getErrorCount", function(){
  745. if( !this.form.statJson ){
  746. this.form.statJson = new StatJson(this);
  747. }
  748. return this.form.statJson.getErrorCount();
  749. }.bind(this));
  750. // this.define("getErrorCount", function(){
  751. // if( this.form.view_error ){
  752. // return this.form.view_error.gridJson.length;
  753. // }
  754. // var workId = this.data.provinceWorkId || this.data.cityWorkId || this.data.countyWorkId;
  755. // var filter = [{
  756. // "logic":"and",
  757. // "path": "workId",
  758. // "title": "workId",
  759. // "comparison":"equals",
  760. // "comparisonTitle":"等于",
  761. // "value": workId,
  762. // "formatType":"textValue"
  763. // }];
  764. // var count = 0;
  765. // MWF.Actions.get("x_query_assemble_surface").loadView("手机号码-导入失败", "渠道-手机号码设置", {"filterList": filter }, function(json){
  766. // count = json.data.grid.length;
  767. // }.bind(this), null, false);
  768. // return count;
  769. // }.bind(this))
  770. this.define("setUploadedUnit", function( callback ){
  771. if( !this.form.statJson ){
  772. this.form.statJson = new StatJson(this);
  773. }
  774. var unit = this.data.currentUnit;
  775. if( unit == "" && !this.data.newFlag ){
  776. //unit = this.workContext.getWork().creatorUnitLevelName.split("/")[0];
  777. var creatorUnitLevelName = this.workContext.getWork().creatorUnitLevelName;
  778. if( creatorUnitLevelName ){
  779. var u = creatorUnitLevelName.split("/")[0];
  780. var unit = this.org.getUnit( u );
  781. }
  782. }
  783. var flag = this.data.flag || this.data.newFlag;
  784. var array = [];
  785. if( !flag ){
  786. array = this.form.statJson.getCity();
  787. this.data.numberCount = this.form.statJson.getUnitCount();
  788. }else if( flag=="city" ){
  789. if( unit ){
  790. array = this.form.statJson.getCounty( unit );
  791. this.data.numberCount = this.form.statJson.getUnitCount(unit);
  792. }else{
  793. this.data.numberCount = this.form.statJson.getUnitCount();
  794. array = this.form.statJson.getAllCounty();
  795. }
  796. }else if( flag == "county" ){
  797. if( unit ){
  798. var city = this.data.city;
  799. if( !city ){
  800. var creatorUnitLevelName = this.workContext.getWork().creatorUnitLevelName;
  801. if( creatorUnitLevelName ){
  802. var u = creatorUnitLevelName.split("/")[0];
  803. city = this.org.getUnit( u );
  804. }else{
  805. var u = this.org.listSupUnit( unit );
  806. city = u[0].distinguishedName;
  807. }
  808. }
  809. this.data.numberCount = this.form.statJson.getUnitCount( unit );
  810. array = this.form.statJson.getBranch( city, unit );
  811. }else{
  812. this.data.numberCount = this.form.statJson.getUnitCount();
  813. array = this.form.statJson.getAllBranch();
  814. }
  815. }
  816. var f;
  817. if( !flag ){
  818. f = "city";
  819. }else if( flag=="city" ){
  820. f = "county";
  821. }else if( flag == "county" ){
  822. f = "branch"
  823. }
  824. this.data[f+"TaskPerson"] = array;
  825. this.form.save(function(){
  826. if(callback)callback()
  827. });
  828. });
  829. this.define( "loadView", function( status, isSetCurrent ){
  830. var workId = this.data.provinceWorkId || this.data.cityWorkId || this.data.countyWorkId;
  831. var unit = this.data.currentUnit;
  832. if( unit == "" && !this.data.newFlag ){
  833. unit = this.workContext.getWork().creatorUnitLevelName.split("/")[0];
  834. }
  835. //unit = unit.split("@")[0];
  836. var flag = this.data.flag || this.data.newFlag;
  837. var control = this.workContext.getControl();
  838. var viewName;
  839. if( status == "published" ){
  840. viewName = "手机号码-导入成功"
  841. }else if( status == "error" ){
  842. viewName = "手机号码-导入失败"
  843. }else{
  844. viewName = "手机号码"
  845. }
  846. var viewJson = {
  847. "application": "渠道-手机号码设置",
  848. "viewName": viewName,
  849. "isTitle": "yes",
  850. "select": control.allowSave ? "multi" : "none", //none , single, multi
  851. //"titleStyles": this.json.titleStyles,
  852. // "itemStyles": this.json.itemStyles,
  853. "isExpand": "no",
  854. "filter": [{
  855. "logic":"and",
  856. "path": "workId",
  857. "title": "workId",
  858. "comparison":"equals",
  859. "comparisonTitle":"等于",
  860. "value": workId,
  861. "formatType":"textValue"
  862. }]
  863. };
  864. if( flag && unit){
  865. viewJson.filter.push({
  866. "logic":"and",
  867. "path": flag,
  868. "title": flag,
  869. "comparison":"equals",
  870. "comparisonTitle":"等于",
  871. "value": unit,
  872. "formatType":"textValue"
  873. })
  874. }
  875. var container;
  876. if( status == "published" ){
  877. container = this.form.get("view_container_published").node
  878. }else if( status == "error" ){
  879. container = this.form.get("view_container_error").node
  880. }else{
  881. container = this.form.get("view_container").node
  882. }
  883. MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  884. var view = new MWF.xApplication.query.Query.Viewer(container, viewJson, {
  885. "resizeNode": true, //(this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  886. "onSelect": function(){
  887. //this.fireEvent("select");
  888. }.bind(this)
  889. });
  890. if( status == "published" ){
  891. view.docStatus = "published";
  892. this.form.view = view;
  893. }else if( status == "error" ){
  894. view.docStatus = "error";
  895. this.form.view_error = view;
  896. }else{
  897. this.form.view = view;
  898. }
  899. if( isSetCurrent )this.form.currentView = view;
  900. }.bind(this));
  901. });
  902. this.define("createImportBatchDiv", function(){
  903. if(!this.data.importBatchNames)return;
  904. if( !this.form.statJson ){
  905. this.form.statJson = new StatJson(this);
  906. }
  907. var _self = this;
  908. var div = this.form.get("importBatchDiv").node;
  909. div.empty();
  910. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  911. var table = new Element( "table", {
  912. "width":"90%",
  913. "border":"0",
  914. "cellpadding":"5",
  915. "cellspacing":"0",
  916. "styles" : {"border-top" : "1px solid #ccc", "border-left" : "1px solid #ccc", "margin" : "20px auto 10px auto"}
  917. }).inject( div );
  918. var tr = new Element("tr").inject( table );
  919. new Element("th", { "styles": tdCss, text : "导入时间" }).inject( tr );
  920. new Element("th", { "styles": tdCss, text : "校验通过条数" }).inject( tr );
  921. new Element("th", { "styles": tdCss, text : "校验未通过条数" }).inject( tr );
  922. new Element("th", { "styles": tdCss, text : "操作" }).inject( tr );
  923. this.data.importBatchNames.split(",").each( function(d){
  924. var timeStr = d.split("_")[1];
  925. var year = timeStr.substring(0,4);
  926. var month = timeStr.substring(4,6);
  927. var date = timeStr.substring(6,8);
  928. var hour = timeStr.substring(8,10);
  929. var minture = timeStr.substring(10,12);
  930. var second = timeStr.substring(12,14);
  931. var time = year+"-"+month+"-"+date + " " + hour + ":" + minture + ":" + second;
  932. var tr = new Element("tr").inject( table );
  933. new Element("td", { "styles": tdCss, text : time }).inject( tr );
  934. new Element("td", { "styles": tdCss, text : this.form.statJson.getPublishedCount( d ) }).inject( tr );
  935. new Element("td", { "styles": tdCss, text : this.form.statJson.getErrorCount( d ) }).inject( tr );
  936. var td = new Element("td", { "styles": tdCss }).inject( tr );
  937. var button = new Element("button", { styles : {
  938. "border-radius": "5px", "border": "1px solid rgb(204, 204, 204)", "height": "26px", "color": "rgb(119, 119, 119)", "cursor" : "pointer", "margin-right" : "20px"
  939. } , text : "只查看该批次导入的数据" }).inject(td);
  940. button.store("data",d);
  941. button.addEvent("click", function(e){
  942. var btn = e.target;
  943. var data = {
  944. "logic":"and",
  945. "path": "$document.importBatchName",
  946. "title": "workId",
  947. "comparison":"equals",
  948. "comparisonTitle":"等于",
  949. "value": btn.retrieve("data"),
  950. "formatType":"textValue"
  951. };
  952. if( this.form.view ){
  953. var view = this.form.view;
  954. var filter = view.json.filter ? view.json.filter.clone() : [];
  955. filter.push( data );
  956. var filterList = {"filterList": filter };
  957. view.createViewNode( filterList );
  958. }
  959. if( this.form.view_error ){
  960. var view_error = this.form.view_error;
  961. var filter = view_error.json.filter ? view_error.json.filter.clone() : [];
  962. filter.push( data );
  963. var filterList = {"filterList": filter };
  964. view_error.createViewNode( filterList );
  965. }
  966. this.loadStatTable( this.statTableOptions ? this.statTableOptions.contaier : this.form.get("statContaienr").node , btn.retrieve("data") );
  967. }.bind(this));
  968. var button = new Element("button", { styles : {
  969. "border-radius": "5px", "border": "1px solid rgb(204, 204, 204)", "height": "26px", "color": "rgb(119, 119, 119)", "cursor" : "pointer"
  970. } , text : "删除该批次导入的数据" }).inject(td);
  971. button.store("data",d);
  972. button.store("time",time);
  973. button.addEvent("click", function(e){
  974. this.form.app.confirm("infor", e, "删除确认", "删除后无法恢复,确定要删除"+e.target.retrieve("time")+"导入的数据?", 380, 150, function(){
  975. MWF.Actions.get("x_cms_assemble_control").deleteDocumentWithBatchName( e.target.retrieve("data"), function(){
  976. var array = _self.data.importBatchNames.split(",");
  977. var batch = e.target.retrieve("data");
  978. _self.form.statJson.deleteBatch( batch );
  979. _self.form.statJson.submit();
  980. array.erase( batch );
  981. _self.data.importBatchNames = array.toString();
  982. _self.form.save(function(){
  983. _self.setUploadedUnit( function(){
  984. _self.form.app.notice( "删除成功" );
  985. _self.form.loadErrorView = false;
  986. _self.form.app.refresh();
  987. });
  988. });
  989. });
  990. this.close();
  991. }, function(){
  992. this.close();
  993. });
  994. }.bind(this))
  995. }.bind(this));
  996. var tr = new Element("tr").inject( table );
  997. new Element("td", { "styles": tdCss, text : "总数" }).inject( tr );
  998. new Element("td", { "styles": tdCss, text : this.form.statJson.getPublishedCount() }).inject( tr );
  999. new Element("td", { "styles": tdCss, text : this.form.statJson.getErrorCount() }).inject( tr );
  1000. var td = new Element("td", { "styles": tdCss }).inject( tr );
  1001. var button = new Element("button", { styles : {
  1002. "border-radius": "5px", "border": "1px solid rgb(204, 204, 204)", "height": "26px", "color": "rgb(119, 119, 119)", "cursor" : "pointer", "margin-right" : "20px"
  1003. } , text : "查看全部" }).inject(td);
  1004. button.addEvent("click", function(e){
  1005. var btn = e.target;
  1006. if( this.form.view ){
  1007. var view = this.form.view;
  1008. var filter = view.json.filter ? view.json.filter.clone() : [];
  1009. var filterList = {"filterList": filter };
  1010. view.createViewNode( filterList );
  1011. }
  1012. if( this.form.view_error ){
  1013. var view_error = this.form.view_error;
  1014. var filter = view_error.json.filter ? view_error.json.filter.clone() : [];
  1015. var filterList = {"filterList": filter };
  1016. view_error.createViewNode( filterList );
  1017. }
  1018. this.loadStatTable( this.statTableOptions ? this.statTableOptions.contaier : this.form.get("statContaienr").node );
  1019. }.bind(this));
  1020. });
  1021. //this.define("checkImportedData", function( isFirst, importBatchName ){
  1022. // if( isFirst ){
  1023. // this.form.checked = 0;
  1024. // if( !this.form.statJson ){
  1025. // this.form.statJson = new StatJson(this);
  1026. // }
  1027. // this.form.statJson.addBatch(importBatchName, true);
  1028. // }
  1029. //
  1030. // //http://ahpp.zoneland.net:20020/x_cms_assemble_control/jaxrs/document/filter/list/(0)/next/20?v=0.4.2&jio4cwnm
  1031. // MWF.Actions.get("x_cms_assemble_control").listDocumentFilterNext( "(0)", 1000, {
  1032. // "importBatchNames" : [importBatchName],
  1033. // "categoryAliasList":["渠道-手机号码设置-手机号码"],
  1034. // "statusList":["checking"], //,"published","error"
  1035. // "orderField":null,"orderType":null,
  1036. // "documentType":"全部",
  1037. // "needData" : true
  1038. // }, function( json ){
  1039. // if( !this.form.totalCount ){
  1040. // this.form.totalCount = json.count;
  1041. // this.form.uploadExcelDialog.progressBar.gotoStep(2);
  1042. // this.form.uploadExcelDialog.progressBar.setProgress(0,this.form.totalCount,"正在校验导入数据");
  1043. // }
  1044. // var length = (json.data || []).length;
  1045. // var loaded = 0;
  1046. // ( json.data || [] ).each( function( d, i ){
  1047. // this.checkDocData( d , function(){
  1048. // this.form.checked ++;
  1049. // loaded ++;
  1050. // this.form.uploadExcelDialog.progressBar.setProgress(this.form.checked,this.form.totalCount,"正在校验导入数据");
  1051. // if( loaded == length && this.form.checked < this.form.totalCount ){
  1052. // window.setTimeout( function(){
  1053. // this.checkImportedData( false, importBatchName );
  1054. // }.bind(this), 1000 );
  1055. // }
  1056. // if( this.form.checked == this.form.totalCount ){
  1057. // this.form.uploadExcelDialog.progressBar.gotoStep(3);
  1058. // this.form.uploadExcelDialog.setResult();
  1059. // this.form.statJson.submit();
  1060. // this.setUploadedUnit( function(){
  1061. // this.form.view.reload();
  1062. // this.form.view.selectedItems = [];
  1063. // if( this.form.view_error ){
  1064. // this.form.view_error.reload();
  1065. // this.form.view_error.selectedItems = [];
  1066. // }
  1067. // this.createImportBatchDiv();
  1068. // }.bind(this));
  1069. // }
  1070. // }.bind(this), function(){
  1071. // this.form.checked ++;
  1072. // loaded ++;
  1073. // }.bind(this));
  1074. // }.bind(this));
  1075. // }.bind(this))
  1076. //}.bind(this));
  1077. this.define("getAllUnit", function( callback){
  1078. if( this.name_all ){
  1079. if(callback)callback();
  1080. }
  1081. var array = this.name_all = [];
  1082. this.name_levelName = {};
  1083. this.dnName_levelName = {};
  1084. this.name_dnName = {};
  1085. var action = new this.Action("x_organization_assemble_express", {
  1086. "lookup":{"uri": "/jaxrs/unit/list/all/object", "method": "GET"}
  1087. });
  1088. action.invoke({"name": "lookup","parameter": {}, data:null, "success": function(json){
  1089. json.data.each( function(d){
  1090. this.name_levelName[ d.name ] = d.levelName;
  1091. this.dnName_levelName[ d.distinguishedName ] = d.levelName;
  1092. this.name_dnName[ d.name ] = d.distinguishedName;
  1093. array.push( d.name );
  1094. array.push( d.distinguishedName );
  1095. array.push( d.shortName );
  1096. array.push( d.levelName );
  1097. }.bind(this));
  1098. if(callback)callback(json);
  1099. }.bind(this), async : false
  1100. });
  1101. return array;
  1102. }.bind(this));
  1103. //this.define( "checkDocData", function( d, callback ){
  1104. // if( d.docStatus != "checking" ){
  1105. // if(callback)callback();
  1106. // return;
  1107. // }
  1108. // var data = d.data;
  1109. // var errorTexts = [];
  1110. // var cityDn, countyDn, branchDn;
  1111. // if( data.branch || data.county || data.city ){
  1112. // if(data.branch)data.branch = data.branch.trim();
  1113. // if(data.county)data.county = data.county.trim();
  1114. // if(data.city)data.city = data.city.trim();
  1115. // if( data.city ){
  1116. // cityDn = this.name_dnName[ data.city ];
  1117. // if( !cityDn )errorTexts.push( "未在系统中找到"+data.city +"。");
  1118. // }
  1119. // if( errorTexts.length == 0 && data.county ){
  1120. // countyDn = this.name_dnName[ data.county ];
  1121. // if( !countyDn ){
  1122. // errorTexts.push( "未在系统中找到"+data.county+"。");
  1123. // }else{
  1124. // if( data.city ){
  1125. // if( !this.allUnit.contains( data.city + "/" +data.county ) ){
  1126. // errorTexts.push( "未在系统中找到"+data.city + "/" +data.county +"。" );
  1127. // }
  1128. // }else{
  1129. // var levelName = this.name_levelName[ data.county ];
  1130. // if( !levelName ){
  1131. // errorTexts.push( "未在系统中找到"+data.county +"所在的市公司。" );
  1132. // }else{
  1133. // cityDn = this.name_dnName[ levelName.split("/")[0] ];
  1134. // if( !cityDn )errorTexts.push( "未在系统中找到"+data.county +"所在的市公司。" );
  1135. // }
  1136. // }
  1137. // }
  1138. // }
  1139. // if( errorTexts.length == 0 && data.branch ){
  1140. // branchDn = this.name_dnName[ data.branch ];
  1141. // if( !branchDn ){
  1142. // errorTexts.push( "未在系统中找到"+data.branch+"。");
  1143. // }else{
  1144. // if( data.city && data.county ){
  1145. // if( !this.allUnit.contains( data.city + "/" +data.county + "/" +data.branch ) ){
  1146. // errorTexts.push( "未在系统中找到"+data.city + "/" +data.county + "/" +data.branch );
  1147. // }
  1148. // }else{
  1149. // var levelName = this.name_levelName[ data.branch ];
  1150. // if( !levelName ){
  1151. // errorTexts.push( "未在系统中找到"+ data.branch +"所在的县公司。" );
  1152. // }else{
  1153. // if( !cityDn ){
  1154. // cityDn = this.name_dnName[ levelName.split("/")[0] ];
  1155. // if( !cityDn )errorTexts.push( "未在系统中找到"+data.branch +"所在的市公司。" );
  1156. // }
  1157. // if( !countyDn ){
  1158. // countyDn = this.name_dnName[ levelName.split("/")[1] ];
  1159. // if( !countyDn )errorTexts.push( "未在系统中找到"+data.branch +"所在的县公司。" );
  1160. // }
  1161. // }
  1162. // }
  1163. // }
  1164. //
  1165. // }
  1166. // }
  1167. //
  1168. // if( errorTexts.length == 0 ){
  1169. // d.docStatus = "published";
  1170. // data.docStatus = "published";
  1171. // data.status = "成功";
  1172. // if( cityDn ){
  1173. // data.city_import = data.city;
  1174. // data.city = cityDn;
  1175. // }
  1176. // if( countyDn ){
  1177. // data.county_import = data.county;
  1178. // data.county = countyDn;
  1179. // }
  1180. // if( branchDn ){
  1181. // data.branch_import = data.branch;
  1182. // data.branch = branchDn;
  1183. // }
  1184. // }else{
  1185. // d.docStatus = "error";
  1186. // data.docStatus = "error";
  1187. // data.status = "错误";
  1188. // data.errorText = errorTexts.join("");
  1189. // }
  1190. // d.docData = data;
  1191. // delete d.data;
  1192. // this.form.statJson.addData( data );
  1193. // MWF.Actions.get("x_cms_assemble_control").updateDocument( d , function(){
  1194. // if( callback )callback();
  1195. // });
  1196. //
  1197. //}.bind(this));
  1198. this.define("setWorkId", function(){
  1199. if (this.workContext.getWork().activityName=="发起"){
  1200. this.form.get("provinceWorkId").setData(this.workContext.getWork().id);
  1201. this.form.get("currentWorkId").setData(this.workContext.getWork().id)
  1202. }
  1203. if (this.workContext.getWork().activityName=="市级接收单元负责人处理"){
  1204. this.form.get("cityWorkId").setData(this.workContext.getWork().id);
  1205. this.form.get("currentWorkId").setData(this.workContext.getWork().id)
  1206. }
  1207. if (this.workContext.getWork().activityName=="县级接收单元负责人处理"){
  1208. this.form.get("countyWorkId").setData(this.workContext.getWork().id);
  1209. this.form.get("currentWorkId").setData(this.workContext.getWork().id)
  1210. }
  1211. if (this.workContext.getWork().activityName=="网格接收单元负责人处理"){
  1212. this.form.get("branchWorkId").setData(this.workContext.getWork().id);
  1213. this.form.get("currentWorkId").setData(this.workContext.getWork().id)
  1214. }
  1215. });
  1216. this.define("getUnitLevel", function(level, isObject){
  1217. var identity = this.workContext.getWork().creatorIdentityDn;
  1218. var topUnit;
  1219. MWF.Actions.get("x_organization_assemble_express")[isObject ? "getUnitWithIdentityAndLevel" : "getUnitWithIdentityAndLevelValue" ]( {"identity":identity,"level":level}, function( json ){
  1220. topUnit = json.data.unit;
  1221. }.bind(this), null, false);
  1222. return topUnit;
  1223. }.bind(this));
  1224. this.define("openMinder", function( workId ){
  1225. layout.desktop.openApplication(null, "portal.Portal", {
  1226. pageId : "71acdde6-97cc-4c6d-abe2-817ea5afad4f",
  1227. portalId : "b66420c3-dee9-4b4c-9d52-050fd0921864",
  1228. workId : workId,
  1229. "appId": "portal_"+workId
  1230. })
  1231. });
  1232. this.define("openUploadForm", function(){
  1233. // var flag = (this.workContext.getControl().allowSave && this.workContext.getActivity().alias == "draft") ;
  1234. // if( !flag ){
  1235. // this.form.app.notice( "发起节点才能上传Excel","error" );
  1236. // return;
  1237. // }
  1238. if( !this.data.subject ){
  1239. this.form.app.notice( "请填写任务名称并保存","error" );
  1240. return;
  1241. }
  1242. var dialog = this.form.uploadExcelDialog = new UploadExcelDialog( { app : this.form.app }, {
  1243. workName : this.data.subject,
  1244. workId : this.data.provinceWorkId || this.data.currentWorkId,
  1245. jobId : this.workContext.getWork().job,
  1246. categoryId:"288a0f05-78dd-4650-af79-236e33832a7e"
  1247. }, {
  1248. });
  1249. dialog.contextForm = this.form;
  1250. dialog.context = this;
  1251. dialog.edit();
  1252. });
  1253. var ProgressBar = new Class({
  1254. initialize: function ( container ) {
  1255. this.container = container;
  1256. },
  1257. load : function(){
  1258. this.getCss();
  1259. this.loadSteps();
  1260. this.loadProgressBar();
  1261. },
  1262. setProgress : function( processed, total, text ){
  1263. var width = Math.floor(( processed / total ) * 100 );
  1264. this.progressFront.setStyles({ width: width+"%" });
  1265. this.textNode.set("text", text + ",共"+total+"条,已处理"+ processed + "条,进度" + width + "%" );
  1266. },
  1267. loadProgressBar : function(){
  1268. this.progressNode = new Element("div", { styles : this.css.progressNode }).inject( this.container );
  1269. this.progressBack = new Element("div.progressBack", { styles: this.css.progressBack }).inject(this.progressNode);
  1270. this.progressBack.setStyle("width", "100%");
  1271. this.progressFront = new Element("div.progressFront", { styles: this.css.progressFront, text : " " }).inject(this.progressBack);
  1272. this.progressFront.setStyle("width", "0px");
  1273. this.textNode = new Element("div", { styles : this.css.textNode }).inject( this.container );
  1274. },
  1275. loadSteps: function() {
  1276. var stepsContainer = new Element("div", { styles : this.css.stepsContainer }).inject( this.container );
  1277. this.step_1 = new Element( "div", {
  1278. styles : this.css.step_1_active,
  1279. text : "导入数据"
  1280. }).inject(stepsContainer);
  1281. this.stepLink_1 = new Element( "div", { styles : this.css.stepLink_1 }).inject(this.step_1);
  1282. this.step_2 = new Element( "div", {
  1283. styles : this.css.step_2,
  1284. text : "校验数据"
  1285. }).inject(stepsContainer);
  1286. this.stepLink_2 = new Element( "div", { styles : this.css.stepLink_2 }).inject(this.step_2);
  1287. this.step_3 = new Element( "div", {
  1288. styles : this.css.step_3,
  1289. text : "完成"
  1290. }).inject(stepsContainer);
  1291. },
  1292. gotoStep: function( step ){
  1293. var i;
  1294. for( i = 1; i<=step; i++ ){
  1295. this["step_"+i].setStyles( this.css["step_"+i+"_active"] );
  1296. if( i!==step && this["stepLink_"+i]){
  1297. this["stepLink_"+i].setStyles( this.css["stepLink_"+i+"_active"] );
  1298. }
  1299. }
  1300. for( i = step+1; i<=3; i++ ){
  1301. this["step_"+i].setStyles( this.css["step_"+i] );
  1302. if( i!==3 ){
  1303. this["stepLink_"+i].setStyles( this.css["stepLink_"+i] );
  1304. }
  1305. }
  1306. },
  1307. getCss : function(){
  1308. this.css = {
  1309. "loadingNode" : {
  1310. },
  1311. "textNode" : {
  1312. "margin-top" : "10px",
  1313. "font-size" : "12px",
  1314. "margin-left" : "10px"
  1315. },
  1316. "progressNode" : {
  1317. "margin" : "10px 0px",
  1318. "overflow" : "hidden"
  1319. },
  1320. "progressBack" : {
  1321. "float":"left",
  1322. "border-radius" : "10px",
  1323. "background-color" : "#f4f4f4",
  1324. "height" : "16px"
  1325. },
  1326. "progressFront" : {
  1327. "height" : "16px",
  1328. "background-color" : "#4a9adb"
  1329. },
  1330. "stepsContainer" : {
  1331. "margin-top" : "30px",
  1332. "margin-bottom" : "30px",
  1333. "margin-left" : "70px",
  1334. "overflow" : "hidden"
  1335. },
  1336. "stepLink_1" : {
  1337. "position" : "absolute",
  1338. "top" : "11px",
  1339. "left" : "42px",
  1340. "border-top" : "2px solid #b3b3b3",
  1341. "height" : "2px",
  1342. "width" : "150px"
  1343. },
  1344. "stepLink_1_active" : {
  1345. "position" : "absolute",
  1346. "top" : "11px",
  1347. "left" : "42px",
  1348. "border-top" : "2px solid #3c75b7",
  1349. "height" : "2px",
  1350. "width" : "150px"
  1351. },
  1352. "stepLink_2" : {
  1353. "position" : "absolute",
  1354. "top" : "11px",
  1355. "left" : "47px",
  1356. "border-top" : "2px solid #b3b3b3",
  1357. "height" : "2px",
  1358. "width" : "150px"
  1359. },
  1360. "stepLink_2_active" : {
  1361. "position" : "absolute",
  1362. "top" : "11px",
  1363. "left" : "47px",
  1364. "border-top" : "2px solid #3c75b7",
  1365. "height" : "2px",
  1366. "width" : "150px"
  1367. },
  1368. "step_1" : {
  1369. "float" : "left",
  1370. "position" : "relative",
  1371. "color" : "#b3b3b3",
  1372. "font-size" : "15px",
  1373. "width" : "165px",
  1374. "height" : "25px",
  1375. "padding-top" : "30px",
  1376. "background" : "url("+MWF.defaultPath+"/xDesktop/$Authentication/default/icon/pic_1_pre.png) 20px 1px no-repeat"
  1377. },
  1378. "step_1_active" : {
  1379. "float" : "left",
  1380. "position" : "relative",
  1381. "color" : "#3c75b7",
  1382. "font-size" : "15px",
  1383. "width" : "165px",
  1384. "height" : "25px",
  1385. "padding-top" : "30px",
  1386. "background" : "url("+MWF.defaultPath+"/xDesktop/$Authentication/default/icon/pic_1_nor.png ) 20px 1px no-repeat"
  1387. },
  1388. "step_2" : {
  1389. "float" : "left",
  1390. "position" : "relative",
  1391. "color" : "#b3b3b3",
  1392. "font-size" : "15px",
  1393. "width" : "175px",
  1394. "height" : "25px",
  1395. "padding-top" : "30px",
  1396. "background" : "url("+MWF.defaultPath+"/xDesktop/$Authentication/default/icon/pic_2_pre.png) 25px 1px no-repeat"
  1397. },
  1398. "step_2_active" : {
  1399. "float" : "left",
  1400. "position" : "relative",
  1401. "color" : "#3c75b7",
  1402. "font-size" : "15px",
  1403. "width" : "175px",
  1404. "height" : "25px",
  1405. "padding-top" : "30px",
  1406. "background" : "url("+MWF.defaultPath+"/xDesktop/$Authentication/default/icon/pic_2_nor.png ) 25px 1px no-repeat"
  1407. },
  1408. "step_3" : {
  1409. "float" : "left",
  1410. "position" : "relative",
  1411. "color" : "#b3b3b3",
  1412. "font-size" : "15px",
  1413. "width" : "50px",
  1414. "height" : "25px",
  1415. "padding-top" : "30px",
  1416. "background" : "url("+MWF.defaultPath+"/xDesktop/$Authentication/default/icon/pic_3_pre.png) 5px 1px no-repeat"
  1417. },
  1418. "step_3_active" : {
  1419. "float" : "left",
  1420. "position" : "relative",
  1421. "color" : "#3c75b7",
  1422. "font-size" : "15px",
  1423. "width" : "50px",
  1424. "height" : "25px",
  1425. "padding-top" : "30px",
  1426. "background" : "url("+MWF.defaultPath+"/xDesktop/$Authentication/default/icon/pic_3_nor.png ) 5px 1px no-repeat"
  1427. }
  1428. }
  1429. }
  1430. });
  1431. this.define("loadStatTable", function( container , batchName, unitLevel, unitName ){
  1432. container.empty();
  1433. if( !this.form.statJson ){
  1434. this.form.statJson = new StatJson(this);
  1435. }
  1436. if( !unitLevel && this.statTableOptions ){
  1437. unitLevel = this.statTableOptions.unitLevel
  1438. }
  1439. if( !unitName && this.statTableOptions ){
  1440. unitName = this.statTableOptions.unitName
  1441. }
  1442. this.form.statJson.loadTable( container, batchName, unitLevel, unitName );
  1443. });
  1444. var StatJson = new Class({
  1445. initialize: function ( context ) {
  1446. this.context = context;
  1447. if( this.context.data.statJson ){
  1448. this.json = JSON.parse(this.context.data.statJson);
  1449. }else{
  1450. this.json = {
  1451. total : {
  1452. publishedCount : 0,
  1453. errorCount : 0
  1454. },
  1455. batch: {}
  1456. }
  1457. }
  1458. },
  1459. submit : function(){
  1460. this.deleteEmptyUnit();
  1461. for( var key in this.json.batch ){
  1462. this.deleteEmptyUnit(key);
  1463. }
  1464. this.context.data.statJson = JSON.stringify(this.json);
  1465. },
  1466. addBatch : function( batchName, isSetCurrent ){
  1467. if( !this.json.batch[batchName] ){
  1468. this.json.batch[batchName] = {
  1469. publishedCount : 0,
  1470. errorCount : 0
  1471. };
  1472. }
  1473. if( isSetCurrent )this.currentBatch = this.json.batch[batchName];
  1474. },
  1475. deleteBatch : function( batchName ){
  1476. var json = this.json;
  1477. var batchData = json.batch[batchName];
  1478. if( batchData ){
  1479. if( batchData.publishedCount ){
  1480. json.total.publishedCount = json.total.publishedCount - batchData.publishedCount;
  1481. }
  1482. if( batchData.errorCount ){
  1483. json.total.errorCount = json.total.errorCount - batchData.errorCount;
  1484. }
  1485. this.reduceByBatchData( batchData );
  1486. delete this.json.batch[batchName];
  1487. }
  1488. },
  1489. reduceByBatchData : function( batchData ){
  1490. var totalData = this.json.total;
  1491. for( var key in batchData ){
  1492. if( key != "publishedCount" && key != "errorCount" ){
  1493. var totalD = totalData[key];
  1494. var batchD = batchData[key];
  1495. if( batchData.publishedCount )totalD.publishedCount = totalD.publishedCount - batchD.publishedCount;
  1496. if( batchData.errorCount )totalD.errorCount = totalD.errorCount - batchD.errorCount;
  1497. for( var key_2 in batchD ){
  1498. if( key_2 != "publishedCount" && key_2 != "errorCount" ){
  1499. var totalD_2 = totalD[key_2];
  1500. var batchD_2 = batchD[key_2];
  1501. if( batchD_2.publishedCount )totalD_2.publishedCount = totalD_2.publishedCount - batchD_2.publishedCount;
  1502. if( batchD_2.errorCount )totalD_2.errorCount = totalD_2.errorCount - batchD_2.errorCount;
  1503. for(var key_3 in batchD_2 ){
  1504. if( key_3 != "publishedCount" && key_3 != "errorCount" ) {
  1505. var totalD_3 = totalD_2[key_3];
  1506. var batchD_3 = batchD_2[key_3];
  1507. if( batchD_3.publishedCount )totalD_3.publishedCount = totalD_3.publishedCount - batchD_3.publishedCount;
  1508. if( batchD_3.errorCount )totalD_3.errorCount = totalD_3.errorCount - batchD_3.errorCount;
  1509. }
  1510. }
  1511. }
  1512. }
  1513. }
  1514. }
  1515. },
  1516. addData: function( cmsDocData ){
  1517. var d = cmsDocData;
  1518. var totalJson = this.json.total;
  1519. var batchJson = this.currentBatch;
  1520. if( d.docStatus == "published" ){
  1521. totalJson.publishedCount++;
  1522. batchJson.publishedCount++;
  1523. this.addCount( totalJson, d );
  1524. this.addCount( batchJson, d );
  1525. }else if( d.docStatus == "error" ){
  1526. totalJson.errorCount++;
  1527. batchJson.errorCount++;
  1528. }
  1529. },
  1530. addCount : function( json, d ){
  1531. if( d.city ){
  1532. var cityJson = json[ d.city ];
  1533. if( !cityJson ){
  1534. cityJson = json[ d.city ] = { publishedCount : 0 };
  1535. }
  1536. cityJson.publishedCount ++;
  1537. if( d.county ){
  1538. var countyJson = cityJson[ d.county ];
  1539. if( !countyJson ){
  1540. countyJson = cityJson[ d.county ] = { publishedCount : 0 };
  1541. }
  1542. countyJson.publishedCount ++;
  1543. if( d.branch ) {
  1544. var branchJson = countyJson[d.branch];
  1545. if (!branchJson) {
  1546. branchJson = countyJson[d.branch] = {publishedCount: 0};
  1547. }
  1548. branchJson.publishedCount++;
  1549. }
  1550. }
  1551. }else{
  1552. var city = "未设置组织";
  1553. var cityJson = json[ city ];
  1554. if( !cityJson ){
  1555. cityJson = json[ city ] = { publishedCount : 0 };
  1556. }
  1557. cityJson.publishedCount ++;
  1558. }
  1559. },
  1560. reduceCount : function( json, d ){
  1561. if( d.city ){
  1562. var cityJson = json[ d.city ];
  1563. if( !cityJson ){
  1564. cityJson = json[ d.city ] = { publishedCount : 0 };
  1565. }
  1566. cityJson.publishedCount --;
  1567. if( d.county ){
  1568. var countyJson = cityJson[ d.county ];
  1569. if( !countyJson ){
  1570. countyJson = cityJson[ d.county ] = { publishedCount : 0 };
  1571. }
  1572. countyJson.publishedCount --;
  1573. if( d.branch ) {
  1574. var branchJson = countyJson[d.branch];
  1575. if (!branchJson) {
  1576. branchJson = countyJson[d.branch] = {publishedCount: 0};
  1577. }
  1578. branchJson.publishedCount--;
  1579. }
  1580. }
  1581. }else{
  1582. var city = "未设置组织";
  1583. var cityJson = json[ city ];
  1584. if( !cityJson ){
  1585. cityJson = json[ city ] = { publishedCount : 0 };
  1586. }
  1587. cityJson.publishedCount--;
  1588. }
  1589. },
  1590. getCity : function(){
  1591. var totalJson = this.json.total;
  1592. var city = [];
  1593. for( var key in totalJson ){
  1594. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1595. if( totalJson[key].publishedCount > 0 ){
  1596. city.push(key);
  1597. }
  1598. }
  1599. }
  1600. return city;
  1601. },
  1602. getCounty : function( city ){
  1603. var totalJson = this.json.total;
  1604. var county = [];
  1605. if( totalJson[city] ){
  1606. var cityJson = totalJson[city];
  1607. for( var key in cityJson ){
  1608. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1609. if( cityJson[key].publishedCount > 0 ){
  1610. county.push(key);
  1611. }
  1612. }
  1613. }
  1614. }
  1615. return county;
  1616. },
  1617. getBranch : function( city, county ){
  1618. var totalJson = this.json.total;
  1619. var branch = [];
  1620. if( totalJson[city] ){
  1621. var cityJson = totalJson[city];
  1622. if( cityJson[county] ){
  1623. var countyJson = cityJson[county];
  1624. for( var key in countyJson ){
  1625. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1626. if( countyJson[key].publishedCount > 0 ){
  1627. branch.push(key);
  1628. }
  1629. }
  1630. }
  1631. }
  1632. }
  1633. return branch;
  1634. },
  1635. getAllCounty : function(){
  1636. var totalJson = this.json.total;
  1637. var county = [];
  1638. for(var key in totalJson ){
  1639. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1640. for( var key_2 in totalJson[key] ){
  1641. if( key_2 != "publishedCount" && key_2 != "errorCount" && key_2 != "未设置组织"){
  1642. if( totalJson[key][key_2].publishedCount > 0 ){
  1643. county.push(key_2);
  1644. }
  1645. }
  1646. }
  1647. }
  1648. }
  1649. return county;
  1650. },
  1651. getAllBranch : function(){
  1652. var totalJson = this.json.total;
  1653. var branch = [];
  1654. for(var key in totalJson ){
  1655. if( key != "publishedCount" && key != "errorCount" && key != "未设置组织"){
  1656. for( var key_2 in totalJson[key] ){
  1657. if( key_2 != "publishedCount" && key_2 != "errorCount" && key_2 != "未设置组织"){
  1658. for( var key_3 in totalJson[key][key_2] ){
  1659. if( key_3 != "publishedCount" && key_3 != "errorCount" && key_3 != "未设置组织"){
  1660. if( totalJson[key][key_2][key_3].publishedCount > 0 ){
  1661. branch.push(key_3);
  1662. }
  1663. }
  1664. }
  1665. }
  1666. }
  1667. }
  1668. }
  1669. return branch;
  1670. },
  1671. getUnitCount : function( unit, importBatchName ){
  1672. var data;
  1673. if( importBatchName && this.json.batch[importBatchName]) {
  1674. data = this.json.batch[importBatchName];
  1675. }else{
  1676. data = this.json.total;
  1677. }
  1678. if( !unit )return data.publishedCount;
  1679. for( var city in data ){
  1680. var cityData = data[city];
  1681. if( city == unit )return cityData.publishedCount;
  1682. for( var county in cityData ){
  1683. var countyData = cityData[county];
  1684. if( county == unit )return countyData.publishedCount;
  1685. for( var branch in countyData ){
  1686. var branchData = countyData[branch];
  1687. if( branch == unit )return branchData.publishedCount;
  1688. }
  1689. }
  1690. }
  1691. return 0;
  1692. },
  1693. changeData : function( newData, oldData, importBatchName ){
  1694. //var oldData = {
  1695. // status : "error",
  1696. // city : "",
  1697. // county : "",
  1698. // branch : ""
  1699. //};
  1700. var batchJson;
  1701. if( importBatchName && this.json.batch[importBatchName]) {
  1702. batchJson = this.json.batch[importBatchName];
  1703. }
  1704. var totalJson = this.json.total;
  1705. if( oldData.docStatus == "error" ){
  1706. totalJson.errorCount--;
  1707. if( batchJson )batchJson.errorCount--;
  1708. }
  1709. if( oldData.docStatus == "published" ){
  1710. totalJson.publishedCount--;
  1711. this.reduceCount( totalJson, oldData );
  1712. if( batchJson ){
  1713. batchJson.publishedCount--;
  1714. this.reduceCount( batchJson, oldData );
  1715. }
  1716. }
  1717. if( newData.docStatus == "error"){
  1718. totalJson.errorCount++;
  1719. if( batchJson )batchJson.errorCount++;
  1720. }
  1721. if( newData.docStatus == "published"){
  1722. totalJson.publishedCount++;
  1723. this.addCount( totalJson, newData );
  1724. if( batchJson ){
  1725. batchJson.publishedCount++;
  1726. this.addCount( batchJson, newData );
  1727. }
  1728. }
  1729. },
  1730. getPublishedCount : function( importBatchName ){
  1731. if( !importBatchName ){
  1732. return this.json.total.publishedCount;
  1733. }else{
  1734. if( this.json.batch[importBatchName]) {
  1735. var batchJson = this.json.batch[importBatchName];
  1736. return batchJson.publishedCount;
  1737. }
  1738. }
  1739. },
  1740. getErrorCount : function( importBatchName ){
  1741. if( !importBatchName ){
  1742. return this.json.total.errorCount;
  1743. }else{
  1744. if( this.json.batch[importBatchName]) {
  1745. var batchJson = this.json.batch[importBatchName];
  1746. return batchJson.errorCount;
  1747. }
  1748. }
  1749. },
  1750. deleteEmptyUnit : function( batchName ){
  1751. if( batchName ){
  1752. var data = this.json.batch[batchName];
  1753. }else{
  1754. var data = this.json.total;
  1755. }
  1756. for( var key in data ){
  1757. if( key != "publishedCount" && key != "errorCount" ){
  1758. var cityData = data[key];
  1759. if( !cityData.publishedCount && !cityData.errorCount ){
  1760. delete data[key]
  1761. }else{
  1762. for( var key_2 in cityData ){
  1763. if( key_2 != "publishedCount" && key_2 != "errorCount" ){
  1764. var countyData = cityData[key_2];
  1765. if( !countyData.publishedCount && !countyData.errorCount ){
  1766. delete data[key][key_2]
  1767. }else{
  1768. for(var key_3 in countyData ){
  1769. if( key_3 != "publishedCount" && key_3 != "errorCount" ) {
  1770. var branchData = countyData[key_3];
  1771. if( !branchData.publishedCount && !branchData.errorCount ) {
  1772. delete data[key][key_2][key_3]
  1773. }
  1774. }
  1775. }
  1776. }
  1777. }
  1778. }
  1779. }
  1780. }
  1781. }
  1782. },
  1783. getNoUnitJson : function( d ){
  1784. var data = Object.clone(d);
  1785. for( var key in data ){
  1786. if( key != "publishedCount" && key != "errorCount" ){
  1787. var cityData = data[key];
  1788. var cityCount = cityData.publishedCount;
  1789. var countyCount = 0;
  1790. for( var county in cityData ){
  1791. if( county != "publishedCount" && county != "errorCount" ){
  1792. var countyData = cityData[county];
  1793. countyCount = countyCount + countyData.publishedCount;
  1794. var branchCount = 0;
  1795. for( var branch in countyData ) {
  1796. if( branch != "publishedCount" && branch != "errorCount" ) {
  1797. var branchData = countyData[branch];
  1798. branchCount = branchCount + branchData.publishedCount
  1799. }
  1800. }
  1801. if( countyData.publishedCount > branchCount ){
  1802. countyData["未设置"] = { publishedCount : countyData.publishedCount - branchCount };
  1803. }
  1804. }
  1805. }
  1806. if( cityData.publishedCount > countyCount ){
  1807. cityData["未设置"] = { publishedCount : cityData.publishedCount - countyCount };
  1808. }
  1809. }
  1810. }
  1811. return data;
  1812. },
  1813. loadTable : function( container, batchName, unitLevel, unitName ){
  1814. if( !unitLevel ){
  1815. this._loadTable(container, batchName);
  1816. }else{
  1817. this._loadTableByUnit( container, batchName, unitLevel, unitName )
  1818. }
  1819. },
  1820. _loadTableByUnit : function(container, batchName, unitLevel, unitName ){
  1821. if (batchName) {
  1822. var d = this.json.batch[batchName];
  1823. } else {
  1824. var d = this.json.total;
  1825. }
  1826. var data = this.getNoUnitJson( d );
  1827. var table = this.table = new Element( "table", {
  1828. "width":"90%",
  1829. "border":"0",
  1830. "cellpadding":"5",
  1831. "cellspacing":"0",
  1832. "styles" : {"border-top" : "1px solid #ccc", "border-left" : "1px solid #ccc", "margin" : "20px auto 10px auto", "font-size":"14px"}
  1833. }).inject( container );
  1834. if( batchName ){
  1835. var timeStr = batchName.split("_")[1];
  1836. var year = timeStr.substring(0,4);
  1837. var month = timeStr.substring(4,6);
  1838. var date = timeStr.substring(6,8);
  1839. var hour = timeStr.substring(8,10);
  1840. var minture = timeStr.substring(10,12);
  1841. var second = timeStr.substring(12,14);
  1842. var title = year+"-"+month+"-"+date + " " + hour + ":" + minture + ":" + second + "批次数据统计"
  1843. }else{
  1844. var title = "数据统计";
  1845. }
  1846. if( unitLevel == "city" )this._loadTableByCity(title, data, table, unitName );
  1847. if( unitLevel == "county" )this._loadTableByCounty(title, data, table, unitName );
  1848. if( unitLevel == "branch" )this._loadTableByBranch(title, data, table, unitName );
  1849. },
  1850. _loadTableByCity : function(title, data, table, unitName){
  1851. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  1852. var tdTitleCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" , "font-size":"16px", "font-weight" : "bold"};
  1853. var tr = new Element("tr").inject( table );
  1854. new Element("td", { "styles": tdTitleCss, text : title, colspan:3 }).inject( tr );
  1855. var tr = new Element("tr").inject( table );
  1856. new Element("th", { "styles": tdCss, text : "市分" }).inject( tr );
  1857. new Element("th", { "styles": tdCss, text : "县分" }).inject( tr );
  1858. new Element("th", { "styles": tdCss, text : "网格" }).inject( tr );
  1859. for( var city in data ){
  1860. if( city != unitName )continue;
  1861. if( city != "publishedCount" && city!="errorCount" ){
  1862. var cityTr = new Element("tr").inject( table );
  1863. var cityData = data[city];
  1864. var cityShow = city == "未设置组织" ? "未设置" : city.split("@")[0];
  1865. var cityTd = new Element("td", { "styles": tdCss, text : cityShow + "(" + cityData.publishedCount + ")" }).inject( cityTr );
  1866. var citySpan = 1;
  1867. var countyIndex = 0;
  1868. var countyTr = null;
  1869. var countyTd = null;
  1870. var branchTd = null;
  1871. for( var county in cityData ){
  1872. if( county != "publishedCount" && county!="errorCount" ){
  1873. if( countyIndex != 0 ){
  1874. citySpan++;
  1875. countyTr = new Element("tr").inject( table );
  1876. }
  1877. countyIndex ++;
  1878. var countySpan = 1;
  1879. var countyData = cityData[county];
  1880. countyTd = new Element("td", { "styles": tdCss, text : county.split("@")[0] + "(" + countyData.publishedCount + ")" }).inject( countyTr || cityTr );
  1881. var branchIndex = 0;
  1882. var branchTr = null;
  1883. for( var branch in countyData ){
  1884. if( branch != "publishedCount" && branch!="errorCount" ) {
  1885. if( branchIndex != 0 ){
  1886. branchTr = new Element("tr").inject( table );
  1887. citySpan++;
  1888. countySpan++;
  1889. }
  1890. branchIndex++;
  1891. var branchData = countyData[branch];
  1892. branchTd = new Element("td", {"styles": tdCss, text: branch.split("@")[0]+ "(" + branchData.publishedCount + ")" }).inject( branchTr || countyTr || cityTr );
  1893. }
  1894. }
  1895. if( branchIndex == 0 ){
  1896. branchTd = new Element("td", { "styles": tdCss, text :"" }).inject( branchTr || countyTr || cityTr );
  1897. }
  1898. countyTd.set("rowspan",countySpan);
  1899. }
  1900. }
  1901. if( countyIndex == 0 ){
  1902. countyTd = new Element("td", { "styles": tdCss, text :"" }).inject( countyTr || cityTr );
  1903. }
  1904. if( !branchTd ){
  1905. new Element("td", { "styles": tdCss, text :"" }).inject( countyTr || cityTr );
  1906. }
  1907. cityTd.set("rowspan",citySpan);
  1908. }
  1909. }
  1910. },
  1911. _loadTableByCounty : function(title, data, table, unitName){
  1912. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  1913. var tdTitleCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" , "font-size":"16px", "font-weight" : "bold"};
  1914. var tr = new Element("tr").inject( table );
  1915. new Element("td", { "styles": tdTitleCss, text : title, colspan:2 }).inject( tr );
  1916. var tr = new Element("tr").inject( table );
  1917. new Element("th", { "styles": tdCss, text : "县分" }).inject( tr );
  1918. new Element("th", { "styles": tdCss, text : "网格" }).inject( tr );
  1919. for( var city in data ){
  1920. if( city != "publishedCount" && city!="errorCount" ){
  1921. var cityData = data[city];
  1922. var countyIndex = 0;
  1923. var countyTr = null;
  1924. var countyTd = null;
  1925. var branchTd = null;
  1926. for( var county in cityData ){
  1927. if( unitName != county )continue;
  1928. if( county != "publishedCount" && county!="errorCount" ){
  1929. countyTr = new Element("tr").inject( table );
  1930. countyIndex ++;
  1931. var countySpan = 1;
  1932. var countyData = cityData[county];
  1933. countyTd = new Element("td", { "styles": tdCss, text : county.split("@")[0] + "(" + countyData.publishedCount + ")" }).inject( countyTr );
  1934. var branchIndex = 0;
  1935. var branchTr = null;
  1936. for( var branch in countyData ){
  1937. if( branch != "publishedCount" && branch!="errorCount" ) {
  1938. if( branchIndex != 0 ){
  1939. branchTr = new Element("tr").inject( table );
  1940. countySpan++;
  1941. }
  1942. branchIndex++;
  1943. var branchData = countyData[branch];
  1944. branchTd = new Element("td", {"styles": tdCss, text: branch.split("@")[0]+ "(" + branchData.publishedCount + ")" }).inject( branchTr || countyTr );
  1945. }
  1946. }
  1947. if( branchIndex == 0 ){
  1948. branchTd = new Element("td", { "styles": tdCss, text :"" }).inject( branchTr || countyTr );
  1949. }
  1950. countyTd.set("rowspan",countySpan);
  1951. }
  1952. }
  1953. if( !branchTd && countyTr ){
  1954. new Element("td", { "styles": tdCss, text :"" }).inject( countyTr );
  1955. }
  1956. }
  1957. }
  1958. },
  1959. _loadTableByBranch : function(title, data, table, unitName){
  1960. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  1961. var tdTitleCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" , "font-size":"16px", "font-weight" : "bold"};
  1962. var tr = new Element("tr").inject( table );
  1963. new Element("td", { "styles": tdTitleCss, text : title }).inject( tr );
  1964. for( var city in data ){
  1965. if( city != "publishedCount" && city!="errorCount" ){
  1966. var cityData = data[city];
  1967. var branchTd = null;
  1968. for( var county in cityData ){
  1969. if( county != "publishedCount" && county!="errorCount" ){
  1970. var countyData = cityData[county];
  1971. for( var branch in countyData ){
  1972. if( branch != unitName )continue;
  1973. if( branch != "publishedCount" && branch!="errorCount" ) {
  1974. var branchTr = new Element("tr").inject( table );
  1975. var branchData = countyData[branch];
  1976. branchTd = new Element("td", {"styles": tdCss, text: branch.split("@")[0]+ "(" + branchData.publishedCount + ")" }).inject( branchTr );
  1977. }
  1978. }
  1979. }
  1980. }
  1981. }
  1982. }
  1983. },
  1984. _loadTable : function( container, batchName ) {
  1985. if (batchName) {
  1986. var d = this.json.batch[batchName];
  1987. } else {
  1988. var d = this.json.total;
  1989. }
  1990. var data = this.getNoUnitJson( d );
  1991. var tdCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" };
  1992. var tdTitleCss = { "border-right" : "1px solid #ccc", "border-bottom" : "1px solid #ccc", "text-align" : "center" , "font-size":"16px", "font-weight" : "bold"};
  1993. var table = this.table = new Element( "table", {
  1994. "width":"90%",
  1995. "border":"0",
  1996. "cellpadding":"5",
  1997. "cellspacing":"0",
  1998. "styles" : {"border-top" : "1px solid #ccc", "border-left" : "1px solid #ccc", "margin" : "20px auto 10px auto", "font-size":"14px"}
  1999. }).inject( container );
  2000. var tr = new Element("tr").inject( table );
  2001. if( batchName ){
  2002. var timeStr = batchName.split("_")[1];
  2003. var year = timeStr.substring(0,4);
  2004. var month = timeStr.substring(4,6);
  2005. var date = timeStr.substring(6,8);
  2006. var hour = timeStr.substring(8,10);
  2007. var minture = timeStr.substring(10,12);
  2008. var second = timeStr.substring(12,14);
  2009. var title = year+"-"+month+"-"+date + " " + hour + ":" + minture + ":" + second + "批次数据统计"
  2010. }else{
  2011. var title = "数据统计";
  2012. }
  2013. new Element("td", { "styles": tdTitleCss, text : title, colspan:3 }).inject( tr );
  2014. var tr = new Element("tr").inject( table );
  2015. new Element("td", { "styles": tdCss, text : "校验未通过(条)" }).inject( tr );
  2016. new Element("td", { "styles": tdCss, colspan:2, text : data.errorCount || "" }).inject( tr );
  2017. var tr = new Element("tr").inject( table );
  2018. new Element("td", { "styles": tdCss, text : "校验通过(条)" }).inject( tr );
  2019. new Element("td", { "styles": tdCss, colspan:2, text : data.publishedCount || "" }).inject( tr );
  2020. var tr = new Element("tr").inject( table );
  2021. new Element("th", { "styles": tdCss, text : "市分" }).inject( tr );
  2022. new Element("th", { "styles": tdCss, text : "县分" }).inject( tr );
  2023. new Element("th", { "styles": tdCss, text : "网格" }).inject( tr );
  2024. for( var city in data ){
  2025. if( city != "publishedCount" && city!="errorCount" ){
  2026. var cityTr = new Element("tr").inject( table );
  2027. var cityData = data[city];
  2028. var cityShow = city == "未设置组织" ? "未设置" : city.split("@")[0];
  2029. var cityTd = new Element("td", { "styles": tdCss, text : cityShow + "(" + cityData.publishedCount + ")" }).inject( cityTr );
  2030. var citySpan = 1;
  2031. var countyIndex = 0;
  2032. var countyTr = null;
  2033. var countyTd = null;
  2034. var branchTd = null;
  2035. for( var county in cityData ){
  2036. if( county != "publishedCount" && county!="errorCount" ){
  2037. if( countyIndex != 0 ){
  2038. citySpan++;
  2039. countyTr = new Element("tr").inject( table );
  2040. }
  2041. countyIndex ++;
  2042. var countySpan = 1;
  2043. var countyData = cityData[county];
  2044. countyTd = new Element("td", { "styles": tdCss, text : county.split("@")[0] + "(" + countyData.publishedCount + ")" }).inject( countyTr || cityTr );
  2045. var branchIndex = 0;
  2046. var branchTr = null;
  2047. for( var branch in countyData ){
  2048. if( branch != "publishedCount" && branch!="errorCount" ) {
  2049. if( branchIndex != 0 ){
  2050. branchTr = new Element("tr").inject( table );
  2051. citySpan++;
  2052. countySpan++;
  2053. }
  2054. branchIndex++;
  2055. var branchData = countyData[branch];
  2056. branchTd = new Element("td", {"styles": tdCss, text: branch.split("@")[0]+ "(" + branchData.publishedCount + ")" }).inject( branchTr || countyTr || cityTr );
  2057. }
  2058. }
  2059. if( branchIndex == 0 ){
  2060. branchTd = new Element("td", { "styles": tdCss, text :"" }).inject( branchTr || countyTr || cityTr );
  2061. }
  2062. countyTd.set("rowspan",countySpan);
  2063. }
  2064. }
  2065. if( countyIndex == 0 ){
  2066. countyTd = new Element("td", { "styles": tdCss, text :"" }).inject( countyTr || cityTr );
  2067. }
  2068. if( !branchTd ){
  2069. new Element("td", { "styles": tdCss, text :"" }).inject( countyTr || cityTr );
  2070. }
  2071. cityTd.set("rowspan",citySpan);
  2072. }
  2073. }
  2074. }
  2075. });
  2076. // this.define("setUploadedUnit", function( callback ){
  2077. // var workId = this.data.provinceWorkId || this.data.cityWorkId || this.data.countyWorkId;
  2078. // var unit = this.data.currentUnit;
  2079. // if( unit == "" && !this.data.newFlag ){
  2080. // unit = this.workContext.getWork().creatorUnitLevelName.split("/")[0];
  2081. // }
  2082. // var flag = this.data.flag || this.data.newFlag;
  2083. //
  2084. // var viewName;
  2085. // if( !flag ){
  2086. // viewName = "byCity";
  2087. // }else if( flag=="city" ){
  2088. // viewName = "byCounty";
  2089. // }else if( flag == "county" ){
  2090. // viewName = "byBranch"
  2091. // }
  2092. // var filter = [{
  2093. // "logic":"and",
  2094. // "path": "workId",
  2095. // "title": "workId",
  2096. // "comparison":"equals",
  2097. // "comparisonTitle":"等于",
  2098. // "value": workId,
  2099. // "formatType":"textValue"
  2100. // }];
  2101. // if( flag && unit){
  2102. // filter.push({
  2103. // "logic":"and",
  2104. // "path": flag,
  2105. // "title": flag,
  2106. // "comparison":"equals",
  2107. // "comparisonTitle":"等于",
  2108. // "value": unit,
  2109. // "formatType":"textValue"
  2110. // })
  2111. // }
  2112. // MWF.Actions.get("x_query_assemble_surface").loadView(viewName, "渠道-手机号码设置", {"filterList": filter }, function(json){
  2113. // //;
  2114. //
  2115. // var f;
  2116. // if( !flag ){
  2117. // f = "city";
  2118. // }else if( flag=="city" ){
  2119. // f = "county";
  2120. // }else if( flag == "county" ){
  2121. // f = "branch"
  2122. // }
  2123. // var array = []
  2124. // json.data.groupGrid.each( function(d){
  2125. // if( d.group.split("@").getLast().toLowerCase() == "u" ){
  2126. // array.push( d.group );
  2127. // }
  2128. // }.bind(this))
  2129. // this.data[f+"TaskPerson"] = array;
  2130. // this.form.save(function(){
  2131. // if(callback)callback()
  2132. // });
  2133. // }.bind(this));
  2134. // })