SaleForecast.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.drp.distribution.SaleForecast', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'core.form.Panel','drp.distribution.SaleForecast','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField',
  9. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.Upload','core.button.ChangeDate',
  10. 'core.button.ResAudit','core.button.Scan','core.button.DeleteDetail','core.button.ResSubmit','core.button.FeatureDefinition',
  11. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.End','core.button.ResEnd','core.button.Print',
  12. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.grid.YnColumn','core.button.FeatureView'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. 'erpGridPanel2': {
  18. itemclick: function(selModel, record){
  19. Ext.getCmp('featuredefinition').setDisabled(false);
  20. Ext.getCmp('featureview').setDisabled(false);
  21. this.onGridItemClick
  22. }
  23. },
  24. 'erpChangeDateButton':{
  25. afterrender: function(btn){
  26. var status = Ext.getCmp('sf_statuscode');
  27. if(status && status.value != 'AUDITED'){
  28. btn.hide();
  29. }
  30. },
  31. click:function(btn){
  32. var keyvalue=Ext.getCmp('sf_id').value;
  33. var condition='sd_sfid='+keyvalue;
  34. var win = new Ext.window.Window({
  35. id : 'win',
  36. height: "100%",
  37. width: "80%",
  38. maximizable : true,
  39. buttonAlign : 'center',
  40. layout : 'anchor',
  41. items: [{
  42. tag : 'iframe',
  43. frame : true,
  44. anchor : '100% 100%',
  45. layout : 'fit',
  46. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/common/editorColumn.jsp?caller=SaleForecast!Change'
  47. +"&condition=" + condition +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  48. }],
  49. buttons : [{
  50. text : $I18N.common.button.erpConfirmButton,
  51. iconCls: 'x-button-icon-confirm',
  52. cls: 'x-btn-gray',
  53. handler : function(){
  54. var grid = Ext.getCmp('win').items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow.Ext.getCmp("editorColumnGridPanel");
  55. var data = grid.getEffectData();
  56. if(data != null){
  57. grid.setLoading(true);
  58. Ext.Ajax.request({
  59. url : basePath + 'scm/sale/SaleForecastChangedate.action',
  60. params: {
  61. caller: caller,
  62. data: Ext.encode(data)
  63. },
  64. method : 'post',
  65. callback : function(options,success,response){
  66. grid.setLoading(false);
  67. var localJson = new Ext.decode(response.responseText);
  68. if(localJson.exceptionInfo){
  69. showError(localJson.exceptionInfo);
  70. return "";
  71. }
  72. if(localJson.success){
  73. if(localJson.log){
  74. showMessage("提示", localJson.log);
  75. }
  76. Ext.Msg.alert("提示", "处理成功!", function(){
  77. win.close();
  78. var detailgrid= Ext.getCmp('grid');
  79. gridParam = {caller: 'SaleForecast', condition: condition};
  80. me.GridUtil.getGridColumnsAndStore(detailgrid, 'common/singleGridPanel.action', gridParam, "")
  81. });
  82. }
  83. }
  84. });
  85. }
  86. }
  87. }, {
  88. text : $I18N.common.button.erpCloseButton,
  89. iconCls: 'x-button-icon-close',
  90. cls: 'x-btn-gray',
  91. handler : function(){
  92. Ext.getCmp('win').close();
  93. }
  94. }]
  95. });
  96. win.show();
  97. }
  98. },
  99. 'erpSaveButton': {
  100. click: function(btn){
  101. var form = me.getForm(btn);
  102. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  103. me.BaseUtil.getRandomNumber();//自动添加编号
  104. }
  105. this.beforeSaveSaleForecast(this);
  106. }
  107. },
  108. 'erpDeleteDetailButton': {
  109. afterrender: function(btn){
  110. btn.ownerCt.add({
  111. xtype: 'erpFeatureDefinitionButton'
  112. });
  113. btn.ownerCt.add({
  114. xtype: 'erpFeatureViewButton'
  115. });
  116. }
  117. },
  118. 'erpDeleteButton' : {
  119. click: function(btn){
  120. me.FormUtil.onDelete(Ext.getCmp('sf_id').value);
  121. }
  122. },
  123. 'erpUpdateButton': {
  124. click: function(btn){
  125. this.beforeUpdate(this);
  126. }
  127. },
  128. 'erpAddButton': {
  129. click: function(){
  130. me.FormUtil.onAdd('addSaleForecast', '新增销售预测单', 'jsps/drp/distribution/saleForecast.jsp');
  131. }
  132. },
  133. 'erpCloseButton': {
  134. click: function(btn){
  135. me.FormUtil.beforeClose(me);
  136. }
  137. },
  138. 'erpSubmitButton': {
  139. afterrender: function(btn){
  140. var status = Ext.getCmp('sf_statuscode');
  141. if(status && status.value != 'ENTERING'){
  142. btn.hide();
  143. }
  144. },
  145. click: function(btn){
  146. me.FormUtil.onSubmit(Ext.getCmp('sf_id').value);
  147. }
  148. },
  149. 'erpResSubmitButton': {
  150. afterrender: function(btn){
  151. var status = Ext.getCmp('sf_statuscode');
  152. if(status && status.value != 'COMMITED'){
  153. btn.hide();
  154. }
  155. },
  156. click: function(btn){
  157. me.FormUtil.onResSubmit(Ext.getCmp('sf_id').value);
  158. }
  159. },
  160. 'erpAuditButton': {
  161. afterrender: function(btn){
  162. var status = Ext.getCmp('sf_statuscode');
  163. if(status && status.value != 'COMMITED'){
  164. btn.hide();
  165. }
  166. },
  167. click: function(btn){
  168. me.FormUtil.onAudit(Ext.getCmp('sf_id').value);
  169. }
  170. },
  171. 'erpResAuditButton': {
  172. afterrender: function(btn){
  173. var status = Ext.getCmp('sf_statuscode');
  174. if(status && status.value != 'AUDITED'){
  175. btn.hide();
  176. }
  177. },
  178. click: function(btn){
  179. me.FormUtil.onResAudit(Ext.getCmp('sf_id').value);
  180. }
  181. },
  182. 'erpPrintButton': {
  183. click:function(btn){
  184. var reportName="SaleForecastAudit1";
  185. var condition='{SaleForeCast.sf_id}='+Ext.getCmp('sf_id').value+'';
  186. var id=Ext.getCmp('sf_id').value;
  187. me.FormUtil.onwindowsPrint(id,reportName,condition);
  188. }
  189. },
  190. 'erpEndButton': {
  191. afterrender: function(btn){
  192. var status = Ext.getCmp('sf_statuscode');
  193. if(status && status.value != 'AUDITED'){
  194. btn.hide();
  195. }
  196. },
  197. click: function(btn){
  198. me.FormUtil.onEnd(Ext.getCmp('sf_id').value);
  199. }
  200. },
  201. 'erpResEndButton': {
  202. afterrender: function(btn){
  203. var status = Ext.getCmp('sf_statuscode');
  204. if(status && status.value != 'FINISH'){
  205. btn.hide();
  206. }
  207. },
  208. click: function(btn){
  209. me.FormUtil.onResEnd(Ext.getCmp('sf_id').value);
  210. }
  211. },
  212. 'erpFeatureDefinitionButton':{
  213. click: function(btn){
  214. var grid = Ext.getCmp('grid');
  215. var record = grid.selModel.lastSelected;
  216. console.log(record);
  217. if(record.data.sd_prodcode != null){
  218. Ext.Ajax.request({//拿到grid的columns
  219. url : basePath + "pm/bom/getDescription.action",
  220. params: {
  221. tablename: 'Product',
  222. field: 'pr_specvalue',
  223. condition: "pr_code='" + record.data.sd_prodcode + "'"
  224. },
  225. method : 'post',
  226. async: false,
  227. callback : function(options,success,response){
  228. var res = new Ext.decode(response.responseText);
  229. if(res.exceptionInfo){
  230. showError(res.exceptionInfo);return;
  231. }
  232. if(res.success){
  233. if(res.description != '' && res.description != null && res.description == 'SPECIFIC'){
  234. var win = new Ext.window.Window({
  235. id : 'win' + record.data.sd_id,
  236. title: '生成特征料号',
  237. height: "90%",
  238. width: "70%",
  239. maximizable : true,
  240. buttonAlign : 'center',
  241. layout : 'anchor',
  242. items: [{
  243. tag : 'iframe',
  244. frame : true,
  245. anchor : '100% 100%',
  246. layout : 'fit',
  247. html : '<iframe id="iframe_' + record.data.sd_id + '" src="' + basePath +
  248. "jsps/pm/bom/FeatureValueSet.jsp?fromwhere=SaleForecastDetail&condition=formidIS" + record.data.sd_id + ' AND pr_codeIS' + record.data.sd_prodcode + ' AND pr_nameIS' + record.data.pr_detail +'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  249. }]
  250. });
  251. win.show();
  252. } else {
  253. showError('物料特征必须为 虚拟特征件');return;
  254. }
  255. }
  256. }
  257. });
  258. }
  259. }
  260. },
  261. 'erpFeatureViewButton':{
  262. click: function(btn){
  263. var grid = Ext.getCmp('grid');
  264. var record = grid.selModel.lastSelected;
  265. console.log(record);
  266. if(record.data.sd_prodcode != null){
  267. Ext.Ajax.request({//拿到grid的columns
  268. url : basePath + "pm/bom/getDescription.action",
  269. params: {
  270. tablename: 'Product',
  271. field: 'pr_specvalue',
  272. condition: "pr_code='" + record.data.sd_prodcode + "'"
  273. },
  274. method : 'post',
  275. async: false,
  276. callback : function(options,success,response){
  277. var res = new Ext.decode(response.responseText);
  278. if(res.exceptionInfo){
  279. showError(res.exceptionInfo);return;
  280. }
  281. if(res.success){
  282. if(res.description != '' && res.description != null && res.description == 'NOTSPECIFIC'){
  283. var win = new Ext.window.Window({
  284. id : 'win' + record.data.sd_id,
  285. title: '特征查看',
  286. height: "90%",
  287. width: "70%",
  288. maximizable : true,
  289. buttonAlign : 'center',
  290. layout : 'anchor',
  291. items: [{
  292. tag : 'iframe',
  293. frame : true,
  294. anchor : '100% 100%',
  295. layout : 'fit',
  296. html : '<iframe id="iframe_' + record.data.sd_id + '" src="' + basePath +
  297. "jsps/pm/bom/FeatureValueView.jsp?fromwhere=SaleForecastDetail&condition=formidIS" + record.data.sd_id + ' AND pr_codeIS' + record.data.sd_prodcode + ' AND pr_nameIS' + record.data.pr_detail +'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  298. }]
  299. });
  300. win.show();
  301. } else {
  302. showError('物料特征必须为 虚拟特征件');return;
  303. }
  304. }
  305. }
  306. });
  307. }
  308. }
  309. },
  310. 'textfield[name=sf_fromdate]': {
  311. change: function(field){
  312. if(field.value != null && field.value != ''){
  313. var grid = Ext.getCmp('grid');
  314. var date = field.value;
  315. Ext.Array.each(grid.getStore().data.items,function(item){
  316. item.set('sd_startdate',date);
  317. });
  318. }
  319. }
  320. },
  321. 'textfield[name=sf_todate]': {
  322. change: function(field){
  323. if(field.value != null && field.value != ''){
  324. var grid = Ext.getCmp('grid');
  325. var date = field.value;
  326. Ext.Array.each(grid.getStore().data.items,function(item){
  327. item.set('sd_enddate',date);
  328. });
  329. }
  330. }
  331. },
  332. 'textfield[name=sf_custcode]': {
  333. change: function(field){
  334. if(field.value != null && field.value != ''){
  335. var grid = Ext.getCmp('grid');
  336. var date = field.value;
  337. Ext.Array.each(grid.getStore().data.items,function(item){
  338. item.set('sd_custcode',date);
  339. });
  340. }
  341. }
  342. }
  343. });
  344. },
  345. onGridItemClick: function(selModel, record){//grid行选择
  346. this.GridUtil.onGridItemClick(selModel, record);
  347. },
  348. getForm: function(btn){
  349. return btn.ownerCt.ownerCt;
  350. },
  351. beforeSaveSaleForecast: function(){
  352. var grid = Ext.getCmp('grid'), items = grid.store.data.items, c = Ext.getCmp('sf_code').value;
  353. Ext.Array.each(items, function(item){
  354. item.set('sd_code', c);
  355. });
  356. //保存
  357. this.FormUtil.beforeSave(this);
  358. },
  359. beforeUpdate: function(){
  360. var grid = Ext.getCmp('grid'), items = grid.store.data.items, c = Ext.getCmp('sf_code').value;
  361. Ext.Array.each(items, function(item){
  362. item.set('sd_code', c);
  363. });
  364. //更新
  365. this.FormUtil.onUpdate(this);
  366. }
  367. });