|
@@ -183,6 +183,7 @@ export default {
|
|
|
hosts: {
|
|
|
type: String,
|
|
|
required: false,
|
|
|
+ default: "",
|
|
|
},
|
|
|
/**
|
|
|
* 可上传的文件数
|
|
@@ -233,6 +234,24 @@ export default {
|
|
|
type: Boolean,
|
|
|
default: true,
|
|
|
},
|
|
|
+ initValue: {
|
|
|
+ type: [String, Number, Array, Object],
|
|
|
+ default: () => {
|
|
|
+ return [];
|
|
|
+ },
|
|
|
+ },
|
|
|
+ formItemObj: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {
|
|
|
+ return { isMultiple: false };
|
|
|
+ },
|
|
|
+ },
|
|
|
+ info: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {
|
|
|
+ return {};
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
// 限制上传
|
|
@@ -267,12 +286,17 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
mounted() {
|
|
|
- const templateList = JSON.parse(JSON.stringify(this.defaultFileList)),
|
|
|
- flag = !this.previewMode
|
|
|
- ? this.defaultFileList.length > this.limitMaxNumber
|
|
|
- : false;
|
|
|
- if (flag) templateList.splice(this.limitMaxNumber, templateList.length - 1);
|
|
|
- this.renderImageList = templateList;
|
|
|
+ if (!Array.isArray(this.defaultFileList)) {
|
|
|
+ this.renderImageList = [];
|
|
|
+ } else {
|
|
|
+ const templateList = JSON.parse(JSON.stringify(this.defaultFileList)),
|
|
|
+ flag = !this.previewMode
|
|
|
+ ? this.defaultFileList.length > this.limitMaxNumber
|
|
|
+ : false;
|
|
|
+ if (flag)
|
|
|
+ templateList.splice(this.limitMaxNumber, templateList.length - 1);
|
|
|
+ this.renderImageList = templateList;
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
// 图片缩放
|
|
@@ -490,6 +514,7 @@ export default {
|
|
|
* 上传文
|
|
|
*/
|
|
|
async featchUpload(fileItem) {
|
|
|
+ console.log(this.renderImageList, " 22");
|
|
|
const _currentIndex = this.renderImageList.findIndex(
|
|
|
(item) => item.name === fileItem.name
|
|
|
);
|
|
@@ -519,11 +544,17 @@ export default {
|
|
|
uploadProgressCall: function (_obj) {
|
|
|
console.log("uploadProgressCall", _obj);
|
|
|
},
|
|
|
- oneUploadedCall: function (_obj) {
|
|
|
+ oneUploadedCall: async (_obj) => {
|
|
|
console.log("oneUploadedCall", _obj);
|
|
|
- const _data =
|
|
|
- typeof response === "string" ? JSON.parse(response) : response;
|
|
|
- // _this.handleData(fileItem, _data, 'done');
|
|
|
+ const viewUrl = await FileController.getImgViewUrl(_obj.fileId);
|
|
|
+ console.log(viewUrl);
|
|
|
+ const _data = {
|
|
|
+ url: viewUrl,
|
|
|
+ fileId: _obj.fileId,
|
|
|
+ };
|
|
|
+ // const _data =
|
|
|
+ // typeof response === "string" ? JSON.parse(response) : response;
|
|
|
+ _this.handleData(fileItem, _data, "done");
|
|
|
},
|
|
|
files: [
|
|
|
{
|
|
@@ -586,6 +617,7 @@ export default {
|
|
|
suffix: fileItem.type, // 文件格式
|
|
|
progressRate: 100, // 上传进度
|
|
|
size: fileItem.size,
|
|
|
+ fileId: response.fileId,
|
|
|
};
|
|
|
_this.renderImageList.splice(_currentIndex, 1, templateFile);
|
|
|
} else {
|