isNumberString ( ns) {
if ( isNaN ( Number ( ns) ) ) {
return alert ( '不是数字类型字符串' )
} else {
return alert ( '是数字类型字符串' )
}
} ,
isJSON ( str) {
if ( typeof str == "string" ) {
try {
var obj = JSON . parse ( str) ;
if ( typeof obj == "object" && obj) {
return true ;
} else {
return false ;
}
} catch ( e ) {
return false ;
}
}
}
getRandomColor: function ( ) {
const rgb = [ ]
for ( let i = 0 ; i < 3 ; ++ i) {
let color = Math. floor ( Math. random ( ) * 256 ) . toString ( 16 )
olor = color. length == 1 ? '0' + color : color
gb. push ( color)
}
return '#' + rgb. join ( '' )
}
data ( ) {
return {
docmHeight: "0" ,
showHeight: "0" ,
hidshow: true ,
isResize: false
} ;
} ,
mounted ( ) {
( window. onresize = ( ) => {
return ( ( ) => {
if ( ! this . isResize) {
this . docmHeight = document. documentElement. clientHeight;
this . isResize = true ;
}
this . showHeight = document. body. clientHeight;
} ) ( ) ;
} ) ,
} ,
watch: {
showHeight ( ) {
if ( this . docmHeight > this . showHeight) {
} else {
}
}
} ,
androidVersions ( ) {
var userAgent = navigator. userAgent;
var index = userAgent. indexOf ( "Android" ) ;
if ( index >= 0 ) {
var androidVersion = parseFloat ( userAgent. slice ( index + 8 ) ) ;
if ( androidVersion > 9 ) {
this . versions = androidVersion;
}
}
}
var a = { }
Object. keys ( a) . length ? alert ( 1 ) : alert ( 2 )
handleExport ( ) {
api. wwdy. addHzExport ( {
responseType: "blob" ,
data: {
xxxx: xxxx,
bs: "1" ,
}
} ) . then ( res => {
const content = res. data;
const blob = new Blob ( [ content] ) ;
const fileName = "xxxx.xlsx" ;
if ( "download" in document. createElement ( "a" ) ) {
const elink = document. createElement ( "a" ) ;
elink. download = fileName;
elink. style. display = "none" ;
elink. href = URL . createObjectURL ( blob) ;
document. body. appendChild ( elink) ;
elink. click ( ) ;
URL . revokeObjectURL ( elink. href) ;
document. body. removeChild ( elink) ;
} else {
navigator. msSaveBlob ( blob, fileName) ;
}
} ) ;
} ,
downexcel ( tableid) {
let str = `姓名,性别,xxx,xxxx,xxxxx,xxxxx,xxxxx,xxxx\n` ;
for ( let i = 0 ; i < this . addFormData. wwdyRyList. length; i++ ) {
for ( let item in this . addFormData. xxx[ i] ) {
str += ` ${ this . addFormData. xxxx[ i] [ item] + "\t" } ,` ;
}
str += "\n" ;
}
let uri = "data:text/csv;charset=utf-8,\ufeff" + encodeURIComponent ( str) ;
let link = document. createElement ( "a" ) ;
link. href = uri;
link. download = "文件名.csv" ;
document. body. appendChild ( link) ;
link. click ( ) ;
document. body. removeChild ( link) ;
} ,