123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- 'use strict';
- /**
- * controller for User Profile Example
- */
- app.controller('woketimeCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_schedule", "api_bpm_data", "api_wechatfile", function($rootScope, $scope, $state, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_schedule, api_bpm_data, api_wechatfile) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- var loginUser = $rootScope.user;
- $scope.xinzeng=false;
- $scope.shanchu=false;
- $scope.bianji=false;
- for(var i=0;i<loginUser.menu.length;i++){
- if(loginUser.menu[i].link=="gongzuoshijianshezhi_xinzeng"){
- $scope.xinzeng=true
- }
- if(loginUser.menu[i].link=="gongzuoshijianshezhi_shanchu"){
- $scope.shanchu=true
- }
- if(loginUser.menu[i].link=="gongzuoshijianshezhi_bianji"){
- $scope.bianji=true
- }
- }
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $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.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.transfer = function(deleteFlag) {
- if (deleteFlag == true) { return "是" } else { return "否" }
- }
- $scope.transferstatus = function(deleteFlag) {
- if (deleteFlag == true) { return "停用" } else { return "使用" }
- }
- $scope.translate = function(item) {
- return item?moment(item).format('HH:mm'):''
- }
- $scope.gridOptions.columnDefs = [
- { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
- { name: 'name', displayName: '班次', width: '8%', enableFiltering: false },
- {
- name: 'startTime',
- displayName: '开始时间',
- width: '8%',
- enableFiltering: false,
- cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.translate(row.entity.startTime)}}</div>'
- },
- {
- name: 'endTime',
- displayName: '结束时间',
- width: '8%',
- enableFiltering: false,
- cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.translate(row.entity.endTime)}}</div>'
- },
- { name: 'person', displayName: '本班次人数', width: '8%', enableFiltering: false },
- { name: 'dictionaryDTO.name', displayName: '季节', width: '8%', enableFiltering: false },
- { name: 'description', displayName: '班次描述', width: '10%', enableFiltering: false },
- { name: 'deleteFlag', displayName: '使用状态', width: '8%', enableFiltering: false, cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.transferstatus(row.entity.deleteFlag)}}</div>' },
- { name: 'isTemplate', displayName: '是否为模版', width: '8%', enableFiltering: false, cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.transfer(row.entity.isTemplate)}}</div>' },
- { name: 'sendMsg', displayName: '是否值班提醒', width: '8%', enableFiltering: false, cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.transfer(row.entity.sendMsg)}}</div>' },
- { name: 'sendTime', displayName: '每日发送时间', width: '8%', enableFiltering: false, cellTemplate: '<div class="ui-grid-cell-contents">{{grid.appScope.translate(row.entity.sendTime)}}</div>' },
- {
- name: '编辑',
- cellTemplate: '<div><div class="links cl-effect-1 ui-grid-cell-contents" >' +
- '<a ng-click="grid.appScope.saveData(row.entity)" ng-show="grid.appScope.bianji" class="bianjifont">编辑</a>' +
- '</div></div>',
- enableFiltering: false
- },
- ];
- $scope.saveData = function(selectdata) {
- selectdata = angular.copy(selectdata);
- var modalInstance = $modal.open({
- resolve: {
- scope: function () {
- return $scope;
- }
- },
- templateUrl: 'assets/views/system/tpl/systemworktime.html',
- controller: function($scope, scope, $modalInstance, api_bpm_data) {
- $scope.title = "修改班次";
- $scope.worktimedata = {};
- selectdata.sendMsg = selectdata.sendMsg?selectdata.sendMsg:0;
- selectdata.sendTime = selectdata.sendTime?moment(selectdata.sendTime).format('YYYY-MM-DD HH:mm:ss'):moment().format('YYYY-MM-DD HH:mm:ss');
- $scope.worktimedata = angular.copy(selectdata);
- $scope.dictionary = [];
- api_wechatfile.getDictionary({ "type": "list", "key": "incident_scheduleclass" }).then(function(data) {
- if (data) {
- $scope.dictionary = data;
- }
- })
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- $scope.savercode = function(worktimedata) {
- var fildata = {
- "scheduleclass": {
- "id": worktimedata.id,
- // "code": worktimedata.code,
- "name": worktimedata.name,
- "person": worktimedata.person,
- "description": worktimedata.description,
- "startTime": moment(worktimedata.startTime).format('YYYY-MM-DD HH:mm:ss'),
- "endTime": moment(worktimedata.endTime).format('YYYY-MM-DD HH:mm:ss'),
- "shiftTime": worktimedata.shiftTime,
- "succeedTime": worktimedata.succeedTime,
- "dictionaryDTO": worktimedata.dictionaryDTO,
- "isTemplate": worktimedata.isTemplate,
- "deleteFlag": worktimedata.deleteFlag,
- "sendMsg": worktimedata.sendMsg,
- "sendTime": worktimedata.sendMsg == 1?(worktimedata.sendTime?moment(worktimedata.sendTime).format('YYYY-MM-DD HH:mm:ss'):moment().format('YYYY-MM-DD HH:mm:ss')):undefined
- }
- }
- // api_wechatfile.getDictionary({ "type": "list", "key": "incident_scheduleclass" }).then(function(data) {
- // if (data.status == 200) {
- // $scope.dictionary = data;
- // }
- // })
- api_bpm_data.updData('scheduleclass', fildata).then(function(response) {
- if (response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "修改成功!",
- type: "success"
- }, function() {
- scope.refreshData('expand-right');
- })
- } else {
- SweetAlert.swal({
- title: "修改失败!",
- type: "error"
- })
- }
- }
- })
- $modalInstance.close();
- }
- }
- });
- }
- $scope.addData = function() {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/system/tpl/systemworktime.html',
- controller: function($scope, $modalInstance, api_bpm_data) {
- $scope.title = "新增班次";
- $scope.dictionary = [];
- api_wechatfile.getDictionary({ "type": "list", "key": "incident_scheduleclass" }).then(function(data) {
- if (data) {
- $scope.dictionary = data;
- }
- })
- $scope.worktimedata = { "startTime": new Date(), "endTime": new Date(), "isTemplate": false, sendMsg:0,sendTime:new Date() }
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- $scope.savercode = function(worktimedata) {
- $modalInstance.close(worktimedata);
- };
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- var fildata = {
- "scheduleclass": {
- // "code": selectedItem.code,
- "name": selectedItem.name,
- "person": selectedItem.person,
- "description": selectedItem.description,
- "startTime": moment(selectedItem.startTime).format('YYYY-MM-DD HH:mm:ss'),
- "endTime": moment(selectedItem.endTime).format('YYYY-MM-DD HH:mm:ss'),
- "shiftTime": selectedItem.shiftTime,
- "succeedTime": selectedItem.succeedTime,
- "dictionaryDTO": selectedItem.dictionaryDTO,
- "isTemplate": selectedItem.isTemplate,
- "deleteFlag": selectedItem.deleteFlag,
- "sendMsg": selectedItem.sendMsg,
- "sendTime": selectedItem.sendMsg == 1?moment(selectedItem.sendTime).format('YYYY-MM-DD HH:mm:ss'):undefined
- }
- }
- if (!fildata.scheduleclass.name) {
- SweetAlert.swal({
- title: "新增失败!",
- text: "班次未填",
- type: "error"
- })
- } else if (!fildata.scheduleclass.startTime) {
- SweetAlert.swal({
- title: "新增失败!",
- text: "班次开始时间未填",
- type: "error"
- })
- } else if (!fildata.scheduleclass.endTime) {
- SweetAlert.swal({
- title: "新增失败!",
- text: "班次结束时间未填",
- type: "error"
- })
- } else if (!fildata.scheduleclass.person) {
- SweetAlert.swal({
- title: "新增失败!",
- text: "本班次人数未填",
- type: "error"
- })
- } else {
- api_bpm_data.addData('scheduleclass', fildata).then(function(response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "新增成功!",
- type: "success"
- }, function() {
- $scope.refreshData('expand-right', defaultFilterData);
- })
- } else {
- SweetAlert.swal({
- title: "新增失败!",
- type: "error"
- })
- }
- })
- }
- }
- });
- }
- $scope.removeData = function() {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/acceptTask.tpl.html',
- controller: function($scope, scope, $modalInstance, api_user_data) {
- var rmvList = [];
- $scope.title = "删除";
- $scope.connect = "确定要删除本班次?";
- rmvList.push(scope.selected.items[0].id);
- $scope.ok = function() {
- $modalInstance.close(rmvList);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function() {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- if (selectedItem.length > 0) {
- api_bpm_data.rmvData('scheduleclass', selectedItem).then(function(response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "删除成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function() {
- $scope.refreshData('expand-right', defaultFilterData);
- // $scope.myData = _.reject($scope.myData, function(o) { return _.includes(selectedItem, o.id); });
- // $scope.selected = {
- // items: []
- // };
- // $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length
- $scope.gridApi.grid.selection.selectedCount = 0;
- });
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- }
- }
- })
- }
- $scope.selected = {
- items: []
- }
- $scope.editted = {
- items: []
- }
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- // gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){
- // console.log(rowEntity);
- // });
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- defaultFilterData = filtersData;
- $scope.refreshData('expand-right', filtersData);
- });
- // gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
- // scope.grid.appScope.selected.items[0] = scope.entity
- // });
- gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- if (data.isSelected) {
- data.grid.appScope.selected.items[0] = data.entity;
- } else {
- if (data.grid.appScope.selected.items[0].id == data.entity.id) {
- data.grid.appScope.selected.items = [];
- }
- }
- });
- };
- var defaultFilterData = {
- "idx": 0,
- "sum": 10
- };
- $scope.memoryfilterData = {
- "idx": 0,
- "sum": 10
- }
- $scope.ldloading = {};
- $scope.refresh = function(style, filterData) {
- $scope.selected = { items: [] };
- if ($scope.gridApi) {
- // $scope.gridApi.grid.options.paginationCurrentPage = 0;
- $scope.gridApi.grid.selection.selectedCount = 0;
- }
- $scope.refreshData('expand-right', defaultFilterData);
- }
- $scope.refreshData = function(style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- // $scope.selected = { items: [] };
- // if ($scope.gridApi) {
- // $scope.gridApi.grid.selection.selectedCount = 0;
- // }
- api_bpm_schedule.getScheduleClass().then(function(response) {
- if (response.status == 200) {
- $scope.ldloading[style.replace('-', '_')] = false;
- var scheduleClassList = response.list;
- $scope.gridOptions.totalItems = response.totalNum;
- angular.forEach(scheduleClassList, function(item) {
- var templateEvent = {
- id: item.id,
- name: item['name'],
- // code: item['code'],
- startTime: item.startTime,
- person: item.person,
- //starts_at:
- endTime: item.endTime,
- dictionaryDTO: item.dictionaryDTO,
- succeedTime: item.succeedTime,
- shiftTime: item.shiftTime,
- description: item.description,
- deleteFlag: item.deleteFlag,
- isTemplate: item.isTemplate,
- draggable: true,
- sendMsg: item.sendMsg,
- sendTime: item.sendTime
- };
- $scope.myData.push(templateEvent);
- })
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- }
- })
- // $scope.myData = [];
- // api_bpm_data.fetchDataList('closecode',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);
- }]);
|