Rework.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.make.Rework', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. views:[
  8. 'pm.make.Rework','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar','core.button.SNRange',
  9. 'core.button.Add','core.button.Save','core.button.Close','core.button.StepCollection',
  10. 'core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.ResAudit',
  11. 'core.button.Update','core.button.Delete','core.form.YnField','core.button.OnlineMake','core.button.Modify',
  12. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.button.OpenMake','core.button.DecomSetting'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. 'erpGridPanel2': {
  18. reconfigure: function(grid){
  19. Ext.defer(function(){
  20. grid.readOnly = true;
  21. }, 500);
  22. },
  23. itemclick: this.onGridItemClick
  24. },
  25. 'erpSaveButton': {
  26. click: function(btn){
  27. var form = me.getForm(btn);
  28. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  29. me.BaseUtil.getRandomNumber();//自动添加编号
  30. }
  31. this.FormUtil.beforeSave(this);
  32. }
  33. },
  34. 'erpCloseButton': {
  35. click: function(btn){
  36. this.FormUtil.beforeClose(this);
  37. }
  38. },
  39. 'erpAddButton': {
  40. click: function(){
  41. me.FormUtil.onAdd('addMakeBase', '新增单据', 'jsps/pm/make/rework.jsp?whoami=' + caller);
  42. }
  43. },
  44. 'erpUpdateButton': {
  45. click: function(btn){
  46. this.FormUtil.onUpdate(this);
  47. }
  48. },
  49. 'erpDeleteButton': {
  50. click: function(btn){
  51. me.FormUtil.onDelete(Ext.getCmp('re_id').value);
  52. }
  53. },
  54. 'erpSubmitButton': {
  55. afterrender: function(btn){
  56. var status = Ext.getCmp('re_statuscode');
  57. if(status && status.value != 'ENTERING'){
  58. btn.hide();
  59. }
  60. },
  61. click: function(btn){
  62. me.FormUtil.onSubmit(Ext.getCmp('re_id').value);
  63. }
  64. },
  65. 'erpResSubmitButton': {
  66. afterrender: function(btn){
  67. var status = Ext.getCmp('re_statuscode');
  68. if(status && status.value != 'COMMITED'){
  69. btn.hide();
  70. }
  71. },
  72. click: function(btn){
  73. me.FormUtil.onResSubmit(Ext.getCmp('re_id').value);
  74. }
  75. },
  76. 'erpAuditButton': {
  77. afterrender: function(btn){
  78. var status = Ext.getCmp('re_statuscode');
  79. if(status && status.value != 'COMMITED'){
  80. btn.hide();
  81. }
  82. },
  83. click: function(btn){
  84. me.FormUtil.onAudit(Ext.getCmp('re_id').value);
  85. }
  86. },
  87. 'erpResAuditButton': {
  88. afterrender: function(btn){
  89. var status = Ext.getCmp('re_statuscode');
  90. if(status && status.value != 'AUDITED'){
  91. btn.hide();
  92. }
  93. },
  94. click: function(btn){
  95. me.FormUtil.onResAudit(Ext.getCmp('re_id').value);
  96. }
  97. },
  98. 'erpOnlineMakeButton' :{
  99. afterrender: function(btn){
  100. var status = Ext.getCmp('re_statuscode');
  101. if(status && status.value != 'AUDITED'){
  102. btn.hide();
  103. }
  104. },
  105. click: function(btn){
  106. me.onlineMake(Ext.getCmp('re_id').value);
  107. }
  108. },
  109. 'erpOpenMakeButton' :{
  110. afterrender: function(btn){
  111. var status = Ext.getCmp('re_statuscode');
  112. if(status && status.value != 'AUDITED'){
  113. btn.hide();
  114. }
  115. },
  116. click: function(btn){
  117. me.openMake(Ext.getCmp('re_id').value);
  118. }
  119. },
  120. 'erpDecomSettingButton':{
  121. /*afterrender: function(btn){
  122. var grid = Ext.getCmp('grid');
  123. var bool = true;
  124. var s = grid.getStore().data.items;//获取store里面的数据
  125. console.log(s.length);
  126. for(var i=0;i<s.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
  127. var data = s[i].data;
  128. }
  129. Ext.Array.each(grid.getStore().data.items,function(item){
  130. if(item.data['rd_detno'] != null && item.data['rd_detno'] != '' ){
  131. bool = false;
  132. }
  133. });
  134. if(bool){
  135. btn.setDisabled(true);
  136. }
  137. },*/
  138. click: function(btn){
  139. var id = Ext.getCmp('re_id').value;
  140. var caller = 'DecomSetting';
  141. var grid = Ext.getCmp('grid');
  142. var items = grid.getStore().data.items;//获取store里面的数据
  143. var bool = false;
  144. Ext.Array.each(items,function(item){
  145. if(item.data['rd_sncode'] != null && item.data['rd_sncode'] != '' ){
  146. bool = true;
  147. }
  148. });
  149. if(!bool){
  150. showError("不存在序列号");return;
  151. }
  152. var dbwin = new Ext.window.Window({
  153. id : 'dcswin',
  154. title: '拆解部件设定',
  155. height: "100%",
  156. width: "90%",
  157. maximizable : true,
  158. buttonAlign : 'center',
  159. layout : 'anchor',
  160. items: [],
  161. listeners:{
  162. beforeclose: function(){
  163. window.location.reload();
  164. }
  165. }
  166. });
  167. dbwin.add({
  168. tag : 'iframe',
  169. frame : true,
  170. anchor : '100% 100%',
  171. layout : 'fit',
  172. html : '<iframe id="iframe_Updatebomlevel" src="'+basePath+'jsps/pm/make/decomSetting.jsp?whoami='+caller+'&formCondition=re_idIS'+id+'&gridCondition=rd_reidIS'+id+'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  173. });
  174. dbwin.show();
  175. }
  176. },
  177. 'erpSNRangeButton':{
  178. afterrender: function(btn){
  179. var status = Ext.getCmp('re_statuscode');
  180. if(status && status.value == 'AUDITED'){
  181. btn.hide();
  182. }
  183. },
  184. click: function(btn){
  185. var id = Ext.getCmp('re_id').value;
  186. var dbwin = new Ext.window.Window({
  187. id : 'dbwin',
  188. title: '序列号范围',
  189. height: "100%",
  190. width: "80%",
  191. maximizable : true,
  192. buttonAlign : 'center',
  193. layout : 'anchor',
  194. items: [],
  195. listeners:{
  196. beforeclose: function(){
  197. window.location.reload();
  198. }
  199. }
  200. });
  201. dbwin.add({
  202. tag : 'iframe',
  203. frame : true,
  204. anchor : '100% 100%',
  205. layout : 'fit',
  206. html : '<iframe id="iframe_Updatebomlevel" src="'+basePath+'jsps/pm/make/snRange.jsp?whoami=SNRange&formCondition=re_idIS'+id+'&gridCondition=rd_reidIS'+id+'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  207. });
  208. dbwin.show();
  209. }
  210. },
  211. 'dbfindtrigger[name=re_craftcode]': {
  212. beforetrigger: function(field) {
  213. var t = field.up('form').down('field[name=re_prodcode]'),
  214. value = t.getValue();
  215. if(value) {
  216. field.findConfig = "cr_prodcode='" + value + "'";
  217. }
  218. }
  219. }
  220. });
  221. },
  222. onGridItemClick: function(selModel, record){//grid行选择
  223. this.GridUtil.onGridItemClick(selModel, record);
  224. },
  225. getForm: function(btn){
  226. return btn.ownerCt.ownerCt;
  227. },
  228. onlineMake: function(id){
  229. var mm = this;
  230. mm.FormUtil.setLoading(true);
  231. Ext.Ajax.request({
  232. url : basePath + "pm/make/onlinemake.action",
  233. params: {
  234. id : id,
  235. caller : caller
  236. },
  237. method : 'post',
  238. callback : function(options,success,response){
  239. mm.FormUtil.setLoading(false);
  240. var res = new Ext.decode(response.responseText);
  241. if(res.exceptionInfo != null){
  242. showError(res.exceptionInfo);return;
  243. }else{
  244. Ext.Msg.alert("提示","在线返工成功!",function(){
  245. window.location.reload();
  246. });
  247. }
  248. }
  249. });
  250. },
  251. openMake: function(id){
  252. var mm = this;
  253. mm.FormUtil.setLoading(true);
  254. Ext.Ajax.request({
  255. url : basePath + "pm/make/openmake.action",
  256. params: {
  257. id : id,
  258. caller : caller
  259. },
  260. method : 'post',
  261. callback : function(options,success,response){
  262. mm.FormUtil.setLoading(false);
  263. var res = new Ext.decode(response.responseText);
  264. if(res.exceptionInfo != null){
  265. showError(res.exceptionInfo);return;
  266. }else if(res.log){
  267. showMessage("提示", res.log);
  268. Ext.Msg.alert("提示","开返工单成功!");
  269. }
  270. }
  271. });
  272. }
  273. });