HandCard.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.hr.attendance.HandCard', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. views:[
  8. 'hr.attendance.HandCard','core.form.Panel','core.form.FileField','core.form.MultiField','core.grid.Panel2',
  9. 'core.button.Save','core.button.Add',
  10. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.ResSubmit',
  11. 'core.button.Flow','core.button.DownLoad','core.button.Scan','common.datalist.Toolbar',
  12. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.trigger.AutoCodeTrigger','core.button.Confirm',
  13. 'core.button.InsertEmployee','hr.attendance.EmpTree2'
  14. ],
  15. init:function(){
  16. var me = this;
  17. this.control({
  18. 'erpGridPanel2': {
  19. itemclick:function(selModel, record){
  20. me.onGridItemClick(selModel, record);
  21. }
  22. },
  23. 'erpSaveButton': {
  24. click: function(btn){
  25. var form = me.getForm(btn);
  26. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  27. me.BaseUtil.getRandomNumber();//自动添加编号
  28. }
  29. this.FormUtil.beforeSave(this);
  30. }
  31. },
  32. 'erpInsertEmployeeButton' : {
  33. click: function(btn){
  34. me.insertEmployee();
  35. }
  36. },
  37. 'erpDeleteButton' : {
  38. afterrender: function(btn){
  39. var status = Ext.getCmp('hc_statuscode');
  40. if(status && status.value != 'ENTERING'){
  41. btn.hide();
  42. }
  43. },
  44. click: function(btn){
  45. me.FormUtil.onDelete(Ext.getCmp('hc_id').value);
  46. }
  47. },
  48. 'erpUpdateButton': {
  49. afterrender: function(btn){
  50. var status = Ext.getCmp('hc_statuscode');
  51. if(status && status.value != 'ENTERING'){
  52. btn.hide();
  53. }
  54. },
  55. click: function(btn){
  56. this.FormUtil.onUpdate(this);
  57. }
  58. },
  59. 'erpAddButton': {
  60. click: function(){
  61. me.FormUtil.onAdd('addHandCard', '新增手工打卡单', 'jsps/hr/attendance/handcard.jsp');
  62. }
  63. },
  64. 'erpCloseButton': {
  65. click: function(btn){
  66. me.FormUtil.beforeClose(me);
  67. }
  68. },
  69. 'erpAuditButton': {
  70. afterrender: function(btn){
  71. var status = Ext.getCmp('hc_statuscode');
  72. if(status && status.value != 'ENTERING'){
  73. btn.hide();
  74. }
  75. },
  76. click: function(btn){
  77. // me.FormUtil.onAuditWithManAndTime(Ext.getCmp('hc_id').value,'wo_auditer','wo_auditdate');
  78. me.FormUtil.onAudit(Ext.getCmp('hc_id').value);
  79. }
  80. }
  81. });
  82. },
  83. insertEmployee: function (btn){
  84. var deptcode = Ext.getCmp('hc_deptcode').value;
  85. var hcid = Ext.getCmp('hc_id').value;
  86. if(deptcode != null && deptcode != '' && deptcode.length > 0 && hcid != null && hcid > 0){
  87. Ext.Ajax.request({
  88. url : basePath + '/hr/attendance/insertEmployee.action',
  89. params: {
  90. deptcode:deptcode,
  91. hcid:hcid
  92. },
  93. method : 'post',
  94. async:false,
  95. callback : function(options,success,response){
  96. var res = new Ext.decode(response.responseText);
  97. if(res.exceptionInfo != null){
  98. showError(res.exceptionInfo);return;
  99. }
  100. //showMessage("提示", '生成任务成功!');
  101. window.location.reload();
  102. }
  103. });
  104. }
  105. /* Ext.Ajax.request({
  106. url : basePath + '/crm/marketmgr/turnTask.action',
  107. params: {id:id},
  108. method : 'post',
  109. async:false,
  110. callback : function(options,success,response){
  111. var res = new Ext.decode(response.responseText);
  112. if(res.exceptionInfo != null){
  113. showError(res.exceptionInfo);return;
  114. }
  115. //showMessage("提示", '生成任务成功!');
  116. //window.location.reload();
  117. }
  118. });*/
  119. },
  120. openInsertWin: function(btn){
  121. var me = this;
  122. var filter = null;
  123. if(caller == 'Workovertime'){
  124. //加班
  125. filter = Ext.create('Ext.Window', {
  126. id: btn.getId() + '-filter',
  127. style: 'background:#f1f1f1',
  128. title: '插入员工',
  129. width: 800,
  130. modal:true,
  131. height: 500,
  132. layout: 'column',
  133. defaults: {
  134. margin: '5 5 5 5'
  135. },
  136. items: [
  137. {
  138. xtype:'form',
  139. columnWidth: 1,
  140. id:'win-form',
  141. layout: 'column',
  142. defaults: {
  143. margin: '5 5 5 5'
  144. },
  145. items:[
  146. { xtype:'datefield', name:'startdate', id:'startdate', columnWidth: .33, fieldLabel: '起始时间', labelWidth: 70 },
  147. { xtype:'datefield', name:'enddate', id:'enddate', columnWidth: .33, fieldLabel: '结束时间', labelWidth: 70 }, //起始 结束时间
  148. { xtype:'combo', name:'type', id:'type', columnWidth: .33, fieldLabel: '请假类型', labelWidth: 70, displayField:'dftext',valueField:'vftext',queryMode:'local',store:{fields:['dftext','vftext'],data:[{'dftext':'普通加班','vftext':'普通加班'},{'dftext':'双休日加班','vftext':'双休日加班'},{'dftext':'节假日加班','vftext':'节假日加班'}]} },
  149. { xtype : 'timefield', labelWidth: 70, name : 'jias1', id : 'jias1', fieldLabel : '加上1', columnWidth: .5, format: 'H:i', increment: 30 },
  150. { xtype : 'timefield', name : 'jiax1', labelWidth: 70, id : 'jiax1', fieldLabel : '加下1', columnWidth: .5, format: 'H:i', increment: 30 }, //加上1,加下1
  151. { xtype : 'timefield', name : 'jias2', labelWidth: 70, id : 'jias2', fieldLabel : '加上2', columnWidth: .5, format: 'H:i', increment: 30 },
  152. { xtype : 'timefield', name : 'jiax2', labelWidth: 70, id : 'jiax2', fieldLabel : '加下2', columnWidth: .5, format: 'H:i', increment: 30 }, //加上2,加下2
  153. { xtype : 'timefield', name : 'jias3', labelWidth: 70, id : 'jias3', fieldLabel : '加上3', columnWidth: .5, format: 'H:i', increment: 30 },
  154. { xtype : 'timefield', name : 'jiax3', labelWidth: 70, id : 'jiax3', fieldLabel : '加下3', columnWidth: .5, format: 'H:i', increment: 30 }, //加上3,加下3
  155. { xtype : 'timefield', name : 'jias4', labelWidth: 70, id : 'jias4', fieldLabel : '加上4', columnWidth: .5, format: 'H:i', increment: 30 },
  156. { xtype : 'timefield', name : 'jiax4', labelWidth: 70, id : 'jiax4', fieldLabel : '加下4', columnWidth: .5, format: 'H:i', increment: 30 } //加上4,加下4
  157. ]
  158. },
  159. {
  160. xtype: 'EmpTree2',
  161. columnWidth: .5,
  162. margin: '5 5 5 5',
  163. height:250,
  164. listeners:{
  165. checkchange: function(node,checked){
  166. if(node.data.leaf){
  167. var dialog = this.ownerCt;
  168. var grid = dialog.items.items[2];
  169. if(checked){
  170. me.loadNodeToGrid(node,grid);
  171. }else{
  172. me.removeNodeFromGrid(node,grid);
  173. }
  174. }
  175. }
  176. }
  177. },{
  178. columnWidth: .5,
  179. xtype:'grid',
  180. id:'select_grid',
  181. margin: '5 5 5 5',
  182. height:250,
  183. columns:[
  184. {header:'员工编号',dataIndex:'em_code'},
  185. {header:'员工姓名',dataIndex:'em_name'},
  186. {header:'员工id',dataIndex:'em_id'}
  187. ]
  188. } /* */ //组织树, 选中列表
  189. ],
  190. buttonAlign: 'center',
  191. buttons: [{
  192. text: '确定',
  193. width: 60,
  194. cls: 'x-btn-blue',
  195. handler: function(btn) {
  196. var fl = btn.ownerCt.ownerCt;
  197. var form = fl.items.items[0];
  198. var grid = fl.items.items[2];
  199. var formValues = form.getValues();
  200. var gridValues = grid.getStore().getNewRecords();
  201. me.createBaseGridData(formValues,gridValues);
  202. fl.items.items[2].store.removeAll();
  203. fl.destroy();
  204. }
  205. },{
  206. text: '关闭',
  207. width: 60,
  208. cls: 'x-btn-blue',
  209. handler: function(btn) {
  210. var fl = btn.ownerCt.ownerCt;
  211. fl.items.items[2].store.removeAll();
  212. fl.destroy();
  213. }
  214. }]
  215. });
  216. }else if (caller == 'Workovertime!Straight'){
  217. //直落
  218. filter = Ext.create('Ext.Window', {
  219. id: btn.getId() + '-filter',
  220. style: 'background:#f1f1f1',
  221. title: '插入员工',
  222. width: 800,
  223. modal:true,
  224. height: 500,
  225. layout: 'column',
  226. defaults: {
  227. margin: '5 5 5 5'
  228. },
  229. items: [
  230. {
  231. xtype:'form',
  232. columnWidth: 1,
  233. id:'win-form',
  234. layout: 'column',
  235. defaults: {
  236. margin: '5 5 5 5'
  237. },
  238. items:[
  239. { xtype:'datefield', name:'startdate', id:'startdate', columnWidth: .5, fieldLabel: '起始时间', labelWidth: 70 },
  240. { xtype:'datefield', name:'enddate', id:'enddate', columnWidth: .5, fieldLabel: '结束时间', labelWidth: 70 }, //起始 结束时间
  241. // { xtype:'combo', name:'type', id:'type', columnWidth: .33, fieldLabel: '请假类型', labelWidth: 70, displayField:'dftext',valueField:'vftext',queryMode:'local',store:{fields:['dftext','vftext'],data:[{'dftext':'普通加班','vftext':'普通加班'},{'dftext':'双休日加班','vftext':'双休日加班'},{'dftext':'节假日加班','vftext':'节假日加班'}]} },
  242. { xtype : 'timefield', name : 'jias1', labelWidth: 70, id : 'jias1', fieldLabel : '直落开始1', columnWidth: .5, format: 'H:i', increment: 30 },
  243. { xtype : 'timefield', name : 'jiax1', labelWidth: 70, id : 'jiax1', fieldLabel : '直落结束1', columnWidth: .5, format: 'H:i', increment: 30 }, //加上1,加下1
  244. { xtype : 'timefield', name : 'jias2', labelWidth: 70, id : 'jias2', fieldLabel : '直落开始2', columnWidth: .5, format: 'H:i', increment: 30 },
  245. { xtype : 'timefield', name : 'jiax2', labelWidth: 70, id : 'jiax2', fieldLabel : '直落结束2', columnWidth: .5, format: 'H:i', increment: 30 }, //加上2,加下2
  246. { xtype : 'timefield', name : 'jias3', labelWidth: 70, id : 'jias3', fieldLabel : '直落开始3', columnWidth: .5, format: 'H:i', increment: 30 },
  247. { xtype : 'timefield', name : 'jiax3', labelWidth: 70, id : 'jiax3', fieldLabel : '加下结束3', columnWidth: .5, format: 'H:i', increment: 30 }, //加上3,加下3
  248. { xtype : 'timefield', name : 'jias4', labelWidth: 70, id : 'jias4', fieldLabel : '直落开始4', columnWidth: .5, format: 'H:i', increment: 30 },
  249. { xtype : 'timefield', name : 'jiax4', labelWidth: 70, id : 'jiax4', fieldLabel : '加下结束4', columnWidth: .5, format: 'H:i', increment: 30 } //加上4,加下4
  250. ]
  251. },
  252. {
  253. xtype: 'EmpTree2',
  254. columnWidth: .5,
  255. margin: '5 5 5 5',
  256. height:250,
  257. listeners:{
  258. checkchange: function(node,checked){
  259. if(node.data.leaf){
  260. var dialog = this.ownerCt;
  261. var grid = dialog.items.items[2];
  262. if(checked){
  263. me.loadNodeToGrid(node,grid);
  264. }else{
  265. me.removeNodeFromGrid(node,grid);
  266. }
  267. }
  268. }
  269. }
  270. },{
  271. columnWidth: .5,
  272. xtype:'grid',
  273. id:'select_grid',
  274. margin: '5 5 5 5',
  275. height:250,
  276. columns:[
  277. {header:'员工编号',dataIndex:'em_code'},
  278. {header:'员工姓名',dataIndex:'em_name'},
  279. {header:'员工id',dataIndex:'em_id'}
  280. ]
  281. } /* */ //组织树, 选中列表
  282. ],
  283. buttonAlign: 'center',
  284. buttons: [{
  285. text: '确定',
  286. width: 60,
  287. cls: 'x-btn-blue',
  288. handler: function(btn) {
  289. var fl = btn.ownerCt.ownerCt;
  290. var form = fl.items.items[0];
  291. var grid = fl.items.items[2];
  292. var formValues = form.getValues();
  293. var gridValues = grid.getStore().getNewRecords();
  294. me.createBaseGridData(formValues,gridValues);
  295. fl.items.items[2].store.removeAll();
  296. fl.destroy();
  297. }
  298. },{
  299. text: '关闭',
  300. width: 60,
  301. cls: 'x-btn-blue',
  302. handler: function(btn) {
  303. var fl = btn.ownerCt.ownerCt;
  304. fl.items.items[2].store.removeAll();
  305. fl.destroy();
  306. }
  307. }]
  308. });
  309. }else if (caller == 'Workovertime!WholeNight'){
  310. //通宵
  311. filter = Ext.create('Ext.Window', {
  312. id: btn.getId() + '-filter',
  313. style: 'background:#f1f1f1',
  314. title: '插入员工',
  315. width: 800,
  316. modal:true,
  317. height: 500,
  318. layout: 'column',
  319. defaults: {
  320. margin: '5 5 5 5'
  321. },
  322. items: [
  323. {
  324. xtype:'form',
  325. columnWidth: 1,
  326. id:'win-form',
  327. layout: 'column',
  328. defaults: {
  329. margin: '5 5 5 5'
  330. },
  331. items:[
  332. { xtype:'datefield', name:'startdate', id:'startdate', columnWidth: .33, fieldLabel: '起始时间', labelWidth: 70 },
  333. { xtype:'datefield', name:'enddate', id:'enddate', columnWidth: .33, fieldLabel: '结束时间', labelWidth: 70 }, //起始 结束时间
  334. // { xtype:'combo', name:'type', id:'type', columnWidth: .33, fieldLabel: '请假类型', labelWidth: 70, displayField:'dftext',valueField:'vftext',queryMode:'local',store:{fields:['dftext','vftext'],data:[{'dftext':'普通加班','vftext':'普通加班'},{'dftext':'双休日加班','vftext':'双休日加班'},{'dftext':'节假日加班','vftext':'节假日加班'}]} },
  335. { xtype : 'timefield', labelWidth: 70, name : 'jias1', id : 'jias1', fieldLabel : '通宵开始1', columnWidth: .5, format: 'H:i', increment: 30 },
  336. { xtype : 'timefield', name : 'jiax1', labelWidth: 70, id : 'jiax1', fieldLabel : '通宵结束1', columnWidth: .5, format: 'H:i', increment: 30 }, //加上1,加下1
  337. { xtype : 'timefield', name : 'jias2', labelWidth: 70, id : 'jias2', fieldLabel : '通宵开始2', columnWidth: .5, format: 'H:i', increment: 30 },
  338. { xtype : 'timefield', name : 'jiax2', labelWidth: 70, id : 'jiax2', fieldLabel : '通宵结束2', columnWidth: .5, format: 'H:i', increment: 30 }, //加上2,加下2
  339. { xtype : 'timefield', name : 'jias3', labelWidth: 70, id : 'jias3', fieldLabel : '通宵开始3', columnWidth: .5, format: 'H:i', increment: 30 },
  340. { xtype : 'timefield', name : 'jiax3', labelWidth: 70, id : 'jiax3', fieldLabel : '通宵结束3', columnWidth: .5, format: 'H:i', increment: 30 }, //加上3,加下3
  341. { xtype : 'timefield', name : 'jias4', labelWidth: 70, id : 'jias4', fieldLabel : '通宵开始4', columnWidth: .5, format: 'H:i', increment: 30 },
  342. { xtype : 'timefield', name : 'jiax4', labelWidth: 70, id : 'jiax4', fieldLabel : '通宵结束4', columnWidth: .5, format: 'H:i', increment: 30 } //加上4,加下4
  343. ]
  344. },
  345. {
  346. xtype: 'EmpTree2',
  347. columnWidth: .5,
  348. margin: '5 5 5 5',
  349. height:250,
  350. listeners:{
  351. checkchange: function(node,checked){
  352. if(node.data.leaf){
  353. var dialog = this.ownerCt;
  354. var grid = dialog.items.items[2];
  355. if(checked){
  356. me.loadNodeToGrid(node,grid);
  357. }else{
  358. me.removeNodeFromGrid(node,grid);
  359. }
  360. }
  361. }
  362. }
  363. },{
  364. columnWidth: .5,
  365. xtype:'grid',
  366. id:'select_grid',
  367. margin: '5 5 5 5',
  368. height:250,
  369. columns:[
  370. {header:'员工编号',dataIndex:'em_code'},
  371. {header:'员工姓名',dataIndex:'em_name'},
  372. {header:'员工id',dataIndex:'em_id'}
  373. ]
  374. } /* */ //组织树, 选中列表
  375. ],
  376. buttonAlign: 'center',
  377. buttons: [{
  378. text: '确定',
  379. width: 60,
  380. cls: 'x-btn-blue',
  381. handler: function(btn) {
  382. var fl = btn.ownerCt.ownerCt;
  383. var form = fl.items.items[0];
  384. var grid = fl.items.items[2];
  385. var formValues = form.getValues();
  386. var gridValues = grid.getStore().getNewRecords();
  387. me.createBaseGridData(formValues,gridValues);
  388. fl.items.items[2].store.removeAll();
  389. fl.destroy();
  390. }
  391. },{
  392. text: '关闭',
  393. width: 60,
  394. cls: 'x-btn-blue',
  395. handler: function(btn) {
  396. var fl = btn.ownerCt.ownerCt;
  397. fl.items.items[2].store.removeAll();
  398. fl.destroy();
  399. }
  400. }]
  401. });
  402. }
  403. return filter;
  404. },
  405. createBaseGridData: function(win_form_values, win_grid_store ){
  406. var me = this;
  407. // var array = new Array();
  408. var base_grid = Ext.getCmp('grid');
  409. var last_detno = 0;
  410. var last_index = -1;
  411. var old_store = base_grid.getStore().getNewRecords();
  412. var old_array = new Array();
  413. Ext.each(old_store,function(item,index){
  414. if(item.data[base_grid.necessaryField] &&item.data[base_grid.necessaryField] != null &&Ext.String.trim( item.data[base_grid.necessaryField])!=''){
  415. if(item.data['wod_detno'] > last_detno ){
  416. last_detno = item.data['wod_detno'];
  417. }
  418. last_index ++;
  419. old_array.push(item);
  420. }
  421. });
  422. Ext.each(win_grid_store,function(item,index){
  423. var record = base_grid.getStore().getAt(last_index+1);
  424. if(record||record == null ){
  425. me.GridUtil.add10EmptyItems(base_grid,1);
  426. record = base_grid.getStore().getAt(last_index+1);
  427. }
  428. if(win_form_values.hasOwnProperty('startdate')){record.set('wod_startdate',win_form_values.startdate);}
  429. if(win_form_values.hasOwnProperty('enddate')){record.set('wod_enddate',win_form_values.enddate);}
  430. if(win_form_values.hasOwnProperty('type')){record.set('wod_type',win_form_values.type);}
  431. if(win_form_values.hasOwnProperty('jias1')){record.set('wod_jias1',win_form_values.jias1);}
  432. if(win_form_values.hasOwnProperty('jiax1')){record.set('wod_jiax1',win_form_values.jiax1);}
  433. if(win_form_values.hasOwnProperty('jias2')){record.set('wod_jias2',win_form_values.jias2);}
  434. if(win_form_values.hasOwnProperty('jiax2')){record.set('wod_jiax2',win_form_values.jiax2);}
  435. if(win_form_values.hasOwnProperty('jias3')){record.set('wod_jias3',win_form_values.jias3);}
  436. if(win_form_values.hasOwnProperty('jiax3')){record.set('wod_jiax3',win_form_values.jiax3);}
  437. if(win_form_values.hasOwnProperty('jias4')){record.set('wod_jias4',win_form_values.jias4);}
  438. if(win_form_values.hasOwnProperty('jiax4')){record.set('wod_jiax4',win_form_values.jiax4);}
  439. record.set('wod_detno',last_detno+1);
  440. record.set('wod_empcode',item.data.em_code);
  441. record.set('wod_empname',item.data.em_name);
  442. last_detno++;
  443. last_index++;
  444. });
  445. },
  446. /**
  447. * 从grid 中删除树节点
  448. * @param node
  449. * @param grid
  450. */
  451. removeNodeFromGrid : function(node,grid){
  452. var em_id = node.raw.id;
  453. Ext.each(grid.store.data.items,function(item,index){
  454. if(item.data.em_id==em_id){
  455. grid.store.remove([item]);
  456. }
  457. });
  458. },
  459. /**
  460. * 向grid 中插入选中树节点
  461. * @param node
  462. * @param grid
  463. */
  464. loadNodeToGrid : function(node,grid){
  465. var o = new Object();
  466. o['em_id'] = node.raw.id;
  467. o['em_code'] = node.raw.code;
  468. o['em_name'] = node.raw.qtip;
  469. grid.store.loadData([o],true);
  470. },
  471. onGridItemClick: function(selModel, record){//grid行选择
  472. this.GridUtil.onGridItemClick(selModel, record);
  473. },
  474. getForm: function(btn){
  475. return btn.ownerCt.ownerCt;
  476. },
  477. getGriddata: function(grid){
  478. if(grid == null){
  479. grid = Ext.getCmp('grid');
  480. }
  481. var jsonGridData = new Array();
  482. var s = grid.getStore().data.items;//获取store里面的数据
  483. for(var i=0;i<s.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
  484. var data = s[i].data;
  485. jsonGridData.push(Ext.JSON.encode(data));
  486. }
  487. return jsonGridData;
  488. },
  489. check:function(){
  490. if(Ext.getCmp('wo_startdate').value>Ext.getCmp('wo_enddate').value){
  491. showError('结束时间不能小于开始时间!');return true;
  492. }
  493. var grid = Ext.getCmp('grid');
  494. var items = grid.store.data.items;
  495. var flag=false;
  496. Ext.each(items,function(item){
  497. if(item.dirty && item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ""){
  498. if(item.data['ppd_costid']==null||item.data['ppd_costid']==0){
  499. showError('第'+item.data['ppd_detno']+'行的费用类型没选或无效!');flag=true;
  500. }
  501. if(item.data['ppd_standardamount']<item.data['ppd_amount']){
  502. showError('第'+item.data['ppd_detno']+'行的预算费用超出标准金额!');flag=true;
  503. }
  504. }
  505. });
  506. return flag;
  507. },
  508. turnTask:function(id){
  509. Ext.Ajax.request({
  510. url : basePath + '/crm/marketmgr/turnTask.action',
  511. params: {id:id},
  512. method : 'post',
  513. async:false,
  514. callback : function(options,success,response){
  515. var res = new Ext.decode(response.responseText);
  516. if(res.exceptionInfo != null){
  517. showError(res.exceptionInfo);return;
  518. }
  519. //showMessage("提示", '生成任务成功!');
  520. //window.location.reload();
  521. }
  522. });
  523. },
  524. onConfirm: function(id){
  525. var form = Ext.getCmp('form');
  526. Ext.Ajax.request({
  527. url : basePath + form.confirmUrl,
  528. params: {
  529. id: id,
  530. caller:caller
  531. },
  532. method : 'post',
  533. callback : function(options,success,response){
  534. //me.setLoading(false);
  535. var localJson = new Ext.decode(response.responseText);
  536. if(localJson.success){
  537. //audit成功后刷新页面进入可编辑的页面
  538. //auditSuccess(function(){
  539. window.location.reload();
  540. //});
  541. } else {
  542. if(localJson.exceptionInfo){
  543. var str = localJson.exceptionInfo;
  544. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  545. str = str.replace('AFTERSUCCESS', '');
  546. showMessage("提示", '确认成功');
  547. //auditSuccess(function(){
  548. window.location.reload();
  549. //});
  550. } else {
  551. showError(str);return;
  552. }
  553. }
  554. }
  555. }
  556. });
  557. }
  558. });