StepTest.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.mes.StepTest', {
  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. 'pm.mes.StepTest','core.trigger.DbfindTrigger',
  9. 'core.form.YnField','core.grid.YnColumn', 'core.grid.TfColumn',
  10. 'core.button.Query','core.button.Close', 'core.trigger.TextAreaTrigger'
  11. ],
  12. init:function(){
  13. var me = this;
  14. this.control({
  15. 'dbfindtrigger[name=mc_code]': {
  16. focus: function(t){
  17. t.setHideTrigger(false);
  18. t.setReadOnly(false);//用disable()可以,但enable()无效
  19. var st_code = Ext.getCmp('st_code').value;
  20. if(st_code == null || st_code == ''){
  21. showError("请先选择资源编号!");
  22. t.setHideTrigger(true);
  23. t.setReadOnly(true);
  24. return;
  25. } else {
  26. t.dbBaseCondition = "st_code='" + st_code + "'";
  27. }
  28. },
  29. beforetrigger:function(t,e){
  30. t.setHideTrigger(false);
  31. t.setReadOnly(false);//用disable()可以,但enable()无效
  32. var st_code = Ext.getCmp('st_code').value;
  33. if(st_code == null || st_code == ''){
  34. showError("请先选择资源编号!");
  35. t.setHideTrigger(true);
  36. t.setReadOnly(true);
  37. return false;
  38. } else {
  39. t.dbBaseCondition = "st_code='" + st_code + "'";
  40. }
  41. }
  42. },
  43. '#deletebutton':{//删除不良原因明细
  44. click:function(btn){
  45. var grid = Ext.getCmp("querygrid");
  46. var items = grid.selModel.getSelection();
  47. var bool = false;
  48. var data = new Array();
  49. Ext.each(items, function(item, index){
  50. if(this.data['mb_id'] != null && this.data['mb_id'] != ''
  51. && this.data['mb_id'] != '0' && this.data['mb_id'] != 0){
  52. bool = true;
  53. var o = new Object();
  54. o['mb_id'] = this.data['mb_id'];
  55. o['mb_sncode'] = this.data['mb_sncode'];
  56. data.push(o);
  57. }
  58. });
  59. if(bool){
  60. warnMsg("确认删除?", function(btn){
  61. if(btn == 'yes'){
  62. me.deleteBadCode(data);
  63. }
  64. });
  65. }else{
  66. showError("请勾选需要的明细!");
  67. return;
  68. }
  69. }
  70. },
  71. 'combo[id=bc_reason]':{
  72. focus:function(){
  73. if(Ext.getCmp("bc_groupcode").value ==''){
  74. showError("请先选择不良组别");
  75. return;
  76. }
  77. }
  78. },
  79. 'combo[id=bc_groupcode]':{
  80. change: function(combo, nv, ov){
  81. if(nv!=ov && !Ext.isEmpty(nv)){
  82. var reasonCombo = Ext.getCmp("bc_reason");
  83. reasonCombo.clearValue();
  84. var reasonStore=reasonCombo.getStore();
  85. reasonStore.proxy.extraParams.condition = nv;
  86. reasonStore.load();
  87. }
  88. }
  89. },
  90. '#ms_code': {
  91. specialkey: function(f, e){//按ENTER执行确认
  92. if (e.getKey() == e.ENTER) {
  93. if(f.value != null && f.value != '' ){
  94. me.onCheck(f.value);
  95. }
  96. }
  97. }
  98. },
  99. 'button[id=confirmBtn]':{//确认合格通过
  100. click : function(btn){
  101. var ms_code = Ext.getCmp("ms_code").value;
  102. if(ms_code && !Ext.isEmpty(ms_code)){
  103. Ext.Ajax.request({
  104. url : basePath + 'pm/mes/confirmQualified.action',
  105. params: {
  106. mcd_stepcode:Ext.getCmp('st_code').value,
  107. mc_code:Ext.getCmp('mc_code').value,
  108. sc_code:Ext.getCmp('sc_code').value,
  109. ms_code:ms_code,
  110. makecode:Ext.getCmp("mc_makecode").value
  111. },
  112. method : 'post',
  113. callback : function(options,success,response){
  114. var r = new Ext.decode(response.responseText);
  115. if(r.exceptionInfo){
  116. showError('确认合格通过失败:'+r.exceptionInfo);
  117. }else{
  118. showMessage('提示','确认合格通过成功,序列号:'+ms_code);
  119. Ext.getCmp("ms_code").setValue('');
  120. //更新已采集数
  121. Ext.getCmp('mcd_inqty').setValue(r.data.mcd_inqty);
  122. }
  123. }
  124. });
  125. }else{
  126. showError("请先填写序列号!");
  127. }
  128. }
  129. },
  130. '#mcd_inqty':{
  131. change:function(f,n,o){
  132. var qty = Ext.getCmp("mc_qty").value;
  133. Ext.getCmp("mc_restqty").setValue(qty-n);//设置剩余数的值
  134. }
  135. },
  136. 'button[id=saveBad]':{//保存不良原因
  137. click:function(btn){
  138. var ms_code = Ext.getCmp("ms_code").value;
  139. var bc_reason = Ext.getCmp("bc_reason").value
  140. if(!Ext.isEmpty(ms_code)){
  141. if(!Ext.isEmpty(bc_reason)){
  142. Ext.Ajax.request({
  143. url : basePath + 'pm/mes/saveBadReason.action',
  144. params: {
  145. mcd_stepcode:Ext.getCmp('st_code').value,
  146. mc_code:Ext.getCmp('mc_code').value,
  147. sc_code:Ext.getCmp('sc_code').value,
  148. ms_code:ms_code,
  149. bc_reason:bc_reason,
  150. bc_remark:Ext.getCmp('bc_remark').value
  151. },
  152. method : 'post',
  153. callback : function(options,success,response){
  154. var r = new Ext.decode(response.responseText);
  155. if(r.exceptionInfo){
  156. showError('保存不良原因失败:'+r.exceptionInfo);
  157. }else{
  158. showMessage('提示','保存不良原因成功,序列号:'+ms_code + ',不良原因:'+bc_reason);
  159. me.onCheck(ms_code);
  160. }
  161. }
  162. });
  163. }else{
  164. showError("请选择不良原因!");
  165. }
  166. }else{
  167. showError("请先填写序列号!");
  168. }
  169. }
  170. },
  171. 'button[id=confirmRepairStep]':{//确定返修途程
  172. click:function(btn){
  173. var ms_code = Ext.getCmp("ms_code").value;
  174. var st_rcode = Ext.getCmp("st_rcode").value
  175. if(!Ext.isEmpty(ms_code)){
  176. if(!Ext.isEmpty(st_rcode)){
  177. Ext.Ajax.request({
  178. url : basePath + 'pm/mes/confirmRepairStep.action',
  179. params: {
  180. mcd_stepcode:Ext.getCmp('st_code').value,
  181. mc_code:Ext.getCmp('mc_code').value,
  182. sc_code:Ext.getCmp('sc_code').value,
  183. ms_code:ms_code,
  184. st_rcode:st_rcode
  185. },
  186. method : 'post',
  187. callback : function(options,success,response){
  188. var r = new Ext.decode(response.responseText);
  189. if(r.exceptionInfo){
  190. showError('确认返修途程失败:'+r.exceptionInfo);
  191. }else{
  192. showMessage('提示','确认返修途程成功,序列号:'+ms_code + ',返修工序:'+st_rcode);
  193. //更新已采集数
  194. Ext.getCmp('testform').getForm().reset();
  195. Ext.getCmp('querygrid').store.removeAll();
  196. //更新已采集数
  197. Ext.getCmp('mcd_inqty').setValue(r.data.mcd_inqty);
  198. }
  199. }
  200. });
  201. }else{
  202. showError("请填写返修工序!");
  203. }
  204. }else{
  205. showError("请先填写序列号!");
  206. }
  207. }
  208. }
  209. });
  210. },
  211. getSourceM:function(data){/*
  212. Ext.Ajax.request({
  213. url : basePath + 'pm/mes/getSourceM.action',
  214. params: {condition:data},
  215. method : 'post',
  216. callback : function(options,success,response){
  217. var r = new Ext.decode(response.responseText);
  218. if(r.exceptionInfo){
  219. showError(r.exceptionInfo);
  220. Ext.getCmp('sc_code').setValue();
  221. }else if(r.data){
  222. Ext.getCmp("form").getForm().setValues(r.data);
  223. if(r.data['st_rstepcode']){//根据资源带出返修工序
  224. Ext.getCmp("st_rcode").setValue(r.data['st_rstepcode']);
  225. }
  226. }
  227. }
  228. });
  229. */},
  230. getFormStore : function(data){
  231. var stepcode = Ext.getCmp("st_code").value,sccode = Ext.getCmp("sc_code").value;
  232. if(Ext.isEmpty(sccode)){
  233. showError("请先录入资源编号!");
  234. return ;
  235. }
  236. Ext.Ajax.request({
  237. url : basePath + 'pm/mes/getFormStore.action',
  238. params: {condition:unescape(escape(Ext.JSON.encode(data)))},
  239. method : 'post',
  240. callback : function(options,success,response){
  241. var r = new Ext.decode(response.responseText);
  242. if(r.exceptionInfo){
  243. showError(r.exceptionInfo);
  244. Ext.getCmp('mc_code').setValue();
  245. }else if(r.data){
  246. Ext.getCmp("form").getForm().setValues(r.data);
  247. }
  248. }
  249. });
  250. },
  251. onCheck:function(data){
  252. var makecode = Ext.getCmp("mc_makecode").value,stepcode = Ext.getCmp("st_code").value,
  253. mccode = Ext.getCmp("mc_code").value;
  254. if(Ext.isEmpty(stepcode)){
  255. showError("请先录入资源编号!");return ;
  256. }
  257. if(Ext.isEmpty(mccode)){
  258. showError("请先录入作业单号!");return;
  259. }
  260. Ext.getCmp("querygrid").setLoading(true);
  261. Ext.Ajax.request({
  262. url : basePath + 'pm/mes/checkStep.action',
  263. params: {
  264. makecode:makecode,
  265. stepcode:stepcode,
  266. mscode:data,
  267. mccode:mccode
  268. },
  269. method : 'post',
  270. callback : function(options,success,response){
  271. Ext.getCmp("querygrid").setLoading(false);
  272. var r = new Ext.decode(response.responseText);
  273. if(r.exceptionInfo){
  274. showError(r.exceptionInfo);
  275. Ext.getCmp('ms_code').setValue();
  276. return ;
  277. }else if(r.data && r.data.length > 0){
  278. Ext.getCmp("querygrid").store.loadData(r.data);
  279. }else{
  280. Ext.getCmp("querygrid").store.loadData([{},{},{},{},{},{},{},{},{},{},{}]);
  281. }
  282. }
  283. });
  284. },
  285. deleteBadCode : function(data){
  286. var me = this;
  287. Ext.Ajax.request({
  288. url : basePath + 'pm/mes/deleteTestBadCode.action',
  289. params: {
  290. condition:unescape(Ext.JSON.encode(data))
  291. },
  292. method : 'post',
  293. callback : function(options,success,response){
  294. var r = new Ext.decode(response.responseText);
  295. if(r.exceptionInfo){
  296. showError(r.exceptionInfo);
  297. }else if(r.success){
  298. me.onCheck(Ext.getCmp('ms_code').value);
  299. showMessage('系统提示', '删除成功!');
  300. }
  301. }
  302. });
  303. }
  304. });