schedulingplan.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. 'use strict';
  2. app.config(['calendarConfigProvider', function(calendarConfigProvider) {
  3. calendarConfigProvider.setDateFormatter('moment'); // use moment to format dates
  4. calendarConfigProvider.setTitleFormats({
  5. day: 'dddd MMMM DD, YYYY',
  6. week: '{year}年{week}周',
  7. month: 'MMMM YYYY',
  8. year: 'YYYY'
  9. //day: 'ddd D MMM' //this will configure the day view title to be shorter
  10. });
  11. calendarConfigProvider.setI18nStrings({
  12. eventsLabel: '描述', //This will set the events label on the day view
  13. timeLabel: '时间', //This will set the time label on the time view
  14. weekNumber: '{week}周'
  15. });
  16. }]);
  17. app.controller("calendarCtrl", function($scope, $filter, $q, $timeout, $log, MaterialCalendarData,SweetAlert,api_bpm_data) {
  18. $scope.calendarView="month";
  19. $scope.msg={}
  20. $scope.msg['year']=new Date().getFullYear();
  21. $scope.msg['month']=new Date().getMonth()+1;
  22. var workdays=$scope.msg
  23. $scope.selected=[]
  24. var weekdate={"workDayconfigure":{"year":workdays.year,"state":1},"idx":0,"sum":1000}
  25. api_bpm_data.fetchDataList('workDayconfigure',weekdate).then(function(response){
  26. var myData = response.list[0];
  27. myData.monday==1 ? $scope.options.selected[0]=workdays.year+'-1':$scope.options.selected[0]='';
  28. myData.tuesday==1 ? $scope.options.selected[1]=workdays.year+'-2':$scope.options.selected.splice(1,1);
  29. myData.wednesday==1 ? $scope.options.selected[2]=workdays.year+'-3':$scope.options.selected.splice(2,1);
  30. myData.thursday==1 ? $scope.options.selected[3]=workdays.year+'-4':$scope.options.selected.splice(3,1);
  31. myData.friday==1 ? $scope.options.selected[4]=workdays.year+'-5':$scope.options.selected.splice(4,1);
  32. myData.saturday==1 ? $scope.options.selected[5]=workdays.year+'-6':$scope.options.selected.splice(5,1);
  33. myData.sunday==1 ? $scope.options.selected[6]=workdays.year+'-7':$scope.options.selected.splice(6,1);
  34. // console.log($scope.options.selected)
  35. })
  36. $scope.options = {
  37. reset: true,
  38. onChange: function(selected) {
  39. // console.log(selected)
  40. $scope.options.selected=selected;
  41. },
  42. selected: []
  43. };
  44. $scope.saveweek=function(selected){
  45. var numget=['2','2','2','2','2','2','2'];
  46. var longtime='';
  47. var j=''
  48. var w=''
  49. var timeget=''
  50. for(var i=0;i<selected.length;i++){
  51. j =selected[i].substr(selected[i].length-1,1)
  52. j=Number(j)
  53. numget[j]='1'
  54. }
  55. angular.forEach(numget,function(item){
  56. w+=item
  57. })
  58. timeget=workdays.year+'-'+w
  59. var weekdata={
  60. "workDayconfigure": {
  61. "rule": timeget
  62. }
  63. }
  64. api_bpm_data.addData('workDayconfigure',weekdata).then(function(response){
  65. if(response.status==200){
  66. SweetAlert.swal({
  67. title: "修改成功!",
  68. text: "修改排班成功!",
  69. type: "success"
  70. }, function(){
  71. $scope.refreshData(workdays);
  72. });
  73. }else{
  74. SweetAlert.swal({
  75. title: "修改失败!",
  76. text: "修改排班失败!",
  77. type: "error"
  78. });
  79. }
  80. })
  81. }
  82. $scope.selectedDate = [];
  83. $scope.weekStartsOn = 0;
  84. $scope.dayFormat = "d";
  85. $scope.tooltips = true;
  86. $scope.disableFutureDates = true;
  87. $scope.refreshData=function(workdays){
  88. var monedata= {
  89. "idx": 0,
  90. "sum": 31,
  91. "workday": {
  92. "year": workdays.year,
  93. "month": workdays.month
  94. }
  95. }
  96. api_bpm_data.fetchDataList('workday',monedata).then(function(response){
  97. var myData = response.list;
  98. $scope.selectedDate = [];
  99. angular.forEach(myData,function(item){
  100. if(item.isWork==true){
  101. $scope.selectedDate.push(moment(item.date).toDate());
  102. }
  103. })
  104. })
  105. }
  106. $scope.refreshData(workdays);
  107. $scope.setDirection = function(direction) {
  108. $scope.direction = direction;
  109. $scope.dayFormat = direction === "vertical" ? "EEEE, MMMM d" : "d";
  110. };
  111. var ischeck='';
  112. $scope.dayClick = function(date) {
  113. for(var i=0;i<$scope.selectedDate.length;i++){
  114. if(angular.equals(date, $scope.selectedDate[i])==true){
  115. ischeck =false
  116. break
  117. }else{ischeck =true}
  118. }
  119. var ymd=[date.getFullYear(), date.getMonth() + 1, date.getDate()].join("-");
  120. var monedata=
  121. {
  122. "workdayexception": {
  123. "date": ymd,
  124. "isWork": ischeck
  125. }
  126. }
  127. api_bpm_data.addData('workdayexception',monedata).then(function(response){
  128. if(response.status==200){
  129. SweetAlert.swal({
  130. title: "修改成功!",
  131. text: "修改排班成功!",
  132. type: "success"
  133. }, function(){
  134. $scope.refreshData(workdays);
  135. });
  136. }else{
  137. SweetAlert.swal({
  138. title: "修改失败!",
  139. text: "修改排班失败!",
  140. type: "error"
  141. });
  142. }
  143. })
  144. };
  145. $scope.prevMonth = function(data) {
  146. $scope.refreshData(data);
  147. };
  148. $scope.nextMonth = function(data) {
  149. $scope.refreshData(data);
  150. };
  151. $scope.setContentViaService = function() {
  152. var today = new Date();
  153. MaterialCalendarData.setDayContent(today, '<span> :oD </span>')
  154. }
  155. // var holidays = {"2015-01-01":[{"name":"Last Day of Kwanzaa","country":"US","date":"2015-01-01"},{"name":"New Year's Day","country":"US","date":"2015-01-01"}],"2015-01-06":[{"name":"Epiphany","country":"US","date":"2015-01-06"}],"2015-01-07":[{"name":"Orthodox Christmas","country":"US","date":"2015-01-07"}],"2015-01-19":[{"name":"Martin Luther King, Jr. Day","country":"US","date":"2015-01-19"}],"2015-02-02":[{"name":"Groundhog Day","country":"US","date":"2015-02-02"}],"2015-02-14":[{"name":"Valentine's Day","country":"US","date":"2015-02-14"}],"2015-02-16":[{"name":"Washington's Birthday","country":"US","date":"2015-02-16"}],"2015-02-18":[{"name":"Ash Wednesday","country":"US","date":"2015-02-18"}],"2015-03-08":[{"name":"International Women's Day","country":"US","date":"2015-03-08"}],"2015-03-17":[{"name":"Saint Patrick's Day","country":"US","date":"2015-03-17"}],"2015-03-29":[{"name":"Palm Sunday","country":"US","date":"2015-03-29"}],"2015-04-01":[{"name":"April Fools' Day","country":"US","date":"2015-04-01"}],"2015-04-03":[{"name":"Good Friday","country":"US","date":"2015-04-03"}],"2015-04-05":[{"name":"Easter","country":"US","date":"2015-04-05"}],"2015-04-22":[{"name":"Earth Day","country":"US","date":"2015-04-22"}],"2015-04-24":[{"name":"Arbor Day","country":"US","date":"2015-04-24"}],"2015-05-01":[{"name":"May Day","country":"US","date":"2015-05-01"}],"2015-05-04":[{"name":"Star Wars Day","country":"US","date":"2015-05-04"}],"2015-05-05":[{"name":"Cinco de Mayo","country":"US","date":"2015-05-05"}],"2015-05-10":[{"name":"Mother's Day","country":"US","date":"2015-05-10"}],"2015-05-25":[{"name":"Memorial Day","country":"US","date":"2015-05-25"}],"2015-06-14":[{"name":"Flag Day","country":"US","date":"2015-06-14"}],"2015-06-21":[{"name":"Father's Day","country":"US","date":"2015-06-21"}],"2015-06-27":[{"name":"Helen Keller Day","country":"US","date":"2015-06-27"}],"2015-07-04":[{"name":"Independence Day","country":"US","date":"2015-07-04"}],"2015-08-26":[{"name":"Women's Equality Day","country":"US","date":"2015-08-26"}],"2015-09-07":[{"name":"Labor Day","country":"US","date":"2015-09-07"}],"2015-09-11":[{"name":"Patriot Day","country":"US","date":"2015-09-11"}],"2015-09-13":[{"name":"Grandparent's Day","country":"US","date":"2015-09-13"}],"2015-09-17":[{"name":"Constitution Day","country":"US","date":"2015-09-17"}],"2015-10-06":[{"name":"German-American Day","country":"US","date":"2015-10-06"}],"2015-10-09":[{"name":"Leif Erkson Day","country":"US","date":"2015-10-09"}],"2015-10-12":[{"name":"Columbus Day","country":"US","date":"2015-10-12"}],"2015-10-31":[{"name":"Halloween","country":"US","date":"2015-10-31"}],"2015-11-03":[{"name":"Election Day","country":"US","date":"2015-11-03"}],"2015-11-11":[{"name":"Veterans Day","country":"US","date":"2015-11-11"}],"2015-11-26":[{"name":"Thanksgiving Day","country":"US","date":"2015-11-26"}],"2015-11-27":[{"name":"Black Friday","country":"US","date":"2015-11-27"}],"2015-12-07":[{"name":"Pearl Harbor Remembrance Day","country":"US","date":"2015-12-07"}],"2015-12-08":[{"name":"Immaculate Conception of the Virgin Mary","country":"US","date":"2015-12-08"}],"2015-12-24":[{"name":"Christmas Eve","country":"US","date":"2015-12-24"}],"2015-12-25":[{"name":"Christmas","country":"US","date":"2015-12-25"}],"2015-12-26":[{"name":"First Day of Kwanzaa","country":"US","date":"2015-12-26"}],"2015-12-27":[{"name":"Second Day of Kwanzaa","country":"US","date":"2015-12-27"}],"2015-12-28":[{"name":"Third Day of Kwanzaa","country":"US","date":"2015-12-28"}],"2015-12-29":[{"name":"Fourth Day of Kwanzaa","country":"US","date":"2015-12-29"}],"2015-12-30":[{"name":"Fifth Day of Kwanzaa","country":"US","date":"2015-12-30"}],"2015-12-31":[{"name":"New Year's Eve","country":"US","date":"2015-12-31"},{"name":"Sixth Day of Kwanzaa","country":"US","date":"2015-12-31"}],"2016-01-01":[{"name":"Last Day of Kwanzaa","country":"US","date":"2016-01-01"},{"name":"New Year's Day","country":"US","date":"2016-01-01"}],"2016-01-06":[{"name":"Epiphany","country":"US","date":"2016-01-06"}],"2016-01-07":[{"name":"Orthodox Christmas","country":"US","date":"2016-01-07"}],"2016-01-18":[{"name":"Martin Luther King, Jr. Day","country":"US","date":"2016-01-18"}],"2016-02-02":[{"name":"Groundhog Day","country":"US","date":"2016-02-02"}],"2016-02-10":[{"name":"Ash Wednesday","country":"US","date":"2016-02-10"}],"2016-02-14":[{"name":"Valentine's Day","country":"US","date":"2016-02-14"}],"2016-02-15":[{"name":"Washington's Birthday","country":"US","date":"2016-02-15"}],"2016-03-08":[{"name":"International Women's Day","country":"US","date":"2016-03-08"}],"2016-03-17":[{"name":"Saint Patrick's Day","country":"US","date":"2016-03-17"}],"2016-03-20":[{"name":"Palm Sunday","country":"US","date":"2016-03-20"}],"2016-03-25":[{"name":"Good Friday","country":"US","date":"2016-03-25"}],"2016-03-27":[{"name":"Easter","country":"US","date":"2016-03-27"}],"2016-04-01":[{"name":"April Fools' Day","country":"US","date":"2016-04-01"}],"2016-04-22":[{"name":"Earth Day","country":"US","date":"2016-04-22"}],"2016-04-29":[{"name":"Arbor Day","country":"US","date":"2016-04-29"}],"2016-05-01":[{"name":"May Day","country":"US","date":"2016-05-01"}],"2016-05-04":[{"name":"Star Wars Day","country":"US","date":"2016-05-04"}],"2016-05-05":[{"name":"Cinco de Mayo","country":"US","date":"2016-05-05"}],"2016-05-08":[{"name":"Mother's Day","country":"US","date":"2016-05-08"}],"2016-05-30":[{"name":"Memorial Day","country":"US","date":"2016-05-30"}],"2016-06-14":[{"name":"Flag Day","country":"US","date":"2016-06-14"}],"2016-06-19":[{"name":"Father's Day","country":"US","date":"2016-06-19"}],"2016-06-27":[{"name":"Helen Keller Day","country":"US","date":"2016-06-27"}],"2016-07-04":[{"name":"Independence Day","country":"US","date":"2016-07-04"}],"2016-08-26":[{"name":"Women's Equality Day","country":"US","date":"2016-08-26"}],"2016-09-05":[{"name":"Labor Day","country":"US","date":"2016-09-05"}],"2016-09-11":[{"name":"Grandparent's Day","country":"US","date":"2016-09-11"},{"name":"Patriot Day","country":"US","date":"2016-09-11"}],"2016-09-17":[{"name":"Constitution Day","country":"US","date":"2016-09-17"}],"2016-10-06":[{"name":"German-American Day","country":"US","date":"2016-10-06"}],"2016-10-09":[{"name":"Leif Erkson Day","country":"US","date":"2016-10-09"}],"2016-10-10":[{"name":"Columbus Day","country":"US","date":"2016-10-10"}],"2016-10-31":[{"name":"Halloween","country":"US","date":"2016-10-31"}],"2016-11-08":[{"name":"Election Day","country":"US","date":"2016-11-08"},{"name":"Super Tuesday","country":"US","date":"2016-11-08"}],"2016-11-11":[{"name":"Veterans Day","country":"US","date":"2016-11-11"}],"2016-11-24":[{"name":"Thanksgiving Day","country":"US","date":"2016-11-24"}],"2016-11-25":[{"name":"Black Friday","country":"US","date":"2016-11-25"}],"2016-12-07":[{"name":"Pearl Harbor Remembrance Day","country":"US","date":"2016-12-07"}],"2016-12-08":[{"name":"Immaculate Conception of the Virgin Mary","country":"US","date":"2016-12-08"}],"2016-12-24":[{"name":"Christmas Eve","country":"US","date":"2016-12-24"}],"2016-12-25":[{"name":"Christmas","country":"US","date":"2016-12-25"}],"2016-12-26":[{"name":"First Day of Kwanzaa","country":"US","date":"2016-12-26"}],"2016-12-27":[{"name":"Second Day of Kwanzaa","country":"US","date":"2016-12-27"}],"2016-12-28":[{"name":"Third Day of Kwanzaa","country":"US","date":"2016-12-28"}],"2016-12-29":[{"name":"Fourth Day of Kwanzaa","country":"US","date":"2016-12-29"}],"2016-12-30":[{"name":"Fifth Day of Kwanzaa","country":"US","date":"2016-12-30"}],"2016-12-31":[{"name":"New Year's Eve","country":"US","date":"2016-12-31"},{"name":"Sixth Day of Kwanzaa","country":"US","date":"2016-12-31"}]};
  156. // You would inject any HTML you wanted for
  157. // that particular date here.
  158. var numFmt = function(num) {
  159. num = num.toString();
  160. if (num.length < 2) {
  161. num = "0" + num;
  162. }
  163. return num;
  164. };
  165. var loadContentAsync = true;
  166. $log.info("setDayContent.async", loadContentAsync);
  167. $scope.setDayContent = function(date) {
  168. var key = [date.getFullYear(), numFmt(date.getMonth()+1), numFmt(date.getDate())].join("-");
  169. // var data = (holidays[key]||[{ name: ""}])[0].name;
  170. if (loadContentAsync) {
  171. var deferred = $q.defer();
  172. $timeout(function() {
  173. deferred.resolve(data);
  174. });
  175. return deferred.promise;
  176. }
  177. return data;
  178. };
  179. });