Commit 1ec7ac34 authored by Mac's avatar Mac

1

parent acbb2a60
This diff is collapsed.
This diff is collapsed.
......@@ -6,6 +6,65 @@ export default{
apiurl: ''
},
install(Vue, options){
//消息成功提示
Vue.prototype.Success = function (msg) {
this.$message({
message: msg,
duration: 2000,
type: "success"
});
},
//错误提示
Vue.prototype.Error = function (msg) {
this.$message({
message: msg,
duration: 2000,
type: "error"
});
},
//一般提示
Vue.prototype.Info = function (msg) {
this.$message({
message: msg,
duration: 2000,
type: "info"
});
},
//警告提示
Vue.prototype.Warning = function (msg) {
this.$message({
message: msg,
duration: 2000,
type: "warning"
});
},
//Confirm
Vue.prototype.Confirm = function (msg, callback) {
this.$confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
if (typeof callback === 'function') {
callback();
}
})
.catch(() => {
this.Info("已取消操作");
});
},
Vue.prototype.random_string = function (len) {
len = len || 32;
var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
var maxPos = chars.length;
var pwd = '';
for (let i = 0; i < len; i++) {
pwd += chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
},
//ERP本地缓存
Vue.prototype.md5 = md5;
Vue.prototype.getLocalStorage = function () {
......@@ -126,7 +185,70 @@ export default{
successCall(res);
}
}, faildCall)
}
},
Vue.prototype.uploadFile = function (path, files, successCall) {
if (files && files.length > 0) {
let nameList = new Array()
for (let index = 0; index < files.length; index++) {
nameList.push(this.random_string());
}
var oss = new OSS({
region: 'oss-cn-chengdu',
accessKeyId: 'LTAIwE7l9dImZSa3',
accessKeySecret: 'j47Ajn0d0WzUCIX8Biyj3P2r8QDltI',
bucket: 'vt-im-bucket'
})
let that = this;
let checkpoint = null;
let percentage = 0;
co(function* () {
for (let index = 0; index < files.length; index++) {
let fileName = nameList[index]
fileName = "/New" + path + fileName + "." + files[index].name.split('.').pop()
var result = yield oss.multipartUpload(fileName, files[index], {
progress: function* (p) {},
mime: 'application/octet-stream'
})
successCall(result);
}
}).catch(function (err) {
});
}
},
//上传文件到本地服务器
Vue.prototype.UploadSelfFileT = function (path, files, successCall, ocr) {
if (files && files.length > 0) {
let nameList = new Array()
for (let index = 0; index < files.length; index++) {
nameList.push(this.random_string());
}
let that = this;
co(function* () {
for (let index = 0; index < files.length; index++) {
let fileName = nameList[index]
fileName = path + fileName + "." + files[index].name.split('.').pop()
var formData = new FormData();
var uploadUrl = that.domainManager().UploadUrl + "/Upload?filePath=" + path + '&ocr=' + ocr;
formData.append("myfile", files[index]);
that.$http.post(uploadUrl, formData, {})
.then(res => {
successCall(res);
}).catch(function (reason) {
that.$refs['my-upload'].clearFiles();
that.$message.error('上传失败!');
that.MsgBus.$emit('UploadSelfFileErr')
});
}
}).catch(function (err) {
that.$refs['my-upload'].clearFiles();
that.$message.error('上传失败!');
});
}
}
}
}
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