PreProduct.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.product.PreProduct', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'scm.product.PreProduct','core.form.Panel','core.form.MultiField','core.form.FileField',
  8. 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close',
  9. 'core.button.ResSubmit','core.button.Update','core.button.Delete','core.button.TurnCustomer',
  10. 'core.button.ResAudit','core.button.Temporary','core.button.Flow','core.button.TurnBorrow','core.trigger.MultiDbfindTrigger','core.trigger.AddDbfindTrigger',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField','core.trigger.AutoCodeTrigger'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'erpSaveButton': {
  17. click: function(btn){
  18. //申请编号
  19. if(Ext.getCmp('pre_thisid').value == null || Ext.getCmp('pre_thisid').value == ''){
  20. me.BaseUtil.getRandomNumber(null, null, 'pre_thisid');
  21. }
  22. this.FormUtil.beforeSave(me);
  23. }
  24. },
  25. 'mfilefield':{
  26. beforerender:function(f){
  27. f.readOnly=false;
  28. }
  29. },
  30. 'erpCloseButton': {
  31. click: function(btn){
  32. this.FormUtil.beforeClose(this);
  33. }
  34. },
  35. 'erpAddButton': {
  36. click: function(){
  37. me.FormUtil.onAdd('addPreProduct', '新增物料申请', 'jsps/scm/product/preProduct.jsp');
  38. }
  39. },
  40. 'erpUpdateButton': {
  41. click: function(btn){
  42. this.FormUtil.onUpdate(this);
  43. }
  44. },
  45. 'erpTurnBorrowButton':{
  46. beforerender:function(btn){
  47. btn.setText('转询价');
  48. },
  49. afterrender: function(btn){
  50. var status = Ext.getCmp('pre_statuscode');
  51. if(status && status.value != 'TURNFM'){
  52. btn.hide();
  53. }
  54. },
  55. click:function(btn){
  56. warnMsg("确定要转询价吗?", function(b){
  57. if(b == 'yes'){
  58. me.turn(btn.ownerCt.ownerCt,'scm/product/turninquiry.action',
  59. 'jsps/scm/purchase/inquiry.jsp?formCondition=in_idIS@@&gridCondition=id_inidIS@@','inquiry','采购询价单维护');
  60. }
  61. });
  62. }
  63. },
  64. 'erpTurnCustomerButton':{
  65. beforerender:function(btn){
  66. btn.setText('转打样');
  67. },
  68. afterrender: function(btn){
  69. var status = Ext.getCmp('pre_statuscode');
  70. if(status && status.value != 'TURNFM'){
  71. btn.hide();
  72. }
  73. },
  74. click:function(btn){
  75. warnMsg("确定要转打样吗?", function(b){//url,jsp,pageid,title
  76. if(b == 'yes'){
  77. me.turn(btn.ownerCt.ownerCt,'scm/product/turnsample.action',
  78. 'jsps/scm/product/ProductSample.jsp?formCondition=ps_idIS@@&gridCondition=pd_psidIS@@','ProductSample','打样申请单');
  79. }
  80. });
  81. }
  82. },
  83. 'combobox[name=pre_manutype]': {
  84. change: function(btn){
  85. /*var value = Ext.getCmp('pre_manutype').value;
  86. if(value =="MAKE" || value =="PURCHASE"){
  87. Ext.getCmp('pre_leadtime').allowBlank = false;
  88. }else{
  89. Ext.getCmp('pre_gdtqq').allowBlank = false;
  90. }*/
  91. }
  92. },
  93. 'autocodetrigger': {
  94. aftertrigger: function(trigger, val, path, item) {
  95. if(path) {
  96. if(path[0]) {
  97. Ext.getCmp('pre_kind').setValue(path[0]);
  98. }
  99. if(path[1]) {
  100. Ext.getCmp('pre_kind2').setValue(path[1]);
  101. }
  102. if(path[2]) {
  103. Ext.getCmp('pre_kind3').setValue(path[2]);
  104. }
  105. if(path[3]) {
  106. if(Ext.getCmp('pre_xikind')){
  107. Ext.getCmp('pre_xikind').setValue(path[3]);
  108. }
  109. Ext.getCmp('pre_detail').setValue(('无' == path[3] ? '' : path[3]) +
  110. ('无' == path[2] ? '' : path[2]) + ('无' == path[1] ? '' : path[1]));
  111. }
  112. var data = item.get('data') || item.raw.data, f;
  113. if(typeof (f = Ext.getCmp('pre_namerule')) !== 'undefined')
  114. f.setValue(data.pk_namerule);
  115. if(typeof (f = Ext.getCmp('pre_nameeg')) !== 'undefined')
  116. f.setValue(data.pk_nameeg);
  117. if(typeof (f = Ext.getCmp('pre_specrule')) !== 'undefined')
  118. f.setValue(data.pk_specrule);
  119. if(typeof (f = Ext.getCmp('pre_speceg')) !== 'undefined')
  120. f.setValue(data.pk_speceg);
  121. if(typeof (f = Ext.getCmp('pre_parameterrule')) !== 'undefined')
  122. f.setValue(data.pk_parameterrule);
  123. if(typeof (f = Ext.getCmp('pre_parametereg')) !== 'undefined')
  124. f.setValue(data.pk_parametereg);
  125. if(typeof (f = Ext.getCmp('pre_dhzc')) !== 'undefined')
  126. f.setValue(data.pk_dhzc);
  127. if(typeof (f = Ext.getCmp('pre_supplytype')) !== 'undefined')
  128. f.setValue(data.pk_supplytype);
  129. if(typeof (f = Ext.getCmp('pre_manutype')) !== 'undefined'){
  130. var d = data.pk_manutype, v = d;
  131. switch(d){
  132. case '制造':
  133. v = 'MAKE';break;
  134. case '委外':
  135. v = 'OSMAKE';break;
  136. case '外购':
  137. v = 'PURCHASE';break;
  138. case '客供':
  139. v = 'CUSTOFFER';break;
  140. }
  141. f.setValue(v);
  142. }
  143. if(typeof (f = Ext.getCmp('pre_acceptmethod')) !== 'undefined')
  144. f.setValue(['检验','0'].indexOf(data.pk_acceptmethod) > -1 ? '0' : '1');
  145. if(typeof (f = Ext.getCmp('pre_stockcatecode')) !== 'undefined'){
  146. f.setValue(data.pk_stockcatecode);
  147. Ext.getCmp('pre_stockcate').setValue(data.pk_stockcate);
  148. }
  149. if(typeof (f = Ext.getCmp('pre_stockcatecode')) !== 'undefined'){
  150. f.setValue(data.pk_stockcatecode);
  151. Ext.getCmp('pre_stockcate').setValue(data.pk_stockcate);
  152. }
  153. if(typeof (f = Ext.getCmp('pre_incomecatecode')) !== 'undefined'){
  154. f.setValue(data.pk_incomecatecode);
  155. Ext.getCmp('pre_incomecate').setValue(data.pk_incomecate);
  156. }
  157. if(typeof (f = Ext.getCmp('pre_costcatecode')) !== 'undefined'){
  158. f.setValue(data.pk_costcatecode);
  159. Ext.getCmp('pre_costcate').setValue(data.pk_costcate);
  160. }
  161. if(typeof (f = Ext.getCmp('pre_whcode')) !== 'undefined'){
  162. f.setValue(data.pk_whcode);
  163. Ext.getCmp('pre_whname').setValue(data.pk_whname);
  164. }
  165. if(typeof (f = Ext.getCmp('pre_isstandardpr')) !== 'undefined'){
  166. f.setValue(data.pk_isstandardpr);// 是否标准化物料
  167. }
  168. if(typeof (f = Ext.getCmp('pre_wccode')) !== 'undefined'){
  169. f.setValue(data.pk_wccode);
  170. Ext.getCmp('pre_wcname').setValue(data.pk_wcname);
  171. }
  172. if(typeof (f = Ext.getCmp('pre_material')) !== 'undefined'){
  173. f.setValue(data.pk_material);// 认可状态
  174. }
  175. if(typeof (f = Ext.getCmp('pre_level')) !== 'undefined'){
  176. f.setValue(data.pk_priority);// 优先等级
  177. }
  178. if(typeof (f = Ext.getCmp('pre_testlossrate')) !== 'undefined'){
  179. f.setValue(data.pk_testlossrate);// 试产损耗
  180. }
  181. if(typeof (f = Ext.getCmp('pre_lossrate')) !== 'undefined'){
  182. f.setValue(data.pk_lossrate);// 量产
  183. }
  184. if(typeof (f = Ext.getCmp('pre_exportlossrate')) !== 'undefined'){
  185. f.setValue(data.pk_exportlossrate);// 委外
  186. }
  187. }
  188. }
  189. },
  190. 'erpDeleteButton': {
  191. click: function(btn){
  192. this.FormUtil.onDelete(Ext.getCmp('pre_id').value);
  193. }
  194. },
  195. 'erpSubmitButton': {
  196. afterrender: function(btn){
  197. var status = Ext.getCmp('pre_statuscode');
  198. if(status && status.value != 'ENTERING'){
  199. btn.hide();
  200. }
  201. },
  202. click: function(btn){
  203. me.FormUtil.onSubmit(Ext.getCmp('pre_id').value);
  204. }
  205. },
  206. 'erpResSubmitButton': {
  207. afterrender: function(btn){
  208. var status = Ext.getCmp('pre_statuscode');
  209. if(status && status.value != 'COMMITED'){
  210. btn.hide();
  211. }
  212. },
  213. click: function(btn){
  214. me.FormUtil.onResSubmit(Ext.getCmp('pre_id').value);
  215. }
  216. },
  217. 'erpAuditButton': {
  218. afterrender: function(btn){
  219. var status = Ext.getCmp('pre_statuscode');
  220. if(status && status.value != 'COMMITED'){
  221. btn.hide();
  222. }
  223. },
  224. click: function(btn){
  225. me.FormUtil.onAudit(Ext.getCmp('pre_id').value);
  226. }
  227. },
  228. 'erpResAuditButton': {
  229. afterrender: function(btn){
  230. var status = Ext.getCmp('pre_statuscode');
  231. if(status && status.value != 'AUDITED'){
  232. btn.hide();
  233. }
  234. },
  235. click: function(btn){
  236. me.FormUtil.onResAudit(Ext.getCmp('pre_id').value);
  237. }
  238. },
  239. 'erpTemporaryButton': {
  240. afterrender: function(btn){
  241. var status = Ext.getCmp('pre_statuscode');
  242. if(status && status.value != 'AUDITED'){
  243. btn.hide();
  244. }
  245. },
  246. click: function(b){
  247. warnMsg("确定要转入正式物料吗?", function(btn){
  248. if(btn == 'yes'){
  249. me.turnFormal(b.ownerCt.ownerCt);
  250. }
  251. });
  252. }
  253. }
  254. });
  255. },
  256. getForm: function(btn){
  257. return btn.ownerCt.ownerCt;
  258. },
  259. turnFormal: function(form) {
  260. var me = this;
  261. form.setLoading(true);//loading...
  262. Ext.Ajax.request({
  263. url : basePath + 'scm/product/turnFormal.action',
  264. params: {
  265. id: form.down('#pre_id').value
  266. },
  267. method : 'post',
  268. callback : function(options,success,response){
  269. form.setLoading(false);
  270. var localJson = new Ext.decode(response.responseText);
  271. if(localJson.exceptionInfo){
  272. showError(localJson.exceptionInfo);
  273. }
  274. if(localJson.success){
  275. turnSuccess(function(){
  276. var id = localJson.id;
  277. var url = "jsps/scm/product/product.jsp?formCondition=pr_id=" + id;
  278. me.FormUtil.onAdd('Product' + id, '物料资料' + id, url);
  279. });
  280. }
  281. }
  282. });
  283. },
  284. turn: function(form,url,jsp,pageid,title) {
  285. var me = this;
  286. form.setLoading(true);//loading...
  287. Ext.Ajax.request({
  288. url : basePath + url,
  289. params: {
  290. id: form.down('#pre_id').value
  291. },
  292. method : 'post',
  293. callback : function(options,success,response){
  294. form.setLoading(false);
  295. var localJson = new Ext.decode(response.responseText);
  296. if(localJson.exceptionInfo){
  297. showError(localJson.exceptionInfo);
  298. }
  299. if(localJson.success){
  300. turnSuccess(function(){
  301. var id = localJson.id;
  302. var url2 = jsp.replace(/@@/g,id);
  303. me.FormUtil.onAdd(pageid + id, title + id, url2);
  304. });
  305. }
  306. }
  307. });
  308. }
  309. });