JprocessTemplateSet.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.jprocess.JprocessTemplateSet', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'core.form.Panel','ma.jprocess.JprocessTemplateSet','core.toolbar.Toolbar','core.form.FileField','core.form.MultiField',
  9. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.Upload','core.button.ResAudit',
  10. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.ResSubmit','oa.doc.OrgTreePanel',
  11. 'core.button.Consign','core.button.End','core.button.ResEnd','core.trigger.MultiDbfindTrigger','core.form.HrOrgSelectField',
  12. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.grid.YnColumn','core.form.FileField'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. 'erpSaveButton': {
  18. click: function(btn){
  19. this.save(btn);
  20. }
  21. },
  22. 'erpDeleteButton' : {
  23. click: function(btn){
  24. me.FormUtil.onDelete({id: Number(Ext.getCmp('pt_id').value)});
  25. }
  26. },
  27. 'erpUpdateButton': {
  28. afterrender: function(btn){
  29. var status = Ext.getCmp('pt_statuscode');
  30. if(status && status.value != 'ENTERING'){
  31. btn.hide();
  32. }
  33. },
  34. click: function(btn){
  35. this.update(btn);
  36. }
  37. },
  38. 'htmleditor':{
  39. beforerender: function(field){
  40. if(!field.autoHeight) field.height=500;
  41. }
  42. },
  43. 'erpAddButton': {
  44. click: function(){
  45. me.FormUtil.onAdd('addJprocessTemplate', '自定流程模板', 'jsps/ma/jprocess/JprocessTemplateSet.jsp');
  46. }
  47. },
  48. 'erpCloseButton': {
  49. click: function(btn){
  50. me.FormUtil.beforeClose(me);
  51. }
  52. },
  53. 'erpSubmitButton': {
  54. afterrender: function(btn){
  55. var status = Ext.getCmp('pt_statuscode');
  56. if(status && status.value != 'ENTERING'){
  57. btn.hide();
  58. }
  59. },
  60. click: function(btn){
  61. me.FormUtil.onSubmit(Ext.getCmp('pt_id').value);
  62. }
  63. },
  64. 'erpResSubmitButton': {
  65. afterrender: function(btn){
  66. var status = Ext.getCmp('pt_statuscode');
  67. if(status && status.value != 'COMMITED'){
  68. btn.hide();
  69. }
  70. },
  71. click: function(btn){
  72. me.FormUtil.onResSubmit(Ext.getCmp('pt_id').value);
  73. }
  74. },
  75. 'erpAuditButton': {
  76. afterrender: function(btn){
  77. var status = Ext.getCmp('pt_statuscode');
  78. if(status && status.value != 'COMMITED'){
  79. btn.hide();
  80. }
  81. },
  82. click: function(btn){
  83. me.FormUtil.onAudit(Ext.getCmp('pt_id').value);
  84. }
  85. },
  86. 'erpResAuditButton': {
  87. afterrender: function(btn){
  88. var status = Ext.getCmp('pt_statuscode');
  89. if(status && status.value != 'AUDITED'){
  90. btn.hide();
  91. }
  92. },
  93. click: function(btn){
  94. me.FormUtil.onResAudit(Ext.getCmp('pt_id').value);
  95. }
  96. },
  97. 'erpFeatureDefinitionButton':{
  98. click: function(btn){
  99. var grid = Ext.getCmp('grid');
  100. var record = grid.selModel.lastSelected;
  101. if(record.data.sd_prodcode != null){
  102. Ext.Ajax.request({//拿到grid的columns
  103. url : basePath + "pm/bom/getDescription.action",
  104. params: {
  105. tablename: 'Product',
  106. field: 'pr_specvalue',
  107. condition: "pr_code='" + record.data.sd_prodcode + "'"
  108. },
  109. method : 'post',
  110. async: false,
  111. callback : function(options,success,response){
  112. var res = new Ext.decode(response.responseText);
  113. if(res.exceptionInfo){
  114. showError(res.exceptionInfo);return;
  115. }
  116. if(res.success){
  117. if(res.description != '' && res.description != null && res.description == 'NOTSPECIFIC'){
  118. var win = new Ext.window.Window({
  119. id : 'win',
  120. title: '生成特征料号',
  121. height: "90%",
  122. width: "95%",
  123. maximizable : true,
  124. buttonAlign : 'center',
  125. layout : 'anchor',
  126. items: [{
  127. tag : 'iframe',
  128. frame : true,
  129. anchor : '100% 100%',
  130. layout : 'fit',
  131. html : '<iframe id="iframe_' + record.data.sd_id + '" src="' + basePath +
  132. "jsps/pm/bom/FeatureValueSet.jsp?fromwhere=SaleDetail&condition=formidIS" + record.data.sd_id + ' AND pr_codeIS' + record.data.sd_prodcode + ' AND pr_nameIS' + record.data.pr_detail +'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  133. }]
  134. });
  135. win.show();
  136. } else {
  137. showError('物料特征必须为虚拟特征件');return;
  138. }
  139. }
  140. }
  141. });
  142. }
  143. }
  144. },
  145. '#workflow':{
  146. activate:function (tab){
  147. if(tab.items.length==0){
  148. var caller=Ext.getCmp('pt_caller').value;
  149. var bool=me.isHaveFlow(caller);
  150. var items=new Array();
  151. if(!bool){
  152. items.push({
  153. tag : 'iframe',
  154. style:{
  155. background:'#f0f0f0',
  156. border:'none'
  157. },
  158. frame : true,
  159. border : false,
  160. layout : 'fit',
  161. height:window.innerHeight*0.9,
  162. iconCls : 'x-tree-icon-tab-tab',
  163. html : '<iframe id="iframe_maindetail_" src="'+basePath+'workfloweditor/workfloweditor2.jsp?caller='+caller+'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  164. });
  165. }else {
  166. var url="workfloweditor/workfloweditor.jsp";
  167. items.push({
  168. title:'查看流程',
  169. frame:true,
  170. html:'<h2>你还没有设置个人导航流程或系统没有定义相应的导航图</br><a style="text-decoration:none;" href="javascript:openTable('+'\''+"查看流程"+'\',\''+url+'\''+ ');">快去看看吧!</a></h2>'
  171. });
  172. }
  173. tab.add(items);
  174. }}
  175. }
  176. });
  177. },
  178. save:function(btn){
  179. var me=this;
  180. var form = me.getForm(btn);
  181. if(! this.FormUtil.checkForm()){
  182. return;
  183. }
  184. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  185. this.FormUtil.getSeqId(form);
  186. }
  187. var r=form.getValues();
  188. Ext.each(Ext.Object.getKeys(r), function(k){
  189. if(contains(k, 'ext-', true)){
  190. delete r[k];
  191. }
  192. });
  193. var clobtext=r["pt_text"];
  194. delete r['pt_text'];
  195. form.setLoading(true);//loading...
  196. Ext.Ajax.request({
  197. url : basePath + form.saveUrl,
  198. params : {
  199. formStore: unescape(Ext.JSON.encode(r)),
  200. clobtext:clobtext
  201. },
  202. method : 'post',
  203. callback : function(options,success,response){
  204. form.setLoading(false);
  205. var localJson = new Ext.decode(response.responseText);
  206. if(localJson.success){
  207. showMessage('提示','保存成功!',1000);
  208. var value = r[form.keyField];
  209. var formCondition = form.keyField + "IS" + value ;
  210. window.location.href = window.location.href + '?formCondition=' +formCondition;
  211. } else if(localJson.exceptionInfo){
  212. var str = localJson.exceptionInfo;
  213. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  214. str = str.replace('AFTERSUCCESS', '');
  215. showError(str);
  216. } else {
  217. showError(str);
  218. return;
  219. }
  220. } else{
  221. saveFailure();
  222. }
  223. }
  224. });
  225. },
  226. update:function(btn){
  227. var me=this;
  228. var form = me.getForm(btn);
  229. if(! this.FormUtil.checkForm()){
  230. return;
  231. }
  232. var r=form.getValues();
  233. Ext.each(Ext.Object.getKeys(r), function(k){
  234. if(contains(k, 'ext-', true)){
  235. delete r[k];
  236. }
  237. });
  238. var clobtext=r["pt_text"];
  239. delete r['pt_text'];
  240. form.setLoading(true);//loading...
  241. Ext.Ajax.request({
  242. url : basePath + form.updateUrl,
  243. params : {
  244. formStore: unescape(Ext.JSON.encode(r)),
  245. clobtext:clobtext
  246. },
  247. method : 'post',
  248. callback : function(options,success,response){
  249. form.setLoading(false);
  250. var localJson = new Ext.decode(response.responseText);
  251. if(localJson.success){
  252. showMessage('提示', '保存成功!', 1000);
  253. window.location.reload();
  254. } else if(localJson.exceptionInfo){
  255. var str = localJson.exceptionInfo;
  256. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  257. str = str.replace('AFTERSUCCESS', '');
  258. showMessage('提示', '保存成功!', 1000);
  259. window.location.reload();
  260. showError(str);
  261. } else {
  262. showError(str);
  263. return;
  264. }
  265. } else{
  266. saveFailure();
  267. }
  268. }
  269. });
  270. },
  271. isHaveFlow:function(caller){
  272. var bool=false;
  273. Ext.Ajax.request({
  274. url : basePath + 'common/checkFieldData.action',
  275. async: false,
  276. params: {
  277. caller: 'JprocessDeploy',
  278. condition: 'jd_caller=\'' + caller + '\''
  279. },
  280. method : 'post',
  281. callback : function(opt, s, res){
  282. var r = new Ext.decode(res.responseText);
  283. if(r.exceptionInfo){
  284. showError(r.exceptionInfo);return;
  285. } else if(r.success && r.data){
  286. bool=r.data;
  287. }
  288. }
  289. });
  290. return bool;
  291. },
  292. onGridItemClick: function(selModel, record){//grid行选择
  293. if(record.data['sd_statuscode']=='AUDITED'){
  294. var turnMake=Ext.getCmp('turnmake');
  295. if(turnMake){
  296. turnMake.setDisabled(false);
  297. }
  298. }
  299. if(!selModel.ownerCt.readOnly){
  300. this.GridUtil.onGridItemClick(selModel, record);
  301. }
  302. },
  303. getForm: function(btn){
  304. return btn.ownerCt.ownerCt;
  305. }
  306. });