ImportExplorer.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  3. MWF.xDesktop.requireApp("Template", "MDomItem", null, false);
  4. MWF.xDesktop.requireApp("Selector", "package", null, false);
  5. MWF.xApplication.Attendance.ImportExplorer = new Class({
  6. Extends: MWF.xApplication.Attendance.Explorer,
  7. Implements: [Options, Events],
  8. initialize: function(node, app, actions, options){
  9. this.setOptions(options);
  10. this.app = app;
  11. this.path = "../x_component_Attendance/$ImportExplorer/";
  12. this.cssPath = "../x_component_Attendance/$ImportExplorer/"+this.options.style+"/css.wcss";
  13. this._loadCss();
  14. this.actions = actions;
  15. this.node = $(node);
  16. this.initData();
  17. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  18. },
  19. loadView : function(){
  20. this.view = new MWF.xApplication.Attendance.ImportExplorer.View(this.elementContentNode, this.app,this, this.viewData, this.options.searchKey );
  21. this.view.load();
  22. this.setContentSize();
  23. },
  24. createDocument: function(){
  25. if(this.view)this.view._createDocument();
  26. },
  27. importExcel : function(){
  28. //this.importer = new MWF.xApplication.Attendance.ImportExplorer.Importer( this );
  29. //this.importer.upload();
  30. this.upload();
  31. },
  32. upload : function(){
  33. if (!this.uploadFileAreaNode){
  34. this.uploadFileAreaNode = new Element("div");
  35. var html = "<input name=\"file\" type=\"file\"/>";
  36. this.uploadFileAreaNode.set("html", html);
  37. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  38. this.fileUploadNode.addEvent("change", function(){
  39. var files = fileNode.files;
  40. if (files.length){
  41. for (var i = 0; i < files.length; i++) {
  42. var file = files.item(i);
  43. var tmp = file.name.split(".");
  44. this.uploadFileName = file.name;
  45. if( tmp[tmp.length-1].toLowerCase() != "xls" && tmp[tmp.length-1].toLowerCase() != "xlsx" ){
  46. this.app.notice( this.app.lp.importExcelNotice ,"error");
  47. return;
  48. }
  49. var formData = new FormData();
  50. formData.append('file', file);
  51. this.actions.uploadAttachment( function( json ){
  52. var id = json.id;
  53. this.actions.getAttachmentInfo( id, function( info ){
  54. var progress = new MWF.xApplication.Attendance.ImportExplorer.Progress(id, this.actions, this.app);
  55. progress.load( function(){
  56. var form = new MWF.xApplication.Attendance.ImportExplorer.Result(this, info.data, { id : id }, { app : this.app , actions : this.app.restActions, css : {} });
  57. form.open();
  58. this.view.reload();
  59. }.bind(this))
  60. }.bind(this));
  61. }.bind(this), function(xhr, text, error){
  62. var errorText = error;
  63. if (xhr) errorText = xhr.responseText;
  64. this.app.notice( errorText,"error");
  65. }.bind(this), formData, file);
  66. }
  67. }
  68. }.bind(this));
  69. }
  70. var fileNode = this.uploadFileAreaNode.getFirst();
  71. fileNode.click();
  72. },
  73. checkData : function(){
  74. var selector = new MWF.xApplication.Attendance.ImportExplorer.YearMonthSelctor(this);
  75. selector.edit();
  76. },
  77. exportSourceData : function(){
  78. var selector = new MWF.xApplication.Attendance.ImportExplorer.ExportSourceData(this);
  79. selector.edit();
  80. },
  81. analyseData : function(){
  82. this.actions.analyseDetail("0","0",function(){
  83. this.app.notice( this.app.lp.analyseDataSuccess,"success")
  84. }.bind(this))
  85. },
  86. staticData : function(){
  87. this.actions.staticAllDetail(function(){
  88. this.app.notice( this.app.lp.statDataSuccess,"success")
  89. }.bind(this))
  90. },
  91. downloadTemplate : function(){
  92. window.open( o2.filterUrl(this.path + encodeURIComponent( "dataTemplate.xls" ), "_blank" ))
  93. },
  94. showDescription: function( el ){
  95. if( this.descriptionNode ){
  96. this.descriptionNode.setStyle("display","block");
  97. this.descriptionNode.position({
  98. relativeTo: el,
  99. position: 'bottomLeft',
  100. edge: 'upperCenter',
  101. offset:{
  102. x : -60,
  103. y : 0
  104. }
  105. });
  106. }else{
  107. this.descriptionNode = new Element("div", {"styles": this.css.descriptionNode}).inject(this.node);
  108. this.descriptionNode.position({
  109. relativeTo: el,
  110. position: 'bottomLeft',
  111. edge: 'upperCenter',
  112. offset:{
  113. x : -60,
  114. y : 0
  115. }
  116. });
  117. this.descriptionNode.addEvent("mousedown", function(e){e.stopPropagation();});
  118. document.body.addEvent("mousedown", function(){ this.descriptionNode.setStyle("display","none")}.bind(this));
  119. var table = new Element("table", {
  120. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "class" : "filterTable"
  121. }).inject( this.descriptionNode );
  122. var tr = new Element("tr").inject(table);
  123. new Element("td",{ "text" : this.app.lp.importDataStep , "styles" : this.css.descriptionTdHead }).inject(tr);
  124. Array.each( this.app.lp.importStepDescription, function( description ) {
  125. var tr = new Element("tr").inject(table);
  126. new Element("td",{ "text" :description , "styles" : this.css.descriptionTdValue }).inject(tr);
  127. }.bind(this));
  128. // var tr = new Element("tr").inject(table);
  129. // new Element("td",{ "text" :"1、下载Excel模板,根据模板格式填写考勤数据;" , "styles" : this.css.descriptionTdValue }).inject(tr);
  130. // var tr = new Element("tr").inject(table);
  131. // new Element("td",{ "text" : "2、点击导入考勤数据按钮,选择考勤数据并确定,系统将校验考勤数据是否正确并导入数据;" , "styles" : this.css.descriptionTdValue }).inject(tr);
  132. // var tr = new Element("tr").inject(table);
  133. // new Element("td",{ "text" : "3、点击核对考勤数据按钮,选择需要核对的年度和月份,系统将核对需要考勤的人员的数据;" , "styles" : this.css.descriptionTdValue }).inject(tr);
  134. // var tr = new Element("tr").inject(table);
  135. // new Element("td",{ "text" : "4、点击分析考勤数据按钮,系统将生成出勤明细数据;" , "styles" : this.css.descriptionTdValue }).inject(tr);
  136. // var tr = new Element("tr").inject(table);
  137. // new Element("td",{ "text" : "5、点击统计考勤数据按钮,系统将生成个人、部门、公司的出勤率统计。" , "styles" : this.css.descriptionTdValue }).inject(tr);
  138. }
  139. }
  140. });
  141. MWF.xApplication.Attendance.ImportExplorer.View = new Class({
  142. Extends: MWF.xApplication.Attendance.Explorer.View,
  143. _createItem: function(data){
  144. return new MWF.xApplication.Attendance.ImportExplorer.Document(this.table, data, this.explorer, this);
  145. },
  146. _getCurrentPageData: function(callback, count){
  147. this.actions.listAttachmentInfo(function(json){
  148. if (callback) callback(json);
  149. });
  150. },
  151. _removeDocument: function(document, all){
  152. this.actions.deleteAttachment(document.id, function(json){
  153. this.explorer.view.reload();
  154. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  155. }.bind(this));
  156. },
  157. _createDocument: function(){
  158. //var permission = new MWF.xApplication.Attendance.ImportExplorer.Importer(this.explorer);
  159. //permission.create();
  160. },
  161. _openDocument: function( documentData ){
  162. this.actions.getAttachmentStream( documentData.id )
  163. }
  164. });
  165. MWF.xApplication.Attendance.ImportExplorer.Document = new Class({
  166. Extends: MWF.xApplication.Attendance.Explorer.Document,
  167. openVaild : function( e ){
  168. //this.importer = new MWF.xApplication.Attendance.ImportExplorer.Importer( this );
  169. },
  170. openResult: function(){
  171. var form = new MWF.xApplication.Attendance.ImportExplorer.Result(this, this.data, { id : this.data.id }, { app : this.app , actions : this.app.restActions, css : {} });
  172. form.open();
  173. }
  174. });
  175. MWF.xApplication.Attendance.ImportExplorer.YearMonthSelctor = new Class({
  176. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  177. options : {
  178. "width": 500,
  179. "height": 300,
  180. "hasTop" : true,
  181. "hasBottom" : true,
  182. "title" : MWF.xApplication.Attendance.LP.selectCheckMonth,
  183. "draggable" : true,
  184. "closeAction" : true,
  185. },
  186. _createTableContent: function(){
  187. this.formTableContainer.setStyles({
  188. "width" : "300px"
  189. });
  190. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  191. //"<tr><td colspan='2' styles='formTableHead'>选择核对月份</td></tr>" +
  192. "<tr><td styles='formTabelTitle' lable='cycleYear'></td>"+
  193. " <td styles='formTableValue' item='cycleYear'></td></tr>" +
  194. "<tr><td styles='formTabelTitle' lable='cycleMonth'></td>"+
  195. " <td styles='formTableValue' item='cycleMonth'></td></tr>" +
  196. "</table>";
  197. this.formTableArea.set("html",html);
  198. MWF.xDesktop.requireApp("Template", "MForm", function(){
  199. this.form = new MForm( this.formTableArea, {}, {
  200. style : "attendance",
  201. isEdited : this.isEdited || this.isNew,
  202. itemTemplate : {
  203. cycleYear : {
  204. text: MWF.xApplication.Attendance.LP.annuaal,
  205. type : "select",
  206. selectValue : function(){
  207. var years = []; d = new Date();
  208. for(var i=0 ; i<5; i++){
  209. years.push(d.getFullYear());
  210. d.setFullYear(d.getFullYear()-1)
  211. }
  212. return years;
  213. }
  214. },
  215. cycleMonth : {
  216. text: MWF.xApplication.Attendance.LP.months,
  217. type : "select",
  218. defaultValue : function(){ return new Date().getMonth(); },
  219. selectValue : ["1","2","3","4","5","6","7","8","9","10","11","12"]
  220. }
  221. }
  222. }, this.app);
  223. this.form.load();
  224. }.bind(this), true);
  225. },
  226. _ok: function( data, callback ){
  227. this.app.restActions.checkDetail( data.cycleYear, data.cycleMonth, function(json){
  228. this.app.notice( MWF.xApplication.Attendance.LP.checkDetailSuccess );
  229. this.close();
  230. }.bind(this));
  231. }
  232. });
  233. MWF.xApplication.Attendance.ImportExplorer.ExportSourceData = new Class({
  234. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  235. options : {
  236. "width": 500,
  237. "height": 300,
  238. "hasTop" : true,
  239. "hasBottom" : true,
  240. "title" : MWF.xApplication.Attendance.LP.selectExportMonth,
  241. "draggable" : true,
  242. "closeAction" : true,
  243. },
  244. _createTableContent: function(){
  245. this.formTableContainer.setStyles({
  246. "width" : "300px"
  247. });
  248. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  249. "<tr><td styles='formTabelTitle' lable='cycleYear'></td>"+
  250. " <td styles='formTableValue' item='cycleYear'></td></tr>" +
  251. "<tr><td styles='formTabelTitle' lable='cycleMonth'></td>"+
  252. " <td styles='formTableValue' item='cycleMonth'></td></tr>" +
  253. "</table>";
  254. this.formTableArea.set("html",html);
  255. MWF.xDesktop.requireApp("Template", "MForm", function(){
  256. this.form = new MForm( this.formTableArea, {}, {
  257. style : "attendance",
  258. isEdited : this.isEdited || this.isNew,
  259. itemTemplate : {
  260. cycleYear : {
  261. text: MWF.xApplication.Attendance.LP.annuaal,
  262. type : "select",
  263. selectValue : function(){
  264. var years = []; d = new Date();
  265. for(var i=0 ; i<5; i++){
  266. years.push(d.getFullYear());
  267. d.setFullYear(d.getFullYear()-1)
  268. }
  269. return years;
  270. }
  271. },
  272. cycleMonth : {
  273. text: MWF.xApplication.Attendance.LP.months,
  274. type : "select",
  275. defaultValue : function(){ return new Date().getMonth(); },
  276. selectValue : ["1","2","3","4","5","6","7","8","9","10","11","12"]
  277. }
  278. }
  279. }, this.app);
  280. this.form.load();
  281. }.bind(this), true);
  282. },
  283. _ok: function( data, callback ){
  284. var cycleMonth = data.cycleMonth;
  285. if(parseInt(cycleMonth)<10){
  286. cycleMonth = "0"+cycleMonth;
  287. }
  288. debugger;
  289. this.app.restActions.exportSourceDetail( data.cycleYear, cycleMonth, function(json){
  290. this.close();
  291. }.bind(this));
  292. }
  293. });
  294. MWF.xApplication.Attendance.ImportExplorer.Result = new Class({
  295. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  296. options : {
  297. "width": 800,
  298. "height": 600,
  299. "hasTop" : true,
  300. "hasBottom" : false,
  301. "title" : MWF.xApplication.Attendance.LP.importDataResult,
  302. "draggable" : true,
  303. "closeAction" : true,
  304. "closeByClickMask" : true,
  305. "resizeable" : true,
  306. "maxAction" : true,
  307. "id" : ""
  308. },
  309. _createTableContent: function(){
  310. this.actions.getImportStatusDetail( this.options.id, function( json ){
  311. this.checkData = json.data;
  312. this.createImportContent();
  313. }.bind(this));
  314. },
  315. createImportContent : function(){
  316. this.formTableContainer.setStyle("width","90%");
  317. var lp = MWF.xApplication.Attendance.LP;
  318. if( this.checkData.errorCount == 0 ){
  319. var text = lp.importDataResultSuccess.replace("{fileName}", this.data.fileName ).
  320. replace("{count}", this.checkData.detailList.length);
  321. } else{
  322. var text = lp.importDataResultFail.replace("{fileName}",this.data.fileName ).
  323. replace("{errorCount}", this.checkData.errorCount).
  324. replace("{count}", this.checkData.detailList.length);
  325. // var text ="您上传的文件:“" + this.data.fileName + "”未通过校验,有"+ this.checkData.errorCount +"条错误数据。请修改后重新导入。下面显示其中的"+this.checkData.detailList.length+"条:" ;
  326. }
  327. this.formDescriptionNode = new Element("div", {
  328. "styles": this.css.formDescriptionNode,
  329. "text" : text
  330. }).inject(this.formTableArea);
  331. var table = new Element("table", {
  332. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.explorer.css.editTable, "class" : "editTable"
  333. }).inject( this.formTableArea );
  334. var tr = new Element("tr").inject(table);
  335. var td;
  336. Array.each( lp.importDataResultThList, function(text){
  337. td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : text }).inject(tr);
  338. }.bind(this));
  339. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "行号" }).inject(tr);
  340. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "员工号" }).inject(tr);
  341. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "员工名字" }).inject(tr);
  342. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "日期" }).inject(tr);
  343. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "上午上班打卡时间" }).inject(tr);
  344. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "上午下班打卡时间" }).inject(tr);
  345. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "下午上班打卡时间" }).inject(tr);
  346. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "下午下班打卡时间" }).inject(tr);
  347. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "检查结果" }).inject(tr);
  348. // var td = new Element("td", { "styles" : this.explorer.css.editTableTitle, "text" : "描述" }).inject(tr);
  349. // td.setStyle( "width" , "300px" );
  350. this.checkData.detailList.each(function( d ){
  351. var tr = new Element("tr").inject(table);
  352. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.curRow }).inject(tr);
  353. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.employeeNo }).inject(tr);
  354. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.employeeName.split('@')[0] }).inject(tr);
  355. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.recordDateString }).inject(tr);
  356. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.onDutyTime }).inject(tr);
  357. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.morningOffDutyTime }).inject(tr);
  358. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.afternoonOnDutyTime }).inject(tr);
  359. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.offDutyTime }).inject(tr);
  360. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.checkStatus == "error" ? lp.false : lp.true }).inject(tr);
  361. var td = new Element("td", { "styles" : this.explorer.css.editTableValue , "text": d.description }).inject(tr);
  362. }.bind(this))
  363. }
  364. });
  365. MWF.xApplication.Attendance.ImportExplorer.Progress = new Class({
  366. initialize : function( id, actions, app ){
  367. this.id = id;
  368. this.actions = actions;
  369. this.app = app;
  370. },
  371. load : function( callback ){
  372. var lp = MWF.xApplication.Attendance.LP;
  373. this.currentDate = new Date();
  374. if(layout.desktop.message){
  375. this.addFormDataMessage();
  376. }else{
  377. this.app.notice(lp.importDataTitle);
  378. MWF.require("o2.widget.Mask", null, false);
  379. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  380. this.mask.loadNode(this.app.content);
  381. }
  382. this.status = "ready";
  383. this.intervalId = setInterval( function(){
  384. this.actions.getImportStatus( this.id, function( json ){
  385. var data = json.data;
  386. if( layout.desktop.message ){
  387. if( data.processing && data.currentProcessName !== "COMPLETE"){
  388. if( data.currentProcessName === "VALIDATE" ){
  389. if( this.status !== data.currentProcessName ){
  390. this.setMessageTitle( lp.checkDataTitle );
  391. this.setMessageText( lp.checkDataContent.replace( "{count}", data.process_validate_total));
  392. this.status = data.currentProcessName;
  393. }
  394. this.updateProgress( data.currentProcessName, data.process_validate_count, data.process_validate_total, data.errorCount );
  395. }else if( data.currentProcessName === "SAVEDATA" ){
  396. if( this.status !== data.currentProcessName ){
  397. this.setMessageTitle(lp.importDataTitle);
  398. this.setMessageText(lp.importDataContent.replace("{count}", data.process_save_total));
  399. this.status = data.currentProcessName;
  400. }
  401. this.updateProgress( data.currentProcessName, data.process_save_count, data.process_save_total, data.errorCount );
  402. }
  403. }else{
  404. this.status = data.currentProcessName;
  405. clearInterval( this.intervalId );
  406. this.transferComplete( data );
  407. if( callback )callback();
  408. }
  409. }else{
  410. if( data.processing && data.currentProcessName !== "COMPLETE"){
  411. if( data.currentProcessName === "VALIDATE" ){
  412. if( this.status !== data.currentProcessName ){
  413. this.status = data.currentProcessName;
  414. }
  415. }else if( data.currentProcessName === "SAVEDATA" ){
  416. if( this.status !== data.currentProcessName ){
  417. this.status = data.currentProcessName;
  418. }
  419. }
  420. }else{
  421. // this.app.notice(lp.importSuccessTitle);
  422. this.status = data.currentProcessName;
  423. clearInterval( this.intervalId );
  424. if (this.mask) this.mask.hide();
  425. if( callback )callback();
  426. }
  427. }
  428. }.bind(this), null)
  429. }.bind(this), 500 );
  430. },
  431. addFormDataMessage: function( noProgress ){
  432. var lp = MWF.xApplication.Attendance.LP;
  433. var contentHTML = "";
  434. if (noProgress){
  435. contentHTML = "<div style=\"height: 20px; line-height: 20px\">"+lp.readyToImportData1+"</div></div>" ;
  436. }else{
  437. contentHTML = "<div style=\"overflow: hidden\"><div style=\"height: 3px; border:1px solid #999; margin: 3px 0px\">" +
  438. "<div style=\"height: 3px; background-color: #acdab9; width: 0px;\"></div></div>" +
  439. "<div style=\"height: 20px; line-height: 20px\">"+lp.readyToImportData1+"</div></div>" ;
  440. }
  441. var msg = {
  442. "subject": lp.readyToImportData,
  443. "content": contentHTML
  444. };
  445. this.messageItem = layout.desktop.message.addMessage(msg);
  446. this.messageItem.status = "ready";
  447. window.setTimeout(function(){
  448. if (!layout.desktop.message.isShow) layout.desktop.message.show();
  449. }.bind(this), 100);
  450. },
  451. updateProgress: function(type, loaded, total, errorCount){
  452. var lp = MWF.xApplication.Attendance.LP;
  453. var messageItem = this.messageItem;
  454. var processed = errorCount ? ( loaded + errorCount ) : loaded;
  455. var percent = 100*(processed/total);
  456. var sendDate = new Date();
  457. var lastDate = this.lastTime || this.currentDate;
  458. var ms = sendDate.getTime() - lastDate.getTime();
  459. var speed = ( (processed - ( this.lastProcessed || 0 )) * 1000)/ms ;
  460. var u = lp.importSpeed;
  461. speed = speed.round(2);
  462. if (messageItem.contentNode){
  463. var progressNode = messageItem.contentNode.getFirst("div").getFirst("div");
  464. var progressPercentNode = progressNode.getFirst("div");
  465. var progressInforNode = messageItem.contentNode.getFirst("div").getLast("div");
  466. progressPercentNode.setStyle("width", ""+percent+"%");
  467. if( type == "VALIDATE" ){
  468. var text = lp.checkingDataContent.replace("{speed}",speed).replace("{total}",total).replace("{remaining}",( total - loaded ));
  469. text += errorCount ? lp.checkingDataErrorContent.replace("{errorCount}",errorCount) : "";
  470. // var text = "正检查数据"+": "+speed+u + ",共"+total+"条,剩余"+( total - loaded )+"条";
  471. // text += errorCount ? ",出错"+errorCount+"条" : ""
  472. }else{
  473. var text = lp.importingDataContent.replace("{speed}",speed).replace("{total}",total).replace("{remaining}",( total - loaded ));
  474. text += errorCount ? lp.importingDataErrorContent.replace("{errorCount}",errorCount) : "";
  475. // var text = "正导入数据"+": "+speed+u + ",共"+total+"条,剩余"+( total - loaded )+"条";
  476. // text += errorCount ? ",出错"+errorCount+"条" : ""
  477. }
  478. progressInforNode.set("text", text);
  479. }
  480. this.lastProcessed = processed;
  481. this.lastTime = new Date();
  482. },
  483. transferComplete: function( data ){
  484. var lp = MWF.xApplication.Attendance.LP;
  485. var errorCount = data.errorCount;
  486. var messageItem = this.messageItem;
  487. var sendDate = new Date();
  488. var ms = sendDate.getTime()-this.currentDate.getTime();
  489. var timeStr = "";
  490. if (ms>3600000){
  491. var h = ms/3600000;
  492. var m_s = ms % 3600000;
  493. var m = m_s / 60000;
  494. var s_s = m_s % 60000;
  495. var s = s_s/1000;
  496. timeStr = ""+h.toInt()+lp.hour+m.toInt()+lp.mintue+s.toInt()+lp.second;
  497. }else if (ms>60000){
  498. var m = ms / 60000;
  499. var s_s = ms % 60000;
  500. var s = s_s/1000;
  501. timeStr = ""+m.toInt()+lp.mintue+s.toInt()+lp.second;
  502. }else{
  503. var s = ms/1000;
  504. timeStr = ""+s.toInt()+lp.second;
  505. }
  506. if( errorCount == 0 ){
  507. var size = data.process_save_total;
  508. var speed = (size * 1000)/ms ;
  509. var u = lp.importSpeed;
  510. speed = speed.round(2);
  511. this.setMessageTitle( lp.importSuccessTitle );
  512. var text = lp.importSuccessContent.replace("{total}",size).replace("{speed}",speed).replace("{timeStr}",timeStr);
  513. this.setMessageText( text );
  514. // this.setMessageText( "共导入数据"+size+"条 速度"+": "+speed+u+" "+"耗时"+": "+timeStr);
  515. }else{
  516. var size = data.process_validate_total;
  517. this.setMessageTitle( lp.importFailTitle );
  518. var text = lp.importFailContent.replace("{total}",size).replace("{errorCount}",errorCount).replace("{timeStr}",timeStr);
  519. this.setMessageText( text );
  520. // this.setMessageText( "共有数据"+size+"条 出错"+ errorCount +"条 耗时"+": "+timeStr +" 请修改后重新导入");
  521. }
  522. this.clearMessageProgress();
  523. },
  524. setMessageText: function( text){
  525. var progressPercentNode = this.getProgessNode().getFirst("div");
  526. this.getProgressInforNode().set("text", text);
  527. this.messageItem.dateNode.set("text", (new Date()).format("db"));
  528. },
  529. setMessageTitle: function( text){
  530. this.messageItem.subjectNode.set("text", text);
  531. },
  532. clearMessageProgress: function(){
  533. var progressNode = this.getProgessNode();
  534. progressNode.destroy();
  535. },
  536. getProgessNode : function(){
  537. if(!this.progressNode)this.progressNode = this.messageItem.contentNode.getFirst("div").getFirst("div");
  538. return this.progressNode;
  539. },
  540. getProgressInforNode : function(){
  541. if(!this.progressInforNode)this.progressInforNode = this.messageItem.contentNode.getFirst("div").getLast("div");
  542. return this.progressInforNode;
  543. }
  544. });