Import.js 60 KB

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