NewSynergy.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.myProcess.synergy.NewSynergy', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'oa.myProcess.synergy.NewSynergy','core.form.Panel','core.button.Save','core.button.Close',
  8. 'core.button.Over','core.button.Submit','core.form.FileField',
  9. 'core.button.Update','core.button.Delete',
  10. 'core.form.YnField','core.trigger.DbfindTrigger'
  11. ],
  12. init:function(){
  13. var me = this;
  14. this.control({
  15. 'erpSaveButton': {
  16. click: function(btn){
  17. var mm = this.FormUtil;
  18. mm.beforeSave(this);
  19. var form = Ext.getCmp('form');
  20. if(! mm.checkForm()){
  21. return;
  22. }
  23. // if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  24. // mm.getSeqId(form);
  25. // }
  26. if(form.getForm().isValid()){
  27. me.saveCustomFlow(form.getForm().getValues()['sy_id']);
  28. }else{
  29. mm.checkForm();
  30. }
  31. }
  32. },
  33. 'erpUpdateButton': {
  34. click: function(btn){
  35. this.FormUtil.onUpdate(this);
  36. }
  37. },
  38. 'erpSubmitButton': {
  39. click: function(btn){
  40. this.FormUtil.onSubmit(Ext.getCmp('sy_id').value);
  41. alert('提交成功');
  42. var main = parent.Ext.getCmp("content-panel");
  43. main.getActiveTab().close();
  44. }
  45. },
  46. 'erpOverButton': {
  47. click: function(btn){
  48. Ext.getCmp('sy_status').setValue('已结束');
  49. Ext.getCmp('sy_statuscode').setValue('OVERED');
  50. this.FormUtil.onUpdate(this);
  51. alert('提交成功');
  52. var main = parent.Ext.getCmp("content-panel");
  53. main.getActiveTab().close();
  54. }
  55. },
  56. 'erpCloseButton': {
  57. click: function(btn){
  58. this.FormUtil.beforeClose(this);
  59. }
  60. },
  61. 'erpDeleteButton': {
  62. click: function(btn){
  63. this.FormUtil.onDelete(Ext.getCmp('sy_id').value);
  64. }
  65. },
  66. 'button[id=addprocess]':{
  67. click: function(btn){
  68. var panel = Ext.getCmp("process");
  69. var main = parent.Ext.getCmp("content-panel");
  70. if(!panel){
  71. var title = "添加流程";
  72. panel = {
  73. title : title,
  74. tag : 'iframe',
  75. tabConfig:{tooltip: '添加流程'},
  76. frame : true,
  77. border : false,
  78. layout : 'fit',
  79. iconCls : 'x-tree-icon-tab-tab1',
  80. html : '<iframe id="iframe_' + 1 + '" src="' + basePath + 'jsps/oa/myProcess/customFlow.jsp" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>',
  81. closable : true,
  82. listeners : {
  83. close : function(){
  84. main.setActiveTab(main.getActiveTab().id);
  85. }
  86. }
  87. };
  88. var win = Ext.create('Ext.window.Window', {
  89. title: '自定义流程',
  90. height: 300,
  91. width: 640,
  92. layout: 'fit',
  93. items: [panel]
  94. });
  95. win.show();
  96. }else{
  97. main.setActiveTab(panel);
  98. }
  99. }
  100. },
  101. 'htmleditor[id=sy_content]': {
  102. afterrender: function(f){
  103. f.setHeight(325);
  104. }
  105. }
  106. });
  107. },
  108. getForm: function(btn){
  109. return btn.ownerCt.ownerCt;
  110. },
  111. saveCustomFlow: function(){
  112. var syId = arguments[0];
  113. var customFlowDetail = iframe_1.window.Ext.getCmp('grid');
  114. var cparam = [];
  115. if(!customFlowDetail){
  116. alert('你尚未添加流程!');
  117. }else{
  118. var datas = customFlowDetail.store.data.items;
  119. Ext.each(datas,function(data){
  120. if(data.data['cfd_actorUsers']!=null&&data.data['cfd_actorUsers']!=''){
  121. cparam.push(data.data);
  122. }
  123. });
  124. }
  125. var cArray = [];
  126. Ext.each(cparam,function(param){
  127. var ps = Ext.encode(param);
  128. cArray.push(ps);
  129. });
  130. var param = '['+cArray.join(",")+']';
  131. var customFlow = iframe_1.window.Ext.getCmp('form');
  132. var cf_sourceId = iframe_1.window.Ext.getCmp('cf_sourceId');
  133. cf_sourceId.setValue(syId);
  134. var cf_id = iframe_1.window.Ext.getCmp('cf_id');
  135. cf_id.setValue(syId);
  136. var cf_caller = iframe_1.window.Ext.getCmp('cf_caller');
  137. cf_caller.setValue("CustomFlow_"+new String(syId));
  138. var cf_name = iframe_1.window.Ext.getCmp('cf_name');
  139. cf_name.setValue("CustomFlow_"+new String(syId));
  140. var cf_source = iframe_1.window.Ext.getCmp('cf_source');
  141. cf_source.setValue("CustomFlow");
  142. console.log("ssddddddd");
  143. var formStore = Ext.encode(customFlow.getForm().getValues());
  144. Ext.Ajax.request({
  145. url: basePath + customFlow.saveUrl,
  146. params: {
  147. formStore:formStore,
  148. param:param
  149. },
  150. success: function(response){
  151. alert("成功");
  152. }
  153. });
  154. }
  155. });