1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365 |
- 'use strict';
- app.config(['calendarConfigProvider', function(calendarConfigProvider) {
- calendarConfigProvider.setDateFormatter('moment'); // use moment to format dates
- calendarConfigProvider.setTitleFormats({
- day: 'dddd MMMM DD, YYYY',
- week: '{year}年{week}周',
- month: 'MMMM YYYY',
- year: 'YYYY'
- //day: 'ddd D MMM' //this will configure the day view title to be shorter
- });
- calendarConfigProvider.setI18nStrings({
- eventsLabel: '描述', //This will set the events label on the day view
- timeLabel: '时间', //This will set the time label on the time view
- weekNumber: '{week}周'
- });
- }]);
- /**
- * Controller of the angularBootstrapCalendarApp
- */
- 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) {
- var loginUser = $rootScope.user;
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.allright = false;
- $scope.someright = true;
- for (var obj in $rootScope.user.role) {
- if ($rootScope.user.role[obj].rolecode == 'schedule manager') {
- $scope.allright = true;
- $scope.someright = false;
- }
- }
- var pdKey = $state.current.pdKey;
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- // $scope.gridOptions.useExternalFiltering=true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $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>";
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 50,
- enableFiltering: false
- }, {
- name: 'sourceWatch.watchTime',
- displayName: '换班时间',
- width: '15%',
- enableFiltering: false
- }, {
- name: 'initUser.name',
- displayName: '申请人',
- width: '10%',
- enableFiltering: false
- }, {
- name: 'sourceWatch.scheduleClass.name',
- displayName: '换班班次',
- width: '10%',
- enableFiltering: false
- }, {
- name: 'endWatch.watchTime',
- displayName: '对换时间',
- width: '15%',
- enableFiltering: false
- }, {
- name: 'endWatch.user.name',
- displayName: '对换人员',
- width: '10%',
- enableFiltering: false
- }, {
- name: 'endWatch.scheduleClass.name',
- displayName: '对换班次',
- width: '10%',
- enableFiltering: false
- }, {
- name: 'stage.name',
- displayName: '状态',
- width: '10%',
- enableFiltering: false
- }, {
- name: '操作',
- cellTemplate: '<schedulingoperator item="row.entity" colobject="col">',
- enableFiltering: false
- }];
- // $scope.gridOptions.importerDataAddCallback = function( grid, newObjects ) {
- // $scope.myData = $scope.myData.concat( newObjects );
- // console.log($scope);
- // };
- $scope.refresh = function(style, filterData) {
- var filtersData = {
- "assignee": $rootScope.user.id,
- "candidateGroups": $rootScope.user.group[0].id,
- idx: 0,
- sum: 10
- };
- $scope.gridOptions.refresh();
- $scope.refreshData('expand-right', $scope.fileData);
- };
- $scope.searchstate = "all";
- $scope.onChange = function(searchType) {
- if (searchType && searchType != "") {
- $scope.searchstate = searchType;
- } else {
- $scope.searchstate = "all";
- }
- $scope.fileData.searchType = searchType;
- $scope.refreshData('expand-right', $scope.fileData);
- };
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- // console.log(newPage);
- // console.log(pageSize);
- $rootScope['idx'] = newPage;
- $scope.fileData.idx=newPage - 1;
- $scope.fileData.sum=pageSize;
- $scope.refreshData('expand-right', $scope.fileData);
- });
- // gridApi.core.on.filterChanged($scope, function() {
- // var grid = this.grid;
- // var filtersData = {
- // "assignee":$rootScope.user.id,
- // "candidateGroups":$rootScope.user.group[0].id,
- // "idx":0,
- // "sum":10
- // };
- // angular.forEach(grid.columns,function(item){
- // if(item.enableFiltering){
- // if(angular.isDefined(item.filters[0].term)&&item.filters[0].term!=''){
- // // console.log('item.filters[0]='+JSON.stringify(item.filters[0]));
- // if(angular.isUndefined(filtersData['scheduling'])){
- // filtersData['scheduling']={};
- // }
- // filtersData['scheduling'][item.field]=item.filters[0].term;
- // }
- // }
- // });
- // $scope.refreshData('expand-right', filtersData);
- // });
- // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // //$scope.selected.item = data.entity;
- // console.log(data);
- // });
- };
- // $scope.gridOptions.appScopeProvider = {
- // onDblClick : function(row) {
- // $state.go('app.form.detail',{data:row, formKey:'changeDetail', pdKey:'change'});
- // //var url = '//google.com';
- // //$window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
- // }
- // };
- $scope.selectRowFunction = function(data) {
- // console.log(data);
- // $state.go('app.process.modeler',{modelId:data.id});
- $state.go('app.scheduling.editor', {
- taskId: data.taskId,
- processInstanceId: data.processInstanceId,
- id:data.id
- });
- };
- $scope.onDblClick = function(data) {
- //console.log(row.entity);
- $state.go('app.detail', { formKey: 'schedulingDetail', pdKey: 'schedule', dataId: data.entity.id, taskId: data.entity.taskId, processInstanceId: data.entity.processInstanceId });
- };
- // this.onDblClick = function(row) {
- // //console.log(row.entity);
- // $state.go('app.detail', {
- // formKey: 'schedulingDetail',
- // pdKey: 'scheduling',
- // dataId: row.entity.id
- // });
- // };
- this.removeRowFunction = function(data) {
- //TODO $translate('key')
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除以后,你将不能恢复该数据!",
- type: "warning",
- cancelButtonText: "取消",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确认删除!"
- }, function(isConfirm) {
- if (isConfirm) {
- // api_bpm_domain.removemodel(data.id).then(function(response){
- // if(response){
- // $scope.refreshData();
- // SweetAlert.swal({
- // title: "删除成功!",
- // confirmButtonColor: "#007AFF"
- // });
- // }
- // });
- } else {
- }
- });
- }
- //$scope.callsPending = 0;
- //var i = 0;
- var defaultFilterData = {
- "assignee": $rootScope.user.id,
- // "candidateGroups":$rootScope.user.group[0].id,
- "searchType":"all",
- "idx": 0,
- "sum": 10
- };
- // if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.scheduling)) {
- // defaultFilterData['searchType'] = $rootScope.search.scheduling;
- // $scope.searchTypes = $rootScope.search.scheduling;
- // }
- // if ($rootScope['cmdbs'] != 'scheduling') { $rootScope.idx = 1 }
- // if (angular.isDefined($rootScope.idx) && $rootScope.cmdbs != "false") {
- // $rootScope['cmdbs'] = 'scheduling';
- // defaultFilterData.idx = $rootScope.idx - 1;
- // } else { $rootScope.cmdbs = ""; }
- $scope.fileData={
- "assignee": $rootScope.user.id,
- "searchType":"all",
- "idx": 0,
- "sum": 10
- }
- $scope.ldloading = {};
- $scope.refreshData = function(style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- // defaultFilterData.idx = $rootScope.idx - 1;
- filterData = defaultFilterData;
- }
- // if (angular.isDefined($scope.searchTypes)) {
- // $rootScope['search'] = {};
- // filterData['searchType'] = $scope.searchTypes;
- // $rootScope['search']['scheduling'] = $scope.searchTypes;
- // }
- $scope.myData = [];
- //var start = new Date();
- //var sec = $interval(function () {
- //$scope.callsPending++;
- api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) {
- $scope.callsPending--;
- // console.log('filterData='+JSON.stringify(filterData));
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.resultCount;
- $scope.myData = myData.data;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- $scope.refreshData2 = function(style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- // defaultFilterData.idx = $rootScope.idx - 1;
- filterData = defaultFilterData;
- }
- // if (angular.isDefined($scope.searchTypes)) {
- // $rootScope['search'] = {};
- // filterData['searchType'] = $scope.searchTypes;
- // $rootScope['search']['scheduling'] = $scope.searchTypes;
- // }
- $scope.myData = [];
- //var start = new Date();
- //var sec = $interval(function () {
- //$scope.callsPending++;
- api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) {
- $scope.callsPending--;
- // console.log('filterData='+JSON.stringify(filterData));
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.resultCount;
- $scope.myData = myData.data;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- $scope.refreshData('expand-right', $scope.fileData);
- $scope.timer = $interval(function () {
- $scope.refreshData2('expand-right', $scope.fileData);
- }, $rootScope.refreshTime);
- $scope.$on('$destroy', function () {
- $interval.cancel($scope.timer)
- });
- }]);
- app.controller('SchedulingOperCtrl', ['$rootScope', '$http', '$scope', function($rootScope, $http, $scope, $event) {
- if ($scope.item.handlerUser != null) {
- if ($rootScope.user.id == $scope.item.handlerUser.id) {
- $scope.item.chaozuoPower = true;
- }
- }
- $scope.look = function() {
- $scope.colobject.grid.appScope.onDblClick($scope.item);
- }
- $scope.edit = function() {
- $scope.colobject.grid.appScope.selectRowFunction($scope.item);
- // console.log('$scope.item='+JSON.stringify($scope.item));
- $scope.doEdit($scope.item.id);
- }
- }]);
- app.directive('schedulingoperator', function() {
- return {
- restrict: 'E',
- scope: {
- item: '=',
- colobject: '='
- },
- controller: 'SchedulingOperCtrl',
- template: '<div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
- // '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>' +
- // '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" tooltip="编辑" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>' +
- '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" class="bianjifont">编辑</a>' +
- '</div>'
- };
- });
- /* 我的排班 */
- 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) {
- var loginUser = $rootScope.user;
- //console.log(loginUser);
- calendarConfig.dateFormatter = 'moment';
- calendarConfig.i18nStrings.eventsLabel = '排班描述';
- calendarConfig.i18nStrings.timeLabel = '时间';
- calendarConfig.i18nStrings.weekNumber = '{week}周';
- calendarConfig.allDateFormats = {
- angular: {
- date: {
- hour: 'ha',
- day: 'd MMM',
- month: 'MMMM',
- weekDay: 'EEEE',
- time: 'HH:mm',
- datetime: 'MMM d, h:mm a'
- },
- title: {
- day: 'yyyy MMMM EEEE d',
- week: '{year}年第{week}周',
- month: 'yyyy MMMM',
- year: 'yyyy'
- }
- },
- moment: {
- date: {
- hour: 'ha',
- day: 'MMMDD日',
- month: 'MMMM',
- weekDay: 'dddd',
- time: 'HH:mm',
- datetime: 'MMM D, h:mm a'
- },
- title: {
- day: 'YYYY年MMMMDD日, dddd ',
- week: '{year}年第{week}周',
- month: 'YYYY年MMMM',
- year: 'YYYY'
- }
- }
- };
- moment.locale('zh_cn', {
- months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
- monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
- weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
- weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
- weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
- longDateFormat: {
- LT: 'Ah点mm分',
- LTS: 'Ah点m分s秒',
- L: 'YYYY-MM-DD',
- LL: 'YYYY年MMMD日',
- LLL: 'YYYY年MMMD日Ah点mm分',
- LLLL: 'YYYY年MMMD日ddddAh点mm分',
- l: 'YYYY-MM-DD',
- ll: 'YYYY年MMMD日',
- lll: 'YYYY年MMMD日Ah点mm分',
- llll: 'YYYY年MMMD日ddddAh点mm分'
- },
- meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
- meridiemHour: function(hour, meridiem) {
- if (hour === 12) {
- hour = 0;
- }
- if (meridiem === '凌晨' || meridiem === '早上' ||
- meridiem === '上午') {
- return hour;
- } else if (meridiem === '下午' || meridiem === '晚上') {
- return hour + 12;
- } else {
- // '中午'
- return hour >= 11 ? hour : hour + 12;
- }
- },
- meridiem: function(hour, minute, isLower) {
- var hm = hour * 100 + minute;
- if (hm < 600) {
- return '凌晨';
- } else if (hm < 900) {
- return '早上';
- } else if (hm < 1130) {
- return '上午';
- } else if (hm < 1230) {
- return '中午';
- } else if (hm < 1800) {
- return '下午';
- } else {
- return '晚上';
- }
- },
- calendar: {
- sameDay: function() {
- return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
- },
- nextDay: function() {
- return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
- },
- lastDay: function() {
- return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
- },
- nextWeek: function() {
- var startOfWeek, prefix;
- startOfWeek = moment().startOf('week');
- prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
- return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
- },
- lastWeek: function() {
- var startOfWeek, prefix;
- startOfWeek = moment().startOf('week');
- prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
- return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
- },
- sameElse: 'LL'
- },
- ordinalParse: /\d{1,2}(日|月|周)/,
- ordinal: function(number, period) {
- switch (period) {
- case 'd':
- case 'D':
- case 'DDD':
- return number + '日';
- case 'M':
- return number + '月';
- case 'w':
- case 'W':
- return number + '周';
- default:
- return number;
- }
- },
- relativeTime: {
- future: '%s内',
- past: '%s前',
- s: '几秒',
- m: '1 分钟',
- mm: '%d 分钟',
- h: '1 小时',
- hh: '%d 小时',
- d: '1 天',
- dd: '%d 天',
- M: '1 个月',
- MM: '%d 个月',
- y: '1 年',
- yy: '%d 年'
- },
- week: {
- // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
- dow: 1, // Monday is the first day of the week.
- doy: 4 // The week that contains Jan 4th is the first week of the year.
- }
- });
- //console.log(window.moment().weekdays);
- var date = new Date();
- var d = date.getDate();
- var m = date.getMonth();
- var y = date.getFullYear();
- // console.log(loginUser);
- var filterData = {
- "userId": loginUser.id,
- "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
- "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
- };
- var load = $scope.load = function(filterData) {
- api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response) {
- if (response.status == 200) {
- $scope.events = [];
- // console.log(response.list);
- var myData = response.list;
- angular.forEach(myData, function(item) {
- var eventTemp = {};
- eventTemp.title = item.description;
- // eventTemp.title = item.name;
- eventTemp.type = item.scheduleClass.code;
- eventTemp.startsAt = moment(item['scheduleOrder'].startTime).toDate();
- eventTemp.endsAtTime = moment(item['scheduleOrder'].endTime).toDate();
- eventTemp.startTime = item['scheduleOrder'].startTime;
- eventTemp.endTime = item['scheduleOrder'].endTime;
- //eventTemp.ends_at = moment(item.endTime).toDate();
- eventTemp.id = item.id;
- eventTemp.deletable = false;
- eventTemp.user = item.user;
- $scope.events.push(eventTemp);
- })
- }
- });
- }
- // var load = $scope.load = function(filterData){
- // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
- // console.log("response="+JSON.stringify(response));
- // if(response.status==200){
- // $scope.events = [];
- // console.log(response.list);
- // var myData = response.list;
- // angular.forEach(myData,function(item){
- // var eventTemp = {};
- // eventTemp.title = item.description;
- // eventTemp.type = item.scheduleClass.code;
- // eventTemp.startsAt = moment(item.startTime).toDate();
- // eventTemp.endsAtTime = moment(item.endTime).toDate();
- // eventTemp.startTime = item.startTime;
- // eventTemp.endTime = item.endTime;
- // //eventTemp.ends_at = moment(item.endTime).toDate();
- // eventTemp.id = item.id;
- // eventTemp.deletable = false;
- // eventTemp.users = item.users;
- // $scope.events.push(eventTemp);
- // // console.log("eventTemp="+JSON.stringify(eventTemp));
- // })
- // }
- // });
- // }
- $scope.scheduleClass = {};
- var convertEvent = function(scheduleorder) {
- var eventTemp = {};
- eventTemp.title = scheduleorder.name;
- eventTemp.type = scheduleorder.scheduleClass.code;
- eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
- //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
- eventTemp.id = scheduleorder.id;
- eventTemp.user = scheduleorder.user;
- eventTemp.deletable = false;
- return eventTemp;
- }
- // var convertEvent = function(scheduleorder){
- // var eventTemp = {};
- // eventTemp.title = scheduleorder.description;
- // eventTemp.type = scheduleorder.scheduleClass.code;
- // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
- // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
- // eventTemp.id = scheduleorder.id;
- // eventTemp.users = scheduleorder.users;
- // eventTemp.deletable = false;
- // return eventTemp;
- // }
- // function getdatas() {
- api_bpm_schedule.getScheduleClass().then(function(response) {
- if (response.status == 200) {
- var scheduleClassList = response.list;
- angular.forEach(scheduleClassList, function(item) {
- item.startsAt = moment(item.startTime).format('HH:mm:ss');
- item.endsAt = moment(item.endTime).format('HH:mm:ss');
- // console.log("item.startsAt="+JSON.stringify(item.startsAt))
- // console.log("item.endsAt="+JSON.stringify(item.endsAt))
- $scope.scheduleClass[item['code']] = item;
- })
- }
- })
- // }
- function getalldata() {
- api_bpm_schedule.fetchList(filterData.startTime, filterData.endTime).then(function(response) {
- if (response.status == 200) {
- $scope.events = [];
- // console.log(response.list);
- var myData = response.list;
- angular.forEach(myData, function(item) {
- var eventTemp = {};
- // eventTemp.title = item.name;
- eventTemp.title = item.description;
- eventTemp.type = item.scheduleClass.code;
- eventTemp.startsAt = moment(item.startTime).toDate();
- eventTemp.endsAtTime = moment(item.endTime).toDate();
- eventTemp.startTime = item.startTime;
- eventTemp.endTime = item.endTime;
- //eventTemp.ends_at = moment(item.endTime).toDate();
- eventTemp.id = item.id;
- eventTemp.users = item.users;
- // {
- // title: '白班',
- // type: 'job',
- // starts_at: new Date(y, m, 5, 19, 0),
- // ends_at: new Date(y, m, 5, 22, 30)
- // },
- $scope.events.push(eventTemp);
- })
- }
- });
- }
- getalldata();
- $scope.odr = 2;
- $scope.searchstate = 2;
- $scope.order = function(odr) {
- if (odr == 1) {
- $scope.odr = 1;
- $scope.searchstate = 1;
- $scope.load(filterData);
- } else if (odr == 2) {
- $scope.odr = 2;
- $scope.searchstate = 2;
- getalldata();
- }
- }
- $scope.events = [];
- $scope.calendarView = 'month';
- //$scope.calendarDay = new Date();
- $scope.calendarDate = moment().startOf('month').toDate();
- $scope.timeLabel = "时间";
- $scope.eventLabel = "描述";
- //日历编辑
- function showModal(action, event) {
- // console.log("action="+JSON.stringify(action))
- var modalInstance = $aside.open({
- templateUrl: 'scheduleEvent.html',
- placement: 'right',
- size: 'sm',
- backdrop: true,
- controller: function($scope, $modalInstance, scheduleClass, APIService, MementFormat) {
- $scope.$modalInstance = $modalInstance;
- $scope.action = action;
- $scope.event = event;
- $scope.scheduleClassic = event;
- $scope.$watch('event.type', function(newvalue, oldvalue) {
- // if(oldvalue == newvalue) return;
- // if(scheduleClass[newvalue]){
- var sm = MementFormat(scheduleClass[newvalue].startTime);
- var em = MementFormat(scheduleClass[newvalue].endTime);
- // console.log("sm=" + JSON.stringify(sm))
- event.starts_at = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
- // console.log("event.starts_at=" + JSON.stringify(event.starts_at))
- if (sm.hour() > em.hour()) {
- event.ends_at = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- // console.log("event.ends_at=" + JSON.stringify(event.starts_at))
- } else {
- event.ends_at = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- // console.log("event.ends_at=" + JSON.stringify(event.ends_at))
- }
- // }
- });
- // $scope.ok = function (event) {
- // console.log("event="+JSON.stringify(event))
- // event.action = action;
- // $modalInstance.close(event);
- // };
- $scope.cancel = function(event) {
- $modalInstance.dismiss();
- };
- var acUserSelect = $scope.refreshUser = function(key) {
- //for test
- // $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":"管理层"}]}];
- // return;
- var data = { "idx": "0", "sum": "5",user:{engineer: 1,} };
- if (key) {
- data.user.name = key;
- }
- APIService.fetchDataList('user', data).then(function(response) {
- if (response) {
- if (response.status = 200) {
- $scope.users = response.list;
- // console.log($scope.users);
- }
- }
- })
- };
- if (angular.isDefined(event.users) && event.users.length > 0) {
- }
- $scope.users = [event.user];
- acUserSelect();
- },
- resolve: {
- scheduleClass: function() {
- return $scope.scheduleClass;
- },
- APIService: function() {
- return api_user_data;
- },
- MementFormat: function() {
- return moment;
- }
- }
- });
- modalInstance.result.then(function(selectedEvent) {
- if (selectedEvent.action == 'Clicked') {
- // var data = {
- // "scheduleorder":{
- // "id":selectedEvent.id,
- // "description":selectedEvent.title,
- // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
- // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
- // "users":selectedEvent.users,
- // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
- // }
- // };
- // api_bpm_schedule.update(data).then(function(response){
- // if(response.status==200){
- // SweetAlert.swal({
- // title: "操作成功!",
- // text: "排班更新成功!",
- // type: "succes"
- // });
- // angular.forEach($scope.events,function(item){
- // if(item.id==selectedEvent.id){
- // item = selectedEvent;
- // }
- // })
- // }else{
- // SweetAlert.swal({
- // title: "操作失败",
- // text: "排班更新失败,请稍后重试!",
- // type: "error"
- // })
- // }
- // })
- } else {
- //
- }
- });
- }
- $scope.moment = function(string) {
- return moment(string);
- }
- $scope.eventClicked = function(event) {
- // console.log("event="+JSON.stringify(event))
- showModal('Clicked', event);
- };
- $scope.eventEdited = function(event) {
- showModal('Edited', event);
- };
- //
- var updateViews = function(newvalue, oldvalue) {
- if (oldvalue == newvalue) return;
- var timeStart, timeEnd, timeStartSpan, timeEndSpan;
- if ($scope.calendarView == "year") {
- } else if ($scope.calendarView == "month") {
- // $scope.getmonth=
- timeStart = moment(newvalue).startOf('month');
- timeEnd = moment(newvalue).endOf('month');
- } else if ($scope.calendarView == "week") {
- timeStart = moment(newvalue).startOf('week');
- timeEnd = moment(newvalue).endOf('week');
- } else if ($scope.calendarView == "Day") {
- timeStart = moment(newvalue).startOf('day');
- timeEnd = moment(newvalue).endOf('day');
- }
- timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
- timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
- filterData["startTime"] = timeStartSpan;
- filterData["endTime"] = timeEndSpan;
- $scope.order($scope.odr);
- }
- $scope.$watch('calendarDate', updateViews)
- $scope.next = function() {
- $scope.getmonth = 'nextmonth';
- $scope.calendarControl.next();
- }
- $scope.prev = function() {
- $scope.calendarControl.prev();
- }
- $scope.setCalendarToToday = function() {
- $scope.calendarDay = new Date();
- };
- $scope.toggle = function($event, field, event) {
- $event.preventDefault();
- $event.stopPropagation();
- event[field] = !event[field];
- };
- // $scope.load(filterData);
- }]);
- /* 排班日历 */
- 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) {
- var loginUser = $rootScope.user;
- $scope.xinzeng=false;
- for(var i=0;i<loginUser.menu.length;i++){
- if(loginUser.menu[i].link=="paibanrili_xinzeng"){
- $scope.xinzeng=true
- }
- };
- console.log($scope.bianji);
- var date = new Date();
- var d = date.getDate();
- var m = date.getMonth();
- var y = date.getFullYear();
- // console.log(week);
- calendarConfig.dateFormatter = 'moment';
- calendarConfig.i18nStrings.eventsLabel = '排班描述';
- calendarConfig.i18nStrings.timeLabel = '时间';
- calendarConfig.i18nStrings.weekNumber = '{week}周';
- calendarConfig.allDateFormats = {
- angular: {
- date: {
- hour: 'ha',
- day: 'd MMM',
- month: 'MMMM',
- weekDay: 'EEEE',
- time: 'HH:mm',
- datetime: 'MMM d, h:mm a'
- },
- title: {
- day: 'yyyy MMMM EEEE d',
- week: '{year}年第{week}周',
- month: 'yyyy MMMM',
- year: 'yyyy'
- }
- },
- moment: {
- date: {
- hour: 'ha',
- day: 'MMMDD日',
- month: 'MMMM',
- weekDay: 'dddd',
- time: 'HH:mm',
- datetime: 'MMM D, h:mm a'
- },
- title: {
- day: 'YYYY年MMMMDD日, dddd ',
- week: '{year}年第{week}周',
- month: 'YYYY年MMMM',
- year: 'YYYY'
- }
- }
- };
- moment.locale('zh_cn', {
- months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
- monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
- weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
- weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
- weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
- longDateFormat: {
- LT: 'Ah点mm分',
- LTS: 'Ah点m分s秒',
- L: 'YYYY-MM-DD',
- LL: 'YYYY年MMMD日',
- LLL: 'YYYY年MMMD日Ah点mm分',
- LLLL: 'YYYY年MMMD日ddddAh点mm分',
- l: 'YYYY-MM-DD',
- ll: 'YYYY年MMMD日',
- lll: 'YYYY年MMMD日Ah点mm分',
- llll: 'YYYY年MMMD日ddddAh点mm分'
- },
- meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
- meridiemHour: function(hour, meridiem) {
- if (hour === 12) {
- hour = 0;
- }
- if (meridiem === '凌晨' || meridiem === '早上' ||
- meridiem === '上午') {
- return hour;
- } else if (meridiem === '下午' || meridiem === '晚上') {
- return hour + 12;
- } else {
- // '中午'
- return hour >= 11 ? hour : hour + 12;
- }
- },
- meridiem: function(hour, minute, isLower) {
- var hm = hour * 100 + minute;
- if (hm < 600) {
- return '凌晨';
- } else if (hm < 900) {
- return '早上';
- } else if (hm < 1130) {
- return '上午';
- } else if (hm < 1230) {
- return '中午';
- } else if (hm < 1800) {
- return '下午';
- } else {
- return '晚上';
- }
- },
- calendar: {
- sameDay: function() {
- return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
- },
- nextDay: function() {
- return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
- },
- lastDay: function() {
- return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
- },
- nextWeek: function() {
- var startOfWeek, prefix;
- startOfWeek = moment().startOf('week');
- prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
- return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
- },
- lastWeek: function() {
- var startOfWeek, prefix;
- startOfWeek = moment().startOf('week');
- prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
- return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
- },
- sameElse: 'LL'
- },
- ordinalParse: /\d{1,2}(日|月|周)/,
- ordinal: function(number, period) {
- switch (period) {
- case 'd':
- case 'D':
- case 'DDD':
- return number + '日';
- case 'M':
- return number + '月';
- case 'w':
- case 'W':
- return number + '周';
- default:
- return number;
- }
- },
- relativeTime: {
- future: '%s内',
- past: '%s前',
- s: '几秒',
- m: '1 分钟',
- mm: '%d 分钟',
- h: '1 小时',
- hh: '%d 小时',
- d: '1 天',
- dd: '%d 天',
- M: '1 个月',
- MM: '%d 个月',
- y: '1 年',
- yy: '%d 年'
- },
- week: {
- // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
- dow: 1, // Monday is the first day of the week.
- doy: 4 // The week that contains Jan 4th is the first week of the year.
- }
- });
- var importUploader = $scope.importUploader = new FileUploader({
- url: api_bpm_data.impFileData().getRequestedUrl()
- });
- // importUploader.filters.push({
- // name: 'customFilter',
- // fn: function(item /*{File|FileLikeObject}*/ , options) {
- // var type = item.name.slice(item.name.lastIndexOf('.') + 1);
- // //var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
- // return (type == 'xlsx');
- // }
- // });
- importUploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- importUploader.onAfterAddingFile = function(fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- importUploader.onAfterAddingAll = function(addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- importUploader.onProgressItem = function(fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- importUploader.onProgressAll = function(progress) {
- console.info('onProgressAll', progress);
- };
- importUploader.onSuccessItem = function(fileItem, response, status, headers) {
- $scope.ldloading.expand_right = false;
- SweetAlert.swal({
- title: "导入成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- }, function() {
- $scope.scheduleClass = {};
- $scope.calendarView = 'month';
- $scope.calendarDate = moment().startOf('month').toDate();
- $scope.calendarTitle;
- $scope.externalEvents = [];
- api_bpm_schedule.getScheduleClass().then(function(response) {
- if (response.status == 200) {
- var scheduleClassList = response.list;
- angular.forEach(scheduleClassList, function(item) {
- item.startsAt = moment(item.startTime).format('HH:mm:ss');
- item.endsAt = moment(item.endTime).format('HH:mm:ss');
- $scope.scheduleClass[item['code']] = item;
- var templateEvent = {
- title: item['name'],
- type: item['code'],
- startTime: item.startsAt,
- //starts_at:
- endTime: item.endsAt,
- //ends_at:
- draggable: true,
- deleteFlag: item.deleteFlag
- };
- if (!templateEvent.deleteFlag) {
- $scope.externalEvents.push(templateEvent);
- }
- })
- }
- })
- });
- console.info('onSuccessItem', fileItem, response, status, headers);
- };
- importUploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- SweetAlert.swal({
- title: "系统错误!",
- text: "系统错误,请稍候重试!",
- type: "error"
- });
- };
- importUploader.onCancelItem = function(fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- importUploader.onCompleteItem = function(fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- importUploader.onCompleteAll = function() {
- console.info('onCompleteAll');
- };
- $scope.ldloading = {};
- $scope.import = function() {
- $scope.ldloading.expand_right = true;
- importUploader.onBeforeUploadItem = function(item) {
- console.info('onBeforeUploadItem', item);
- };
- importUploader.uploadAll();
- }
- //导入
- $scope.importopen = function() { //导入触发事件
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/import.html',
- controller: function($scope, $modalInstance, FileUploader) {
- var importUploader = $scope.importUploader = new FileUploader({
- url: api_bpm_data.impFileData().getRequestedUrl()
- });
- // importUploader.filters.push({
- // name: 'customFilter',
- // fn: function(item /*{File|FileLikeObject}*/ , options) {
- // var type = item.name.slice(item.name.lastIndexOf('.') + 1);
- // //var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
- // return (type == 'xlsx');
- // }
- // });
- importUploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- importUploader.onAfterAddingFile = function(fileItem) {
- console.info('onAfterAddingFile', fileItem);
- };
- importUploader.onAfterAddingAll = function(addedFileItems) {
- console.info('onAfterAddingAll', addedFileItems);
- };
- importUploader.onProgressItem = function(fileItem, progress) {
- console.info('onProgressItem', fileItem, progress);
- };
- importUploader.onProgressAll = function(progress) {
- console.info('onProgressAll', progress);
- };
- $rootScope.isMask = false;
- importUploader.onSuccessItem = function(fileItem, response, status, headers) {
- if (response.status == 200) {
- $rootScope.isMask = false;
- SweetAlert.swal({
- title: "导入成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- }, function() {
- $scope.scheduleClass = {};
- $scope.calendarView = 'month';
- $scope.calendarDate = moment().startOf('month').toDate();
- $scope.calendarTitle;
- $scope.externalEvents = [];
- api_bpm_schedule.getScheduleClass().then(function(response) {
- if (response.status == 200) {
- var scheduleClassList = response.list;
- angular.forEach(scheduleClassList, function(item) {
- item.startsAt = moment(item.startTime).format('HH:mm:ss');
- item.endsAt = moment(item.endTime).format('HH:mm:ss');
- $scope.scheduleClass[item['code']] = item;
- var templateEvent = {
- title: item['name'],
- type: item['code'],
- startTime: item.startsAt,
- //starts_at:
- endTime: item.endsAt,
- //ends_at:
- draggable: true,
- deleteFlag: item.deleteFlag
- };
- if (!templateEvent.deleteFlag) {
- $scope.externalEvents.push(templateEvent);
- }
- })
- }
- })
- });
- } else {
- $rootScope.isMask = false;
- SweetAlert.swal({
- title: "导入失败!",
- text: response.error,
- type: "error"
- })
- }
- // console.info('onSuccessItem', fileItem, response, status, headers);
- };
- importUploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- SweetAlert.swal({
- title: "系统错误!",
- text: "系统错误,请稍候重试!",
- type: "error"
- });
- };
- importUploader.onCancelItem = function(fileItem, response, status, headers) {
- console.info('onCancelItem', fileItem, response, status, headers);
- };
- importUploader.onCompleteItem = function(fileItem, response, status, headers) {
- console.info('onCompleteItem', fileItem, response, status, headers);
- };
- importUploader.onCompleteAll = function() {
- console.info('onCompleteAll');
- };
- $scope.ldloading = {};
- $scope.import = function() {
- $modalInstance.dismiss('cancel');
- $rootScope.isMask = true;
- importUploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.formData.push({ 'filename': item.file.name });
- item.formData.push({ 'type': "scheduleOrder" });
- };
- importUploader.uploadAll();
- }
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- importUploader: function() {
- return $scope.importUploader;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {}
- })
- }
- //导出
- $scope.export = function(eventtime) {
- var filadata = { 'sum': 1000, 'idx': 0 };
- $http({
- url: api_bpm_data.downDataModel("scheduleOrder", eventtime.getMonth() + 1).getRequestedUrl(),
- method: 'POST',
- data: JSON.stringify(filadata),
- headers: {
- // 'Content-type': 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- var file = new Blob([data], {
- type: 'application/vnd.ms-excel'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = $scope.calendarTitle + '排班.xls';
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- console.log(data);
- });
- }
- var filterData = {
- //"userId": loginUser.id,
- "startTime": moment(new Date(y, m, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
- "endTime": moment(new Date(y, m + 1, 1, 0, 0)).format('YYYY-MM-DD HH:mm:ss')
- };
- var load = $scope.load = function(filterData) {
- api_bpm_schedule.fetchList(filterData.startTime, filterData.endTime, filterData.userId).then(function(response) {
- if (response.status == 200) {
- $scope.events = [];
- // console.log(response.list);
- var myData = response.list;
- angular.forEach(myData, function(item) {
- var eventTemp = {};
- eventTemp.title = item.description;
- eventTemp.type = item.scheduleClass.code;
- eventTemp.startsAt = moment(item.startTime).toDate();
- eventTemp.endsAtTime = moment(item.endTime).toDate();
- eventTemp.startTime = item.startTime;
- eventTemp.endTime = item.endTime;
- //eventTemp.ends_at = moment(item.endTime).toDate();
- eventTemp.id = item.id;
- eventTemp.users = item.users;
- // {
- // title: '白班',
- // type: 'job',
- // starts_at: new Date(y, m, 5, 19, 0),
- // ends_at: new Date(y, m, 5, 22, 30)
- // },
- $scope.events.push(eventTemp);
- })
- }
- });
- }
- $scope.scheduleClass = {};
- $scope.calendarView = 'month';
- $scope.calendarDate = moment().startOf('month').toDate();
- $scope.calendarTitle;
- $scope.externalEvents = [];
- api_bpm_schedule.getScheduleClass().then(function(response) {
- if (response.status == 200) {
- var scheduleClassList = response.list;
- // console.log(scheduleClassList)
- angular.forEach(scheduleClassList, function(item) {
- item.startsAt = moment(item.startTime).format('HH:mm:ss');
- item.endsAt = moment(item.endTime).format('HH:mm:ss');
- $scope.scheduleClass[item['code']] = item;
- var templateEvent = {
- title: item['name'],
- type: item['code'],
- startTime: item.startsAt,
- //starts_at:
- endTime: item.endsAt,
- person: item.person,
- //ends_at:
- deleteFlag: item.deleteFlag
- };
- if (!templateEvent.deleteFlag) {
- $scope.externalEvents.push(templateEvent);
- }
- })
- }
- })
- $scope.typeTransfer = function(type) {
- return $scope.scheduleClass[type].name;
- }
- $scope.events = [];
- var acUserSelect = $scope.refreshUser = function(key) {
- //for test
- // $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":"管理层"}]}];
- // return;
- var data = { "idx": "0", "sum": "999", "user": { "roledata": { "rolecode": "watch" },engineer: 1, } };
- // console.log(data);
- if (key) {
- data.user['name'] = key
- }
- // console.log(data);
- api_user_data.fetchDataList('user', data).then(function(response) {
- if (response) {
- if (response.status = 200) {
- $scope.users = response.list;
- // console.log($scope.users);
- }
- }
- })
- };
- $scope.users = [];
- acUserSelect();
- $scope.calendarView = 'month';
- $scope.calendarDay = new Date();
- $scope.timeLabel = "时间";
- $scope.eventLabel = "描述";
- var judegeEventByLimit = function(event, compareDay) {
- var ret = true;
- angular.forEach($scope.events, function(item) {
- var day = moment(item.startsAt).startOf('day').format('YYYY-MM-DD');
- if (day == compareDay) {
- if (item.type == event.type) {
- ret = false;
- }
- }
- });
- return ret;
- }
- $scope.eventDropped = function(event, start, end) {
- console.log($scope.xinzeng);
- if(!$scope.xinzeng){
- SweetAlert.swal({
- title: "操作失败",
- text: "对不起,你没有权限新增!",
- type: "error"
- });
- }else{
- var externalIndex = $scope.externalEvents.indexOf(event);
- if (externalIndex > -1) {
- if (angular.isDefined(event.users) && event.users != null && event.users.length <= event.person) {
- var compareDay = moment(start).startOf('day').format('YYYY-MM-DD');
- if (!judegeEventByLimit(event, compareDay)) {
- SweetAlert.swal({
- title: "操作失败",
- text: "当天" + event.title + "已存在, 请纠正后重试!",
- type: "error"
- });
- return;
- }
- //$scope.externalEvents.splice(externalIndex, 1);
- var bm = moment(moment(start).startOf('day').format('YYYY-MM-DD') + ' ' + event.startTime);
- var em = moment(moment(start).startOf('day').format('YYYY-MM-DD') + ' ' + event.endTime);
- event.startsAt = bm.toDate();
- //console.log(JSON.stringify(event) + "start" + start + " end" + end);
- var endTime = '';
- var startTime = '';
- if (bm.hour() > em.hour()) {
- endTime = (moment(start).startOf('day').add('day', 1).format('YYYY-MM-DD') + ' ' + event.endTime);
- } else {
- endTime = (moment(start).startOf('day').format('YYYY-MM-DD') + ' ' + event.endTime);
- }
- startTime = (moment(start).startOf('day').format('YYYY-MM-DD') + ' ' + event.startTime);
- var data = {
- "scheduleorder": {
- "description": event.title,
- "startTime": startTime,
- "endTime": endTime,
- "users": event.users,
- "scheduleClass": { "id": $scope.scheduleClass[event.type].id }
- }
- };
- //event.endTime = "";
- // event.startTime = "";
- api_bpm_schedule.add(data).then(function(response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "操作成功!",
- text: "新建排班成功!",
- type: "succes"
- });
- var myData = response.data;
- event.id = myData.id;
- $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 });
- } else {
- SweetAlert.swal({
- title: "操作失败",
- text: "新建排班失败,请稍后重试!",
- type: "error"
- })
- }
- })
- } else {
- SweetAlert.swal({
- title: "操作失败",
- text: "请选择" + event.person + "位值班人",
- type: "error"
- });
- }
- }
- }
- //console.log("new eventDropped")
- };
- function showModal(action, event) {
- var modalInstance = $aside.open({
- templateUrl: 'calendarEvent.html',
- placement: 'right',
- size: 'sm',
- backdrop: true,
- controller: function($scope, $modalInstance, scheduleClass, APIService, MementFormat, Alert, EventsData,moment) {
- var loginUser = $rootScope.user;
- $scope.shanchu=false;
- $scope.bianji=false;
- for(var i=0;i<loginUser.menu.length;i++){
- if(loginUser.menu[i].link=="paibanrili_shanchu"){
- $scope.shanchu=true
- }
- if(loginUser.menu[i].link=="paibanrili_bianji"){
- $scope.bianji=true
- }
- };
- $scope.$modalInstance = $modalInstance;
- $scope.action = action;
- event.startsAt = moment(event.startsAt).format('YYYY-MM-DD HH:mm:ss');
- event.endsAtTime = moment(event.startsAt).format('YYYY-MM-DD HH:mm:ss');
- $scope.event = event;
- console.log(event);
- $scope.scheduleClassic = event.tilte;
- $scope.currentDate = MementFormat().toDate();
- $scope.$watch('event.type', function(newvalue, oldvalue) {
- if (oldvalue == newvalue) return;
- if (scheduleClass[newvalue]) {
- var sm = MementFormat(scheduleClass[newvalue].startTime);
- var em = MementFormat(scheduleClass[newvalue].endTime);
- event.startsAt = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
- 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');
- event.title = scheduleClass[newvalue].name;
- if (sm.hour() > em.hour()) {
- 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');
- event.endsAtTime = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- } else {
- 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');
- event.endsAtTime = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- }
- }
- });
- $scope.$watch('event.startsAt', function(newvalue, oldvalue) {
- if (oldvalue == newvalue) return;
- if (MementFormat(oldvalue).format('YYYY-MM-DD HH:mm:ss') == MementFormat(newvalue).format('YYYY-MM-DD HH:mm:ss')) return;
- if (scheduleClass[event.type]) {
- var sm = MementFormat(scheduleClass[event.type].startTime);
- var em = MementFormat(scheduleClass[event.type].endTime);
- //event.starts_at = MementFormat(event.starts_at).startOf('day').add(sm.hour(),'hour').add(sm.minute(),'minute').add(sm.second(),'second').toDate();
- if (sm.hour() > em.hour()) {
- 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');
- event.endsAtTime = MementFormat(event.startsAt).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- } else {
- 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');
- event.endsAtTime = MementFormat(event.startsAt).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- }
- }
- });
- $scope.setEndOpen = function() {
- if (scheduleClass[event.type]) {
- var sm = MementFormat(scheduleClass[event.type].startTime);
- var em = MementFormat(scheduleClass[event.type].endTime);
- event.startsAt = MementFormat(event.startTime).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
- if (sm.hour() > em.hour()) {
- 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');
- event.endsAtTime = MementFormat(event.startTime).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- } else {
- 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');
- event.endsAtTime = MementFormat(event.startTime).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- }
- }
- }
- //同一天只能排出一个白班一个夜班
- function judegeEventByLimit(event) {
- var ret = true;
- var compareDay = moment(event.startsAt).startOf('day').format('YYYY-MM-DD');
- angular.forEach(EventsData, function(item) {
- var day = moment(item.startsAt).startOf('day').format('YYYY-MM-DD');
- if (day == compareDay) {
- if (angular.isDefined(event.id)) {
- if (item.type == event.type && event.id != item.id) ret = false;
- } else {
- if (item.type == event.type) ret = false;
- }
- }
- });
- return ret;
- }
- $scope.ok = function(event) {
- // console.log("event="+JSON.stringify(event));
- if (angular.isDefined(event.users) && event.users != null) {
- if (judegeEventByLimit(event)) {
- event.action = action;
- $modalInstance.close(event);
- } else {
- Alert.swal({
- title: "操作失败",
- text: "同一天只能排出一个白班一个夜班, 请纠正后重试!",
- type: "error"
- })
- }
- } else {
- Alert.swal({
- title: "操作失败",
- text: "请填写值班人",
- type: "error"
- })
- }
- };
- $scope.deleteEvent = function(event) {
- event.action = "Deleted";
- $modalInstance.close(event);
- };
- $scope.refreshModalUser = function(key) {
- //for test
- // $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":"管理层"}]}];
- // return;
- var data = { "idx": "0", "sum": "999", "user": { "roledata": { "rolecode": "watch" },engineer: 1, } };
- if (key) {
- data.user['name'] = key
- }
- console.log(data);
- APIService.fetchDataList('user', data).then(function(response) {
- if (response) {
- // console.log("response=" + JSON.stringify(response))
- if (response.status = 200) {
- $scope.modalusers = response.list;
- console.log($scope.users);
- }
- }
- })
- };
- $scope.users = [];
- $scope.refreshModalUser();
- },
- resolve: {
- scheduleClass: function() {
- return $scope.scheduleClass;
- },
- APIService: function() {
- return api_user_data;
- },
- MementFormat: function() {
- return moment;
- },
- Alert: function() {
- return SweetAlert;
- },
- EventsData: function() {
- return $scope.events;
- }
- }
- });
- modalInstance.result.then(function(selectedEvent) {
- if (selectedEvent.action == 'Edited') {
- //new
- var data = {
- "scheduleorder": {
- "description": selectedEvent.title,
- "startTime": selectedEvent.startTime,
- "endTime": selectedEvent.endTime,
- "users": selectedEvent.users,
- "scheduleClass": { "id": $scope.scheduleClass[selectedEvent.type].id }
- }
- };
- api_bpm_schedule.add(data).then(function(response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "操作成功!",
- text: "新建排班成功!",
- type: "succes"
- });
- $scope.events.push(convertEvent(response.data));
- // angular.forEach($scope.events,function(item){
- // if(item.id==selectedEvent.id){
- // item = selectedEvent;
- // }
- // })
- } else {
- SweetAlert.swal({
- title: "操作失败",
- text: "新建排班失败,请稍后重试!",
- type: "error"
- })
- }
- })
- } else if (selectedEvent.action == 'Clicked') {
- if(typeof(selectedEvent.startTime)!="string"){
- selectedEvent.startTime=moment(selectedEvent.startTime.getTime()).format('YYYY-MM-DD HH:mm:ss')
- }
- if(typeof(selectedEvent.endTime)!="string"){
- selectedEvent.endTime=moment(selectedEvent.endTime.getTime()).format('YYYY-MM-DD HH:mm:ss')
- }
- var data = {
- "scheduleorder": {
- "id": selectedEvent.id,
- "description": selectedEvent.title,
- "startTime":selectedEvent.startTime,
- "endTime": selectedEvent.endTime,
- "users": selectedEvent.users,
- "scheduleClass": { "id": $scope.scheduleClass[selectedEvent.type].id }
- }
- };
- api_bpm_schedule.update(data).then(function(response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "操作成功!",
- text: "排班更新成功!",
- type: "succes"
- });
- angular.forEach($scope.events, function(item) {
- if (item.id == selectedEvent.id) {
- item = selectedEvent;
- }
- })
- } else {
- SweetAlert.swal({
- title: "操作失败",
- text: "排班更新失败,请稍后重试!",
- type: "error"
- })
- }
- })
- } else {
- $scope.eventDeleted(selectedEvent);
- }
- });
- }
- $scope.moment = function(string) {
- return moment(string);
- }
- $scope.eventClicked = function(event) {
- showModal('Clicked', event);
- };
- $scope.addEvent = function() {
- var sm = moment($scope.scheduleClass['job'].startTime);
- var em = moment($scope.scheduleClass['job'].endTime);
- var newevent = {
- title: $scope.scheduleClass['job'].name,
- type: $scope.scheduleClass['job'].code,
- user: loginUser
- };
- newevent.startsAt = moment($scope.calendarDay).startOf('day').add(sm.hour(), 'hour').add(sm.minute(), 'minute').add(sm.second(), 'second').toDate();
- 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');
- if (sm.hour() > em.hour()) {
- 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');
- newevent.endsAtTime = moment($scope.calendarDay).startOf('day').add(1, 'day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- //newevent.ends_at = moment($scope.calendarDay).startOf('day').add(1, 'day').add(em.hour(),'hour').add(em.minute(),'minute').add(em.second(),'second').toDate();
- } else {
- 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');
- newevent.endsAtTime = moment($scope.calendarDay).startOf('day').add(em.hour(), 'hour').add(em.minute(), 'minute').add(em.second(), 'second').toDate();
- //newevent.ends_at = moment($scope.calendarDay).startOf('day').add(em.hour(),'hour').add(em.minute(),'minute').add(em.second(),'second').toDate();
- }
- $scope.eventEdited(newevent);
- };
- $scope.eventEdited = function(event) {
- showModal('Edited', event);
- };
- $scope.eventDeleted = function(event) {
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function(isConfirm) {
- if (isConfirm) {
- api_bpm_schedule.remove([event.id]).then(function(response) {
- if (response.status == 200) {
- $scope.events.splice(event.$id, 1);
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- } else {
- SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
- }
- });
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- };
- //$scope.timeStart;
- //$scope.timeEnd;
- var updateView = function(newvalue, oldvalue) {
- if (oldvalue == newvalue) return;
- if (moment(oldvalue).format('YYYY-MM-DD HH:mm:ss') == moment(newvalue).format('YYYY-MM-DD HH:mm:ss')) return;
- var timeStart, timeEnd, timeStartSpan, timeEndSpan;
- if ($scope.calendarView == "year") {
- } else if ($scope.calendarView == "month") {
- timeStart = moment(newvalue).startOf('month');
- timeEnd = moment(newvalue).endOf('month');
- } else if ($scope.calendarView == "week") {
- timeStart = moment(newvalue).startOf('week');
- timeEnd = moment(newvalue).endOf('week');
- } else if ($scope.calendarView == "Day") {
- timeStart = moment(newvalue).startOf('day');
- timeEnd = moment(newvalue).endOf('day');
- }
- timeStartSpan = timeStart.format('YYYY-MM-DD HH:mm:ss');
- timeEndSpan = timeEnd.format('YYYY-MM-DD HH:mm:ss');
- filterData["startTime"] = timeStartSpan;
- filterData["endTime"] = timeEndSpan;
- load(filterData);
- }
- $scope.$watch('calendarDate', updateView)
- $scope.next = function() {
- $scope.calendarControl.next();
- }
- $scope.prev = function() {
- $scope.calendarControl.prev();
- }
- $scope.setCalendarToToday = function() {
- $scope.calendarDay = new Date();
- };
- $scope.toggle = function($event, field, event) {
- $event.preventDefault();
- $event.stopPropagation();
- event[field] = !event[field];
- };
- $scope.load(filterData);
- }]);
- /* 换班记录 */
- 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) {
- var loginUser = $rootScope.user;
- $scope.shiftes = [];
- var load = function() {
- $scope.shiftes = [];
- api_bpm_schedule.queryHandleoutSwitch(loginUser.id).then(function(response) {
- if (response) {
- var myData = Restangular.stripRestangular(response);
- angular.forEach(myData.list, function(item) {
- $scope.shiftes.push(item);
- })
- }
- })
- }
- $scope.getShiftType = function(shift) {
- var ret = "error";
- if (shift.scheduleOrderDTO.status.id == 2) {
- ret = "import";
- }
- if (shift.scheduleOrderDTO.status.id == 4) {
- ret = "upload";
- }
- return ret;
- }
- // var getShift = function(){
- // angular.forEach($scope.shiftes, function(item){
- // if(item.user.id==loginUser.id){
- // return item;
- // }
- // })
- // }
- var getShift = function() {
- var ret = null;
- angular.forEach($scope.shiftes, function(item) {
- if (item.user.id == loginUser.id && (item.status.id == 1 || item.status.id == 2) && ret == null) {
- ret = item;
- }
- })
- return ret;
- }
- $scope.getHandle = function() {
- var ret = "error";
- var shift;
- var index = 0;
- //angular.forEach($scope.shiftes, function(item){
- for (var index1 in $scope.shiftes) {
- //shift = item;
- var item = $scope.shiftes[index1];
- //console.log(item.user.id +"==" +loginUser.id + "shift.status.id"+shift.status.id + " " + shift.scheduleOrderDTO.status.id );
- if (item.user.id == loginUser.id) {
- shift = item;
- //console.log(shift.status.id);
- if (shift.status.id == 1) {
- //console.log("shift.scheduleOrderDTO.status.id="+shift.scheduleOrderDTO.status.id);
- if (shift.scheduleOrderDTO.status.id == 2) {
- ret = "import";
- }
- } else if (shift.status.id == 2) {
- if (shift.scheduleOrderDTO.status.id == 4) {
- ret = "upload";
- break;
- //return;
- }
- }
- //return ret;
- }
- if (item.status.id == 5) {
- index++;
- }
- //});
- }
- //console.log(index)
- if (ret == 'import' && index != 2) {
- ret = 'uploadDes';
- }
- console.log(ret);
- return ret;
- }
- $scope.importShift = function() {
- var shift = getShift();
- var data = {};
- if (shift.status.id == 1) {
- data.status = {};
- data.status.id = 4;
- }
- data.id = shift.id;
- api_bpm_schedule.handleSchedule(data).then(function(response) {
- if (response) {
- var myData = Restangular.stripRestangular(response);
- if (response.status == 200) {
- SweetAlert.swal("接班成功!", "接班成功!", "success");
- load();
- } else {
- SweetAlert.swal("接班失败!", "接班失败,请稍候重试", "error");
- }
- }
- })
- }
- $scope.uploadShift = function() {
- var shift = getShift();
- var data = {};
- if (shift.status.id == 2) {
- data.status = {};
- data.status.id = 5;
- }
- data.id = shift.id;
- api_bpm_schedule.handleSchedule(data).then(function(response) {
- if (response) {
- var myData = Restangular.stripRestangular(response);
- if (response.status == 200) {
- SweetAlert.swal("交班成功!", "交班成功!", "success");
- load();
- } else {
- SweetAlert.swal("交班失败!", "交班失败,请稍候重试", "error");
- }
- }
- })
- }
- load();
- // api_bpm_schedule.queryRecieveSwitch(loginUser.id).then(function(response){
- // if(response){
- // var myData = Restangular.stripRestangular(response);
- // angular.forEach(myData.list, function(item){
- // $scope.shiftes.push(item);
- // })
- // }
- // })
- }]);
- /* 换班申请 */
- 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) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- //$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>";
- //
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [{
- name: 'orderTime',
- displayName: '日期',
- width: 100
- }, {
- name: 'scheduleClass.name',
- displayName: '班次',
- width: 80,
- enableFiltering: false
- },
- {
- name: 'scheduleWatchList[2].user.name',
- displayName: '第一交班人',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'scheduleWatchList[2].shiftTime',
- displayName: '交班时间',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'scheduleWatchList[3].user.name',
- displayName: '第二交班人',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'scheduleWatchList[3].shiftTime',
- displayName: '交班时间',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'scheduleWatchList[0].user.name',
- displayName: '第一接班人',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'scheduleWatchList[0].succeedTime',
- displayName: '接班时间',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'scheduleWatchList[1].user.name',
- displayName: '第二接班人',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'scheduleWatchList[1].succeedTime',
- displayName: '接班时间',
- width: 180,
- enableFiltering: false
- },
- {
- name: 'status.name',
- displayName: '状态',
- width: 100,
- enableFiltering: false
- }
- ];
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- console.log(newPage);
- console.log(pageSize);
- $scope.refreshData('expand-right', {
- "idx": newPage - 1,
- "sum": pageSize
- });
- });
- gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- //$scope.selected.item = data.entity;
- console.log(data);
- });
- // gridApi.core.on.filterChanged($scope, function() {
- // var grid = this.grid;
- // var filtersData = {
- // idx:0,
- // sum:10
- // };
- // angular.forEach(grid.columns,function(item){
- // if(item.enableFiltering){
- // if(angular.isDefined(item.filters[0].term)&&item.filters[0].term!=''){
- // // console.log('item.filters[0]='+JSON.stringify(item.filters[0]));
- // if(angular.isUndefined(filtersData['scheduling'])){
- // filtersData['scheduling']={};
- // }
- // filtersData['scheduling'][item.field]=item.filters[0].term;
- // }
- // }
- // });
- // $scope.memoryfilterData = filtersData;
- // $scope.refreshData('expand-right', filtersData);
- // });
- };
- this.selectRowFunction = function(data) {
- console.log(data);
- // $state.go('app.process.modeler',{modelId:data.id});
- $state.go('app.scheduling.editor', {
- taskId: data.taskId,
- processInstanceId: data.processInstanceId
- });
- };
- $scope.search = function(start, end) {
- var filtersData = {
- "scheduleorder": { "type": "4" },
- idx: 0,
- sum: 10
- };
- if (angular.isDefined(start) || angular.isDefined(end)) {
- filtersData.scheduleorder['startTime'] = moment(start).format('YYYY-MM-DD HH:mm:ss');
- // filtersData.scheduleorder['endTime']=moment(end).format('YYYY-MM-DD HH:mm:ss');
- var timedata = new Date(end).getTime() + 86400000;
- var d = new Date(timedata)
- filtersData.scheduleorder['endTime'] = moment(d).format('YYYY-MM-DD HH:mm:ss');
- console.log(timedata)
- }
- $scope.memoryfilterData = filtersData;
- $scope.refresh('expand-right', filtersData);
- }
- $scope.ldloading = false;
- $scope.export = function(start, end) {
- $scope.ldloading.expand_right = true;
- var filtersData = {
- scheduleorder: { "type": "4" },
- idx: 0,
- sum: 1000
- };
- if (angular.isDefined(start) || angular.isDefined(end)) {
- filtersData.scheduleorder['startTime'] = moment(start).format('YYYY-MM-DD HH:mm:ss');
- var timedata = new Date(end).getTime() + 86400000;
- var d = new Date(timedata)
- filtersData.scheduleorder['endTime'] = moment(d).format('YYYY-MM-DD HH:mm:ss');
- }
- // if(angular.isDefined($scope.ciclassify)&&$scope.ciclassify!=null){
- // if(angular.isUndefined($scope.ciclassify.children)||$scope.ciclassify.children.length==0){
- api_bpm_schedule.query(filtersData).then(function(data) {
- var dataList = Restangular.stripRestangular(data).list;
- // if(dataList&&(dataList.list.length>=1)){
- var headers = [];
- var fieldHeaders = [];
- var exportdata = [];
- var fields = [];
- var rowData = [];
- var rowdata = [];
- if ($scope.gridOptions.columnDefs.length > 0) {
- angular.forEach($scope.gridOptions.columnDefs, function(prop) {
- headers.push(prop.displayName);
- // angular.forEach(prop.form.fields, function(field, index){
- // fieldHeaders.push(field.templateOptions.label);
- // fields.push(field.key);
- // if(index!=0){
- // headers.push("");
- // }
- // });
- })
- }
- var rowLine = [];
- var dataline = [];
- for (var i = 0; i < dataList.length; i++) {
- if (angular.isUndefined(dataList[i].scheduleWatchList[0])) { dataList[i].scheduleWatchList[0] = {} }
- if (angular.isUndefined(dataList[i].scheduleWatchList[1])) { dataList[i].scheduleWatchList[1] = {} }
- if (angular.isUndefined(dataList[i].scheduleWatchList[2])) { dataList[i].scheduleWatchList[2] = {} }
- if (angular.isUndefined(dataList[i].scheduleWatchList[3])) { dataList[i].scheduleWatchList[3] = {} }
- if (angular.isUndefined(dataList[i].scheduleWatchList[2].user)) { dataList[i].scheduleWatchList[2].user = "" }
- if (angular.isUndefined(dataList[i].scheduleWatchList[2].shiftTime)) { dataList[i].scheduleWatchList[2].shiftTime = "" }
- if (angular.isUndefined(dataList[i].scheduleWatchList[1].user)) { dataList[i].scheduleWatchList[1].user = "" }
- if (angular.isUndefined(dataList[i].scheduleWatchList[1].succeedTime)) { dataList[i].scheduleWatchList[1].succeedTime = "" }
- if (angular.isUndefined(dataList[i].scheduleWatchList[0].user)) { dataList[i].scheduleWatchList[0].user = "" }
- if (angular.isUndefined(dataList[i].scheduleWatchList[0].succeedTime)) { dataList[i].scheduleWatchList[0].succeedTime = "" }
- if (angular.isUndefined(dataList[i].scheduleWatchList[3].user)) { dataList[i].scheduleWatchList[3].user = "" }
- if (angular.isUndefined(dataList[i].scheduleWatchList[3].shiftTime)) { dataList[i].scheduleWatchList[3].shiftTime = "" }
- exportdata = {
- orderTime: dataList[i].orderTime,
- scheduleClass: dataList[i].scheduleClass.name,
- username2: dataList[i].scheduleWatchList[2].user.name,
- shiftTime2: dataList[i].scheduleWatchList[2].shiftTime,
- username3: dataList[i].scheduleWatchList[3].user.name,
- succeedTime3: dataList[i].scheduleWatchList[3].succeedTime,
- username0: dataList[i].scheduleWatchList[0].user.name,
- succeedTime0: dataList[i].scheduleWatchList[0].succeedTime,
- username1: dataList[i].scheduleWatchList[1].user.name,
- shiftTime1: dataList[i].scheduleWatchList[1].shiftTime,
- status: dataList[i].status.name
- }
- // dataline.push([exportdata]);
- var rowLine = [];
- angular.forEach(exportdata, function(keyfield) {
- // angular.forEach(data,function(keyfield){
- // if(data[keyfield]){
- rowLine.push(keyfield);
- // }else{
- // rowLine.push("");
- // }
- // })
- // rowData.push(rowLine);
- })
- rowData.push(rowLine);
- rowdata = rowData;
- }
- var csvdata = headers.join(',') + '\r\n';
- // csvdata = csvdata + fieldHeaders.join(',') + '\r\n';
- // csvdata = csvdata + fields.join(',') + '\r\n';
- angular.forEach(rowData, function(line) {
- csvdata = csvdata + line.join(',') + '\r\n';
- })
- csvdata = "\ufeff" + csvdata;
- var file = new Blob([csvdata], {
- type: 'application/csv;charset=utf-8'
- });
- // var filename = $scope.ciclassify.label;
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = "交接班记录" + '.csv';
- document.body.appendChild(a);
- a.click();
- // }
- $scope.ldloading.expand_right = false;
- // },function(){
- // $scope.ldloading.expand_right = false;
- })
- // }else{
- // SweetAlert.swal({
- // title: "参数不合法!",
- // text: "参数不合法,请选择没有子类的配置项导出!",
- // type: "error"
- // });
- // }
- // }else{
- // SweetAlert.swal({
- // title: "参数不合法!",
- // text: "参数不合法,请选择需要导出的配置项分类!",
- // type: "error"
- // });
- // }
- }
- $scope.today = function() {
- $scope.dt = new Date();
- };
- $scope.today();
- $scope.clear = function() {
- $scope.dt = null;
- };
- // Disable weekend selection
- $scope.disabled = function(date, mode) {
- return (mode === 'day' && (date.getDay() === 0 || date.getDay() === 6));
- };
- // $scope.toggleMin = function () {
- // $scope.minDate = $scope.minDate ? null : new Date();
- // };
- // $scope.toggleMin();
- $scope.open = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $scope.endOpen = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- $scope.dateOptions = {
- formatYear: 'yy',
- startingDay: 1
- };
- $scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
- $scope.format = $scope.formats[1];
- $scope.hstep = 1;
- $scope.mstep = 15;
- // Time Picker
- $scope.options = {
- hstep: [1, 2, 3],
- mstep: [1, 5, 10, 15, 25, 30]
- };
- $scope.ismeridian = true;
- $scope.toggleMode = function() {
- $scope.ismeridian = !$scope.ismeridian;
- };
- $scope.update = function() {
- var d = new Date();
- d.setHours(14);
- d.setMinutes(0);
- $scope.dt = d;
- };
- $scope.changed = function() {
- $log.log('Time changed to: ' + $scope.dt);
- };
- $scope.clear = function() {
- $scope.dt = null;
- };
- var defaultFilterData = {
- "idx": 0,
- "sum": 10
- };
- $scope.ldloading = {};
- $scope.refreshData = function(style, filterData) {
- // $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- if (angular.isDefined($scope.searchTypes)) {
- filterData['searchType'] = $scope.searchTypes;
- }
- $scope.myData = [];
- api_bpm_schedule.querySwitch(filterData).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- // $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- // $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- $scope.refreshData('expand-right', defaultFilterData);
- $scope.refresh = function(style, filterData) {
- // $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- if (angular.isDefined($scope.searchTypes)) {
- filterData['searchType'] = $scope.searchTypes;
- }
- $scope.myData = [];
- api_bpm_schedule.query(filterData).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- // $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- // $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- }]);
- // delete-event-html="'<i class=\'glyphicon glyphicon-remove\'></i>'"
- // edit-event-html="'<i class=\'glyphicon glyphicon-pencil\'></i>'"
|