ProdRelation.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.bom.ProdRelation', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'core.form.Panel','pm.bom.ProdRelation','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField',
  9. 'core.button.Save','core.button.Add','core.button.Submit','core.button.ResAudit',
  10. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
  11. 'core.button.ResSubmit','core.button.Banned','core.button.ResBanned',
  12. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. 'erpGridPanel2': {
  18. itemclick: this.onGridItemClick
  19. },
  20. 'erpSaveButton': {
  21. click: function(btn){
  22. var me = this;
  23. var form = me.getForm(btn);
  24. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  25. me.BaseUtil.getRandomNumber();//自动添加编号
  26. }
  27. this.FormUtil.beforeSave(this);
  28. }
  29. },
  30. 'erpDeleteButton' : {
  31. click: function(btn){
  32. warnMsg("确定要删除单据吗?", function(btn){
  33. if(btn == 'yes'){
  34. var id= Ext.getCmp('prr_thisid').value;
  35. me.setLoading(true);
  36. Ext.Ajax.request({
  37. url : basePath + 'pm/bom/deleteProdRelation.action',
  38. params: {
  39. id: id
  40. },
  41. method : 'post',
  42. callback : function(options,success,response){
  43. me.setLoading(false);
  44. var localJson = new Ext.decode(response.responseText);
  45. if(localJson.exceptionInfo){
  46. showError(localJson.exceptionInfo);return;
  47. }
  48. if(localJson.success){
  49. delSuccess(function(){
  50. me.FormUtil.beforeClose(me);
  51. });//@i18n/i18n.js
  52. } else {
  53. delFailure();
  54. }
  55. }
  56. });
  57. }
  58. });
  59. }
  60. },
  61. 'erpUpdateButton': {
  62. click: function(btn){
  63. this.FormUtil.onUpdate(this);
  64. }
  65. },
  66. 'erpAddButton': {
  67. click: function(){
  68. me.FormUtil.onAdd('addProdRelation', '新增物料标准替代库', 'jsps/pm/bom/prodRelation.jsp');
  69. }
  70. },
  71. 'erpCloseButton': {
  72. click: function(btn){
  73. me.FormUtil.beforeClose(me);
  74. }
  75. },
  76. 'erpSubmitButton': {
  77. afterrender: function(btn){
  78. var status = Ext.getCmp('prr_usestatuscode');
  79. if(status && status.value != 'ENTERING'){
  80. btn.hide();
  81. }
  82. },
  83. click: function(btn){
  84. var me = this;
  85. var id= Ext.getCmp('prr_thisid').value;
  86. me.setLoading(true);//loading...
  87. Ext.Ajax.request({
  88. url : basePath + 'pm/bom/submitProdRelation.action',
  89. params: {
  90. id: id
  91. },
  92. method : 'post',
  93. callback : function(options,success,response){
  94. var localJson = new Ext.decode(response.responseText);
  95. if(localJson.exceptionInfo){
  96. var str = localJson.exceptionInfo;
  97. showError(str);
  98. }else {
  99. if(localJson.MultiAssign){
  100. me.showAssignWin(localJson.assigns,localJson.nodeId);
  101. }else {
  102. showMessage('提示', '提交成功!', 1000);
  103. window.location.reload();
  104. }
  105. }
  106. }
  107. });
  108. }
  109. },
  110. 'erpResSubmitButton': {
  111. afterrender: function(btn){
  112. var status = Ext.getCmp('prr_usestatuscode');
  113. if(status && status.value != 'COMMITED'){
  114. btn.hide();
  115. }
  116. },
  117. click: function(btn){
  118. var me = this;
  119. var id= Ext.getCmp('prr_thisid').value;
  120. me.setLoading(true);//loading...
  121. Ext.Ajax.request({
  122. url : basePath + 'pm/bom/resSubmitProdRelation.action',
  123. params: {
  124. id: id
  125. },
  126. method : 'post',
  127. callback : function(options,success,response){
  128. me.setLoading(false);
  129. var localJson = new Ext.decode(response.responseText);
  130. if(localJson.exceptionInfo){
  131. showError(localJson.exceptionInfo);
  132. }
  133. if(localJson.success){
  134. showMessage('提示', '反提交成功!', 1000);
  135. window.location.reload();
  136. }
  137. }
  138. });
  139. }
  140. },
  141. 'erpAuditButton': {
  142. afterrender: function(btn){
  143. var status = Ext.getCmp('prr_usestatuscode');
  144. if(status && status.value != 'COMMITED'){
  145. btn.hide();
  146. }
  147. },
  148. click: function(btn){
  149. var me = this;
  150. var id= Ext.getCmp('prr_thisid').value;
  151. me.setLoading(true);//loading...
  152. Ext.Ajax.request({
  153. url : basePath + 'pm/bom/auditProdRelation.action',
  154. params: {
  155. id: id
  156. },
  157. method : 'post',
  158. callback : function(options,success,response){
  159. var localJson = new Ext.decode(response.responseText);
  160. if(localJson.exceptionInfo){
  161. var str = localJson.exceptionInfo;
  162. showError(str);
  163. }else {
  164. if(localJson.MultiAssign){
  165. me.showAssignWin(localJson.assigns,localJson.nodeId);
  166. }else {
  167. showMessage('提示', '审核成功!', 1000);
  168. window.location.reload();
  169. }
  170. }
  171. }
  172. });
  173. }
  174. },
  175. 'erpResAuditButton': {
  176. afterrender: function(btn){
  177. var status = Ext.getCmp('prr_usestatuscode');
  178. if(status && status.value != 'AUDITED'){
  179. btn.hide();
  180. }
  181. },
  182. click: function(btn){
  183. var me = this;
  184. var id= Ext.getCmp('prr_thisid').value;
  185. me.setLoading(true);//loading...
  186. Ext.Ajax.request({
  187. url : basePath + 'pm/bom/resAuditProdRelation.action',
  188. params: {
  189. id: id
  190. },
  191. method : 'post',
  192. callback : function(options,success,response){
  193. me.setLoading(false);
  194. var localJson = new Ext.decode(response.responseText);
  195. if(localJson.exceptionInfo){
  196. showError(localJson.exceptionInfo);
  197. }
  198. if(localJson.success){
  199. showMessage('提示', '反审核成功!', 1000);
  200. window.location.reload();
  201. }
  202. }
  203. });
  204. }
  205. },
  206. 'erpBannedButton': {
  207. click: function(m){
  208. var me = this;
  209. me.turn('ProdRelation!Banned', ' prr_thisid=' + Ext.getCmp('prr_thisid').value +' and prr_usestatuscode=\'AUDITED\'', 'pm/bom/bannedProdRelation.action');
  210. }
  211. },
  212. 'dbfindtrigger[name=ra_topid]':{
  213. afterrender: function(){
  214. var id = Ext.getCmp('prr_thisid').value;
  215. if(id != null & id != ''){
  216. this.getProdRelationStore('prr_thisid=' + id);
  217. }
  218. },
  219. aftertrigger: function(){
  220. var id = Ext.getCmp('prr_thisid').value;
  221. if(id != null & id != ''){
  222. this.getProdRelationStore('prr_thisid=' + id);
  223. }
  224. }
  225. }
  226. });
  227. },
  228. onGridItemClick: function(selModel, record){//grid行选择
  229. this.GridUtil.onGridItemClick(selModel, record);
  230. },
  231. getForm: function(btn){
  232. return btn.ownerCt.ownerCt;
  233. },
  234. turn: function(nCaller, condition, url){
  235. var win = new Ext.window.Window({
  236. id : 'win',
  237. height: "100%",
  238. width: "80%",
  239. maximizable : true,
  240. buttonAlign : 'center',
  241. layout : 'anchor',
  242. items: [{
  243. tag : 'iframe',
  244. frame : true,
  245. anchor : '100% 100%',
  246. layout : 'fit',
  247. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/common/editorColumn.jsp?caller=' + nCaller
  248. + "&condition=" + condition +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  249. }],
  250. buttons : [{
  251. name: 'confirm',
  252. text : $I18N.common.button.erpConfirmButton,
  253. iconCls: 'x-button-icon-confirm',
  254. cls: 'x-btn-gray',
  255. listeners: {
  256. buffer: 500,
  257. click: function(btn) {
  258. var grid = Ext.getCmp('win').items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow.Ext.getCmp("editorColumnGridPanel");
  259. btn.setDisabled(true);
  260. grid.updateAction(url);
  261. window.location.reload();
  262. }
  263. }
  264. }, {
  265. text : $I18N.common.button.erpCloseButton,
  266. iconCls: 'x-button-icon-close',
  267. cls: 'x-btn-gray',
  268. handler : function(){
  269. Ext.getCmp('win').close();
  270. }
  271. }]
  272. });
  273. win.show();
  274. },
  275. getProdRelationStore: function(condition){
  276. var me = this;
  277. var grid = Ext.getCmp('grid');
  278. grid.store.removeAll(false);
  279. me.BaseUtil.getActiveTab().setLoading(true);//loading...
  280. Ext.Ajax.request({//拿到grid的columns
  281. url : basePath + "common/singleGridPanel.action",
  282. params: {
  283. caller: "ProdRelation",
  284. condition: condition
  285. },
  286. method : 'post',
  287. callback : function(options,success,response){
  288. me.BaseUtil.getActiveTab().setLoading(false);
  289. var res = new Ext.decode(response.responseText);
  290. if(res.exceptionInfo){
  291. showError(res.exceptionInfo);return;
  292. }
  293. var data = [];
  294. if(!res.data || res.data.length == 2){
  295. me.GridUtil.add10EmptyItems(grid);
  296. } else {
  297. data = Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  298. if(data.length > 0){
  299. grid.store.loadData(data);
  300. }
  301. }
  302. }
  303. });
  304. },
  305. setLoading : function(b) {
  306. var mask = this.mask;
  307. if (!mask) {
  308. this.mask = mask = new Ext.LoadMask(Ext.getBody(), {
  309. msg : "处理中,请稍后...",
  310. msgCls : 'z-index:10000;'
  311. });
  312. }
  313. if (b)
  314. mask.show();
  315. else
  316. mask.hide();
  317. }
  318. });