Commit e50e08fa authored by wangqinghua's avatar wangqinghua

兼容IE下载

parent 7558fa57
......@@ -132,11 +132,6 @@
</nz-col>
</nz-row>
</ng-container>
<ng-container *ngIf="countOrderList?.length == 0">
<div class="img-noData" style="min-height: 400px">
<div class="noData" title="暂无数据"></div>
</div>
</ng-container>
</div>
</nz-col>
<nz-col class="padding-10" nzSpan="12">
......@@ -163,11 +158,6 @@
<nz-col nzSpan="8">{{flow.receive}}</nz-col>
</nz-row>
</ng-container>
<ng-container *ngIf="flowListNum?.length == 0">
<div class="img-noData" style="min-height: 400px">
<div class="noData" title="暂无数据"></div>
</div>
</ng-container>
</div>
</nz-col>
<nz-col class="padding-10" nzSpan="12">
......@@ -212,11 +202,6 @@
<nz-col nzSpan="12">系统名称</nz-col>
<nz-col nzSpan="12">运行天数</nz-col>
</nz-row>
<ng-container *ngIf="safeRunDayList?.length == 0">
<div class="img-noData" style="min-height: 400px">
<div class="noData" title="暂无数据"></div>
</div>
</ng-container>
<ng-container *ngFor="let day of safeRunDayList;">
<nz-row class="table-content">
<nz-col nzSpan="12">{{day.name}}</nz-col>
......
......@@ -131,8 +131,6 @@ export class HomeComponent implements OnInit, AfterViewInit {
this.groupList = res.data;
this.obj.leftGroupId = this.groupList[0].groupid;
this.countGroupItem();
} else {
this.message.error(res.errMsg);
}
}
);
......
import {Injectable, OnInit} from "@angular/core";
import {NzModalService} from 'ng-zorro-antd';
import {Injectable, OnInit} from '@angular/core';
import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {SERVER_API_URL, SERVER_API_URL_COMS} from '../../app.constants';
import {DatePipe} from '@angular/common';
@Injectable()
export class CommonService implements OnInit {
constructor(private modalSer:NzModalService,private datePipe:DatePipe) {
constructor(private modalSer: NzModalService, private datePipe: DatePipe,
private message: NzMessageService) {
// 定义发射事件
}
......@@ -13,9 +15,9 @@ export class CommonService implements OnInit {
}
exists(list, parentId,myId){
for(let i=0; i<list.length; i++){
if(list[i][myId] == parentId){
exists(list, parentId, myId) {
for (let i = 0; i < list.length; i++) {
if (list[i][myId] == parentId) {
return true;
}
}
......@@ -29,26 +31,26 @@ export class CommonService implements OnInit {
* @param list
* @returns {any[]}
*/
listToTree(myId,pId,list){
const nodes = [];
for(let i=0; i<list.length; i++){
listToTree(myId, pId, list) {
const nodes = [];
for (let i = 0; i < list.length; i++) {
list[i].checked = false;
const row = list[i];
if ( !this.exists(list, row[pId],myId) ){
if (!this.exists(list, row[pId], myId)) {
nodes.push(row);
}
}
const toDo = [];
for(let i=0; i<nodes.length; i++){
for (let i = 0; i < nodes.length; i++) {
toDo.push(nodes[i]);
}
while(toDo.length){
while (toDo.length) {
const node = toDo.shift(); // the parent node
for(let i=0; i<list.length; i++){
for (let i = 0; i < list.length; i++) {
const row = list[i];
if (row[pId] == node[myId]){
if (node.children){
if (row[pId] == node[myId]) {
if (node.children) {
node.children.push(row);
} else {
node.children = [row];
......@@ -65,7 +67,7 @@ export class CommonService implements OnInit {
* @param data json格式的数据
* @returns {string}
*/
toQuery(data){
toQuery(data) {
let str = '';
for (let key in data) {
if (data.hasOwnProperty(key)) {
......@@ -82,31 +84,46 @@ export class CommonService implements OnInit {
* @param title 提示语
* @param callback 回调函数
*/
confirmThing(title,content,callback){
confirmThing(title, content, callback) {
this.modalSer.confirm({
nzTitle: title,
nzContent: '<b style="color: red;">'+content+'</b>',
nzContent: '<b style="color: red;">' + content + '</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: callback,
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel'),
})
});
}
/**
* 下载文件
* @param url 文件URL
*/
downloadFile(title,data: Response) {
const blob = new Blob([data], {type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;"});
const url= window.URL.createObjectURL(blob);
let link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("download", title);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
downloadFile(title, data: Response) {
const blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;'});
const ie = navigator.userAgent.match(/MSIE\s([\d.]+)/),
ie11 = navigator.userAgent.match(/Trident\/7.0/) && navigator.userAgent.match(/rv:11/),
ieEDGE = navigator.userAgent.match(/Edge/g),
ieVer = (ie ? ie[1] : (ie11 ? 11 : (ieEDGE ? 12 : -1)));
console.log('ie:' + ie);
console.log('ieVer:' + ieVer);
if (ie && ieVer < 10) {
this.message.error('No blobs on IE<10');
return;
}
if (ieVer > -1) {
window.navigator.msSaveBlob(blob, title);
} else {
const url = window.URL.createObjectURL(blob);
let link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('download', title);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
/**
......@@ -115,11 +132,11 @@ export class CommonService implements OnInit {
* @param method 全屏方法
* @returns {any}
*/
showInFullScreen(element, method){
showInFullScreen(element, method) {
let usablePrefixMethod;
['webkit', 'moz', 'ms', 'o', ''].forEach( (prefix)=> {
['webkit', 'moz', 'ms', 'o', ''].forEach((prefix) => {
if (usablePrefixMethod) {
return
return;
}
if (prefix === '') {
// 无前缀,方法首字母小写
......@@ -128,13 +145,13 @@ export class CommonService implements OnInit {
let typePrefixMethod = typeof element[prefix + method];
if (typePrefixMethod + '' !== 'undefined') {
if (typePrefixMethod === 'function') {
usablePrefixMethod = element[prefix + method]()
usablePrefixMethod = element[prefix + method]();
} else {
usablePrefixMethod = element[prefix + method]
usablePrefixMethod = element[prefix + method];
}
}
}
)
);
return usablePrefixMethod;
}
......@@ -142,12 +159,12 @@ export class CommonService implements OnInit {
* 根据type 查询时间段
* @param timeType 0:最近一小时 1:今天 2:昨天(最近一天) 3:最近三天 4:最近一周 5:最近一个月
*/
getTimeByType(timeType){
getTimeByType(timeType) {
const nowDate = new Date().getTime();
let day1, day2; //当作变量使用
let obj = {startTime:'',endTime:''};
let obj = {startTime: '', endTime: ''};
switch (timeType) {
case'0':{ //最近一小时
case'0': { //最近一小时
day1 = nowDate - 1 * 60 * 60 * 1000;
obj.startTime = this.datePipe.transform(day1, 'yyyy-MM-dd HH:mm:ss');
obj.endTime = this.datePipe.transform(nowDate, 'yyyy-MM-dd HH:mm:ss');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment