Commit e50e08fa authored by wangqinghua's avatar wangqinghua

兼容IE下载

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