PreProduct.js 18 KB

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