12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169 |
- 'use strict';
- /**
- * controller for User Profile Example
- */
- // "$aside", "toaster", "api_bpm_domain", "api_configure_data", "api_cmdb", "api_configure_form",
- app.controller('fixedCtrl', ["$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","api_wechatfile","api_cmdb_print", 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,api_wechatfile,api_cmdb_print) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- var loginUser = $rootScope.user;
- $scope.showdown = false;
- $scope.clickshow = function() {
- $scope.showdown = !$scope.showdown;
- }
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableSelectAll = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.enableSorting = true;
- $scope.gridOptions.useExternalSorting = true;
- $scope.gridOptions.useExternalFiltering = false;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- // $scope.gridOptions.enableRowHeaderSelection = true;
- // $scope.gridOptions.enableRowSelection = true;
- // $scope.gridOptions.enableFullRowSelection = true;
- // $scope.gridOptions.enableSelectionBatchEvent = true;
- var mun = $scope.gridOptions.paginationPageSize;
- $scope.gridOptions.rowTemplate = "<div ng-click=\"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',
- enableSorting: false,
- displayName: '序号',
- width: 49,
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>'
- },
- {
- name: '关系图',
- enableSorting: false,
- displayName: '关系图',
- width: 60,
- enableFiltering: false,
- cellTemplate: '<div class="ui-grid-cell-contents"><a ng-click="grid.appScope.lookmap(row.entity)" tooltip="查看关系图" tooltip-placement="right"><i class="icon iconfontsmall icon-guanxitu1 pointfont"></i></a></div>'
- },
- {
- name: 'uuid',
- enableSorting: false,
- displayName: '资产编码',
- width: '15%',
- minWidth: 164,
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.uuid}}</div>' +
- '</div>'
- },
- {
- name: 'props.hw_mingcheng',
- enableSorting: false,
- displayName: '资产名称',
- width: 160,
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.props.hw_mingcheng}}</div>' +
- '</div>'
- },
- {
- name: 'props.hw_state',
- enableSorting: false,
- displayName: '状态',
- width: '5%',
- minWidth: 80,
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.props.hw_state}}</div>' +
- '</div>'
- },
- // {
- // name: 'status',
- // enableSorting: false,
- // displayName: '资产型号',
- // width: 217,
- // enableFiltering: false ,
- // // cellTemplate: '<div>' +
- // // '<div class="ui-grid-cell-contents">{{row.entity.managementUnit.name}}</div>' +
- // // '</div>'
- // },
- // {
- // name: 'placeBasehw',
- // enableSorting: false,
- // displayName: '资产地点',
- // width: 88,
- // enableFiltering: false ,
- // // cellTemplate: '<div>' +
- // // '<div class="ui-grid-cell-contents">{{row.entity.managementUnit.name}}</div>' +
- // // '</div>'
- // },
- {
- name: 'createtime',
- enableSorting: false,
- displayName: '入库时间',
- width: '14%',
- minWidth: 140,
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.createtime)}}</div>' +
- '</div>'
- },
- {
- name: 'lastupdatetime',
- enableSorting: false,
- displayName: '最后更新时间',
- width: '14%',
- minWidth: 140,
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.lastupdatetime)}}</div>' +
- '</div>'
- },
- // {
- // name: 'props.meansmanager',
- // enableSorting: false,
- // displayName: '资产所有人',
- // width: 98,
- // enableFiltering: false ,
- // // cellTemplate: '<div>' +
- // // '<div class="ui-grid-cell-contents">{{row.entity.managementUnit.name}}</div>' +
- // // '</div>'
- // },
- {
- name: 'props.hw_zherenren',
- enableSorting: false,
- displayName: '责任人',
- width: '10%',
- minWidth: '80',
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.props.hw_zherenren}}</div>' +
- '</div>'
- },
- {
- name: 'props.hwnw_xiangmu',
- enableSorting: false,
- displayName: '所属项目',
- width: 148,
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.props.hwnw_xiangmu}}</div>' +
- '</div>'
- },
- {
- name: 'props.erweima',
- enableSorting: false,
- displayName: '是否贴过二维码',
- width: 132,
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.qrcodeState == 1?"是":"否"}}</div>' +
- '</div>'
- },
- {
- name: '操作',
- enableSorting: false,
- width:'9%',
- minWidth: 130,
- cellTemplate: '<wttt class="bianjifont" style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
- enableFiltering: false
- },
- ];
- $scope.transferTime = function(time) {
- return moment(time).format('YYYY-MM-DD HH:mm');
- }
- $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.onDblClick = function(row) {
- localStorage.ciclassify = JSON.stringify($scope.my_tree);
- $state.go('app.means.fixed_see', { gdzc_label: row.entity.label, gdzc_item: JSON.stringify(row.entity), idd: row.entity.id })
- };
- //打印二维码
- $scope.printIt = function(){
- var uuidArr = [];
- var uuidStr = '';
- angular.forEach($scope.selected.items,function(v){
- uuidArr.push(v.uuid);
- })
- uuidStr = uuidArr.join(',');
- api_cmdb_print.getCmdbPrit(uuidStr).then(function(res){})
- }
- //查看
- $scope.onview = function(row) {
- console.log(row);
- var data = { "model": row };
- $state.go('app.means.view', { formKey: 'means_edit', service: 'api_cmdb', 'model': JSON.stringify(data) })
- };
- $scope.fileData={
- "idx":0,
- "sum":10
- }
- //查看关系图
- $scope.lookmap = function(row) {
- var data = { "model": row };
- // $state.go('cmdbmap', { 'model': JSON.stringify(data) });
- // var data = { "model": row };
- // var url = serverurl + '/cmdbmap/' + JSON.stringify(data)
- // window.open(url, '_blank');
- localStorage.cmdbmap = JSON.stringify(data);
- localStorage.ciclassify = JSON.stringify($scope.my_tree);
- var url = $state.href('cmdbmap', { basicType: 8 });
- window.open(url, '_blank');
- }
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- $scope.fenye = newPage - 1;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.fileData.idx=newPage - 1;
- $scope.fileData.sum=pageSize;
- $scope.refreshData('expand-right', $scope.fileData);
- // $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, ect) {
- if (scope.isSelected) {
- scope.grid.appScope.selected.items.push(scope.entity)
- } else {
- for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
- if (scope.grid.appScope.selected.items[i].id == scope.entity.id) {
- scope.grid.appScope.selected.items.splice(i, 1);
- break;
- }
- }
- }
- // 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;
- // }
- // }
- // if (j == 1) {
- // scope.grid.appScope.selected.items.splice(i, 1);
- // } else {
- // scope.grid.appScope.selected.items.push(scope.entity);
- // }
- $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
- });
- gridApi.selection.on.rowSelectionChangedBatch($scope, function(rows) {
- var selectitem = [];
- selectitem = angular.copy($scope.selected.items);
- for (var j = 0; j < rows.length; j++) {
- if (rows[j].isSelected == true) {
- selectitem.push(rows[j].entity);
- } else {
- delete selectitem[j];
- // rows.splice(j, 1);
- }
- }
- $scope.selected.items = [];
- for (var i = 0; i < selectitem.length; i++) {
- if (selectitem[i]) {
- $scope.selected.items.push(selectitem[i]);
- }
- }
- });
- };
- // 条件搜索下拉框
- $scope.lb_tiaojian = {};
- $scope.tiaojian = [
- { "name": "资产编码", "value": "uuid" },
- { "name": "资产名称", "value": "hw_mingcheng" },
- { "name": "型号", "value": "hw_modelnumber" },
- { "name": "序列号", "value": "hw_assetsxlh" },
- { "name": "用途", "value": "hw_assetsyongtu" },
- { "name": "IP", "value": "hw_assetsip" },
- { "name": "位置", "value": "hw_assetsweizhi" }
- ]
- // 点击搜索
- $scope.searchSolution = function(type, key) {
- $scope.gridApi.grid.options.paginationCurrentPage = 1;
- var memoryfilterData = {
- "idx": 0,
- "sum": $scope.gridOptions.paginationPageSize
- };
- angular.extend($scope.memoryfilterData, memoryfilterData);
- $scope.memoryfilterData['searchCriteria'] = type;
- $scope.memoryfilterData['keys'] = key;
- $scope.fileData['searchCriteria']=type;
- $scope.fileData['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.fileData);
- }
- // 资产状态
- $scope.lb_state_data = {};
- $scope.getStateSelect=function(){
- var data={
- "key":"cmdb_status",
- "type":"list"
- }
- api_wechatfile.getDictionary(data).then(function(res){
- $scope.state_data=res
- })
- }
- $scope.getStateSelect();
- // $scope.state_data = [
- // { "name": "全部状态", "value": "" },
- // { "name": "在库", "value": "1" },
- // { "name": "在线", "value": "2" },
- // { "name": "借出", "value": "3" },
- // { "name": "报修", "value": "4" },
- // { "name": "报废", "value": "5" },
- // // {"name":"备用","value":"6"},
- // ]
- $scope.onChangestatus = function(searchType) {
- console.log(searchType.value);
- if (searchType.value == "") {
- var all = {
- "idx": 0,
- "sum": $scope.gridOptions.paginationPageSize
- };
- $scope.refreshData('expand-right', $scope.fileData);
- } else {
- // defaultFilterData['status'] = searchType;
- $scope.gridApi.grid.options.paginationCurrentPage = 1;
- var memoryfilterData = {
- "idx": 0,
- "sum": $scope.gridOptions.paginationPageSize
- };
- angular.extend($scope.memoryfilterData, memoryfilterData);
- // $scope.memoryfilterData['state'] = searchType.value;
- $scope.memoryfilterData['hw_state'] = searchType.name;
- $scope.fileData['hw_state']=searchType.name;
- $scope.refreshData('expand-right', $scope.fileData);
- }
- }
- this.selectRowFunction = function(data) {
- $scope.ciId = data.id;
- // localStorage.ciclassify = JSON.stringify($scope.my_tree);
- // 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) {
- $scope.my_tree = 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.item?item.item.prefix.toLowerCase():item.prefix.toLowerCase()) + (item.item?item.item.sign:item.sign);
- $scope.gridApi.grid.options.paginationCurrentPage = 1;
- $scope.cifilter_classic = tempclassify;
- var memoryfilterData = {
- "sign": tempclassify,
- "idx": 0,
- "sum": $scope.gridOptions.paginationPageSize
- }
- angular.extend($scope.memoryfilterData, memoryfilterData);
- $scope.fileData["sign"]=tempclassify;
- // $scope.memoryfilterData=memoryfilterData;
- $scope.refreshData('expand-right', $scope.fileData);
- // 专有属性
- api_configure_form.renderTabForm(tempclassify).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- angular.forEach(myData, function(item, index) {
- if (index == 0) {
- $scope.propTypeOptions = myData[0].form.fields;
- } else {
- angular.forEach(item.form.fields, function(itemdata) {
- $scope.propTypeOptions.push(itemdata)
- })
- }
- })
- // $scope.propTypeOptions = myData[2].form.fields;
- console.log($scope.propTypeOptions)
- });
- }
- }
- //关系下载模版
- 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.openmodel = function() {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/means/tpl/relationdown.html',
- controller: function($scope, scope, $modalInstance) {
- $scope.key = {};
- $scope.linktypeOptions = scope.linktypeOptions;
- $scope.ok = function(key) {
- $modalInstance.close(key);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function() {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem && angular.isDefined(selectedItem.type)) {
- var type = 2;
- $http({
- url: api_configure_data.downModels(type, selectedItem.id, selectedItem.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);
- });
- } else {
- SweetAlert.swal({
- title: "未选择资产关系!",
- text: "请选择资产关系",
- type: "error"
- })
- }
- });
- }
- $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_cmdb.importData().getRequestedUrl(),
- alias: "file",
- removeAfterUpload: true
- });
- importUploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/ , filter, options) {
- console.info('onWhenAddingFileFailed', item, filter, options);
- };
- importUploader.onAfterAddingFile = function(fileItem) {
- console.info('onAfterAddingFile', fileItem);
- if ($scope.importUploader.queue.length > 1) {
- $scope.importUploader.queue.splice(0, 1);
- }
- };
- 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() {
- $rootScope.isMask = false;
- // $scope.ldloading.expand_right = false;
- });
- console.info('onSuccessItem', fileItem, response, status, headers);
- } else {
- SweetAlert.swal({
- title: "导入失败!",
- text: response.error,
- type: "error"
- }, function() {
- $rootScope.isMask = false;
- // $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;
- $rootScope.isMask = 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;
- $rootScope.isMask = 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.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- importUploader: function() {
- return $scope.importUploader;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {}
- })
- }
- //添加
- $scope.addData = function(size) {
- $state.go('app.means.editor', { formKey: 'means_editor', service: 'api_bpm_data' });
- }
- //下载资产模版
- $scope.openmeans = function() {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/means/tpl/meansdown.html',
- controller: function($scope, scope, $modalInstance) {
- $scope.item = {};
- $scope.headname = "资产模版下载";
- $scope.select_treedata = scope.select_treedata;
- $scope.ok = function(item) {
- $modalInstance.close(item);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function() {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- $rootScope.isMask = true;
- if (selectedItem) {
- // 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 < $scope.select_treedata.length; i++) {
- // if ((myData[i].prefix.toLowerCase() + myData[i].sign) == classfy) {
- $http({
- url: api_configure_data.downModels(type, selectedItem.id, selectedItem.label).getRequestedUrl(),
- method: 'GET',
- headers: {
- // 'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- $rootScope.isMask = 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 = "资产属性.xlsx";
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- console.log(data);
- $rootScope.isMask = false;
- });
- // break;
- // }
- // }
- // }
- // })
- } else {
- SweetAlert.swal({
- title: "未选择资产分类!",
- text: "请选择资产分类",
- type: "error"
- }, function() {
- $rootScope.isMask = false;
- });
- }
- // }
- });
- }
- // 重置按钮
- $scope.reset = function() {
- $scope.propTypeOptions = [];
- $scope.lb_state_data = {};
- $scope.lb_tiaojian = {};
- $scope.searchSolutionInput = "";
- if ($scope.fenye == undefined) {
- $scope.fenye = 0
- };
- $scope.try_async_load();
- $scope.memoryfilterData = {
- idx: 0,
- sum: mun
- };
- $scope.fileData={
- "idx":$scope.fileData.idx,
- "sum":$scope.fileData.sum
- }
- $scope.refreshData('expand-right', $scope.fileData);
- // $scope.memoryfilterData={
- // "idx": 0,
- // "sum": $scope.gridOptions.paginationPageSize,
- // }
- }
- // 新增下拉框
- $scope.new_one = [
- { "keys": { templateOptions: { label: "选择搜索字段" } }, "vals": "" },
- { "keys": { templateOptions: { label: "选择搜索字段" } }, "vals": "" },
- { "keys": { templateOptions: { label: "选择搜索字段" } }, "vals": "" }
- ];
- // var k=1;
- // 新增按钮
- $scope.new_select = function() {
- // k++;
- if ($scope.new_one.length >= $scope.propTypeOptions.length) {
- SweetAlert.swal({
- title: "新增失败",
- text: "新增项已达到上限!",
- type: "error"
- });
- return false
- } else {
- $scope.new_one.push({ "keys": { templateOptions: { label: "选择搜索字段" } }, "vals": "" })
- }
- }
- // 删除搜索框出现的字段
- $scope.delet = function(val) {
- // console.log($scope.propTypeOptions);
- // console.log(val);
- $scope.propTypeOptions.splice($scope.propTypeOptions.indexOf(val), 1)
- }
- $scope.gdzc_edit = "new_top";
- // 高级搜索搜索
- $scope.gaoji_search = function() {
- $scope.key1 = {};
- // var sear_data={
- // "idx": 0,
- // "sum": $scope.gridOptions.paginationPageSize,
- // }
- // console.log($scope.new_one);
- for (var j = 0; j < $scope.new_one.length; j++) {
- $scope.fileData[$scope.new_one[j].keys.key] = $scope.new_one[j].vals;
- }
- // angular.extend($scope.memoryfilterData, sear_data)
- delete($scope.fileData[undefined]);
- $scope.refreshData('expand-right', $scope.fileData);
- $scope.senior_show = false;
- $scope.gdzc_edit = "new_top";
- }
- $scope.senior_show = false;
- // 高级搜索按钮
- $scope.senior_cli = function() {
- if ($scope.propTypeOptions.length == 0) {
- SweetAlert.swal({
- title: "点开失败",
- text: "请先选择资产分类!",
- type: "error"
- });
- } else {
- $scope.senior_show = true;
- $scope.gdzc_edit = "new_after";
- $scope.new_one = [
- { "keys": { templateOptions: { label: "选择搜索字段" } }, "vals": "" },
- { "keys": { templateOptions: { label: "选择搜索字段" } }, "vals": "" },
- { "keys": { templateOptions: { label: "选择搜索字段" } }, "vals": "" },
- ];
- }
- }
- // 高级搜索关闭按钮
- $scope.close = function() {
- $scope.senior_show = false;
- $scope.gdzc_edit = "new_top";
- }
- // 刷新
- $scope.new_data = function() {
- console.log($scope.memoryfilterData);
- $scope.myData = [];
- if ($scope.fenye == undefined) {
- $scope.fenye = 0
- };
- $scope.refreshData('expand-right', $scope.fileData);
- }
- //导出
- $scope.exportopen = function() {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/means/tpl/gdzc_meansdown.html',
- controller: function($scope, scope, $modalInstance) {
- $scope.item = {};
- $scope.headname = "资产导出";
- $scope.select_treedata = scope.select_treedata;
- $scope.ok = function(item) {
- $modalInstance.close(item);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function() {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- $rootScope.isMask = true;
- if (selectedItem) {
- // 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 < $scope.select_treedata.length; i++) {
- // if ((myData[i].prefix.toLowerCase() + myData[i].sign) == classfy) {
- $http({
- url: api_cmdb.exportData(selectedItem.label, selectedItem.id).getRequestedUrl(),
- method: 'GET',
- headers: {
- // 'Content-type' : 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function(data, status, headers, config) {
- $rootScope.isMask = 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 = selectedItem.label + '.xlsx';
- document.body.appendChild(a);
- a.click();
- }).error(function(data, status, headers, config) {
- $rootScope.isMask = false;
- console.log(data);
- });
- // break;
- // }
- // }
- // }
- // })
- } else {
- SweetAlert.swal({
- title: "未选择资产分类!",
- text: "请选择资产分类",
- type: "error"
- }, function() {
- $rootScope.isMask = false;
- });
- }
- // }
- });
- }
- //导入
- 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() {
- $rootScope.isMask = false;
- });
- console.info('onSuccessItem', fileItem, response, status, headers);
- } else {
- SweetAlert.swal({
- title: "导入失败!",
- text: response.error,
- type: "error"
- }, function() {
- $rootScope.isMask = false;
- });
- }
- };
- importUploader.onErrorItem = function(fileItem, response, status, headers) {
- console.info('onErrorItem', fileItem, response, status, headers);
- SweetAlert.swal({
- title: "系统错误!",
- text: "系统错误,请稍候重试!",
- type: "error"
- }, function() {
- $rootScope.isMask = 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) {
- $rootScope.isMask = 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: []
- }
- var defaultFilterData = {
- // "assignee":2,
- // "sign":"basehwitndl",
- "idx": 0,
- "sum": $scope.gridOptions.paginationPageSize
- };
- $scope.memoryfilterData = {
- // "assignee":2,
- // "sign":"basehwitndl",
- "idx": 0,
- "sum": $scope.gridOptions.paginationPageSize
- }
- $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;
- for (var n = 0; n < $scope.myData.length; n++) {
- $scope.myData[n]['item'] = n + 1 + filterData.idx * filterData.sum
- }
- console.log( $scope.myData)
- }, function() {});
- };
- $scope.refreshData2 = 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;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- }, function() {});
- };
- $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('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.controller('gdzc_caozuoCtrl', ['$rootScope', '$http', '$scope', '$modal', 'api_cmdb2', 'api_bpm_domain', 'up_down_file', '$state', function($rootScope, $http, $scope, $modal, api_cmdb2, api_bpm_domain, up_down_file, $state) {
- $scope.edit = function() {
- var aaa = { "model": $scope.item };
- localStorage.ciclassify = JSON.stringify($scope.colobject.grid.appScope.my_tree);
- $state.go('app.means.fixed_edit', { formKey: 'means_edit', service: 'api_cmdb', 'model': JSON.stringify(aaa) })
- }
- $scope.watch = function() {
- // console.log($scope.item.id);
- console.log($scope.item);
- $state.go('app.means.fixed_see', { gdzc_label: $scope.item.label, gdzc_item: JSON.stringify($scope.item), idd: $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>'
- };
- });
- //操作
- app.directive('wttt', function() {
- return {
- restrict: 'E',
- scope: {
- item: '=',
- colobject: '='
- },
- controller: 'gdzc_caozuoCtrl',
- template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
- '<a class="bianjifont" ng-click="watch()">查看</a>' +
- // '<a ng-click="edit()" class="handlefont" ui-sref="app.fixed.edit">编辑</a>' +
- '<a ng-click="edit()" class="bianjifont">编辑</a>' +
- '</div></div>'
- };
- });
|