Import.js 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.Import', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil','erp.util.GridUtil'],
  5. views: ['common.init.Template', 'core.button.UpExcel', 'core.trigger.DbfindTrigger', 'core.trigger.MultiDbfindTrigger',
  6. 'core.toolbar.Toolbar'],
  7. init: function(){
  8. var me = this;
  9. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  10. me.GridUtil = Ext.create('erp.util.GridUtil');
  11. this.control({
  12. 'form[id=upexcel]': {
  13. afterrender: function(btn){
  14. btn.upexcel = function(field){
  15. if(btn.grid){
  16. btn.getForm().submit({
  17. url: basePath + 'system/initImport.action?caller=' + btn.grid.caller,
  18. waitMsg: "正在解析Excel",
  19. success: function(fp, o){
  20. field.reset();
  21. btn.grid.ilid = o.result.ilid;
  22. btn.grid.down('pagingtoolbar').dataCount = o.result.count;
  23. btn.grid.down('pagingtoolbar').onLoad();
  24. btn.grid.getGridData(1);
  25. Ext.getCmp('check').show();
  26. },
  27. failure: function(fp, o){
  28. if(o.result.size){
  29. showError(o.result.error + " " + Ext.util.Format.fileSize(o.result.size));
  30. field.reset();
  31. } else {
  32. showError(o.result.error);
  33. field.reset();
  34. }
  35. }
  36. });
  37. }
  38. };
  39. }
  40. },
  41. 'button[id=export]': {
  42. click: function(btn){
  43. var grid = btn.ownerCt.ownerCt.down('gridpanel');
  44. if(grid){
  45. window.location = basePath + 'system/initTemplate.xls?caller=' + grid.caller +
  46. '&title=' + (grid.ownerCt.title.replace(/»/g, '/'));
  47. }
  48. }
  49. },
  50. 'button[id=rule]': {
  51. click: function(btn){
  52. me.showRule(btn.ownerCt.ownerCt.down('gridpanel'));
  53. }
  54. },
  55. 'button[id=check]': {
  56. click: function(btn){
  57. var grid = btn.ownerCt.ownerCt.down('gridpanel');
  58. if(grid && grid.down('pagingtoolbar').dataCount<=0) showMessage('提示', '无数据');
  59. else if(grid) me.checkdata(grid);
  60. }
  61. },
  62. 'button[id=history]': {
  63. click: function(btn){
  64. var grid = btn.ownerCt.ownerCt.down('gridpanel');
  65. if(grid){
  66. me.showHistory(grid.caller);
  67. }
  68. }
  69. },
  70. 'checkbox[id=onlyerror]': {
  71. change: function(f){
  72. var grid = f.ownerCt.ownerCt.down('gridpanel');
  73. if(grid) {/*
  74. if(f.checked) {
  75. grid.store.filterBy(function(item) {
  76. return !Ext.isEmpty(item.get('log'));
  77. });
  78. } else {
  79. grid.store.filterBy(function(item) {
  80. return true;
  81. });
  82. }
  83. */
  84. grid.getGridData(1);
  85. }
  86. }
  87. },
  88. 'button[id=toformal]': {
  89. click: function(btn){
  90. var grid = btn.ownerCt.ownerCt.down('gridpanel');
  91. if(grid && grid.ilid > 0) {
  92. if(grid.errorNodes && grid.errorNodes.length > 0) {
  93. showMessage('提示', '测试未通过,无法转入正式');
  94. } else {
  95. me.toformal(grid);
  96. }
  97. }
  98. }
  99. },
  100. /*'button[id=errdelete]': {
  101. click: function(btn){
  102. var grid = btn.ownerCt.ownerCt.down('gridpanel');
  103. if(grid && grid.ilid > 0) {
  104. me.deleteErrors(grid);
  105. }
  106. }
  107. },
  108. 'button[id=saveupdates]': {
  109. click: function(btn){
  110. var grid = btn.ownerCt.ownerCt.down('gridpanel');
  111. if(grid && grid.ilid > 0) {
  112. me.saveUpdates(grid);
  113. }
  114. }
  115. },*/
  116. 'button[id=errdownload]': {
  117. click: function(btn){
  118. var grid = btn.ownerCt.ownerCt.down('gridpanel');
  119. if(grid && grid.ilid > 0) {
  120. grid.store.filterBy(function(item) {
  121. return !Ext.isEmpty(item.get('log'));
  122. });
  123. me.BaseUtil.exportGrid(grid, btn.ownerCt.ownerCt.title);
  124. }
  125. }
  126. },
  127. '#template': {
  128. afterrender: function(p) {
  129. this.getDetails(p, caller, false);
  130. }
  131. }
  132. });
  133. },
  134. getDetails: function(p, caller, isReload){
  135. if(caller != p.caller || isReload){
  136. p.caller = caller;
  137. var me = this;
  138. Ext.Ajax.request({
  139. url: basePath + 'system/initDetails.action',
  140. params: {
  141. caller: caller
  142. },
  143. method: 'post',
  144. callback: function(options, success, response){
  145. var res = new Ext.decode(response.responseText);
  146. if(res.exceptionInfo != null){
  147. Ext.getCmp('upexcel').hide();
  148. showError(res.exceptionInfo);return;
  149. } else {
  150. p.removeAll();
  151. var store = me.emptyData(res.data);
  152. p.add({
  153. xtype: 'grid',
  154. id: 'template-data',
  155. anchor: "100% 100%",
  156. cls: 'custom',
  157. caller: caller,
  158. ilid: -1,
  159. cfg: res.data,//当前导入项的配置信息
  160. columnLines: true,
  161. columns: me.parseInitDetails(res.data),
  162. store: store,
  163. dockedItems: [me.getDockedItems(store)],
  164. getGridData: function(page){
  165. var f = Ext.getCmp('onlyerror');
  166. if(f.checked) {
  167. me.loadErrData(this, page);
  168. }else {
  169. me.loadInitData(this, page);
  170. }
  171. },
  172. loadData: function(ilid, count, page){
  173. this.ilid = ilid;
  174. this.down('pagingtoolbar').dataCount = count;
  175. this.down('pagingtoolbar').onLoad();
  176. this.getGridData(page);
  177. Ext.getCmp('errdownload').show();
  178. Ext.getCmp('onlyerror').show();
  179. Ext.getCmp('toformal').show();
  180. /*Ext.getCmp('errdelete').show();
  181. Ext.getCmp('saveupdates').show();*/
  182. Ext.getCmp('check').show();
  183. },
  184. deleteData: function(ilid){
  185. me.ondelete(ilid);
  186. },
  187. reset: function(){
  188. this.ilid = -1;
  189. this.down('pagingtoolbar').dataCount = 25;
  190. this.down('pagingtoolbar').onLoad();
  191. this.store.removeAll(true);
  192. this.store.loadData([{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]);
  193. },
  194. showErrors: function(){
  195. var grid = this,items = grid.store.data.items,
  196. columns = grid.columns,d,nodes = grid.errorNodes,log = '';
  197. if(nodes && nodes.length > 0) {
  198. grid.errorArray = me.getMixedGroups(nodes);
  199. Ext.each(items, function(item, index){
  200. d = item.data;
  201. log = '';
  202. Ext.each(columns, function(c, idx){
  203. var e = d.id_id+':'+c.dataIndex;
  204. e = e.toLowerCase();
  205. var errorGrid = grid.errorArray[e];
  206. if(errorGrid){
  207. if(log == '') {
  208. log = '<table class="custom-log">';
  209. log += '<tr class="custom-tr"><td>字段</td><td>值</td>' +
  210. '<td>规则</td><td>数据类型</td>' +
  211. '<td>是否必填</td>' +
  212. '<td>逻辑</td>' +
  213. '</tr>';
  214. }
  215. /*if(idx > 0 && errorGrid.groups){
  216. log += '<tr><td>' + c.text + '</td><td><font color=red>'
  217. + d[c.dataIndex] + '</td><td><font color=blue>'
  218. + (c.rule || '') + '</font></td><td><font color=blue>'
  219. + c.dataType + '</font></td><td><font color=blue>'
  220. + c.isNeed + '</font></td><td><font color=red>' ;
  221. var dat='';
  222. Ext.each(errorGrid.groups, function(da) {
  223. if(da!=null && da!=''){
  224. dat += da+"<br>";
  225. }else{
  226. dat+= c.logicdesc+"<br>";
  227. }
  228. });
  229. log +=dat +'</font></td></tr>';
  230. }*/
  231. Ext.each(errorGrid.groups, function(da) {
  232. if(idx > 0){
  233. if(da!=null && da!=''){
  234. log += '<tr><td>' + c.text + '</td><td><font color=red>'
  235. + d[c.dataIndex] + '</td><td><font color=blue>'
  236. + '' + '</font></td><td><font color=blue>'
  237. + c.dataType + '</font></td><td><font color=blue>'
  238. + '' + '</font></td><td><font color=red>'
  239. + da +'</font></td></tr>';
  240. }else{
  241. log += '<tr><td>' + c.text + '</td><td><font color=red>'
  242. + d[c.dataIndex] + '</td><td><font color=blue>'
  243. + (c.rule || '') + '</font></td><td><font color=blue>'
  244. + c.dataType + '</font></td><td><font color=blue>'
  245. + c.isNeed + '</font></td><td><font color=red>'
  246. + c.logicdesc +'</font></td></tr>';
  247. }
  248. }
  249. });
  250. }
  251. });
  252. if(log != '') {
  253. log += '</table>';
  254. }
  255. item.set('log', log);
  256. });
  257. }
  258. },
  259. plugins: [{
  260. ptype: 'rowexpander',
  261. rowBodyTpl : [
  262. '<p><b>校验状态:</b> {log}</p><br>'
  263. ],
  264. toggleRow: function(rowIdx) {
  265. var rowNode = this.view.getNode(rowIdx),
  266. row = Ext.get(rowNode),
  267. nextBd = Ext.get(row).down(this.rowBodyTrSelector),
  268. record = this.view.getRecord(rowNode),
  269. grid = this.getCmp();
  270. if (row.hasCls(this.rowCollapsedCls)) {
  271. row.removeCls(this.rowCollapsedCls);
  272. nextBd.removeCls(this.rowBodyHiddenCls);
  273. this.recordsExpanded[record.internalId] = true;
  274. this.view.fireEvent('expandbody', rowNode, record, nextBd.dom);
  275. } else {
  276. row.addCls(this.rowCollapsedCls);
  277. nextBd.addCls(this.rowBodyHiddenCls);
  278. this.recordsExpanded[record.internalId] = false;
  279. this.view.fireEvent('collapsebody', rowNode, record, nextBd.dom);
  280. }
  281. this.view.up('gridpanel').invalidateScroller();
  282. this.view.up('gridpanel').doComponentLayout();
  283. }
  284. }, Ext.create('Ext.grid.plugin.CellEditing', {
  285. clicksToEdit: 1
  286. })]
  287. });
  288. var btn = Ext.getCmp('upexcel');
  289. if(btn) {
  290. btn.show();
  291. btn.grid = p.down('gridpanel');
  292. }
  293. }
  294. }
  295. });
  296. }
  297. },
  298. parseInitDetails: function(arr){
  299. var me = this, d = new Array(),o;
  300. d.push({xtype: 'rownumberer', width: 35});
  301. d.push({
  302. text: '导入日志',
  303. dataIndex: 'log',
  304. hidden: true,
  305. renderer: function(val, meta){
  306. meta.style = 'height:0px;';
  307. }
  308. });
  309. d.push({
  310. text: 'ID',
  311. dataIndex: 'id_id',
  312. hidden: true
  313. });
  314. Ext.each(arr, function(a){
  315. o = new Object();
  316. o.text = a.id_caption;
  317. o.dataIndex = a.id_field;
  318. o.hidden = a.id_visible == 0;
  319. o.width = a.id_width;
  320. o.rule = a.id_rule;
  321. o.dataType = a.id_type;
  322. o.isNeed = a.id_need == 1 ? '是' : '否';
  323. o.logic = a.id_logic;
  324. o.logicdesc = me.parseLogic(o.logic);
  325. o.editor = {
  326. xtype: 'textfield'
  327. };
  328. if(/combo(.)/.test(o.logic)){
  329. var s = o.logic.substring(6, o.logic.lastIndexOf(')')).split(','),
  330. da = new Array();
  331. Ext.each(s, function(t){
  332. da.push({
  333. display: t,
  334. value: t
  335. });
  336. });
  337. o.editor = {
  338. xtype: 'combobox',
  339. displayField: 'display',
  340. valueField: 'value',
  341. queryMode: 'local',
  342. editable: false,
  343. store: Ext.create('Ext.data.Store', {
  344. fields: ['display', 'value'],
  345. data : da
  346. })
  347. };
  348. }
  349. o.renderer = function(val, meta, record, x, y, store, view){
  350. if(view) {
  351. var grid = view.ownerCt,errorArray = grid.errorArray,cm = grid.columns[y];
  352. if(errorArray && y > 0 && !!record.get('log') && errorArray[record.data['id_id'] + ':' + (cm.dataIndex).toLowerCase()]){
  353. meta.tdCls = 'x-td-warn';
  354. meta.tdAttr = 'data-qtip="' + (cm.rule || cm.dataType) + '"';
  355. }else
  356. meta.tdCls = '';
  357. }
  358. return val;
  359. };
  360. d.push(o);
  361. });
  362. return d;
  363. },
  364. emptyData: function(arr){
  365. var fields = new Array();
  366. Ext.each(arr, function(a){
  367. fields.push(a.id_field);
  368. });
  369. return new Ext.data.Store({
  370. fields: fields,
  371. data: [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]
  372. });
  373. },
  374. getDockedItems: function(store){
  375. return {
  376. xtype: 'pagingtoolbar',
  377. store: store,
  378. pageSize: 100,
  379. dataCount: store.data.items.length,
  380. page: 1,
  381. dock: 'bottom',
  382. displayInfo: true,
  383. updateInfo : function(){
  384. var page = this.child('#inputItem').getValue() || 1;
  385. var me = this,
  386. pageSize = me.pageSize || 100,
  387. dataCount = me.dataCount || 20;
  388. var displayItem = me.child('#displayItem'),
  389. pageData = me.getPageData();
  390. pageData.fromRecord = (page-1)*pageSize+1;
  391. pageData.toRecord = page*pageSize > dataCount ? dataCount : page*pageSize;
  392. pageData.total = dataCount;
  393. var msg;
  394. if (displayItem) {
  395. if (me.dataCount === 0) {
  396. msg = me.emptyMsg;
  397. } else {
  398. msg = Ext.String.format(
  399. me.displayMsg,
  400. pageData.fromRecord,
  401. pageData.toRecord,
  402. pageData.total
  403. );
  404. }
  405. displayItem.setText(msg);
  406. me.doComponentLayout();
  407. }
  408. },
  409. getPageData : function(){
  410. var me = this,
  411. totalCount = me.dataCount;
  412. return {
  413. total : totalCount,
  414. currentPage : me.page,
  415. pageCount: Math.ceil(me.dataCount / me.pageSize),
  416. fromRecord: ((me.page - 1) * me.pageSize) + 1,
  417. toRecord: Math.min(me.page * me.pageSize, totalCount)
  418. };
  419. },
  420. doRefresh:function(){
  421. this.moveFirst();
  422. },
  423. onPagingKeyDown : function(field, e){
  424. var me = this,
  425. k = e.getKey(),
  426. pageData = me.getPageData(),
  427. increment = e.shiftKey ? 10 : 1,
  428. pageNum = 0;
  429. if (k == e.RETURN) {
  430. e.stopEvent();
  431. pageNum = me.readPageFromInput(pageData);
  432. if (pageNum !== false) {
  433. pageNum = Math.min(Math.max(1, pageNum), pageData.pageCount);
  434. me.child('#inputItem').setValue(pageNum);
  435. if(me.fireEvent('beforechange', me, pageNum) !== false){
  436. me.page = pageNum;
  437. me.ownerCt.getGridData(me.page);
  438. }
  439. }
  440. } else if (k == e.HOME || k == e.END) {
  441. e.stopEvent();
  442. pageNum = k == e.HOME ? 1 : pageData.pageCount;
  443. field.setValue(pageNum);
  444. } else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN) {
  445. e.stopEvent();
  446. pageNum = me.readPageFromInput(pageData);
  447. if (pageNum) {
  448. if (k == e.DOWN || k == e.PAGEDOWN) {
  449. increment *= -1;
  450. }
  451. pageNum += increment;
  452. if (pageNum >= 1 && pageNum <= pageData.pages) {
  453. field.setValue(pageNum);
  454. }
  455. }
  456. }
  457. me.updateInfo();
  458. me.resetTool(value);
  459. },
  460. moveFirst : function(){
  461. var me = this;
  462. me.child('#inputItem').setValue(1);
  463. value = 1;
  464. me.page = value;
  465. me.ownerCt.getGridData(value);
  466. me.updateInfo();
  467. me.resetTool(value);
  468. },
  469. movePrevious : function(){
  470. var me = this;
  471. me.child('#inputItem').setValue(me.child('#inputItem').getValue() - 1);
  472. value = me.child('#inputItem').getValue();
  473. me.page = value;
  474. me.ownerCt.getGridData(value);
  475. me.updateInfo();
  476. me.resetTool(value);
  477. },
  478. moveNext : function(){
  479. var me = this,
  480. last = me.getPageData().pageCount;
  481. total = last;
  482. me.child('#inputItem').setValue(me.child('#inputItem').getValue() + 1);
  483. value = me.child('#inputItem').getValue();
  484. me.page = value;
  485. me.ownerCt.getGridData(value);
  486. me.updateInfo();
  487. me.resetTool(value);
  488. },
  489. moveLast : function(){
  490. var me = this,
  491. last = me.getPageData().pageCount;
  492. total = last;
  493. me.child('#inputItem').setValue(last);
  494. value = me.child('#inputItem').getValue();
  495. me.page = value;
  496. me.ownerCt.getGridData(value);
  497. me.updateInfo();
  498. me.resetTool(value);
  499. },
  500. onLoad : function() {
  501. var e = this, d, b, c, a;
  502. if (!e.rendered) {
  503. return
  504. }
  505. d = e.getPageData();
  506. b = d.currentPage;
  507. c = Math.ceil(e.dataCount / e.pageSize);
  508. a = Ext.String.format(e.afterPageText, isNaN(c) ? 1 : c);
  509. e.child("#afterTextItem").setText(a);
  510. e.child("#inputItem").setValue(b);
  511. e.child("#first").setDisabled(b === 1);
  512. e.child("#prev").setDisabled(b === 1);
  513. e.child("#next").setDisabled(b === c || c===1);//
  514. e.child("#last").setDisabled(b === c || c===1);
  515. e.child("#refresh").enable();
  516. e.updateInfo();
  517. e.fireEvent("change", e, d);
  518. },
  519. resetTool: function(value){
  520. var pageCount = this.getPageData().pageCount;
  521. this.child('#last').setDisabled(value == pageCount || pageCount == 1);
  522. this.child('#next').setDisabled(value == pageCount || pageCount == 1);
  523. this.child('#first').setDisabled(value <= 1);
  524. this.child('#prev').setDisabled(value <= 1);
  525. }
  526. };
  527. },
  528. getPathString: function(tree, record){//path:/root/5/12
  529. var str = tree.ownerCt.title;
  530. return record.getPath('text', '&raquo;').replace('root', str);
  531. },
  532. showHistory: function(caller){
  533. var w = Ext.create('Ext.Window', {
  534. width: '60%',
  535. height: '80%',
  536. id: 'history-win',
  537. title: '导入数据历史记录',
  538. autoShow: true,
  539. layout: 'anchor',
  540. items: [{
  541. xtype: 'gridpanel',
  542. anchor: '100% 100%',
  543. columnLines: true,
  544. columns: [{dataIndex: 'il_id', hidden: true},{dataIndex: 'il_caller', hidden: true},{dataIndex: 'il_date', text: '日期', flex: 2},
  545. {dataIndex: 'il_sequence', text: '次数', flex: 1},{dataIndex: 'il_count', text: '数据量(条)', flex: 1},
  546. {dataIndex: 'il_checked', text: '是否已校验', flex: 1, renderer: function(val, m){
  547. if(val == '否') {
  548. m.style = 'float:right';
  549. }
  550. return val;
  551. }},{dataIndex: 'il_success',text:'是否校验通过', flex: 1, renderer: function(val, m){
  552. if(val == '否') {
  553. m.style = 'float:right';
  554. }
  555. return val;
  556. }},
  557. {dataIndex: 'il_toformal', text: '是否转正式', flex: 1, renderer: function(val, m){
  558. if(val == '否') {
  559. m.style = 'float:right';
  560. }
  561. return val;
  562. }}, {text: '', flex: 1, renderer: function(val, m, r){
  563. return '<a href="javascript:Ext.getCmp(\'template-data\').loadData(' + r.get('il_id') + ','
  564. + r.get('il_count') + ',1);Ext.getCmp(\'history-win\').close();Ext.getDom(\'check\').click();">载入</a>&nbsp;&nbsp;<a href="javascript:Ext.getCmp(\'template-data\').deleteData(' +
  565. r.get('il_id') + ');Ext.getCmp(\'history-win\').close();">删除</a>';
  566. }}],
  567. store: Ext.create('Ext.data.Store', {
  568. fields: ['il_id', 'il_caller', 'il_date', 'il_sequence', 'il_count', 'il_checked', 'il_success', 'il_toformal'],
  569. data: [{},{},{},{},{},{},{},{},{},{}]
  570. })
  571. }]
  572. });
  573. this.getInitLog(w.down('gridpanel'), caller);
  574. },
  575. getInitLog: function(g, c){
  576. Ext.Ajax.request({
  577. url: basePath + 'system/initHistory.action',
  578. params: {
  579. caller: c
  580. },
  581. method: 'post',
  582. callback: function(opt, s, r){
  583. var res = new Ext.decode(r.responseText);
  584. var dd = res.data;
  585. Ext.each(dd, function(d){
  586. d.il_date = Ext.Date.format(new Date(d.il_date), 'Y-m-d H:i:s');
  587. d.il_checked = d.il_checked == 1 ? '是' : '否';
  588. d.il_success = d.il_success == 1 ? '是' : '否';
  589. d.il_toformal = d.il_toformal == 1 ? '是' : '否';
  590. });
  591. g.store.loadData(dd);
  592. }
  593. });
  594. },
  595. loadInitData: function(grid, page){
  596. var f = (page-1) * 100 + 1,
  597. t = page*100;
  598. grid.setLoading(true);
  599. Ext.Ajax.request({
  600. url: basePath + 'system/getInitData.action',
  601. params: {
  602. condition: "id_ilid=" + grid.ilid +
  603. " AND id_detno between " + f + " AND " + t
  604. },
  605. method: 'post',
  606. callback: function(options, success, response){
  607. var res = new Ext.decode(response.responseText);
  608. grid.setLoading(false);
  609. if(res.exceptionInfo != null){
  610. showError(res.exceptionInfo);return;
  611. } else {
  612. var datas = new Array(), o;
  613. Ext.each(res.data, function(d){
  614. o = Ext.decode(d.id_data);
  615. o.id_id = d.id_id;
  616. datas.push(o);
  617. });
  618. grid.store.loadData(datas);
  619. grid.showErrors();
  620. /*var f = Ext.getCmp('onlyerror');
  621. if(f.checked) {
  622. grid.store.filterBy(function(item) {
  623. return !Ext.isEmpty(item.get('log'));
  624. });
  625. }*/
  626. }
  627. }
  628. });
  629. },
  630. loadErrData: function(grid, page){
  631. var f = (page-1) * 100 + 1,
  632. t = page*100;
  633. grid.setLoading(true);
  634. Ext.Ajax.request({
  635. url: basePath + 'system/getErrData.action',
  636. timeout: 10000,
  637. params: {
  638. id:grid.ilid,
  639. condition:" RN between " + f + " AND " + t
  640. },
  641. method: 'post',
  642. callback: function(options, success, response){
  643. grid.setLoading(false);
  644. var res = new Ext.decode(response.responseText);
  645. if(!success) {
  646. if(res.exceptionInfo != null){
  647. alert(res.exceptionInfo);return;
  648. }
  649. alert('系统繁忙,请稍后再试!');
  650. return;
  651. }
  652. if(res.exceptionInfo != null){
  653. showError(res.exceptionInfo);return;
  654. } else {
  655. var datas = new Array(), o;
  656. Ext.each(res.data, function(d){
  657. o = Ext.decode(d.id_data);
  658. o.id_id = d.id_id;
  659. datas.push(o);
  660. });
  661. grid.store.loadData(datas);
  662. grid.showErrors();
  663. }
  664. }
  665. });
  666. },
  667. ondelete: function(id){
  668. var grid = Ext.getCmp('template-data');
  669. grid.setLoading(true);
  670. Ext.Ajax.request({
  671. url: basePath + 'system/deleteInitData.action',
  672. params: {
  673. id: id
  674. },
  675. method: 'post',
  676. callback: function(options, success, response){
  677. var res = new Ext.decode(response.responseText);
  678. grid.setLoading(false);
  679. if(res.exceptionInfo != null){
  680. showError(res.exceptionInfo);return;
  681. } else {
  682. if(id == grid.ilid) {//如果删除的是当前显示的数据,要清除当前grid的数据
  683. grid.reset();
  684. }
  685. }
  686. }
  687. });
  688. },
  689. showRule: function(grid){
  690. if(grid){
  691. var me = this,data = me.getRules(grid);
  692. Ext.create('Ext.window.Window', {
  693. width: '100%',
  694. height: '100%',
  695. autoShow: 'true',
  696. closeAction: 'destroy',
  697. title: '导入配置',
  698. layout: 'anchor',
  699. tbar: ['->',{
  700. text: '保存',
  701. width: 80,
  702. cls: 'x-btn-bar-s',
  703. handler: function(b){
  704. me.saveInitDetails(b.ownerCt.ownerCt.down('gridpanel'), grid.caller);
  705. }
  706. },{
  707. text: '取消',
  708. width: 80,
  709. cls: 'x-btn-bar-s',
  710. handler: function(b) {
  711. b.ownerCt.ownerCt.close();
  712. }
  713. },'->'],
  714. items: [{
  715. xtype: 'gridpanel',
  716. id: 'initdetails',
  717. anchor: '100% 100%',
  718. plugins: Ext.create('Ext.grid.plugin.CellEditing', {
  719. clicksToEdit: 1
  720. }),
  721. columnLines: true,
  722. keyField: 'id_id',
  723. detno: 'id_detno',
  724. bbar: {xtype: 'erpToolbar'},
  725. dbfinds: [{
  726. field: 'id_table',
  727. dbGridField: 'dd_tablename;ddd_tablename'
  728. },{
  729. field: 'id_field',
  730. dbGridField: 'ddd_fieldname'
  731. },{
  732. field: 'id_caption',
  733. dbGridField: 'ddd_description'
  734. },{
  735. field: 'id_type',
  736. dbGridField: 'ddd_fieldtype'
  737. }],
  738. columns: [{
  739. dataIndex: 'id_id',
  740. hidden: true
  741. },{
  742. dataIndex: 'id_caller',
  743. hidden: true,
  744. renderer: function(v, m, r, x, y, s, w){
  745. var grid = w.ownerCt;
  746. if(Ext.isEmpty(v) && !Ext.isEmpty(grid.caller)) {
  747. v = grid.caller;
  748. r.set('id_caller', v);
  749. }
  750. return v;
  751. }
  752. },{
  753. dataIndex: 'id_detno',
  754. text: '序号',
  755. width: 40,
  756. renderer: function(val, meta) {
  757. meta.tdCls = Ext.baseCSSPrefix + 'grid-cell-special';
  758. return val;
  759. }
  760. },{
  761. text: '导入表',
  762. dataIndex: 'id_table',
  763. width: 90,
  764. editor: {
  765. xtype: 'dbfindtrigger'
  766. },
  767. dbfind: 'DataDictionary|dd_tablename'
  768. },{
  769. text: '导入项',
  770. dataIndex: 'id_field',
  771. width: 100,
  772. editor: {
  773. xtype: 'multidbfindtrigger'
  774. },
  775. dbfind: 'DataDictionaryDetail|ddd_fieldname'
  776. },{
  777. text: '描述',
  778. dataIndex: 'id_caption',
  779. width: 105,
  780. renderer: function(v){
  781. if(Ext.isEmpty(v)) {
  782. return '<font color=gray>无</font>';
  783. }
  784. return v;
  785. },
  786. editor: {
  787. xtype: 'textfield'
  788. }
  789. },{
  790. text: '逻辑表达式',
  791. dataIndex: 'id_logic',
  792. width: 250,
  793. renderer: function(v){
  794. if(Ext.isEmpty(v)) {
  795. return '<font color=gray>无</font>';
  796. }
  797. return v;
  798. },
  799. editor: {
  800. xtype: 'trigger',
  801. editable: false,
  802. triggerCls: 'x-form-search-trigger',
  803. onTriggerClick: function(){
  804. me.logicTypes(this, Ext.getCmp('initdetails').selModel.lastSelected);
  805. }
  806. }
  807. },{
  808. text: '逻辑描述',
  809. dataIndex: 'id_rule',
  810. width: 500,
  811. renderer: function(v){
  812. if(Ext.isEmpty(v)) {
  813. return '<font color=gray>无</font>';
  814. }
  815. return v;
  816. },
  817. editor: {
  818. xtype: 'textfield'
  819. }
  820. },{
  821. text: '类型',
  822. dataIndex: 'id_type',
  823. width: 105,
  824. renderer: function(v, meta, record){
  825. if(Ext.isEmpty(v)) {
  826. return '<font color=gray>无</font>';
  827. } else {
  828. v = v.toLowerCase();
  829. if(contains(v, 'varchar2')) {
  830. v = v.replace(/byte/g, '').trim();
  831. }
  832. if(record.data['id_type'] != v) {
  833. record.set('id_type', v);
  834. }
  835. }
  836. return v;
  837. },
  838. editor: {
  839. xtype: 'trigger',
  840. editable: false,
  841. triggerCls: 'x-form-search-trigger',
  842. onTriggerClick: function(){
  843. me.dataTypes(this, Ext.getCmp('initdetails').selModel.lastSelected);
  844. }
  845. }
  846. },{
  847. text: '默认值',
  848. dataIndex: 'id_default',
  849. wdith: 80,
  850. renderer: function(v){
  851. if(Ext.isEmpty(v)) {
  852. return '<font color=gray>无</font>';
  853. }
  854. return v;
  855. },
  856. editor: {
  857. xtype: 'trigger',
  858. editable: false,
  859. triggerCls: 'x-form-search-trigger',
  860. onTriggerClick: function(){
  861. me.fieldTypes(this, Ext.getCmp('initdetails').selModel.lastSelected);
  862. }
  863. }
  864. },{
  865. text: '是否显示',
  866. dataIndex: 'id_visible',
  867. xtype: 'checkcolumn',
  868. width: 75,
  869. editor: {
  870. xtype: 'checkbox'
  871. }
  872. },{
  873. text: '是否必填',
  874. dataIndex: 'id_need',
  875. xtype: 'checkcolumn',
  876. width: 75,
  877. editor: {
  878. xtype: 'checkbox'
  879. }
  880. },{
  881. text: '列宽度',
  882. dataIndex: 'id_width',
  883. xtype: 'numbercolumn',
  884. format: '0',
  885. width: 75,
  886. editor: {
  887. xtype: 'numberfield',
  888. hideTrigger: true,
  889. format: '0'
  890. }
  891. }],
  892. store: Ext.create('Ext.data.Store', {
  893. fields: ['id_id', 'id_caller', 'id_detno', 'id_table', 'id_field', 'id_caption', 'id_logic', 'id_rule',
  894. 'id_type', {name: 'id_visible', type: 'bool'}, {name: 'id_need', type: 'bool'}, 'id_default',
  895. 'id_width'],
  896. data: data
  897. }),
  898. listeners: {
  899. itemclick: function(selModel, record){
  900. me.GridUtil.onGridItemClick(selModel, record);
  901. }
  902. }
  903. }]
  904. });
  905. me.control('field[name=id_field]', {
  906. focus: function(t){
  907. var record = Ext.getCmp('initdetails').selModel.lastSelected;
  908. var dd = record.data['id_table'];
  909. if(!Ext.isEmpty(dd)) {
  910. t.dbBaseCondition = 'ddd_tablename=\'' + dd + '\'';
  911. } else {
  912. t.dbBaseCondition = '';
  913. }
  914. }
  915. });
  916. }
  917. },
  918. saveInitDetails: function(grid, caller){
  919. var me = this,datas = [],items = grid.store.data.items,d;
  920. Ext.each(items, function(i){
  921. if(i.dirty) {
  922. d = i.data;
  923. if(!Ext.isEmpty(d.id_field) && !Ext.isEmpty(d.id_table)) {
  924. d.id_need = d.id_need ? 1 : 0;
  925. d.id_visible = d.id_visible ? 1 : 0;
  926. d.id_caller = caller;
  927. d.id_width = Ext.isEmpty(d.id_width) ? 0 : d.id_width;
  928. datas.push(d);
  929. }
  930. }
  931. });
  932. Ext.Ajax.request({
  933. url: basePath + 'system/saveInitDetail.action',
  934. method: 'post',
  935. params: {
  936. data: unescape(Ext.encode(datas).replace(/\\/g,"%"))
  937. },
  938. callback: function(opt, s, r) {
  939. if(r.exceptionInfo) {
  940. showError(r.exceptionInfo);
  941. } else {
  942. alert('保存成功!');
  943. grid.ownerCt.destroy();
  944. me.getDetails(Ext.getCmp('template'), caller, true);
  945. }
  946. }
  947. });
  948. },
  949. fieldTypes: function(f, record){
  950. var g = Ext.getCmp('initdetails'), dd = g.store.data.items,ff = [];
  951. Ext.each(dd, function(i){
  952. if(i.data.id_field != record.data.id_field) {
  953. ff.push({
  954. display: i.data.id_caption,
  955. value: i.data.id_field
  956. });
  957. }
  958. });
  959. var ww = Ext.create('Ext.Window', {
  960. autoShow: true,
  961. modal: true,
  962. title: '默认值',
  963. width: '55%',
  964. height: '50%',
  965. layout: 'column',
  966. items: [{
  967. xtype: 'fieldcontainer',
  968. name: 'keyField',
  969. columnWidth: 1,
  970. items: [{
  971. xtype: 'radio',
  972. columnWidth: 1,
  973. boxLabel: '自动取ID',
  974. name: 'default'
  975. }],
  976. getValue: function(){
  977. return 'keyField';
  978. },
  979. setValue: function(){
  980. this.down('radio').setValue(true);
  981. }
  982. },{
  983. xtype: 'fieldcontainer',
  984. name: 'codeField',
  985. columnWidth: 1,
  986. items: [{
  987. xtype: 'radio',
  988. columnWidth: 1,
  989. boxLabel: '自动取编号',
  990. name: 'default'
  991. }],
  992. getValue: function(){
  993. return 'codeField';
  994. },
  995. setValue: function(){
  996. this.down('radio').setValue(true);
  997. }
  998. },{
  999. xtype: 'fieldcontainer',
  1000. name: 'date',
  1001. columnWidth: 1,
  1002. layout: 'hbox',
  1003. items: [{
  1004. xtype: 'radio',
  1005. boxLabel: '当前时间',
  1006. name: 'default'
  1007. },{
  1008. xtype: 'checkbox',
  1009. inputValue: 'yy-MM-dd',
  1010. separator: ' ',
  1011. boxLabel: '年月日'
  1012. },{
  1013. xtype: 'checkbox',
  1014. inputValue: 'HH:mm:ss',
  1015. separator: '',
  1016. boxLabel: '时分秒'
  1017. }],
  1018. getValue: function(){
  1019. var rr = this.query('checkbox[checked=true]'), vv = '', len = rr.length;
  1020. Ext.each(rr, function(r, idx){
  1021. if(r.xtype == 'checkbox' && r.inputValue) {
  1022. vv += r.inputValue;
  1023. if(idx < len - 1) {
  1024. vv += r.separator;
  1025. }
  1026. }
  1027. });
  1028. if(vv == '') {
  1029. return '';
  1030. }
  1031. return 'date(' + vv + ')';
  1032. },
  1033. setValue: function(v){
  1034. this.down('radio').setValue(true);
  1035. v = v.substring(v.indexOf('(') + 1, v.indexOf(')'));
  1036. var y = v.split(' '),arr,me = this;
  1037. Ext.each(y, function(i){
  1038. if(i.indexOf('-') != -1) {
  1039. arr = i.split('-');
  1040. } else {
  1041. arr = i.split(':');
  1042. }
  1043. var ch;
  1044. Ext.each(arr, function(j){
  1045. ch = me.down('checkbox[inputValue=' + j + ']');
  1046. if(ch)
  1047. ch.setValue(true);
  1048. });
  1049. });
  1050. }
  1051. },{
  1052. xtype: 'fieldcontainer',
  1053. name: 'replace',
  1054. columnWidth: 1,
  1055. layout: 'hbox',
  1056. items: [{
  1057. xtype: 'radio',
  1058. name: 'default',
  1059. boxLabel: '替代值'
  1060. },{
  1061. xtype: 'fieldcontainer',
  1062. items: [{
  1063. xtype: 'textfield',
  1064. emptyText: '显示值'
  1065. },{
  1066. xtype: 'textfield',
  1067. emptyText: '实际值'
  1068. }],
  1069. getValue: function(){
  1070. var val = this.items.items[0],dis = this.items.items[1];
  1071. if(!Ext.isEmpty(val.value) && !Ext.isEmpty(dis.value)) {
  1072. return val.value + ':' + dis.value;
  1073. }
  1074. return '';
  1075. },
  1076. setValue: function(v) {
  1077. if(!Ext.isEmpty(v)) {
  1078. this.items.items[0].setValue(v.split(':')[0]);
  1079. this.items.items[1].setValue(v.split(':')[1] || '');
  1080. }
  1081. }
  1082. },{
  1083. xtype: 'button',
  1084. iconCls: 'x-button-icon-add',
  1085. cls: 'x-btn-tb',
  1086. handler: function(b){
  1087. b.ownerCt.insert(b.ownerCt.items.items.length - 1, {
  1088. xtype: 'fieldcontainer',
  1089. items: [{
  1090. xtype: 'textfield',
  1091. emptyText: '显示值'
  1092. },{
  1093. xtype: 'textfield',
  1094. emptyText: '实际值'
  1095. }],
  1096. getValue: function(){
  1097. var val = this.items.items[0],dis = this.items.items[1];
  1098. if(!Ext.isEmpty(val.value) && !Ext.isEmpty(dis.value)) {
  1099. return val.value + ':' + dis.value;
  1100. }
  1101. return '';
  1102. },
  1103. setValue: function(v) {
  1104. if(!Ext.isEmpty(v)) {
  1105. this.items.items[0].setValue(v.split(':')[0]);
  1106. this.items.items[1].setValue(v.split(':')[1] || '');
  1107. }
  1108. }
  1109. });
  1110. }
  1111. }],
  1112. getValue: function(){
  1113. var tx = this.query('fieldcontainer'),val = '';
  1114. Ext.each(tx, function(t){
  1115. if(!Ext.isEmpty(t.getValue())) {
  1116. if(val == '') {
  1117. val = t.getValue();
  1118. } else {
  1119. val += ',' + t.getValue();
  1120. }
  1121. }
  1122. });
  1123. if(val == '') {
  1124. return null;
  1125. }
  1126. return 'replace(' +val + ')';
  1127. },
  1128. setValue: function(v){
  1129. var m = this;
  1130. this.down('radio').setValue(true);
  1131. var t = v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')).split(',');
  1132. Ext.each(t, function(r, i){
  1133. if(i == 0) {
  1134. m.down('fieldcontainer').setValue(r);
  1135. } else {
  1136. var f = Ext.create('Ext.form.FieldContainer', {
  1137. items: [{
  1138. xtype: 'textfield',
  1139. emptyText: '显示值'
  1140. },{
  1141. xtype: 'textfield',
  1142. emptyText: '实际值'
  1143. }],
  1144. getValue: function(){
  1145. var val = this.items.items[0],dis = this.items.items[1];
  1146. if(!Ext.isEmpty(val.value) && !Ext.isEmpty(dis.value)) {
  1147. return val.value + ':' + dis.value;
  1148. }
  1149. return '';
  1150. },
  1151. setValue: function(v) {
  1152. if(!Ext.isEmpty(v)) {
  1153. this.items.items[0].setValue(v.split(':')[0]);
  1154. this.items.items[1].setValue(v.split(':')[1] || '');
  1155. }
  1156. }
  1157. });
  1158. m.insert(m.items.items.length - 1, f);
  1159. f.setValue(r);
  1160. }
  1161. });
  1162. }
  1163. },{
  1164. xtype: 'fieldcontainer',
  1165. name: 'copy',
  1166. columnWidth: 1,
  1167. layout: 'hbox',
  1168. items: [{
  1169. xtype: 'radio',
  1170. boxLabel: '等于字段',
  1171. name: 'default'
  1172. },{
  1173. xtype: 'combo',
  1174. displayField: 'display',
  1175. valueField: 'value',
  1176. queryMode: 'local',
  1177. editable: false,
  1178. store: Ext.create('Ext.data.Store', {
  1179. fields: ['display','value'],
  1180. data: ff
  1181. })
  1182. },{
  1183. xtype: 'radio',
  1184. name: 'condition',
  1185. inputValue: 'if',
  1186. boxLabel: '只在值为空时'
  1187. },{
  1188. xtype: 'radio',
  1189. name: 'condition',
  1190. inputValue: 'of',
  1191. boxLabel: '任何情况下',
  1192. checked: true
  1193. }],
  1194. getValue: function(){
  1195. var rr = this.query('radio[name=condition]'), vv = '';
  1196. Ext.each(rr, function(){
  1197. if(this.checked) {
  1198. vv = this.inputValue;
  1199. }
  1200. });
  1201. return 'copy' + vv + '(' + this.down('combo').value + ')';
  1202. },
  1203. setValue: function(v) {
  1204. this.down('radio').setValue(true);
  1205. this.down('combo').setValue(v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')));
  1206. var ff = v.substring(4, v.indexOf('('));
  1207. this.down('radio[inputValue=' + ff + ']').setValue(true);
  1208. }
  1209. },{
  1210. xtype: 'fieldcontainer',
  1211. name: 'others',
  1212. columnWidth: 1,
  1213. layout: 'hbox',
  1214. items: [{
  1215. xtype: 'radio',
  1216. boxLabel: '其它',
  1217. name: 'default'
  1218. },{
  1219. xtype: 'textfield'
  1220. }],
  1221. getValue: function() {
  1222. return this.down('textfield').value;
  1223. },
  1224. setValue: function(v) {
  1225. this.down('radio').setValue(true);
  1226. this.down('textfield').setValue(v);
  1227. }
  1228. }],
  1229. buttonAlign: 'center',
  1230. buttons: [{
  1231. text: '确定',
  1232. handler: function(b){
  1233. var w = b.ownerCt.ownerCt;
  1234. var val = '',ch = w.query('radio[name="default"]'),cc = null;
  1235. Ext.each(ch, function(){
  1236. if(this.checked) {
  1237. cc = this;
  1238. }
  1239. });
  1240. if(cc) {
  1241. v = cc.ownerCt.getValue();
  1242. if(v != null) {
  1243. val = v;
  1244. }
  1245. }
  1246. f.setValue(val);
  1247. record.set('id_default', val);
  1248. w.close();
  1249. }
  1250. },{
  1251. text: '取消',
  1252. handler: function(b){
  1253. b.ownerCt.ownerCt.close();
  1254. }
  1255. }]
  1256. });
  1257. var fc = ww.query('fieldcontainer');
  1258. if(!Ext.isEmpty(f.value)) {
  1259. var vv = f.value,bool = false;
  1260. Ext.each(fc, function(r){
  1261. if(contains(vv, r.name, true)) {
  1262. bool = true;
  1263. r.setValue(vv);
  1264. }
  1265. });
  1266. if(!bool) {
  1267. ww.down('fieldcontainer[name=others]').setValue(vv);
  1268. }
  1269. }
  1270. },
  1271. logicTypes: function(f, record){
  1272. var g = Ext.getCmp('initdetails'), dd = g.store.data.items,ff = [];
  1273. Ext.each(dd, function(i){
  1274. if(i.data.id_field != record.data.id_field) {
  1275. ff.push({
  1276. display: i.data.id_caption,
  1277. value: i.data.id_field
  1278. });
  1279. }
  1280. });
  1281. var ww = Ext.create('Ext.Window', {
  1282. autoShow: true,
  1283. modal: true,
  1284. title: '逻辑表达式',
  1285. width: '60%',
  1286. height: '60%',
  1287. layout: 'column',
  1288. padding: 15,
  1289. items: [{
  1290. xtype: 'fieldcontainer',
  1291. name: 'unique',
  1292. columnWidth: 1,
  1293. items: [{
  1294. xtype: 'checkbox',
  1295. boxLabel: '唯一性'
  1296. }],
  1297. getValue: function(){
  1298. return 'unique(' + record.data.id_table + '|' + record.data.id_field + ')';
  1299. },
  1300. setValue: function(v){
  1301. this.down('checkbox').setValue(true);
  1302. }
  1303. },{
  1304. xtype: 'fieldcontainer',
  1305. name: 'trim',
  1306. columnWidth: 1,
  1307. layout: 'column',
  1308. items: [{
  1309. xtype: 'checkbox',
  1310. columnWidth: 0.1,
  1311. boxLabel: '禁用字符'
  1312. },{
  1313. xtype: 'textfield',
  1314. columnWidth: 0.1
  1315. },{
  1316. xtype: 'button',
  1317. iconCls: 'x-button-icon-add',
  1318. cls: 'x-btn-tb',
  1319. handler: function(b){
  1320. b.ownerCt.insert(b.ownerCt.items.items.length - 1, {
  1321. xtype: 'textfield',
  1322. columnWidth: 0.1
  1323. });
  1324. }
  1325. }],
  1326. getValue: function(){
  1327. var tx = this.query('textfield'),val = '';
  1328. Ext.each(tx, function(t){
  1329. if(!Ext.isEmpty(t.value)) {
  1330. if(val == '') {
  1331. val = t.value;
  1332. } else {
  1333. val += ',' + t.value;
  1334. }
  1335. }
  1336. });
  1337. if(val == '') {
  1338. return null;
  1339. }
  1340. return 'trim(' +val + ')';
  1341. },
  1342. setValue: function(v){
  1343. var m = this;
  1344. m.down('checkbox').setValue(true);
  1345. var t = v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')).split(',');
  1346. Ext.each(t, function(r, i){
  1347. if(i == 0) {
  1348. m.down('textfield').setValue(r);
  1349. } else {
  1350. m.insert(m.items.items.length - 1, {
  1351. xtype: 'textfield',
  1352. columnWidth: 0.1,
  1353. value: r
  1354. });
  1355. }
  1356. });
  1357. }
  1358. },{
  1359. xtype: 'fieldcontainer',
  1360. name: 'combo',
  1361. columnWidth: 1,
  1362. layout: 'column',
  1363. items: [{
  1364. xtype: 'checkbox',
  1365. columnWidth: 0.1,
  1366. boxLabel: '可选范围'
  1367. },{
  1368. xtype: 'textfield',
  1369. columnWidth: 0.1
  1370. },{
  1371. xtype: 'button',
  1372. iconCls: 'x-button-icon-add',
  1373. cls: 'x-btn-tb',
  1374. handler: function(b){
  1375. b.ownerCt.insert(b.ownerCt.items.items.length - 1, {
  1376. xtype: 'textfield',
  1377. columnWidth: 0.1
  1378. });
  1379. }
  1380. }],
  1381. getValue: function(){
  1382. var tx = this.query('textfield'),val = '';
  1383. Ext.each(tx, function(t){
  1384. if(!Ext.isEmpty(t.value)) {
  1385. if(val == '') {
  1386. val = t.value;
  1387. } else {
  1388. val += ',' + t.value;
  1389. }
  1390. }
  1391. });
  1392. if(val == '') {
  1393. return null;
  1394. }
  1395. return 'combo(' +val + ')';
  1396. },
  1397. setValue: function(v){
  1398. var m = this;
  1399. m.down('checkbox').setValue(true);
  1400. var t = v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')).split(',');
  1401. Ext.each(t, function(r, i){
  1402. if(i == 0) {
  1403. m.down('textfield').setValue(r);
  1404. } else {
  1405. m.insert(m.items.items.length - 1, {
  1406. xtype: 'textfield',
  1407. columnWidth: 0.1,
  1408. value: r
  1409. });
  1410. }
  1411. });
  1412. }
  1413. },{
  1414. xtype: 'fieldcontainer',
  1415. name: 'accord',
  1416. columnWidth: 1,
  1417. layout: 'column',
  1418. items: [{
  1419. xtype: 'checkbox',
  1420. columnWidth: 0.1,
  1421. boxLabel: '关联'
  1422. },{
  1423. columnWidth: 0.3,
  1424. emptyText: '表',
  1425. id: 'accord_table',
  1426. name: 'accord_table',
  1427. xtype: 'dbfindtrigger'
  1428. },{
  1429. columnWidth: 0.3,
  1430. emptyText: '字段',
  1431. id: 'accord_field',
  1432. name: 'accord_field',
  1433. dbKey: 'accord_table',
  1434. mappingKey: 'ddd_tablename',
  1435. dbMessage: '请选择表名',
  1436. xtype: 'dbfindtrigger'
  1437. }],
  1438. getValue: function(){
  1439. var at = this.down('dbfindtrigger[name=accord_table]'),
  1440. af = this.down('dbfindtrigger[name=accord_field]');
  1441. if(!Ext.isEmpty(at.value) && !Ext.isEmpty(af.value)) {
  1442. return 'accord(' + at.value + '|' + af.value + ')';
  1443. }
  1444. return null;
  1445. },
  1446. setValue: function(v){
  1447. this.down('checkbox').setValue(true);
  1448. var t = v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')).split('|');
  1449. this.down('dbfindtrigger[name=accord_table]').setValue(t[0]);
  1450. this.down('dbfindtrigger[name=accord_field]').setValue(t[1]);
  1451. }
  1452. },{
  1453. xtype: 'fieldcontainer',
  1454. name: 'diffence',
  1455. columnWidth: 1,
  1456. layout: 'column',
  1457. items: [{
  1458. xtype: 'checkbox',
  1459. columnWidth: 0.1,
  1460. boxLabel: '不同于'
  1461. },{
  1462. columnWidth: 0.3,
  1463. xtype: 'combo',
  1464. displayField: 'display',
  1465. valueField: 'value',
  1466. queryMode: 'local',
  1467. editable: false,
  1468. store: Ext.create('Ext.data.Store', {
  1469. fields: ['display','value'],
  1470. data: ff
  1471. })
  1472. }],
  1473. getValue: function(){
  1474. var c = this.down('combo');
  1475. if(!Ext.isEmpty(c.value)) {
  1476. return 'diffence(' + c.value + ')';
  1477. }
  1478. return null;
  1479. },
  1480. setValue: function(v){
  1481. this.down('checkbox').setValue(true);
  1482. this.down('combo').setValue(v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')));
  1483. }
  1484. },{
  1485. xtype: 'fieldcontainer',
  1486. name: 'minValue',
  1487. columnWidth: 1,
  1488. layout: 'column',
  1489. items: [{
  1490. xtype: 'checkbox',
  1491. columnWidth: 0.1,
  1492. boxLabel: '最小值'
  1493. },{
  1494. columnWidth: 0.3,
  1495. xtype: 'numberfield'
  1496. }],
  1497. getValue: function(){
  1498. var c = this.down('numberfield');
  1499. if(!Ext.isEmpty(c.value)) {
  1500. return 'minValue(' + c.value + ')';
  1501. }
  1502. return null;
  1503. },
  1504. setValue: function(v){
  1505. this.down('checkbox').setValue(true);
  1506. this.down('minValue').setValue(v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')));
  1507. }
  1508. }],
  1509. buttonAlign: 'center',
  1510. buttons: [{
  1511. text: '确定',
  1512. handler: function(b){
  1513. var w = b.ownerCt.ownerCt;
  1514. var val = '',ch = w.query('checkbox[checked=true]'),v;
  1515. Ext.each(ch, function(c){
  1516. v = c.ownerCt.getValue();
  1517. if(v != null) {
  1518. if(val != '') {
  1519. val += ';';
  1520. }
  1521. val += v;
  1522. }
  1523. });
  1524. f.setValue(val);
  1525. record.set('id_logic', val);
  1526. w.close();
  1527. }
  1528. },{
  1529. text: '取消',
  1530. handler: function(b){
  1531. b.ownerCt.ownerCt.close();
  1532. }
  1533. }]
  1534. });
  1535. var fc = ww.query('fieldcontainer');
  1536. if(!Ext.isEmpty(f.value)) {
  1537. var vv = f.value.split(';');
  1538. Ext.each(vv, function(s){
  1539. Ext.each(fc, function(r){
  1540. if(contains(s, r.name, true)) {
  1541. r.setValue(s);
  1542. }
  1543. });
  1544. });
  1545. }
  1546. },
  1547. dataTypes: function(f, record){
  1548. var v = f.value,a = v.substring(v.indexOf('(') + 1, v.indexOf(')')),x = 30,y = 0;
  1549. if(a) {
  1550. x = a.split(',')[0];
  1551. y = a.split(',')[1];
  1552. }
  1553. var isDate = contains(f.value, 'date', true), isStr = contains(f.value, 'varchar2', true);
  1554. Ext.create('Ext.Window', {
  1555. autoShow: true,
  1556. modal: true,
  1557. title: '数据类型',
  1558. width: '40%',
  1559. height: '40%',
  1560. items: [{
  1561. xtype: 'container',
  1562. padding: '10 5 5 10',
  1563. items: [{
  1564. xtype: 'radio',
  1565. boxLabel: '日期',
  1566. name: 'type',
  1567. checked: isDate,
  1568. inputValue: 'date()',
  1569. listeners: {
  1570. change : function(){
  1571. if(this.checked) {
  1572. this.ownerCt.down('numberfield[name=length_y]').hide();
  1573. this.ownerCt.down('numberfield[name=length_x]').hide();
  1574. } else {
  1575. this.ownerCt.down('numberfield[name=length_x]').show();
  1576. }
  1577. }
  1578. }
  1579. },{
  1580. xtype: 'radio',
  1581. boxLabel: '字符串',
  1582. name: 'type',
  1583. checked: isStr,
  1584. inputValue: 'varchar2'
  1585. },{
  1586. xtype: 'radio',
  1587. boxLabel: '数字',
  1588. name: 'type',
  1589. checked: !isDate && !isStr,
  1590. inputValue: 'number',
  1591. listeners: {
  1592. change : function(){
  1593. if(this.checked) {
  1594. this.ownerCt.down('numberfield[name=length_y]').show();
  1595. this.ownerCt.down('numberfield[name=length_x]').setMaxValue(38);
  1596. this.ownerCt.down('numberfield[name=length_x]').validate();
  1597. } else {
  1598. this.ownerCt.down('numberfield[name=length_y]').hide();
  1599. this.ownerCt.down('numberfield[name=length_x]').setMaxValue(2000);
  1600. }
  1601. }
  1602. }
  1603. },{
  1604. xtype: 'numberfield',
  1605. fieldLabel: '长度',
  1606. name: 'length_x',
  1607. format: '0',
  1608. value: x,
  1609. hidden: isDate,
  1610. maxText: '超过最大长度',
  1611. listeners: {
  1612. change: function(f){
  1613. var a = f.ownerCt.down('radio[checked=true]').inputValue;
  1614. if(a == 'number') {
  1615. f.setMaxValue(38);
  1616. } else {
  1617. f.setMaxValue(2000);
  1618. }
  1619. }
  1620. }
  1621. },{
  1622. xtype: 'numberfield',
  1623. fieldLabel: '小数位数',
  1624. name: 'length_y',
  1625. hidden: isDate || isStr,
  1626. format: '0',
  1627. maxValue: 57,
  1628. maxText: '超过最大数57',
  1629. value: y
  1630. }]
  1631. }],
  1632. buttonAlign: 'center',
  1633. buttons: [{
  1634. text: '确定',
  1635. handler: function(b){
  1636. var w = b.ownerCt.ownerCt;
  1637. v = w.down('radio[checked=true]').inputValue;
  1638. x = w.down('numberfield[name=length_x]').value || 0;
  1639. y = w.down('numberfield[name=length_y]').value || 0;
  1640. if(v == 'varchar2') {
  1641. v += '(' + x + ')';
  1642. } else if (v == 'number') {
  1643. v += '(' + x + ',' + y + ')';
  1644. }
  1645. f.setValue(v);
  1646. record.set(f.name, v);
  1647. w.close();
  1648. }
  1649. },{
  1650. text: '取消',
  1651. handler: function(b){
  1652. b.ownerCt.ownerCt.close();
  1653. }
  1654. }]
  1655. });
  1656. },
  1657. getRules: function(grid){
  1658. var datas = new Array();
  1659. if(grid.cfg && grid.cfg.length > 0) {
  1660. datas = grid.cfg;
  1661. var keys;
  1662. Ext.each(datas, function(d){
  1663. keys = Ext.Object.getKeys(d);
  1664. Ext.each(keys, function(k){
  1665. d[k] = d[k] == null ? '' : d[k];
  1666. });
  1667. d.id_visible = d.id_visible == 1;
  1668. d.id_need = d.id_need == 1;
  1669. });
  1670. } else {
  1671. datas = [{id_detno:1,id_width:100},{id_detno:2,id_width:100},{id_detno:3,id_width:100},
  1672. {id_detno:4,id_width:100},{id_detno:5,id_width:100},{id_detno:6,id_width:100},
  1673. {id_detno:7,id_width:100},{id_detno:8,id_width:100},{id_detno:9,id_width:100},
  1674. {id_detno:10,id_width:100}];
  1675. }
  1676. return datas;
  1677. },
  1678. /**
  1679. * 数据校验
  1680. */
  1681. checkdata: function(grid){
  1682. var me = this, count = grid.down('pagingtoolbar').dataCount, pageSize = 5000, page = 0, a, b,
  1683. len = Math.ceil(count/pageSize), index = 0;
  1684. var p = Ext.create('Ext.ProgressBar', {
  1685. width: '60%',
  1686. text: '准备校验中...',
  1687. floating: true,
  1688. renderTo: Ext.getBody()
  1689. }).show();
  1690. grid.setLoading(true);
  1691. //先删除上次校验记录
  1692. Ext.Ajax.request({
  1693. url: basePath + 'system/beforeCheckLog.action',
  1694. params: {
  1695. id: grid.ilid
  1696. },
  1697. method: 'post',
  1698. callback: function(opt, s, r){
  1699. var res = Ext.decode(r.responseText);
  1700. if(res.success) {
  1701. while (page*pageSize < count) {
  1702. a = page * pageSize + 1;
  1703. b = (page + 1) * pageSize;
  1704. Ext.Ajax.request({
  1705. url: basePath + 'system/checkInitData.action',
  1706. timeout: 30000,
  1707. async: false,
  1708. method: 'post',
  1709. params: {
  1710. id: grid.ilid,
  1711. start: a,
  1712. end: b
  1713. },
  1714. callback: function(opt, s, r){
  1715. var rs = Ext.decode(r.responseText);
  1716. if(rs.exceptionInfo) {
  1717. grid.setLoading(false);
  1718. p.destroy();
  1719. Ext.Msg.alert('发现错误', rs.exceptionInfo);return;
  1720. }
  1721. index++;
  1722. p.updateProgress(index/len, '完成' + index/len*100 + '%', true);
  1723. if(index == len) {
  1724. p.updateProgress(0.4, '准备完毕,正在校验...', true);
  1725. Ext.Ajax.request({
  1726. url: basePath + 'system/afterCheckLog.action',
  1727. timeout: 30000,
  1728. params: {
  1729. id: grid.ilid
  1730. },
  1731. method: 'post',
  1732. callback: function(opt, s, r){
  1733. var res = Ext.decode(r.responseText);
  1734. if(res.success) {
  1735. p.updateProgress(0.8, '校验完成,正在获取校验结果...', true);
  1736. grid.setLoading(false);
  1737. //刷新grid.renderer
  1738. me.getCheckResult(grid, p);
  1739. }
  1740. }
  1741. });
  1742. }
  1743. }
  1744. });
  1745. page++;
  1746. }
  1747. } else {
  1748. if(res.exceptionInfo) {
  1749. if(res.exceptionInfo = '数据超过5000条,请分批导入'){
  1750. alert('数据超过5000条,请分批导入!');
  1751. grid.setLoading(false);
  1752. p.destroy();
  1753. return;
  1754. }
  1755. }
  1756. alert('系统错误,准备校验失败!');
  1757. grid.setLoading(false);
  1758. p.destroy();
  1759. }
  1760. }
  1761. });
  1762. },
  1763. /**
  1764. * 从数据库取校验结果
  1765. */
  1766. getCheckResult: function(grid, p){
  1767. grid.setLoading(true);
  1768. Ext.Ajax.request({
  1769. url: basePath + 'system/getCheckResult.action',
  1770. timeout: 15000,
  1771. params: {
  1772. id: grid.ilid
  1773. },
  1774. method: 'post',
  1775. callback: function(opt, s, r){
  1776. p.destroy();
  1777. grid.setLoading(false);
  1778. var rs = r.responseText;
  1779. if(rs != null && rs != '') {
  1780. grid.errorNodes = rs.replace(/\s/g, '').split(';|,').filter(function(a){
  1781. return a != '' && a != ' ';
  1782. });
  1783. } else {
  1784. grid.errorNodes = [];
  1785. alert('系统错误,未找到校验结果.');
  1786. }
  1787. grid.showErrors();
  1788. Ext.getCmp('errdownload').show();
  1789. Ext.getCmp('onlyerror').show();
  1790. Ext.getCmp('toformal').show();
  1791. /*Ext.getCmp('errdelete').show();
  1792. Ext.getCmp('saveupdates').show();*/
  1793. }
  1794. });
  1795. },
  1796. toformal: function(grid){
  1797. var count = grid.down('pagingtoolbar').dataCount, pageSize = 2000, page = 0, a, b,
  1798. len = Math.ceil(count/pageSize), index = 0;
  1799. if ('Purchase' == grid.caller || 'Sale' == grid.caller ||
  1800. 'PurchasePrice' == grid.caller || 'SalePrice' == grid.caller ||
  1801. 'ProdInOut' == grid.caller || 'Estimate' == grid.caller ||
  1802. 'Make' == grid.caller || 'SaleForecast' == grid.caller
  1803. || 'GoodsSend' == grid.caller||'ARBill'==grid.caller||'APBill'==grid.caller||
  1804. 'ProdInOut!ExchangeIn'==grid.caller||'ProdInOut!SaleBorrow'==grid.caller||
  1805. 'ProdInOut!OtherPurcIn'==grid.caller||"Make!Mac"==grid.caller||"Make!IMEI"==grid.caller||"Make!MakeSN"==grid.caller || "Make!SaleSN"==grid.caller ) {
  1806. pageSize = count;
  1807. len = 1;
  1808. }
  1809. var p = Ext.create('Ext.ProgressBar', {
  1810. width: '60%',
  1811. text: '准备中...',
  1812. floating: true,
  1813. renderTo: Ext.getBody()
  1814. }).show();
  1815. grid.setLoading(true);
  1816. Ext.Ajax.request({
  1817. url: basePath + 'system/beforeToFormal.action',
  1818. params: {
  1819. id: grid.ilid
  1820. },
  1821. callback: function(opt, s, r){
  1822. if (!s) {
  1823. grid.setLoading(false);
  1824. p.destroy();
  1825. var rs = Ext.decode(r.responseText);
  1826. if(rs.exceptionInfo) {
  1827. showError(rs.exceptionInfo);return;
  1828. }
  1829. }
  1830. var res = Ext.decode(r.responseText);
  1831. if(res.success) {
  1832. while (page*pageSize < count) {
  1833. a = page * pageSize + 1;
  1834. b = (page + 1) * pageSize;
  1835. p.updateProgress(index/len, '开始导入' + index/len*100 + '%', true);
  1836. Ext.Ajax.request({
  1837. url: basePath + 'system/toFormalData.action',
  1838. timeout: 30000,
  1839. method: 'post',
  1840. async: false,
  1841. params: {
  1842. id: grid.ilid,
  1843. start: a,
  1844. end: b
  1845. },
  1846. callback: function(_opt, _s, _r){
  1847. var rs = Ext.decode(_r.responseText);
  1848. if(rs.exceptionInfo) {
  1849. grid.setLoading(false);
  1850. p.destroy();
  1851. showError(rs.exceptionInfo);return;
  1852. } else if(_s){
  1853. index++;
  1854. p.updateProgress(index/len, '完成' + index/len*100 + '%', true);
  1855. if(index == len) {
  1856. grid.setLoading(false);
  1857. p.destroy();
  1858. alert('转入成功!');
  1859. Ext.Ajax.request({
  1860. url: basePath + 'system/afterToFormal.action',
  1861. params: {
  1862. id: grid.ilid
  1863. },
  1864. callback: function(){
  1865. }
  1866. });
  1867. }
  1868. } else
  1869. return;
  1870. }
  1871. });
  1872. page++;
  1873. }
  1874. } else {
  1875. grid.setLoading(false);
  1876. p.destroy();
  1877. showError(res.exceptionInfo);
  1878. }
  1879. }
  1880. });
  1881. },
  1882. /**
  1883. * 保存已修改的数据
  1884. */
  1885. saveUpdates: function(grid){
  1886. var items = grid.store.data.items,arr = new Array(), d;
  1887. Ext.each(items, function(item){
  1888. if(item.dirty) {
  1889. d = item.data;
  1890. delete d.log;
  1891. arr.push(d);
  1892. }
  1893. });
  1894. Ext.Ajax.request({
  1895. url: basePath + 'system/updateInitData.action',
  1896. method: 'post',
  1897. params: {
  1898. data: Ext.encode(arr)
  1899. },
  1900. callback: function(opt, s, r) {
  1901. var res = Ext.decode(r.responseText);
  1902. if(res.success) {
  1903. alert('保存成功!');
  1904. grid.getGridData(1);
  1905. }
  1906. }
  1907. });
  1908. },
  1909. /**
  1910. * 删除校验错误数据
  1911. */
  1912. deleteErrors: function(grid) {
  1913. Ext.Msg.alert('提示', '确定删除?', function(btn){
  1914. if(btn == 'ok') {
  1915. Ext.Ajax.request({
  1916. url: basePath + 'system/init/errdelete.action',
  1917. params: {
  1918. id: grid.ilid
  1919. },
  1920. callback: function(opt, s, r) {
  1921. var rs = Ext.decode(r.responseText);
  1922. if(rs.success) {
  1923. alert('删除成功!');
  1924. grid.getGridData(1);
  1925. }
  1926. }
  1927. });
  1928. }
  1929. });
  1930. },
  1931. parseLogic: function(logic) {
  1932. if(logic != null) {
  1933. var gc = logic.split(';'), str = '';
  1934. for(var i in gc) {
  1935. var s = gc[i];
  1936. if(s != null) {
  1937. if(s.indexOf('unique') > -1) {
  1938. str += '唯一性;';
  1939. } else if(s.indexOf('trim') > -1) {
  1940. str += '不能包含' + s.replace('trim', '') + ';';
  1941. } else if(s.indexOf('combo') > -1) {
  1942. str += '只能是' + s.replace('combo', '') + '之一;';
  1943. } else if(s.indexOf('accord') > -1) {
  1944. str += '必须存在于' + s.replace('accord', '') + '中;';
  1945. } else if(s.indexOf('diffence') > -1) {
  1946. str += '必须与' + s.replace('diffence', '') + '不同;';
  1947. }
  1948. }
  1949. }
  1950. return str;
  1951. }
  1952. return null;
  1953. },
  1954. getMixedGroups: function(items) {
  1955. var data = new Object(), k;
  1956. var name= new Array();
  1957. Ext.each(items, function(d) {
  1958. k = '',j='',n,name=[];
  1959. if(d!=null && d!=''){
  1960. name = d.split("-");
  1961. k=name[0];
  1962. if (k.length > 0) {
  1963. if (!data[k]) {
  1964. data[k] = {
  1965. keys: d,
  1966. groups: [name[1]||'']
  1967. };
  1968. } else {
  1969. data[k].groups.push(name[1]||'');
  1970. }
  1971. }
  1972. }
  1973. });
  1974. return data;
  1975. }
  1976. });