123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841 |
- 'use strict';
- /**
- * controller for User Profile Example
- */
- // "$aside", "toaster", "api_bpm_domain", "api_configure_data", "api_cmdb", "api_configure_form",
- app.controller('meansCtrl', ["$rootScope","$scope","$http", "$state", "$timeout","$injector",'$parse', "$interval", "$modal","$stateParams", "$aside", "SweetAlert", "toaster", "FileUploader","i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", "api_configure_data", "api_cmdb", "api_configure_form", function ($rootScope, $scope,$http, $state, $timeout,$parse,$injector, $interval, $modal,$stateParams, $aside, SweetAlert, toaster,FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular,api_bpm_domain, api_configure_data, api_cmdb, api_configure_form) {
- $scope.langs=i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- var loginUser=$rootScope.user;
- // $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 = true;
- // $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 = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.enableSelectAll = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = true;
- $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.enableSelectionBatchEvent= true;
- var mun=$scope.gridOptions.paginationPageSize;
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [
- { name:'操作', width:50,enableFiltering:false, cellTemplate:'<div class="links cl-effect-1">' +
- '<a ng-click="grid.appScope.onClick(row.entity)" tooltip="修改" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>'+
- '</div>' },
- { name:'uuid',enableSorting: false, displayName:'内部编码', width:150,enableFiltering:false,cellTemplate:'<div class="uigrid" ng-click="grid.appScope.onview(row.entity)">{{row.entity.uuid}}</div>'},
- { name:'name',enableSorting: false, displayName:'资产名称', width:100,enableFiltering:false,cellTemplate:'<div class="uigrid" ng-click="grid.appScope.onview(row.entity)">{{row.entity.name}}</div>'},
- { name:'dept',enableSorting: false, displayName:'资产类型', width:100,enableFiltering:false,cellTemplate:'<div class="uigrid" ng-click="grid.appScope.onview(row.entity)">{{row.entity.title}}</div>'},
- { name:'state',enableSorting: false, displayName:'资产状态', width:100,enableFiltering:false,cellTemplate:'<div class="uigrid" ng-click="grid.appScope.onview(row.entity)">{{row.entity.status}}</div>'},
- { name:'placeBasehw',enableSorting: false, displayName:'资产地点', width:120,enableFiltering:false,cellTemplate:'<div class="uigrid" ng-click="grid.appScope.onview(row.entity)">{{row.entity.placeBasehw}}</div>'},
- { name:'createtime',enableSorting: false, displayName:'创建时间', width:120,enableFiltering:false,cellTemplate:'<div class="uigrid" ng-click="grid.appScope.onview(row.entity)">{{row.entity.createtime}}</div>'},
- { name:'plantime',enableSorting: false, displayName:'预计报废时间', width:120,enableFiltering:false,cellTemplate:'<div class="uigrid" ng-click="grid.appScope.onview(row.entity)">{{row.entity.plantime}}</div>'},
- { name:'props.meansmanager',enableSorting: false, displayName:'管理员', width:80,enableFiltering:false,cellTemplate:'<div class="uigrid" ng-click="grid.appScope.onview(row.entity)">{{row.entity.props.meansmanager}}</div>'},
- ];
- $scope.gridOptions.rowTemplate= "<div ng-click=\"onview(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.onClick = function(row){
- // $scope.classify="basehwntwsv";
- var data={"model":row};
- $state.go('app.means.bill',{formKey:'means_edit',service:'api_cmdb','model':JSON.stringify(data)})
- };
- //查看
- $scope.onview = function(row){
- var data={"model":row};
- $state.go('app.means.view',{formKey:'means_edit',service:'api_cmdb','model':JSON.stringify(data)})
- };
- // if(configdata&&configdata.length>0){redrawSvg(configdata)};
- // $scope.gridOptions.onRegisterApi = function(gridApi){
- // $scope.gridApi = gridApi;
- // gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- // var filtersData = $scope.memoryfilterData;
- // filtersData.idx=newPage-1;
- // filtersData.sum=pageSize;
- // $rootScope['idxchange']=newPage-1;
- // $scope.refreshData('expand-right',filtersData);
- // // $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize});
- // });
- // $scope.gridOptions.onRegisterApi = function(gridApi) {
- // $scope.gridApi = gridApi;
- // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // //$scope.selected.item = data.entity;
- // $scope.entity = angular.copy(data.entity);
- // $scope.ciId = data.entity.id;
- // //TODO
- // vm.model=$scope.vm.model=decodeCIModel($scope.entity);
- // angular.forEach($scope.vm.tabs, function(tab){
- // tab.form.model = vm.model;
- // });
- // //decodeVMTabForm($scope.entity, vm.tabs);
- // //console.log(data);
- // });
- // };
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- // $scope.mySelectedRows=$scope.gridApi.selection.getSelectedRows();
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx=newPage-1;
- filtersData.sum=pageSize;
- $scope.refreshData('expand-right',filtersData);
- // $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize});
- });
- // $scope.sels=[];
- gridApi.selection.on.rowSelectionChanged($scope, function(scope){
- var j=0;
- for(var i=0;i<=scope.grid.appScope.selected.items.length;i++){
- if(scope.grid.appScope.selected.items[i]==scope.entity){
- j++;
- break;
- }
- }
- // console.log("j="+j)
- if(j==1){
- scope.grid.appScope.selected.items.splice(i,1);
- // $scope.sels.splice(i,1);
- }else{
- scope.grid.appScope.selected.items.push(scope.entity);
- // if(scope.entity.createtime){
- // $scope.sels.push(scope.entity);
- // for(var i=0;i<$scope.sels.length;i++){
- // $scope.sels[i].createtime=moment($scope.sels[i].createtime).format('YYYY-MM-DD')
- // }
- // }
- }
- $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
- console.log($scope.mySelectedRows);
- });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function(rows){
- // rows.forEach($scope.selected.items);
- $scope.mySelectedRows=$scope.gridApi.selection.getSelectedRows();
- if($scope.selected.items.length==0){
- $scope.selected.items=$scope.mySelectedRows;
- console.log($scope.selected.items);
- }else{
- if($scope.mySelectedRows.length==0){
- for(var i=0;i<$scope.selected.items.length;i++){
- for(var j=0;j<rows.length;j++){
- if($scope.selected.items[i].id==rows[j].entity.id){
- $scope.selected.items.splice(i,1);
- }
- }
- }
- }else{
- angular.forEach($scope.mySelectedRows,function(item){
- $scope.selected.items.push(item);
- });
- }
- }
- // if($scope.mySelectedRows.length==0){
- // $scope.selected.items.splice(i,1);
- // }
- // if($scope.selected.items.length==0){
- // $scope.selected.items.push($scope.mySelectedRows[i])
- // }else{
- // for(var i=0;i<$scope.mySelectedRows.length;i++){
- // for(var j=0;j<$scope.selected.items.length;j++){
- // if($scope.mySelectedRows[i]==$scope.selected.items[j]){
- // $scope.selected.items.splice(i,1);
- // }else{
- // $scope.selected.items.push($scope.mySelectedRows[i])
- // }
- // }
- // }
- // }
- // angular.forEach($scope.mySelectedRows,function(item,i){
- // angular.forEach($scope.selected.items,function(index,j){
- // if(){
- // }else{
- // }
- // $scope.selected.items.push(item)
- // });
- // });
- console.log($scope.mySelectedRows);
- // for(var i=0;i<=item.length;i++){
- // if(scope.GridRow[i].grid.appScope.selected.items==item.entity){
- // j++;
- // break;
- // }
- // $scope.selected.items.push(item[i].entity)
- // }
- // scope.GridRow[0].grid.appScope.selected.items.push(item.)
- });
- };
- $scope.searchSolution = function(type,key){
- $scope.gridApi.grid.options.paginationCurrentPage=1;
- var memoryfilterData = {
- "idx":0,
- "sum":mun
- };
- angular.extend($scope.memoryfilterData,memoryfilterData);
- $scope.memoryfilterData['searchCriteria'] = type;
- $scope.memoryfilterData['keys'] = key;
- // $scope.memoryfilterData=defaultFilterData;
- // api_cmdb.searchkey(defaultFilterData.type,defaultFilterData.key,defaultFilterData.idx,defaultFilterData.sum).then(function(data){
- // var myData = Restangular.stripRestangular(data);
- // if(myData.data&&myData.status==200){
- // $scope.gridOptions.totalItems = myData.total;
- // $scope.myData = myData.data;
- // }
- // });
- $scope.refreshData('expand-right',$scope.memoryfilterData);
- }
- $scope.onChangestatus= function(searchType){
- // defaultFilterData['status'] = searchType;
- $scope.gridApi.grid.options.paginationCurrentPage=1;
- var memoryfilterData = {
- "idx":0,
- "sum":mun
- };
- angular.extend($scope.memoryfilterData,memoryfilterData);
- $scope.memoryfilterData['status']=searchType;
- $scope.refreshData('expand-right', $scope.memoryfilterData);
- }
-
- this.selectRowFunction = function(data) {
- $scope.ciId = data.id;
- console.log(data);
- };
- //树形图
- var apple_selected, tree, treedata_avm, treedata_geography;
- $scope.my_tree_handler = function (branch) {
- //var _ref;
- var classify=$scope.classify=branch.prefix.toLowerCase()+branch.sign;
- api_cmdb.query({'sign':classify}).then(function(data){
- var myData = Restangular.stripRestangular(data);
- // console.log(myData.data.node);
- if(myData.data&&myData.status==200){
- var ret = myData.data;
- redrawSvg(myData);
- }
- });
- };
- $scope.my_data = [];
- function convertListToTree(data, treeMap){
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for(var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if(typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data){
- var treeMap = {};
- var list=[];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap,function(item){
- list.push(item);
- });
- return list;
- }
- $scope.my_tree = tree = {};
- $scope.try_async_load = function () {
- $scope.my_data = [];
- $scope.select_treedata = [];
- $scope.doing_async = true;
- api_configure_data.fetchDataList('ciclassify',{'idx':0,'sum':100}).then(function(result){
- //console.log(result['list']);
- $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
- $scope.doing_async = false;
- // tree.expand_all();
- //console.log(treelist);
- });
- };
- $scope.select_treedata = [];
- $scope.propTypeOptions = [];
- $scope.try_async_load();
-
- $scope.onFilterremove = function(item){
- console.log(item)
- }
- $scope.onFilterCallback = function(item){
- //console.log(item);
- if(angular.isDefined(item.children)&&item.children.length>=1){
- //not valid
- }else{
- var tempclassify=item.prefix.toLowerCase()+item.sign;
- $scope.gridApi.grid.options.paginationCurrentPage=1;
- $scope.cifilter_classic=tempclassify;
- var memoryfilterData = {
- "sign":tempclassify,
- "idx":0,
- "sum":mun
- }
- angular.extend($scope.memoryfilterData,memoryfilterData)
- // $scope.memoryfilterData=memoryfilterData;
- $scope.refreshData('expand-right',$scope.memoryfilterData);
- // api_configure_form.renderTabForm(tempclassify).then(function(data){
- // var myData = Restangular.stripRestangular(data);
- // $scope.propTypeOptions = myData;
- // });
- }
- }
- //关系下载模版
- api_configure_data.fetchDataList('ciedgetype',{'idx':0,'sum':100}).then(function(response){
- if(response){
- $scope.linktypeOptions = response.list;
- // angular.forEach($scope.linktypeOptions,function(item){
- // if(item.type==$scope.modelData.name){
- // $scope.modelData.linkName=item;
- // }
- // })
- }
- })
- $scope.rela={};
- $scope.onChange=function(rela){
- $scope.rela=rela;
- }
- $scope.getdown=function(){
- if(angular.isDefined($scope.rela)&&angular.isDefined($scope.rela.type)){
- var type=2;
- // api_configure_data.fetchDataList('ciedgetype',{'idx':0,'sum':100}).then(function(data){
- // if(data.status==200){
- // var myData = Restangular.stripRestangular(data).list;
- // for(var i=0;i<myData.length;i++){
- $http({
- url : api_configure_data.downModels(type,$scope.rela.id,$scope.rela.label).getRequestedUrl(),
- method : 'GET',
- headers : {
- // 'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType : 'arraybuffer'
- }).success(function(data, status, headers, config) {
- var file = new Blob([ data ], {
- type : 'application/octet-stream'
- // 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 = "关系属性.xlsx";
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- console.log(data);
- });
- // break;
- // }
-
- // }
- // })
- }else{
- SweetAlert.swal({
- title: "未选择资产关系!",
- text: "请选择资产关系",
- type: "error"
- })
- }
- }
- //资产关系导入
- var importUploader = $scope.importUploader = new FileUploader({
- url:api_cmdb.importData().getRequestedUrl()
- });
- 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) {
- if(response.status==200){
- SweetAlert.swal({
- title: "导入成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- },function(){
- $scope.ldloading.expand_right = false;
- });
- console.info('onSuccessItem', fileItem, response, status, headers);
- }else{
- SweetAlert.swal({
- title: "导入失败!",
- text: response.error,
- type: "error"
- },function(){
- $scope.ldloading.expand_right = false;
- });
- }
- };
- importUploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- SweetAlert.swal({
- title: "系统错误!",
- text: "系统错误,请稍候重试!",
- type: "error"
- },function(){
- $scope.ldloading.expand_right = false;
- });
- };
- 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.import = function(style){
- $scope.ldloading[style.replace('-', '_')] = true;
- importUploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers,$rootScope.getSession());
- item.formData.push({'filename':item.file.name});
- console.info('onBeforeUploadItem', item);
- };
- importUploader.uploadAll();
- }
- //添加
- $scope.addData = function(size){
- $state.go('app.means.editor',{formKey:'means_editor',service:'api_bpm_data'});
- }
- //导出模版
- $scope.download=function(classfy){
- if(angular.isDefined(classfy)){
- var type=1;
- api_configure_data.fetchDataList('ciclassify',{'idx':0,'sum':100}).then(function(data){
- if(data.status==200){
- var myData = Restangular.stripRestangular(data).list;
- for(var i=0;i<myData.length;i++){
- if((myData[i].prefix.toLowerCase()+myData[i].sign)==classfy){
- $http({
- url : api_configure_data.downModels(type,myData[i].id,myData[i].label).getRequestedUrl(),
- method : 'GET',
- headers : {
- // 'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType : 'arraybuffer'
- }).success(function(data, status, headers, config) {
- var file = new Blob([ data ], {
- type : 'application/octet-stream'
- // 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 = "资产属性.xlsx";
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- console.log(data);
- });
- break;
- }
- }
-
- }
- })
- }else{
- SweetAlert.swal({
- title: "未选择资产分类!",
- text: "请选择资产分类",
- type: "error"
- })
- }
- }
- //导出
- $scope.export = function(classfy,style){
- if(angular.isDefined(classfy)){
- $scope.ldloading[style.replace('-', '_')] = true;
- api_configure_data.fetchDataList('ciclassify',{'idx':0,'sum':100}).then(function(data){
- if(data.status==200){
- var myData = Restangular.stripRestangular(data).list;
- for(var i=0;i<myData.length;i++){
- if((myData[i].prefix.toLowerCase()+myData[i].sign)==classfy){
- $http({
- url : api_cmdb.exportData(myData[i].label,myData[i].id).getRequestedUrl(),
- method : 'GET',
- 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/octet-stream'
- // 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 = myData[i].label+'.xlsx';
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- $scope.ldloading.zoom_in = false;
- console.log(data);
- });
- break;
- }
- }
-
- }
- })
- }else{
- SweetAlert.swal({
- title: "未选择资产分类!",
- text: "请选择资产分类",
- type: "error"
- })
- }
- }
- // }
- //导入
- var importUploader = $scope.importUploader = new FileUploader({
- url:api_cmdb.importData().getRequestedUrl()
- });
- 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) {
- if(response.status==200){
- SweetAlert.swal({
- title: "导入成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- },function(){
- $scope.ldloading.expand_right = false;
- });
- console.info('onSuccessItem', fileItem, response, status, headers);
- }else{
- SweetAlert.swal({
- title: "导入失败!",
- text: response.error,
- type: "error"
- },function(){
- $scope.ldloading.expand_right = false;
- });
- }
- };
- importUploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- SweetAlert.swal({
- title: "系统错误!",
- text: "系统错误,请稍候重试!",
- type: "error"
- },function(){
- $scope.ldloading.expand_right = false;
- });
- };
- 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.import = function(style){
- $scope.ldloading[style.replace('-', '_')] = true;
- importUploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers,$rootScope.getSession());
- item.formData.push({'filename':item.file.name});
- console.info('onBeforeUploadItem', item);
- };
- importUploader.uploadAll();
- }
- $scope.removeData = function(){
- var rmvList = $scope.selected.items.id;
- // angular.forEach($scope.selected.items,function(item){
- // rmvList.push(item.id);
- // });
- // if(rmvList.length>0){
- api_cmdb.put($scope.selected.items,rmvList).then(function(response){
- if(response.status==200){
- SweetAlert.swal({
- title: "删除成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- },function(){
- $scope.myData = _.reject($scope.myData, function(o) { return _.includes(rmvList,o.id); });
- $scope.selected = {
- items:[]
- };
- });
-
- }else{
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- // }
- }
-
- $scope.selected = {
- items:[]
- }
- $scope.editted = {
- items:[]
- }
- // $scope.stamp = function(){
- // var modalInstance = $modal.open({
- // templateUrl: 'assets/views/means/tpl/uuidprint.html',
- // controller: function($scope,$modalInstance ){
- // // $scope.stamp = function(){
- // $scope.stampable=true;
- // setInterval(function(){
- // if($scope.stampable){
- // $scope.stampable=false;
- // // $scope.selected=scope.selected;
- // angular.forEach($scope.selected.items,function(item){
- // function $(selector) {
- // return document.querySelector(selector);
- // }
- // $scope.q= $('#qrcanvas');
- // var canvas;
- // var colorIn = "#191970";
- // var colorOut = "#cd5c5c";
- // var colorFore = "#4169e1";
- // var colorBack = "#ffffff";
- // var options = {
- // cellSize: 6,
- // foreground: [
- // // foreground color
- // {style: colorFore},
- // // outer squares of the positioner
- // {row: 0, rows: 7, col: 0, cols: 7, style: colorOut},
- // {row: -7, rows: 7, col: 0, cols: 7, style: colorOut},
- // {row: 0, rows: 7, col: -7, cols: 7, style: colorOut},
- // // inner squares of the positioner
- // {row: 2, rows: 3, col: 2, cols: 3, style: colorIn},
- // {row: -5, rows: 3, col: 2, cols: 3, style: colorIn},
- // {row: 2, rows: 3, col: -5, cols: 3, style: colorIn},
- // ],
- // background: colorBack,
- // data: item.uuid,
- // typeNumber: 1,
- // };
- // var effect = 'none';
- // if (effect !== 'none') {
- // options.effect = {key: effect, value: 1};
- // if (effect === 'image') {
- // options.background = [colorBack, effectImg];
- // }
- // }
- // options.reuseCanvas = canvas;
- // canvas = qrgen.canvas(options);
- // $scope.q.appendChild(canvas);
- // })
- // }else{
- // }
- // },500);
- // $scope.ok = function() {
- // $modalInstance.close($scope.entity);
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
-
- // },
- // size:'lg',
- // resolve: {
- // $scope: function(){
- // return $scope;
- // }
- // }
- // })
- // };
- var defaultFilterData = {
- // "assignee":2,
- // "sign":"basehwitndl",
- "idx":0,
- "sum":mun
- };
- $scope.memoryfilterData = {
- // "assignee":2,
- // "sign":"basehwitndl",
- "idx":0,
- "sum":mun
- }
- $scope.ldloading = {};
- var pdKey = $state.current.pdKey;
- $scope.refreshData = function(style,filterData){
- if(angular.isUndefined(filterData)){
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- // $scope.gridOptions['sum']=filterData.sum;
- api_cmdb.query(filterData).then(function(data){
- // $scope.callsPending--;
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions['totalItems'] = data.total;
- // angular.forEach(myData.data.node,function(item){
- // moment(item.createtime).format('YYYY-MM-DD');
- // })
- for(var i=0;i<myData.data.node.length;i++){
- myData.data.node[i].createtime=moment(myData.data.node[i].createtime).format('YYYY-MM-DD');
- }
- $scope.myData = myData.data.node;
- },function(){
- });
- };
- $scope.refreshData('expand-right', defaultFilterData);
-
- }]);
- app.controller('MeansOperCtrl', ['$rootScope','$http', '$scope', function ($rootScope,$http, $scope) {
- // console.log('$rootScope.user3='+JSON.stringify($scope.item));
- // if( $scope.item.handlerUser!=null){
-
- // if ($rootScope.user.id==$scope.item.handlerUser.id) {
- // $scope.item.chaozuoPower=true;
-
- // }
- // }
-
-
- $scope.look = function(){
- $scope.colobject.grid.appScope.lookFunction($scope.item);
- // console.log('$scope.item='+JSON.stringify($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('meansoperator', function () {
- return {
- restrict: 'E',
- scope:
- {
- item: '=',
- colobject: '='
- },
- controller: 'MeansOperCtrl',
- template: '<div class="links cl-effect-1">' +
- '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>'+
- '<a ng-click="edit()" tooltip="修改" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>'+
- '</div>'
- };
- });
-
|