Commit 4f5904b4 by 杨明

fixed

1 parent d1fb8f34
......@@ -6,7 +6,7 @@
* @param {*} params
* @returns
*/
import { http_common } from '@/main'
import { http_common, http } from '@/main'
const pictureUpload = params => {
params.method = 'glsx.accounts.biz.common.pictureUpload'
return http_common({
......@@ -17,6 +17,42 @@ const pictureUpload = params => {
noSignAttr: ['file']
})
}
// const pictureUpload = params => {
// params.method = 'scrm.api.equity.common.upload.common.multiple'
// return http({
// url: 'rop-scrm-equity/router',
// data: params,
// sign: true,
// noSignAttr: ['file']
// })
// }
const getUploadFileToken = params => {
params.method = 'glsx.accounts.biz.common.getUploadFileToken'
return http_common({
url: 'http://qcdidicb.glsx.com.cn:7060/router',
method: 'get',
data: params
})
}
const checkAndListFragmentDetail = params => {
params.method = 'glsx.accounts.biz.common.checkAndListFragmentDetail'
return http_common({
url: 'http://qcdidicb.glsx.com.cn:7060/router',
method: 'get',
data: params
})
}
const uploadFileWithFileInfo = params => {
params.method = 'glsx.accounts.biz.common.uploadFileWithFileInfo'
return http_common({
url: 'http://qcdidicb.glsx.com.cn:7060/router',
method: 'get',
data: params
})
}
export default {
pictureUpload
pictureUpload,
getUploadFileToken,
checkAndListFragmentDetail,
uploadFileWithFileInfo
}
/*
* JavaScript MD5
* https://github.com/blueimp/JavaScript-MD5
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* https://opensource.org/licenses/MIT
*
* Based on
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/* global define */
;(function ($) {
'use strict'
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safeAdd (x, y) {
var lsw = (x & 0xffff) + (y & 0xffff)
var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
return (msw << 16) | (lsw & 0xffff)
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bitRotateLeft (num, cnt) {
return (num << cnt) | (num >>> (32 - cnt))
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5cmn (q, a, b, x, s, t) {
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)
}
function md5ff (a, b, c, d, x, s, t) {
return md5cmn((b & c) | (~b & d), a, b, x, s, t)
}
function md5gg (a, b, c, d, x, s, t) {
return md5cmn((b & d) | (c & ~d), a, b, x, s, t)
}
function md5hh (a, b, c, d, x, s, t) {
return md5cmn(b ^ c ^ d, a, b, x, s, t)
}
function md5ii (a, b, c, d, x, s, t) {
return md5cmn(c ^ (b | ~d), a, b, x, s, t)
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binlMD5 (x, len) {
/* append padding */
x[len >> 5] |= 0x80 << (len % 32)
x[((len + 64) >>> 9 << 4) + 14] = len
var i
var olda
var oldb
var oldc
var oldd
var a = 1732584193
var b = -271733879
var c = -1732584194
var d = 271733878
for (i = 0; i < x.length; i += 16) {
olda = a
oldb = b
oldc = c
oldd = d
a = md5ff(a, b, c, d, x[i], 7, -680876936)
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586)
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819)
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330)
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897)
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426)
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341)
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983)
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416)
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417)
c = md5ff(c, d, a, b, x[i + 10], 17, -42063)
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162)
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682)
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101)
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290)
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329)
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510)
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632)
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713)
b = md5gg(b, c, d, a, x[i], 20, -373897302)
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691)
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083)
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335)
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848)
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438)
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690)
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961)
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501)
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467)
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784)
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473)
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734)
a = md5hh(a, b, c, d, x[i + 5], 4, -378558)
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463)
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562)
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556)
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060)
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353)
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632)
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640)
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174)
d = md5hh(d, a, b, c, x[i], 11, -358537222)
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979)
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189)
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487)
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835)
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520)
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651)
a = md5ii(a, b, c, d, x[i], 6, -198630844)
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415)
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905)
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055)
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571)
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606)
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523)
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799)
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359)
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744)
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380)
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649)
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070)
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379)
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259)
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551)
a = safeAdd(a, olda)
b = safeAdd(b, oldb)
c = safeAdd(c, oldc)
d = safeAdd(d, oldd)
}
return [a, b, c, d]
}
/*
* Convert an array of little-endian words to a string
*/
function binl2rstr (input) {
var i
var output = ''
var length32 = input.length * 32
for (i = 0; i < length32; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xff)
}
return output
}
/*
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binl (input) {
var i
var output = []
output[(input.length >> 2) - 1] = undefined
for (i = 0; i < output.length; i += 1) {
output[i] = 0
}
var length8 = input.length * 8
for (i = 0; i < length8; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << (i % 32)
}
return output
}
/*
* Calculate the MD5 of a raw string
*/
function rstrMD5 (s) {
return binl2rstr(binlMD5(rstr2binl(s), s.length * 8))
}
/*
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
function rstrHMACMD5 (key, data) {
var i
var bkey = rstr2binl(key)
var ipad = []
var opad = []
var hash
ipad[15] = opad[15] = undefined
if (bkey.length > 16) {
bkey = binlMD5(bkey, key.length * 8)
}
for (i = 0; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636
opad[i] = bkey[i] ^ 0x5c5c5c5c
}
hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8)
return binl2rstr(binlMD5(opad.concat(hash), 512 + 128))
}
/*
* Convert a raw string to a hex string
*/
function rstr2hex (input) {
var hexTab = '0123456789abcdef'
var output = ''
var x
var i
for (i = 0; i < input.length; i += 1) {
x = input.charCodeAt(i)
output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f)
}
return output
}
/*
* Encode a string as utf-8
*/
function str2rstrUTF8 (input) {
return unescape(encodeURIComponent(input))
}
/*
* Take string arguments and return either raw or hex encoded strings
*/
function rawMD5 (s) {
return rstrMD5(str2rstrUTF8(s))
}
function hexMD5 (s) {
return rstr2hex(rawMD5(s))
}
function rawHMACMD5 (k, d) {
return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d))
}
function hexHMACMD5 (k, d) {
return rstr2hex(rawHMACMD5(k, d))
}
function md5 (string, key, raw) {
if (!key) {
if (!raw) {
return hexMD5(string)
}
return rawMD5(string)
}
if (!raw) {
return hexHMACMD5(key, string)
}
return rawHMACMD5(key, string)
}
if (typeof define === 'function' && define.amd) {
define(function () {
return md5
})
} else if (typeof module === 'object' && module.exports) {
module.exports = md5
} else {
$.md5 = md5
}
})(this)
import MD5 from 'js-md5'
const sign = (params, noSignAttr = []) => {
delete params.sign
const secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
const keys = Object.keys(params).sort()
var str = []
// for (const key in params) {
// if (typeof params[key] === 'object') params[key] = JSON.stringify(params[key])
// }
var obj = null
for (const key in params) {
obj = params[key]
if (obj === null || obj === undefined) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
params[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + params[e])
})
params.sign = MD5(secret + str.join('') + secret)
return params
}
export default sign
(function(factory){if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{var glob;try{glob=window}catch(e){glob=self}glob.SparkMD5=factory()}})(function(undefined){"use strict";var add32=function(a,b){return a+b&4294967295},hex_chr=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function cmn(q,a,b,x,s,t){a=add32(add32(a,q),add32(x,t));return add32(a<<s|a>>>32-s,b)}function md5cycle(x,k){var a=x[0],b=x[1],c=x[2],d=x[3];a+=(b&c|~b&d)+k[0]-680876936|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[1]-389564586|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[2]+606105819|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[3]-1044525330|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[4]-176418897|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[5]+1200080426|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[6]-1473231341|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[7]-45705983|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[8]+1770035416|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[9]-1958414417|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[10]-42063|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[11]-1990404162|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[12]+1804603682|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[13]-40341101|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[14]-1502002290|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[15]+1236535329|0;b=(b<<22|b>>>10)+c|0;a+=(b&d|c&~d)+k[1]-165796510|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[6]-1069501632|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[11]+643717713|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[0]-373897302|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[5]-701558691|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[10]+38016083|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[15]-660478335|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[4]-405537848|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[9]+568446438|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[14]-1019803690|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[3]-187363961|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[8]+1163531501|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[13]-1444681467|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[2]-51403784|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[7]+1735328473|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[12]-1926607734|0;b=(b<<20|b>>>12)+c|0;a+=(b^c^d)+k[5]-378558|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[8]-2022574463|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[11]+1839030562|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[14]-35309556|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[1]-1530992060|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[4]+1272893353|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[7]-155497632|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[10]-1094730640|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[13]+681279174|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[0]-358537222|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[3]-722521979|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[6]+76029189|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[9]-640364487|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[12]-421815835|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[15]+530742520|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[2]-995338651|0;b=(b<<23|b>>>9)+c|0;a+=(c^(b|~d))+k[0]-198630844|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[7]+1126891415|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[14]-1416354905|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[5]-57434055|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[12]+1700485571|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[3]-1894986606|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[10]-1051523|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[1]-2054922799|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[8]+1873313359|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[15]-30611744|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[6]-1560198380|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[13]+1309151649|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[4]-145523070|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[11]-1120210379|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[2]+718787259|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[9]-343485551|0;b=(b<<21|b>>>11)+c|0;x[0]=a+x[0]|0;x[1]=b+x[1]|0;x[2]=c+x[2]|0;x[3]=d+x[3]|0}function md5blk(s){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=s.charCodeAt(i)+(s.charCodeAt(i+1)<<8)+(s.charCodeAt(i+2)<<16)+(s.charCodeAt(i+3)<<24)}return md5blks}function md5blk_array(a){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=a[i]+(a[i+1]<<8)+(a[i+2]<<16)+(a[i+3]<<24)}return md5blks}function md51(s){var n=s.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk(s.substring(i-64,i)))}s=s.substring(i-64);length=s.length;tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i<length;i+=1){tail[i>>2]|=s.charCodeAt(i)<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function md51_array(a){var n=a.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk_array(a.subarray(i-64,i)))}a=i-64<n?a.subarray(i-64):new Uint8Array(0);length=a.length;tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i<length;i+=1){tail[i>>2]|=a[i]<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function rhex(n){var s="",j;for(j=0;j<4;j+=1){s+=hex_chr[n>>j*8+4&15]+hex_chr[n>>j*8&15]}return s}function hex(x){var i;for(i=0;i<x.length;i+=1){x[i]=rhex(x[i])}return x.join("")}if(hex(md51("hello"))!=="5d41402abc4b2a76b9719d911017c592"){add32=function(x,y){var lsw=(x&65535)+(y&65535),msw=(x>>16)+(y>>16)+(lsw>>16);return msw<<16|lsw&65535}}if(typeof ArrayBuffer!=="undefined"&&!ArrayBuffer.prototype.slice){(function(){function clamp(val,length){val=val|0||0;if(val<0){return Math.max(val+length,0)}return Math.min(val,length)}ArrayBuffer.prototype.slice=function(from,to){var length=this.byteLength,begin=clamp(from,length),end=length,num,target,targetArray,sourceArray;if(to!==undefined){end=clamp(to,length)}if(begin>end){return new ArrayBuffer(0)}num=end-begin;target=new ArrayBuffer(num);targetArray=new Uint8Array(target);sourceArray=new Uint8Array(this,begin,num);targetArray.set(sourceArray);return target}})()}function toUtf8(str){if(/[\u0080-\uFFFF]/.test(str)){str=unescape(encodeURIComponent(str))}return str}function utf8Str2ArrayBuffer(str,returnUInt8Array){var length=str.length,buff=new ArrayBuffer(length),arr=new Uint8Array(buff),i;for(i=0;i<length;i+=1){arr[i]=str.charCodeAt(i)}return returnUInt8Array?arr:buff}function arrayBuffer2Utf8Str(buff){return String.fromCharCode.apply(null,new Uint8Array(buff))}function concatenateArrayBuffers(first,second,returnUInt8Array){var result=new Uint8Array(first.byteLength+second.byteLength);result.set(new Uint8Array(first));result.set(new Uint8Array(second),first.byteLength);return returnUInt8Array?result:result.buffer}function hexToBinaryString(hex){var bytes=[],length=hex.length,x;for(x=0;x<length-1;x+=2){bytes.push(parseInt(hex.substr(x,2),16))}return String.fromCharCode.apply(String,bytes)}function SparkMD5(){this.reset()}SparkMD5.prototype.append=function(str){this.appendBinary(toUtf8(str));return this};SparkMD5.prototype.appendBinary=function(contents){this._buff+=contents;this._length+=contents.length;var length=this._buff.length,i;for(i=64;i<=length;i+=64){md5cycle(this._hash,md5blk(this._buff.substring(i-64,i)))}this._buff=this._buff.substring(i-64);return this};SparkMD5.prototype.end=function(raw){var buff=this._buff,length=buff.length,i,tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ret;for(i=0;i<length;i+=1){tail[i>>2]|=buff.charCodeAt(i)<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.prototype.reset=function(){this._buff="";this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}};SparkMD5.prototype.setState=function(state){this._buff=state.buff;this._length=state.length;this._hash=state.hash;return this};SparkMD5.prototype.destroy=function(){delete this._hash;delete this._buff;delete this._length};SparkMD5.prototype._finish=function(tail,length){var i=length,tmp,lo,hi;tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(this._hash,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=this._length*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(this._hash,tail)};SparkMD5.hash=function(str,raw){return SparkMD5.hashBinary(toUtf8(str),raw)};SparkMD5.hashBinary=function(content,raw){var hash=md51(content),ret=hex(hash);return raw?hexToBinaryString(ret):ret};SparkMD5.ArrayBuffer=function(){this.reset()};SparkMD5.ArrayBuffer.prototype.append=function(arr){var buff=concatenateArrayBuffers(this._buff.buffer,arr,true),length=buff.length,i;this._length+=arr.byteLength;for(i=64;i<=length;i+=64){md5cycle(this._hash,md5blk_array(buff.subarray(i-64,i)))}this._buff=i-64<length?new Uint8Array(buff.buffer.slice(i-64)):new Uint8Array(0);return this};SparkMD5.ArrayBuffer.prototype.end=function(raw){var buff=this._buff,length=buff.length,tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i,ret;for(i=0;i<length;i+=1){tail[i>>2]|=buff[i]<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.ArrayBuffer.prototype.reset=function(){this._buff=new Uint8Array(0);this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.ArrayBuffer.prototype.getState=function(){var state=SparkMD5.prototype.getState.call(this);state.buff=arrayBuffer2Utf8Str(state.buff);return state};SparkMD5.ArrayBuffer.prototype.setState=function(state){state.buff=utf8Str2ArrayBuffer(state.buff,true);return SparkMD5.prototype.setState.call(this,state)};SparkMD5.ArrayBuffer.prototype.destroy=SparkMD5.prototype.destroy;SparkMD5.ArrayBuffer.prototype._finish=SparkMD5.prototype._finish;SparkMD5.ArrayBuffer.hash=function(arr,raw){var hash=md51_array(new Uint8Array(arr)),ret=hex(hash);return raw?hexToBinaryString(ret):ret};return SparkMD5});
import MD5 from 'md5'
var w = {}
let uploadInfo = {}
let that = {}
const options = {
showprocess: true,
action: '',
tips: '',
size: 2,
url: '',
success: ''
}
that.config = {
id: '',
token: '',
app_key: '48e5e13229b82c1b4e6e8c96151f0637',
v: '1.0.0',
format: 'json',
url: 'http://qcdidicb.glsx.com.cn:7060/router',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
}
/**
* 参数序列化
*/
uploadInfo.formRequestData = function(data) {
var _sendstr = null
if (data) {
_sendstr = ''
for (var i in data) {
_sendstr += (_sendstr ? '&' : '') + i + '=' + encodeURIComponent(data[i])
}
}
return _sendstr
}
/**
* 检查文件是否上传
*/
/**
* 文件切片
*/
uploadInfo.fileSlice = function(oParams) {
if (!oParams) {
return false
}
var o = options
var file = oParams.file
var cellBlod = []
var cell = Number(o.size) * 1024 * 1024 //单个分片的大小
var size = oParams.size //文件大小
var num = Math.ceil(size / cell) //计算分片的个数
if (num == 1) {
cellBlod.push(file)
} else {
for (var i = 0; i < num; i++) {
var s = i * cell
var e = (i + 1) * cell
var m = ''
if (file.slice) {
m = file.slice(s, e)
}
//兼容firefox
if (file.mozSlice) {
m = file.mozSlice(s, e)
}
// 兼容webkit
if (file.webkitSlice) {
m = file.webkitSlice(s, e)
}
cellBlod.push(m)
}
}
return cellBlod
}
/**
* 获取文件类型
*/
uploadInfo.getFileType = function(file) {
if (!file) {
return false
}
var arr = file.split('.')
return arr[arr.length - 1]
}
/**
* arrbuffer转换成base64
*/
uploadInfo.transformArrayBufferToBase64 = function(buffer) {
var binary = ''
var bytes = new Uint8Array(buffer)
for (var len = bytes.byteLength, i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i])
}
return window.btoa(binary)
}
/**
* 生成签名
*/
uploadInfo.createSign = function(params) {
var secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
var noSignAttr = []
delete params.sign
noSignAttr.push('refreshTable')
var keys = Object.keys(params).sort()
var str = []
var obj = null
for (const key in params) {
obj = params[key]
if (obj === null || obj === undefined) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
params[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + params[e])
})
params.sign = MD5(secret + str.join('') + secret)
return params
}
/**
* 获取参数
*/
uploadInfo.getParams = function(index, oInfo) {
var o = that.options
var k = that.config
var oParams = {}
var len = w.list.length
var size = Number(o.size * 1024 * 1024)
// console.log(o.size)
// console.log(w);
// console.log('个数:' + w.list.length);
// console.log('当前个数' + index)
if (len > 1 && index == len - 1) {
size = w.fileSize - o.size * 1024 * 1024 * (w.list.length - 2)
}
//只有一个分片
if (w.list.length == 1) {
size = w.fileSize
}
var spark = new MD5()
spark.append(oInfo)
oParams.app_key = k.app_key
oParams.v = k.v
oParams.timestamp = new Date().getTime()
oParams.format = k.format
oParams.source = '2323242323'
oParams.method = 'glsx.accounts.biz.common.uploadFileWithFileInfo'
oParams.token = w.token
oParams.number = index + 1
oParams.fileType = w.fileType
oParams.fileName = w.fileName
oParams.fileSize = w.fileSize
oParams.fileFragmentSize = size
oParams.fileUpSum = w.list.length
oParams.fileMD5 = w.fileMD5
oParams.fragmentMD5 = spark.end()
// for (let k in m) {
// oParams.append(k, m[k]);
// }
return uploadInfo.createSign(oParams)
}
export default uploadInfo
......@@ -148,7 +148,7 @@ export default {
this.$message.info('图片格式不正确')
return false
}
if (file.size / 1024 / 1000 > 40) {
if (file.size / 1024 / 1000 > 10) {
this.$message.info('请上传小于10M的图片')
return
}
......
......@@ -2,7 +2,7 @@
<div class="import-main" v-loading="loading">
<div class="upload-container">
<div class="upload-item" v-for="(item, index) in fileList" :key="item">
<div class="upload-label" :style="{ width: textNum * 18 + 'px' }">
<div class="upload-label" :style="{ width: textNum * 20 + 'px' }">
<label v-if="item.flag">*</label>
{{ item.templateName }}:
</div>
......@@ -68,7 +68,9 @@
<script>
import * as XLSX from 'xlsx'
import util from '@/utils/util'
import uploadInfo from '@/utils/upload'
import selectEmp from '@/components/selectEmp'
import MD5 from 'md5'
export default {
name: 'step-first',
......@@ -198,12 +200,111 @@ export default {
/* 获取文件的第一个工作表(WorkSheet) */
const wsname = wb.SheetNames[0]
const ws = wb.Sheets[wsname]
if (!ws['!ref']) {
this.$message.error('格式错误')
this.loading = false
return
}
const data = this.getHeaderRow(ws)
resolve(data)
}
reader.readAsBinaryString(file)
})
},
send(arr) {
let max = 3 //最多允许同时执行的ajax次数
var current = 0 //当前有多少ajax正在执行
// var _name = getFileType(w.fileName);
var _num = 0
var len = arr.length
var hasFile = false
for (let i = len - 1; i >= 0; i--) {
var _index = i
var fileBase64 = uploadInfo.transformArrayBufferToBase64(arr[i])
var oParams = uploadInfo.getParams(_index, fileBase64)
var o = {}
oParams.file = oParams.fileType + '@' + fileBase64
o.method = 'POST'
o.data = oParams
//fileFragmentUpload(o);
//如果存在url,则直接跳出循环
if (hasFile) {
return false
}
this.$apis.common.getUploadFileToken(o).then(res => {
if (res.code == 0) {
_num++
var _obj = res.data
// 如果有进度条,则设置对应的进度条属性
//如果存在url,则直接跳出循环
if (res.data.fileUrl) {
hasFile = true
return false
}
}
})
}
},
//创建worker分线程
createWorker() {
let self = this
var myWorker = function() {
// let that = this
let w = {}
this.addEventListener(
'message',
function(e) {
var _obj = e.data
var files = self.file
console.log(self)
var reader = new FileReader()
w.config = _obj.config
w.options = _obj.options
w.file = _obj.file
//var r1 = getToken(files);
reader.readAsArrayBuffer(files)
reader.onload = function(e) {
var hexHash = MD5(e.target.res)
if (hexHash) {
console.log('加密结束:' + new Date().getTime())
}
var oParams = {}
oParams.fileMD5 = hexHash
oParams.file = e.target.result
oParams.size = files.size
//w.fileMD5 = hexHash;
this.postMessage(oParams)
/*var _arr = fileSlice(oParams);
console.log(_arr)
w.list = _arr;
Promise.all([r1]).then(res => {
checkFileIsUpload(hexHash).then(res => {
console.log(res);
if (res.code == 0) {
send(_arr);
}
});
})*/
}
},
false
)
}
var workerData = new Blob(['(' + myWorker.toString() + ')()'], {
type: 'text/javascript'
})
return workerData
},
async uploadFile(e, uploadItem, index) {
const file = e.srcElement.files[0]
let AllImgExt = '.xls|.xlsx'
......@@ -214,11 +315,10 @@ export default {
return false
}
const size = file.size / 1024 / 1024
if (size > 30) {
this.$message.error('单文件体积需小于30M')
if (size > 8) {
this.$message.error('单文件体积需小于8M')
return
}
this.loading = true
const header = await this.compareHeader(file)
if (util.getArrayIsSubset(header, this.tabelHeaderModel[index])) {
......@@ -232,7 +332,10 @@ export default {
uploadItem.size = size
uploadItem.fileName = file.name
this.loading = false
// this.$apis.common.pictureUpload({ file: fileInfo }).then(res => {
// const params = {}
// console.log(fileInfo)
// params.fileList = [{ file: fileInfo, fileType: 'doc' }]
// this.$apis.common.pictureUpload(params).then(res => {
// uploadItem.fileUrl = res
// uploadItem.size = size
// uploadItem.fileName = file.name
......@@ -242,6 +345,7 @@ export default {
}
} else {
uploadItem.fileName = file.name
uploadItem.fileInfo = ''
this.loading = false
}
},
......@@ -345,6 +449,7 @@ export default {
color: #333333;
line-height: 20px;
text-align: right;
min-width: 110px;
label {
color: #eb4e4e;
}
......
......@@ -2,7 +2,7 @@
<div class="import-main">
<div class="upload-process">
<div class="upload-process-item" v-for="(item, index) in process" :key="item">
<div class="process-item-label">
<div class="process-item-label" :style="{ width: textNum * 20 + 'px' }">
<label>*</label>
{{ item.templateName }}:
</div>
......@@ -27,7 +27,7 @@
</div>
</div>
</div>
<el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
<el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose" top="30vh">
<div class="dialog-body">
<div class="dialog-tips-icon"><i class="el-icon-warning"></i></div>
<div class="dialog-tips-text">点击继续将开始上传数据文件</div>
......@@ -43,17 +43,19 @@
<el-button size="small" type="primary" @click="handleSure">确 定</el-button>
</div>
</el-dialog>
<div class="loading-containner" v-if="processLoading"></div>
</div>
</template>
<script>
import { utils } from 'glsx-common'
export default {
name: 'step-second',
props: {},
data() {
return {
textNum: 0,
processLoading: false,
resultNum: 0,
dialogVisible: false,
setInter: [],
......@@ -63,9 +65,8 @@ export default {
},
mounted() {},
beforeDestroy() {
this.resultNum = 0
this.setInter.forEach(item => {
clearInterval(this.setInter)
item && clearInterval(item)
})
},
methods: {
......@@ -84,6 +85,7 @@ export default {
this.uploadItem = info
const fileList = info.fileList
this.process = fileList.map(p => {
this.textNum = this.textNum > p.templateName.length ? this.textNum : p.templateName.length + 1
return {
percentage: 0,
fileName: p.fileName,
......@@ -95,7 +97,8 @@ export default {
this.dialogVisible = true
},
async refresh(index) {
this.process[index].percentage = 100
this.processLoading = true
this.process[index].percentage = 0
this.setInter[index] = setInterval(this.addProcess(index), 300)
try {
this.uploadItem.fileList[index].fileUrl = await this.$apis.common.pictureUpload({ file: this.uploadItem.fileList[index].fileInfo })
......@@ -106,11 +109,13 @@ export default {
this.datacubeUpload()
}
} catch (e) {
this.processLoading = false
this.process[index].percentage = 0
clearInterval(this.setInter[index])
}
},
datacubeUpload() {
this.processLoading = false
const fileList = this.uploadItem.fileList.map(item => {
return {
templateName: item.templateName,
......@@ -121,7 +126,7 @@ export default {
businessTypeName: item.businessTypeName
}
})
let params = { fileList, createdStaffId: this.$globalState.session.id }
let params = { fileList, createdStaffId: this.$globalState.session.id, remarks: this.uploadItem.remarks, staffIdList: this.uploadItem.staffIdList }
this.$apis.square.datacubeUpload(params).then(res => {
if (res) {
this.$emit('handleSuccess')
......@@ -133,6 +138,7 @@ export default {
p.percentage = Math.random() * 30
})
this.resultNum = 0
this.processLoading = true
this.uploadItem.fileList.forEach(async (item, index) => {
this.$set(this.setInter, index, setInterval(this.addProcess(index), 300))
try {
......@@ -144,6 +150,7 @@ export default {
this.datacubeUpload()
}
} catch (e) {
this.processLoading = false
this.process[index].percentage = 0
clearInterval(this.setInter[index])
}
......@@ -203,6 +210,15 @@ export default {
</script>
<style lang="scss" scoped>
.loading-containner {
top: 0px;
left: 0px;
position: fixed;
width: 100%;
background: rgba(255, 255, 255, 0.1);
z-index: 5000;
height: 100%;
}
.import-main {
margin: 60px auto 0px;
width: 92%;
......@@ -215,7 +231,9 @@ export default {
font-size: 14px;
font-weight: 400;
color: #333333;
min-width: 120px;
line-height: 20px;
text-align: right;
label {
color: #eb4e4e;
}
......
......@@ -62,7 +62,7 @@
</div>
<GLFooter>
<el-button type="primary" @click="handleNext" v-show="activeIndex == 1">下一步</el-button>
<el-button type="primary" @click="$router.go(-1)" v-show="activeIndex == 3">返回魔方</el-button>
<el-button type="primary" @click="goBack" v-show="activeIndex == 3">返回魔方</el-button>
</GLFooter>
</div>
</template>
......@@ -109,6 +109,9 @@ export default {
}
},
methods: {
goBack() {
this.$router.push('/square/index')
},
// 从网络上读取某个excel文件,url必须同域,否则报错
readWorkbookFromRemoteFile() {
var xhr = new XMLHttpRequest()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!