|
@@ -70,10 +70,10 @@ export default {
|
|
type: String,
|
|
type: String,
|
|
default: "text",
|
|
default: "text",
|
|
},
|
|
},
|
|
- // platformId: {
|
|
|
|
- // type: Number,
|
|
|
|
- // default: "",
|
|
|
|
- // },
|
|
|
|
|
|
+ platformId: {
|
|
|
|
+ type: Number,
|
|
|
|
+ default: null,
|
|
|
|
+ },
|
|
// 是否支持自动上传
|
|
// 是否支持自动上传
|
|
autoUpload: {
|
|
autoUpload: {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
@@ -124,13 +124,12 @@ export default {
|
|
},
|
|
},
|
|
// 上传地址
|
|
// 上传地址
|
|
action: "#",
|
|
action: "#",
|
|
- platformId: 0,
|
|
|
|
// 请求头部
|
|
// 请求头部
|
|
headers: {
|
|
headers: {
|
|
Authorization: "Bearer " + getToken(),
|
|
Authorization: "Bearer " + getToken(),
|
|
},
|
|
},
|
|
// 额外参数
|
|
// 额外参数
|
|
- data: { platformId: 6 },
|
|
|
|
|
|
+ data: {},
|
|
// 进度条
|
|
// 进度条
|
|
percentage: 0,
|
|
percentage: 0,
|
|
title: "",
|
|
title: "",
|
|
@@ -153,7 +152,6 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
listType(val) {
|
|
listType(val) {
|
|
- console.log("gasdfqwerqwerqwerwqr==xxxxx==" + val);
|
|
|
|
this.action = this.obj[val];
|
|
this.action = this.obj[val];
|
|
},
|
|
},
|
|
|
|
|
|
@@ -164,19 +162,17 @@ export default {
|
|
|
|
|
|
created() {
|
|
created() {
|
|
// 根据上传类型 变更 上传地址
|
|
// 根据上传类型 变更 上传地址
|
|
- console.log("gasdfqwerqwerqwerwqr==yyyy==" + this.listType);
|
|
|
|
this.action = this.obj[this.listType];
|
|
this.action = this.obj[this.listType];
|
|
// 回显图片
|
|
// 回显图片
|
|
this.form.file = this.url;
|
|
this.form.file = this.url;
|
|
- this.form.platformId = this.platformId;
|
|
|
|
- this.data.platformId = this.platformId;
|
|
|
|
|
|
+ var platformId = this.$props.platformId;
|
|
|
|
+ this.form.platformId = this.$props.platformId;
|
|
|
|
+ this.data.platformId = this.$props.platformId;
|
|
},
|
|
},
|
|
|
|
+
|
|
methods: {
|
|
methods: {
|
|
// 上传之前
|
|
// 上传之前
|
|
async beforeUpload(file) {
|
|
async beforeUpload(file) {
|
|
- console.log("gasdfqwerqwerqwerwqr==111==" + JSON.stringify(file));
|
|
|
|
- console.log("gasdfqwerqwerqwerwqr==aaa==" + JSON.stringify(this.form));
|
|
|
|
- console.log("gasdfqwerqwerqwerwqr==bbb==" + JSON.stringify(this.data));
|
|
|
|
if (this.width && this.height) {
|
|
if (this.width && this.height) {
|
|
const data = await this.readerImg(file);
|
|
const data = await this.readerImg(file);
|
|
let _width =
|
|
let _width =
|
|
@@ -204,7 +200,6 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
readerImg(file) {
|
|
readerImg(file) {
|
|
- console.log("gasdfqwerqwerqwerwqr==222==" + file);
|
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
const reader = new FileReader();
|
|
const reader = new FileReader();
|
|
reader.readAsDataURL(file);
|
|
reader.readAsDataURL(file);
|
|
@@ -227,16 +222,22 @@ export default {
|
|
this.title = `已上传 ${parseInt(file.percent - 1)}%`;
|
|
this.title = `已上传 ${parseInt(file.percent - 1)}%`;
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // {"data":null,"code":0,"message":"请求成功","requestId":null,"success":true}
|
|
// 上传成功
|
|
// 上传成功
|
|
onSuccess(file) {
|
|
onSuccess(file) {
|
|
- console.log("gasdfqwerqwerqwerwqr==333==" + JSON.stringify(file));
|
|
|
|
if (file.code === 0) {
|
|
if (file.code === 0) {
|
|
this.form.file = file.data;
|
|
this.form.file = file.data;
|
|
this.$emit("upload", this.form);
|
|
this.$emit("upload", this.form);
|
|
this.title = "上传成功";
|
|
this.title = "上传成功";
|
|
this.type = "success";
|
|
this.type = "success";
|
|
|
|
+ if (this.form.platformId != null && this.form.platformId != "") {
|
|
|
|
+ this.$message.success(`上传成功`);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
this.onError();
|
|
this.onError();
|
|
|
|
+ if (this.form.platformId != null && this.form.platformId != "") {
|
|
|
|
+ this.$message.success(`上传失败`);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -245,6 +246,9 @@ export default {
|
|
this.status = "exception";
|
|
this.status = "exception";
|
|
this.type = "danger";
|
|
this.type = "danger";
|
|
this.title = "上传失败";
|
|
this.title = "上传失败";
|
|
|
|
+ if (this.form.platformId != null && this.form.platformId != "") {
|
|
|
|
+ this.$message.success(`上传失败`);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
// 删除
|
|
// 删除
|