You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.2 KiB

6 months ago
<template>
<div >
<Upload :action="uploadFileUrl" :headers="accessToken" :data="uploadData" :on-success="handleSuccess"
:on-error="handleError" :max-size="100000000" :before-upload="beforeUpload"
multiple type="drag" ref="up">
<div style="padding: 20px 0">
<Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
<p>点击这里或将文件拖拽到这里上传</p>
</div>
</Upload>
<Form ref="form" :model="form" :label-width="85" :rules="formValidate">
<FormItem label="版本号" prop="title">
<Input v-model="form.version" />
</FormItem>
</Form>
<div slot="footer">
<Button type="primary" :loading="submitLoading" @click="handelSubmit">提交</Button>
</div>
</div>
</template>
<script>
import {
getFileCate,
addFileCate,
editFileCate,
uploadFile,
trashFileCate,
searchFileCate,
checkOssSet,
} from "@/api/index";
export default {
name: "fileCategory",
props: {
showOnly: {
type: Boolean,
default: false,
},
},
data() {
return {
uploadFileUrl: uploadFile,
submitLoading: false,
accessToken: {},
uploadData: {},
form:{
path:'',
version:''
}
};
},
methods: {
init() {
this.accessToken = {
accessToken: this.getStore("accessToken"),
};
checkOssSet().then((res) => {
if (!res.success) {
this.$Modal.confirm({
title: "系统还未配置OSS",
content: "管理员还未配置第三方OSS服务,是否现在立即去配置?",
onOk: () => {
this.$router.push({
name: "setting",
query: {
name: "oss"
},
});
},
});
}
});
},
beforeUpload() {
return true;
},
handleSuccess(res, file, fileList) {
if (res.success) {
this.$Message.success("上传文件 " + file.name + " 成功");
this.form.path = res.result
} else {
file.percentage = 0;
file.status = "fail";
file.name += "(上传失败)";
this.$Message.error(res.message);
}
},
handleError(error, file, fileList) {
this.$Message.error(error.toString());
},
handelSubmit() {
console.log(this.form)
}
},
mounted() {
this.init();
},
};
</script>
<style lang="less">
</style>