SvnLog.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.SvnLog', {
  3. extend : 'Ext.app.Controller',
  4. requires : [ 'erp.util.BaseUtil' ],
  5. views : [ 'ma.SvnLog', 'core.form.FtDateField' ],
  6. refs : [ {
  7. ref : 'date',
  8. selector : '#date'
  9. }, {
  10. ref : 'remark',
  11. selector : '#remark'
  12. }, {
  13. ref : 'grid',
  14. selector : '#grid'
  15. }, {
  16. ref: 'paging',
  17. selector : '#grid > pagingtoolbar'
  18. }, {
  19. ref: 'switch',
  20. selector : '#switch'
  21. }, {
  22. ref: 'unAudit',
  23. selector : '#unaudit'
  24. }, {
  25. ref: 'unTest',
  26. selector : '#untest'
  27. }, {
  28. ref: 'svninfo',
  29. selector : '#svninfo'
  30. }],
  31. init : function() {
  32. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  33. var me = this;
  34. this.control({
  35. '#refresh' : {
  36. click : function(btn) {
  37. if (me.getPaging().fireEvent('beforechange', me.getPaging(), 1) !== false){
  38. me.search(0);
  39. }
  40. }
  41. },
  42. '#close' : {
  43. click : function() {
  44. this.BaseUtil.getActiveTab().close();
  45. }
  46. },
  47. '#date' : {
  48. afterrender : function(field) {
  49. field.setValues(me.getDateArea('m', -1), me.getDateArea('d', 0));
  50. }
  51. },
  52. '#grid' : {
  53. afterrender : function() {
  54. me.search(0);
  55. }
  56. },
  57. '#switch' : {
  58. change : function() {
  59. me.search(0);
  60. }
  61. },
  62. '#unaudit' : {
  63. change : function() {
  64. me.search(0);
  65. }
  66. },
  67. '#untest' : {
  68. change : function() {
  69. me.search(0);
  70. }
  71. },
  72. 'button' : {
  73. click : function(btn) {
  74. if (btn.param) {
  75. var a = btn.param[0], b = btn.param[2], m = btn.param[1], n = btn.param[3];
  76. me.getDate().setValues(me.getDateArea(a, m), me.getDateArea(b, n));
  77. if (me.getPaging().fireEvent('beforechange', me.getPaging(), 1) !== false){
  78. me.search(0);
  79. }
  80. }
  81. }
  82. },
  83. '#svninfo' : {
  84. afterrender: function(field) {
  85. // 系统程序版本
  86. Ext.Ajax.request({
  87. url: basePath + 'common/svninfo.html',
  88. callback: function(scope, success, response) {
  89. if(response.status == 200) {
  90. field.setValue(response.responseText);
  91. }
  92. }
  93. });
  94. }
  95. },
  96. '#svnlast' : {
  97. afterrender: function(field) {
  98. // 系统程序版本
  99. Ext.Ajax.request({
  100. url: basePath + 'ma/svn/version.action',
  101. callback: function(scope, success, response) {
  102. if(response.status == 200) {
  103. var rs = Ext.decode(response.responseText);
  104. field.setValue(rs.version);
  105. }
  106. }
  107. });
  108. }
  109. },
  110. 'menuitem[name=item-changedetail]': {
  111. click: function(m) {
  112. me.showDetail(m.ownerCt.record);
  113. }
  114. }
  115. });
  116. },
  117. getDateArea : function(type, val) {
  118. var today = new Date(), year = today.getFullYear(), month = today.getMonth(), day = today.getDate();
  119. if (type == 'd') {
  120. return new Date(year, month, day + val);
  121. } else if (type == 'm') {
  122. return new Date(year, month + val, val == 0 ? 1 : day);
  123. } else if (type == 'y') {
  124. return new Date(year + val, val == 0 ? 0 : month, val == 0 ? 1 : day);
  125. }
  126. },
  127. search : function(start) {
  128. var me = this, store = me.getGrid().store,
  129. condition = me.toUnicode(me.getCondition());
  130. me.getGrid().condition = condition;
  131. store.load({
  132. params : {
  133. start : start,
  134. limit : store.pageSize,
  135. condition : condition
  136. }
  137. });
  138. },
  139. getCondition : function() {
  140. var dateF = this.getDate(),
  141. remark = this.getRemark().value,
  142. onlyNew = this.getSwitch().getValue(),
  143. onlyUnAudit = this.getUnAudit().getValue(),
  144. onlyUnTest = this.getUnTest().getValue(),
  145. version = this.getSvninfo().getValue(),
  146. filter = {};
  147. if (dateF.value != null && dateF.value.length > 0) {
  148. filter.date = {"gted": dateF.firstItem.value.getTime(), "lted": dateF.secondItem.value.getTime() + 86399999};
  149. }
  150. if (remark != null && remark.length > 0) {
  151. filter.remark = remark;
  152. }
  153. if (onlyNew && version != null) {
  154. filter.version = {"gt": version};
  155. }
  156. if (onlyUnAudit) {
  157. filter.auditor = {"eq": null};
  158. }
  159. if (onlyUnTest) {
  160. filter.tester = {"eq": null};
  161. }
  162. return Ext.encode(filter);
  163. },
  164. toUnicode : function(s) {
  165. return s.replace(/([\u4E00-\u9FA5]|[\uFE30-\uFFA0])/g, function() {
  166. return "\\u" + RegExp["$1"].charCodeAt(0).toString(16);
  167. });
  168. },
  169. showDetail : function(record) {
  170. var me = this, win = me.detailWin;
  171. if (!win) {
  172. win = this.detailWin = Ext.create('Ext.Window', {
  173. title: '详细',
  174. height: 300,
  175. width: 500,
  176. autoScroll: true,
  177. closeAction: 'hide',
  178. items: [{
  179. xtype: 'displayfield',
  180. width: '100%'
  181. }]
  182. });
  183. }
  184. var changed = record.get('changed').split('\n'), vals = [];
  185. for(var i in changed) {
  186. vals.push(me.parseSvnLog(changed[i]));
  187. }
  188. win.down('displayfield').setValue(vals.join('<br>'));
  189. win.setTitle(record.get('remark'));
  190. win.show();
  191. },
  192. parseSvnLog: function(val) {
  193. var ch = val.substr(0,1);
  194. switch(ch){
  195. case 'U':
  196. ch = '修改';break;
  197. case 'A':
  198. ch = '新增';break;
  199. case 'D':
  200. ch = '删除';break;
  201. }
  202. return ch + val.substr(1);
  203. }
  204. });