Conf.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.Conf', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views: ['ma.Conf'],
  6. init:function(){
  7. var me = this;
  8. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  9. this.control({
  10. 'button[id=condition]': {
  11. afterrender: function(btn) {
  12. setTimeout(function(){
  13. me.showFilterPanel(btn);
  14. }, 200);
  15. },
  16. click: function(btn) {
  17. me.showFilterPanel(btn);
  18. }
  19. },
  20. 'triggerfield[name=sn_displayname]': {
  21. afterrender: function(f){
  22. f.onTriggerClick = function(){
  23. me.getLogicTree();
  24. };
  25. }
  26. },
  27. 'treepanel': {
  28. itemmousedown: function(selModel, record){
  29. var tree = selModel.ownerCt;
  30. me.loadTree(tree, record);
  31. }
  32. },
  33. '#analysis': {
  34. click: function(btn) {
  35. btn.ownerCt.ownerCt.hide();
  36. var cal = Ext.getCmp('sn_caller').value;
  37. if(!Ext.isEmpty(cal)) {
  38. var record = me.lastSelected;
  39. this.errors = 0;
  40. Ext.getCmp('logger').setValue('');
  41. Ext.getCmp('sync').hide();
  42. me.BaseUtil.getActiveTab().setLoading(true);
  43. Ext.Ajax.request({
  44. url: basePath + 'ma/sync.action',
  45. params: {
  46. caller: cal,
  47. path: record.getPath('id', '/').replace('/root/', ''),
  48. spath: record.getPath('text', '/').replace('/root/', '')
  49. },
  50. callback: function(opt, s, r) {
  51. me.BaseUtil.getActiveTab().setLoading(false);
  52. if(s) {
  53. var rs = Ext.decode(r.responseText);
  54. if(rs.navigation) {
  55. me.compareNavigation(rs.navigation);
  56. }
  57. if(rs.form) {
  58. me.compareForm(rs.form);
  59. }
  60. if(rs.detailgrid) {
  61. me.compareGrid(rs.detailgrid);
  62. }
  63. }
  64. }
  65. });
  66. }
  67. }
  68. },
  69. '#others': {
  70. click: function(btn) {
  71. me.showOtherConf();
  72. }
  73. }
  74. });
  75. },
  76. count: function(n) {
  77. if(!this.errors) {
  78. this.errors = 0;
  79. }
  80. n = n == null ? 1 : n;
  81. this.errors += n;
  82. Ext.getCmp('logger').setValue('共发现 ' + this.errors + '个差异项');
  83. Ext.getCmp('sync').show();
  84. },
  85. compareNavigation: function(navigation) {
  86. var usoft = navigation[0], current = navigation[1], dd = [], isExist = usoft.sn_Id != null;
  87. dd[0] = {conf: '描述', usoft: isExist ? usoft.sn_DisplayName : usoft, current: current.sn_DisplayName};
  88. dd[1] = {conf: '链接', usoft: isExist ? usoft.sn_Url : '--', current: current.sn_Url};
  89. dd[2] = {conf: '序号', usoft: isExist ? usoft.sn_detno : '--', current: current.sn_detno};
  90. dd[3] = {conf: '是否叶节点', usoft: isExist ? usoft.sn_isleaf : '--', current: current.sn_isleaf};
  91. dd[4] = {conf: '显示模式', usoft: isExist ? usoft.sn_showmode : '--', current: current.sn_showmode};
  92. dd[5] = {conf: '允许删除', usoft: isExist ? usoft.sn_deleteable : '--', current: current.sn_deleteable};
  93. dd[6] = {conf: '是否启用', usoft: isExist ? usoft.sn_using : '--', current: current.sn_using};
  94. dd[7] = {conf: '允许扩展逻辑', usoft: isExist ? usoft.sn_logic : '--', current: current.sn_logic};
  95. dd[8] = {conf: 'Caller', usoft: isExist ? usoft.sn_caller : '--', current: current.sn_caller};
  96. Ext.getCmp('navigation').store.loadData(dd);
  97. if(!this.equals(usoft, current, ['sn_Id', 'sn_ParentId'])) {
  98. this.count();
  99. }
  100. },
  101. compareForm: function(forms) {
  102. var me = this, usoft = forms[0], current = forms[1], dd = [],
  103. isExist = usoft != null && usoft.fo_id != null,
  104. _isExist = current != null && current.fo_id != null;
  105. dd[0] = {conf: '详细', usoft: isExist ? ('共' + usoft.formDetails.length + '条<button>展开</button>') : usoft, current:
  106. _isExist ? '共' + current.formDetails.length + '条<button>展开</button>' : ''};
  107. if(isExist) {//比较FormDetail
  108. var u = usoft.formDetails, c = current.formDetails, n = 0;
  109. for(var i in u) {
  110. var x = u[i], y = null;
  111. for(var j in c) {
  112. if(x.fd_field == c[j].fd_field) {
  113. y = c[j];
  114. }
  115. }
  116. if(!y || !me.equals(x, y, ['fd_id', 'fd_foid'])) {
  117. n++;
  118. }
  119. }
  120. if(n > 0) {
  121. dd[0].result = n;
  122. this.count(n);
  123. }
  124. }
  125. dd[1] = {conf: 'Caller', usoft: isExist ? usoft.fo_caller : '--', current: _isExist ? current.fo_caller : '--'};
  126. dd[2] = {conf: '表名', usoft: isExist ? usoft.fo_table : '--', current: _isExist ? current.fo_table : '--'};
  127. dd[3] = {conf: '界面名称', usoft: isExist ? usoft.fo_title : '--', current: _isExist ? current.fo_title : '--'};
  128. dd[4] = {conf: '主表关键字', usoft: isExist ? usoft.fo_keyfield : '--', current: _isExist ? current.fo_keyfield : '--'};
  129. dd[5] = {conf: 'Code字段', usoft: isExist ? usoft.fo_codefield : '--', current: _isExist ? current.fo_codefield : '--'};
  130. dd[6] = {conf: '明细表名', usoft: isExist ? usoft.fo_detailtable : '--', current: _isExist ? current.fo_detailtable : '--'};
  131. dd[7] = {conf: '明细关联字段', usoft: isExist ? usoft.fo_detailmainkeyfield : '--', current: _isExist ? current.fo_detailmainkeyfield : '--'};
  132. dd[8] = {conf: '明细orderby', usoft: isExist ? usoft.fo_detailgridorderby : '--', current: _isExist ? current.fo_detailgridorderby : '--'};
  133. dd[9] = {conf: '明细序号字段', usoft: isExist ? usoft.fo_detaildetnofield : '--', current: _isExist ? current.fo_detaildetnofield : '--'};
  134. dd[10] = {conf: 'Buttons(新增)', usoft: isExist ? usoft.fo_button4add : '--', current: _isExist ? current.fo_button4add : '--'};
  135. dd[11] = {conf: 'Buttons(读写)', usoft: isExist ? usoft.fo_button4rw : '--', current: _isExist ? current.fo_button4rw : '--'};
  136. dd[12] = {conf: '审批流Caller', usoft: isExist ? usoft.fo_flowcaller : '--', current: _isExist ? current.fo_flowcaller : '--'};
  137. dd[13] = {conf: '状态字段', usoft: isExist ? usoft.fo_statusfield : '--', current: _isExist ? current.fo_statusfield : '--'};
  138. dd[14] = {conf: '状态码字段', usoft: isExist ? usoft.fo_statuscodefield : '--', current: _isExist ? current.fo_statuscodefield : '--'};
  139. dd[15] = {conf: '明细状态', usoft: isExist ? usoft.fo_detailstatus : '--', current: _isExist ? current.fo_detailstatus : '--'};
  140. dd[16] = {conf: '明细状态码', usoft: isExist ? usoft.fo_detailstatuscode : '--', current: _isExist ? current.fo_detailstatuscode : '--'};
  141. dd[17] = {conf: '录入人字段', usoft: isExist ? usoft.fo_recorderfield : '--', current: _isExist ? current.fo_recorderfield : '--'};
  142. dd[18] = {conf: '提交触发流程', usoft: isExist ? usoft.fo_isautoflow : '--', current: _isExist ? current.fo_isautoflow : '--'};
  143. Ext.getCmp('form').store.loadData(dd);
  144. if(!this.equals(usoft, current, ['fo_id', 'formDetails'])) {
  145. this.count();
  146. }
  147. },
  148. compareGrid: function(grids) {
  149. var me = this, usoft = grids[0], current = grids[1], dd = [],
  150. isExist = usoft instanceof Array,
  151. _isExist = current instanceof Array;
  152. dd[0] = {conf: '详细', usoft: isExist ? ('共' + usoft.length + '条<button>展开</button>') : usoft, current:
  153. _isExist ? '共' + current.length + '条<button>展开</button>' : ''};
  154. if(isExist) {
  155. var n = 0;
  156. for(var i in usoft) {
  157. var x = usoft[i], y = null;
  158. for(var j in current) {
  159. if(x.dg_field == current[j].dg_field) {
  160. y = current[j];
  161. }
  162. }
  163. if(!y || !me.equals(x, y, ['dg_id'])) {
  164. n++;
  165. }
  166. }
  167. if(n > 0) {
  168. dd[0].result = n;
  169. this.count(n);
  170. }
  171. }
  172. Ext.getCmp('detailgrid').store.loadData(dd);
  173. },
  174. compareDbfindSetui: function(sets) {
  175. var me = this, usoft = sets[0], current = sets[1], dd = [],
  176. isExist = usoft instanceof Array,
  177. _isExist = current instanceof Array;
  178. dd[0] = {conf: '详细', usoft: isExist ? ('共' + usoft.length + '条<button>展开</button>') : usoft, current:
  179. _isExist ? '共' + current.length + '条<button>展开</button>' : ''};
  180. if(isExist) {
  181. var n = 0;
  182. for(var i in usoft) {
  183. var x = usoft[i], y = null;
  184. for(var j in current) {
  185. if(x.ds_whichui == current[j].ds_whichui) {
  186. y = current[j];
  187. }
  188. }
  189. if(!y || !me.equals(x, y, ['ds_id'])) {
  190. n++;
  191. }
  192. }
  193. if(n > 0) {
  194. dd[0].result = n;
  195. this.count(n);
  196. }
  197. }
  198. Ext.getCmp('dbfindsetui').store.loadData(dd);
  199. },
  200. compareDbfindSet: function(sets) {
  201. var me = this, usoft = sets[0], current = sets[1], dd = [],
  202. isExist = usoft instanceof Array,
  203. _isExist = current instanceof Array;
  204. if(isExist) {
  205. var n = 0;
  206. for(var i in usoft) {
  207. var x = usoft[i], y = null;
  208. dd[0 + 7*i] = {conf: 'Caller', usoft: x.ds_caller, current: ''};
  209. dd[1 + 7*i] = {conf: '表名', usoft: x.ds_tablename, current: ''};
  210. dd[2 + 7*i] = {conf: '描述', usoft: x.ds_caption, current: ''};
  211. dd[3 + 7*i] = {conf: '分组SQL', usoft: x.ds_groupby, current: ''};
  212. dd[4 + 7*i] = {conf: '排序SQL', usoft: x.ds_orderby, current: ''};
  213. dd[5 + 7*i] = {conf: '筛选条件', usoft: x.ds_fixedcondition, current: ''};
  214. dd[6 + 7*i] = {conf: '明细', usoft: '共' + x.dbFindSetDetails.length + '条<button>展开</button>',
  215. current: ''};
  216. for(var j in current) {
  217. if(x.ds_caller == current[j].ds_caller) {
  218. y = current[j];
  219. dd[0 + 7*i].current = y.ds_caller;
  220. dd[1 + 7*i].current;
  221. dd[2 + 7*i].current;
  222. dd[3 + 7*i].current;
  223. dd[4 + 7*i].current;
  224. dd[5 + 7*i].current;
  225. dd[6 + 7*i].current;
  226. }
  227. }
  228. if(y) {
  229. }
  230. if(!y || !me.equals(x, y, ['ds_id'])) {
  231. n++;
  232. }
  233. }
  234. if(n > 0) {
  235. dd[0].result = n;
  236. this.count(n);
  237. }
  238. }
  239. Ext.getCmp('dbfindset').store.loadData(dd);
  240. },
  241. getLogicTree: function(){
  242. var me = this;
  243. var w = Ext.create('Ext.Window',{
  244. title: '查找',
  245. height: "100%",
  246. width: "80%",
  247. maximizable : true,
  248. buttonAlign : 'center',
  249. layout : 'anchor',
  250. items: [{
  251. anchor: '100% 100%',
  252. xtype: 'treepanel',
  253. rootVisible: false,
  254. useArrows: true,
  255. store: Ext.create('Ext.data.TreeStore', {
  256. root : {
  257. text: 'root',
  258. id: 'root',
  259. expanded: true
  260. }
  261. })
  262. }],
  263. buttons : [{
  264. text : '关 闭',
  265. iconCls: 'x-button-icon-close',
  266. cls: 'x-btn-gray',
  267. handler : function(btn){
  268. btn.ownerCt.ownerCt.close();
  269. }
  270. },{
  271. text: '确定',
  272. iconCls: 'x-button-icon-confirm',
  273. cls: 'x-btn-gray',
  274. handler: function(btn){
  275. var t = btn.ownerCt.ownerCt.down('treepanel'),
  276. record = t.selModel.lastSelected;
  277. if(record && record.data.leaf && record.data.caller) {
  278. Ext.getCmp('sn_displayname').setValue(record.data.text);
  279. Ext.getCmp('sn_caller').setValue(record.data.caller);
  280. Ext.getCmp('sn_caller').show();
  281. me.lastSelected = record;
  282. btn.ownerCt.ownerCt.close();
  283. }
  284. }
  285. }]
  286. });
  287. w.show();
  288. this.loadTree(w.down('treepanel'), null);
  289. },
  290. loadTree: function(tree, record){
  291. var pid = 0;
  292. if(record) {
  293. if (record.get('leaf')) {
  294. return;
  295. } else {
  296. if(record.isExpanded() && record.childNodes.length > 0){
  297. record.collapse(true, true);//收拢
  298. return;
  299. } else {
  300. if(record.childNodes.length != 0){
  301. record.expand(false, true);//展开
  302. return;
  303. }
  304. }
  305. }
  306. pid = record.get('id');
  307. }
  308. tree.setLoading(true);
  309. Ext.Ajax.request({
  310. url : basePath + 'ma/lazyTree.action',
  311. params: {
  312. parentId: pid,
  313. condition: 'sn_limit=1'
  314. },
  315. callback : function(options,success,response){
  316. tree.setLoading(false);
  317. var res = new Ext.decode(response.responseText);
  318. if(res.tree){
  319. if(record) {
  320. record.appendChild(res.tree);
  321. record.expand(false,true);//展开
  322. tree.setTitle(record.getPath('text', '/').replace('root', '').replace('//', '/'));
  323. } else {
  324. tree.store.setRootNode({
  325. text: 'root',
  326. id: 'root',
  327. expanded: true,
  328. children: res.tree
  329. });
  330. }
  331. } else if(res.exceptionInfo){
  332. showError(res.exceptionInfo);
  333. }
  334. }
  335. });
  336. },
  337. showFilterPanel: function(btn) {
  338. var filter = Ext.getCmp(btn.getId() + '-filter');
  339. if(!filter) {
  340. filter = this.createFilterPanel(btn);
  341. }
  342. filter.show();
  343. },
  344. hideFilterPanel: function(btn) {
  345. var filter = Ext.getCmp(btn.getId() + '-filter');
  346. if(filter) {
  347. filter.hide();
  348. }
  349. },
  350. createFilterPanel: function(btn) {
  351. var filter = Ext.create('Ext.Window', {
  352. id: btn.getId() + '-filter',
  353. style: 'background:#f1f1f1',
  354. title: '条件',
  355. width: 500,
  356. height: 300,
  357. layout: 'column',
  358. defaults: {
  359. margin: '2 2 2 10'
  360. },
  361. items: [{
  362. xtype: 'fieldset',
  363. title: '按导航栏查询',
  364. checkboxToggle: true,
  365. items: [{
  366. xtype: 'displayfield',
  367. value: '* 根据导航栏节点配置的Caller,分析关联的Form、DetailGrid、DataList、Dbfind、Button、Table、DataDictionary、Index等的配置差异'
  368. },{
  369. xtype: 'triggerfield',
  370. triggerCls: 'x-form-search-trigger',
  371. fieldLabel: '选择页面',
  372. name: 'sn_displayname',
  373. id: 'sn_displayname',
  374. margin: '3 10 3 3',
  375. width: 400
  376. }, {
  377. xtype: 'displayfield',
  378. hidden: true,
  379. name: 'sn_caller',
  380. id: 'sn_caller'
  381. }]
  382. }, {
  383. xtype: 'fieldset',
  384. title: '按Caller查询',
  385. checkboxToggle: true,
  386. collapsed: true,
  387. }, {
  388. xtype: 'fieldset',
  389. title: '按Table查询',
  390. checkboxToggle: true,
  391. collapsed: true,
  392. }],
  393. buttonAlign: 'center',
  394. buttons: [{
  395. text: '确定',
  396. cls: 'x-btn-blue',
  397. id: 'analysis'
  398. }, {
  399. text: '关闭',
  400. cls: 'x-btn-blue',
  401. handler: function(btn) {
  402. btn.ownerCt.ownerCt.hide();
  403. }
  404. }]
  405. });
  406. return filter;
  407. },
  408. showOtherConf: function() {
  409. var win = Ext.getCmp('win-others');
  410. if(!win) {
  411. win = Ext.create('Ext.Window', {
  412. id: 'win-others',
  413. style: 'background:#f1f1f1',
  414. title: '其它配置项',
  415. width: 500,
  416. height: 300,
  417. layout: 'column',
  418. defaults: {
  419. margin: '2 2 2 10',
  420. xtype: 'checkbox',
  421. columnWidth: .33,
  422. checked: true
  423. },
  424. items: [{
  425. boxLabel: '全选/反选',
  426. columnWidth: 1,
  427. listeners: {
  428. change: function(f) {
  429. var g = f.ownerCt.down('checkboxgroup');
  430. if(f.checked) {
  431. Ext.each(g.items.items, function(c){
  432. c.setValue(true);
  433. });
  434. } else {
  435. Ext.each(g.getChecked(), function(c){
  436. c.setValue(false);
  437. });
  438. }
  439. }
  440. }
  441. }, {
  442. xtype: 'checkboxgroup',
  443. fieldLabel: '',
  444. columnWidth: 1,
  445. columns: 2,
  446. vertical: true,
  447. items: [
  448. { boxLabel: '特殊权限库', name: 'rb', inputValue: '1' },
  449. { boxLabel: '业务逻辑设计', name: 'rb', inputValue: '2', checked: true },
  450. { boxLabel: '出入库参数', name: 'rb', inputValue: '4' },
  451. { boxLabel: '初始化系统配置', name: 'rb', inputValue: '5' },
  452. { boxLabel: '数据库视图', name: 'rb', inputValue: '6' },
  453. { boxLabel: '数据库函数', name: 'rb', inputValue: '7' },
  454. { boxLabel: '数据库类型', name: 'rb', inputValue: '8' },
  455. { boxLabel: '数据库过程', name: 'rb', inputValue: '9' }
  456. ]
  457. }]
  458. });
  459. }
  460. win.show();
  461. },
  462. equals: function( x, y, ignores ) {
  463. var me = this;
  464. if ( x === y ) {
  465. return true;
  466. }
  467. if ( ! ( x instanceof Object ) || ! ( y instanceof Object ) ) {
  468. return false;
  469. }
  470. if ( x.constructor !== y.constructor ) {
  471. return false;
  472. }
  473. for ( var p in x ) {
  474. var b = true;
  475. for( var i in ignores ) {
  476. if(ignores[i] == p) {
  477. b = false;
  478. break;
  479. }
  480. }
  481. if( !b ) {
  482. continue;
  483. }
  484. if ( x.hasOwnProperty( p ) ) {
  485. if ( ! y.hasOwnProperty( p ) ) {
  486. return false;
  487. }
  488. if ( x[ p ] === y[ p ] ) {
  489. continue;
  490. }
  491. if ( typeof( x[ p ] ) !== "object" ) {
  492. return false;
  493. }
  494. if ( ! me.equals( x[ p ], y[ p ] ) ) {
  495. return false;
  496. }
  497. }
  498. }
  499. for ( p in y ) {
  500. var b = true;
  501. for( var i in ignores ) {
  502. if(ignores[i] == p) {
  503. b = false;
  504. break;
  505. }
  506. }
  507. if( !b ) {
  508. continue;
  509. }
  510. if ( y.hasOwnProperty( p ) && ! x.hasOwnProperty( p ) ) {
  511. return false;
  512. }
  513. }
  514. return true;
  515. }
  516. });