Form.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. Ext.define('erp.view.scm.reserve.setBarcode.Form',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpSetBarcodeFormPanel',
  4. requires: ['Ext.tip.QuickTipManager','erp.view.core.button.Save','erp.view.core.button.GenerateBarcode','erp.view.core.trigger.DbfindTrigger',''],
  5. id: 'setBarcodeform',
  6. region: 'north',
  7. frame : true,
  8. layout : 'column',
  9. title:'条形码维护',
  10. columnWidth:0.33,
  11. padding: '0 4 0 4',
  12. autoScroll : true,
  13. defaultType : 'textfield',
  14. labelSeparator : ':',
  15. buttonAlign : 'center',
  16. fieldDefaults : {
  17. fieldStyle : "background:#FFFAFA;color:#515151;",
  18. labelAlign : "left",
  19. blankText : $I18N.common.form.blankText,
  20. labelWidth: 80
  21. },
  22. FormUtil: Ext.create('erp.util.FormUtil'),
  23. isStatic: true,
  24. initComponent : function(){
  25. Ext.tip.QuickTipManager.init();
  26. var me = this;
  27. Ext.apply(me, {
  28. items : [{
  29. id : 'bi_inoutno',
  30. name : 'bi_inoutno',
  31. fieldLabel : '出入库单号',
  32. readOnly : true,
  33. columnWidth : 0.20,
  34. fieldStyle : 'background:#f0f0f0;border: 0px solid #8B8970;font-color:blue'
  35. }, {
  36. id : 'bi_pdno',
  37. name : 'bi_pdno',
  38. fieldLabel : '行号',
  39. columnWidth : 0.10,
  40. readOnly : true,
  41. labelWidth : 40,
  42. fieldStyle : 'background:#f0f0f0;border: 0px solid #8B8970;font-color:blue'
  43. },{
  44. xtype:'tool',
  45. type:'prev',
  46. id: 'prev',
  47. tooltip: '上一条',
  48. margin:'4 6 0 0',
  49. listeners:{
  50. render: function(btn){
  51. setTimeout(function(){
  52. if(parent.Ext) {
  53. var form = Ext.getCmp('setBarcodeform');
  54. var bi_pdid = Ext.getCmp("bi_pdid").value;
  55. var datalistStore = form.getCurrentStore(bi_pdid);
  56. Ext.each(datalistStore, function(){
  57. if(this.selected == true){
  58. if(this.prev == null){
  59. btn.disable(true);
  60. }
  61. }
  62. });
  63. } else {
  64. btn.disable(true);
  65. }
  66. },100);
  67. },
  68. click: function(btn){
  69. var form = Ext.getCmp('setBarcodeform');
  70. var newId = 0;
  71. var idx = 0;
  72. var id = Ext.getCmp("bi_piid").value;
  73. var bi_pdid = Ext.getCmp("bi_pdid").value;
  74. var datalistStore = form.getCurrentStore(bi_pdid);
  75. Ext.each(datalistStore, function(s, index){
  76. if(s.selected == true){
  77. if(s.prev != null){
  78. newId = this.prev;
  79. idx = index;
  80. }
  81. }
  82. });
  83. var formCondition = "pd_id="+newId+" and pi_id='"+id+"'";
  84. var gridCondition = "bi_pdid="+newId+" and bi_piid='"+id+"'";
  85. window.location.href = basePath+'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  86. }
  87. }
  88. },{
  89. xtype:'tool',
  90. type: 'next',
  91. id: 'next',
  92. tooltip: '下一条',
  93. margin:'4 8 0 6',
  94. listeners:{
  95. render: function(btn){
  96. setTimeout(function(){
  97. if(parent.Ext) {
  98. var form = Ext.getCmp('setBarcodeform');
  99. var bi_pdid = Ext.getCmp("bi_pdid").value;
  100. var datalistStore = form.getCurrentStore(bi_pdid);
  101. Ext.each(datalistStore, function(){
  102. if(this.selected == true){
  103. if(this.next == null){
  104. btn.disable(true);
  105. }
  106. }
  107. });
  108. } else {
  109. btn.disable(true);
  110. }
  111. },100);
  112. },
  113. click: function(btn){
  114. var form = Ext.getCmp('setBarcodeform');
  115. var bi_pdid = Ext.getCmp("bi_pdid").value;
  116. var datalistStore = form.getCurrentStore(bi_pdid);
  117. var idx = 0;
  118. var newId = 0;
  119. var id = Ext.getCmp("bi_piid").value;
  120. Ext.each(datalistStore, function(s, index){
  121. if(s.selected == true){
  122. if(s.next != null){
  123. newId = s.next;
  124. idx = index;
  125. }
  126. }
  127. });
  128. var formCondition = "pd_id="+newId+" and pi_id='"+id+"'";
  129. var gridCondition = "bi_pdid="+newId+" and bi_piid='"+id+"'";
  130. window.location.href = basePath+'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  131. }
  132. }
  133. } ,{
  134. id : 'pd_ordercode',
  135. name : 'pd_ordercode',
  136. fieldLabel : '采购单号',
  137. readOnly : true,
  138. hidden : true,
  139. hideLabel : true,
  140. logic:'ignore'
  141. }, {
  142. id : 'bi_prodcode',
  143. name : 'bi_prodcode',
  144. fieldLabel : '物料编号',
  145. columnWidth : 0.20,
  146. readOnly : true,
  147. fieldStyle : 'background:#f0f0f0;border: 0px solid #8B8970;font-color:blue'
  148. }, {
  149. id : 'bi_prodid',
  150. name : 'bi_prodid',
  151. fieldLabel : '物料ID',
  152. readOnly : true,
  153. hidden : true,
  154. hideLabel : true
  155. }, {
  156. id : 'bi_pdid',
  157. name : 'bi_pdid',
  158. fieldLabel : '出入库单行号ID',
  159. readOnly : true,
  160. hidden : true,
  161. hideLabel : true
  162. }, {
  163. id : 'bi_piid',
  164. name : 'bi_piid',
  165. fieldLabel : '出入库单ID',
  166. readOnly : true,
  167. hidden : true,
  168. hideLabel : true
  169. },{
  170. id : 'pr_detail',
  171. name : 'pr_detail',
  172. fieldLabel : '物料名称',
  173. readOnly : true,
  174. logic:'ignore',
  175. fieldStyle : 'background:#f0f0f0;border: 0px solid #8B8970;font-color:blue',
  176. columnWidth : 0.20
  177. }, {
  178. id : 'pr_unit',
  179. name : 'pr_unit',
  180. fieldLabel : '单位',
  181. readOnly : true,
  182. logic:'ignore',
  183. fieldStyle : 'background:#f0f0f0;border: 0px solid #8B8970;font-color:blue',
  184. columnWidth : 0.15
  185. }, {
  186. id : 'pd_qty',
  187. name : 'pd_qty',
  188. fieldLabel : '来料总数',
  189. readOnly : true,
  190. logic:'ignore',
  191. fieldStyle : 'background:#f0f0f0;border: 0px solid #8B8970;font-color:blue',
  192. columnWidth : 0.15
  193. }, {
  194. id : 'pr_tracekind',
  195. name : 'pr_tracekind',
  196. xtype : 'combobox',
  197. fieldLabel : '管控类型',
  198. readOnly : true,
  199. fieldStyle : 'background:#f0f0f0;border: 0px solid #8B8970;font-color:blue',
  200. columnWidth : 0.20,
  201. store: Ext.create('Ext.data.Store', {
  202. fields: ['display', 'value'],
  203. data : [
  204. {"display": '不管控', "value": '0'},
  205. {"display": '单件管控', "value": '1'},
  206. {"display": '批管控', "value": '2'}
  207. ]
  208. }),
  209. displayField: 'display',
  210. valueField: 'value',
  211. editable: false
  212. }, {
  213. id : 'pi_cardcode',
  214. name : 'pi_cardcode',
  215. fieldLabel : '供应商编号',
  216. readOnly : true,
  217. fieldStyle : 'background:#f0f0f0;border: 0px solid #8B8970;font-color:blue',
  218. columnWidth : 0.20
  219. }, {
  220. id : 'pi_title',
  221. name : 'pi_title',
  222. fieldLabel : '供应商名称',
  223. readOnly : true,
  224. logic:'ignore',
  225. fieldStyle : 'background:#f0f0f0;border: 0px solid #8B8970;font-color:blue',
  226. columnWidth : 0.4
  227. }, {
  228. xtype : 'textfield',
  229. id : 'pd_inqty',
  230. name : 'pd_inqty',
  231. fieldLabel : '批总量',
  232. fieldStyle : "background:rgb(224, 224, 255);",
  233. labelStyle:"color:red;",
  234. columnWidth : 0.20
  235. }, {
  236. id : 'pd_outqty',
  237. name : 'pd_outqty',
  238. fieldLabel : '批总量',
  239. allowBlank:false,
  240. columnWidth : 0.20
  241. },{
  242. xtype : 'textfield',
  243. id : 'pk_qty',
  244. name : 'pk_qty',
  245. fieldLabel : '箱内总数',
  246. columnWidth : 0.20
  247. },{
  248. xtype : 'textfield',
  249. id : 'pr_zxbzs',
  250. name : 'pr_zxbzs',
  251. fieldLabel : '最小包数',
  252. columnWidth : 0.20,
  253. allowBlank:false,
  254. fieldStyle : "background:rgb(224, 224, 255);",
  255. labelStyle:"color:red;"
  256. },{
  257. xtype : 'textareatrigger',
  258. id : 'bi_bzs',
  259. name : 'bi_bzs',
  260. fieldLabel : '来料包装数',
  261. columnWidth : 0.20
  262. }, {
  263. xtype : 'textfield',
  264. id : 'bi_vendbarcode',
  265. name : 'bi_vendbarcode',
  266. fieldLabel : '供应商批号',
  267. columnWidth : 0.22
  268. }, {
  269. xtype : 'datefield',
  270. id : 'bi_madedate',
  271. name : 'bi_madedate',
  272. fieldLabel : '生产日期',
  273. columnWidth : 0.20
  274. }, {
  275. xtype : 'datefield',
  276. id : 'bi_validdate',
  277. name : 'bi_validdate',
  278. fieldLabel : '有效期',
  279. columnWidth : 0.20,
  280. labelWidth : 50
  281. }, {
  282. id : 'pl_code',
  283. xtype : 'dbfindtrigger',
  284. name : 'bi_location',
  285. fieldLabel : '仓位',
  286. fieldStyle : "background:rgb(224, 224, 255);",
  287. labelStyle:"color:red;",
  288. columnWidth : 0.15,
  289. allowBlank:false,
  290. labelWidth : 50
  291. }],
  292. dockedItems:[{
  293. xtype: 'toolbar',
  294. dock: 'bottom',
  295. layout: {
  296. pack: 'center' //放置位置
  297. },
  298. defaults: {
  299. style: {
  300. marginLeft: '10px',
  301. marginBottom:'15px'
  302. }
  303. },
  304. items:[{
  305. id : 'batchGenBarcode',
  306. cls : 'x-btn-gray',
  307. text : '批量生成条码',
  308. style : 'margin-left:20px',
  309. formBind : true,// form.isValid() == false时,按钮disabled
  310. width:100
  311. },/*{
  312. cls: 'x-btn-gray',
  313. id: 'generateBarcodebtn',
  314. text: $I18N.common.button.erpGenerateBarcodeButton,
  315. formBind : true,// form.isValid() == false时,按钮disabled
  316. style: {
  317. marginLeft: '10px'
  318. },
  319. width: 90
  320. },*/{
  321. id : 'batchGenBarOBcode',
  322. cls : 'x-btn-gray',
  323. text : '批量生成条码和箱号',
  324. style : 'margin-left:20px',
  325. formBind : true,// form.isValid() == false时,按钮disabled
  326. width:150
  327. }/*,{
  328. xtype:'erpGeneratePaCodeButton'
  329. }*/,{
  330. xtype:'erpPrintAllButton'
  331. },{
  332. xtype:'erpPrintAllPackageButton'
  333. },{
  334. id : 'save',
  335. text : '保存',
  336. width : 60,
  337. iconCls : 'x-button-icon-save',
  338. cls : 'x-btn-gray'
  339. },{
  340. xtype:'erpDeleteAllDetailsButton'
  341. },{
  342. xtype:'erpCloseButton'
  343. }]
  344. }]
  345. });
  346. formCondition = getUrlParam('formCondition');// 从url解析参数
  347. formCondition = (formCondition == null) ? "" : formCondition.replace(/IS/g,"=");
  348. this.loadStore(this,formCondition);
  349. this.callParent(arguments);
  350. },
  351. loadStore : function(form,param){
  352. var me = this;
  353. Ext.Ajax.request({
  354. url : basePath + "scm/reserve/getBarFormStore.action",
  355. params: {
  356. caller: caller,
  357. condition:param
  358. },
  359. method : 'post',
  360. callback : function(options,success,response){
  361. var res = new Ext.decode(response.responseText);
  362. if(res.exceptionInfo != null){
  363. showError(res.exceptionInfo);return;
  364. }
  365. if(res.data){
  366. var d = Ext.decode(res.data);
  367. form.getForm().setValues(d);
  368. }
  369. }
  370. });
  371. },
  372. getCurrentStore: function(value){
  373. var grid = parent.Ext.getCmp('grid');
  374. var items = grid.store.data.items;
  375. var array = new Array();
  376. var o = null;
  377. Ext.each(items, function(item, index){
  378. o = new Object();
  379. o.selected = false;
  380. if(index == 0){
  381. o.prev = null;
  382. } else {
  383. o.prev = items[index-1].data["pd_id"];
  384. }
  385. if(index == items.length - 1){
  386. o.next = null;
  387. } else {
  388. o.next = items[index+1].data["pd_id"];
  389. }
  390. var v = item.data["pd_id"];
  391. o.value = v;
  392. if(v == value)
  393. o.selected = true;
  394. array.push(o);
  395. });
  396. return array;
  397. }
  398. });