VoucherStyle2.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.VoucherStyle2', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. views: ['fa.VoucherStyle', 'core.form.Panel', 'core.grid.Panel2', 'core.grid.YnColumn', 'core.trigger.TextAreaTrigger',
  7. 'core.trigger.DbfindTrigger','core.button.Sync','core.button.CreateSQL',
  8. 'core.button.Close', 'core.button.Save', 'core.button.Update'],
  9. init:function(){
  10. var me = this;
  11. this.control({
  12. 'erpGridPanel2': {
  13. itemclick: function(selModel, record) {
  14. me.GridUtil.onGridItemClick(selModel, record);
  15. var btn = Ext.getCmp('assdetail');
  16. var ass = record.data['ca_asstype'],
  17. check = record.data['vd_checkitem'];
  18. if(!Ext.isEmpty(ass) || check == -1){
  19. btn.setDisabled(false);
  20. } else {
  21. btn.setDisabled(true);
  22. }
  23. }
  24. },
  25. 'erpCreateSQLButton': {
  26. click: function(btn){
  27. warnMsg("确定要生成SQL语句吗?", function(btn){
  28. if(btn == 'yes'){
  29. me.FormUtil.getActiveTab().setLoading(true);//loading...
  30. var grid = Ext.getCmp('grid'), items = grid.store.data.items;
  31. var type = items[0].data['vd_class']
  32. Ext.Ajax.request({
  33. url : basePath + 'fa/vc/createSql.action',
  34. params: {
  35. id: Ext.getCmp('vs_id').value,
  36. type: type
  37. },
  38. method : 'post',
  39. callback : function(options,success,response){
  40. me.FormUtil.getActiveTab().setLoading(false);
  41. var localJson = new Ext.decode(response.responseText);
  42. if(localJson.exceptionInfo){
  43. showError(localJson.exceptionInfo);
  44. }
  45. if(localJson.success){
  46. window.location.reload();
  47. }
  48. }
  49. });
  50. }
  51. });
  52. }
  53. },
  54. 'erpDeleteDetailButton': {
  55. afterrender: function(btn){
  56. //辅助核算
  57. btn.ownerCt.add({
  58. text: '辅助核算',
  59. width: 85,
  60. disabled: true,
  61. cls: 'x-btn-blue',
  62. id: 'assdetail'
  63. });
  64. }
  65. },
  66. 'erpSaveButton': {
  67. click: function(btn){
  68. me._beforeSave();
  69. me.beforeSave();
  70. }
  71. },
  72. 'erpUpdateButton': {
  73. click: function(btn){
  74. me._beforeSave();
  75. me.beforeUpdate();
  76. }
  77. },
  78. 'button[id=assdetail]': {
  79. click: function(btn){
  80. var grid = btn.ownerCt.ownerCt;
  81. var record = grid.selModel.lastSelected;
  82. if(record){
  83. var id = record.get('vd_id') || (-grid.store.indexOf(record));
  84. var win = Ext.getCmp('ass-' + id);
  85. if(win) {
  86. win.show();
  87. } else {
  88. var grid = Ext.create('Ext.grid.Panel', {
  89. anchor: '100% 100%',
  90. columns: [{
  91. text: 'ID',
  92. hidden: true,
  93. dataIndex: 'vsa_id'
  94. },{
  95. text: 'VD_ID',
  96. hidden: true,
  97. dataIndex: 'vsa_vdid'
  98. },{
  99. text: '核算项',
  100. dataIndex: 'vsa_assname',
  101. flex: 1,
  102. editor: {
  103. xtype: 'dbfindtrigger'
  104. },
  105. dbfind: 'AssKind|ak_name'
  106. },{
  107. text: '编号表达式',
  108. dataIndex: 'vsa_codefield',
  109. flex: 1,
  110. editor: {
  111. xtype: 'textfield'
  112. }
  113. },{
  114. text: '名称表达式',
  115. dataIndex: 'vsa_namefield',
  116. flex: 1,
  117. editor: {
  118. xtype: 'textfield'
  119. }
  120. }],
  121. store: new Ext.data.Store({
  122. fields: [{name: 'vsa_id', type: 'number'}, {name: 'vsa_vdid', type: 'number'},
  123. {name: 'vsa_assname', type: 'string'}, {name: 'vsa_codefield', type: 'string'},
  124. {name: 'vsa_namefield', type: 'string'}]
  125. }),
  126. columnLines: true,
  127. plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
  128. clicksToEdit: 1
  129. })],
  130. dbfinds: [{
  131. field: 'vsa_assname',
  132. dbGridField: 'ak_name'
  133. }],
  134. listeners: {
  135. itemclick: function(selModel, record) {
  136. var grid = selModel.ownerCt,
  137. store = grid.store,
  138. idx = store.indexOf(record),
  139. len = store.getCount();
  140. if(idx == len - 1) {
  141. store.add({}, {}, {}, {}, {});
  142. }
  143. }
  144. }
  145. });
  146. win = Ext.create('Ext.Window', {
  147. width: 500,
  148. height: 360,
  149. layout: 'anchor',
  150. title: '辅助核算公式',
  151. items: [grid],
  152. buttonAlign: 'center',
  153. modal: true,
  154. buttons: [{
  155. text: $I18N.common.button.erpConfirmButton,
  156. cls: 'x-btn-blue',
  157. handler: function(btn) {
  158. var win = btn.ownerCt.ownerCt,
  159. grid = Ext.getCmp('grid'),
  160. record = grid.selModel.lastSelected,
  161. ass = win.down('gridpanel');
  162. var data = new Array();
  163. ass.store.each(function(item){
  164. data.push(item.data);
  165. });
  166. if(data.length > 0){
  167. me.cacheStore[record.data[grid.keyField] || (-record.index)] = data;
  168. }
  169. win.hide();
  170. }
  171. },{
  172. text: $I18N.common.button.erpOffButton,
  173. cls: 'x-btn-blue',
  174. handler: function(btn) {
  175. btn.ownerCt.ownerCt.hide();
  176. }
  177. }]
  178. }).show();
  179. }
  180. me.getAss(win.down('gridpanel'), id, record.get('ca_assname'));
  181. }
  182. }
  183. },
  184. 'field[name=vd_catecode]': {
  185. aftertrigger: function(f, d) {
  186. var record = f.record,
  187. ass = d.get('ca_asstype');
  188. if(!Ext.isEmpty(ass)) {
  189. record.set('vd_checkitem', -1);
  190. } else {
  191. record.set('vd_checkitem', 0);
  192. }
  193. }
  194. },
  195. 'dbfindtrigger[name=vd_casdesc]': {
  196. focus: function(t){
  197. t.setHideTrigger(false);
  198. t.setReadOnly(false);
  199. if(Ext.getCmp('vs_pritable')){
  200. var code = Ext.getCmp('vs_pritable').value;
  201. if(code != null && code != ''){
  202. if(t.dbBaseCondition==null||t.dbBaseCondition==''){
  203. t.dbBaseCondition= "cas_code='"+code+"'";
  204. }else{
  205. t.dbBaseCondition=t.dbBaseCondition+" and cas_code='"+code+"'";
  206. }
  207. }
  208. }
  209. }
  210. },
  211. 'dbfindtrigger[name=vd_amsdesc]': {
  212. focus: function(t){
  213. t.setHideTrigger(false);
  214. t.setReadOnly(false);
  215. if(Ext.getCmp('vs_pritable')){
  216. var code = Ext.getCmp('vs_pritable').value;
  217. if(code != null && code != ''){
  218. if(t.dbBaseCondition==null||t.dbBaseCondition==''){
  219. t.dbBaseCondition= "ams_code='"+code+"'";
  220. }else{
  221. t.dbBaseCondition=t.dbBaseCondition+" and ams_code='"+code+"'";
  222. }
  223. }
  224. }
  225. }
  226. },
  227. 'dbfindtrigger[name=vd_cusdesc]': {
  228. focus: function(t){
  229. t.setHideTrigger(false);
  230. t.setReadOnly(false);
  231. if(Ext.getCmp('vs_pritable')){
  232. var code = Ext.getCmp('vs_pritable').value;
  233. if(code != null && code != ''){
  234. if(t.dbBaseCondition==null||t.dbBaseCondition==''){
  235. t.dbBaseCondition= "cus_code='"+code+"'";
  236. }else{
  237. t.dbBaseCondition=t.dbBaseCondition+" and cus_code='"+code+"'";
  238. }
  239. }
  240. }
  241. }
  242. },
  243. 'dbfindtrigger[name=vd_rasdesc]': {
  244. focus: function(t){
  245. t.setHideTrigger(false);
  246. t.setReadOnly(false);
  247. if(Ext.getCmp('vs_pritable')){
  248. var code = Ext.getCmp('vs_pritable').value;
  249. if(code != null && code != ''){
  250. if(t.dbBaseCondition==null||t.dbBaseCondition==''){
  251. t.dbBaseCondition= "ras_code='"+code+"'";
  252. }else{
  253. t.dbBaseCondition=t.dbBaseCondition+" and ras_code='"+code+"'";
  254. }
  255. }
  256. }
  257. }
  258. },
  259. 'dbfindtrigger[name=vd_resdesc]': {
  260. focus: function(t){
  261. t.setHideTrigger(false);
  262. t.setReadOnly(false);
  263. if(Ext.getCmp('vs_pritable')){
  264. var code = Ext.getCmp('vs_pritable').value;
  265. if(code != null && code != ''){
  266. if(t.dbBaseCondition==null||t.dbBaseCondition==''){
  267. t.dbBaseCondition= "res_code='"+code+"'";
  268. }else{
  269. t.dbBaseCondition=t.dbBaseCondition+" and res_code='"+code+"'";
  270. }
  271. }
  272. }
  273. }
  274. },
  275. 'field[name=vd_explanation]': {
  276. focus: function(f){
  277. var grid = Ext.getCmp('grid');
  278. var record = grid.selModel.lastSelected;
  279. me.explainView(record);
  280. }
  281. },
  282. });
  283. },
  284. explainView:function(gridrecord){
  285. var width = Ext.isIE ? screen.width*0.7*0.9 : '80%',
  286. height = Ext.isIE ? screen.height*0.75 : '80%';
  287. var code = Ext.getCmp('vs_pritable').value, type = gridrecord.data['vd_class'];
  288. if(!this.explainWin) {
  289. this.explainWin = Ext.create('Ext.Window', {
  290. title : '摘要定义',
  291. closeAction: 'hide',
  292. width: width,
  293. height: height,
  294. autoShow: true,
  295. layout: 'anchor',
  296. items: [{
  297. xtype : 'grid',
  298. frame : true,
  299. anchor: '100% 60%',
  300. id : 'grid1',
  301. plugins: [Ext.create('erp.view.core.grid.HeaderFilter', {
  302. remoteFilter: true
  303. })],
  304. tbar : [ '->', {
  305. text : $I18N.common.button.erpConfirmButton,
  306. iconCls: 'x-button-icon-close',
  307. cls: 'x-btn-gray',
  308. handler : function(btn){
  309. gridrecord.set('vd_explanation',btn.up('window').down('htmleditor').getFormatValue());
  310. btn.up('window').close();
  311. }
  312. }, {
  313. text : $I18N.common.button.erpCancelButton,
  314. iconCls: 'x-button-icon-close',
  315. cls: 'x-btn-gray',
  316. handler : function(btn){
  317. btn.up('window').close();
  318. }
  319. }],
  320. columns : [{
  321. text : '可选择摘要单元',
  322. cls : 'x-grid-header-1',
  323. dataIndex: 'DIS_DESCRIPTION',
  324. flex: 2,
  325. filter: {
  326. xtype : 'textfield'
  327. }
  328. },{
  329. text : '编号',
  330. cls : 'x-grid-header-1',
  331. dataIndex: 'DIS_CODE',
  332. flex: 1,
  333. filter: {
  334. xtype : 'textfield'
  335. }
  336. },{
  337. text : '单据类型',
  338. cls : 'x-grid-header-1',
  339. dataIndex: 'DIS_CLASS',
  340. flex: 1,
  341. filter: {
  342. xtype : 'textfield'
  343. }
  344. }],
  345. store : new Ext.data.Store({
  346. fields : [ 'DIS_DESCRIPTION', 'DIS_CODE', 'DIS_CLASS',
  347. 'DIS_ID','DIS_SQLPARAM' ],
  348. proxy : {
  349. type : 'ajax',
  350. url : basePath + 'fa/vc/getDigestSource.action',
  351. reader : {
  352. type : 'json',
  353. root : 'data'
  354. }
  355. },
  356. autoLoad : {
  357. params: {
  358. code: code,
  359. type: type
  360. }
  361. },
  362. listeners: {
  363. load: function(store, datas) {
  364. var sqlparams = gridrecord.get('vd_explanation');
  365. if(sqlparams && datas) {
  366. var editor = Ext.getCmp('parameditor');
  367. editor.parseSql(sqlparams, datas);
  368. }
  369. }
  370. }
  371. }),
  372. listeners:{
  373. itemmousedown:function(selmodel, record){
  374. var grid = selmodel.ownerCt, editor = grid.ownerCt.down('#parameditor');
  375. var desc = record.data['DIS_DESCRIPTION'], param = record.get('DIS_SQLPARAM');
  376. editor.insertCell(desc, param);
  377. }
  378. }
  379. },{
  380. xtype : 'htmleditor',
  381. anchor : '100% 40%',
  382. id: 'parameditor',
  383. enableColors: false,
  384. enableAlignments: false,
  385. enableFont: false,
  386. enableFontSize: false,
  387. enableFormat: false,
  388. enableLinks: false,
  389. enableLists: false,
  390. enableSourceEdit: false,
  391. insertCell: function(desc, param) {
  392. var me = this, src = this.textToDataURL(desc, {fontSize: 14, color: '#ff0000'});
  393. me.win.focus();
  394. me.execCmd('InsertHTML', '<img src="' + src +'" title="' + desc + '" style="margin-bottom: -2px;" data-code="' + param + '"/>');
  395. me.deferFocus();
  396. },
  397. textToDataURL: function(text, opts) {
  398. var canvas = this.getCanvas(), context = canvas.getContext('2d');
  399. text = '[' + text + ']';
  400. var offset = this.getCharOffset(text, opts.fontSize);
  401. canvas.width = offset.width;
  402. canvas.height = offset.height;
  403. context.clearRect(0, 0, canvas.width, canvas.height);
  404. context.fillStyle = opts.color;
  405. context.font = 'normal ' + opts.fontSize + 'px \'microsoft yahei\', sans-serif';
  406. context.textBaseline = 'top';
  407. canvas.style.display = 'none';
  408. context.fillText(text, 0, 0, canvas.width);
  409. return canvas.toDataURL("image/png");
  410. },
  411. /**
  412. * html5画布
  413. **/
  414. getCanvas: function() {
  415. if(Ext.supports.Canvas) {
  416. var me = this;
  417. if(!me.canvas) {
  418. Ext.DomHelper.append(Ext.getBody(), {
  419. tag: 'canvas',
  420. id: me.getId() + '-canvas',
  421. style: 'display:block;'
  422. });
  423. me.canvas = Ext.get(me.getId() + '-canvas').dom;
  424. }
  425. return me.canvas;
  426. } else {
  427. Ext.Msg.alert('您的浏览器暂不支持!');
  428. }
  429. },
  430. /**
  431. * 预先计算即将插入的文字所占宽度和高度
  432. **/
  433. getCharOffset: function(str, fontSize) {
  434. var me = this;
  435. if(!me.charWidthSpan) {
  436. Ext.DomHelper.append(Ext.getBody(), {
  437. tag: 'span',
  438. id: me.getId() + '-char-width-span',
  439. style: 'visibility:hidden;white-space:nowrap;font-size:' + fontSize + 'px'
  440. });
  441. me.charWidthSpan = Ext.get(me.getId() + '-char-width-span').dom;
  442. }
  443. me.charWidthSpan.innerText = str;
  444. return {width: me.charWidthSpan.offsetWidth, height: me.charWidthSpan.offsetHeight};
  445. },
  446. /**
  447. * 转化成sql代码
  448. */
  449. getFormatValue: function() {
  450. var val = this.getValue();
  451. if(val) {
  452. var imgs = this.getEditorBody().getElementsByTagName('img');
  453. Ext.Array.each(imgs, function(img){
  454. val = val.replace(img.outerHTML, '\'||' + img.getAttribute('data-code') + '||\'');
  455. });
  456. val = ('\'' + val + '\'').replace(/(''\|\|)|(\|\|'')/gi,'');
  457. }
  458. return val;
  459. },
  460. parseSql: function(sqlValue, datas) {
  461. var me = this, sqls = sqlValue.split('||');
  462. Ext.defer(function(){
  463. me.setValue(null);
  464. if (!me.activated) {
  465. me.onFirstFocus();
  466. }
  467. me.win.focus();
  468. Ext.Array.each(sqls, function(sql){
  469. if(/'.+'/.test(sql)) {
  470. me.insertAtCursor(sql.substring(1, sql.length - 1));
  471. } else {
  472. Ext.Array.each(datas, function(data){
  473. if(data.get('DIS_SQLPARAM') == sql) {console.log(sql);
  474. me.insertCell(data.get('DIS_DESCRIPTION'), data.get('DIS_SQLPARAM'));
  475. return;
  476. }
  477. });
  478. }
  479. });
  480. }, !me.win ? 500 : 1, me);
  481. }
  482. }]
  483. });
  484. } else {
  485. this.explainWin.down('#parameditor').setValue(null);
  486. this.explainWin.down('#grid1').store.load({
  487. params: {
  488. code: code,
  489. type: type
  490. }
  491. });
  492. }
  493. this.explainWin.show();
  494. },
  495. _beforeSave: function() {
  496. var grid = Ext.getCmp('grid'),
  497. code = Ext.getCmp('vs_code').value;
  498. // Ext.each(grid.store.data.items,function(item,index){
  499. //
  500. // if(item.data['vd_class']==''){
  501. // item.data['vd_code']=code;
  502. // }
  503. //
  504. // });
  505. grid.store.each(function(d){
  506. if(!Ext.isEmpty(d.get('vd_class'))) {
  507. d.set('vd_code', code);
  508. }
  509. });
  510. },
  511. cacheStore: new Array(),
  512. getAss: function(grid, id, assname) {
  513. var me = this;
  514. if(!me.cacheStore[id]){
  515. if(id == null || id <= 0){
  516. var data = new Array(),r = assname.join('#');
  517. for(var i=0;i<r.length;i++){
  518. var o = new Object();
  519. o.vsa_vdid = id;
  520. o.vsa_assname = r[i];
  521. data.push(o);
  522. }
  523. grid.store.loadData(data);
  524. } else {
  525. var condition = "vsa_vdid=" + id;
  526. Ext.Ajax.request({
  527. url : basePath + 'common/getFieldsDatas.action',
  528. params: {
  529. caller: "VoucherStyleAss",
  530. fields: 'vsa_id,vsa_vdid,vsa_assname,vsa_codefield,vsa_namefield',
  531. condition: condition
  532. },
  533. method : 'post',
  534. callback : function(options,success,response){
  535. var res = new Ext.decode(response.responseText);
  536. if(res.exception || res.exceptionInfo){
  537. showError(res.exceptionInfo);
  538. return;
  539. }
  540. var data = Ext.decode(res.data);
  541. var dd = new Array(),r = assname.split('#');
  542. Ext.Array.each(data, function(d){
  543. var o = new Object();
  544. o.vsa_id = d.VSA_ID;
  545. o.vsa_vdid = d.VSA_VDID;
  546. o.vsa_assname = d.VSA_ASSNAME;
  547. o.vsa_codefield = d.VSA_CODEFIELD;
  548. o.vsa_namefield = d.VSA_NAMEFIELD;
  549. dd.push(o);
  550. });
  551. for(var i = 0; i < r.length; i++){
  552. if(!Ext.isEmpty(r[i])) {
  553. var bool = false;
  554. Ext.Array.each(data, function(d){
  555. if(d.VSA_ASSNAME == r[i]) {
  556. bool = true;
  557. }
  558. });
  559. if(!bool) {
  560. var o = new Object();
  561. o.vsa_vdid = id;
  562. o.vsa_assname = r[i];
  563. dd.push(o);
  564. }
  565. }
  566. }
  567. if(dd.length == 0) {
  568. dd = [{}, {}, {}, {}, {}];
  569. }
  570. grid.store.loadData(dd);
  571. }
  572. });
  573. }
  574. } else {
  575. grid.store.loadData(me.cacheStore[id]);
  576. }
  577. },
  578. beforeSave: function(){
  579. var me = this;
  580. var form = Ext.getCmp('form');
  581. if(! me.FormUtil.checkForm()){
  582. return;
  583. }
  584. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  585. me.FormUtil.getSeqId(form);
  586. }
  587. var detail = Ext.getCmp('grid');
  588. var param2 = new Array();
  589. Ext.each(Ext.Object.getKeys(me.cacheStore), function(key){
  590. Ext.each(me.cacheStore[key], function(d){
  591. d['vsa_vdid'] = key;
  592. param2.push(d);
  593. });
  594. });
  595. Ext.each(detail.store.data.items, function(item){
  596. if(item.data.vd_id == null || item.data.vd_id == 0){
  597. item.data.vd_id = -item.index;
  598. }
  599. });
  600. var param1 = me.GridUtil.getGridStore(detail);
  601. if(detail.necessaryField.length > 0 && (param1.length == 0)){
  602. showError($I18N.common.grid.emptyDetail);
  603. return;
  604. }
  605. me.onSave(form, param1, param2);
  606. },
  607. onSave: function(form, param1, param2) {
  608. var me = this;
  609. param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
  610. param2 = param2 == null ? [] : Ext.encode(param2).replace(/\\/g,"%");
  611. // param3 = param3 == null ? [] : param3.toString().replace(/\\/g,"%");
  612. if(form.getForm().isValid()){
  613. Ext.each(form.items.items, function(item){
  614. if(item.xtype == 'numberfield'){
  615. if(item.value == null || item.value == ''){
  616. item.setValue(0);
  617. }
  618. }
  619. });
  620. me.FormUtil.save(form.getValues(), param1, param2);
  621. }else{
  622. me.FormUtil.checkForm();
  623. }
  624. },
  625. beforeUpdate: function(){
  626. var me = this;
  627. var form = Ext.getCmp('form');
  628. if(! me.FormUtil.checkForm()){
  629. return;
  630. }
  631. var detail = Ext.getCmp('grid');
  632. Ext.each(detail.store.data.items, function(item){
  633. if(item.data.vd_id == null || item.data.vd_id == 0){
  634. item.data.vd_id = -item.index;
  635. }
  636. });
  637. var param1 = me.GridUtil.getGridStore(detail);
  638. var param2 = new Array();
  639. Ext.each(Ext.Object.getKeys(me.cacheStore), function(key){
  640. Ext.each(me.cacheStore[key], function(d){
  641. d['vsa_vdid'] = key;
  642. param2.push(d);
  643. });
  644. });
  645. if(me.FormUtil.checkFormDirty(form) == '' && detail.necessaryField.length > 0 && (param1.length == 0)
  646. && param2.length == 0){
  647. showError($I18N.common.grid.emptyDetail);
  648. return;
  649. } else {
  650. param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
  651. param2 = param2 == null ? [] : Ext.encode(param2).replace(/\\/g,"%");
  652. if(form.getForm().isValid()){
  653. Ext.each(form.items.items, function(item){
  654. if(item.xtype == 'numberfield'){
  655. if(item.value == null || item.value == ''){
  656. item.setValue(0);
  657. }
  658. }
  659. });
  660. me.FormUtil.update(form.getValues(), param1, param2);
  661. }else{
  662. me.FormUtil.checkForm();
  663. }
  664. }
  665. }
  666. });