|
@@ -12,15 +12,15 @@
|
|
|
:on-error="error"
|
|
|
:http-request="toUpload"
|
|
|
:auto-upload="true"
|
|
|
- :show-file-list="false"
|
|
|
+ :show-file-list="true"
|
|
|
:file-list="fileList"
|
|
|
:limit="limit"
|
|
|
:on-exceed="handleExceed"
|
|
|
:multiple="multiple"
|
|
|
>
|
|
|
- <img v-if="imageUrl" :src="imageUrl" class="avatar" />
|
|
|
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
- <!-- <el-button size="small" type="primary">点击上传</el-button> -->
|
|
|
+ <!-- <img v-if="imageUrl" :src="imageUrl" class="avatar" /> -->
|
|
|
+ <!-- <i v-else class="el-icon-plus avatar-uploader-icon"></i> -->
|
|
|
+ <el-button size="small" type="primary">点击上传</el-button>
|
|
|
</el-upload>
|
|
|
<!-- <el-button @click="download">下载</el-button>-->
|
|
|
</div>
|
|
@@ -28,12 +28,12 @@
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
- name: "upload",
|
|
|
+ name: "uploadVM",
|
|
|
props: {
|
|
|
// 限制上传的个数
|
|
|
limit: {
|
|
|
type: Number,
|
|
|
- default: 100,
|
|
|
+ default: 1,
|
|
|
},
|
|
|
// 一组文件传相同的值,保证其为一组
|
|
|
objectPath: {
|
|
@@ -73,11 +73,19 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
beforeUpload(file) {
|
|
|
- // .jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PNG,.GIF,.BMP
|
|
|
- let arr = ["jpg", "jpeg", "png", "gif", "bmp"];
|
|
|
+ let arr = [];
|
|
|
+
|
|
|
+ if (this.model === "glb") {
|
|
|
+ arr = ["glb"];
|
|
|
+ } else {
|
|
|
+ arr = ["osgb"];
|
|
|
+ }
|
|
|
+
|
|
|
let i = file.name.lastIndexOf(".");
|
|
|
if (!arr.includes(file.name.slice(i + 1).toLowerCase())) {
|
|
|
- this.$message.warning("请上传图片");
|
|
|
+ this.$message.warning(
|
|
|
+ `请上传${this.model.toUpperCase()}格式的文件`
|
|
|
+ );
|
|
|
return false;
|
|
|
}
|
|
|
},
|
|
@@ -113,7 +121,7 @@ export default {
|
|
|
// }
|
|
|
|
|
|
this.attachmentList.splice(removeIndex, 1);
|
|
|
- this.$emit("attachmentChange", this.attachmentList);
|
|
|
+ this.$emit("attachmentDel", this.model);
|
|
|
},
|
|
|
async toUpload(file) {
|
|
|
let _this = this;
|
|
@@ -127,7 +135,7 @@ export default {
|
|
|
// await formData.append("md5", _this.defaultParam.md5);
|
|
|
await formData.append("file", file.file);
|
|
|
|
|
|
- let axios = this.$axios;
|
|
|
+ let axios = this.$instance;
|
|
|
// 处理大文件上传 instance已被设置不携带token
|
|
|
// if (this.needInstance) {
|
|
|
// axios = this.$instance;
|
|
@@ -149,7 +157,17 @@ export default {
|
|
|
});
|
|
|
} */
|
|
|
|
|
|
- let url = this.$api.systemManagement.upload;
|
|
|
+ let url = "";
|
|
|
+ let timeout = 1000 * 60 * 6;
|
|
|
+
|
|
|
+ if (this.model === "glb") {
|
|
|
+ url = this.$api.systemManagement.upload;
|
|
|
+ } else {
|
|
|
+ url = this.$api.common.uploadToLocal;
|
|
|
+ timeout = 1000 * 60 * 30;
|
|
|
+ }
|
|
|
+
|
|
|
+ // let url = this.$api.systemManagement.upload;
|
|
|
// let defaultParam = {};
|
|
|
// // 获取MD5值
|
|
|
// await this.$md5(file.file).then((res) => {
|
|
@@ -163,6 +181,7 @@ export default {
|
|
|
method: "post",
|
|
|
url,
|
|
|
data: formData,
|
|
|
+ timeout,
|
|
|
withCredentials: true,
|
|
|
headers: {
|
|
|
"Content-type": "multipart/form-data",
|
|
@@ -181,11 +200,16 @@ export default {
|
|
|
});
|
|
|
resolve("成功");
|
|
|
this.imageUrl = res.info.previewUrl;
|
|
|
- this.$emit(
|
|
|
- "attachmentChange",
|
|
|
- res.info.fileName,
|
|
|
- this.model
|
|
|
- );
|
|
|
+
|
|
|
+ let name = "";
|
|
|
+
|
|
|
+ if (this.model === "glb") {
|
|
|
+ name = res.info.fileName;
|
|
|
+ } else {
|
|
|
+ name = res.info.filePath;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$emit("attachmentChange", name, this.model);
|
|
|
// 上传完成后进行通知
|
|
|
this.$emit("didUpload", "success");
|
|
|
} else {
|
|
@@ -249,6 +273,10 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang='less' scoped>
|
|
|
+.avatar-uploader {
|
|
|
+ padding-top: 10px;
|
|
|
+}
|
|
|
+
|
|
|
.avatar-uploader .el-upload {
|
|
|
border: 1px dashed #ccc;
|
|
|
border-radius: 6px;
|