schedulingCtrl.js 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365
  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. /**
  18. * Controller of the angularBootstrapCalendarApp
  19. */
  20. app.controller('schedulingCtrl', ["$scope", "i18nService", "$rootScope", "$log", "$state", "$timeout", "$interval", "SweetAlert", 'FileUploader', "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", "api_bpm_data", "$aside", "moment", function($scope, i18nService, $rootScope, $log, $state, $timeout, $interval, SweetAlert, FileUploader, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain, api_bpm_data, $aside, moment) {
  21. var loginUser = $rootScope.user;
  22. $scope.langs = i18nService.getAllLangs();
  23. $scope.lang = 'zh-cn';
  24. i18nService.setCurrentLang($scope.lang);
  25. $scope.allright = false;
  26. $scope.someright = true;
  27. for (var obj in $rootScope.user.role) {
  28. if ($rootScope.user.role[obj].rolecode == 'schedule manager') {
  29. $scope.allright = true;
  30. $scope.someright = false;
  31. }
  32. }
  33. var pdKey = $state.current.pdKey;
  34. $scope.gridOptions = {};
  35. $scope.gridOptions.data = 'myData';
  36. $scope.gridOptions.enableColumnResizing = true;
  37. $scope.gridOptions.enableFiltering = false;
  38. $scope.gridOptions.enableGridMenu = true;
  39. $scope.gridOptions.enableRowSelection = true;
  40. $scope.gridOptions.showGridFooter = true;
  41. $scope.gridOptions.showColumnFooter = false;
  42. $scope.gridOptions.fastWatch = true;
  43. // $scope.gridOptions.useExternalFiltering=true;
  44. $scope.gridOptions.useExternalPagination = true;
  45. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  46. $scope.gridOptions.paginationPageSize = 10;
  47. $scope.gridOptions.multiSelect = false;
  48. $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  49. $scope.gridOptions.rowIdentity = function(row) {
  50. return row.id;
  51. };
  52. $scope.gridOptions.getRowIdentity = function(row) {
  53. return row.id;
  54. };
  55. $scope.gridOptions.columnDefs = [{
  56. name: 'item',
  57. displayName: '序号',
  58. width: 50,
  59. enableFiltering: false
  60. }, {
  61. name: 'sourceWatch.watchTime',
  62. displayName: '换班时间',
  63. width: '15%',
  64. enableFiltering: false
  65. }, {
  66. name: 'initUser.name',
  67. displayName: '申请人',
  68. width: '10%',
  69. enableFiltering: false
  70. }, {
  71. name: 'sourceWatch.scheduleClass.name',
  72. displayName: '换班班次',
  73. width: '10%',
  74. enableFiltering: false
  75. }, {
  76. name: 'endWatch.watchTime',
  77. displayName: '对换时间',
  78. width: '15%',
  79. enableFiltering: false
  80. }, {
  81. name: 'endWatch.user.name',
  82. displayName: '对换人员',
  83. width: '10%',
  84. enableFiltering: false
  85. }, {
  86. name: 'endWatch.scheduleClass.name',
  87. displayName: '对换班次',
  88. width: '10%',
  89. enableFiltering: false
  90. }, {
  91. name: 'stage.name',
  92. displayName: '状态',
  93. width: '10%',
  94. enableFiltering: false
  95. }, {
  96. name: '操作',
  97. cellTemplate: '<schedulingoperator item="row.entity" colobject="col">',
  98. enableFiltering: false
  99. }];
  100. // $scope.gridOptions.importerDataAddCallback = function( grid, newObjects ) {
  101. // $scope.myData = $scope.myData.concat( newObjects );
  102. // console.log($scope);
  103. // };
  104. $scope.refresh = function(style, filterData) {
  105. var filtersData = {
  106. "assignee": $rootScope.user.id,
  107. "candidateGroups": $rootScope.user.group[0].id,
  108. idx: 0,
  109. sum: 10
  110. };
  111. $scope.gridOptions.refresh();
  112. $scope.refreshData('expand-right', $scope.fileData);
  113. };
  114. $scope.searchstate = "all";
  115. $scope.onChange = function(searchType) {
  116. if (searchType && searchType != "") {
  117. $scope.searchstate = searchType;
  118. } else {
  119. $scope.searchstate = "all";
  120. }
  121. $scope.fileData.searchType = searchType;
  122. $scope.refreshData('expand-right', $scope.fileData);
  123. };
  124. $scope.gridOptions.onRegisterApi = function(gridApi) {
  125. $scope.gridApi = gridApi;
  126. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  127. // console.log(newPage);
  128. // console.log(pageSize);
  129. $rootScope['idx'] = newPage;
  130. $scope.fileData.idx=newPage - 1;
  131. $scope.fileData.sum=pageSize;
  132. $scope.refreshData('expand-right', $scope.fileData);
  133. });
  134. // gridApi.core.on.filterChanged($scope, function() {
  135. // var grid = this.grid;
  136. // var filtersData = {
  137. // "assignee":$rootScope.user.id,
  138. // "candidateGroups":$rootScope.user.group[0].id,
  139. // "idx":0,
  140. // "sum":10
  141. // };
  142. // angular.forEach(grid.columns,function(item){
  143. // if(item.enableFiltering){
  144. // if(angular.isDefined(item.filters[0].term)&&item.filters[0].term!=''){
  145. // // console.log('item.filters[0]='+JSON.stringify(item.filters[0]));
  146. // if(angular.isUndefined(filtersData['scheduling'])){
  147. // filtersData['scheduling']={};
  148. // }
  149. // filtersData['scheduling'][item.field]=item.filters[0].term;
  150. // }
  151. // }
  152. // });
  153. // $scope.refreshData('expand-right', filtersData);
  154. // });
  155. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  156. // //$scope.selected.item = data.entity;
  157. // console.log(data);
  158. // });
  159. };
  160. // $scope.gridOptions.appScopeProvider = {
  161. // onDblClick : function(row) {
  162. // $state.go('app.form.detail',{data:row, formKey:'changeDetail', pdKey:'change'});
  163. // //var url = '//google.com';
  164. // //$window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
  165. // }
  166. // };
  167. $scope.selectRowFunction = function(data) {
  168. // console.log(data);
  169. // $state.go('app.process.modeler',{modelId:data.id});
  170. $state.go('app.scheduling.editor', {
  171. taskId: data.taskId,
  172. processInstanceId: data.processInstanceId,
  173. id:data.id
  174. });
  175. };
  176. $scope.onDblClick = function(data) {
  177. //console.log(row.entity);
  178. $state.go('app.detail', { formKey: 'schedulingDetail', pdKey: 'schedule', dataId: data.entity.id, taskId: data.entity.taskId, processInstanceId: data.entity.processInstanceId });
  179. };
  180. // this.onDblClick = function(row) {
  181. // //console.log(row.entity);
  182. // $state.go('app.detail', {
  183. // formKey: 'schedulingDetail',
  184. // pdKey: 'scheduling',
  185. // dataId: row.entity.id
  186. // });
  187. // };
  188. this.removeRowFunction = function(data) {
  189. //TODO $translate('key')
  190. SweetAlert.swal({
  191. title: "确认删除?",
  192. text: "删除以后,你将不能恢复该数据!",
  193. type: "warning",
  194. cancelButtonText: "取消",
  195. showCancelButton: true,
  196. confirmButtonColor: "#DD6B55",
  197. confirmButtonText: "确认删除!"
  198. }, function(isConfirm) {
  199. if (isConfirm) {
  200. // api_bpm_domain.removemodel(data.id).then(function(response){
  201. // if(response){
  202. // $scope.refreshData();
  203. // SweetAlert.swal({
  204. // title: "删除成功!",
  205. // confirmButtonColor: "#007AFF"
  206. // });
  207. // }
  208. // });
  209. } else {
  210. }
  211. });
  212. }
  213. //$scope.callsPending = 0;
  214. //var i = 0;
  215. var defaultFilterData = {
  216. "assignee": $rootScope.user.id,
  217. // "candidateGroups":$rootScope.user.group[0].id,
  218. "searchType":"all",
  219. "idx": 0,
  220. "sum": 10
  221. };
  222. // if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.scheduling)) {
  223. // defaultFilterData['searchType'] = $rootScope.search.scheduling;
  224. // $scope.searchTypes = $rootScope.search.scheduling;
  225. // }
  226. // if ($rootScope['cmdbs'] != 'scheduling') { $rootScope.idx = 1 }
  227. // if (angular.isDefined($rootScope.idx) && $rootScope.cmdbs != "false") {
  228. // $rootScope['cmdbs'] = 'scheduling';
  229. // defaultFilterData.idx = $rootScope.idx - 1;
  230. // } else { $rootScope.cmdbs = ""; }
  231. $scope.fileData={
  232. "assignee": $rootScope.user.id,
  233. "searchType":"all",
  234. "idx": 0,
  235. "sum": 10
  236. }
  237. $scope.ldloading = {};
  238. $scope.refreshData = function(style, filterData) {
  239. $scope.ldloading[style.replace('-', '_')] = true;
  240. if (angular.isUndefined(filterData)) {
  241. // defaultFilterData.idx = $rootScope.idx - 1;
  242. filterData = defaultFilterData;
  243. }
  244. // if (angular.isDefined($scope.searchTypes)) {
  245. // $rootScope['search'] = {};
  246. // filterData['searchType'] = $scope.searchTypes;
  247. // $rootScope['search']['scheduling'] = $scope.searchTypes;
  248. // }
  249. $scope.myData = [];
  250. //var start = new Date();
  251. //var sec = $interval(function () {
  252. //$scope.callsPending++;
  253. api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) {
  254. $scope.callsPending--;
  255. // console.log('filterData='+JSON.stringify(filterData));
  256. var myData = Restangular.stripRestangular(data);
  257. $scope.gridOptions.totalItems = myData.resultCount;
  258. $scope.myData = myData.data;
  259. for (var i = 0; i < $scope.myData.length; i++) {
  260. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  261. }
  262. $scope.ldloading[style.replace('-', '_')] = false;
  263. }, function() {
  264. $scope.ldloading[style.replace('-', '_')] = false;
  265. });
  266. };
  267. $scope.refreshData2 = function(style, filterData) {
  268. $scope.ldloading[style.replace('-', '_')] = true;
  269. if (angular.isUndefined(filterData)) {
  270. // defaultFilterData.idx = $rootScope.idx - 1;
  271. filterData = defaultFilterData;
  272. }
  273. // if (angular.isDefined($scope.searchTypes)) {
  274. // $rootScope['search'] = {};
  275. // filterData['searchType'] = $scope.searchTypes;
  276. // $rootScope['search']['scheduling'] = $scope.searchTypes;
  277. // }
  278. $scope.myData = [];
  279. //var start = new Date();
  280. //var sec = $interval(function () {
  281. //$scope.callsPending++;
  282. api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) {
  283. $scope.callsPending--;
  284. // console.log('filterData='+JSON.stringify(filterData));
  285. var myData = Restangular.stripRestangular(data);
  286. $scope.gridOptions.totalItems = myData.resultCount;
  287. $scope.myData = myData.data;
  288. for (var i = 0; i < $scope.myData.length; i++) {
  289. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  290. }
  291. $scope.ldloading[style.replace('-', '_')] = false;
  292. }, function() {
  293. $scope.ldloading[style.replace('-', '_')] = false;
  294. });
  295. };
  296. $scope.refreshData('expand-right', $scope.fileData);
  297. $scope.timer = $interval(function () {
  298. $scope.refreshData2('expand-right', $scope.fileData);
  299. }, $rootScope.refreshTime);
  300. $scope.$on('$destroy', function () {
  301. $interval.cancel($scope.timer)
  302. });
  303. }]);
  304. app.controller('SchedulingOperCtrl', ['$rootScope', '$http', '$scope', function($rootScope, $http, $scope, $event) {
  305. if ($scope.item.handlerUser != null) {
  306. if ($rootScope.user.id == $scope.item.handlerUser.id) {
  307. $scope.item.chaozuoPower = true;
  308. }
  309. }
  310. $scope.look = function() {
  311. $scope.colobject.grid.appScope.onDblClick($scope.item);
  312. }
  313. $scope.edit = function() {
  314. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  315. // console.log('$scope.item='+JSON.stringify($scope.item));
  316. $scope.doEdit($scope.item.id);
  317. }
  318. }]);
  319. app.directive('schedulingoperator', function() {
  320. return {
  321. restrict: 'E',
  322. scope: {
  323. item: '=',
  324. colobject: '='
  325. },
  326. controller: 'SchedulingOperCtrl',
  327. template: '<div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
  328. // '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>' +
  329. // '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" tooltip="编辑" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>' +
  330. '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" class="bianjifont">编辑</a>' +
  331. '</div>'
  332. };
  333. });
  334. /* 我的排班 */
  335. app.controller('myCalendarCtrl', ["$rootScope", "$scope", "$aside", "calendarConfig", "moment", "SweetAlert", "Restangular", "api_bpm_schedule", "api_user_data", function($rootScope, $scope, $aside, calendarConfig, moment, SweetAlert, Restangular, api_bpm_schedule, api_user_data) {
  336. var loginUser = $rootScope.user;
  337. //console.log(loginUser);
  338. calendarConfig.dateFormatter = 'moment';
  339. calendarConfig.i18nStrings.eventsLabel = '排班描述';
  340. calendarConfig.i18nStrings.timeLabel = '时间';
  341. calendarConfig.i18nStrings.weekNumber = '{week}周';
  342. calendarConfig.allDateFormats = {
  343. angular: {
  344. date: {
  345. hour: 'ha',
  346. day: 'd MMM',
  347. month: 'MMMM',
  348. weekDay: 'EEEE',
  349. time: 'HH:mm',
  350. datetime: 'MMM d, h:mm a'
  351. },
  352. title: {
  353. day: 'yyyy MMMM EEEE d',
  354. week: '{year}年第{week}周',
  355. month: 'yyyy MMMM',
  356. year: 'yyyy'
  357. }
  358. },
  359. moment: {
  360. date: {
  361. hour: 'ha',
  362. day: 'MMMDD日',
  363. month: 'MMMM',
  364. weekDay: 'dddd',
  365. time: 'HH:mm',
  366. datetime: 'MMM D, h:mm a'
  367. },
  368. title: {
  369. day: 'YYYY年MMMMDD日, dddd ',
  370. week: '{year}年第{week}周',
  371. month: 'YYYY年MMMM',
  372. year: 'YYYY'
  373. }
  374. }
  375. };
  376. moment.locale('zh_cn', {
  377. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  378. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  379. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  380. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  381. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  382. longDateFormat: {
  383. LT: 'Ah点mm分',
  384. LTS: 'Ah点m分s秒',
  385. L: 'YYYY-MM-DD',
  386. LL: 'YYYY年MMMD日',
  387. LLL: 'YYYY年MMMD日Ah点mm分',
  388. LLLL: 'YYYY年MMMD日ddddAh点mm分',
  389. l: 'YYYY-MM-DD',
  390. ll: 'YYYY年MMMD日',
  391. lll: 'YYYY年MMMD日Ah点mm分',
  392. llll: 'YYYY年MMMD日ddddAh点mm分'
  393. },
  394. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  395. meridiemHour: function(hour, meridiem) {
  396. if (hour === 12) {
  397. hour = 0;
  398. }
  399. if (meridiem === '凌晨' || meridiem === '早上' ||
  400. meridiem === '上午') {
  401. return hour;
  402. } else if (meridiem === '下午' || meridiem === '晚上') {
  403. return hour + 12;
  404. } else {
  405. // '中午'
  406. return hour >= 11 ? hour : hour + 12;
  407. }
  408. },
  409. meridiem: function(hour, minute, isLower) {
  410. var hm = hour * 100 + minute;
  411. if (hm < 600) {
  412. return '凌晨';
  413. } else if (hm < 900) {
  414. return '早上';
  415. } else if (hm < 1130) {
  416. return '上午';
  417. } else if (hm < 1230) {
  418. return '中午';
  419. } else if (hm < 1800) {
  420. return '下午';
  421. } else {
  422. return '晚上';
  423. }
  424. },
  425. calendar: {
  426. sameDay: function() {
  427. return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
  428. },
  429. nextDay: function() {
  430. return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
  431. },
  432. lastDay: function() {
  433. return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
  434. },
  435. nextWeek: function() {
  436. var startOfWeek, prefix;
  437. startOfWeek = moment().startOf('week');
  438. prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
  439. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  440. },
  441. lastWeek: function() {
  442. var startOfWeek, prefix;
  443. startOfWeek = moment().startOf('week');
  444. prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
  445. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  446. },
  447. sameElse: 'LL'
  448. },
  449. ordinalParse: /\d{1,2}(日|月|周)/,
  450. ordinal: function(number, period) {
  451. switch (period) {
  452. case 'd':
  453. case 'D':
  454. case 'DDD':
  455. return number + '日';
  456. case 'M':
  457. return number + '月';
  458. case 'w':
  459. case 'W':
  460. return number + '周';
  461. default:
  462. return number;
  463. }
  464. },
  465. relativeTime: {
  466. future: '%s内',
  467. past: '%s前',
  468. s: '几秒',
  469. m: '1 分钟',
  470. mm: '%d 分钟',
  471. h: '1 小时',
  472. hh: '%d 小时',
  473. d: '1 天',
  474. dd: '%d 天',
  475. M: '1 个月',
  476. MM: '%d 个月',
  477. y: '1 年',
  478. yy: '%d 年'
  479. },
  480. week: {
  481. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  482. dow: 1, // Monday is the first day of the week.
  483. doy: 4 // The week that contains Jan 4th is the first week of the year.
  484. }
  485. });
  486. //console.log(window.moment().weekdays);
  487. var date = new Date();
  488. var d = date.getDate();
  489. var m = date.getMonth();
  490. var y = date.getFullYear();
  491. // console.log(loginUser);
  492. var filterData = {
  493. "userId": loginUser.id,
  494. "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
  495. "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
  496. };
  497. var load = $scope.load = function(filterData) {
  498. api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response) {
  499. if (response.status == 200) {
  500. $scope.events = [];
  501. // console.log(response.list);
  502. var myData = response.list;
  503. angular.forEach(myData, function(item) {
  504. var eventTemp = {};
  505. eventTemp.title = item.description;
  506. // eventTemp.title = item.name;
  507. eventTemp.type = item.scheduleClass.code;
  508. eventTemp.startsAt = moment(item['scheduleOrder'].startTime).toDate();
  509. eventTemp.endsAtTime = moment(item['scheduleOrder'].endTime).toDate();
  510. eventTemp.startTime = item['scheduleOrder'].startTime;
  511. eventTemp.endTime = item['scheduleOrder'].endTime;
  512. //eventTemp.ends_at = moment(item.endTime).toDate();
  513. eventTemp.id = item.id;
  514. eventTemp.deletable = false;
  515. eventTemp.user = item.user;
  516. $scope.events.push(eventTemp);
  517. })
  518. }
  519. });
  520. }
  521. // var load = $scope.load = function(filterData){
  522. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  523. // console.log("response="+JSON.stringify(response));
  524. // if(response.status==200){
  525. // $scope.events = [];
  526. // console.log(response.list);
  527. // var myData = response.list;
  528. // angular.forEach(myData,function(item){
  529. // var eventTemp = {};
  530. // eventTemp.title = item.description;
  531. // eventTemp.type = item.scheduleClass.code;
  532. // eventTemp.startsAt = moment(item.startTime).toDate();
  533. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  534. // eventTemp.startTime = item.startTime;
  535. // eventTemp.endTime = item.endTime;
  536. // //eventTemp.ends_at = moment(item.endTime).toDate();
  537. // eventTemp.id = item.id;
  538. // eventTemp.deletable = false;
  539. // eventTemp.users = item.users;
  540. // $scope.events.push(eventTemp);
  541. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  542. // })
  543. // }
  544. // });
  545. // }
  546. $scope.scheduleClass = {};
  547. var convertEvent = function(scheduleorder) {
  548. var eventTemp = {};
  549. eventTemp.title = scheduleorder.name;
  550. eventTemp.type = scheduleorder.scheduleClass.code;
  551. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  552. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  553. eventTemp.id = scheduleorder.id;
  554. eventTemp.user = scheduleorder.user;
  555. eventTemp.deletable = false;
  556. return eventTemp;
  557. }
  558. // var convertEvent = function(scheduleorder){
  559. // var eventTemp = {};
  560. // eventTemp.title = scheduleorder.description;
  561. // eventTemp.type = scheduleorder.scheduleClass.code;
  562. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  563. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  564. // eventTemp.id = scheduleorder.id;
  565. // eventTemp.users = scheduleorder.users;
  566. // eventTemp.deletable = false;
  567. // return eventTemp;
  568. // }
  569. // function getdatas() {
  570. api_bpm_schedule.getScheduleClass().then(function(response) {
  571. if (response.status == 200) {
  572. var scheduleClassList = response.list;
  573. angular.forEach(scheduleClassList, function(item) {
  574. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  575. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  576. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  577. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  578. $scope.scheduleClass[item['code']] = item;
  579. })
  580. }
  581. })
  582. // }
  583. function getalldata() {
  584. api_bpm_schedule.fetchList(filterData.startTime, filterData.endTime).then(function(response) {
  585. if (response.status == 200) {
  586. $scope.events = [];
  587. // console.log(response.list);
  588. var myData = response.list;
  589. angular.forEach(myData, function(item) {
  590. var eventTemp = {};
  591. // eventTemp.title = item.name;
  592. eventTemp.title = item.description;
  593. eventTemp.type = item.scheduleClass.code;
  594. eventTemp.startsAt = moment(item.startTime).toDate();
  595. eventTemp.endsAtTime = moment(item.endTime).toDate();
  596. eventTemp.startTime = item.startTime;
  597. eventTemp.endTime = item.endTime;
  598. //eventTemp.ends_at = moment(item.endTime).toDate();
  599. eventTemp.id = item.id;
  600. eventTemp.users = item.users;
  601. // {
  602. // title: '白班',
  603. // type: 'job',
  604. // starts_at: new Date(y, m, 5, 19, 0),
  605. // ends_at: new Date(y, m, 5, 22, 30)
  606. // },
  607. $scope.events.push(eventTemp);
  608. })
  609. }
  610. });
  611. }
  612. getalldata();
  613. $scope.odr = 2;
  614. $scope.searchstate = 2;
  615. $scope.order = function(odr) {
  616. if (odr == 1) {
  617. $scope.odr = 1;
  618. $scope.searchstate = 1;
  619. $scope.load(filterData);
  620. } else if (odr == 2) {
  621. $scope.odr = 2;
  622. $scope.searchstate = 2;
  623. getalldata();
  624. }
  625. }
  626. $scope.events = [];
  627. $scope.calendarView = 'month';
  628. //$scope.calendarDay = new Date();
  629. $scope.calendarDate = moment().startOf('month').toDate();
  630. $scope.timeLabel = "时间";
  631. $scope.eventLabel = "描述";
  632. //日历编辑
  633. function showModal(action, event) {
  634. // console.log("action="+JSON.stringify(action))
  635. var modalInstance = $aside.open({
  636. templateUrl: 'scheduleEvent.html',
  637. placement: 'right',
  638. size: 'sm',
  639. backdrop: true,
  640. controller: function($scope, $modalInstance, scheduleClass, APIService, MementFormat) {
  641. $scope.$modalInstance = $modalInstance;
  642. $scope.action = action;
  643. $scope.event = event;
  644. $scope.scheduleClassic = event;
  645. $scope.$watch('event.type', function(newvalue, oldvalue) {
  646. // if(oldvalue == newvalue) return;
  647. // if(scheduleClass[newvalue]){
  648. var sm = MementFormat(scheduleClass[newvalue].startTime);
  649. var em = MementFormat(scheduleClass[newvalue].endTime);
  650. // console.log("sm=" + JSON.stringify(sm))
  651. event.starts_at = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  652. // console.log("event.starts_at=" + JSON.stringify(event.starts_at))
  653. if (sm.hour() > em.hour()) {
  654. event.ends_at = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  655. // console.log("event.ends_at=" + JSON.stringify(event.starts_at))
  656. } else {
  657. event.ends_at = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  658. // console.log("event.ends_at=" + JSON.stringify(event.ends_at))
  659. }
  660. // }
  661. });
  662. // $scope.ok = function (event) {
  663. // console.log("event="+JSON.stringify(event))
  664. // event.action = action;
  665. // $modalInstance.close(event);
  666. // };
  667. $scope.cancel = function(event) {
  668. $modalInstance.dismiss();
  669. };
  670. var acUserSelect = $scope.refreshUser = function(key) {
  671. //for test
  672. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  673. // return;
  674. var data = { "idx": "0", "sum": "5",user:{engineer: 1,} };
  675. if (key) {
  676. data.user.name = key;
  677. }
  678. APIService.fetchDataList('user', data).then(function(response) {
  679. if (response) {
  680. if (response.status = 200) {
  681. $scope.users = response.list;
  682. // console.log($scope.users);
  683. }
  684. }
  685. })
  686. };
  687. if (angular.isDefined(event.users) && event.users.length > 0) {
  688. }
  689. $scope.users = [event.user];
  690. acUserSelect();
  691. },
  692. resolve: {
  693. scheduleClass: function() {
  694. return $scope.scheduleClass;
  695. },
  696. APIService: function() {
  697. return api_user_data;
  698. },
  699. MementFormat: function() {
  700. return moment;
  701. }
  702. }
  703. });
  704. modalInstance.result.then(function(selectedEvent) {
  705. if (selectedEvent.action == 'Clicked') {
  706. // var data = {
  707. // "scheduleorder":{
  708. // "id":selectedEvent.id,
  709. // "description":selectedEvent.title,
  710. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  711. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  712. // "users":selectedEvent.users,
  713. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  714. // }
  715. // };
  716. // api_bpm_schedule.update(data).then(function(response){
  717. // if(response.status==200){
  718. // SweetAlert.swal({
  719. // title: "操作成功!",
  720. // text: "排班更新成功!",
  721. // type: "succes"
  722. // });
  723. // angular.forEach($scope.events,function(item){
  724. // if(item.id==selectedEvent.id){
  725. // item = selectedEvent;
  726. // }
  727. // })
  728. // }else{
  729. // SweetAlert.swal({
  730. // title: "操作失败",
  731. // text: "排班更新失败,请稍后重试!",
  732. // type: "error"
  733. // })
  734. // }
  735. // })
  736. } else {
  737. //
  738. }
  739. });
  740. }
  741. $scope.moment = function(string) {
  742. return moment(string);
  743. }
  744. $scope.eventClicked = function(event) {
  745. // console.log("event="+JSON.stringify(event))
  746. showModal('Clicked', event);
  747. };
  748. $scope.eventEdited = function(event) {
  749. showModal('Edited', event);
  750. };
  751. //
  752. var updateViews = function(newvalue, oldvalue) {
  753. if (oldvalue == newvalue) return;
  754. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  755. if ($scope.calendarView == "year") {
  756. } else if ($scope.calendarView == "month") {
  757. // $scope.getmonth=
  758. timeStart = moment(newvalue).startOf('month');
  759. timeEnd = moment(newvalue).endOf('month');
  760. } else if ($scope.calendarView == "week") {
  761. timeStart = moment(newvalue).startOf('week');
  762. timeEnd = moment(newvalue).endOf('week');
  763. } else if ($scope.calendarView == "Day") {
  764. timeStart = moment(newvalue).startOf('day');
  765. timeEnd = moment(newvalue).endOf('day');
  766. }
  767. timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
  768. timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
  769. filterData["startTime"] = timeStartSpan;
  770. filterData["endTime"] = timeEndSpan;
  771. $scope.order($scope.odr);
  772. }
  773. $scope.$watch('calendarDate', updateViews)
  774. $scope.next = function() {
  775. $scope.getmonth = 'nextmonth';
  776. $scope.calendarControl.next();
  777. }
  778. $scope.prev = function() {
  779. $scope.calendarControl.prev();
  780. }
  781. $scope.setCalendarToToday = function() {
  782. $scope.calendarDay = new Date();
  783. };
  784. $scope.toggle = function($event, field, event) {
  785. $event.preventDefault();
  786. $event.stopPropagation();
  787. event[field] = !event[field];
  788. };
  789. // $scope.load(filterData);
  790. }]);
  791. /* 排班日历 */
  792. app.controller('adminCalendarCtrl', ["$rootScope", "$scope", "$http", "$aside", "$modal", "calendarConfig", "moment", "SweetAlert", 'FileUploader', "Restangular", "api_bpm_schedule", "api_user_data", "api_bpm_data", function($rootScope, $scope, $http, $aside, $modal, calendarConfig, moment, SweetAlert, FileUploader, Restangular, api_bpm_schedule, api_user_data, api_bpm_data) {
  793. var loginUser = $rootScope.user;
  794. $scope.xinzeng=false;
  795. for(var i=0;i<loginUser.menu.length;i++){
  796. if(loginUser.menu[i].link=="paibanrili_xinzeng"){
  797. $scope.xinzeng=true
  798. }
  799. };
  800. console.log($scope.bianji);
  801. var date = new Date();
  802. var d = date.getDate();
  803. var m = date.getMonth();
  804. var y = date.getFullYear();
  805. // console.log(week);
  806. calendarConfig.dateFormatter = 'moment';
  807. calendarConfig.i18nStrings.eventsLabel = '排班描述';
  808. calendarConfig.i18nStrings.timeLabel = '时间';
  809. calendarConfig.i18nStrings.weekNumber = '{week}周';
  810. calendarConfig.allDateFormats = {
  811. angular: {
  812. date: {
  813. hour: 'ha',
  814. day: 'd MMM',
  815. month: 'MMMM',
  816. weekDay: 'EEEE',
  817. time: 'HH:mm',
  818. datetime: 'MMM d, h:mm a'
  819. },
  820. title: {
  821. day: 'yyyy MMMM EEEE d',
  822. week: '{year}年第{week}周',
  823. month: 'yyyy MMMM',
  824. year: 'yyyy'
  825. }
  826. },
  827. moment: {
  828. date: {
  829. hour: 'ha',
  830. day: 'MMMDD日',
  831. month: 'MMMM',
  832. weekDay: 'dddd',
  833. time: 'HH:mm',
  834. datetime: 'MMM D, h:mm a'
  835. },
  836. title: {
  837. day: 'YYYY年MMMMDD日, dddd ',
  838. week: '{year}年第{week}周',
  839. month: 'YYYY年MMMM',
  840. year: 'YYYY'
  841. }
  842. }
  843. };
  844. moment.locale('zh_cn', {
  845. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  846. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  847. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  848. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  849. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  850. longDateFormat: {
  851. LT: 'Ah点mm分',
  852. LTS: 'Ah点m分s秒',
  853. L: 'YYYY-MM-DD',
  854. LL: 'YYYY年MMMD日',
  855. LLL: 'YYYY年MMMD日Ah点mm分',
  856. LLLL: 'YYYY年MMMD日ddddAh点mm分',
  857. l: 'YYYY-MM-DD',
  858. ll: 'YYYY年MMMD日',
  859. lll: 'YYYY年MMMD日Ah点mm分',
  860. llll: 'YYYY年MMMD日ddddAh点mm分'
  861. },
  862. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  863. meridiemHour: function(hour, meridiem) {
  864. if (hour === 12) {
  865. hour = 0;
  866. }
  867. if (meridiem === '凌晨' || meridiem === '早上' ||
  868. meridiem === '上午') {
  869. return hour;
  870. } else if (meridiem === '下午' || meridiem === '晚上') {
  871. return hour + 12;
  872. } else {
  873. // '中午'
  874. return hour >= 11 ? hour : hour + 12;
  875. }
  876. },
  877. meridiem: function(hour, minute, isLower) {
  878. var hm = hour * 100 + minute;
  879. if (hm < 600) {
  880. return '凌晨';
  881. } else if (hm < 900) {
  882. return '早上';
  883. } else if (hm < 1130) {
  884. return '上午';
  885. } else if (hm < 1230) {
  886. return '中午';
  887. } else if (hm < 1800) {
  888. return '下午';
  889. } else {
  890. return '晚上';
  891. }
  892. },
  893. calendar: {
  894. sameDay: function() {
  895. return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
  896. },
  897. nextDay: function() {
  898. return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
  899. },
  900. lastDay: function() {
  901. return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
  902. },
  903. nextWeek: function() {
  904. var startOfWeek, prefix;
  905. startOfWeek = moment().startOf('week');
  906. prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
  907. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  908. },
  909. lastWeek: function() {
  910. var startOfWeek, prefix;
  911. startOfWeek = moment().startOf('week');
  912. prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
  913. return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
  914. },
  915. sameElse: 'LL'
  916. },
  917. ordinalParse: /\d{1,2}(日|月|周)/,
  918. ordinal: function(number, period) {
  919. switch (period) {
  920. case 'd':
  921. case 'D':
  922. case 'DDD':
  923. return number + '日';
  924. case 'M':
  925. return number + '月';
  926. case 'w':
  927. case 'W':
  928. return number + '周';
  929. default:
  930. return number;
  931. }
  932. },
  933. relativeTime: {
  934. future: '%s内',
  935. past: '%s前',
  936. s: '几秒',
  937. m: '1 分钟',
  938. mm: '%d 分钟',
  939. h: '1 小时',
  940. hh: '%d 小时',
  941. d: '1 天',
  942. dd: '%d 天',
  943. M: '1 个月',
  944. MM: '%d 个月',
  945. y: '1 年',
  946. yy: '%d 年'
  947. },
  948. week: {
  949. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  950. dow: 1, // Monday is the first day of the week.
  951. doy: 4 // The week that contains Jan 4th is the first week of the year.
  952. }
  953. });
  954. var importUploader = $scope.importUploader = new FileUploader({
  955. url: api_bpm_data.impFileData().getRequestedUrl()
  956. });
  957. // importUploader.filters.push({
  958. // name: 'customFilter',
  959. // fn: function(item /*{File|FileLikeObject}*/ , options) {
  960. // var type = item.name.slice(item.name.lastIndexOf('.') + 1);
  961. // //var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
  962. // return (type == 'xlsx');
  963. // }
  964. // });
  965. importUploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  966. console.info('onWhenAddingFileFailed', item, filter, options);
  967. };
  968. importUploader.onAfterAddingFile = function(fileItem) {
  969. console.info('onAfterAddingFile', fileItem);
  970. };
  971. importUploader.onAfterAddingAll = function(addedFileItems) {
  972. console.info('onAfterAddingAll', addedFileItems);
  973. };
  974. importUploader.onProgressItem = function(fileItem, progress) {
  975. console.info('onProgressItem', fileItem, progress);
  976. };
  977. importUploader.onProgressAll = function(progress) {
  978. console.info('onProgressAll', progress);
  979. };
  980. importUploader.onSuccessItem = function(fileItem, response, status, headers) {
  981. $scope.ldloading.expand_right = false;
  982. SweetAlert.swal({
  983. title: "导入成功!",
  984. confirmButtonColor: "#007AFF",
  985. type: "success"
  986. }, function() {
  987. $scope.scheduleClass = {};
  988. $scope.calendarView = 'month';
  989. $scope.calendarDate = moment().startOf('month').toDate();
  990. $scope.calendarTitle;
  991. $scope.externalEvents = [];
  992. api_bpm_schedule.getScheduleClass().then(function(response) {
  993. if (response.status == 200) {
  994. var scheduleClassList = response.list;
  995. angular.forEach(scheduleClassList, function(item) {
  996. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  997. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  998. $scope.scheduleClass[item['code']] = item;
  999. var templateEvent = {
  1000. title: item['name'],
  1001. type: item['code'],
  1002. startTime: item.startsAt,
  1003. //starts_at:
  1004. endTime: item.endsAt,
  1005. //ends_at:
  1006. draggable: true,
  1007. deleteFlag: item.deleteFlag
  1008. };
  1009. if (!templateEvent.deleteFlag) {
  1010. $scope.externalEvents.push(templateEvent);
  1011. }
  1012. })
  1013. }
  1014. })
  1015. });
  1016. console.info('onSuccessItem', fileItem, response, status, headers);
  1017. };
  1018. importUploader.onErrorItem = function(fileItem, response, status, headers) {
  1019. console.info('onErrorItem', fileItem, response, status, headers);
  1020. SweetAlert.swal({
  1021. title: "系统错误!",
  1022. text: "系统错误,请稍候重试!",
  1023. type: "error"
  1024. });
  1025. };
  1026. importUploader.onCancelItem = function(fileItem, response, status, headers) {
  1027. console.info('onCancelItem', fileItem, response, status, headers);
  1028. };
  1029. importUploader.onCompleteItem = function(fileItem, response, status, headers) {
  1030. console.info('onCompleteItem', fileItem, response, status, headers);
  1031. };
  1032. importUploader.onCompleteAll = function() {
  1033. console.info('onCompleteAll');
  1034. };
  1035. $scope.ldloading = {};
  1036. $scope.import = function() {
  1037. $scope.ldloading.expand_right = true;
  1038. importUploader.onBeforeUploadItem = function(item) {
  1039. console.info('onBeforeUploadItem', item);
  1040. };
  1041. importUploader.uploadAll();
  1042. }
  1043. //导入
  1044. $scope.importopen = function() { //导入触发事件
  1045. var modalInstance = $modal.open({
  1046. templateUrl: 'assets/views/import.html',
  1047. controller: function($scope, $modalInstance, FileUploader) {
  1048. var importUploader = $scope.importUploader = new FileUploader({
  1049. url: api_bpm_data.impFileData().getRequestedUrl()
  1050. });
  1051. // importUploader.filters.push({
  1052. // name: 'customFilter',
  1053. // fn: function(item /*{File|FileLikeObject}*/ , options) {
  1054. // var type = item.name.slice(item.name.lastIndexOf('.') + 1);
  1055. // //var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
  1056. // return (type == 'xlsx');
  1057. // }
  1058. // });
  1059. importUploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
  1060. console.info('onWhenAddingFileFailed', item, filter, options);
  1061. };
  1062. importUploader.onAfterAddingFile = function(fileItem) {
  1063. console.info('onAfterAddingFile', fileItem);
  1064. };
  1065. importUploader.onAfterAddingAll = function(addedFileItems) {
  1066. console.info('onAfterAddingAll', addedFileItems);
  1067. };
  1068. importUploader.onProgressItem = function(fileItem, progress) {
  1069. console.info('onProgressItem', fileItem, progress);
  1070. };
  1071. importUploader.onProgressAll = function(progress) {
  1072. console.info('onProgressAll', progress);
  1073. };
  1074. $rootScope.isMask = false;
  1075. importUploader.onSuccessItem = function(fileItem, response, status, headers) {
  1076. if (response.status == 200) {
  1077. $rootScope.isMask = false;
  1078. SweetAlert.swal({
  1079. title: "导入成功!",
  1080. confirmButtonColor: "#007AFF",
  1081. type: "success"
  1082. }, function() {
  1083. $scope.scheduleClass = {};
  1084. $scope.calendarView = 'month';
  1085. $scope.calendarDate = moment().startOf('month').toDate();
  1086. $scope.calendarTitle;
  1087. $scope.externalEvents = [];
  1088. api_bpm_schedule.getScheduleClass().then(function(response) {
  1089. if (response.status == 200) {
  1090. var scheduleClassList = response.list;
  1091. angular.forEach(scheduleClassList, function(item) {
  1092. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  1093. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  1094. $scope.scheduleClass[item['code']] = item;
  1095. var templateEvent = {
  1096. title: item['name'],
  1097. type: item['code'],
  1098. startTime: item.startsAt,
  1099. //starts_at:
  1100. endTime: item.endsAt,
  1101. //ends_at:
  1102. draggable: true,
  1103. deleteFlag: item.deleteFlag
  1104. };
  1105. if (!templateEvent.deleteFlag) {
  1106. $scope.externalEvents.push(templateEvent);
  1107. }
  1108. })
  1109. }
  1110. })
  1111. });
  1112. } else {
  1113. $rootScope.isMask = false;
  1114. SweetAlert.swal({
  1115. title: "导入失败!",
  1116. text: response.error,
  1117. type: "error"
  1118. })
  1119. }
  1120. // console.info('onSuccessItem', fileItem, response, status, headers);
  1121. };
  1122. importUploader.onErrorItem = function(fileItem, response, status, headers) {
  1123. console.info('onErrorItem', fileItem, response, status, headers);
  1124. SweetAlert.swal({
  1125. title: "系统错误!",
  1126. text: "系统错误,请稍候重试!",
  1127. type: "error"
  1128. });
  1129. };
  1130. importUploader.onCancelItem = function(fileItem, response, status, headers) {
  1131. console.info('onCancelItem', fileItem, response, status, headers);
  1132. };
  1133. importUploader.onCompleteItem = function(fileItem, response, status, headers) {
  1134. console.info('onCompleteItem', fileItem, response, status, headers);
  1135. };
  1136. importUploader.onCompleteAll = function() {
  1137. console.info('onCompleteAll');
  1138. };
  1139. $scope.ldloading = {};
  1140. $scope.import = function() {
  1141. $modalInstance.dismiss('cancel');
  1142. $rootScope.isMask = true;
  1143. importUploader.onBeforeUploadItem = function(item) {
  1144. angular.extend(item.headers, $rootScope.getSession());
  1145. item.formData.push({ 'filename': item.file.name });
  1146. item.formData.push({ 'type': "scheduleOrder" });
  1147. };
  1148. importUploader.uploadAll();
  1149. }
  1150. $scope.cancel = function() {
  1151. $modalInstance.dismiss('cancel');
  1152. };
  1153. },
  1154. size: 'sm',
  1155. resolve: {
  1156. importUploader: function() {
  1157. return $scope.importUploader;
  1158. }
  1159. }
  1160. });
  1161. modalInstance.result.then(function(selectedItem) {
  1162. if (selectedItem) {}
  1163. })
  1164. }
  1165. //导出
  1166. $scope.export = function(eventtime) {
  1167. var filadata = { 'sum': 1000, 'idx': 0 };
  1168. $http({
  1169. url: api_bpm_data.downDataModel("scheduleOrder", eventtime.getMonth() + 1).getRequestedUrl(),
  1170. method: 'POST',
  1171. data: JSON.stringify(filadata),
  1172. headers: {
  1173. // 'Content-type': 'application/xls',
  1174. 'Accept': '*/*'
  1175. },
  1176. responseType: 'arraybuffer'
  1177. }).success(function(data, status, headers, config) {
  1178. // $scope.ldloading.zoom_in = false;
  1179. var file = new Blob([data], {
  1180. type: 'application/vnd.ms-excel'
  1181. });
  1182. //trick to download store a file having its URL
  1183. var fileURL = URL.createObjectURL(file);
  1184. var a = document.createElement('a');
  1185. a.href = fileURL;
  1186. a.target = '_blank';
  1187. a.download = $scope.calendarTitle + '排班.xls';
  1188. document.body.appendChild(a);
  1189. a.click();
  1190. }).error(function(data, status, headers, config) {
  1191. // $scope.ldloading.zoom_in = false;
  1192. console.log(data);
  1193. });
  1194. }
  1195. var filterData = {
  1196. //"userId": loginUser.id,
  1197. "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
  1198. "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
  1199. };
  1200. var load = $scope.load = function(filterData) {
  1201. api_bpm_schedule.fetchList(filterData.startTime, filterData.endTime, filterData.userId).then(function(response) {
  1202. if (response.status == 200) {
  1203. $scope.events = [];
  1204. // console.log(response.list);
  1205. var myData = response.list;
  1206. angular.forEach(myData, function(item) {
  1207. var eventTemp = {};
  1208. eventTemp.title = item.description;
  1209. eventTemp.type = item.scheduleClass.code;
  1210. eventTemp.startsAt = moment(item.startTime).toDate();
  1211. eventTemp.endsAtTime = moment(item.endTime).toDate();
  1212. eventTemp.startTime = item.startTime;
  1213. eventTemp.endTime = item.endTime;
  1214. //eventTemp.ends_at = moment(item.endTime).toDate();
  1215. eventTemp.id = item.id;
  1216. eventTemp.users = item.users;
  1217. // {
  1218. // title: '白班',
  1219. // type: 'job',
  1220. // starts_at: new Date(y, m, 5, 19, 0),
  1221. // ends_at: new Date(y, m, 5, 22, 30)
  1222. // },
  1223. $scope.events.push(eventTemp);
  1224. })
  1225. }
  1226. });
  1227. }
  1228. $scope.scheduleClass = {};
  1229. $scope.calendarView = 'month';
  1230. $scope.calendarDate = moment().startOf('month').toDate();
  1231. $scope.calendarTitle;
  1232. $scope.externalEvents = [];
  1233. api_bpm_schedule.getScheduleClass().then(function(response) {
  1234. if (response.status == 200) {
  1235. var scheduleClassList = response.list;
  1236. // console.log(scheduleClassList)
  1237. angular.forEach(scheduleClassList, function(item) {
  1238. item.startsAt = moment(item.startTime).format('HH:mm:ss');
  1239. item.endsAt = moment(item.endTime).format('HH:mm:ss');
  1240. $scope.scheduleClass[item['code']] = item;
  1241. var templateEvent = {
  1242. title: item['name'],
  1243. type: item['code'],
  1244. startTime: item.startsAt,
  1245. //starts_at:
  1246. endTime: item.endsAt,
  1247. person: item.person,
  1248. //ends_at:
  1249. deleteFlag: item.deleteFlag
  1250. };
  1251. if (!templateEvent.deleteFlag) {
  1252. $scope.externalEvents.push(templateEvent);
  1253. }
  1254. })
  1255. }
  1256. })
  1257. $scope.typeTransfer = function(type) {
  1258. return $scope.scheduleClass[type].name;
  1259. }
  1260. $scope.events = [];
  1261. var acUserSelect = $scope.refreshUser = function(key) {
  1262. //for test
  1263. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  1264. // return;
  1265. var data = { "idx": "0", "sum": "999", "user": { "roledata": { "rolecode": "watch" },engineer: 1, } };
  1266. // console.log(data);
  1267. if (key) {
  1268. data.user['name'] = key
  1269. }
  1270. // console.log(data);
  1271. api_user_data.fetchDataList('user', data).then(function(response) {
  1272. if (response) {
  1273. if (response.status = 200) {
  1274. $scope.users = response.list;
  1275. // console.log($scope.users);
  1276. }
  1277. }
  1278. })
  1279. };
  1280. $scope.users = [];
  1281. acUserSelect();
  1282. $scope.calendarView = 'month';
  1283. $scope.calendarDay = new Date();
  1284. $scope.timeLabel = "时间";
  1285. $scope.eventLabel = "描述";
  1286. var judegeEventByLimit = function(event, compareDay) {
  1287. var ret = true;
  1288. angular.forEach($scope.events, function(item) {
  1289. var day = moment(item.startsAt).startOf('day').format('YYYY-MM-DD');
  1290. if (day == compareDay) {
  1291. if (item.type == event.type) {
  1292. ret = false;
  1293. }
  1294. }
  1295. });
  1296. return ret;
  1297. }
  1298. $scope.eventDropped = function(event, start, end) {
  1299. console.log($scope.xinzeng);
  1300. if(!$scope.xinzeng){
  1301. SweetAlert.swal({
  1302. title: "操作失败",
  1303. text: "对不起,你没有权限新增!",
  1304. type: "error"
  1305. });
  1306. }else{
  1307. var externalIndex = $scope.externalEvents.indexOf(event);
  1308. if (externalIndex > -1) {
  1309. if (angular.isDefined(event.users) && event.users != null && event.users.length <= event.person) {
  1310. var compareDay = moment(start).startOf('day').format('YYYY-MM-DD');
  1311. if (!judegeEventByLimit(event, compareDay)) {
  1312. SweetAlert.swal({
  1313. title: "操作失败",
  1314. text: "当天" + event.title + "已存在, 请纠正后重试!",
  1315. type: "error"
  1316. });
  1317. return;
  1318. }
  1319. //$scope.externalEvents.splice(externalIndex, 1);
  1320. var bm = moment(moment(start).startOf('day').format('YYYY-MM-DD') + ' ' + event.startTime);
  1321. var em = moment(moment(start).startOf('day').format('YYYY-MM-DD') + ' ' + event.endTime);
  1322. event.startsAt = bm.toDate();
  1323. //console.log(JSON.stringify(event) + "start" + start + " end" + end);
  1324. var endTime = '';
  1325. var startTime = '';
  1326. if (bm.hour() > em.hour()) {
  1327. endTime = (moment(start).startOf('day').add('day', 1).format('YYYY-MM-DD') + ' ' + event.endTime);
  1328. } else {
  1329. endTime = (moment(start).startOf('day').format('YYYY-MM-DD') + ' ' + event.endTime);
  1330. }
  1331. startTime = (moment(start).startOf('day').format('YYYY-MM-DD') + ' ' + event.startTime);
  1332. var data = {
  1333. "scheduleorder": {
  1334. "description": event.title,
  1335. "startTime": startTime,
  1336. "endTime": endTime,
  1337. "users": event.users,
  1338. "scheduleClass": { "id": $scope.scheduleClass[event.type].id }
  1339. }
  1340. };
  1341. //event.endTime = "";
  1342. // event.startTime = "";
  1343. api_bpm_schedule.add(data).then(function(response) {
  1344. if (response.status == 200) {
  1345. SweetAlert.swal({
  1346. title: "操作成功!",
  1347. text: "新建排班成功!",
  1348. type: "succes"
  1349. });
  1350. var myData = response.data;
  1351. event.id = myData.id;
  1352. $scope.events.push({ 'id': event.id, 'title': event.title, 'startTime': startTime, 'endTime': endTime, 'users': event.users, 'type': event.type, 'startsAt': event.startsAt, 'draggable': event.draggable });
  1353. } else {
  1354. SweetAlert.swal({
  1355. title: "操作失败",
  1356. text: "新建排班失败,请稍后重试!",
  1357. type: "error"
  1358. })
  1359. }
  1360. })
  1361. } else {
  1362. SweetAlert.swal({
  1363. title: "操作失败",
  1364. text: "请选择" + event.person + "位值班人",
  1365. type: "error"
  1366. });
  1367. }
  1368. }
  1369. }
  1370. //console.log("new eventDropped")
  1371. };
  1372. function showModal(action, event) {
  1373. var modalInstance = $aside.open({
  1374. templateUrl: 'calendarEvent.html',
  1375. placement: 'right',
  1376. size: 'sm',
  1377. backdrop: true,
  1378. controller: function($scope, $modalInstance, scheduleClass, APIService, MementFormat, Alert, EventsData,moment) {
  1379. var loginUser = $rootScope.user;
  1380. $scope.shanchu=false;
  1381. $scope.bianji=false;
  1382. for(var i=0;i<loginUser.menu.length;i++){
  1383. if(loginUser.menu[i].link=="paibanrili_shanchu"){
  1384. $scope.shanchu=true
  1385. }
  1386. if(loginUser.menu[i].link=="paibanrili_bianji"){
  1387. $scope.bianji=true
  1388. }
  1389. };
  1390. $scope.$modalInstance = $modalInstance;
  1391. $scope.action = action;
  1392. event.startsAt = moment(event.startsAt).format('YYYY-MM-DD HH:mm:ss');
  1393. event.endsAtTime = moment(event.startsAt).format('YYYY-MM-DD HH:mm:ss');
  1394. $scope.event = event;
  1395. console.log(event);
  1396. $scope.scheduleClassic = event.tilte;
  1397. $scope.currentDate = MementFormat().toDate();
  1398. $scope.$watch('event.type', function(newvalue, oldvalue) {
  1399. if (oldvalue == newvalue) return;
  1400. if (scheduleClass[newvalue]) {
  1401. var sm = MementFormat(scheduleClass[newvalue].startTime);
  1402. var em = MementFormat(scheduleClass[newvalue].endTime);
  1403. event.startsAt = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  1404. event.startTime = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1405. event.title = scheduleClass[newvalue].name;
  1406. if (sm.hour() > em.hour()) {
  1407. event.endTime = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1408. event.endsAtTime = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  1409. } else {
  1410. event.endTime = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1411. event.endsAtTime = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  1412. }
  1413. }
  1414. });
  1415. $scope.$watch('event.startsAt', function(newvalue, oldvalue) {
  1416. if (oldvalue == newvalue) return;
  1417. if (MementFormat(oldvalue).format('YYYY-MM-DD HH:mm:ss') == MementFormat(newvalue).format('YYYY-MM-DD HH:mm:ss')) return;
  1418. if (scheduleClass[event.type]) {
  1419. var sm = MementFormat(scheduleClass[event.type].startTime);
  1420. var em = MementFormat(scheduleClass[event.type].endTime);
  1421. //event.starts_at = MementFormat(event.starts_at).startOf('day').add(sm.hour(),'hour').add(sm.minute(),'minute').add(sm.second(),'second').toDate();
  1422. if (sm.hour() > em.hour()) {
  1423. event.endTime = MementFormat(event.startsAt).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1424. event.endsAtTime = MementFormat(event.startsAt).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  1425. } else {
  1426. event.endTime = MementFormat(event.startsAt).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1427. event.endsAtTime = MementFormat(event.startsAt).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  1428. }
  1429. }
  1430. });
  1431. $scope.setEndOpen = function() {
  1432. if (scheduleClass[event.type]) {
  1433. var sm = MementFormat(scheduleClass[event.type].startTime);
  1434. var em = MementFormat(scheduleClass[event.type].endTime);
  1435. event.startsAt = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  1436. if (sm.hour() > em.hour()) {
  1437. event.endTime = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1438. event.endsAtTime = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  1439. } else {
  1440. event.endTime = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1441. event.endsAtTime = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  1442. }
  1443. }
  1444. }
  1445. //同一天只能排出一个白班一个夜班
  1446. function judegeEventByLimit(event) {
  1447. var ret = true;
  1448. var compareDay = moment(event.startsAt).startOf('day').format('YYYY-MM-DD');
  1449. angular.forEach(EventsData, function(item) {
  1450. var day = moment(item.startsAt).startOf('day').format('YYYY-MM-DD');
  1451. if (day == compareDay) {
  1452. if (angular.isDefined(event.id)) {
  1453. if (item.type == event.type && event.id != item.id) ret = false;
  1454. } else {
  1455. if (item.type == event.type) ret = false;
  1456. }
  1457. }
  1458. });
  1459. return ret;
  1460. }
  1461. $scope.ok = function(event) {
  1462. // console.log("event="+JSON.stringify(event));
  1463. if (angular.isDefined(event.users) && event.users != null) {
  1464. if (judegeEventByLimit(event)) {
  1465. event.action = action;
  1466. $modalInstance.close(event);
  1467. } else {
  1468. Alert.swal({
  1469. title: "操作失败",
  1470. text: "同一天只能排出一个白班一个夜班, 请纠正后重试!",
  1471. type: "error"
  1472. })
  1473. }
  1474. } else {
  1475. Alert.swal({
  1476. title: "操作失败",
  1477. text: "请填写值班人",
  1478. type: "error"
  1479. })
  1480. }
  1481. };
  1482. $scope.deleteEvent = function(event) {
  1483. event.action = "Deleted";
  1484. $modalInstance.close(event);
  1485. };
  1486. $scope.refreshModalUser = function(key) {
  1487. //for test
  1488. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  1489. // return;
  1490. var data = { "idx": "0", "sum": "999", "user": { "roledata": { "rolecode": "watch" },engineer: 1, } };
  1491. if (key) {
  1492. data.user['name'] = key
  1493. }
  1494. console.log(data);
  1495. APIService.fetchDataList('user', data).then(function(response) {
  1496. if (response) {
  1497. // console.log("response=" + JSON.stringify(response))
  1498. if (response.status = 200) {
  1499. $scope.modalusers = response.list;
  1500. console.log($scope.users);
  1501. }
  1502. }
  1503. })
  1504. };
  1505. $scope.users = [];
  1506. $scope.refreshModalUser();
  1507. },
  1508. resolve: {
  1509. scheduleClass: function() {
  1510. return $scope.scheduleClass;
  1511. },
  1512. APIService: function() {
  1513. return api_user_data;
  1514. },
  1515. MementFormat: function() {
  1516. return moment;
  1517. },
  1518. Alert: function() {
  1519. return SweetAlert;
  1520. },
  1521. EventsData: function() {
  1522. return $scope.events;
  1523. }
  1524. }
  1525. });
  1526. modalInstance.result.then(function(selectedEvent) {
  1527. if (selectedEvent.action == 'Edited') {
  1528. //new
  1529. var data = {
  1530. "scheduleorder": {
  1531. "description": selectedEvent.title,
  1532. "startTime": selectedEvent.startTime,
  1533. "endTime": selectedEvent.endTime,
  1534. "users": selectedEvent.users,
  1535. "scheduleClass": { "id": $scope.scheduleClass[selectedEvent.type].id }
  1536. }
  1537. };
  1538. api_bpm_schedule.add(data).then(function(response) {
  1539. if (response.status == 200) {
  1540. SweetAlert.swal({
  1541. title: "操作成功!",
  1542. text: "新建排班成功!",
  1543. type: "succes"
  1544. });
  1545. $scope.events.push(convertEvent(response.data));
  1546. // angular.forEach($scope.events,function(item){
  1547. // if(item.id==selectedEvent.id){
  1548. // item = selectedEvent;
  1549. // }
  1550. // })
  1551. } else {
  1552. SweetAlert.swal({
  1553. title: "操作失败",
  1554. text: "新建排班失败,请稍后重试!",
  1555. type: "error"
  1556. })
  1557. }
  1558. })
  1559. } else if (selectedEvent.action == 'Clicked') {
  1560. if(typeof(selectedEvent.startTime)!="string"){
  1561. selectedEvent.startTime=moment(selectedEvent.startTime.getTime()).format('YYYY-MM-DD HH:mm:ss')
  1562. }
  1563. if(typeof(selectedEvent.endTime)!="string"){
  1564. selectedEvent.endTime=moment(selectedEvent.endTime.getTime()).format('YYYY-MM-DD HH:mm:ss')
  1565. }
  1566. var data = {
  1567. "scheduleorder": {
  1568. "id": selectedEvent.id,
  1569. "description": selectedEvent.title,
  1570. "startTime":selectedEvent.startTime,
  1571. "endTime": selectedEvent.endTime,
  1572. "users": selectedEvent.users,
  1573. "scheduleClass": { "id": $scope.scheduleClass[selectedEvent.type].id }
  1574. }
  1575. };
  1576. api_bpm_schedule.update(data).then(function(response) {
  1577. if (response.status == 200) {
  1578. SweetAlert.swal({
  1579. title: "操作成功!",
  1580. text: "排班更新成功!",
  1581. type: "succes"
  1582. });
  1583. angular.forEach($scope.events, function(item) {
  1584. if (item.id == selectedEvent.id) {
  1585. item = selectedEvent;
  1586. }
  1587. })
  1588. } else {
  1589. SweetAlert.swal({
  1590. title: "操作失败",
  1591. text: "排班更新失败,请稍后重试!",
  1592. type: "error"
  1593. })
  1594. }
  1595. })
  1596. } else {
  1597. $scope.eventDeleted(selectedEvent);
  1598. }
  1599. });
  1600. }
  1601. $scope.moment = function(string) {
  1602. return moment(string);
  1603. }
  1604. $scope.eventClicked = function(event) {
  1605. showModal('Clicked', event);
  1606. };
  1607. $scope.addEvent = function() {
  1608. var sm = moment($scope.scheduleClass['job'].startTime);
  1609. var em = moment($scope.scheduleClass['job'].endTime);
  1610. var newevent = {
  1611. title: $scope.scheduleClass['job'].name,
  1612. type: $scope.scheduleClass['job'].code,
  1613. user: loginUser
  1614. };
  1615. newevent.startsAt = moment($scope.calendarDay).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
  1616. newevent.startTime = moment($scope.calendarDay).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1617. if (sm.hour() > em.hour()) {
  1618. newevent.endTime = moment($scope.calendarDay).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1619. newevent.endsAtTime = moment($scope.calendarDay).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  1620. //newevent.ends_at = moment($scope.calendarDay).startOf('day').add(1, 'day').add(em.hour(),'hour').add(em.minute(),'minute').add(em.second(),'second').toDate();
  1621. } else {
  1622. newevent.endTime = moment($scope.calendarDay).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').format('YYYY-MM-DD HH:mm:ss');
  1623. newevent.endsAtTime = moment($scope.calendarDay).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
  1624. //newevent.ends_at = moment($scope.calendarDay).startOf('day').add(em.hour(),'hour').add(em.minute(),'minute').add(em.second(),'second').toDate();
  1625. }
  1626. $scope.eventEdited(newevent);
  1627. };
  1628. $scope.eventEdited = function(event) {
  1629. showModal('Edited', event);
  1630. };
  1631. $scope.eventDeleted = function(event) {
  1632. SweetAlert.swal({
  1633. title: "确认删除?",
  1634. text: "删除的数据不可恢复,请确认继续操作!",
  1635. type: "warning",
  1636. showCancelButton: true,
  1637. confirmButtonColor: "#DD6B55",
  1638. confirmButtonText: "继续删除",
  1639. cancelButtonText: "取消操作",
  1640. closeOnConfirm: false,
  1641. closeOnCancel: false
  1642. }, function(isConfirm) {
  1643. if (isConfirm) {
  1644. api_bpm_schedule.remove([event.id]).then(function(response) {
  1645. if (response.status == 200) {
  1646. $scope.events.splice(event.$id, 1);
  1647. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  1648. } else {
  1649. SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
  1650. }
  1651. });
  1652. } else {
  1653. SweetAlert.swal("操作取消", "数据安全", "error");
  1654. }
  1655. });
  1656. };
  1657. //$scope.timeStart;
  1658. //$scope.timeEnd;
  1659. var updateView = function(newvalue, oldvalue) {
  1660. if (oldvalue == newvalue) return;
  1661. if (moment(oldvalue).format('YYYY-MM-DD HH:mm:ss') == moment(newvalue).format('YYYY-MM-DD HH:mm:ss')) return;
  1662. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  1663. if ($scope.calendarView == "year") {
  1664. } else if ($scope.calendarView == "month") {
  1665. timeStart = moment(newvalue).startOf('month');
  1666. timeEnd = moment(newvalue).endOf('month');
  1667. } else if ($scope.calendarView == "week") {
  1668. timeStart = moment(newvalue).startOf('week');
  1669. timeEnd = moment(newvalue).endOf('week');
  1670. } else if ($scope.calendarView == "Day") {
  1671. timeStart = moment(newvalue).startOf('day');
  1672. timeEnd = moment(newvalue).endOf('day');
  1673. }
  1674. timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
  1675. timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
  1676. filterData["startTime"] = timeStartSpan;
  1677. filterData["endTime"] = timeEndSpan;
  1678. load(filterData);
  1679. }
  1680. $scope.$watch('calendarDate', updateView)
  1681. $scope.next = function() {
  1682. $scope.calendarControl.next();
  1683. }
  1684. $scope.prev = function() {
  1685. $scope.calendarControl.prev();
  1686. }
  1687. $scope.setCalendarToToday = function() {
  1688. $scope.calendarDay = new Date();
  1689. };
  1690. $scope.toggle = function($event, field, event) {
  1691. $event.preventDefault();
  1692. $event.stopPropagation();
  1693. event[field] = !event[field];
  1694. };
  1695. $scope.load(filterData);
  1696. }]);
  1697. /* 换班记录 */
  1698. app.controller('shiftScheduleCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "moment", "SweetAlert", "Restangular", "api_bpm_schedule", "api_user_data", function($rootScope, $scope, $state, $timeout, $interval, moment, SweetAlert, Restangular, api_bpm_schedule, api_user_data) {
  1699. var loginUser = $rootScope.user;
  1700. $scope.shiftes = [];
  1701. var load = function() {
  1702. $scope.shiftes = [];
  1703. api_bpm_schedule.queryHandleoutSwitch(loginUser.id).then(function(response) {
  1704. if (response) {
  1705. var myData = Restangular.stripRestangular(response);
  1706. angular.forEach(myData.list, function(item) {
  1707. $scope.shiftes.push(item);
  1708. })
  1709. }
  1710. })
  1711. }
  1712. $scope.getShiftType = function(shift) {
  1713. var ret = "error";
  1714. if (shift.scheduleOrderDTO.status.id == 2) {
  1715. ret = "import";
  1716. }
  1717. if (shift.scheduleOrderDTO.status.id == 4) {
  1718. ret = "upload";
  1719. }
  1720. return ret;
  1721. }
  1722. // var getShift = function(){
  1723. // angular.forEach($scope.shiftes, function(item){
  1724. // if(item.user.id==loginUser.id){
  1725. // return item;
  1726. // }
  1727. // })
  1728. // }
  1729. var getShift = function() {
  1730. var ret = null;
  1731. angular.forEach($scope.shiftes, function(item) {
  1732. if (item.user.id == loginUser.id && (item.status.id == 1 || item.status.id == 2) && ret == null) {
  1733. ret = item;
  1734. }
  1735. })
  1736. return ret;
  1737. }
  1738. $scope.getHandle = function() {
  1739. var ret = "error";
  1740. var shift;
  1741. var index = 0;
  1742. //angular.forEach($scope.shiftes, function(item){
  1743. for (var index1 in $scope.shiftes) {
  1744. //shift = item;
  1745. var item = $scope.shiftes[index1];
  1746. //console.log(item.user.id +"==" +loginUser.id + "shift.status.id"+shift.status.id + " " + shift.scheduleOrderDTO.status.id );
  1747. if (item.user.id == loginUser.id) {
  1748. shift = item;
  1749. //console.log(shift.status.id);
  1750. if (shift.status.id == 1) {
  1751. //console.log("shift.scheduleOrderDTO.status.id="+shift.scheduleOrderDTO.status.id);
  1752. if (shift.scheduleOrderDTO.status.id == 2) {
  1753. ret = "import";
  1754. }
  1755. } else if (shift.status.id == 2) {
  1756. if (shift.scheduleOrderDTO.status.id == 4) {
  1757. ret = "upload";
  1758. break;
  1759. //return;
  1760. }
  1761. }
  1762. //return ret;
  1763. }
  1764. if (item.status.id == 5) {
  1765. index++;
  1766. }
  1767. //});
  1768. }
  1769. //console.log(index)
  1770. if (ret == 'import' && index != 2) {
  1771. ret = 'uploadDes';
  1772. }
  1773. console.log(ret);
  1774. return ret;
  1775. }
  1776. $scope.importShift = function() {
  1777. var shift = getShift();
  1778. var data = {};
  1779. if (shift.status.id == 1) {
  1780. data.status = {};
  1781. data.status.id = 4;
  1782. }
  1783. data.id = shift.id;
  1784. api_bpm_schedule.handleSchedule(data).then(function(response) {
  1785. if (response) {
  1786. var myData = Restangular.stripRestangular(response);
  1787. if (response.status == 200) {
  1788. SweetAlert.swal("接班成功!", "接班成功!", "success");
  1789. load();
  1790. } else {
  1791. SweetAlert.swal("接班失败!", "接班失败,请稍候重试", "error");
  1792. }
  1793. }
  1794. })
  1795. }
  1796. $scope.uploadShift = function() {
  1797. var shift = getShift();
  1798. var data = {};
  1799. if (shift.status.id == 2) {
  1800. data.status = {};
  1801. data.status.id = 5;
  1802. }
  1803. data.id = shift.id;
  1804. api_bpm_schedule.handleSchedule(data).then(function(response) {
  1805. if (response) {
  1806. var myData = Restangular.stripRestangular(response);
  1807. if (response.status == 200) {
  1808. SweetAlert.swal("交班成功!", "交班成功!", "success");
  1809. load();
  1810. } else {
  1811. SweetAlert.swal("交班失败!", "交班失败,请稍候重试", "error");
  1812. }
  1813. }
  1814. })
  1815. }
  1816. load();
  1817. // api_bpm_schedule.queryRecieveSwitch(loginUser.id).then(function(response){
  1818. // if(response){
  1819. // var myData = Restangular.stripRestangular(response);
  1820. // angular.forEach(myData.list, function(item){
  1821. // $scope.shiftes.push(item);
  1822. // })
  1823. // }
  1824. // })
  1825. }]);
  1826. /* 换班申请 */
  1827. app.controller('shiftRecordCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_schedule", "$aside", "moment", function($rootScope, $scope, $state, $timeout, $interval, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_schedule, $aside, moment) {
  1828. $scope.langs = i18nService.getAllLangs();
  1829. $scope.lang = 'zh-cn';
  1830. i18nService.setCurrentLang($scope.lang);
  1831. $scope.gridOptions = {};
  1832. $scope.gridOptions.data = 'myData';
  1833. $scope.gridOptions.enableColumnResizing = true;
  1834. $scope.gridOptions.enableFiltering = false;
  1835. $scope.gridOptions.enableGridMenu = true;
  1836. $scope.gridOptions.enableRowSelection = true;
  1837. $scope.gridOptions.showGridFooter = true;
  1838. $scope.gridOptions.showColumnFooter = false;
  1839. $scope.gridOptions.fastWatch = true;
  1840. $scope.gridOptions.useExternalFiltering = true;
  1841. $scope.gridOptions.useExternalPagination = true;
  1842. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1843. $scope.gridOptions.paginationPageSize = 10;
  1844. $scope.gridOptions.multiSelect = false;
  1845. //$scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  1846. //
  1847. $scope.gridOptions.rowIdentity = function(row) {
  1848. return row.id;
  1849. };
  1850. $scope.gridOptions.getRowIdentity = function(row) {
  1851. return row.id;
  1852. };
  1853. $scope.gridOptions.columnDefs = [{
  1854. name: 'orderTime',
  1855. displayName: '日期',
  1856. width: 100
  1857. }, {
  1858. name: 'scheduleClass.name',
  1859. displayName: '班次',
  1860. width: 80,
  1861. enableFiltering: false
  1862. },
  1863. {
  1864. name: 'scheduleWatchList[2].user.name',
  1865. displayName: '第一交班人',
  1866. width: 100,
  1867. enableFiltering: false
  1868. },
  1869. {
  1870. name: 'scheduleWatchList[2].shiftTime',
  1871. displayName: '交班时间',
  1872. width: 180,
  1873. enableFiltering: false
  1874. },
  1875. {
  1876. name: 'scheduleWatchList[3].user.name',
  1877. displayName: '第二交班人',
  1878. width: 100,
  1879. enableFiltering: false
  1880. },
  1881. {
  1882. name: 'scheduleWatchList[3].shiftTime',
  1883. displayName: '交班时间',
  1884. width: 180,
  1885. enableFiltering: false
  1886. },
  1887. {
  1888. name: 'scheduleWatchList[0].user.name',
  1889. displayName: '第一接班人',
  1890. width: 100,
  1891. enableFiltering: false
  1892. },
  1893. {
  1894. name: 'scheduleWatchList[0].succeedTime',
  1895. displayName: '接班时间',
  1896. width: 180,
  1897. enableFiltering: false
  1898. },
  1899. {
  1900. name: 'scheduleWatchList[1].user.name',
  1901. displayName: '第二接班人',
  1902. width: 100,
  1903. enableFiltering: false
  1904. },
  1905. {
  1906. name: 'scheduleWatchList[1].succeedTime',
  1907. displayName: '接班时间',
  1908. width: 180,
  1909. enableFiltering: false
  1910. },
  1911. {
  1912. name: 'status.name',
  1913. displayName: '状态',
  1914. width: 100,
  1915. enableFiltering: false
  1916. }
  1917. ];
  1918. $scope.gridOptions.onRegisterApi = function(gridApi) {
  1919. $scope.gridApi = gridApi;
  1920. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  1921. console.log(newPage);
  1922. console.log(pageSize);
  1923. $scope.refreshData('expand-right', {
  1924. "idx": newPage - 1,
  1925. "sum": pageSize
  1926. });
  1927. });
  1928. gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  1929. //$scope.selected.item = data.entity;
  1930. console.log(data);
  1931. });
  1932. // gridApi.core.on.filterChanged($scope, function() {
  1933. // var grid = this.grid;
  1934. // var filtersData = {
  1935. // idx:0,
  1936. // sum:10
  1937. // };
  1938. // angular.forEach(grid.columns,function(item){
  1939. // if(item.enableFiltering){
  1940. // if(angular.isDefined(item.filters[0].term)&&item.filters[0].term!=''){
  1941. // // console.log('item.filters[0]='+JSON.stringify(item.filters[0]));
  1942. // if(angular.isUndefined(filtersData['scheduling'])){
  1943. // filtersData['scheduling']={};
  1944. // }
  1945. // filtersData['scheduling'][item.field]=item.filters[0].term;
  1946. // }
  1947. // }
  1948. // });
  1949. // $scope.memoryfilterData = filtersData;
  1950. // $scope.refreshData('expand-right', filtersData);
  1951. // });
  1952. };
  1953. this.selectRowFunction = function(data) {
  1954. console.log(data);
  1955. // $state.go('app.process.modeler',{modelId:data.id});
  1956. $state.go('app.scheduling.editor', {
  1957. taskId: data.taskId,
  1958. processInstanceId: data.processInstanceId
  1959. });
  1960. };
  1961. $scope.search = function(start, end) {
  1962. var filtersData = {
  1963. "scheduleorder": { "type": "4" },
  1964. idx: 0,
  1965. sum: 10
  1966. };
  1967. if (angular.isDefined(start) || angular.isDefined(end)) {
  1968. filtersData.scheduleorder['startTime'] = moment(start).format('YYYY-MM-DD HH:mm:ss');
  1969. // filtersData.scheduleorder['endTime']=moment(end).format('YYYY-MM-DD HH:mm:ss');
  1970. var timedata = new Date(end).getTime() + 86400000;
  1971. var d = new Date(timedata)
  1972. filtersData.scheduleorder['endTime'] = moment(d).format('YYYY-MM-DD HH:mm:ss');
  1973. console.log(timedata)
  1974. }
  1975. $scope.memoryfilterData = filtersData;
  1976. $scope.refresh('expand-right', filtersData);
  1977. }
  1978. $scope.ldloading = false;
  1979. $scope.export = function(start, end) {
  1980. $scope.ldloading.expand_right = true;
  1981. var filtersData = {
  1982. scheduleorder: { "type": "4" },
  1983. idx: 0,
  1984. sum: 1000
  1985. };
  1986. if (angular.isDefined(start) || angular.isDefined(end)) {
  1987. filtersData.scheduleorder['startTime'] = moment(start).format('YYYY-MM-DD HH:mm:ss');
  1988. var timedata = new Date(end).getTime() + 86400000;
  1989. var d = new Date(timedata)
  1990. filtersData.scheduleorder['endTime'] = moment(d).format('YYYY-MM-DD HH:mm:ss');
  1991. }
  1992. // if(angular.isDefined($scope.ciclassify)&&$scope.ciclassify!=null){
  1993. // if(angular.isUndefined($scope.ciclassify.children)||$scope.ciclassify.children.length==0){
  1994. api_bpm_schedule.query(filtersData).then(function(data) {
  1995. var dataList = Restangular.stripRestangular(data).list;
  1996. // if(dataList&&(dataList.list.length>=1)){
  1997. var headers = [];
  1998. var fieldHeaders = [];
  1999. var exportdata = [];
  2000. var fields = [];
  2001. var rowData = [];
  2002. var rowdata = [];
  2003. if ($scope.gridOptions.columnDefs.length > 0) {
  2004. angular.forEach($scope.gridOptions.columnDefs, function(prop) {
  2005. headers.push(prop.displayName);
  2006. // angular.forEach(prop.form.fields, function(field, index){
  2007. // fieldHeaders.push(field.templateOptions.label);
  2008. // fields.push(field.key);
  2009. // if(index!=0){
  2010. // headers.push("");
  2011. // }
  2012. // });
  2013. })
  2014. }
  2015. var rowLine = [];
  2016. var dataline = [];
  2017. for (var i = 0; i < dataList.length; i++) {
  2018. if (angular.isUndefined(dataList[i].scheduleWatchList[0])) { dataList[i].scheduleWatchList[0] = {} }
  2019. if (angular.isUndefined(dataList[i].scheduleWatchList[1])) { dataList[i].scheduleWatchList[1] = {} }
  2020. if (angular.isUndefined(dataList[i].scheduleWatchList[2])) { dataList[i].scheduleWatchList[2] = {} }
  2021. if (angular.isUndefined(dataList[i].scheduleWatchList[3])) { dataList[i].scheduleWatchList[3] = {} }
  2022. if (angular.isUndefined(dataList[i].scheduleWatchList[2].user)) { dataList[i].scheduleWatchList[2].user = "" }
  2023. if (angular.isUndefined(dataList[i].scheduleWatchList[2].shiftTime)) { dataList[i].scheduleWatchList[2].shiftTime = "" }
  2024. if (angular.isUndefined(dataList[i].scheduleWatchList[1].user)) { dataList[i].scheduleWatchList[1].user = "" }
  2025. if (angular.isUndefined(dataList[i].scheduleWatchList[1].succeedTime)) { dataList[i].scheduleWatchList[1].succeedTime = "" }
  2026. if (angular.isUndefined(dataList[i].scheduleWatchList[0].user)) { dataList[i].scheduleWatchList[0].user = "" }
  2027. if (angular.isUndefined(dataList[i].scheduleWatchList[0].succeedTime)) { dataList[i].scheduleWatchList[0].succeedTime = "" }
  2028. if (angular.isUndefined(dataList[i].scheduleWatchList[3].user)) { dataList[i].scheduleWatchList[3].user = "" }
  2029. if (angular.isUndefined(dataList[i].scheduleWatchList[3].shiftTime)) { dataList[i].scheduleWatchList[3].shiftTime = "" }
  2030. exportdata = {
  2031. orderTime: dataList[i].orderTime,
  2032. scheduleClass: dataList[i].scheduleClass.name,
  2033. username2: dataList[i].scheduleWatchList[2].user.name,
  2034. shiftTime2: dataList[i].scheduleWatchList[2].shiftTime,
  2035. username3: dataList[i].scheduleWatchList[3].user.name,
  2036. succeedTime3: dataList[i].scheduleWatchList[3].succeedTime,
  2037. username0: dataList[i].scheduleWatchList[0].user.name,
  2038. succeedTime0: dataList[i].scheduleWatchList[0].succeedTime,
  2039. username1: dataList[i].scheduleWatchList[1].user.name,
  2040. shiftTime1: dataList[i].scheduleWatchList[1].shiftTime,
  2041. status: dataList[i].status.name
  2042. }
  2043. // dataline.push([exportdata]);
  2044. var rowLine = [];
  2045. angular.forEach(exportdata, function(keyfield) {
  2046. // angular.forEach(data,function(keyfield){
  2047. // if(data[keyfield]){
  2048. rowLine.push(keyfield);
  2049. // }else{
  2050. // rowLine.push("");
  2051. // }
  2052. // })
  2053. // rowData.push(rowLine);
  2054. })
  2055. rowData.push(rowLine);
  2056. rowdata = rowData;
  2057. }
  2058. var csvdata = headers.join(',') + '\r\n';
  2059. // csvdata = csvdata + fieldHeaders.join(',') + '\r\n';
  2060. // csvdata = csvdata + fields.join(',') + '\r\n';
  2061. angular.forEach(rowData, function(line) {
  2062. csvdata = csvdata + line.join(',') + '\r\n';
  2063. })
  2064. csvdata = "\ufeff" + csvdata;
  2065. var file = new Blob([csvdata], {
  2066. type: 'application/csv;charset=utf-8'
  2067. });
  2068. // var filename = $scope.ciclassify.label;
  2069. var fileURL = URL.createObjectURL(file);
  2070. var a = document.createElement('a');
  2071. a.href = fileURL;
  2072. a.target = '_blank';
  2073. a.download = "交接班记录" + '.csv';
  2074. document.body.appendChild(a);
  2075. a.click();
  2076. // }
  2077. $scope.ldloading.expand_right = false;
  2078. // },function(){
  2079. // $scope.ldloading.expand_right = false;
  2080. })
  2081. // }else{
  2082. // SweetAlert.swal({
  2083. // title: "参数不合法!",
  2084. // text: "参数不合法,请选择没有子类的配置项导出!",
  2085. // type: "error"
  2086. // });
  2087. // }
  2088. // }else{
  2089. // SweetAlert.swal({
  2090. // title: "参数不合法!",
  2091. // text: "参数不合法,请选择需要导出的配置项分类!",
  2092. // type: "error"
  2093. // });
  2094. // }
  2095. }
  2096. $scope.today = function() {
  2097. $scope.dt = new Date();
  2098. };
  2099. $scope.today();
  2100. $scope.clear = function() {
  2101. $scope.dt = null;
  2102. };
  2103. // Disable weekend selection
  2104. $scope.disabled = function(date, mode) {
  2105. return (mode === 'day' && (date.getDay() === 0 || date.getDay() === 6));
  2106. };
  2107. // $scope.toggleMin = function () {
  2108. // $scope.minDate = $scope.minDate ? null : new Date();
  2109. // };
  2110. // $scope.toggleMin();
  2111. $scope.open = function($event) {
  2112. $event.preventDefault();
  2113. $event.stopPropagation();
  2114. $scope.opened = !$scope.opened;
  2115. };
  2116. $scope.endOpen = function($event) {
  2117. $event.preventDefault();
  2118. $event.stopPropagation();
  2119. $scope.startOpened = false;
  2120. $scope.endOpened = !$scope.endOpened;
  2121. };
  2122. $scope.startOpen = function($event) {
  2123. $event.preventDefault();
  2124. $event.stopPropagation();
  2125. $scope.endOpened = false;
  2126. $scope.startOpened = !$scope.startOpened;
  2127. };
  2128. $scope.dateOptions = {
  2129. formatYear: 'yy',
  2130. startingDay: 1
  2131. };
  2132. $scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
  2133. $scope.format = $scope.formats[1];
  2134. $scope.hstep = 1;
  2135. $scope.mstep = 15;
  2136. // Time Picker
  2137. $scope.options = {
  2138. hstep: [1, 2, 3],
  2139. mstep: [1, 5, 10, 15, 25, 30]
  2140. };
  2141. $scope.ismeridian = true;
  2142. $scope.toggleMode = function() {
  2143. $scope.ismeridian = !$scope.ismeridian;
  2144. };
  2145. $scope.update = function() {
  2146. var d = new Date();
  2147. d.setHours(14);
  2148. d.setMinutes(0);
  2149. $scope.dt = d;
  2150. };
  2151. $scope.changed = function() {
  2152. $log.log('Time changed to: ' + $scope.dt);
  2153. };
  2154. $scope.clear = function() {
  2155. $scope.dt = null;
  2156. };
  2157. var defaultFilterData = {
  2158. "idx": 0,
  2159. "sum": 10
  2160. };
  2161. $scope.ldloading = {};
  2162. $scope.refreshData = function(style, filterData) {
  2163. // $scope.ldloading[style.replace('-', '_')] = true;
  2164. if (angular.isUndefined(filterData)) {
  2165. filterData = defaultFilterData;
  2166. }
  2167. if (angular.isDefined($scope.searchTypes)) {
  2168. filterData['searchType'] = $scope.searchTypes;
  2169. }
  2170. $scope.myData = [];
  2171. api_bpm_schedule.querySwitch(filterData).then(function(data) {
  2172. var myData = Restangular.stripRestangular(data);
  2173. $scope.gridOptions.totalItems = myData.totalNum;
  2174. $scope.myData = myData.list;
  2175. // $scope.ldloading[style.replace('-', '_')] = false;
  2176. }, function() {
  2177. // $scope.ldloading[style.replace('-', '_')] = false;
  2178. });
  2179. };
  2180. $scope.refreshData('expand-right', defaultFilterData);
  2181. $scope.refresh = function(style, filterData) {
  2182. // $scope.ldloading[style.replace('-', '_')] = true;
  2183. if (angular.isUndefined(filterData)) {
  2184. filterData = defaultFilterData;
  2185. }
  2186. if (angular.isDefined($scope.searchTypes)) {
  2187. filterData['searchType'] = $scope.searchTypes;
  2188. }
  2189. $scope.myData = [];
  2190. api_bpm_schedule.query(filterData).then(function(data) {
  2191. var myData = Restangular.stripRestangular(data);
  2192. $scope.gridOptions.totalItems = myData.totalNum;
  2193. $scope.myData = myData.list;
  2194. // $scope.ldloading[style.replace('-', '_')] = false;
  2195. }, function() {
  2196. // $scope.ldloading[style.replace('-', '_')] = false;
  2197. });
  2198. };
  2199. }]);
  2200. // delete-event-html="'<i class=\'glyphicon glyphicon-remove\'></i>'"
  2201. // edit-event-html="'<i class=\'glyphicon glyphicon-pencil\'></i>'"