iview 上传附件
iview上传附件<!DOCTYPE html><html><head>@@include('app/inc/header-auth.inc')<style>#vue-object {padding: 10px;}.search-file {padding: 5...
·
iview 上传附件
<!DOCTYPE html>
<html>
<head>
@@include('app/inc/header-auth.inc')
<style>
#vue-object {
padding: 10px;
}
.search-file {
padding: 5px;
background: #ffffff;
display: inline-block;
width: 100%;
height: 100px;
}
</style>
</head>
<body>
<div class="main" id="vue-object">
<div class="search-file">
<div class="control wp100">
<Upload type="ghost" :action="getUploadUrl()" :on-success="handleSuccess" :headers="getCookie()"
v-model="formValidate.flie" :on-preview="onPreview" :format="['jpg','jpeg','png','doc','txt','xls','pdf','xlsx','docx']" :on-format-error="handleFormatError"
style="width:90%" :default-file-list="formValidate.mylist">
<i-button icon="ios-cloud-upload-outline">上传文件</i-button>
</Upload>
</div>
</div>
<div class="sub">
<template>
<i-button @click="close" style="width:120px">取消</i-button>
</template>
</div>
</div>
</body>
<script>
(function () {
window.vueObject = new Vue({
el: "#vue-object",
data: {
formValidate: {
flie: ''
},
},
created: function () {
},
methods: {
//上传
getUploadUrl() {
return app_server + "/auth/crm/resource/importData"
},
handleSuccess(res, file) {
var that = this;
if (res.code == '200') {
msg(res.data);
if (parent.layer) {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
parent.location.reload();
} else {
errorMsg(res.data);
}
},
getCookie() {
var cookie = getSessionTokenFromCookie();
return {
'Session-Token': cookie
}
},
onPreview(file) {
window.open(file.url);
},
handleFormatError(file) {
errorMsg('文件' + file.name + "格式不正确");
},
close() {
if (parent.layer) {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
},
}
});
}());
</script>
</html>
更多推荐
已为社区贡献1条内容
所有评论(0)