Workovertime.js 26 KB

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