PreProduct.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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','core.button.Sync',
  10. 'core.button.ResAudit','core.button.Temporary','core.button.Flow','core.button.TurnBorrow','core.button.FeatureDefinition',
  11. 'core.trigger.MultiDbfindTrigger','core.trigger.AddDbfindTrigger','scm.product.GetUUid.ComponentGrid',
  12. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField','core.trigger.AutoCodeTrigger','core.form.CheckBoxGroup'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. 'erpSaveButton': {
  18. click: function(btn){
  19. //申请编号
  20. if(Ext.getCmp('pre_thisid').value == null || Ext.getCmp('pre_thisid').value == ''){
  21. me.BaseUtil.getRandomNumber(null, null, 'pre_thisid');
  22. }
  23. this.FormUtil.beforeSave(me);
  24. }
  25. },
  26. '#pre_leadtime':{
  27. afterrender: function(f) {
  28. f.isInteger = true;
  29. }
  30. },
  31. '#pre_precision':{
  32. afterrender: function(f) {
  33. f.isInteger = true;
  34. }
  35. },
  36. 'mfilefield':{
  37. beforerender:function(f){
  38. f.readOnly=false;
  39. }
  40. },
  41. '#pre_gdtqq':{
  42. afterrender: function(f) {
  43. f.isInteger = true;
  44. }
  45. },
  46. '#pre_ltwarndays':{
  47. afterrender: function(f) {
  48. f.isInteger = true;
  49. }
  50. },
  51. '#pre_ltinstock':{
  52. afterrender: function(f) {
  53. f.isInteger = true;
  54. }
  55. },
  56. '#pre_purcmergedays':{
  57. afterrender: function(f) {
  58. f.isInteger = true;
  59. }
  60. },
  61. '#pre_purchasedays':{
  62. afterrender: function(f) {
  63. f.isInteger = true;
  64. }
  65. },
  66. '#pre_period':{
  67. afterrender: function(f) {
  68. f.isInteger = true;
  69. }
  70. },
  71. '#pre_validdays':{
  72. afterrender: function(f) {
  73. f.isInteger = true;
  74. }
  75. },
  76. 'erpCloseButton': {
  77. click: function(btn){
  78. this.FormUtil.beforeClose(this);
  79. }
  80. },
  81. 'erpAddButton': {
  82. click: function(){
  83. me.FormUtil.onAdd('addPreProduct', '新增物料申请', 'jsps/scm/product/preProduct.jsp');
  84. }
  85. },
  86. 'erpUpdateButton': {
  87. click: function(btn){
  88. this.FormUtil.onUpdate(this);
  89. }
  90. },
  91. 'erpSyncButton':{
  92. afterrender: function(btn){
  93. var status = Ext.getCmp('pre_statuscode');
  94. if(status && status.value != 'TURNFM'){
  95. btn.hide();
  96. }
  97. }
  98. },
  99. 'erpTurnBorrowButton':{
  100. beforerender:function(btn){
  101. btn.setText('转询价');
  102. },
  103. afterrender: function(btn){
  104. var status = Ext.getCmp('pre_statuscode');
  105. if(status && status.value != 'TURNFM'){
  106. btn.hide();
  107. }
  108. },
  109. click:function(btn){
  110. warnMsg("确定要转询价吗?", function(b){
  111. if(b == 'yes'){
  112. me.turn(btn.ownerCt.ownerCt,'scm/product/turninquiry.action',
  113. 'jsps/scm/purchase/inquiry.jsp?formCondition=in_idIS@@&gridCondition=id_inidIS@@','inquiry','采购询价单维护');
  114. }
  115. });
  116. }
  117. },
  118. 'erpTurnCustomerButton':{
  119. beforerender:function(btn){
  120. btn.setText('转打样');
  121. },
  122. afterrender: function(btn){
  123. var status = Ext.getCmp('pre_statuscode');
  124. if(status && status.value != 'TURNFM'){
  125. btn.hide();
  126. }
  127. },
  128. click:function(btn){
  129. warnMsg("确定要转打样吗?", function(b){//url,jsp,pageid,title
  130. if(b == 'yes'){
  131. me.turn(btn.ownerCt.ownerCt,'scm/product/turnsample.action',
  132. 'jsps/scm/product/ProductSample.jsp?formCondition=ps_idIS@@&gridCondition=pd_psidIS@@','ProductSample','打样申请单');
  133. }
  134. });
  135. }
  136. },
  137. 'combobox[name=pre_manutype]': {
  138. change: function(btn){
  139. /*var value = Ext.getCmp('pre_manutype').value;
  140. if(value =="MAKE" || value =="PURCHASE"){
  141. Ext.getCmp('pre_leadtime').allowBlank = false;
  142. }else{
  143. Ext.getCmp('pre_gdtqq').allowBlank = false;
  144. }*/
  145. }
  146. },
  147. 'autocodetrigger': {
  148. aftertrigger: function(trigger, val, path, item) {
  149. if(path) {
  150. if(path[0]) {
  151. Ext.getCmp('pre_kind').setValue(path[0]);
  152. }
  153. if(path[1]) {
  154. Ext.getCmp('pre_kind2').setValue(path[1]);
  155. }
  156. if(path[2]) {
  157. Ext.getCmp('pre_kind3').setValue(path[2]);
  158. }
  159. if(path[3]) {
  160. if(Ext.getCmp('pre_xikind')){
  161. Ext.getCmp('pre_xikind').setValue(path[3]);
  162. }
  163. Ext.getCmp('pre_detail').setValue(('无' == path[3] ? '' : path[3]) +
  164. ('无' == path[2] ? '' : path[2]) + ('无' == path[1] ? '' : path[1]));
  165. }
  166. var data = item.get('data') || item.raw.data, f;
  167. if(typeof (f = Ext.getCmp('pre_namerule')) !== 'undefined')
  168. f.setValue(data.pk_namerule);
  169. if(typeof (f = Ext.getCmp('pre_nameeg')) !== 'undefined')
  170. f.setValue(data.pk_nameeg);
  171. if(typeof (f = Ext.getCmp('pre_specrule')) !== 'undefined')
  172. f.setValue(data.pk_specrule);
  173. if(typeof (f = Ext.getCmp('pre_speceg')) !== 'undefined')
  174. f.setValue(data.pk_speceg);
  175. if(typeof (f = Ext.getCmp('pre_parameterrule')) !== 'undefined')
  176. f.setValue(data.pk_parameterrule);
  177. if(typeof (f = Ext.getCmp('pre_parametereg')) !== 'undefined')
  178. f.setValue(data.pk_parametereg);
  179. if(typeof (f = Ext.getCmp('pre_dhzc')) !== 'undefined')
  180. f.setValue(data.pk_dhzc);
  181. if(typeof (f = Ext.getCmp('pre_supplytype')) !== 'undefined')
  182. f.setValue(data.pk_supplytype);
  183. if(typeof (f = Ext.getCmp('pre_manutype')) !== 'undefined'){
  184. var d = data.pk_manutype, v = d;
  185. switch(d){
  186. case '制造':
  187. v = 'MAKE';break;
  188. case '委外':
  189. v = 'OSMAKE';break;
  190. case '外购':
  191. v = 'PURCHASE';break;
  192. case '客供':
  193. v = 'CUSTOFFER';break;
  194. }
  195. f.setValue(v);
  196. }
  197. if(typeof (f = Ext.getCmp('pre_acceptmethod')) !== 'undefined')
  198. f.setValue(['检验','0'].indexOf(data.pk_acceptmethod) > -1 ? '0' : '1');
  199. if(typeof (f = Ext.getCmp('pre_stockcatecode')) !== 'undefined'){
  200. f.setValue(data.pk_stockcatecode);
  201. Ext.getCmp('pre_stockcate').setValue(data.pk_stockcate);
  202. }
  203. if(typeof (f = Ext.getCmp('pre_stockcatecode')) !== 'undefined'){
  204. f.setValue(data.pk_stockcatecode);
  205. Ext.getCmp('pre_stockcate').setValue(data.pk_stockcate);
  206. }
  207. if(typeof (f = Ext.getCmp('pre_incomecatecode')) !== 'undefined'){
  208. f.setValue(data.pk_incomecatecode);
  209. Ext.getCmp('pre_incomecate').setValue(data.pk_incomecate);
  210. }
  211. if(typeof (f = Ext.getCmp('pre_costcatecode')) !== 'undefined'){
  212. f.setValue(data.pk_costcatecode);
  213. Ext.getCmp('pre_costcate').setValue(data.pk_costcate);
  214. }
  215. if(typeof (f = Ext.getCmp('pre_whcode')) !== 'undefined'){
  216. f.setValue(data.pk_whcode);
  217. Ext.getCmp('pre_whname').setValue(data.pk_whname);
  218. }
  219. if(typeof (f = Ext.getCmp('pre_wccode')) !== 'undefined'){
  220. f.setValue(data.pk_wccode);
  221. Ext.getCmp('pre_wcname').setValue(data.pk_wcname);
  222. }
  223. if(typeof (f = Ext.getCmp('pre_material')) !== 'undefined'){
  224. f.setValue(data.pk_material);// 认可状态
  225. }
  226. if(typeof (f = Ext.getCmp('pre_level')) !== 'undefined'){
  227. f.setValue(data.pk_priority);// 优先等级
  228. }
  229. if(typeof (f = Ext.getCmp('pre_testlossrate')) !== 'undefined'){
  230. f.setValue(data.pk_testlossrate);// 试产损耗
  231. }
  232. if(typeof (f = Ext.getCmp('pre_lossrate')) !== 'undefined'){
  233. f.setValue(data.pk_lossrate);// 量产
  234. }
  235. if(typeof (f = Ext.getCmp('pre_exportlossrate')) !== 'undefined'){
  236. f.setValue(data.pk_exportlossrate);// 委外
  237. }
  238. if(typeof (f = Ext.getCmp('pre_validdays')) !== 'undefined'){
  239. f.setValue(data.pk_validdays);// 有效期(天)
  240. }
  241. if(typeof (f = Ext.getCmp('pre_detail')) !== 'undefined'){
  242. f.setValue(data.pk_prname);// 物料名称
  243. }
  244. if(typeof (f = Ext.getCmp('pre_jyfa')) !== 'undefined'){
  245. f.setValue(data.pk_qualmethod);// 检验方案
  246. }
  247. if(typeof (f = Ext.getCmp('pre_purclosstate')) !== 'undefined'){
  248. f.setValue(data.pk_purclossrate);// 采购损耗率%
  249. }
  250. if(typeof (f = Ext.getCmp('pre_purchasedays')) !== 'undefined'){
  251. f.setValue(data.pk_purchasedays);// 交货合并天数
  252. }
  253. if(typeof (f = Ext.getCmp('pre_purcmergedays')) !== 'undefined'){
  254. f.setValue(data.pk_purcmergedays);// 采购合并天数
  255. }
  256. if(typeof (f = Ext.getCmp('pre_ltwarndays')) !== 'undefined'){
  257. f.setValue(data.pk_ltwarndays);// 提前预警天数
  258. }
  259. if(typeof (f = Ext.getCmp('pre_ltinstock')) !== 'undefined'){
  260. f.setValue(data.pk_ltinstock);// 送货提前天数
  261. }
  262. if(typeof (f = Ext.getCmp('pre_gdtqq')) !== 'undefined'){
  263. f.setValue(data.pk_leadtime);// 固定提前期
  264. }
  265. if(typeof (f = Ext.getCmp('pre_location')) !== 'undefined'){
  266. f.setValue(data.pk_location);// 仓位
  267. }
  268. if(typeof (f = Ext.getCmp('pre_serial')) !== 'undefined'){
  269. f.setValue(data.pk_serial);// 种类
  270. }
  271. if(typeof (f = Ext.getCmp('pre_isstandardpr')) !== 'undefined'){
  272. f.setValue(data.pk_isstandardpr);// 是否标准化物料
  273. }
  274. if(typeof (f = Ext.getCmp('pre_aql')) !== 'undefined'){
  275. f.setValue(data.pk_aql);// AQL
  276. }
  277. if(typeof (f = Ext.getCmp('pre_plzl')) !== 'undefined'){
  278. f.setValue(data.pr_plzl);// 提前期批量
  279. }
  280. if(typeof (f = Ext.getCmp('pre_period')) !== 'undefined'){
  281. f.setValue(data.pk_period);// 生产周期
  282. }
  283. if(typeof (f = Ext.getCmp('pre_isgrouppurc')) !== 'undefined'){
  284. f.setValue(data.pk_isgrouppurc);// 是否集团采购
  285. }
  286. }
  287. }
  288. },
  289. 'erpDeleteButton': {
  290. click: function(btn){
  291. this.FormUtil.onDelete(Ext.getCmp('pre_id').value);
  292. }
  293. },
  294. 'erpSubmitButton': {
  295. afterrender: function(btn){
  296. var status = Ext.getCmp('pre_statuscode');
  297. if(status && status.value != 'ENTERING'){
  298. btn.hide();
  299. }
  300. },
  301. click: function(btn){
  302. me.FormUtil.onSubmit(Ext.getCmp('pre_id').value);
  303. }
  304. },
  305. 'erpResSubmitButton': {
  306. afterrender: function(btn){
  307. var status = Ext.getCmp('pre_statuscode');
  308. if(status && status.value != 'COMMITED'){
  309. btn.hide();
  310. }
  311. },
  312. click: function(btn){
  313. me.FormUtil.onResSubmit(Ext.getCmp('pre_id').value);
  314. }
  315. },
  316. 'erpAuditButton': {
  317. afterrender: function(btn){
  318. var status = Ext.getCmp('pre_statuscode');
  319. if(status && status.value != 'COMMITED'){
  320. btn.hide();
  321. }
  322. },
  323. click: function(btn){
  324. me.FormUtil.onAudit(Ext.getCmp('pre_id').value);
  325. }
  326. },
  327. 'erpResAuditButton': {
  328. afterrender: function(btn){
  329. var status = Ext.getCmp('pre_statuscode');
  330. if(status && status.value != 'AUDITED'){
  331. btn.hide();
  332. }
  333. },
  334. click: function(btn){
  335. me.FormUtil.onResAudit(Ext.getCmp('pre_id').value);
  336. }
  337. },
  338. 'erpTemporaryButton': {
  339. afterrender: function(btn){
  340. var status = Ext.getCmp('pre_statuscode');
  341. if(status && status.value != 'AUDITED'){
  342. btn.hide();
  343. }
  344. },
  345. click: function(b){
  346. warnMsg("确定要转入正式物料吗?", function(btn){
  347. if(btn == 'yes'){
  348. me.turnFormal(b.ownerCt.ownerCt);
  349. }
  350. });
  351. }
  352. },
  353. 'erpFeatureDefinitionButton':{
  354. afterrender: function(btn){
  355. var refo = Ext.getCmp('pre_refno');
  356. if(refo && Ext.isEmpty(refo.value)){
  357. btn.hide();
  358. }
  359. },
  360. click: function(btn){
  361. var prcode=Ext.getCmp('pre_code').value;
  362. var formCondition="pre_code='"+prcode+"'";
  363. var gridCondition="ppf_prodcode='"+prcode+"'";
  364. var win = new Ext.window.Window({
  365. id : 'win',
  366. title: '物料特征项设置',
  367. height: "90%",
  368. width: "70%",
  369. maximizable : true,
  370. buttonAlign : 'center',
  371. layout : 'anchor',
  372. items: [{
  373. tag : 'iframe',
  374. frame : true,
  375. anchor : '100% 100%',
  376. layout : 'fit',
  377. html : '<iframe id="iframe_' + prcode + '" src="' + basePath +
  378. 'jsps/pm/bom/PreProdFeature.jsp?formCondition='+formCondition+'&&gridCondition='+gridCondition+'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  379. }]
  380. });
  381. win.show();
  382. }
  383. },
  384. '#pre_uuid':{
  385. beforerender:function(e){//不允许手动编辑,但可以通过trigger调用的方式来取值。
  386. e.editable = false;
  387. }
  388. },
  389. '#pre_orispeccode':{//原厂型号发生改变自动获取标准料号
  390. blur:function(e){//失去焦点,并且和上次的值不一样
  391. if(e.value != null && e.value !='' && e.isDirty() && da!= e.value){//值发生改变,发送请求至标准器件库
  392. me.getUUIdByCode(e.value);
  393. }else if(e.value == null || e.value ==''){
  394. var uuid = Ext.getCmp("pre_uuid");
  395. if(uuid){
  396. Ext.getCmp("pre_uuid").setValue('');
  397. }
  398. }
  399. },
  400. focus:function(e){
  401. da = e.value;
  402. }
  403. }
  404. });
  405. },
  406. getForm: function(btn){
  407. return btn.ownerCt.ownerCt;
  408. },
  409. turnFormal: function(form) {
  410. var me = this;
  411. form.setLoading(true);//loading...
  412. Ext.Ajax.request({
  413. url : basePath + 'scm/product/turnFormal.action',
  414. params: {
  415. id: form.down('#pre_id').value
  416. },
  417. method : 'post',
  418. callback : function(options,success,response){
  419. form.setLoading(false);
  420. var localJson = new Ext.decode(response.responseText);
  421. if(localJson.exceptionInfo){
  422. showError(localJson.exceptionInfo);
  423. }
  424. if(localJson.success){
  425. turnSuccess(function(){
  426. var id = localJson.id;
  427. var url = "jsps/scm/product/product.jsp?formCondition=pr_id=" + id;
  428. me.FormUtil.onAdd('Product' + id, '物料资料' + id, url);
  429. });
  430. }
  431. }
  432. });
  433. },
  434. turn: function(form,url,jsp,pageid,title) {
  435. var me = this;
  436. form.setLoading(true);//loading...
  437. Ext.Ajax.request({
  438. url : basePath + url,
  439. params: {
  440. id: form.down('#pre_id').value
  441. },
  442. method : 'post',
  443. callback : function(options,success,response){
  444. form.setLoading(false);
  445. var localJson = new Ext.decode(response.responseText);
  446. if(localJson.exceptionInfo){
  447. showError(localJson.exceptionInfo);
  448. }
  449. if(localJson.success){
  450. turnSuccess(function(){
  451. var id = localJson.id;
  452. var url2 = jsp.replace(/@@/g,id);
  453. me.FormUtil.onAdd(pageid + id, title + id, url2);
  454. });
  455. }
  456. }
  457. });
  458. },
  459. getUUIdByCode:function(v){
  460. var me = this;
  461. //不能跨域访问
  462. Ext.Ajax.request({
  463. url : basePath+"scm/product/getUUIdByCode.action",
  464. method : 'post',
  465. params:{
  466. code:v
  467. },
  468. callback : function(result,success,response){
  469. var localJson = new Ext.decode(response.responseText);
  470. if(localJson.exceptionInfo){
  471. showError(localJson.exceptionInfo);
  472. }
  473. var store = localJson.gridStore;
  474. if(store.length > 1){
  475. //多条弹出grid 提供选择
  476. me.createSigWin(store);
  477. }else if(store.length == 1){
  478. var da = Ext.getCmp("pre_uuid");
  479. if(da){
  480. Ext.getCmp("pre_uuid").setValue(store[0].uuid);
  481. }
  482. }
  483. }
  484. });
  485. },
  486. createSigWin:function(data){
  487. var win = new Ext.window.Window({
  488. id : 'wind',
  489. title:'标准料号',
  490. height : '65%',
  491. width : '65%',
  492. maximizable : true,
  493. buttonAlign : 'center',
  494. layout : 'anchor',
  495. items : [{
  496. xtype:'erpComponentGrid',
  497. anchor: '100% 100%',
  498. listeners:{
  499. beforerender:function(g){
  500. g.store.loadData(data);
  501. }
  502. }
  503. }],
  504. bbar: ['->',{
  505. text:'关闭',
  506. cls: 'x-btn-gray',
  507. iconCls: 'x-button-icon-close',
  508. listeners: {
  509. click: function(){
  510. win.close();
  511. }
  512. }
  513. },'->']
  514. });
  515. win.show();
  516. }
  517. });