WorkPlanForm.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. Ext.define('erp.view.oa.persontask.workPlan.WorkPlanForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpWorkPlanFormPanel',
  4. id: 'form',
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. FormUtil: Ext.create('erp.util.FormUtil'),
  7. region: 'center',
  8. frame : true,
  9. autoScroll:true,
  10. fieldDefaults: {
  11. labelWidth: 80,
  12. cls: 'form-field-allowBlank'
  13. },
  14. layout: {
  15. type: 'column',
  16. align: 'stretch' // Child items are stretched to full width子面板高度充满父容器
  17. },
  18. items: [{
  19. xtype: 'textfield',
  20. columnWidth: 1,
  21. fieldLabel: '标题',
  22. allowBlank: false,
  23. fieldStyle:"background:#fffac0;color:#515151;",
  24. id:'wp_title',
  25. name: 'wp_title',
  26. readOnly: true,
  27. listeners: {
  28. change: function(field){
  29. var me = Ext.getCmp('form');
  30. if(field.value && !getUrlParam('nextworkplan')){//nextworkplan为空--编辑界面
  31. var mm = me.down('workplanfield');
  32. mm.removeAll(true);
  33. var lplan = new Object();
  34. Ext.Ajax.request({//查询当月计划是否存在
  35. url : basePath + 'oa/persontask/workPlan/queryWorkPlan.action',
  36. method : 'post',
  37. params:{
  38. title: Ext.getCmp('lasttitle').value
  39. },
  40. async: false,
  41. callback : function(options,success,response){
  42. var rs = new Ext.decode(response.responseText);
  43. if(rs.exceptionInfo){
  44. showError(rs.exceptionInfo);return;
  45. }
  46. if(rs.success){
  47. lplan = rs.workplan;
  48. if(rs.workplan){//当月计划存在且不为空,则列出当月计划条目
  49. Ext.getCmp('save').last = rs.workplan.wp_id;
  50. Ext.Ajax.request({
  51. url : basePath + 'oa/persontask/workPlan/getWorkPlanDetail.action',
  52. params : {
  53. id: rs.workplan.wp_id
  54. },
  55. method : 'post',
  56. async: false,
  57. callback : function(options,success,response){
  58. // me.getActiveTab().setLoading(false);
  59. var res = new Ext.decode(response.responseText);
  60. if(res.success && res.workplandetaillist.length>0){//当月计划条目存在且不为空
  61. var values = '';
  62. for(var i=0; i<res.workplandetaillist.length; i++){
  63. if(i==res.workplandetaillist.length-1){
  64. values += res.workplandetaillist[i].wpd_plan;
  65. } else {
  66. values += res.workplandetaillist[i].wpd_plan + '==###==';
  67. }
  68. }
  69. var text = values.split('==###==');
  70. mm.tfnumber = text.length;
  71. mm.setTitle(mm.title+'('+mm.tfnumber+')');
  72. for(var i=1; i<=mm.tfnumber; i++){
  73. mm.addItem(Ext.create('Ext.form.field.Text', {
  74. xtype: 'textfield',
  75. name: 'text' + i,
  76. // id: 'text' + i,
  77. columnWidth: 1,
  78. labelWidth: 30,
  79. readOnly: true,
  80. value: text[i-1],
  81. fieldLabel: i +'&nbsp;',
  82. fieldStyle: 'background:#f0f0f0;border-bottom-style: 1px solid #8B8970;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;color:#CD661D;border-bottom-style:1px solid;border-left:none; ',
  83. }));
  84. }
  85. } else{
  86. saveFailure();//@i18n/i18n.js
  87. }
  88. }
  89. });
  90. } else {
  91. mm.addItem(Ext.create('Ext.form.field.TextArea', {
  92. xtype: 'textareafield',
  93. name: 'empty',
  94. // id: 'empty',
  95. columnWidth: 1,
  96. height: 30,
  97. frame: false,
  98. readOnly: true,
  99. value: '无数据',
  100. fieldLabel: '',
  101. listeners:{
  102. }
  103. }));
  104. }
  105. }
  106. }
  107. });
  108. Ext.Ajax.request({
  109. url : basePath + 'oa/persontask/workPlan/queryWorkPlan.action',
  110. method : 'post',
  111. params:{
  112. title: field.value
  113. },
  114. async: false,
  115. callback : function(options,success,response){
  116. var rs = new Ext.decode(response.responseText);
  117. if(rs.exceptionInfo){
  118. showError(rs.exceptionInfo);return;
  119. }
  120. if(rs.success){
  121. if(rs.workplan){
  122. Ext.getCmp('wp_summary').setDisabled(true);
  123. Ext.getCmp('nextplan').setDisabled(true);
  124. var url = 'nextworkplan=wp_idIS'+rs.workplan.wp_id;
  125. if(lplan){
  126. url += '&lastworkplan=wp_idIS'+lplan.wp_id;
  127. }
  128. warnMsg(field.value + ' 已存在!是否查看', function(btn){
  129. if(btn == 'yes'){
  130. var id = rs.workplan.wp_id;
  131. var panel = Ext.getCmp("plan" + id);
  132. var main = parent.Ext.getCmp("content-panel");
  133. if(!panel){
  134. var title = "工作计划查看";
  135. panel = {
  136. title : title,
  137. tag : 'iframe',
  138. tabConfig:{tooltip: field.value},
  139. frame : true,
  140. border : false,
  141. layout : 'fit',
  142. iconCls : 'x-tree-icon-tab-tab1',
  143. html : '<iframe id="iframe_' + id + '" src="' + basePath + "jsps/oa/persontask/workPlan/register.jsp?" + url + '" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>',
  144. closable : true,
  145. listeners : {
  146. close : function(){
  147. main.setActiveTab(main.getActiveTab().id);
  148. }
  149. }
  150. };
  151. me.FormUtil.openTab(panel, "plan" + id);
  152. }else{
  153. main.setActiveTab(panel);
  154. }
  155. } else {
  156. return;
  157. }
  158. });
  159. } else {
  160. Ext.getCmp('wp_summary').setDisabled(false);
  161. Ext.getCmp('nextplan').setDisabled(false);
  162. if(lplan){
  163. Ext.getCmp('import').setDisabled(false);
  164. Ext.getCmp('import').index = lplan.wp_id;
  165. } else {
  166. Ext.getCmp('import').setDisabled(true);
  167. }
  168. }
  169. }
  170. }
  171. });
  172. }
  173. }
  174. }
  175. },{
  176. xtype: 'hidden',
  177. columnWidth: 1,
  178. id:'lasttitle',
  179. name: 'lasttitle'
  180. },{
  181. xtype: 'dbfindtrigger',
  182. columnWidth: 0.25,
  183. allowBlank: false,
  184. fieldStyle:"background:#fffac0;color:#515151;",
  185. fieldLabel: '计划类型',
  186. // editable: false,
  187. id:'wp_type',
  188. name: 'wp_type',
  189. listeners: {
  190. afterrender: function(field){
  191. if(getUrlParam('nextworkplan')){
  192. field.setDisabled(true);
  193. }
  194. if(field.value != null && field.value != ''){
  195. Ext.getCmp('wp_time').setDisabled(false);
  196. } else {
  197. Ext.getCmp('wp_time').setDisabled(true);
  198. }
  199. },
  200. change: function(field){
  201. if(field.value != null && field.value != ''){
  202. Ext.getCmp('wp_time').setDisabled(false);
  203. } else {
  204. Ext.getCmp('wp_time').setDisabled(true);
  205. }
  206. }
  207. }
  208. },{
  209. xtype: 'hidden',
  210. columnWidth: 0.25,
  211. fieldLabel: '类型ID',
  212. id:'wp_typeid',
  213. name: 'wp_typeid'
  214. },{
  215. xtype: 'hidden',
  216. columnWidth: 0.25,
  217. fieldLabel: '员工',
  218. id:'wp_emp',
  219. value: em_name,
  220. name: 'wp_emp'
  221. },{
  222. xtype: 'hidden',
  223. columnWidth: 0.25,
  224. fieldLabel: '员工ID',
  225. id:'wp_empid',
  226. value: em_uu,
  227. name: 'wp_empid'
  228. },{
  229. xtype: 'hidden',
  230. columnWidth: 0.25,
  231. fieldLabel: 'ID',
  232. id:'wp_id',
  233. name: 'wp_id'
  234. },{
  235. xtype: 'plandate',
  236. columnWidth: 0.75,
  237. fieldLabel: '计划时间',
  238. id:'wp_time',
  239. name: 'wp_time',
  240. listeners: {
  241. }
  242. },{
  243. xtype: 'textfield',
  244. columnWidth: 0.25,
  245. fieldLabel: '状态',
  246. value: '在录入',
  247. readOnly: true,
  248. id:'wp_status',
  249. name: 'wp_status'
  250. },{
  251. xtype: 'textfield',
  252. columnWidth: 0.375,
  253. readOnly: true,
  254. fieldLabel: '提交时间',
  255. id:'wp_committime',
  256. name: 'wp_committime'
  257. },{
  258. xtype: 'textfield',
  259. columnWidth: 0.375,
  260. readOnly: true,
  261. fieldLabel: '修改时间',
  262. id:'wp_updatetime',
  263. name: 'wp_updatetime'
  264. },{
  265. xtype: 'workplanfield',
  266. columnWidth: 1,
  267. title: '本月计划',
  268. id:'lastplan',
  269. name: 'lastplan'
  270. },{
  271. xtype: 'button',
  272. columnWidth: 0.3,
  273. index:0,
  274. text: '导&nbsp;&nbsp;&nbsp;&nbsp;入&nbsp;&nbsp;&nbsp;&nbsp;计&nbsp;&nbsp;&nbsp;&nbsp;划&nbsp;&nbsp;&nbsp;&nbsp;任&nbsp&nbsp;&nbsp;&nbsp;务',
  275. name: 'import',
  276. id: 'import',
  277. listeners: {
  278. afterrender: function(btn){
  279. btn.setDisabled(true);
  280. },
  281. click: function(btn){
  282. // alert(btn.index);
  283. if(btn.index != 0){
  284. var id = btn.index;
  285. var win = new Ext.window.Window({
  286. id : 'win',
  287. title: "计划详细查看",
  288. height: "60%",
  289. width: "60%",
  290. maximizable : false,
  291. buttonAlign : 'left',
  292. layout : 'anchor',
  293. items: [{
  294. tag : 'iframe',
  295. frame : true,
  296. anchor : '100% 100%',
  297. layout : 'fit',
  298. html : '<iframe id="iframe_' + id + '" src="' + basePath + 'jsps/oa/persontask/workPlan/plan.jsp?whoami=WorkPlanDetail&urlcondition=wpd_wpid=' + id + '" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  299. }]
  300. });
  301. win.show();
  302. }
  303. }
  304. }
  305. },{
  306. xtype: 'fieldset',
  307. columnWidth: 1,
  308. autoScroll:true,
  309. margin: '2 2 2 2',
  310. style: 'background:#f1f1f1;',
  311. title: '<img src="' + basePath + 'resource/images/icon/detail.png" width=20 height=20/>&nbsp;&nbsp;本月总结',
  312. collapsible: true,
  313. minHeight: 200,
  314. layout:'column',
  315. id: 'wp_summary',
  316. name: 'wp_summary',
  317. value:'',
  318. items:[{
  319. xtype: 'textareafield',
  320. columnWidth: 1,
  321. fieldLabel: '',
  322. allowBlank: false,
  323. fieldStyle:"background:#fffac0;color:#515151;",
  324. frame: false,
  325. height: 250,
  326. listeners:{
  327. change: function(field){
  328. this.ownerCt.value = field.value;
  329. if(field.value!=null && field.value!=''){
  330. Ext.getCmp('save').setDisabled(false);
  331. } else {
  332. Ext.getCmp('save').setDisabled(true);
  333. }
  334. }
  335. }
  336. }],
  337. setValue: function(value){
  338. this.value = value;
  339. }
  340. },{
  341. xtype: 'mfilefield',
  342. columnWidth: 1,
  343. fieldLabel: '总结附件',
  344. id:'wp_sumattachs',
  345. name: 'wp_sumattachs'
  346. },{
  347. xtype: 'workplanfield2',
  348. columnWidth: 1,
  349. fieldLabel: '下月计划',
  350. id:'nextplan',
  351. name: 'nextplan'
  352. },{
  353. xtype: 'mfilefield',
  354. columnWidth: 1,
  355. fieldLabel: '计划附件',
  356. id:'wp_planattachs',
  357. name: 'wp_planattachs'
  358. },{
  359. xtype: 'hidden',
  360. columnWidth: 0.25,
  361. fieldLabel: '状态码',
  362. value: 'ENTRING',
  363. readOnly: true,
  364. id:'wp_statuscode',
  365. name: 'wp_statuscode'
  366. }],
  367. tbar: [{
  368. id: 'save',
  369. text: '保存',
  370. last: 0,
  371. iconCls: 'x-button-icon-save',
  372. cls: 'x-btn-gray',
  373. listeners:{
  374. afterrender: function(btn){
  375. if(getUrlParam('nextworkplan')){
  376. btn.setText('更新');
  377. }
  378. }
  379. }
  380. },{
  381. id: 'over',
  382. text: '结束',
  383. iconCls: 'x-button-icon-save',
  384. cls: 'x-btn-gray'
  385. }],
  386. initComponent : function(){
  387. var nextworkplan = getUrlParam('nextworkplan');
  388. var lastworkplan = getUrlParam('lastworkplan');
  389. this.callParent(arguments);
  390. this.getLast(lastworkplan);
  391. this.getNext(nextworkplan);
  392. },
  393. getNext: function(nextworkplan){
  394. if(nextworkplan!=null && nextworkplan!=''){
  395. var id = nextworkplan.split('IS')[1];
  396. Ext.Ajax.request({
  397. url : basePath + 'oa/persontask/workPlan/getWorkPlan.action',
  398. params : {
  399. id: id
  400. },
  401. method : 'post',
  402. async: false,
  403. callback : function(options,success,response){
  404. // me.getActiveTab().setLoading(false);
  405. var res = new Ext.decode(response.responseText);
  406. if(res.success){
  407. Ext.getCmp('wp_id').setValue(res.workplan.wp_id);
  408. Ext.getCmp('wp_type').setValue(res.workplan.wp_type);
  409. Ext.getCmp('wp_typeid').setValue(res.workplan.wp_typeid);
  410. Ext.getCmp('wp_emp').setValue(res.workplan.wp_emp);
  411. Ext.getCmp('wp_empid').setValue(res.workplan.wp_empid);
  412. Ext.getCmp('wp_summary').setValue(res.workplan.wp_summary.replace(/\%n/g,"\n"));
  413. Ext.getCmp('wp_status').setValue(res.workplan.wp_status);
  414. Ext.getCmp('wp_statuscode').setValue(res.workplan.wp_statuscode);
  415. Ext.getCmp('wp_sumattachs').setValue(res.workplan.wp_sumattachs);
  416. Ext.getCmp('wp_planattachs').setValue(res.workplan.wp_planattachs);
  417. if(res.workplan.wp_committime){
  418. Ext.getCmp('wp_committime').setValue(Ext.util.Format.date(new Date(res.workplan.wp_committime),"Y-m-d H:i:s"));
  419. }
  420. if(res.workplan.wp_updatetime){
  421. Ext.getCmp('wp_updatetime').setValue(Ext.util.Format.date(new Date(res.workplan.wp_updatetime),"Y-m-d H:i:s"));
  422. }
  423. Ext.getCmp('wp_time').setValue(res.workplan.wp_time);
  424. Ext.getCmp('wp_title').setValue(res.workplan.wp_title);
  425. var values = '';
  426. for(var i=0; i<res.workplandetaillist.length; i++){
  427. if(i==res.workplandetaillist.length-1){
  428. values += res.workplandetaillist[i].wpd_plan + '##===##' + res.workplandetaillist[i].wpd_taskid;
  429. } else {
  430. values += res.workplandetaillist[i].wpd_plan + '##===##' + res.workplandetaillist[i].wpd_taskid + '==###==';
  431. }
  432. }
  433. Ext.getCmp('nextplan').setValue(values);
  434. } else{
  435. saveFailure();//@i18n/i18n.js
  436. }
  437. }
  438. });
  439. }
  440. },
  441. getLast: function(lastworkplan){
  442. if(lastworkplan!=null && lastworkplan!=''){
  443. var id = lastworkplan.split('IS')[1];
  444. Ext.Ajax.request({
  445. url : basePath + 'oa/persontask/workPlan/getWorkPlanDetail.action',
  446. params : {
  447. id: id
  448. },
  449. method : 'post',
  450. async: false,
  451. callback : function(options,success,response){
  452. // me.getActiveTab().setLoading(false);
  453. var res = new Ext.decode(response.responseText);
  454. if(res.success){
  455. var values = '';
  456. for(var i=0; i<res.workplandetaillist.length; i++){
  457. if(i==res.workplandetaillist.length-1){
  458. values += res.workplandetaillist[i].wpd_plan;
  459. } else {
  460. values += res.workplandetaillist[i].wpd_plan + '==###==';
  461. }
  462. }
  463. Ext.getCmp('lastplan').setValue(values);
  464. } else{
  465. saveFailure();//@i18n/i18n.js
  466. }
  467. }
  468. });
  469. }
  470. }
  471. });