|
@@ -1,7 +1,7 @@
|
|
|
// import http from '@/api/http.js'
|
|
|
// import { downloadXlsx } from "../utils/xlsx";
|
|
|
import { saveAs } from 'file-saver'
|
|
|
-import {apiGetExportMsg, apiGetModel,} from '../api/api'
|
|
|
+import { apiGetExportMsg, apiGetModel, } from '../api/api'
|
|
|
// import XLSXD from 'xlsx-style'
|
|
|
// import Papa from 'papaparse'
|
|
|
// import { isObject } from "xe-utils"
|
|
@@ -19,7 +19,7 @@ const until = {
|
|
|
} else if (b === '0.00' || b === 0) {
|
|
|
num = '-'
|
|
|
} else {
|
|
|
- num = Math.round((Number(a)/Number(b)*100))+'%'
|
|
|
+ num = Math.round((Number(a) / Number(b) * 100)) + '%'
|
|
|
}
|
|
|
} else {
|
|
|
num = '-'
|
|
@@ -27,7 +27,7 @@ const until = {
|
|
|
return num
|
|
|
},
|
|
|
// 导出所有
|
|
|
- downloadPer(url,fileName, idss, idsmo) {
|
|
|
+ downloadPer(url, fileName, idss, idsmo) {
|
|
|
let params = null
|
|
|
if (!idsmo) {
|
|
|
params = {
|
|
@@ -39,7 +39,7 @@ const until = {
|
|
|
idsBcr: idsmo ? idsmo.join(',') : '',
|
|
|
}
|
|
|
}
|
|
|
- apiGetExportMsg(url,params).then(datas =>{
|
|
|
+ apiGetExportMsg(url, params).then(datas => {
|
|
|
let blob = new Blob([datas])
|
|
|
saveAs(blob, fileName)
|
|
|
}).catch((r) => {
|
|
@@ -48,59 +48,59 @@ const until = {
|
|
|
},
|
|
|
// 下载模板
|
|
|
downloadTemplate(url, params, proName) {
|
|
|
- apiGetModel(url,params).then(datas =>{
|
|
|
+ apiGetModel(url, params).then(datas => {
|
|
|
let blob = new Blob([datas])
|
|
|
saveAs(blob, proName)
|
|
|
}).catch((r) => {
|
|
|
console.error(r)
|
|
|
})
|
|
|
},
|
|
|
- getTime(date){
|
|
|
- var y = date.getFullYear();
|
|
|
- var m = date.getMonth() + 1;
|
|
|
- m = m < 10 ? ('0' + m) : m;
|
|
|
- var d = date.getDate();
|
|
|
- d = d < 10 ? ('0' + d) : d;
|
|
|
- var h = date.getHours();
|
|
|
- h=h < 10 ? ('0' + h) : h;
|
|
|
- var minute = date.getMinutes();
|
|
|
- minute = minute < 10 ? ('0' + minute) : minute;
|
|
|
- var second=date.getSeconds();
|
|
|
- second=second < 10 ? ('0' + second) : second;
|
|
|
- return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
|
|
|
+ getTime(date) {
|
|
|
+ var y = date.getFullYear();
|
|
|
+ var m = date.getMonth() + 1;
|
|
|
+ m = m < 10 ? ('0' + m) : m;
|
|
|
+ var d = date.getDate();
|
|
|
+ d = d < 10 ? ('0' + d) : d;
|
|
|
+ var h = date.getHours();
|
|
|
+ h = h < 10 ? ('0' + h) : h;
|
|
|
+ var minute = date.getMinutes();
|
|
|
+ minute = minute < 10 ? ('0' + minute) : minute;
|
|
|
+ var second = date.getSeconds();
|
|
|
+ second = second < 10 ? ('0' + second) : second;
|
|
|
+ return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
|
|
|
// timeF = y + '-' + m + '-' + d
|
|
|
// return timeF
|
|
|
},
|
|
|
changePowerPickDate(val) {
|
|
|
- let endss = val.substring(val.length-2, val.length) * 1
|
|
|
- let startTime = val.substring(0, val.length-2)
|
|
|
+ let endss = val.substring(val.length - 2, val.length) * 1
|
|
|
+ let startTime = val.substring(0, val.length - 2)
|
|
|
let allTime = ''
|
|
|
- if (0 <= endss && endss < 15) {
|
|
|
+ if (0 <= endss && endss < 15) {
|
|
|
allTime = startTime + '00'
|
|
|
- } else if (15 <= endss && endss < 30) {
|
|
|
+ } else if (15 <= endss && endss < 30) {
|
|
|
allTime = startTime + '15'
|
|
|
- } else if (30 <= endss && endss < 45) {
|
|
|
+ } else if (30 <= endss && endss < 45) {
|
|
|
allTime = startTime + '30'
|
|
|
- } else if (45 <= endss && endss < 60) {
|
|
|
+ } else if (45 <= endss && endss < 60) {
|
|
|
allTime = startTime + '45'
|
|
|
}
|
|
|
return allTime
|
|
|
},
|
|
|
changeElectricPickDate(val) {
|
|
|
- let endss = val.substring(val.length-2, val.length) * 1
|
|
|
- let startTime = val.substring(0, val.length-2)
|
|
|
+ let endss = val.substring(val.length - 2, val.length) * 1
|
|
|
+ let startTime = val.substring(0, val.length - 2)
|
|
|
let allTime = ''
|
|
|
- if (0 <= endss && endss < 10) {
|
|
|
+ if (0 <= endss && endss < 10) {
|
|
|
allTime = startTime + '00'
|
|
|
- } else if (10 <= endss && endss < 20) {
|
|
|
+ } else if (10 <= endss && endss < 20) {
|
|
|
allTime = startTime + '10'
|
|
|
- } else if (20 <= endss && endss < 30) {
|
|
|
+ } else if (20 <= endss && endss < 30) {
|
|
|
allTime = startTime + '20'
|
|
|
- } else if (30 <= endss && endss < 40) {
|
|
|
+ } else if (30 <= endss && endss < 40) {
|
|
|
allTime = startTime + '30'
|
|
|
- } else if (40 <= endss && endss < 50) {
|
|
|
+ } else if (40 <= endss && endss < 50) {
|
|
|
allTime = startTime + '40'
|
|
|
- } else if (50 <= endss && endss < 60) {
|
|
|
+ } else if (50 <= endss && endss < 60) {
|
|
|
allTime = startTime + '50'
|
|
|
}
|
|
|
return allTime
|
|
@@ -134,20 +134,20 @@ const until = {
|
|
|
}
|
|
|
return str
|
|
|
},
|
|
|
- sortBy(attr,rev){
|
|
|
+ sortBy(attr, rev) {
|
|
|
//第二个参数没有传递 默认升序排列
|
|
|
- if(rev == undefined){
|
|
|
+ if (rev == undefined) {
|
|
|
rev = 1;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
rev = (rev) ? 1 : -1;
|
|
|
}
|
|
|
- return function(a,b){
|
|
|
+ return function (a, b) {
|
|
|
a = a[attr];
|
|
|
b = b[attr];
|
|
|
- if(a < b){
|
|
|
+ if (a < b) {
|
|
|
return rev * -1;
|
|
|
}
|
|
|
- if(a > b){
|
|
|
+ if (a > b) {
|
|
|
return rev * 1;
|
|
|
}
|
|
|
return 0;
|
|
@@ -199,15 +199,15 @@ const until = {
|
|
|
*/
|
|
|
commafy(num) {
|
|
|
return num && num.toString()
|
|
|
- .replace(/\d+/, function(s){
|
|
|
- return s.replace(/(\d)(?=(\d{3})+$)/g, '$1,')
|
|
|
- })
|
|
|
+ .replace(/\d+/, function (s) {
|
|
|
+ return s.replace(/(\d)(?=(\d{3})+$)/g, '$1,')
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
-/*
|
|
|
- *手机号码中间4位隐藏花号(*)显示
|
|
|
- *
|
|
|
- */
|
|
|
+ /*
|
|
|
+ *手机号码中间4位隐藏花号(*)显示
|
|
|
+ *
|
|
|
+ */
|
|
|
hideMobile(mobile) {
|
|
|
return mobile && mobile.toString().replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2")
|
|
|
},
|
|
@@ -232,11 +232,11 @@ const until = {
|
|
|
let result = Array.isArray(obj) ? [] : {};
|
|
|
for (let key in obj) {
|
|
|
if (obj.hasOwnProperty(key)) {
|
|
|
- if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
|
- result[key] = deepCopy(obj[key]);
|
|
|
- } else {
|
|
|
- result[key] = obj[key];
|
|
|
- }
|
|
|
+ if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
|
+ result[key] = deepCopy(obj[key]);
|
|
|
+ } else {
|
|
|
+ result[key] = obj[key];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
@@ -245,21 +245,21 @@ const until = {
|
|
|
let datalist = [];
|
|
|
//表头数据
|
|
|
let cluData = ''
|
|
|
- for(let i=0; i<columnData.length;i++){
|
|
|
- cluData += columnData[i].label+','
|
|
|
+ for (let i = 0; i < columnData.length; i++) {
|
|
|
+ cluData += columnData[i].label + ','
|
|
|
}
|
|
|
- cluData.slice(0, cluData.length-1)
|
|
|
+ cluData.slice(0, cluData.length - 1)
|
|
|
datalist.push(cluData.split(','));
|
|
|
//这里的tableData为你的表格数据
|
|
|
- for(let j=0;j<tableDatas.length;j++) {
|
|
|
+ for (let j = 0; j < tableDatas.length; j++) {
|
|
|
let item = tableDatas[j]
|
|
|
let tabelDatas = ''
|
|
|
- for(let k=0; k<columnData.length;k++){
|
|
|
+ for (let k = 0; k < columnData.length; k++) {
|
|
|
let its = columnData[k]
|
|
|
- if (item[its.value] !==null) {
|
|
|
+ if (item[its.value] !== null) {
|
|
|
tabelDatas += item[its.value] + ','
|
|
|
} else {
|
|
|
- tabelDatas += '-,'
|
|
|
+ tabelDatas += '-,'
|
|
|
}
|
|
|
}
|
|
|
datalist.push(tabelDatas.split(','));
|
|
@@ -287,7 +287,7 @@ const until = {
|
|
|
skipHeader: true, //是否忽略表头,默认为false
|
|
|
origin: 'A2' // 设置插入位置
|
|
|
})
|
|
|
- contentWs['!merges'] = [{s:{r:0,c:0}, e:{r:1,c:0}}, {s:{r:0,c:1}, e:{r:1,c:1}}]
|
|
|
+ contentWs['!merges'] = [{ s: { r: 0, c: 0 }, e: { r: 1, c: 0 } }, { s: { r: 0, c: 1 }, e: { r: 1, c: 1 } }]
|
|
|
// contentWs['!merges'] = [{s:{r:1,c:2}, e:{r:2,c:2}}]
|
|
|
// contentWs['A1'] = {
|
|
|
// t: 's',
|
|
@@ -310,7 +310,7 @@ const until = {
|
|
|
// {s:{r:0,c:0}, e:{r:0,c:2}}为一个规则,s:起始位置,e:结束位置,r:行,c:列
|
|
|
// contentWs['!merges'] = [{s:{r:0,c:0}, e:{r:0,c:2}}]
|
|
|
|
|
|
-
|
|
|
+
|
|
|
// contentWs['A3'] = {
|
|
|
// t: 's',
|
|
|
// v: '人员ss',
|
|
@@ -330,7 +330,7 @@ const until = {
|
|
|
// }
|
|
|
// contentWs['!merges'] = [{s:{r:0,c:2}, e:{r:0,c:4}}]
|
|
|
//设置列宽
|
|
|
- contentWs['!cols'] = [{wch: 30},{wch: 20},{wch: 40}]
|
|
|
+ contentWs['!cols'] = [{ wch: 30 }, { wch: 20 }, { wch: 40 }]
|
|
|
XLSX.utils.book_append_sheet(wb, contentWs, '明细')
|
|
|
// XLSX.writeFile(wb, '明细.xlsx')
|
|
|
const tmpDown = new Blob([
|
|
@@ -348,13 +348,13 @@ const until = {
|
|
|
downExcel(obj, fileName) {
|
|
|
const a_node = document.createElement('a')
|
|
|
a_node.download = fileName
|
|
|
- if ('msSaveOrOpenBlob'in navigator) {
|
|
|
+ if ('msSaveOrOpenBlob' in navigator) {
|
|
|
window.navigator.msSaveOrOpenBlob(obj, fileName)
|
|
|
} else {
|
|
|
a_node.href = URL.createObjectURL(obj)
|
|
|
}
|
|
|
a_node.click()
|
|
|
- setTimeout(() =>{
|
|
|
+ setTimeout(() => {
|
|
|
URL.createObjectURL(obj)
|
|
|
}, 2000)
|
|
|
},
|
|
@@ -362,13 +362,13 @@ const until = {
|
|
|
if (typeof ArrayBuffer !== 'undefined') {
|
|
|
const buf = new ArrayBuffer(s.length)
|
|
|
const view = new Uint8Array(buf)
|
|
|
- for(let i =0; i != s.length; ++i) {
|
|
|
+ for (let i = 0; i != s.length; ++i) {
|
|
|
view[i] = s.charCodeAt(i) & 0xff
|
|
|
}
|
|
|
return buf
|
|
|
} else {
|
|
|
const buf = new Array(s.length)
|
|
|
- for(let i =0; i != s.length; ++i) {
|
|
|
+ for (let i = 0; i != s.length; ++i) {
|
|
|
buf[i] = s.charCodeAt(i) & 0xff
|
|
|
}
|
|
|
return buf
|
|
@@ -399,7 +399,7 @@ const until = {
|
|
|
dataIndex: dataIndex,
|
|
|
position: '15%'
|
|
|
});
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
myChart2.dispatchAction({
|
|
|
type: 'hideTip'
|
|
|
});
|
|
@@ -427,7 +427,7 @@ const until = {
|
|
|
dataIndex: dataIndex,
|
|
|
position: '15%'
|
|
|
});
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
myChart1.dispatchAction({
|
|
|
type: 'hideTip'
|
|
|
});
|
|
@@ -443,7 +443,7 @@ const until = {
|
|
|
} else {
|
|
|
num = '-'
|
|
|
}
|
|
|
- } else if(data === 0) {
|
|
|
+ } else if (data === 0) {
|
|
|
num = 0
|
|
|
} else {
|
|
|
num = '-'
|
|
@@ -459,12 +459,12 @@ const until = {
|
|
|
// ------------------------------------------------------------------------
|
|
|
// 冒泡排序
|
|
|
sortBubble(arr) {
|
|
|
- for(let i=0; i<arr.length; i++){
|
|
|
- for(let j=0; j<arr.length-i; j++){
|
|
|
- if (arr[j] > arr[j+1]) {
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
+ for (let j = 0; j < arr.length - i; j++) {
|
|
|
+ if (arr[j] > arr[j + 1]) {
|
|
|
let temp = arr[j]
|
|
|
- arr[j] = arr[j+1]
|
|
|
- arr[j+1] = temp
|
|
|
+ arr[j] = arr[j + 1]
|
|
|
+ arr[j + 1] = temp
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -475,7 +475,7 @@ const until = {
|
|
|
//利用for 循环 搭配 indexOf 去重
|
|
|
unique(arr) {
|
|
|
let newArr = []
|
|
|
- for(let i=0; i<arr.length; i++) {
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
if (newArr.indexOf(arr[i]) === -1) {
|
|
|
newArr.push(arr[i])
|
|
|
}
|
|
@@ -486,7 +486,7 @@ const until = {
|
|
|
//借助ES6提供的Set结构 new Set()
|
|
|
// var arr = [1,9,8,8,7,2,5,3,3,3,2,3,1,4,5,444,55,22];
|
|
|
// var arr2 = noRepeat(arr)
|
|
|
- noRepeatT(arr){
|
|
|
+ noRepeatT(arr) {
|
|
|
var newArr = [...new Set(arr)]; //利用了Set结构不能接收重复数据的特点
|
|
|
return newArr
|
|
|
},
|
|
@@ -494,7 +494,7 @@ const until = {
|
|
|
//利用 filter() 去重
|
|
|
//eg: var arr = ['apple','apps','pear','apple','orange','apps']
|
|
|
useFilter(arr) {
|
|
|
- return arr.filter(function(item,index){
|
|
|
+ return arr.filter(function (item, index) {
|
|
|
return arr.indexOf(item) === index; // 因为indexOf 只能查找到第一个
|
|
|
})
|
|
|
},
|
|
@@ -502,10 +502,10 @@ const until = {
|
|
|
//将数组的每一个元素依次与其他元素做比较,发现重复元素,删除
|
|
|
//eg: var arr = [1,9,8,8,7,2,5,3,3,3,2,3,1,4,5,444,55,22];
|
|
|
noRepeatF(arr) {
|
|
|
- for(var i = 0; i < arr.length-1; i++){
|
|
|
- for(var j = i+1; j < arr.length; j++){
|
|
|
- if(arr[i]===arr[j]){
|
|
|
- arr.splice(j,1);
|
|
|
+ for (var i = 0; i < arr.length - 1; i++) {
|
|
|
+ for (var j = i + 1; j < arr.length; j++) {
|
|
|
+ if (arr[i] === arr[j]) {
|
|
|
+ arr.splice(j, 1);
|
|
|
j--;
|
|
|
}
|
|
|
}
|
|
@@ -519,7 +519,7 @@ const until = {
|
|
|
var newArr = [];
|
|
|
for (var i = 0; i < arr.length; i++) {
|
|
|
if (arr.indexOf(arr[i]) == i) {
|
|
|
- newArr.push(arr[i]);
|
|
|
+ newArr.push(arr[i]);
|
|
|
}
|
|
|
}
|
|
|
return newArr;
|
|
@@ -527,13 +527,13 @@ const until = {
|
|
|
//方法六
|
|
|
//利用双重for循环
|
|
|
// var arr = [1,9,8,8,7,2,5,3,3,3,2,3,1,4,5,444,55,22]
|
|
|
- noRepeatS(arr){
|
|
|
- for (var i = 0; i < arr.length; i++) {
|
|
|
- for (var j = 0; j < arr.length; j++) {
|
|
|
- if (arr[i] == arr[j] && i != j) { //将后面重复的数删掉
|
|
|
- arr.splice(j, 1);
|
|
|
+ noRepeatS(arr) {
|
|
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
+ for (var j = 0; j < arr.length; j++) {
|
|
|
+ if (arr[i] == arr[j] && i != j) { //将后面重复的数删掉
|
|
|
+ arr.splice(j, 1);
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
return arr;
|
|
|
},
|
|
@@ -542,8 +542,8 @@ const until = {
|
|
|
// var arr = [1,9,8,8,7,2,5,3,3,3,2,3,1,4,5,444,55,22];
|
|
|
noRepeatSe(arr) {
|
|
|
let newArr = [];
|
|
|
- for(i=0; i<arr.length; i++){
|
|
|
- if(!newArr.includes(arr[i])){
|
|
|
+ for (i = 0; i < arr.length; i++) {
|
|
|
+ if (!newArr.includes(arr[i])) {
|
|
|
newArr.push(arr[i])
|
|
|
}
|
|
|
}
|
|
@@ -555,7 +555,7 @@ const until = {
|
|
|
let str = argu.split('?')[1]
|
|
|
let result = {}
|
|
|
let temp = str.split('&')
|
|
|
- for(let i=0; i<temp.length; i++) {
|
|
|
+ for (let i = 0; i < temp.length; i++) {
|
|
|
let temp2 = temp[i].split('=')
|
|
|
result[temp2[0]] = temp2[1]
|
|
|
}
|
|
@@ -566,7 +566,7 @@ const until = {
|
|
|
countStr(str) {
|
|
|
let json = {}
|
|
|
//循环完毕后会得到一个对象 如{a:0,b:1,c:2}
|
|
|
- for(let i=0; i<str.length; i++) {
|
|
|
+ for (let i = 0; i < str.length; i++) {
|
|
|
if (!json[str.charAt(i)]) {
|
|
|
json[str.charAt(i)] = 1
|
|
|
} else {
|
|
@@ -579,7 +579,7 @@ const until = {
|
|
|
if (obj instanceof Object) {
|
|
|
let isArray = Array.isArray(obj)
|
|
|
let cloneObj = isArray ? [] : {}
|
|
|
- for(let key in obj) {
|
|
|
+ for (let key in obj) {
|
|
|
cloneObj[key] = isObject(obj[key]) ? deepClone(obj[key]) : obj[key]
|
|
|
}
|
|
|
return cloneObj
|
|
@@ -589,7 +589,7 @@ const until = {
|
|
|
},
|
|
|
// 防抖
|
|
|
debounce(fn, delay) {
|
|
|
-
|
|
|
+
|
|
|
var delay = delay || 200;
|
|
|
var timer;
|
|
|
return function () {
|