Toolbar1.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. Ext.define('erp.view.hr.attendance.Toolbar1', {
  2. extend: 'Ext.toolbar.Toolbar',
  3. alias: 'widget.erpEmpWorkDateModel',
  4. items: [{
  5. xtype:'textfield',
  6. hideTrigger:false,
  7. labelAlign:'right',
  8. fieldLabel:'排班模板id',
  9. id: 'em_wdid',
  10. name: 'em_wdid',
  11. hidden:true
  12. },{
  13. xtype: 'dbfindtrigger',
  14. fieldLabel:'排班模板编码',
  15. labelAlign:'right',
  16. id: 'em_code',
  17. name: 'em_code',
  18. },{
  19. xtype: 'textfield',
  20. fieldLabel:'排班模板名称',
  21. labelAlign:'right',
  22. id: 'em_name',
  23. name: 'em_name',
  24. readOnly: true
  25. }, {
  26. xtype:'button',
  27. text : '保存设置',
  28. width: 80,
  29. style: {
  30. width: 80
  31. },
  32. id : 'submit',
  33. iconCls : 'x-button-icon-submit',
  34. handler : function(){
  35. var wdid = Ext.getCmp("em_wdid").rawValue;
  36. var records = Ext.getCmp('tree-panel').getChecked();
  37. if (wdid == null || wdid == "") {
  38. Ext.MessageBox.alert("提示", "请选择班次!");
  39. return;
  40. }
  41. if (records.length == 0) {
  42. Ext.MessageBox.alert("提示", "请选择需要设置班次的员工!");
  43. return;
  44. }
  45. var ids = "";
  46. var selectIds = new Array();
  47. Ext.each(records, function(item, index) {
  48. selectIds.push(item.getPath('id'));
  49. ids = ids + item.get("id");
  50. if (index < records.length - 1) {
  51. ids = ids + ",";
  52. }
  53. });
  54. Ext.Ajax.request({
  55. url : basePath + 'hr/attendance/setEmpWorkDateModel.action',
  56. params : {
  57. wdid: wdid,
  58. condition: "em_id in (" + ids + ")"
  59. },
  60. method : 'post',
  61. callback : function(options,success,response){
  62. var ret = new Ext.decode(response.responseText);
  63. if (ret.success) {
  64. Ext.Msg.alert("提示", "设置成功!");
  65. var store = Ext.getCmp('tree-panel').getExpandItem();
  66. var ids = new Array();
  67. Ext.each(store,function(item,index){
  68. ids.push(item.getPath('id'));
  69. });
  70. Ext.getCmp('tree-panel').getTreeRootNode(0);
  71. setTimeout(function(){
  72. Ext.each(ids,function(id,index){
  73. Ext.getCmp('tree-panel').expandPath(id,'id');
  74. });
  75. },300);
  76. // setTimeout(function(){
  77. // Ext.each(records,function(item,index){
  78. //// Ext.getCmp('tree-panel').selectPath(id,'id');
  79. // Ext.getCmp('tree-panel').getSelectionModel().select(item);
  80. // });
  81. // },500);
  82. } else {
  83. Ext.Msg.alert('提示','操作失败!');
  84. }
  85. }
  86. });
  87. }
  88. },'-',{
  89. xtype:'button',
  90. text : '取消设置',
  91. width: 80,
  92. style: {
  93. width: 80
  94. },
  95. id : 'cancel',
  96. iconCls : 'x-button-icon-close',
  97. handler : function(){
  98. var wdid = Ext.getCmp("em_wdid").rawValue;
  99. var records = Ext.getCmp('tree-panel').getChecked();
  100. if (records.length == 0) {
  101. Ext.MessageBox.alert("提示", "请选择需要取消班次的员工!");
  102. return;
  103. }
  104. var ids = "";
  105. var selectIds = new Array();
  106. Ext.each(records, function(item, index) {
  107. selectIds.push(item.getPath('id'));
  108. ids = ids + item.get("id");
  109. if (index < records.length - 1) {
  110. ids = ids + ",";
  111. }
  112. });
  113. Ext.Ajax.request({
  114. url : basePath + 'hr/attendance/cancelEmpWorkDateModel.action',
  115. params : {
  116. wdid: wdid,
  117. condition: "em_id in (" + ids + ")"
  118. },
  119. method : 'post',
  120. callback : function(options,success,response){
  121. var ret = new Ext.decode(response.responseText);
  122. if (ret.success) {
  123. Ext.Msg.alert("提示", "取消成功!");
  124. var store = Ext.getCmp('tree-panel').getExpandItem();
  125. var ids = new Array();
  126. Ext.each(store,function(item,index){
  127. ids.push(item.getPath('id'));
  128. });
  129. Ext.getCmp('tree-panel').getTreeRootNode(0);
  130. setTimeout(function(){
  131. Ext.each(ids,function(id,index){
  132. Ext.getCmp('tree-panel').expandPath(id,'id');
  133. });
  134. },300);
  135. } else {
  136. Ext.Msg.alert('提示','取消失败!');
  137. }
  138. }
  139. });
  140. }
  141. },'-' ,{
  142. xtype: 'datefield',
  143. fieldLabel:'开始日期',
  144. labelAlign:'right',
  145. id: 'eml_startdate',
  146. name: 'eml_startdate',
  147. } ,{
  148. xtype: 'datefield',
  149. fieldLabel:'结束日期',
  150. labelAlign:'right',
  151. id: 'eml_enddate',
  152. name: 'eml_enddate'
  153. }, {
  154. xtype:'button',
  155. text : '更新员工班次',
  156. width: 80,
  157. style: {
  158. width: 80
  159. },
  160. id : 'update',
  161. iconCls : 'x-button-icon-save',
  162. handler : function(){
  163. var records = Ext.getCmp('tree-panel').getChecked();
  164. var startdate = Ext.getCmp('eml_startdate').value;
  165. var enddate = Ext.getCmp('eml_enddate').value;
  166. if (startdate == null || startdate == "") {
  167. Ext.MessageBox.alert("提示", "请选择开始时间!");
  168. return;
  169. }
  170. if (enddate == null || enddate == "") {
  171. Ext.MessageBox.alert("提示", "请选择结束时间!");
  172. return;
  173. }
  174. if (records.length == 0) {
  175. Ext.MessageBox.alert("提示", "请选择需要设置班次的员工!");
  176. return;
  177. }
  178. var ids = new Array();
  179. Ext.each(records, function(item, index) {
  180. ids.push(item.get("id"));
  181. });
  182. console.log(ids);
  183. Ext.Ajax.request({
  184. url : basePath + 'hr/attendance/updateEmpWorkDateList.action',
  185. params : {
  186. startdate:startdate,
  187. enddate:enddate,
  188. ids:ids
  189. },
  190. method : 'post',
  191. callback : function(options,success,response){
  192. var ret = new Ext.decode(response.responseText);
  193. if (ret.success) {
  194. Ext.Msg.alert("提示", "更新成功!");
  195. } else {
  196. Ext.Msg.alert('提示',ret.error);
  197. }
  198. }
  199. });
  200. }
  201. }]
  202. });