AddWorkDaily.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.persontask.workDaily.AddWorkDaily', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'oa.persontask.workDaily.AddWorkDaily','core.form.Panel',
  8. 'core.button.Add','core.button.Save','core.button.Close','core.button.Update','core.button.Delete',
  9. 'core.form.DetailTextField','core.form.FileField','common.datalist.GridPanel','common.datalist.Toolbar'
  10. ],
  11. init:function(){
  12. var me = this;
  13. this.control({
  14. 'erpDatalistGridPanel': {
  15. itemclick: this.onGridItemClick
  16. },
  17. 'datefield[id=wd_date]':{
  18. afterrender: function(field){
  19. if(getUrlParam('flag')!=1){
  20. field.setVisible(false);
  21. }
  22. if(contains(window.location.href,'formCondition',true)){
  23. field.setVisible(true);
  24. field.setDisabled(true);
  25. }
  26. this.search(Ext.util.Format.date(new Date(field.value),"Y-m-d"));
  27. },
  28. change: function(field){
  29. this.search(Ext.util.Format.date(new Date(field.value),"Y-m-d"));
  30. }
  31. },
  32. 'button[id=save]': {
  33. click: function(btn){
  34. var mm = this.FormUtil;
  35. var form = Ext.getCmp('form');
  36. if(! mm.checkForm()){
  37. return;
  38. }
  39. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  40. mm.getSeqId(form);
  41. this.save(form);
  42. // alert(Ext.getCmp('wd_tip').value);
  43. if(Ext.getCmp('wd_tip').value != null && Ext.getCmp('wd_tip').value != ''){
  44. this.release();
  45. }
  46. } else {
  47. this.update(form);
  48. }
  49. }
  50. },
  51. 'button[id=addwd]': {
  52. click: function(btn){
  53. window.location.href = window.location.href + '&flag=1';
  54. }
  55. },
  56. 'button[id=daily]': {
  57. click: function(btn){
  58. var date = Ext.util.Format.date(new Date(Ext.getCmp('wd_date').value),"Y-m-d");
  59. // alert(date);
  60. var win = new Ext.window.Window({
  61. id : 'win',
  62. title: "今日提交任务日志",
  63. height: "50%",
  64. width: "70%",
  65. maximizable : false,
  66. buttonAlign : 'left',
  67. layout : 'anchor',
  68. items: [{
  69. tag : 'iframe',
  70. frame : true,
  71. anchor : '100% 100%',
  72. layout : 'fit',
  73. html : '<iframe id="iframe_' + new Date() + '" src="' + basePath +
  74. 'jsps/oa/persontask/workDaily/daily.jsp?whoami=WorkRecord!Daily&urlcondition=wr_recorderemid=' + em_uu +
  75. " and to_char(wr_recorddate,'yyyy-MM-dd')='" + date + "'" + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  76. }]
  77. });
  78. win.show();
  79. }
  80. },
  81. 'button[id=see]': {
  82. click: function(btn){
  83. var d = new Date();
  84. var win = new Ext.window.Window({
  85. id : 'win',
  86. title: d.getFullYear() + '年' + (d.getMonth()+1) + '月份&nbsp;月计划查看',
  87. height: "50%",
  88. width: "70%",
  89. maximizable : false,
  90. buttonAlign : 'left',
  91. layout : 'anchor',
  92. items: [{
  93. tag : 'iframe',
  94. frame : true,
  95. anchor : '100% 100%',
  96. layout : 'fit',
  97. html : '<iframe id="iframe_' + new Date() + '" src="' + basePath + 'jsps/oa/persontask/workPlan/see.jsp" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  98. }]
  99. });
  100. win.show();
  101. }
  102. },
  103. 'erpUpdateButton': {
  104. click: function(btn){
  105. this.FormUtil.onUpdate(this);
  106. }
  107. },
  108. 'erpDeleteButton': {
  109. click: function(btn){
  110. me.onDelete((Ext.getCmp('at_id').value));
  111. }
  112. },
  113. 'erpCloseButton': {
  114. click: function(btn){
  115. parent.window.location.href = parent.window.location.href;
  116. this.FormUtil.onClose(this);
  117. }
  118. }
  119. });
  120. },
  121. getForm: function(btn){
  122. return btn.ownerCt.ownerCt;
  123. },
  124. onGridItemClick: function(selModel, record){//grid行选择
  125. var me = this;
  126. var id = record.data.ra_id;
  127. var panel = Ext.getCmp("task" + id);
  128. var main = parent.Ext.getCmp("content-panel");
  129. if(!panel){
  130. var title = "任务";
  131. panel = {
  132. title : title,
  133. tag : 'iframe',
  134. tabConfig:{tooltip: record.data['ra_taskname']},
  135. frame : true,
  136. border : false,
  137. layout : 'fit',
  138. iconCls : 'x-tree-icon-tab-tab1',
  139. html : '<iframe id="iframe_' + id + '" src="' + basePath + "jsps/plm/record/workrecord.jsp?whoami=ResourceAssignment&formCondition=ra_id=" + id + "&gridCondition=wr_raid=" + id + '" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>',
  140. closable : true,
  141. listeners : {
  142. close : function(){
  143. main.setActiveTab(main.getActiveTab().id);
  144. }
  145. }
  146. };
  147. me.FormUtil.openTab(panel, "task" + id);
  148. }else{
  149. main.setActiveTab(panel);
  150. }
  151. },
  152. save: function(form){
  153. var mm = this.FormUtil;
  154. if(form.getForm().isValid()){
  155. //form里面数据
  156. Ext.each(form.items.items, function(item){
  157. if(item.xtype == 'numberfield'){
  158. //number类型赋默认值,不然sql无法执行
  159. if(item.value == null || item.value == ''){
  160. item.setValue(0);
  161. }
  162. }
  163. });
  164. var r = form.getValues();
  165. var keys = Ext.Object.getKeys(r);
  166. var values = Ext.Object.getValues(r);
  167. var o = new Object();
  168. Ext.each(keys, function(key, index){
  169. if(contains(key, 'wd_', true)){
  170. o[key] = values[index];
  171. }
  172. });
  173. o.wd_context = Ext.getCmp('wd_context').value=='' ? '':Ext.getCmp('wd_context').value;
  174. if(!mm.contains(form.saveUrl, '?caller=', true)){
  175. form.saveUrl = form.saveUrl + "?caller=" + caller;
  176. }
  177. mm.save(o, []);
  178. }else{
  179. mm.checkForm();
  180. }
  181. },
  182. update: function(form){
  183. var mm = this.FormUtil;
  184. var s1 = mm.checkFormDirty(form);
  185. if(s1 == ''){
  186. showError($I18N.common.form.emptyData + '<br/>');
  187. return;
  188. }
  189. if(form && form.getForm().isValid()){
  190. //form里面数据
  191. var r = form.getValues();
  192. var keys = Ext.Object.getKeys(r);
  193. var values = Ext.Object.getValues(r);
  194. var o = new Object();
  195. Ext.each(keys, function(key, index){
  196. if(contains(key, 'wd_', true)){
  197. o[key] = values[index];
  198. }
  199. });
  200. o.wd_context = Ext.getCmp('wd_context').value=='' ? '':Ext.getCmp('wd_context').value;
  201. if(!mm.contains(form.updateUrl, '?caller=', true)){
  202. form.updateUrl = form.updateUrl + "?caller=" + caller;
  203. }
  204. mm.update(o, []);
  205. }else{
  206. mm.checkForm(form);
  207. }
  208. },
  209. getTi: function(n){
  210. var uom = new Date();
  211. uom.setDate(uom.getDate()+n);
  212. uom = uom.getFullYear() + "-" + (uom.getMonth()+1) + "-" + uom.getDate();
  213. return uom;
  214. },
  215. release: function(){
  216. var o = new Object();
  217. o.prd_recipient = em_name;
  218. o.prd_recipientid = em_uu;
  219. o.pr_context = Ext.getCmp('wd_tip').value;
  220. o.pr_date = this.getTi(1) + " 09:00:00";
  221. // alert(o.pr_date);
  222. Ext.Ajax.request({
  223. url : basePath + 'common/getId.action?seq=PAGINGRELEASE_SEQ',
  224. method : 'get',
  225. async: false,
  226. callback : function(options,success,response){
  227. var rs = new Ext.decode(response.responseText);
  228. if(rs.exceptionInfo){
  229. showError(rs.exceptionInfo);return;
  230. }
  231. if(rs.success){
  232. o.pr_id = rs.id;
  233. }
  234. }
  235. });
  236. // console.log(o);
  237. var params = new Object();
  238. params.formStore = unescape(Ext.JSON.encode(o).replace(/\\/g,"%"));
  239. Ext.Ajax.request({
  240. url : basePath + 'oa/info/sendPagingRelease.action?caller=PagingRelease',
  241. params : params,
  242. method : 'post',
  243. callback : function(options,success,response){
  244. // me.getActiveTab().setLoading(false);
  245. var localJson = new Ext.decode(response.responseText);
  246. if(localJson.success){
  247. saveSuccess(function(){
  248. alert('添加提示成功,提醒时间为:'+o.pr_date);
  249. });
  250. } else{
  251. // saveFailure();//@i18n/i18n.js
  252. }
  253. }
  254. });
  255. },
  256. getSeqId: function(o){
  257. Ext.Ajax.request({
  258. url : basePath + 'common/getId.action?seq=PAGINGRELEASE_SEQ',
  259. method : 'get',
  260. async: false,
  261. callback : function(options,success,response){
  262. var rs = new Ext.decode(response.responseText);
  263. if(rs.exceptionInfo){
  264. showError(rs.exceptionInfo);return;
  265. }
  266. if(rs.success){
  267. o.pr_id = rs.id;
  268. }
  269. }
  270. });
  271. },
  272. search: function(value){
  273. if(!contains(window.location.href,'formCondition',true)){
  274. Ext.Ajax.request({
  275. url : basePath + 'oa/persontask/workDaily/searchWorkDaily.action',
  276. params : {
  277. em_id: em_uu,
  278. date: value
  279. },
  280. method : 'post',
  281. callback : function(options,success,response){
  282. // me.getActiveTab().setLoading(false);
  283. var localJson = new Ext.decode(response.responseText);
  284. if(localJson.success){
  285. if(localJson.wd_id != 0){
  286. warnMsg('今日日报已提交!是否查看', function(btn){
  287. if(btn == 'yes'){
  288. window.location.href = window.location.href + '&formCondition=wd_idIS'+localJson.wd_id+'&gridCondition=';
  289. }else{
  290. return;
  291. }
  292. });
  293. }
  294. } else {
  295. // saveFailure();//@i18n/i18n.js
  296. }
  297. }
  298. });
  299. }
  300. }
  301. });