Product.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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',
  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. 'erpFormPanel': {
  18. afterrender: function(){
  19. /*var tree = parent.Ext.getCmp('tree-panel');
  20. if(!tree.collapsed) {
  21. parent.Ext.getCmp('tree-panel').toggleCollapse();
  22. }*/
  23. /*var panel = parent.Ext.getCmp('tree-tab');
  24. if(panel && !panel.collapsed) {
  25. panel.toggleCollapse();
  26. }*/
  27. }
  28. },
  29. 'erpTurnCustomerButton':{
  30. beforerender:function(btn){
  31. btn.setText('转打样');
  32. },
  33. afterrender: function(btn){
  34. var status = Ext.getCmp('pr_statuscode');
  35. if(status && status.value != 'AUDITED'){
  36. btn.hide();
  37. }
  38. },
  39. click:function(btn){
  40. warnMsg("确定要转打样吗?", function(b){//url,jsp,pageid,title
  41. if(b == 'yes'){
  42. me.turn(btn.ownerCt.ownerCt,'scm/product/prodturnsample.action',
  43. 'jsps/scm/product/ProductSample.jsp?formCondition=ps_idIS@@&gridCondition=pd_psidIS@@','ProductSample','打样申请单');
  44. }
  45. });
  46. }
  47. },
  48. 'combobox[name=pr_maketype]': {
  49. change: function(m){
  50. if(!Ext.isEmpty(m.value)) {
  51. var f = Ext.getCmp('pr_purchasepolicy');
  52. switch (f.value) {
  53. case 'MRP':
  54. if(m.value != '外购' && m.value != '客供') {
  55. showError('计划类型为MRP时,生产类型只能为 外购 和 客供');
  56. m.reset();
  57. }
  58. break;
  59. case 'MPS':
  60. if(m.value != '制造 ' && m.value != '委外') {
  61. showError('计划类型为MPS时,生产类型只能为 制造 和 委外');
  62. m.reset();
  63. }
  64. break;
  65. }
  66. }
  67. }
  68. },
  69. 'autocodetrigger': {
  70. aftertrigger: function(trigger, val, path, item) {
  71. if(path) {
  72. if(path[0]) {
  73. Ext.getCmp('pr_kind').setValue(path[0]);
  74. }
  75. if(path[1]) {
  76. Ext.getCmp('pr_kind2').setValue(path[1]);
  77. }
  78. if(path[2]) {
  79. Ext.getCmp('pr_kind3').setValue(path[2]);
  80. }
  81. if(path[3]) {
  82. Ext.getCmp('pr_detail').setValue(('无' == path[3] ? '' : path[3]) +
  83. ('无' == path[2] ? '' : path[2]) + ('无' == path[1] ? '' : path[1]));
  84. var xikind=Ext.getCmp('pr_xikind');
  85. if(xikind){
  86. xikind.setValue(path[3]);
  87. }
  88. }
  89. var data = item.get('data') || item.raw.data, f;
  90. if(typeof (f = Ext.getCmp('pr_namerule')) !== 'undefined')
  91. f.setValue(data.pk_namerule);
  92. if(typeof (f = Ext.getCmp('pr_nameeg')) !== 'undefined')
  93. f.setValue(data.pk_nameeg);
  94. if(typeof (f = Ext.getCmp('pr_specrule')) !== 'undefined')
  95. f.setValue(data.pk_specrule);
  96. if(typeof (f = Ext.getCmp('pr_speceg')) !== 'undefined')
  97. f.setValue(data.pk_speceg);
  98. if(typeof (f = Ext.getCmp('pr_parameterrule')) !== 'undefined')
  99. f.setValue(data.pk_parameterrule);
  100. if(typeof (f = Ext.getCmp('pr_parametereg')) !== 'undefined')
  101. f.setValue(data.pk_parametereg);
  102. }
  103. }
  104. },
  105. 'erpSaveButton': {
  106. click: function(btn){
  107. this.FormUtil.beforeSave(this);
  108. }
  109. },
  110. 'erpDeleteButton' : {
  111. click: function(btn){
  112. me.FormUtil.onDelete(Ext.getCmp('pr_id').value);
  113. }
  114. },
  115. 'erpUpdateButton': {
  116. click: function(btn){
  117. this.FormUtil.onUpdate(this);
  118. }
  119. },
  120. 'erpAddButton': {
  121. click: function(){
  122. me.FormUtil.onAdd('addProduct'+new Date().getTime(), '新增物料', 'jsps/scm/product/product.jsp');
  123. }
  124. },
  125. 'mfilefield':{
  126. beforerender:function(f){
  127. f.readOnly=false;
  128. }
  129. },
  130. 'htmleditor': {
  131. beforerender: function(f){
  132. f.height=300;
  133. f.readOnly=true;
  134. f.dirty=false;
  135. f.value='1)电阻,物料具体名称(如片式电阻,固定电阻,可变电阻等),规格参数写明功率W?<br> 2)电感,规格参数写明功率W?<br>3)晶振,描述中说明是否已装配 <br>4)滤波器,注明是否电磁干扰等<br> 5)二极管,三极管,规格参数写明功率W <br>6)电容,规格参数写明电容量UF<br> 7)集成电路,描述中写明是否加密,具体用途及功能(如控制处理功能,驱动功能,触摸功能等等),存储功能的必须写明存储量G或m<br>8)手机用XX英寸电容式触摸屏,需写明是否含液晶,以及组成,适用于何种品牌和型号的手机,(不含触摸功能的品名直接申报为手机用液晶屏,含触摸功能的液晶屏申报品名为电容式触摸屏含液晶即可)<br> 9)xx英寸彩色液晶屏,需写明是否有触摸功能,制造工艺,工作原理,是否含背光,驱动电路板等等<br> 10)开关,规格参数写明工作电压V(36V以下的,需提前一天提供能证明电压是36V以下的说明书用于办理商检免3c认证,36V以上需提供3c证书)<br> 11)继电器,接插件均需写明电压V,光耦需写明是否含一个半导体器件';
  136. }
  137. },
  138. 'erpCloseButton': {
  139. click: function(btn){
  140. me.FormUtil.beforeClose(me);
  141. }
  142. },
  143. 'erpSubmitButton': {
  144. afterrender: function(btn){
  145. var status = Ext.getCmp('pr_statuscode');
  146. if(status && status.value != 'ENTERING'){
  147. btn.hide();
  148. }
  149. },
  150. click: function(btn){
  151. me.FormUtil.onSubmit(Ext.getCmp('pr_id').value);
  152. }
  153. },
  154. 'erpResSubmitButton': {
  155. afterrender: function(btn){
  156. var status = Ext.getCmp('pr_statuscode');
  157. if(status && status.value != 'COMMITED'){
  158. btn.hide();
  159. }
  160. },
  161. click: function(btn){
  162. me.FormUtil.onResSubmit(Ext.getCmp('pr_id').value);
  163. }
  164. },
  165. 'erpAuditButton': {
  166. afterrender: function(btn){
  167. var status = Ext.getCmp('pr_statuscode');
  168. if(status && status.value != 'COMMITED'){
  169. btn.hide();
  170. }
  171. },
  172. click: function(btn){
  173. me.FormUtil.onAudit(Ext.getCmp('pr_id').value);
  174. }
  175. },
  176. 'erpResAuditButton': {
  177. afterrender: function(btn){
  178. var status = Ext.getCmp('pr_statuscode');
  179. if(status && status.value != 'AUDITED'){
  180. btn.hide();
  181. }
  182. },
  183. click: function(btn){
  184. me.FormUtil.onResAudit(Ext.getCmp('pr_id').value);
  185. }
  186. },
  187. 'erpBannedButton': {
  188. afterrender: function(btn){
  189. var status = Ext.getCmp('pr_statuscode');
  190. if(status && (status.value == 'DELETED' || status.value == 'DISABLE')){
  191. btn.hide();
  192. }
  193. },
  194. click: function(btn){
  195. if (!confirm('确定要禁用此物料?')){
  196. return;
  197. }
  198. //me.FormUtil.onBanned(Ext.getCmp('pr_id').value);
  199. me.toDisable();//zhongyl 2014 03 13
  200. }
  201. },
  202. 'erpResBannedButton': {
  203. afterrender: function(btn){
  204. var status = Ext.getCmp('pr_statuscode');
  205. if(status && status.value != 'DISABLE'){
  206. btn.hide();
  207. }
  208. },
  209. click: function(btn){
  210. if (!confirm('确定要反禁用此物料?')){
  211. return;
  212. }
  213. me.FormUtil.onResBanned(Ext.getCmp('pr_id').value);
  214. }
  215. },
  216. 'erpFeatureViewButton':{
  217. click: function(btn){
  218. var code=Ext.getCmp('pr_code').value;
  219. var id=Ext.getCmp('pr_id').value;
  220. var name=Ext.getCmp('pr_detail').value;
  221. if(code != null){
  222. Ext.Ajax.request({//拿到grid的columns
  223. url : basePath + "pm/bom/getDescription.action",
  224. params: {
  225. tablename: 'Product',
  226. field: 'pr_specvalue',
  227. condition: "pr_code='" + code + "'"
  228. },
  229. method : 'post',
  230. async: false,
  231. callback : function(options,success,response){
  232. var res = new Ext.decode(response.responseText);
  233. if(res.exceptionInfo){
  234. showError(res.exceptionInfo);return;
  235. }
  236. if(res.success){
  237. if(res.description != '' && res.description != null && res.description == 'SPECIFIC'){
  238. var win = new Ext.window.Window({
  239. id : 'win' + id,
  240. title: '特征查看',
  241. height: "90%",
  242. width: "70%",
  243. maximizable : true,
  244. buttonAlign : 'center',
  245. layout : 'anchor',
  246. items: [{
  247. tag : 'iframe',
  248. frame : true,
  249. anchor : '100% 100%',
  250. layout : 'fit',
  251. html : '<iframe id="iframe_' + id + '" src="' + basePath +
  252. "jsps/pm/bom/FeatureValueView.jsp?fromwhere=SaleDetail&formid=" + id + '&pr_code=' + code +'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  253. }]
  254. });
  255. win.show();
  256. } else {
  257. showError('物料特征必须为 虚拟特征件');return;
  258. }
  259. }
  260. }
  261. });
  262. }
  263. }
  264. },
  265. 'erpCreateFeatrueButton':{
  266. afterrender: function(btn){
  267. var status = Ext.getCmp('pr_statuscode');
  268. if(status && status.value != 'AUDITED'){
  269. btn.hide();
  270. }
  271. },
  272. click: function(btn){
  273. var code=Ext.getCmp('pr_code').value;
  274. var id = Ext.getCmp('pr_id').value;
  275. var name=Ext.getCmp('pr_detail').value;
  276. Ext.Ajax.request({//拿到grid的columns
  277. url : basePath + "pm/bom/getDescription.action",
  278. params: {
  279. tablename: 'Product',
  280. field: 'pr_specvalue',
  281. condition: "pr_code='" + code + "'"
  282. },
  283. method : 'post',
  284. async: false,
  285. callback : function(options,success,response){
  286. var res = new Ext.decode(response.responseText);
  287. if(res.exceptionInfo){
  288. showError(res.exceptionInfo);return;
  289. }
  290. if(res.success){
  291. if(res.description != '' && res.description != null && res.description == 'NOTSPECIFIC'){
  292. var win = new Ext.window.Window({
  293. id : 'win',
  294. title: '生成特征料号',
  295. height: "90%",
  296. width: "95%",
  297. maximizable : true,
  298. buttonAlign : 'center',
  299. layout : 'anchor',
  300. items: [{
  301. tag : 'iframe',
  302. frame : true,
  303. anchor : '100% 100%',
  304. layout : 'fit',
  305. html : '<iframe id="iframe_' + id + '" src="' + basePath +
  306. "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>'
  307. }]
  308. });
  309. win.show();
  310. } else {
  311. showError('物料特征必须为虚拟特征件');return;
  312. }
  313. }
  314. }
  315. });
  316. }
  317. },
  318. 'erpFeatureDefinitionButton':{
  319. afterrender: function(btn){
  320. btn.setDisabled(false);
  321. },
  322. click: function(btn){
  323. var prcode=Ext.getCmp('pr_code').value;
  324. Ext.Ajax.request({//拿到grid的columns
  325. url : basePath + "pm/bom/getDescription.action",
  326. params: {
  327. tablename: 'Product',
  328. field: 'pr_specvalue',
  329. condition: "pr_code='" + prcode + "'"
  330. },
  331. method : 'post',
  332. async: false,
  333. callback : function(options,success,response){
  334. var res = new Ext.decode(response.responseText);
  335. if(res.exceptionInfo){
  336. showError(res.exceptionInfo);return;
  337. }
  338. if(res.success){
  339. if(res.description != '' && res.description != null && res.description == 'NOTSPECIFIC'){
  340. var formCondition="pr_code='"+prcode+"'";
  341. var gridCondition="pf_prodcode='"+prcode+"'";
  342. var win = new Ext.window.Window({
  343. id : 'win',
  344. title: '物料特征项设置',
  345. height: "90%",
  346. width: "70%",
  347. maximizable : true,
  348. buttonAlign : 'center',
  349. layout : 'anchor',
  350. items: [{
  351. tag : 'iframe',
  352. frame : true,
  353. anchor : '100% 100%',
  354. layout : 'fit',
  355. html : '<iframe id="iframe_' + prcode + '" src="' + basePath +
  356. 'jsps/pm/bom/ProdFeature.jsp?formCondition='+formCondition+'&&gridCondition='+gridCondition+'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  357. }]
  358. });
  359. win.show();
  360. } else {
  361. showError('物料特征必须为虚拟特征件');return;
  362. }
  363. }
  364. }
  365. });
  366. }
  367. },
  368. 'erpCopyButton':{
  369. click: function(btn){
  370. warnMsg("确定要复制当前物料吗?", function(btn){
  371. if(btn == 'yes'){
  372. Ext.Ajax.request({
  373. url : basePath + 'scm/product/copyProduct.action',
  374. params: {
  375. id: Ext.getCmp('pr_id').value
  376. },
  377. method : 'post',
  378. callback : function(options,success,response){
  379. me.FormUtil.getActiveTab().setLoading(false);
  380. var localJson = new Ext.decode(response.responseText);
  381. if(localJson.exceptionInfo){
  382. showError(localJson.exceptionInfo);
  383. }
  384. if(localJson.success){
  385. turnSuccess(function(){
  386. var id = localJson.id;
  387. var url = "jsps/scm/product/product.jsp?formCondition=pr_id=" + id;
  388. me.FormUtil.onAdd('Product' + id, '物料基本资料' + id, url);
  389. });
  390. }
  391. }
  392. });
  393. }
  394. });
  395. }
  396. }
  397. });
  398. },
  399. turn: function(form,url,jsp,pageid,title) {
  400. var me = this;
  401. form.setLoading(true);//loading...
  402. Ext.Ajax.request({
  403. url : basePath + url,
  404. params: {
  405. id: form.down('#pr_id').value
  406. },
  407. method : 'post',
  408. callback : function(options,success,response){
  409. form.setLoading(false);
  410. var localJson = new Ext.decode(response.responseText);
  411. if(localJson.exceptionInfo){
  412. showError(localJson.exceptionInfo);
  413. }
  414. if(localJson.success){
  415. turnSuccess(function(){
  416. var id = localJson.id;
  417. var url2 = jsp.replace(/@@/g,id);
  418. me.FormUtil.onAdd(pageid + id, title + id, url2);
  419. });
  420. }
  421. }
  422. });
  423. },
  424. getForm: function(btn){
  425. return btn.ownerCt.ownerCt;
  426. },
  427. toDisable:function(){
  428. Ext.create('Ext.window.Window',{
  429. width:350,
  430. height:185,
  431. id:'win',
  432. title:'<h1>禁用物料</h1>',
  433. layout:'column',
  434. items:[{
  435. margin: '10 0 0 0',
  436. xtype: 'textfield',
  437. fieldLabel: '禁用备注',
  438. name:'disremark',
  439. value: '',
  440. }],
  441. buttonAlign:'center',
  442. buttons:[{
  443. xtype:'button',
  444. columnWidth:0.12,
  445. text:'确定',
  446. width:60,
  447. iconCls: 'x-button-icon-save',
  448. handler:function(btn){
  449. var remark=btn.ownerCt.ownerCt.down('textfield[name=disremark]').value;
  450. if (remark==null || remark==''){
  451. showError('禁用备注必须填写');
  452. }
  453. Ext.Ajax.request({
  454. url : basePath + 'scm/product/bannedProduct.action',
  455. params: {
  456. id:Ext.getCmp('pr_id').value,
  457. remark: remark
  458. },
  459. method : 'post',
  460. callback: function(opt, s, r) {
  461. var rs = Ext.decode(r.responseText);
  462. if(rs.exceptionInfo) {
  463. showError(rs.exceptionInfo);
  464. } else {
  465. alert('更新成功!');
  466. window.location.reload();
  467. }
  468. }
  469. });
  470. }
  471. },{
  472. xtype:'button',
  473. columnWidth:0.1,
  474. text:'取消',
  475. width:60,
  476. iconCls: 'x-button-icon-close',
  477. margin:'0 0 0 10',
  478. handler:function(btn){
  479. Ext.getCmp('win').close();
  480. }
  481. }]
  482. }).show();
  483. }
  484. });