MultiForm.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.MultiForm', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil'],
  5. views:[
  6. 'ma.MultiForm','ma.MyForm','ma.MyGrid','ma.MyDetail','core.button.DeleteDetail','core.toolbar.Toolbar',
  7. 'core.trigger.DbfindTrigger','core.trigger.MultiDbfindTrigger','core.grid.TfColumn','core.grid.YnColumn',
  8. 'core.button.UUListener', 'core.button.DbfindButton','core.button.ComboButton', 'core.form.YnField',
  9. 'core.button.Sync','core.button.ReportFiles','core.trigger.AddDbfindTrigger'
  10. ],
  11. init:function(){
  12. var me = this;
  13. me.FormUtil = Ext.create('erp.util.FormUtil');
  14. me.GridUtil = Ext.create('erp.util.GridUtil');
  15. this.control({
  16. 'dbfindtrigger[name=ds_likefield]':{
  17. beforetrigger:function(field){
  18. var table=Ext.getCmp('ds_whichdbfind').value;
  19. if(table){
  20. con=table.toUpperCase().split('LEFT JOIN')[0];
  21. field.dbBaseCondition = "table_name='"+con+"'";
  22. }else{
  23. showError("请先选择查找表名!");
  24. return false;
  25. }
  26. }
  27. },
  28. 'dbfindtrigger[name=linkkey]':{
  29. beforetrigger:function(field){
  30. var table=Ext.getCmp('dbtablename').value;
  31. if(table){
  32. con=table.toUpperCase().split('LEFT JOIN')[0].replace(/(^\s*)|(\s*$)/g, "");
  33. field.dbBaseCondition = "table_name='"+con+"'";
  34. }
  35. }
  36. },
  37. 'erpSyncButton': {
  38. afterrender: function(btn){
  39. if(isSaas){btn.hide();};
  40. btn.autoClearCache = true;
  41. },
  42. aftersync: function(btn, caller, datas, masters) {
  43. if(caller == 'Form!Post') {
  44. var grids = Ext.ComponentQuery.query('mydetail');
  45. Ext.Array.each(grids, function(grid){
  46. var dg = new Array();
  47. grid.store.each(function(){
  48. if(this.get('dg_id') > 0)
  49. dg.push(this.get('dg_id'));
  50. });
  51. btn.syncdatas = dg.join(',');
  52. btn.caller = 'DetailGrid!Post';
  53. btn.sync();
  54. });
  55. } else {
  56. btn.syncdatas = null;
  57. }
  58. }
  59. },
  60. 'tabpanel': {
  61. add: function(tab) {
  62. var btn = Ext.ComponentQuery.query('erpSyncButton')[0];
  63. if(btn) {
  64. var ids = [];
  65. Ext.Array.each(tab.items.items, function(p){
  66. var id = p.dataId;
  67. if(id > 0)
  68. ids.push(id);
  69. });
  70. btn.syncdatas = ids.join(',');
  71. }
  72. }
  73. },
  74. 'multidbfindtrigger': {
  75. render: function(field){
  76. if(field.name == 'fo_button4add' || field.name == 'fo_button4rw'){
  77. var fields = Ext.Object.getKeys($I18N.common.button);
  78. var values = Ext.Object.getValues($I18N.common.button);
  79. var data = [];
  80. Ext.each(fields, function(f, index){
  81. var o = {};
  82. o.value = fields[index];
  83. o.display = values[index];
  84. data.push(o);
  85. });
  86. field.multistore = {fields:['display', 'value'],data:data};
  87. }
  88. }
  89. },
  90. 'mygrid': {
  91. select: function(selModel, record){
  92. this.GridUtil.onGridItemClick(selModel, record);
  93. var grid=selModel.view.ownerCt.ownerCt;
  94. if(record&& (record.data.fd_dbfind != 'F'||(record.data.fd_type=='MT'&&record.data.fd_logictype!=''))){
  95. grid.down('erpDbfindButton').setDisabled(false);
  96. grid.down('erpComboButton').setDisabled(true);
  97. }else if(record && record.data.fd_type == 'C'){
  98. grid.down('erpDbfindButton').setDisabled(true);
  99. grid.down('erpComboButton').setDisabled(false);
  100. }else {
  101. grid.down('erpComboButton').setDisabled(true);
  102. grid.down('erpDbfindButton').setDisabled(true);
  103. }
  104. }
  105. },
  106. 'mydetail': {
  107. select: function(selModel, record){
  108. this.GridUtil.onGridItemClick(selModel, record);
  109. var grid = selModel.view.ownerCt.ownerCt;
  110. if(record&&record.data.dg_dbbutton != '0') {
  111. grid.down('erpDbfindButton').setDisabled(false);
  112. grid.down('erpComboButton').setDisabled(true);
  113. }else if(record && (record.data.dg_type == 'combo' || record.data.dg_type=='editcombo')) {
  114. grid.down('erpDbfindButton').setDisabled(true);
  115. grid.down('erpComboButton').setDisabled(false);
  116. }else {
  117. grid.down('erpComboButton').setDisabled(true);
  118. grid.down('erpDbfindButton').setDisabled(true);
  119. }
  120. }
  121. },
  122. 'button[name=save]': {
  123. click: function(btn){
  124. me.save();
  125. }
  126. },
  127. 'erpDeleteDetailButton': {
  128. afterrender: function(btn){
  129. btn.ownerCt.add({
  130. xtype:'erpDbfindButton'
  131. });
  132. btn.ownerCt.add({
  133. xtype:'erpComboButton'
  134. });
  135. }
  136. },
  137. /**
  138. * 下拉框设置
  139. */
  140. 'erpComboButton': {
  141. click: function(btn){
  142. var tab = btn.up('tabpanel'),
  143. activeTab = tab.getActiveTab() || tab.items.items[0];
  144. var record = activeTab.down('gridpanel').selModel.lastSelected;
  145. if(record) {
  146. if(record.data.fd_type == 'C') {
  147. btn.comboSet(activeTab.down('field[name=fo_caller]').value, record.data.fd_field);
  148. } else if(record.data.dg_type == 'combo' || record.data.dg_type =='editcombo')
  149. btn.comboSet((activeTab.whoami || record.data.dg_caller), record.data.dg_field);
  150. }
  151. }
  152. },
  153. /**
  154. * DBFind设置
  155. */
  156. 'erpDbfindButton': {
  157. click: function(btn){
  158. var tab = btn.up('tabpanel'),
  159. activeTab = tab.getActiveTab() || tab.items.items[0];
  160. var grid = activeTab.down('gridpanel'), record = grid.selModel.lastSelected;
  161. if(record) {
  162. var isFormDetail = grid.xtype == 'mygrid', isDetail = grid.xtype == 'mydetail';
  163. if(isFormDetail && (record.data.fd_dbfind != 'F'||(record.data.fd_type=='MT'&&record.data.fd_logictype!='')))
  164. btn.dbfindSetUI(activeTab.down('field[name=fo_caller]').value, record.data.fd_field, grid);
  165. else if(isDetail && record.data.dg_dbbutton != '0')
  166. btn.dbfindSetGrid((activeTab.whoami || record.data.dg_caller), activeTab.down('gridpanel'), record.data.dg_field);
  167. }
  168. }
  169. },
  170. 'button[name=delete]': {
  171. click: function(btn){
  172. }
  173. },
  174. 'button[name=close]': {
  175. click: function(btn){
  176. me.FormUtil.beforeClose(me);
  177. }
  178. },
  179. 'button[name=ReportFiles]':{
  180. click:function(btn){
  181. var tab = btn.ownerCt.ownerCt.down('tabpanel'),
  182. activeTab = tab.getActiveTab() || tab.items.items[0];
  183. var linkCaller='ReportFilesFG';
  184. var win = new Ext.window.Window(
  185. {
  186. id : 'win',
  187. height : '90%',
  188. width : '95%',
  189. maximizable : true,
  190. buttonAlign : 'center',
  191. layout : 'anchor',
  192. items : [ {
  193. tag : 'iframe',
  194. frame : true,
  195. anchor : '100% 100%',
  196. layout : 'fit',
  197. html : '<iframe id="iframe_'+linkCaller+'" src="'+basePath+'jsps/fa/fp/ReportFilesFG.jsp?formCondition=fo_callerIS'+activeTab.down('field[name=fo_caller]').value+'&gridCondition=callerIS'+activeTab.down('field[name=fo_caller]').value+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  198. } ]
  199. });
  200. win.show();
  201. }
  202. },
  203. 'button[name=listSetting]':{
  204. click:function(btn){
  205. var win = Ext.create('Ext.window.Window',{
  206. modal : true,
  207. id : 'lsWin',
  208. title:'列表设置',
  209. height : '30%',
  210. width : '38%',
  211. layout : 'anchor',
  212. bodyStyle: 'background: #f1f1f1;',
  213. bodyPadding:10,
  214. items : [{
  215. anchor: '100% 100%',
  216. xtype: 'form',
  217. layout: {
  218. type: 'table',
  219. columns: 2
  220. },
  221. bodyStyle: 'background: #f1f1f1;border:none',
  222. defaults:{
  223. fieldStyle : "background:rgb(224, 224, 255);"
  224. },
  225. items : [{
  226. xtype : 'textfield',
  227. name : 'dl_caller',
  228. fieldLabel : '列表Caller',
  229. id : 'dl_caller',
  230. //value : d.fo_dlcaller || '',
  231. allowBlank : false,
  232. labelWidth:105
  233. }, {
  234. xtype : 'button',
  235. text : '确定',
  236. id : 'confirmListBtn',
  237. cls : 'x-btn-gray',
  238. iconCls : 'x-button-icon-save',
  239. width: 80,
  240. style : {
  241. marginLeft : '15px'
  242. },
  243. listeners : {
  244. click : function(btn) {
  245. me.setDatalist("dl");
  246. }
  247. }
  248. }, {
  249. xtype : 'textfield',
  250. name : 'dl_relative',
  251. fieldLabel : '关联列表Caller',
  252. id : 'dl_relative',
  253. //value : d.fo_dlrelativecaller || '',
  254. allowBlank : false,
  255. labelWidth:105
  256. }, {
  257. xtype : 'button',
  258. text : '确定',
  259. id : 'confirmReBtn',
  260. cls : 'x-btn-gray',
  261. width: 80,
  262. iconCls : 'x-button-icon-save',
  263. style : {
  264. marginLeft : '15px'
  265. },
  266. listeners : {
  267. click : function(btn) {
  268. me.setDatalist("re");
  269. }
  270. }
  271. }],
  272. buttonAlign : 'center',
  273. buttons : [{
  274. text : '关闭',
  275. cls : 'x-btn-gray',
  276. iconCls : 'x-button-icon-close',
  277. id : 'closeBtn',
  278. handler : function(btn) {
  279. btn.up('window').close();
  280. }
  281. }]
  282. }],
  283. listeners:{
  284. beforeshow:function(e){
  285. var fo_caller = me.getMainForm().getForm().getValues().fo_caller;
  286. me.FormUtil.getFieldsValue("Form", "fo_dlcaller,fo_dlrelativecaller", "fo_caller='"+fo_caller+"'", "dl_caller,dl_relative");
  287. Ext.getCmp("dl_caller").originalValue = Ext.getCmp("dl_caller").value;
  288. Ext.getCmp("dl_relative").originalValue = Ext.getCmp("dl_relative").value;
  289. if(Ext.getCmp('mytab').items.items.length == 1){//没有从表,不配置关联列表
  290. Ext.getCmp("dl_relative").hide(true);
  291. Ext.getCmp("confirmReBtn").hide(true);
  292. }
  293. }
  294. }
  295. });
  296. win.show();
  297. }
  298. },
  299. 'dbfindtrigger[name=fo_keyfield]': {
  300. afterrender: function(t){
  301. t.dbKey = "fo_table";
  302. t.mappingKey = "ddd_tablename";
  303. t.dbMessage = "请先选择表名!";
  304. }
  305. },
  306. 'dbfindtrigger[name=fo_codefield]': {
  307. afterrender: function(t){
  308. t.dbKey = "fo_table";
  309. t.mappingKey = "ddd_tablename";
  310. t.dbMessage = "请先选择表名!";
  311. }
  312. },
  313. 'dbfindtrigger[name=fo_statusfield]': {
  314. afterrender: function(t){
  315. t.dbKey = "fo_table";
  316. t.mappingKey = "ddd_tablename";
  317. t.dbMessage = "请先选择表名!";
  318. }
  319. },
  320. 'dbfindtrigger[name=fo_statuscodefield]': {
  321. afterrender: function(t){
  322. t.dbKey = "fo_table";
  323. t.mappingKey = "ddd_tablename";
  324. t.dbMessage = "请先选择表名!";
  325. }
  326. },
  327. 'dbfindtrigger[name=fo_detailkeyfield]': {
  328. afterrender: function(t){
  329. t.dbKey = "fo_detailtable";
  330. t.mappingKey = "ddd_tablename";
  331. t.dbMessage = "请先选择从表名!";
  332. }
  333. },
  334. 'dbfindtrigger[name=fo_detailmainkeyfield]': {
  335. afterrender: function(t){
  336. t.dbKey = "fo_detailtable";
  337. t.mappingKey = "ddd_tablename";
  338. t.dbMessage = "请先选择从表名!";
  339. }
  340. },
  341. 'dbfindtrigger[name=fo_detailstatuscode]': {
  342. afterrender: function(t){
  343. t.dbKey = "fo_detailtable";
  344. t.mappingKey = "ddd_tablename";
  345. t.dbMessage = "请先选择从表名!";
  346. }
  347. },
  348. 'dbfindtrigger[name=fo_detailstatus]': {
  349. afterrender: function(t){
  350. t.dbKey = "fo_detailtable";
  351. t.mappingKey = "ddd_tablename";
  352. t.dbMessage = "请先选择从表名!";
  353. }
  354. },
  355. 'dbfindtrigger[name=fo_detaildetnofield]': {
  356. afterrender: function(t){
  357. t.dbKey = "fo_detailtable";
  358. t.mappingKey = "ddd_tablename";
  359. t.dbMessage = "请先选择从表名!";
  360. }
  361. },
  362. 'dbfindtrigger': {
  363. afterrender: function(t){
  364. t.autoDbfind = false;
  365. }
  366. },
  367. 'mfilefield': {
  368. afterrender: function(f) {
  369. // 只能有一个rpt附件
  370. f.multi = false;
  371. }
  372. },
  373. 'button[name=FormBook]': {
  374. click: function(btn){
  375. var forms = Ext.ComponentQuery.query('myform');
  376. if(forms.length > 0)
  377. me.showFormBookEditor(forms[0].down('field[name=fo_id]').value);
  378. }
  379. },
  380. 'field[name=dg_field]': {
  381. blur: function(f) {
  382. var value = f.getValue(), grid = me.getActiveGrid(), record = grid.selModel.lastSelected, gridCaller = record.get("dg_caller");
  383. if(value && gridCaller) {
  384. var form = me.getMainForm(), formCallerField = (form ? (form.down('field[name=fo_caller]')) : null),
  385. formCaller = (formCallerField ? (formCallerField.getValue()) : null);
  386. if(gridCaller == formCaller) {
  387. me.checkColumn(form.down('field[name=fo_detailtable]').getValue(), value, record);
  388. } else {
  389. me.checkColumn(record.get('dg_table'), value, record);
  390. }
  391. }
  392. }
  393. },
  394. 'field[name=fd_field]': {
  395. blur: function(f) {
  396. var value = f.getValue().toLowerCase(), tabpanel = Ext.getCmp('mytab'), tab=tabpanel.getActiveTab() || tabpanel.items.items[0];
  397. grid = tab.down('gridpanel'), record = grid.selModel.lastSelected;
  398. if(value && record) {
  399. me.checkColumn(tab.down('form').down('field[name=fo_table]').getValue(), value, record);
  400. }
  401. }
  402. }
  403. });
  404. },
  405. getMainForm: function() {
  406. var forms = Ext.ComponentQuery.query('myform');
  407. if(forms.length > 0)
  408. return forms[0];
  409. return null;
  410. },
  411. getActiveGrid: function() {
  412. return Ext.getCmp('mytab').getActiveTab().down('gridpanel');
  413. },
  414. checkColumn: function(table, field, record) {
  415. Ext.Ajax.request({
  416. url: basePath + 'ma/checkFields.action',
  417. params: {
  418. table: table,
  419. field: field
  420. },
  421. callback: function(opts, success, response) {
  422. if(!success || response.responseText != 'true') {
  423. showError('字段'+field+'不存在!');
  424. }
  425. }
  426. });
  427. },
  428. createPreForm: function(){
  429. var form = Ext.create('Ext.form.Panel', {
  430. });
  431. },
  432. createPreGrid: function(){
  433. },
  434. createFormItem: function(record){
  435. },
  436. autoSetFormIgnore: function(item, dictionary, fields) {
  437. if(item.get('deploy') && item.get('fd_field') && dictionary && !item.get('fd_logictype')){
  438. var field = item.get('fd_field').toLowerCase(), d = Ext.Array.filter(dictionary, function(i){
  439. return i.column_name == field;
  440. });
  441. if(d.length == 0){
  442. item.set('fd_logictype', 'ignore');
  443. }
  444. }
  445. },
  446. autoSetGridIgnore: function(item, dictionary) {
  447. if(item.get('deploy') && item.get('dg_field') && dictionary && !item.get('dg_logictype')) {
  448. var field = item.get('dg_field').toLowerCase();
  449. if (field.indexOf(" ")>0) {// column有取别名
  450. var strs = field.split(" ");
  451. field = strs[strs.length - 1];
  452. }
  453. var d = Ext.Array.filter(dictionary, function(i){
  454. return i.column_name == field;
  455. });
  456. if(d.length == 0)
  457. item.set('dg_logictype', 'ignore');
  458. }
  459. },
  460. isUnique: function(grid, fieldName) {
  461. var keys = {}, key = null;
  462. grid.store.each(function(item){
  463. key = item.get(fieldName);
  464. if(item.get('deploy') && key) {
  465. key = key.toLowerCase();
  466. keys[key] = (keys[key] || 0) + 1;
  467. }
  468. });
  469. var fields = Ext.Object.getKeys(keys);
  470. var err = Ext.Array.filter(fields, function(field){
  471. return keys[field] > 1;
  472. });
  473. return err.join(',');
  474. },
  475. save: function(){
  476. var me = this, isErr = false, isDefault = false;
  477. var forms = Ext.ComponentQuery.query('myform'), formData = [], added = [], updated = [], deleted = [];
  478. Ext.Array.each(forms, function(form){
  479. var grid = form.ownerCt.down('mygrid');
  480. var field = form.down('field[name=fo_table]'), val = field.value.split(' ')[0],
  481. id = form.dataId || form.down('field[name=fo_id]').value,
  482. button4add = form.down('field[name=fo_button4add]').value,
  483. button4rw = form.down('field[name=fo_button4rw]').value;
  484. var err = me.isUnique(grid, "fd_field");
  485. if(err) {
  486. showError("字段重复:" + err);
  487. isErr = true;
  488. return;
  489. }
  490. var commonChange=form.down('field[name=fo_caller]').value.indexOf("$")>0;//通用变更单不自动设忽略
  491. // 普通页面需要自动设置ignore
  492. isDefault = (button4add != null && button4add.indexOf('erpSaveButton')>-1) || (button4rw != null && (button4rw.indexOf('erpSaveButton')>-1 || button4rw.indexOf('erpUpdateButton')>-1) );
  493. grid.store.each(function(item){
  494. item.set('fd_foid', id);
  495. if(item.get('deploy') && !Ext.isEmpty(item.get('fd_field'))){
  496. if(Ext.isEmpty(item.get('fd_table'))){
  497. item.set('fd_table', val);
  498. }
  499. if(isDefault && !commonChange){
  500. me.autoSetFormIgnore(item, grid.dictionary[val]);
  501. }
  502. }
  503. });
  504. formData.push(form.getValues());
  505. var dd = grid.getChange();
  506. added = Ext.Array.merge(added, dd.added);
  507. updated = Ext.Array.merge(updated, dd.updated);
  508. deleted = Ext.Array.merge(deleted, dd.deleted);
  509. });
  510. var details = Ext.ComponentQuery.query('mydetail'), gridAdded = [], gridUpdated = [], gridDeleted = [];
  511. if (details) {
  512. Ext.Array.each(details, function(detail){
  513. var err = me.isUnique(detail, "dg_field");
  514. if(err) {
  515. showError("字段重复:" + err);
  516. isErr = true;
  517. return;
  518. }
  519. if(isDefault){
  520. detail.store.each(function(item){
  521. me.autoSetGridIgnore(item, detail.dictionary);
  522. });
  523. }
  524. de = detail.getChange();
  525. gridAdded = Ext.Array.merge(gridAdded, de.added);
  526. gridUpdated = Ext.Array.merge(gridUpdated, de.updated);
  527. gridDeleted = Ext.Array.merge(gridDeleted, de.deleted);
  528. });
  529. }
  530. if (isErr)
  531. return;
  532. Ext.Array.each(formData, function(d){
  533. var keys = Ext.Object.getKeys(d);
  534. for(k in keys) {
  535. if (keys[k].indexOf('ext-') > -1)
  536. delete d[keys[k]];
  537. }
  538. });
  539. me.onSave(unescape(escape(Ext.encode(formData))), unescape(Ext.encode(added).toString()),
  540. unescape(Ext.encode(updated).toString()), unescape(Ext.encode(deleted).toString()),
  541. unescape(Ext.encode(gridAdded).toString()), unescape(Ext.encode(gridUpdated).toString()), unescape(Ext.encode(gridDeleted).toString()));
  542. },
  543. onSave: function(formData, formAdded, formUpdated, formDeleted, gridAdded, gridUpdated, gridDeleted){
  544. var me = this;
  545. me.FormUtil.setLoading(true);
  546. Ext.Ajax.request({
  547. url : basePath + 'ma/updateMultiForm.action',
  548. params: {
  549. formData: formData,
  550. formAdded: formAdded,
  551. formUpdated: formUpdated,
  552. formDeleted: formDeleted,
  553. gridAdded: gridAdded,
  554. gridUpdated: gridUpdated,
  555. gridDeleted: gridDeleted
  556. },
  557. method : 'post',
  558. callback : function(opt, s, res){
  559. me.FormUtil.setLoading(false);
  560. var rs = new Ext.decode(res.responseText);
  561. if(rs.success){
  562. showMessage('提示', '保存成功!', 1000);
  563. window.location.reload();
  564. } else if(rs.exceptionInfo){
  565. var str = rs.exceptionInfo;
  566. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
  567. str = str.replace('AFTERSUCCESS', '');
  568. window.location.reload();
  569. }
  570. showError(str);return;
  571. } else {
  572. showMessage('提示', '保存失败!');
  573. }
  574. }
  575. });
  576. },
  577. showFormBookEditor: function(fo_id) {
  578. Ext.Ajax.request({//拿到grid的columns
  579. url : basePath + "common/getFieldData.action",
  580. params: {
  581. caller: 'FormBook',
  582. field: 'fb_content',
  583. condition: "fb_foid='" + fo_id + "'"
  584. },
  585. method : 'post',
  586. async: false,
  587. callback : function(options,success,response){
  588. var res = new Ext.decode(response.responseText);
  589. if(res.exceptionInfo){
  590. showError(res.exceptionInfo);return;
  591. }
  592. if(res.success){
  593. var win = new Ext.window.Window({
  594. title: '责任书',
  595. height: "90%",
  596. width: "95%",
  597. maximizable : true,
  598. buttonAlign : 'center',
  599. layout : 'anchor',
  600. items: [{
  601. xtype : 'htmleditor',
  602. anchor : '100% 100%',
  603. value : res.data
  604. }],
  605. buttons: [{
  606. text : $I18N.common.button.erpSaveButton,
  607. iconCls: 'x-button-icon-save',
  608. cls: 'x-btn-gray',
  609. listeners: {
  610. buffer: 500,
  611. click: function(btn) {
  612. Ext.Ajax.request({
  613. url : basePath + 'ma/saveFormBook.action',
  614. params: {
  615. foid: fo_id,
  616. text: btn.up('window').down('htmleditor').getValue()
  617. },
  618. method : 'post',
  619. callback : function(options,success,response){
  620. var localJson = new Ext.decode(response.responseText);
  621. if(localJson.exceptionInfo){
  622. showError(localJson.exceptionInfo);
  623. }
  624. if(res.success){
  625. btn.up('window').close();
  626. }
  627. }
  628. });
  629. }
  630. }
  631. },{
  632. text : $I18N.common.button.erpCancelButton,
  633. iconCls: 'x-button-icon-close',
  634. cls: 'x-btn-gray',
  635. handler : function(btn){
  636. btn.up('window').close();
  637. }
  638. }]
  639. });
  640. win.show();
  641. }
  642. }
  643. });
  644. },
  645. setDatalist:function(type){
  646. var me = this;
  647. var dlcaller,relativecaller;
  648. var fo_caller = me.getMainForm().getForm().getValues().fo_caller;
  649. var lockpage = parent.Ext.getCmp("content-panel").lockPage+"?whoami="+fo_caller;
  650. if(type == 'dl'){//列表
  651. dlcaller = Ext.getCmp("dl_caller").value;
  652. if(Ext.isEmpty(dlcaller)){
  653. showError('列表Caller字段值不允许为空');
  654. return ;
  655. }
  656. //原来没有值,现在新增不需提示,后台自动生成
  657. //原来有值,值未发生改变,提示将会清空原有配置,自动生成,
  658. //原来有值,值发生了改变,不提示修改关联caller名称 datalist 表 dl_caller和
  659. if(Ext.getCmp("dl_caller").originalValue != '' && Ext.getCmp("dl_caller").originalValue == dlcaller){
  660. warnMsg("确定重置原有列表配置,根据当前form主表配置生成?", function(btn){
  661. if(btn == 'yes'){
  662. me.savedatalist(fo_caller,dlcaller,lockpage);
  663. } else if(btn == 'no'){
  664. return;
  665. } else {
  666. return;
  667. }
  668. });
  669. }else{
  670. me.savedatalist(fo_caller,dlcaller,lockpage);
  671. }
  672. }else if(type == 're'){//关联列表
  673. relativecaller = Ext.getCmp("dl_relative").value;
  674. if(Ext.isEmpty(relativecaller)){
  675. showError('关联列表Caller字段值不允许为空');
  676. }
  677. if(Ext.getCmp("dl_relative").originalValue != '' && Ext.getCmp("dl_relative").originalValue == relativecaller){
  678. warnMsg("确定重置原有关联列表配置,根据当前form主从表配置生成?", function(btn){
  679. if(btn == 'yes'){
  680. me.saverelativelist(fo_caller,relativecaller,lockpage);
  681. } else if(btn == 'no'){
  682. return;
  683. } else {
  684. return;
  685. }
  686. });
  687. }else{
  688. me.saverelativelist(fo_caller,relativecaller,lockpage);
  689. }
  690. }
  691. },
  692. savedatalist :function(fo_caller,dlcaller,lockpage){
  693. var me = this;
  694. var win = Ext.getCmp('lsWin');
  695. win.setLoading(true,win);
  696. //当前页面的form配置对应的jsp
  697. Ext.Ajax.request({//设置列表caller
  698. url : basePath + "ma/setListCaller.action",
  699. params: {
  700. caller : fo_caller,
  701. dl_caller : dlcaller,
  702. lockpage : lockpage
  703. },
  704. method : 'post',
  705. async: false,
  706. callback : function(options,success,response){
  707. win.setLoading(false,win);
  708. var res = new Ext.decode(response.responseText);
  709. if(res.exceptionInfo){
  710. showError(res.exceptionInfo);return;
  711. }
  712. if(res.success){
  713. //提示修改成功
  714. me.FormUtil.getFieldsValue("Form", "fo_dlcaller,fo_dlrelativecaller", "fo_caller='"+fo_caller+"'", "dl_caller,dl_relative");
  715. Ext.getCmp("dl_caller").originalValue = Ext.getCmp("dl_caller").value;
  716. Ext.getCmp("dl_relative").originalValue = Ext.getCmp("dl_relative").value;
  717. showMessage("提示", "重置列表成功");
  718. }
  719. }
  720. });
  721. },
  722. saverelativelist:function(fo_caller,relativecaller,lockpage){
  723. var me = this;
  724. var win = Ext.getCmp('lsWin');
  725. win.setLoading(true,win);
  726. Ext.Ajax.request({//设置列表caller
  727. url : basePath + "ma/setRelativeCaller.action",
  728. params: {
  729. caller : fo_caller,
  730. re_caller : relativecaller,
  731. lockpage : lockpage
  732. },
  733. method : 'post',
  734. async: false,
  735. callback : function(options,success,response){
  736. win.setLoading(false,win);
  737. var res = new Ext.decode(response.responseText);
  738. if(res.exceptionInfo){
  739. showError(res.exceptionInfo);return;
  740. }
  741. if(res.success){
  742. me.FormUtil.getFieldsValue("Form", "fo_dlcaller,fo_dlrelativecaller", "fo_caller='"+fo_caller+"'", "dl_caller,dl_relative");
  743. Ext.getCmp("dl_caller").originalValue = Ext.getCmp("dl_caller").value;
  744. Ext.getCmp("dl_relative").originalValue = Ext.getCmp("dl_relative").value;
  745. showMessage("提示", "重置列表成功");
  746. }
  747. }
  748. });
  749. }
  750. });