123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539 |
- 'use strict';
- /**
- * controller for User Profile Example
- */
- app.controller('informationCtr', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", "api_login", "api_configure_data", "api_solution", "api_wechatfile", function ($rootScope, $scope, $state, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_login, api_configure_data, api_solution, 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;
- $scope.fabu = false;
- $scope.chehui = false;
- for (var i = 0; i < loginUser.menu.length; i++) {
- if (loginUser.menu[i].link == "fuwuzhinanliebiao_xinzeng") {
- $scope.xinzeng = true
- }
- if (loginUser.menu[i].link == "fuwuzhinanliebiao_shanchu") {
- $scope.shanchu = true
- }
- if (loginUser.menu[i].link == "fuwuzhinanliebiao_bianji") {
- $scope.bianji = true
- }
- if (loginUser.menu[i].link == "fuwuzhinanliebiao_fabu") {
- $scope.fabu = true
- }
- if (loginUser.menu[i].link == "fuwuzhinanliebiao_chehui") {
- $scope.chehui = true
- }
- }
- //$scope.allright=false;
- //$scope.allrightnot=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 = true;
- $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.onDblClick(row.entity)\" 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;
- };
- //remote data
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- enableFiltering: false,
- width: 50
- },
- {
- name: 'title',
- displayName: '标题',
- width: '25%',
- enableFiltering: false
- },
- {
- name: 'serviceType.name',
- displayName: '分类',
- width: '13%',
- enableFiltering: false
- },
- {
- name: 'createUser.name',
- displayName: '创建人',
- width: '8%',
- enableFiltering: false
- },
- {
- name: 'createUser.dept.dept',
- displayName: '发布科室',
- width: '10%',
- enableFiltering: false
- },
- {
- name: 'createTime',
- displayName: '创建时间',
- width: '10%',
- minWidth:'140',
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{grid.appScope.transferTime(row.entity.createTime)}}</div>' +
- '</div>'
- },
- {
- name: 'status',
- displayName: '状态',
- width: '8%',
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{grid.appScope.getStatus(row.entity.status)}}</div>' +
- '</div>'
- },
- {
- minWidth: '310',
- name: '操作',
- enableFiltering: false,
- cellTemplate: '<div class="links cl-effect-1 pull-left ui-grid-cell-contents">' +
- '<a ng-click="grid.appScope.saveData(row.entity)" class="bianjifont" ng-show="grid.appScope.showBianji(row.entity)&&grid.appScope.bianji" tooltip="编辑" tooltip-placement="left">编辑</a>' +
- '<a ng-click="grid.appScope.removeData(row.entity)" class="bianjifont" ng-show="grid.appScope.showShanchu(row.entity)&&grid.appScope.shanchu" tooltip="删除" tooltip-placement="left">删除</a>' +
- '<a ng-click="grid.appScope.seeDetail(row.entity)" class="bianjifont" ng-show="grid.appScope.showChakan(row.entity)" tooltip="查看" tooltip-placement="left">查看</a>' +
- '<a ng-click="grid.appScope.release(row.entity)" class="bianjifont" ng-show="grid.appScope.showFabu(row.entity)&&grid.appScope.fabu" tooltip="发布" tooltip-placement="left">发布</a>' +
- '<a ng-click="grid.appScope.withdraw(row.entity)" class="bianjifont" ng-show="grid.appScope.showChehui(row.entity)&&grid.appScope.chehui" tooltip="撤回" tooltip-placement="left">撤回</a>' +
- '</div>'
- },
- ];
- $scope.transferTime = function(time) {
- return moment(time).format('YYYY-MM-DD HH:mm');
- }
- // 状态名转化
- $scope.getStatus = function (data) {
- if (data == 1) {
- return "已发布"
- } else if (data == 2) {
- return "暂存"
- } else if (data == 3) {
- return "已撤回"
- }
- }
- // 撤回显示隐藏
- $scope.showChehui = function (data) {
- // console.log(data);
- if (data.status == 1) {
- return true
- } else {
- return false
- }
- }
- // 发布显示隐藏
- $scope.showFabu = function (data) {
- if (data.status == 2 || data.status == 3) {
- return true
- } else {
- return false
- }
- }
- // 查看显示隐藏
- $scope.showChakan = function (data) {
- // if(data.status==1||data.status==2){
- return true
- // }else{
- // return false
- // }
- }
- // 删除显示隐藏
- $scope.showShanchu = function (data) {
- if (data.status == 2 || data.status == 3) {
- return true
- } else {
- return false
- }
- }
- // 编辑显示隐藏
- $scope.showBianji = function (data) {
- if (data.status == 2 || data.status == 3) {
- return true
- } else {
- return false
- }
- }
- $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.getCreateUser = function () {
- api_configure_data.fetchDataList("user", {
- "idx": 0,
- "sum": 1000,
- "user":{
- "simple": true,
- engineer: 1,
- }
- }).then(function (res) {
- $scope.createUserData = res.list
- })
- }
- $scope.getCreateUser()
- // 发布
- $scope.release = function (data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- $scope.title = '服务指南发布';
- $scope.connect = '确定要发布此服务指南?';
- $scope.ok = function () {
- $modalInstance.close(data);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- selectedItem.status = 1;
- delete selectedItem.item;
- api_solution.updData('serviceGuide', {
- "serviceGuide": selectedItem
- }).then(function (response) {
- if (response.data) {
- SweetAlert.swal({
- title: "发布成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $scope.myData = _.reject($scope.myData, function (o) {
- return _.includes(selectedItem, o.id);
- });
- $scope.gridOptions.totalItems = $scope.gridOptions.totalItems - selectedItem.length;
- $scope.refreshData('expand-right', $scope.jry_fileData);
- });
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- }
- })
- }
- $scope.minTime = "";
- $scope.maxTime = "";
- // 新增
- $scope.addData = function () {
- $state.go('app.system.form', {
- formKey: 'serviceGuideForm',
- service: 'api_solution'
- });
- }
- //列表操作按钮-查看
- // $scope.onDblClick = function(data) {
- // var modelfile = { model: { serviceGuide: data } };
- // $state.go('app.system.form_editor', { formKey: 'serviceGuideDetail', service: 'api_solution', model: JSON.stringify(modelfile) });
- // };
- $scope.seeDetail = function (data) {
- var modelfile = {
- model: {
- serviceGuide: data
- }
- };
- $state.go('app.system.form_editor', {
- formKey: 'serviceGuideDetail',
- service: 'api_solution',
- model: JSON.stringify(modelfile)
- });
- };
- //列表操作按钮-编辑
- $scope.saveData = function (data) {
- var modelData = {
- model: {
- serviceGuide: data
- }
- };
- $state.go('app.system.form', {
- formKey: 'serviceGuideEdi',
- service: 'api_solution',
- model: JSON.stringify(modelData),
- 'isServiceGuideEdit': "true"
- });
- };
- // 搜索
- $scope.searchData = function () {
- if ($scope.minTime) {
- $scope.jry_fileData.serviceGuide.startTime = moment($scope.minTime).format("YYYY-MM-DD HH:mm:ss")
- }
- if ($scope.maxTime) {
- $scope.jry_fileData.serviceGuide.endTime = moment($scope.maxTime).format("YYYY-MM-DD HH:mm:ss")
- }
- $scope.refreshData('expand-right', $scope.jry_fileData);
- }
- // 清空
- $scope.clean = function () {
- delete $scope.jry_fileData.serviceGuide.title;
- delete $scope.jry_fileData.serviceGuide.serviceType;
- delete $scope.jry_fileData.serviceGuide.startTime;
- $scope.minTime = "";
- delete $scope.jry_fileData.serviceGuide.endTime;
- $scope.maxTime = "";
- delete $scope.jry_fileData.serviceGuide.createUser;
- $scope.refreshData('expand-right', $scope.jry_fileData);
- }
- // 撤回
- $scope.withdraw = function (data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- $scope.title = '服务指南撤回';
- $scope.connect = '确定要撤回此服务指南?';
- $scope.ok = function () {
- $modalInstance.close(data);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- console.log(selectedItem);
- delete selectedItem.item;
- selectedItem.status = 3;
- api_solution.updData("serviceGuide", {
- "serviceGuide": selectedItem
- }).then(function (res) {
- if (res.data) {
- SweetAlert.swal({
- title: "撤回成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- })
- $scope.refreshData('expand-right', $scope.jry_fileData);
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- }
- })
- }
- // 删除
- $scope.removeData = function (data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function ($scope, scope, $modalInstance, api_bpm_data) {
- var rmvList = [];
- $scope.title = '服务指南删除';
- $scope.connect = '确定要删除此服务指南?';
- // angular.forEach(scope.selected.items, function(item) {
- // rmvList.push(item.id);
- // });
- rmvList.push(data.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_solution.rmvData('serviceGuide', selectedItem).then(function (response) {
- if (response.data) {
- SweetAlert.swal({
- title: "删除成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function () {
- $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;
- $scope.refreshData('expand-right', $scope.jry_fileData);
- });
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- }
- }
- })
- }
- $scope.selected = {
- items: []
- }
- $scope.editted = {
- items: []
- }
- $scope.jry_fileData = {
- "idx": 0,
- "sum": 10,
- "serviceGuide": {}
- }
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // var filtersData = $scope.memoryfilterData;
- // filtersData.idx = newPage - 1;
- $scope.jry_fileData.idx = newPage - 1;
- // filtersData.sum = pageSize;
- $scope.jry_fileData.sum = pageSize;
- // defaultFilterData = filtersData;
- $scope.refreshData('expand-right', $scope.jry_fileData);
- });
- };
- // api_solution.jry_fetchDataList("serviceGuide",{"idx":0,"sum":10}).then(function(res){
- // console.log(res)
- // })
- $scope.serviceGuideType = [];
- // 获取分类
- $scope.getType = function () {
- var data = {
- key: "service_type",
- type: "list"
- }
- api_wechatfile.getDictionary(data).then(function (res) {
- $scope.serviceGuideType = res
- })
- }
- $scope.getType()
- $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 = [];
- // filterData['flag'] = -1;
- // console.log("filterData=" + JSON.stringify(filterData))
- api_solution.jry_fetchDataList('serviceGuide', filterData).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
- $scope.myData[i]['createTime'] = moment($scope.myData[i]['createTime']).format('YYYY-MM-DD HH:mm:ss')
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- // console.log("$scope.myData="+JSON.stringify($scope.myData))
- }, function () {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- //获取数据
- $scope.refreshData2 = 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 = [];
- // filterData['flag'] = -1;
- // console.log("filterData=" + JSON.stringify(filterData))
- api_solution.jry_fetchDataList('serviceGuide', filterData).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
- $scope.myData[i]['createTime'] = moment($scope.myData[i]['createTime']).format('YYYY-MM-DD HH:mm:ss')
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- // console.log("$scope.myData="+JSON.stringify($scope.myData))
- }, function () {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- $scope.timer = $interval(function () {
- $scope.refreshData2('expand-right', $scope.jry_fileData);
- }, $rootScope.refreshTime);
- $scope.$on('$destroy', function () {
- $interval.cancel($scope.timer)
- })
- $scope.refreshData('expand-right', $scope.jry_fileData);
- }]);
|