Product.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.product.Product', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'core.form.Panel','scm.product.Product','core.form.MultiField','core.form.FileField',
  8. 'core.button.Add','core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print','core.button.TurnCustomer',
  9. 'core.button.Upload','core.button.Update','core.button.FeatureDefinition','core.button.FeatureView','core.button.Delete','core.button.ResAudit','core.button.ForBidden',
  10. 'core.button.ResForBidden','core.button.Banned','core.button.ResBanned','core.button.CopyAll','core.button.ProductStatus','core.button.CreateFeatrue',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField','core.trigger.AutoCodeTrigger','scm.product.GetUUid.ComponentGrid',
  12. 'core.button.Sync','core.button.SubmitStandard','core.button.ResSubmitNoStandard','core.button.UpdatePrLevel'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. '#pr_leadtime':{
  18. afterrender: function(f) {
  19. f.isInteger = true;
  20. }
  21. },
  22. '#pr_validdays':{
  23. afterrender: function(f) {
  24. f.isInteger = true;
  25. }
  26. },
  27. '#pr_precision':{
  28. afterrender: function(f) {
  29. f.isInteger = true;
  30. }
  31. },
  32. '#pr_purcmergedays':{
  33. afterrender: function(f) {
  34. f.isInteger = true;
  35. }
  36. },
  37. '#pr_purchasedays':{
  38. afterrender: function(f) {
  39. f.isInteger = true;
  40. }
  41. },
  42. '#pr_ltinstock':{
  43. afterrender: function(f) {
  44. f.isInteger = true;
  45. }
  46. },
  47. '#pr_ltwarndays':{
  48. afterrender: function(f) {
  49. f.isInteger = true;
  50. }
  51. },
  52. '#pr_gdtqq':{
  53. afterrender: function(f) {
  54. f.isInteger = true;
  55. }
  56. },
  57. '#pr_uuid':{
  58. beforerender:function(e){//不允许手动编辑,但可以通过trigger调用的方式来取值。
  59. e.editable = false;
  60. }
  61. },
  62. '#pr_orispeccode':{//原厂型号发生改变自动获取标准料号
  63. blur:function(e){//失去焦点
  64. if(e.value != null && e.value !='' && e.isDirty() && da!= e.value){//值发生改变,发送请求至标准器件库
  65. me.getUUIdByCode(e.value);
  66. }else if(e.value == null || e.value ==''){
  67. var uuid = Ext.getCmp("pr_uuid");
  68. if(uuid){
  69. Ext.getCmp("pr_uuid").setValue('');
  70. }
  71. }
  72. },
  73. focus:function(e){
  74. da = e.value;
  75. }
  76. },
  77. 'erpTurnCustomerButton':{
  78. beforerender:function(btn){
  79. btn.setText('转打样');
  80. },
  81. afterrender: function(btn){
  82. var status = Ext.getCmp('pr_statuscode');
  83. if(status && status.value != 'AUDITED'){
  84. btn.hide();
  85. }
  86. },
  87. click:function(btn){
  88. warnMsg("确定要转打样吗?", function(b){//url,jsp,pageid,title
  89. if(b == 'yes'){
  90. me.turn(btn.ownerCt.ownerCt,'scm/product/prodturnsample.action',
  91. 'jsps/scm/product/ProductSample.jsp?formCondition=ps_idIS@@&gridCondition=pd_psidIS@@','ProductSample','打样申请单');
  92. }
  93. });
  94. }
  95. },
  96. 'combobox[name=pr_maketype]': {
  97. change: function(m){
  98. if(!Ext.isEmpty(m.value)) {
  99. var f = Ext.getCmp('pr_purchasepolicy');
  100. switch (f.value) {
  101. case 'MRP':
  102. if(m.value != '外购' && m.value != '客供') {
  103. showError('计划类型为MRP时,生产类型只能为 外购 和 客供');
  104. m.reset();
  105. }
  106. break;
  107. case 'MPS':
  108. if(m.value != '制造 ' && m.value != '委外') {
  109. showError('计划类型为MPS时,生产类型只能为 制造 和 委外');
  110. m.reset();
  111. }
  112. break;
  113. }
  114. }
  115. }
  116. },
  117. 'autocodetrigger': {
  118. aftertrigger: function(trigger, val, path, item) {
  119. if(path) {
  120. if(path[0]) {
  121. Ext.getCmp('pr_kind').setValue(path[0]);
  122. }
  123. if(path[1]) {
  124. Ext.getCmp('pr_kind2').setValue(path[1]);
  125. }
  126. if(path[2]) {
  127. Ext.getCmp('pr_kind3').setValue(path[2]);
  128. }
  129. var data = item.get('data') || item.raw.data, f;
  130. if(path[3]) {
  131. if(Ext.getCmp('pr_xikind')){
  132. Ext.getCmp('pr_xikind').setValue(path[3]);
  133. }
  134. if(!Ext.isEmpty(data.pk_prname)){
  135. Ext.getCmp('pr_detail').setValue(data.pk_prname);
  136. } else {
  137. Ext.getCmp('pr_detail').setValue(('无' == path[3] ? '' : path[3]) +
  138. ('无' == path[2] ? '' : path[2]) + ('无' == path[1] ? '' : path[1]));
  139. }
  140. }
  141. //增加了一个abc分类的自动赋值
  142. if(typeof (f = Ext.getCmp('pr_abc')) !== 'undefined')
  143. f.setValue(data.pk_abc);
  144. if(typeof (f = Ext.getCmp('pr_namerule')) !== 'undefined')
  145. f.setValue(data.pk_namerule);
  146. if(typeof (f = Ext.getCmp('pr_nameeg')) !== 'undefined')
  147. f.setValue(data.pk_nameeg);
  148. if(typeof (f = Ext.getCmp('pr_specrule')) !== 'undefined')
  149. f.setValue(data.pk_specrule);
  150. if(typeof (f = Ext.getCmp('pr_speceg')) !== 'undefined')
  151. f.setValue(data.pk_speceg);
  152. if(typeof (f = Ext.getCmp('pr_parameterrule')) !== 'undefined')
  153. f.setValue(data.pk_parameterrule);
  154. if(typeof (f = Ext.getCmp('pr_parametereg')) !== 'undefined')
  155. f.setValue(data.pk_parametereg);
  156. if(typeof (f = Ext.getCmp('pr_lossrate')) !== 'undefined')
  157. f.setValue(data.pk_lossrate);//量产损耗率
  158. if(typeof (f = Ext.getCmp('pr_testlossrate')) !== 'undefined')
  159. f.setValue(data.pk_testlossrate);//试产损耗率
  160. if(typeof (f = Ext.getCmp('pr_exportlossrate')) !== 'undefined')
  161. f.setValue(data.pk_exportlossrate);// 委外损耗率
  162. if(typeof (f = Ext.getCmp('pr_whcode')) !== 'undefined')
  163. f.setValue(data.pk_whcode);// 仓库编号
  164. if(typeof (f = Ext.getCmp('pr_whname')) !== 'undefined')
  165. f.setValue(data.pk_whname);// 仓库名称
  166. if(typeof (f = Ext.getCmp('pr_location')) !== 'undefined')
  167. f.setValue(data.pk_location);// 诸位
  168. if(typeof (f = Ext.getCmp('pr_acceptmethod')) !== 'undefined')
  169. f.setValue(data.pk_acceptmethod);// 接收方式
  170. if(typeof (f = Ext.getCmp('pr_wccode')) !== 'undefined')
  171. f.setValue(data.pk_wccode);// 工作中心号
  172. if(typeof (f = Ext.getCmp('pr_wcname')) !== 'undefined')
  173. f.setValue(data.pk_wcname);// 工作中心名称
  174. if(typeof (f = Ext.getCmp('pr_stockcatecode')) !== 'undefined')
  175. f.setValue(data.pk_stockcatecode);// 存货科目编号
  176. if(typeof (f = Ext.getCmp('pr_stockcatename')) !== 'undefined')
  177. f.setValue(data.pk_stockcate);// 存货科目名称
  178. if(typeof (f = Ext.getCmp('pr_costcatecode')) !== 'undefined')
  179. f.setValue(data.pk_costcatecode);// 成本科目编号
  180. if(typeof (f = Ext.getCmp('pr_costcatename')) !== 'undefined')
  181. f.setValue(data.pk_costcate);// 成本科目名称
  182. if(typeof (f = Ext.getCmp('pr_incomecatecode')) !== 'undefined')
  183. f.setValue(data.pk_incomecatecode);// 收入科目编号
  184. if(typeof (f = Ext.getCmp('pr_incomecatename')) !== 'undefined')
  185. f.setValue(data.pk_incomecate);// 收入科目名称
  186. if(typeof (f = Ext.getCmp('pr_aql')) !== 'undefined')
  187. f.setValue(data.pk_aql);// AQL抽样标准
  188. if(typeof (f = Ext.getCmp('pr_dhzc')) !== 'undefined')
  189. f.setValue(data.pk_dhzc);// 计划类型
  190. if(typeof (f = Ext.getCmp('pr_validdays')) !== 'undefined'){
  191. f.setValue(data.pk_validdays);// 有效期(天)
  192. }
  193. if(typeof (f = Ext.getCmp('pr_qualmethod')) !== 'undefined'){
  194. f.setValue(data.pk_qualmethod);// 检验方案
  195. }
  196. if(typeof (f = Ext.getCmp('pr_purclossrate')) !== 'undefined'){
  197. f.setValue(data.pk_purclossrate);// 采购损耗率%
  198. }
  199. if(typeof (f = Ext.getCmp('pr_purcmergedays')) !== 'undefined'){
  200. f.setValue(data.pk_purcmergedays);// 采购合并天数
  201. }
  202. if(typeof (f = Ext.getCmp('pr_purchasedays')) !== 'undefined'){
  203. f.setValue(data.pk_purchasedays);// 交货合并天数
  204. }
  205. if(typeof (f = Ext.getCmp('pr_ltwarndays')) !== 'undefined'){
  206. f.setValue(data.pk_ltwarndays);// 提前预警天数
  207. }
  208. if(typeof (f = Ext.getCmp('pr_ltinstock')) !== 'undefined'){
  209. f.setValue(data.pk_ltinstock);// 送货提前天数
  210. }
  211. if(typeof (f = Ext.getCmp('pr_gdtqq')) !== 'undefined'){
  212. f.setValue(data.pk_leadtime);// 固定提前期
  213. }
  214. if(typeof (f = Ext.getCmp('pr_location')) !== 'undefined'){
  215. f.setValue(data.pk_location);// 仓位
  216. }
  217. if(typeof (f = Ext.getCmp('pr_serial')) !== 'undefined'){
  218. f.setValue(data.pk_serial);// 种类
  219. }
  220. if(typeof (f = Ext.getCmp('pr_material')) !== 'undefined'){
  221. f.setValue(data.pk_material);// 认可状态
  222. }
  223. if(typeof (f = Ext.getCmp('pr_aql')) !== 'undefined'){
  224. f.setValue(data.pk_aql);// AQL
  225. }
  226. if(typeof (f = Ext.getCmp('pr_isgrouppurc')) !== 'undefined'){
  227. f.setValue(data.pk_isgrouppurc);// 是否集团采购
  228. }if(typeof (f = Ext.getCmp('pr_supplytype')) !== 'undefined')//供应类型
  229. f.setValue(data.pk_supplytype);
  230. if(typeof (f = Ext.getCmp('pr_manutype')) !== 'undefined'){//生产类型
  231. var d = data.pk_manutype, v = d;
  232. switch(d){
  233. case '制造':
  234. v = 'MAKE';break;
  235. case '委外':
  236. v = 'OSMAKE';break;
  237. case '外购':
  238. v = 'PURCHASE';break;
  239. case '客供':
  240. v = 'CUSTOFFER';break;
  241. }
  242. f.setValue(v);
  243. }
  244. if(typeof (f = Ext.getCmp('pr_whmancode')) !== 'undefined'){
  245. f.setValue(data.pk_whmancode);// 仓管员号
  246. }
  247. if(typeof (f = Ext.getCmp('pr_whmanname')) !== 'undefined'){
  248. f.setValue(data.pk_whmanname);// 仓管员名
  249. }
  250. }
  251. }
  252. },
  253. 'erpSaveButton': {
  254. click: function(btn){
  255. this.FormUtil.beforeSave(this);
  256. }
  257. },
  258. 'erpDeleteButton' : {
  259. click: function(btn){
  260. me.FormUtil.onDelete(Ext.getCmp('pr_id').value);
  261. }
  262. },
  263. 'erpUpdateButton': {
  264. click: function(btn){
  265. this.FormUtil.onUpdate(this);
  266. }
  267. },
  268. 'erpAddButton': {
  269. click: function(){
  270. me.FormUtil.onAdd('addProduct'+new Date().getTime(), '新增物料', 'jsps/scm/product/product.jsp');
  271. }
  272. },
  273. 'erpCloseButton': {
  274. click: function(btn){
  275. me.FormUtil.beforeClose(me);
  276. }
  277. },
  278. 'erpSubmitButton': {
  279. afterrender: function(btn){
  280. var status = Ext.getCmp('pr_statuscode');
  281. if(status && status.value != 'ENTERING'){
  282. btn.hide();
  283. }
  284. },
  285. click: function(btn){
  286. me.FormUtil.onSubmit(Ext.getCmp('pr_id').value);
  287. }
  288. },
  289. 'erpResSubmitButton': {
  290. afterrender: function(btn){
  291. var status = Ext.getCmp('pr_statuscode');
  292. if(status && status.value != 'COMMITED'){
  293. btn.hide();
  294. }
  295. },
  296. click: function(btn){
  297. me.FormUtil.onResSubmit(Ext.getCmp('pr_id').value);
  298. }
  299. },
  300. 'erpAuditButton': {
  301. afterrender: function(btn){
  302. var status = Ext.getCmp('pr_statuscode');
  303. if(status && status.value != 'COMMITED'){
  304. btn.hide();
  305. }
  306. },
  307. click: function(btn){
  308. me.FormUtil.onAudit(Ext.getCmp('pr_id').value);
  309. }
  310. },
  311. 'erpResAuditButton': {
  312. afterrender: function(btn){
  313. var status = Ext.getCmp('pr_statuscode');
  314. if(status && status.value != 'AUDITED'){
  315. btn.hide();
  316. }
  317. },
  318. click: function(btn){
  319. me.FormUtil.onResAudit(Ext.getCmp('pr_id').value);
  320. }
  321. },
  322. 'erpBannedButton': {
  323. afterrender: function(btn){
  324. var status = Ext.getCmp('pr_statuscode');
  325. if(status && (status.value == 'BANNED' || status.value == 'DELETED' || status.value == 'DISABLE') && status.value != 'AUDITED'){
  326. btn.hide();
  327. }
  328. },
  329. click: function(btn){
  330. if (!confirm('确定要禁用此物料?')){
  331. return;
  332. }
  333. //me.FormUtil.onBanned(Ext.getCmp('pr_id').value);
  334. me.toDisable();//zhongyl 2014 03 13
  335. }
  336. },
  337. 'erpResBannedButton': {
  338. afterrender: function(btn){
  339. var status = Ext.getCmp('pr_statuscode');
  340. if(status && status.value != 'DISABLE'){
  341. btn.hide();
  342. }
  343. },
  344. click: function(btn){
  345. if (!confirm('确定要反禁用此物料?')){
  346. return;
  347. }
  348. me.FormUtil.onResBanned(Ext.getCmp('pr_id').value);
  349. }
  350. },
  351. 'erpFeatureViewButton':{
  352. click: function(btn){
  353. var code=Ext.getCmp('pr_code').value;
  354. var id=Ext.getCmp('pr_id').value;
  355. var name=Ext.getCmp('pr_detail').value;
  356. if(code != null){
  357. Ext.Ajax.request({//拿到grid的columns
  358. url : basePath + "pm/bom/getDescription.action",
  359. params: {
  360. tablename: 'Product',
  361. field: 'pr_specvalue',
  362. condition: "pr_code='" + code + "'"
  363. },
  364. method : 'post',
  365. async: false,
  366. callback : function(options,success,response){
  367. var res = new Ext.decode(response.responseText);
  368. if(res.exceptionInfo){
  369. showError(res.exceptionInfo);return;
  370. }
  371. if(res.success){
  372. if(res.description != '' && res.description != null && res.description == 'SPECIFIC'){
  373. var win = new Ext.window.Window({
  374. id : 'win' + id,
  375. title: '特征查看',
  376. height: "90%",
  377. width: "70%",
  378. maximizable : true,
  379. buttonAlign : 'center',
  380. layout : 'anchor',
  381. items: [{
  382. tag : 'iframe',
  383. frame : true,
  384. anchor : '100% 100%',
  385. layout : 'fit',
  386. html : '<iframe id="iframe_' + id + '" src="' + basePath +
  387. "jsps/pm/bom/FeatureValueView.jsp?fromwhere=SaleDetail&formid=" + id + '&pr_code=' + code +'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  388. }]
  389. });
  390. win.show();
  391. } else {
  392. showError('物料特征必须为 虚拟特征件');return;
  393. }
  394. }
  395. }
  396. });
  397. }
  398. }
  399. },
  400. 'erpCreateFeatrueButton':{
  401. afterrender: function(btn){
  402. var status = Ext.getCmp('pr_statuscode');
  403. if(status && status.value != 'AUDITED'){
  404. btn.hide();
  405. }
  406. },
  407. click: function(btn){
  408. var code=Ext.getCmp('pr_code').value;
  409. var id = Ext.getCmp('pr_id').value;
  410. var name=Ext.getCmp('pr_detail').value;
  411. Ext.Ajax.request({//拿到grid的columns
  412. url : basePath + "pm/bom/getDescription.action",
  413. params: {
  414. tablename: 'Product',
  415. field: 'pr_specvalue',
  416. condition: "pr_code='" + code + "'"
  417. },
  418. method : 'post',
  419. async: false,
  420. callback : function(options,success,response){
  421. var res = new Ext.decode(response.responseText);
  422. if(res.exceptionInfo){
  423. showError(res.exceptionInfo);return;
  424. }
  425. if(res.success){
  426. if(res.description != '' && res.description != null && res.description == 'NOTSPECIFIC'){
  427. var win = new Ext.window.Window({
  428. id : 'win',
  429. title: '生成特征料号',
  430. height: "90%",
  431. width: "95%",
  432. maximizable : true,
  433. buttonAlign : 'center',
  434. layout : 'anchor',
  435. items: [{
  436. tag : 'iframe',
  437. frame : true,
  438. anchor : '100% 100%',
  439. layout : 'fit',
  440. html : '<iframe id="iframe_' + id + '" src="' + basePath +
  441. "jsps/pm/bom/FeatureValueSet.jsp?fromwhere=SaleDetail&condition=formidIS" + id + ' AND pr_codeIS' + code + ' AND pr_nameIS' + name +'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  442. }]
  443. });
  444. win.show();
  445. } else {
  446. showError('物料特征必须为虚拟特征件');return;
  447. }
  448. }
  449. }
  450. });
  451. }
  452. },
  453. 'erpFeatureDefinitionButton':{
  454. afterrender: function(btn){
  455. var refo = Ext.getCmp('pr_refno');
  456. if(refo && Ext.isEmpty(refo.value)){
  457. btn.hide();
  458. }
  459. },
  460. click: function(btn){
  461. var prcode=Ext.getCmp('pr_code').value;
  462. var formCondition="pr_code='"+prcode+"'";
  463. var gridCondition="pf_prodcode='"+prcode+"'";
  464. var win = new Ext.window.Window({
  465. id : 'win',
  466. title: '物料特征项设置',
  467. height: "90%",
  468. width: "70%",
  469. maximizable : true,
  470. buttonAlign : 'center',
  471. layout : 'anchor',
  472. items: [{
  473. tag : 'iframe',
  474. frame : true,
  475. anchor : '100% 100%',
  476. layout : 'fit',
  477. html : '<iframe id="iframe_' + prcode + '" src="' + basePath +
  478. 'jsps/pm/bom/ProdFeature.jsp?formCondition='+formCondition+'&&gridCondition='+gridCondition+'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  479. }]
  480. });
  481. win.show();
  482. }
  483. },
  484. 'erpCopyButton':{
  485. click: function(btn){
  486. var me = this, win = Ext.getCmp('copyProduct-win'), k3 = Ext.getCmp('pr_kind3'), k4 = Ext.getCmp('pr_xikind');
  487. if(!win){
  488. var prcode = Ext.getCmp('pr_code'), prname = Ext.getCmp('pr_detail'),
  489. prspec = Ext.getCmp('pr_spec'),
  490. val1 = prcode ? prcode.value : '', val2 = prname ? prname.value : '',
  491. val3 = prspec ? prspec.value : '';
  492. win = Ext.create('Ext.Window', {
  493. id: 'copyProduct-win',
  494. title: '复制物料 ' + val1,
  495. height: 300,
  496. width: 400,
  497. items: [{
  498. xtype: 'form',
  499. height: '100%',
  500. width: '100%',
  501. bodyStyle: 'background:#f1f2f5;',
  502. items: [{
  503. margin: '10 0 0 0',
  504. xtype: 'textfield',
  505. fieldLabel: '新料编号',
  506. name:'pr_newcode',
  507. allowBlank: false
  508. },{
  509. margin: '10 0 0 0',
  510. xtype: 'textfield',
  511. fieldLabel: '旧料编号',
  512. name:'pr_oldcode',
  513. allowBlank: false,
  514. readOnly : true,
  515. value: val1
  516. },{
  517. margin: '3 0 0 0',
  518. xtype: 'textfield',
  519. name:'pr_newname',
  520. fieldLabel: '物料名称',
  521. value: val2,
  522. allowBlank: false
  523. },{
  524. margin: '3 0 0 0',
  525. xtype: 'textfield',
  526. name:'pr_newspec',
  527. fieldLabel: '物料规格',
  528. value: val3,
  529. allowBlank: false
  530. }],
  531. closeAction: 'hide',
  532. buttonAlign: 'center',
  533. layout: {
  534. type: 'vbox',
  535. align: 'center'
  536. },
  537. buttons: [{
  538. text: $I18N.common.button.erpConfirmButton,
  539. cls: 'x-btn-blue',
  540. handler: function(btn) {
  541. var form = btn.ownerCt.ownerCt,
  542. a = form.down('textfield[name=pr_newcode]'),
  543. b = form.down('textfield[name=pr_newname]');
  544. c = form.down('textfield[name=pr_newspec]');
  545. if(form.getForm().isDirty()) {
  546. if(a.value == val1){
  547. showError("新物料编号不能与旧料编号相同");
  548. return;
  549. }
  550. me.copyProduct(Ext.getCmp('pr_id').value, a.value, b.value, c.value);
  551. }
  552. }
  553. }, {
  554. text: $I18N.common.button.erpCloseButton,
  555. cls: 'x-btn-blue',
  556. handler: function(btn) {
  557. btn.up('window').hide();
  558. }
  559. }]
  560. }]
  561. });
  562. me.autoCode(function(code){
  563. win.down('textfield[name=pr_newcode]').setValue(code);
  564. });
  565. }
  566. win.show();
  567. }
  568. },
  569. 'erpSyncButton': {
  570. afterrender: function(btn) {
  571. var form = btn.ownerCt.ownerCt, s = form.down('#pr_statuscode');
  572. if (s.getValue() != 'AUDITED' && s.getValue() != 'DISABLE')
  573. btn.hide();
  574. }
  575. }
  576. });
  577. },
  578. copyProduct: function(prid, val1, val2, val3) {
  579. var me = this;
  580. Ext.Ajax.request({
  581. url: basePath + 'scm/product/copyProduct.action',
  582. params: {
  583. caller: caller,
  584. id: prid,
  585. newcode: val1,
  586. newname: val2,
  587. newspec: val3
  588. },
  589. callback : function(options,success,response){
  590. me.FormUtil.getActiveTab().setLoading(false);
  591. var localJson = new Ext.decode(response.responseText);
  592. if(localJson.exceptionInfo){
  593. showError(localJson.exceptionInfo);
  594. }
  595. if(localJson.success){
  596. Ext.getCmp('copyProduct-win').hide();
  597. turnSuccess(function(){
  598. var id = localJson.id;
  599. var url = "jsps/scm/product/product.jsp?formCondition=pr_id=" + id;
  600. me.FormUtil.onAdd('Product' + id, '物料基本资料' + id, url);
  601. });
  602. }
  603. }
  604. });
  605. },
  606. turn: function(form,url,jsp,pageid,title) {
  607. var me = this;
  608. form.setLoading(true);//loading...
  609. Ext.Ajax.request({
  610. url : basePath + url,
  611. params: {
  612. id: form.down('#pr_id').value
  613. },
  614. method : 'post',
  615. callback : function(options,success,response){
  616. form.setLoading(false);
  617. var localJson = new Ext.decode(response.responseText);
  618. if(localJson.exceptionInfo){
  619. showError(localJson.exceptionInfo);
  620. }
  621. if(localJson.success){
  622. turnSuccess(function(){
  623. var id = localJson.id;
  624. var url2 = jsp.replace(/@@/g,id);
  625. me.FormUtil.onAdd(pageid + id, title + id, url2);
  626. });
  627. }
  628. }
  629. });
  630. },
  631. getForm: function(btn){
  632. return btn.ownerCt.ownerCt;
  633. },
  634. toDisable:function(){
  635. Ext.create('Ext.window.Window',{
  636. width:350,
  637. height:185,
  638. id:'win',
  639. title:'<h1>禁用物料</h1>',
  640. layout:'column',
  641. items:[{
  642. margin: '10 0 0 0',
  643. xtype: 'textfield',
  644. fieldLabel: '禁用备注',
  645. name:'disremark',
  646. value: ''
  647. }],
  648. buttonAlign:'center',
  649. buttons:[{
  650. xtype:'button',
  651. columnWidth:0.12,
  652. text:'确定',
  653. width:60,
  654. iconCls: 'x-button-icon-save',
  655. handler:function(btn){
  656. var remark=btn.ownerCt.ownerCt.down('textfield[name=disremark]').value;
  657. if (remark==null || remark==''){
  658. showError('禁用备注必须填写');
  659. }
  660. Ext.Ajax.request({
  661. url : basePath + 'scm/product/bannedProduct.action',
  662. params: {
  663. id: Ext.getCmp('pr_id').value,
  664. remark: remark,
  665. caller: caller
  666. },
  667. method : 'post',
  668. callback: function(opt, s, r) {
  669. var rs = Ext.decode(r.responseText);
  670. if(rs.exceptionInfo) {
  671. showError(rs.exceptionInfo);
  672. } else {
  673. alert('更新成功!');
  674. window.location.reload();
  675. }
  676. }
  677. });
  678. }
  679. },{
  680. xtype:'button',
  681. columnWidth:0.1,
  682. text:'取消',
  683. width:60,
  684. iconCls: 'x-button-icon-close',
  685. margin:'0 0 0 10',
  686. handler:function(btn){
  687. Ext.getCmp('win').close();
  688. }
  689. }]
  690. }).show();
  691. },
  692. getUUIdByCode:function(v){
  693. var me = this;
  694. //不能跨域访问
  695. Ext.Ajax.request({
  696. url : basePath+"scm/product/getUUIdByCode.action",
  697. method : 'post',
  698. params:{
  699. code:v
  700. },
  701. callback : function(result,success,response){
  702. var localJson = new Ext.decode(response.responseText);
  703. if(localJson.exceptionInfo){
  704. showError(localJson.exceptionInfo);
  705. }
  706. var store = localJson.gridStore;
  707. if(store.length > 1){
  708. //多条弹出grid 提供选择
  709. me.createSigWin(store);
  710. }else if(store.length == 1){
  711. var da = Ext.getCmp("pr_uuid");
  712. if(da){
  713. Ext.getCmp("pr_uuid").setValue(store[0].uuid);
  714. }
  715. }
  716. }
  717. });
  718. },
  719. autoCode : function(callback) {
  720. var me = this;
  721. Ext.Ajax.request({
  722. url : basePath + 'scm/product/getProductKindNum.action',
  723. params : {
  724. k1 : (Ext.getCmp('pr_kind') && !Ext.isEmpty(Ext.getCmp('pr_kind').getValue())) ? Ext.getCmp('pr_kind').getValue(): null,
  725. k2 : (Ext.getCmp('pr_kind2') && !Ext.isEmpty(Ext.getCmp('pr_kind2').getValue())) ? Ext.getCmp('pr_kind2').getValue(): null,
  726. k3 : (Ext.getCmp('pr_kind3') && !Ext.isEmpty(Ext.getCmp('pr_kind3').getValue())) ? Ext.getCmp('pr_kind3').getValue(): null,
  727. k4 : (Ext.getCmp('pr_xikind') && !Ext.isEmpty(Ext.getCmp('pr_xikind').getValue())) ? Ext.getCmp('pr_xikind').getValue(): null
  728. },
  729. callback : function(opt, s, r) {
  730. var r = Ext.decode(r.responseText);
  731. if (r.exceptionInfo) {
  732. showError(r.exceptionInfo);
  733. } else if (r.success && r.number) {
  734. callback.call(null, r.number);
  735. }
  736. }
  737. });
  738. },
  739. createSigWin:function(data){
  740. var win = new Ext.window.Window({
  741. id : 'wind',
  742. title:'标准料号',
  743. height : '65%',
  744. width : '65%',
  745. maximizable : true,
  746. buttonAlign : 'center',
  747. layout : 'anchor',
  748. items : [{
  749. xtype:'erpComponentGrid',
  750. anchor: '100% 100%',
  751. listeners:{
  752. beforerender:function(g){
  753. g.store.loadData(data);
  754. }
  755. }
  756. }],
  757. bbar: ['->',{
  758. text:'关闭',
  759. cls: 'x-btn-gray',
  760. iconCls: 'x-button-icon-close',
  761. listeners: {
  762. click: function(){
  763. win.close();
  764. }
  765. }
  766. },'->']
  767. });
  768. win.show();
  769. }
  770. });