AtsTurnShiftWizard.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. /*******************************************************************************
  2. *
  3. * 考勤管理-编排管理js
  4. *
  5. * <pre>
  6. *
  7. * 作者:hugh zhuang
  8. * 邮箱:zhuangxh@jee-soft.cn
  9. * 日期:2015-05-29-上午11:10:52
  10. * 版权:广州宏天软件有限公司版权所有
  11. * </pre>
  12. *
  13. ******************************************************************************/
  14. var AtsTurnShiftWizardPlugin = null;
  15. ;
  16. (function($, window, document, undefined) {
  17. var pluginName = "AtsTurnShiftWizard", defaults = {}, me, _shiftType = null, // 排班类型
  18. _startTime = null, // 开始时间
  19. _endTime = null, // 结束时间
  20. _listRowDatas = [],
  21. _attencePolicy = null,
  22. AtsConstant = { // 用户的常量
  23. SHIFT_TYPE_CALENDAR : 1,
  24. SHIFT_TYPE_LIST : 2
  25. };
  26. function Plugin(element, options) {
  27. this.settings = $.extend({}, defaults, options);
  28. this._defaults = defaults;
  29. this._name = pluginName;
  30. this.init();
  31. }
  32. Plugin.prototype = {
  33. /**
  34. * 初始化页面
  35. */
  36. init : function() {
  37. me = this;
  38. AtsTurnShiftWizardPlugin = this;
  39. me.initWizard();
  40. me.initUserGrid();
  41. me.initScheduleShiftGrid();
  42. me.initOperation();
  43. },
  44. /**
  45. * 初始化向导
  46. */
  47. initWizard : function() {
  48. $('#fuelux-wizard')
  49. .ht_wizard()
  50. .on('change', function(e, data) {
  51. var step = data.step, direction = data.direction;
  52. // 第1步的下一步操作
  53. if (step == 1 && direction == 'next')
  54. return me.change1next();
  55. // 第2步的下一步操作
  56. else if (step == 2 && direction == 'next')
  57. return me.change2next();
  58. else if (step == 3 && direction == 'next')
  59. return me.change3next();
  60. // 第4步的上一步 操作
  61. else if (step == 4 && direction == 'previous')
  62. me.clickQueryUser();
  63. // 第四步下一步 检查是否排班
  64. else if (step == 4 && direction == 'next')
  65. return me.change4next();
  66. })
  67. .on('changed',function(e, data) {
  68. if (data.currentStep == 4
  69. && _shiftType == AtsConstant.SHIFT_TYPE_CALENDAR) {
  70. $('#calendar_info').fullCalendar('render');
  71. $('#calendar_info').fullCalendar('gotoDate', _startTime);
  72. }
  73. })
  74. .on('finished',function(e) {// 完成事件
  75. $.ligerDialog.confirm("排班完成,是否继续操作","提示信息",function(rtn) {
  76. if (rtn) {
  77. window.location.href = __ctx
  78. + "/platform/ats/atsTurnShift/wizard.ht";
  79. } else {
  80. window.location.href = __ctx
  81. + "/platform/ats/atsScheduleShift/list.ht";
  82. }
  83. });
  84. })
  85. .on('stepclick', function(e, data) {
  86. // e.preventDefault();//this will prevent clicking and
  87. // selecting steps
  88. // return false;
  89. });
  90. },
  91. /**
  92. * 第1步的下一步 操作
  93. */
  94. change1next : function() {
  95. if (!$.isEmpty(_shiftType))// 变换
  96. _listRowDatas = [];
  97. _shiftType = $("input[name='shiftType']:checked").val();
  98. if ($.isEmpty(_shiftType)) {
  99. $.ligerDialog.alert("请选择排班方式!", "提示信息");
  100. return false;
  101. }
  102. },
  103. /**
  104. * 第2步的下一步 操作
  105. */
  106. change2next : function() {
  107. var date1 = $('#startTime').val(),date2=$('#endTime').val();
  108. //时间变化了,_listRowDatas也需要设置为空
  109. if (!$.isEmpty(_startTime) && !$.isEmpty(_endTime)) {
  110. if(date1 != _startTime || date2 !=_endTime)
  111. _listRowDatas = [];
  112. }
  113. _startTime = date1;
  114. _endTime = date2;
  115. if ($.isEmpty(_startTime) || $.isEmpty(_endTime)) {
  116. $.ligerDialog.alert("请设置排班时间!", "提示信息");
  117. return false;
  118. }
  119. // 时间范围不超过一个月
  120. var startTime1 = me.formatDate(_startTime),
  121. endTime1 = me.formatDate(_endTime),
  122. startTime2 = me.formatDate(_startTime);
  123. startTime2.setMonth(startTime2.getMonth() + 1);
  124. var leftsecond = endTime1.getTime() - startTime1.getTime(), rightsecond = startTime2
  125. .getTime()
  126. - startTime1.getTime();
  127. if (leftsecond > rightsecond) {
  128. $.ligerDialog.alert("开始日期和结束日期之间的时间间隔不能超过一个月!", "提示信息");
  129. return false;
  130. }
  131. me.clickQueryUser();
  132. },
  133. /**
  134. * 第3步的下一步 操作
  135. */
  136. change3next : function() {
  137. _attencePolicy = $('#attencePolicy').val();
  138. if (_attencePolicy == "") {
  139. $.ligerDialog.alert("请选择考勤制度进行查询!", "提示信息");
  140. return false;
  141. }
  142. var userlists = $('#userlist').find(".text-tag");
  143. if (userlists.length == 0) {
  144. $.ligerDialog.alert("请选择人员!", "提示信息");
  145. return false;
  146. }
  147. if (_shiftType == AtsConstant.SHIFT_TYPE_CALENDAR) {
  148. $('#scheduleCalendar').show();
  149. $('#scheduleList').hide();
  150. if (_listRowDatas.length > 0){
  151. me.initCalendar();
  152. }else{
  153. $.ajax({
  154. type : "POST",
  155. url : __ctx + "/platform/ats/atsTurnShift/calendarShiftHandler.ht",
  156. dataType: 'json',
  157. data : {
  158. startTime : _startTime,
  159. endTime : _endTime
  160. },
  161. success : function(data) {
  162. if (!data.success) {
  163. alert(data.msg);
  164. return;
  165. }
  166. _listRowDatas = data.results;
  167. me.initCalendar();
  168. }
  169. });
  170. }
  171. } else { //列表方式
  172. $('#scheduleCalendar').hide();
  173. $('#scheduleList').show();
  174. var userAry = me.getUserAry();
  175. $.ajax({
  176. type : "POST",
  177. url : __ctx + "/platform/ats/atsTurnShift/scheduleList.ht",
  178. data : {
  179. startTime : _startTime,
  180. endTime : _endTime
  181. },
  182. success : function(data) {
  183. me.initUserScheduleList(data, userAry);
  184. }
  185. });
  186. }
  187. },
  188. /**
  189. * 第4步的下一步 操作
  190. */
  191. change4next : function() {
  192. var userAry = me.getUserAry();
  193. if (userAry.length == 0) {
  194. $.ligerDialog.alert("请选择人员!", "提示信息");
  195. return false;
  196. }
  197. if (_listRowDatas.length == 0) {
  198. $.ligerDialog.alert("请进行排班!", "提示信息");
  199. return false;
  200. }
  201. $.ligerDialog.waitting("请稍后……");
  202. $.ajax({
  203. type : "POST",
  204. url : __ctx + "/platform/ats/atsTurnShift/finished.ht",
  205. async : true,
  206. data : {
  207. userAry : JSON2.stringify(userAry),
  208. listRowDatas : JSON2.stringify(_listRowDatas),
  209. attencePolicyName : $('#attencePolicyName').val(),
  210. shiftType : _shiftType
  211. },
  212. success : function(data) {
  213. var d = $.parseJSON(data);
  214. $("#scheduleShiftGrid").jqGrid("clearGridData");
  215. $.ligerDialog.closeWaitting();
  216. if (!d.success) {
  217. $.ligerDialog.error(d.results, "提示信息");
  218. return;
  219. }
  220. $("#scheduleShiftGrid").jqGrid('setGridParam', {
  221. data : d.results,
  222. datatype : "local",
  223. page : 1
  224. }).trigger("reloadGrid"); // 重新载入
  225. }
  226. });
  227. },
  228. getListHtml:function(d){
  229. return "<span class='list-gridcell' title='"+d.title+"' dateType='"+d.dateType+"' holidayName='"+d.holidayName+"' >" + d.title
  230. + "</span>";
  231. },
  232. initUserScheduleList : function(data, userAry) {
  233. $.ligerDialog.waitting("请稍后……");
  234. var colModel = data.colModel;
  235. for (var i = 0; i < colModel.length; i++) {
  236. if (i <= 2)
  237. continue;
  238. colModel[i].formatter = function(d, options, rowObject) {
  239. if ($.isEmpty(d))
  240. return "";
  241. return me.getListHtml(d);
  242. };
  243. }
  244. var options = {
  245. url : __ctx
  246. + "/platform/ats/atsTurnShift/listShiftHandler.ht?startTime="
  247. + _startTime + "&endTime=" + _endTime + "&users="
  248. + encodeURIComponent(JSON2.stringify(userAry)),
  249. datatype : "json",
  250. multiselect : true,
  251. rownumbers : false,
  252. colNames : data.colNames,
  253. colModel : colModel,
  254. recordpos : 'left',
  255. gridview : true,
  256. pginput : true,
  257. autoheight : true,
  258. shrinkToFit : data.colModel.length > 10 ? false : true,
  259. height : 'auto',
  260. width : document.body.clientWidth - 30,
  261. viewrecords : false,
  262. cellEdit : false,
  263. sortable : false,
  264. jsonReader : {
  265. root : "results",// json中代表实际模型数据的入口
  266. repeatitems : false
  267. },
  268. gridComplete : function() {
  269. },
  270. onCellSelect : function(rowid, iCol, cellcontent, e) {
  271. if (iCol > 3 && iCol <= data.colModel.length) {
  272. var table = $("#list_info");
  273. var tdObject = $("#" + rowid + ">td")[iCol];
  274. var colName = data.colModel[iCol - 1].name;
  275. me.replaceShift({
  276. start : colName,
  277. callback : function(rtn, date1) {
  278. table.setCell(rowid, iCol, rtn);
  279. $(tdObject).attr('title', rtn.title);
  280. //更新数据
  281. var rowData = (_listRowDatas[parseInt(rowid) - 1])[colName];
  282. rowData.title = rtn.title;
  283. rowData.start = rtn.start;
  284. rowData.dateType = rtn.dateType;
  285. rowData.shiftId = rtn.shiftId;
  286. rowData.holidayName = rtn.holidayName;
  287. me.colorFormatter();
  288. }
  289. });
  290. }
  291. },
  292. loadComplete : function(data) {
  293. $.ligerDialog.closeWaitting();
  294. _listRowDatas = data.results;
  295. me.colorFormatter();
  296. }
  297. };
  298. $('#scheduleList').empty();
  299. $('#scheduleList').append("<table id='list_info' > </table>");
  300. $('#list_info').html();
  301. $('#list_info').jqGrid(options);
  302. // $('#list_info').jqGrid('setFrozenColumns');
  303. var height = (userAry.length + 1) * 33.3, h = document.body.clientHeight - 265;
  304. if (height > h) {
  305. height = h;
  306. }
  307. height += 'px'
  308. $('#scheduleList .ui-jqgrid-bdiv').css('height', height).css(
  309. 'width', '100%').css('overflow-y', 'scroll', 'overflow-x',
  310. 'scroll');
  311. $('#scheduleList .ui-jqgrid .ui-jqgrid-htable th div').css(
  312. 'height', '35px');
  313. $('#scheduleList .frozen-bdiv').css('top', '36px').css('height',
  314. '35px');
  315. $('#scheduleList .frozen-div').css('height', '36px');
  316. },
  317. /**
  318. * 初始化选择人员的列表
  319. */
  320. initUserGrid : function() {
  321. $("#userGrid").jqGrid({
  322. datatype : "json", // 数据来源,本地数据
  323. mtype : "POST",// 提交方式
  324. height : document.body.clientHeight - 265,// 高度,表格高度。可为数值、百分比或'auto'
  325. width : document.body.clientWidth - 30,
  326. colNames : [ 'ID', '考勤编号', '工号', '姓名', '组织', '岗位' ],
  327. colModel : [ {
  328. name : 'id',
  329. hidden : true
  330. }, {
  331. name : 'cardNumber'
  332. }, {
  333. name : 'account',
  334. width : 80
  335. }, {
  336. name : 'fullname'
  337. }, {
  338. name : 'orgName'
  339. }, {
  340. name : 'posName'
  341. } ],
  342. multikey : 'id',
  343. multiselect : true,
  344. rownumbers : true,// 添加左侧行号
  345. viewrecords : true,// 是否在浏览导航栏显示记录总数
  346. rowNum : 100,// 每页显示记录数
  347. rowList : [ 10, 20, 50, 100, 200 ],// 用于改变显示行数的下拉列表框的元素数组。
  348. jsonReader : {
  349. root : "results",// json中代表实际模型数据的入口
  350. total : "total", // json中代表总页数的数据
  351. page : "page", // json中代表当前页码的数据
  352. records : "records",// json中代表数据行总数的数据
  353. repeatitems : false
  354. // 如果设为false,则jqGrid在解析json时,会根据name来搜索对应的数据元素(即可以json中元素可以不按顺序);而所使用的name是来自于colModel中的name设定。
  355. },
  356. prmNames : {
  357. page : "page", // 表示请求页码的参数名称
  358. rows : "pageSize" // 表示请求行数的参数名称
  359. },
  360. shrinkToFit : true,
  361. pager : $('#gridPager'),
  362. afterInsertRow : function(rowid, rowdata) {
  363. me.userGridAfterInsertRow(rowid, rowdata);
  364. },
  365. onSelectAll : function(rowids, status) {
  366. me.userGridSelectAll(rowids, status);
  367. },
  368. onSelectRow : function(rowid, status) {
  369. me.userGridSelectRow(rowid, status);
  370. }
  371. });
  372. // 查询
  373. $("#btn_query").click(function() {
  374. $("#userGrid").jqGrid('setGridParam', {
  375. url : __ctx + "/platform/ats/atsTurnShift/userList.ht",
  376. postData : {
  377. 'Q_attencePolicy_L' : $("#attencePolicy").val(),
  378. 'Q_attenceGroup_L' : $("#attenceGroup").val(),
  379. 'Q_fullname_SL' : $("#userName").val(),
  380. 'orgPath' : $("#orgId").val()
  381. }, // 发送数据
  382. page : 1
  383. }).trigger("reloadGrid"); // 重新载入
  384. });
  385. },
  386. userGridAfterInsertRow : function(rowid, rowdata) {
  387. var id = $('#userGrid').jqGrid("getCell", rowid, "id");
  388. $("#userlist").find(".text-tag").each(function() {
  389. if (this['id'] == id) {
  390. $('#userGrid').jqGrid("setSelection", rowid, true);
  391. return;
  392. }
  393. });
  394. },
  395. userGridSelectAll : function(rowids, status) {
  396. for (var i = 0; i < rowids.length; i++) {
  397. me.userGridSelectRow(rowids[i], status);
  398. }
  399. },
  400. userGridSelectRow : function(rowid, status) {
  401. var id = "", userName = "", orgName = "", cardNumber = "", userlist = $("#userlist"), userGrid = $('#userGrid'), hasName = false;
  402. id = userGrid.jqGrid("getCell", rowid, "id");
  403. if (status) {
  404. account = userGrid.jqGrid("getCell", rowid, "account");
  405. userName = userGrid.jqGrid("getCell", rowid, "fullname");
  406. orgName = userGrid.jqGrid("getCell", rowid, "orgName");
  407. cardNumber = userGrid.jqGrid("getCell", rowid, "cardNumber");
  408. hasName = false;
  409. userlist.find(".text-tag").each(function() {
  410. if (this['id'] == id) {
  411. hasName = true;
  412. return;
  413. }
  414. });
  415. value = '[' + cardNumber + ']' + userName;
  416. if (!hasName) {
  417. userlist.append('<div class="text-tag" id="' + id
  418. + '" account="' + account + '" userName="'
  419. + userName + '" orgName="' + orgName
  420. + '" cardNumber="' + cardNumber + '" >'
  421. + '<span class="text-label" title="' + value + '">'
  422. + value + '</span>'
  423. + '<span class="text-remove" title="删除">x</span>'
  424. + '</div>');
  425. }
  426. } else {
  427. userlist.find(".text-tag").each(function() {
  428. if (this['id'] == id) {
  429. $(this).remove();
  430. return;
  431. }
  432. });
  433. }
  434. },
  435. initOperation : function() {
  436. $("#userlist").delegate('.text-remove', 'click', function() {
  437. $(this).parent().remove();
  438. });
  439. $('.help-block').click(function() {
  440. var v = $(this).attr("var");
  441. $("#" + v).attr("checked", "checked");
  442. });
  443. },
  444. /**
  445. * 点击查询用户
  446. */
  447. clickQueryUser : function() {
  448. $("#btn_query").click();
  449. },
  450. /**
  451. * 清除用户
  452. */
  453. cleanUserInfo : function() {
  454. $("#userlist").empty();
  455. },
  456. getUserAry : function() {
  457. var userAry = [];
  458. $("#userlist").find(".text-tag").each(
  459. function() {
  460. var me = $(this), id = me.attr("id"), account = me
  461. .attr("account"), userName = me
  462. .attr("userName"), orgName = me
  463. .attr("orgName"), cardNumber = me
  464. .attr("cardNumber");
  465. var obj = {
  466. id : id,
  467. account : account,
  468. userName : userName,
  469. orgName : orgName,
  470. cardNumber : cardNumber
  471. };
  472. userAry.push(obj);
  473. });
  474. return userAry;
  475. },
  476. /**
  477. * 初始化日历
  478. */
  479. initCalendar : function() {
  480. var startTime1 = me.formatDate(_startTime),
  481. endTime1 = me.formatDate(_endTime);
  482. $('#calendarScheduleInfo').empty();
  483. $("#calendarScheduleInfo").append("<div id='calendar_info' > </div>");
  484. $('#calendar_info').fullCalendar({
  485. header : {
  486. left : 'title',
  487. right : 'prev,next'
  488. },
  489. year: startTime1.getFullYear(),month: startTime1.getMonth(),
  490. height : 600,
  491. editable : true,
  492. aspectRatio : 1.35,
  493. disableDragging: true,
  494. eventAfterRender: function(event, element, view) {
  495. var title = "",startTime = me.formatDate(event.start.format('YYYY-MM-DD'));
  496. $("#calendar_info td").each(function() {
  497. var tdThis = this;
  498. var dateValue = $(tdThis).attr('data-date');
  499. if (dateValue != null && dateValue != undefined) {
  500. var time = new Date(dateValue.replace(/-/g, "/"));
  501. if (time.getTime() >= startTime1.getTime() && time.getTime() <= endTime1.getTime()) {
  502. $(this).each(function() {
  503. var grand = $(this);
  504. if ($(grand).hasClass("fc-day-number")) {
  505. $(grand).css("opacity", 0.7);
  506. }
  507. });
  508. if (time.getTime() == startTime.getTime()) {
  509. title = me.getColorTitle(tdThis, event, true);
  510. }
  511. }
  512. }
  513. });
  514. var divHtml = '<div style="color:#ffffff;">' + title + '</div>';
  515. element.html(divHtml);
  516. },
  517. eventClick : function(event, e) {
  518. },
  519. dayClick: function(date, allDay, event, view) {
  520. var start = date.format('YYYY-MM-DD'),
  521. date1 = me.formatDate(start);
  522. if (date1.getTime() < startTime1.getTime() || date1.getTime() > endTime1.getTime())
  523. return false;
  524. me.replaceShiftCalendar(event, start,
  525. date1);
  526. },
  527. events: _listRowDatas
  528. });
  529. $('tr[class="fc-week fc-last"]').css('display', 'none');
  530. $('#calendar_info').fullCalendar('gotoDate', _startTime);
  531. },
  532. colorFormatter :function () {
  533. var html = "";
  534. $('#list_info td').each(function() {
  535. html = $(this).html();
  536. if (!$.isEmpty(html)) {
  537. var h = $(html);
  538. if(!h.hasClass("list-gridcell"))
  539. return true;
  540. var event = {
  541. title:h.attr("title"),
  542. dateType:h.attr("dateType"),
  543. holidayName:h.attr("holidayName")
  544. };
  545. me.getColorTitle(this, event, true);
  546. $(this).html(me.getListHtml(event));
  547. }
  548. });
  549. },
  550. getColorTitle :function (_self, event, flag) {
  551. var self = $(_self), title = event.title,dateType =event.dateType;
  552. self.removeClass('gray-color');
  553. self.removeClass('litterGreen-color');
  554. if (dateType == 2) {//休息日
  555. if (flag) {
  556. self.addClass('gray-color');
  557. }
  558. }
  559. else if (dateType == 3) {//节假日
  560. if (flag) {
  561. if (self.hasClass("fc-day-number") && !$.isEmpty(event.holidayName)) {
  562. var td = self.html();
  563. self.html(event.holidayName+"&nbsp;"+td);
  564. }
  565. self.addClass('litterGreen-color');
  566. }
  567. }
  568. return title;
  569. },
  570. addShiftRule : function() {
  571. var selectedIds = [];
  572. if (_shiftType == AtsConstant.SHIFT_TYPE_LIST) {// 列表模式
  573. selectedIds = $("#list_info").jqGrid('getGridParam',
  574. 'selarrrow');
  575. if (selectedIds == null || selectedIds.length < 1) {
  576. $.ligerDialog.alert("请选择要编排人员!", "提示信息");
  577. return;
  578. }
  579. }
  580. var params = {
  581. startTime : _startTime,
  582. endTime : _endTime,
  583. attencePolicy : $('#attencePolicy').val()
  584. }, url = __ctx + '/platform/ats/atsShiftRule/setting.ht';
  585. url = url.getNewUrl();
  586. DialogUtil.open({
  587. height : 600,
  588. width : 800,
  589. title : '轮班规则',
  590. url : url,
  591. isResize : true,
  592. // 自定义参数
  593. params : params,
  594. // 回调函数
  595. sucCall : function(rtn, beginCol) {
  596. if (_shiftType == AtsConstant.SHIFT_TYPE_CALENDAR) {// 日历模式
  597. _listRowDatas = rtn;
  598. me.initCalendar();
  599. } else {
  600. var table = $("#list_info");
  601. for (var i = 0; i < selectedIds.length; i++) {
  602. var rowid = selectedIds[i];
  603. for (var j = 0; j < rtn.length; j++) {
  604. var iCol = beginCol + j + 3;// 从第3列开始
  605. var tdObject = $("#" + rowid + ">td")[iCol];
  606. table.setCell(rowid, iCol, rtn[j]);
  607. $(tdObject).attr('title', rtn[j].title);
  608. // 数据处理
  609. var rowData = (_listRowDatas[parseInt(rowid) - 1])[rtn[j].start];
  610. rowData.title = rtn[j].title;
  611. rowData.start = rtn[j].start;
  612. rowData.dateType = rtn[j].dateType;
  613. rowData.shiftId = rtn[j].shiftId;
  614. rowData.holidayName = rtn[j].holidayName;
  615. }
  616. }
  617. me.colorFormatter();
  618. }
  619. }
  620. });
  621. },
  622. replaceShiftCalendar : function(event, start, date1) {
  623. me.replaceShift({
  624. start : start,
  625. callback : function(rtn) {
  626. for (var j = 0; j < _listRowDatas.length; j++) {
  627. var events = _listRowDatas[j], date = me
  628. .formatDate(events["start"]);
  629. if (date.getTime() == date1.getTime()) {
  630. events.title = rtn.title;
  631. events.dateType = rtn.dateType;
  632. events.shiftId = rtn.shiftId;
  633. events.start = rtn.start;
  634. events.holidayName = rtn.holidayName;
  635. me.initCalendar();
  636. break;
  637. }
  638. }
  639. }
  640. });
  641. },
  642. replaceShift : function(conf) {
  643. var params = {
  644. start : conf.start
  645. }, url = __ctx + '/platform/ats/atsShiftInfo/replace.ht?isSingle=true&attencePolicy='+_attencePolicy;
  646. url = url.getNewUrl();
  647. DialogUtil.open({
  648. height : 600,
  649. width : 800,
  650. title : '选择日期类型和班次',
  651. url : url,
  652. isResize : true,
  653. // 自定义参数
  654. params : params,
  655. // 回调函数
  656. sucCall : function(rtn) {
  657. conf.callback.call(this, rtn);
  658. }
  659. });
  660. },
  661. formatDate : function(d) {
  662. return new Date(d.replace(/-/g, "/"));
  663. },
  664. /**
  665. * 初始化编排完成的表格
  666. */
  667. initScheduleShiftGrid : function() {
  668. $("#scheduleShiftGrid").jqGrid(
  669. {
  670. datatype : "local", // 数据来源,本地数据
  671. mtype : "POST",// 提交方式
  672. height : document.body.clientHeight - 200,
  673. width : document.body.clientWidth - 30,
  674. colNames : [ '用户名', '组织名称', '考勤时间', '日期类型', '班次名称',
  675. '考勤编号', '考勤制度', '取卡规则' ],
  676. colModel : [ {
  677. name : 'userName',
  678. width : 80
  679. }, {
  680. name : 'orgName',
  681. width : 80
  682. }, {
  683. name : 'attenceTime',
  684. width : 80
  685. }, {
  686. name : 'dateType',
  687. width : 80
  688. }, {
  689. name : 'shiftName',
  690. width : 80
  691. }, {
  692. name : 'cardNumber',
  693. width : 80
  694. }, {
  695. name : 'policyName',
  696. width : 80
  697. }, {
  698. name : 'cardRuleName',
  699. width : 80
  700. } ],
  701. rownumbers : true,// 添加左侧行号
  702. viewrecords : true,
  703. pager : $('#scheduleShiftGridPager')
  704. });
  705. }
  706. }
  707. $.fn[pluginName] = function(options) {
  708. return this
  709. .each(function() {
  710. if (!$.data(this, "plugin_" + pluginName)) {
  711. $.data(this, "plugin_" + pluginName, new Plugin(this,
  712. options));
  713. }
  714. });
  715. };
  716. })(jQuery, window, document);
  717. $(document).ready(function() {
  718. $('body').AtsTurnShiftWizard();
  719. });
  720. /**
  721. * 新增排班规则
  722. */
  723. function addShiftRule() {
  724. AtsTurnShiftWizardPlugin.addShiftRule();
  725. }
  726. /**
  727. * 选择考勤制度
  728. */
  729. function selectAttencePolicy() {
  730. AtsAttencePolicyDialog({
  731. isSingle:true,
  732. callback : function(rtn) {
  733. $('#attencePolicy').val(rtn.id);
  734. $('#attencePolicyName').val(rtn.name);
  735. AtsTurnShiftWizardPlugin.clickQueryUser();
  736. AtsTurnShiftWizardPlugin.cleanUserInfo();
  737. }
  738. });
  739. }
  740. function selectAttenceGroup() {
  741. AtsAttenceGroupDialog({
  742. isSingle : true,
  743. callback : function(rtn) {
  744. $('#attenceGroup').val(rtn.id);
  745. $('#attenceGroupName').val(rtn.name);
  746. }
  747. });
  748. }
  749. function selectOrg(){
  750. OrgDialog({
  751. isSingle : true,
  752. callback : function(orgId, orgName) {
  753. $('#orgId').val(orgId);
  754. $('#orgName').val(orgName);
  755. }
  756. });
  757. }
  758. /**
  759. * 选择用户
  760. */
  761. function selectUser() {
  762. UserDialog({
  763. isSingle : true,
  764. callback : function(userId, userName) {
  765. $('#userId').val(userId);
  766. $('#userName').val(userName);
  767. }
  768. });
  769. }