MultiForm.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. Ext.define('erp.view.oa.custom.MultiForm',{
  2. extend: 'Ext.Viewport',
  3. layout: 'fit',
  4. hideBorders: true,
  5. initComponent : function(){
  6. var me = this;
  7. Ext.apply(me, {
  8. items: [{
  9. layout: 'anchor',
  10. items: [{
  11. xtype: 'tabpanel',
  12. anchor: '100% 95%',
  13. id: 'mytab',
  14. items: [{
  15. title: '主表',
  16. id: 'maintab',
  17. iconCls: 'formset-form',
  18. layout: 'anchor',
  19. items: [{
  20. xtype: 'myform',
  21. saveUrl:'ma/saveMultiForm.action',
  22. deleteUrl: 'ma/deleteMultiForm.action',
  23. updateUrl: 'ma/updateMultiForm.action',
  24. getIdUrl: 'common/getId.action?seq=FORM_SEQ',
  25. keyField: 'fo_id',
  26. caller:caller,
  27. anchor: '100% 45%'
  28. },{
  29. xtype: 'customgrid',
  30. anchor: '100% 55%'
  31. }]
  32. },{
  33. title: '从表',
  34. id: 'detailtab',
  35. iconCls: 'formset-grid',
  36. layout: 'anchor',
  37. items: [{
  38. xtype: 'mydetail',
  39. anchor: '100% 100%',
  40. detno: 'dg_sequence',
  41. necessaryField: 'dg_field',
  42. keyField: 'dg_id',
  43. getGridColumnsAndStore: function(){
  44. var grid = this;
  45. var main = parent.Ext.getCmp("content-panel");
  46. if(!main)
  47. main = parent.parent.Ext.getCmp("content-panel");
  48. if(main){
  49. main.getActiveTab().setLoading(true);//loading...
  50. }
  51. Ext.Ajax.request({//拿到grid的columns
  52. url : basePath + 'common/singleGridPanel.action',
  53. async: false,
  54. params: {
  55. caller: grid.caller,
  56. condition: "dg_caller='" + whoami + "'"
  57. },
  58. method : 'post',
  59. callback : function(options,success,response){
  60. if(main){
  61. main.getActiveTab().setLoading(false);
  62. }
  63. var res = new Ext.decode(response.responseText);
  64. if(res.exceptionInfo){
  65. showError(res.exceptionInfo);return;
  66. }
  67. if(res.columns){
  68. grid.columns = res.columns;
  69. grid.fields = res.fields;
  70. grid.columns.push({
  71. xtype: 'checkcolumn',
  72. text: '配置',
  73. width: 60,
  74. dataIndex: 'deploy',
  75. cls: "x-grid-header-1",
  76. locked: true,
  77. editor: {
  78. xtype: 'checkbox',
  79. cls: "x-grid-checkheader-editor"
  80. }
  81. });
  82. grid.fields.push({name: 'deploy', type: 'bool'});
  83. //renderer
  84. grid.getRenderer();
  85. var data = Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  86. Ext.each(data, function(d){
  87. d.deploy = true;
  88. });
  89. grid.data = data;
  90. if(res.dbfinds.length > 0){
  91. grid.dbfinds = res.dbfinds;
  92. }
  93. //取数据字典配置
  94. grid.getDataDictionaryData('CUSTOMTABLEDETAIL');
  95. grid.reconfigureGrid();
  96. }
  97. }
  98. });
  99. },
  100. parseDictionary: function(dictionary) {
  101. var me = this, data = this.data;
  102. if(data.length==0){
  103. var v_detno=0;
  104. Ext.each(dictionary, function(d, index){
  105. if(d.column_name=='cd_id'||d.column_name=='cd_ctid'||d.column_name=='cd_detno'){
  106. o = new Object();
  107. o.dg_table = d.table_name;
  108. o.dg_field = d.column_name;
  109. o.dg_caption = d.comments;
  110. o.dg_captionfan = d.comments;
  111. o.dg_captionen = d.comments;
  112. o.dg_editable = false;
  113. o.dg_width = 80;
  114. o.dg_dbbutton = '0';
  115. o.dg_visible = true;
  116. o.deploy = true;
  117. o.dg_caller = me.whoami;
  118. if(contains(d.data_type, 'VARCHAR2', true)){
  119. o.dg_type = 'text';
  120. o.dg_maxlength=d.data_length;
  121. } else if(contains(d.data_type, 'TIMESTAMP', true)){
  122. o.dg_type = 'datetimecolumn';
  123. } else if(d.data_type == 'DATE'){
  124. o.dg_type = 'datecolumn';
  125. } else if(d.data_type == 'NUMBER'){
  126. o.dg_type = 'numbercolumn';
  127. } else if(d.data_type == 'FLOAT'){
  128. o.dg_type = 'floatcolumn';
  129. } else {
  130. o.dg_type = 'text';
  131. o.dg_maxlength=d.data_length||100;
  132. }
  133. o.dg_sequence = ++v_detno;
  134. if(d.column_name=='cd_id'){
  135. o.dg_logictype='keyField';
  136. o.dg_width = 0;
  137. o.dg_field = d.column_name.toUpperCase();
  138. }
  139. if(d.column_name=='cd_ctid'){
  140. o.dg_logictype='mainField';
  141. o.dg_field = d.column_name.toUpperCase();
  142. o.dg_width = 0;
  143. }
  144. if(d.column_name=='cd_detno'){
  145. o.dg_logictype='detno';
  146. o.dg_field = d.column_name.toUpperCase();
  147. }
  148. data.push(o);
  149. }
  150. });
  151. }
  152. //取Max(序号)
  153. var det = Ext.Array.max(Ext.Array.pluck(data, me.detno));
  154. //data里面包含的字段
  155. var sel = [];
  156. Ext.Array.each(data, function(d){
  157. sel.push(d.dg_field.toLowerCase());
  158. });
  159. var o = null;
  160. Ext.each(dictionary, function(d, index){
  161. //将DataDictionary的数据转化成FormDetail数据
  162. if(sel.indexOf(d.column_name) == -1){
  163. o = new Object();
  164. o.dg_table = d.table_name;
  165. o.dg_field = d.column_name;
  166. o.dg_caption = d.comments;
  167. o.dg_captionfan = d.comments;
  168. o.dg_captionen = d.comments;
  169. o.dg_editable = false;
  170. o.dg_width = 80;
  171. o.dg_dbbutton = '0';
  172. o.dg_visible = true;
  173. o.deploy = false;
  174. o.dg_caller = me.whoami;
  175. if(contains(d.data_type, 'VARCHAR2', true)){
  176. o.dg_type = 'text';
  177. o.dg_maxlength=d.data_length;
  178. } else if(contains(d.data_type, 'TIMESTAMP', true)){
  179. o.dg_type = 'datetimecolumn';
  180. } else if(d.data_type == 'DATE'){
  181. o.dg_type = 'datecolumn';
  182. } else if(d.data_type == 'NUMBER'){
  183. o.dg_type = 'numbercolumn';
  184. } else if(d.data_type == 'FLOAT'){
  185. o.dg_type = 'floatcolumn';
  186. } else {
  187. o.dg_type = 'text';
  188. o.dg_maxlength=d.data_length||100;
  189. }
  190. o.dg_sequence = ++det;
  191. data.push(o);
  192. }
  193. });
  194. me.dictionary = dictionary;
  195. }
  196. }]
  197. }]
  198. },{
  199. xtype: 'toolbar',
  200. anchor: '100% 5%',
  201. items: ['->',{
  202. xtype: 'erpUUListenerButton'
  203. },'-',{
  204. iconCls: 'x-button-icon-preview',
  205. name: 'preview',
  206. cls: 'x-btn-gray',
  207. text: $I18N.common.button.erpPreviewButton
  208. },'-',{
  209. iconCls: 'tree-save',
  210. name: 'save',
  211. cls: 'x-btn-gray',
  212. text: $I18N.common.button.erpSaveButton
  213. },'-',{
  214. xtype: 'erpSyncButton'
  215. },'-',{
  216. iconCls: 'tree-delete',
  217. name: 'delete',
  218. cls: 'x-btn-gray',
  219. text: $I18N.common.button.erpDeleteButton
  220. },'-',{
  221. iconCls: 'tree-close',
  222. name: 'close',
  223. cls: 'x-btn-gray',
  224. text: $I18N.common.button.erpCloseButton
  225. },'->']
  226. }]
  227. }]
  228. });
  229. me.callParent(arguments);
  230. }
  231. });