|
@@ -233,20 +233,31 @@ export default {
|
|
|
}
|
|
}
|
|
|
this.$refs.uploadInput.value = []
|
|
this.$refs.uploadInput.value = []
|
|
|
},
|
|
},
|
|
|
|
|
+ getQueryParams(queryName) {
|
|
|
|
|
+ const urlSearchParams = new URLSearchParams(window.location.search);
|
|
|
|
|
+ const query = urlSearchParams.get(queryName);
|
|
|
|
|
+ return JSON.parse(query);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
uploadAction (res, file, key) {
|
|
uploadAction (res, file, key) {
|
|
|
let changeIndex = this.fileList.findIndex(item => item.key === key)
|
|
let changeIndex = this.fileList.findIndex(item => item.key === key)
|
|
|
const xhr = new XMLHttpRequest()
|
|
const xhr = new XMLHttpRequest()
|
|
|
-
|
|
|
|
|
|
|
+ let headers = this.getQueryParams('headers');
|
|
|
|
|
+ console.log(headers.Authorization,'this.headers.Authorization')
|
|
|
const url = this.action
|
|
const url = this.action
|
|
|
xhr.open('POST', url, true)
|
|
xhr.open('POST', url, true)
|
|
|
// xhr.setRequestHeader('Content-Type', 'multipart/form-data')
|
|
// xhr.setRequestHeader('Content-Type', 'multipart/form-data')
|
|
|
this.headers.map(item => {
|
|
this.headers.map(item => {
|
|
|
|
|
+ if (item.key == 'Authorization') {
|
|
|
|
|
+ item.value = headers.Authorization
|
|
|
|
|
+ console.log(item.value, '====111');
|
|
|
|
|
+ }
|
|
|
item.key && xhr.setRequestHeader(item.key, item.fx ? executeExpression(item.value, {}, this.formContext) : item.value)
|
|
item.key && xhr.setRequestHeader(item.key, item.fx ? executeExpression(item.value, {}, this.formContext) : item.value)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
let formData = new FormData()
|
|
let formData = new FormData()
|
|
|
formData.append('multiPartFile', file)
|
|
formData.append('multiPartFile', file)
|
|
|
- formData.append('file', file)
|
|
|
|
|
|
|
+ // formData.append('file', file)
|
|
|
formData.append('fname', file.name)
|
|
formData.append('fname', file.name)
|
|
|
formData.append('key', key)
|
|
formData.append('key', key)
|
|
|
|
|
|
|
@@ -254,9 +265,9 @@ export default {
|
|
|
|
|
|
|
|
xhr.onreadystatechange = () => {
|
|
xhr.onreadystatechange = () => {
|
|
|
if (xhr.readyState === 4) {
|
|
if (xhr.readyState === 4) {
|
|
|
-
|
|
|
|
|
let resData = JSON.parse(xhr.response)
|
|
let resData = JSON.parse(xhr.response)
|
|
|
if (resData && resData.code == 0) {
|
|
if (resData && resData.code == 0) {
|
|
|
|
|
+ console.log('用的新的')
|
|
|
this.$set(this.fileList, this.fileList.findIndex(item => item.key === key), {
|
|
this.$set(this.fileList, this.fileList.findIndex(item => item.key === key), {
|
|
|
...this.fileList[this.fileList.findIndex(item => item.key === key)],
|
|
...this.fileList[this.fileList.findIndex(item => item.key === key)],
|
|
|
percent: 100,
|
|
percent: 100,
|
|
@@ -273,8 +284,7 @@ export default {
|
|
|
status: 'success',
|
|
status: 'success',
|
|
|
...resData.data
|
|
...resData.data
|
|
|
})
|
|
})
|
|
|
- console.log(this.fileList, '====');
|
|
|
|
|
- this.$emit('input', this.fileList)
|
|
|
|
|
|
|
+ this.$emit('update:modelValue', this.fileList)
|
|
|
}, 200)
|
|
}, 200)
|
|
|
} else if (resData && resData.url) {
|
|
} else if (resData && resData.url) {
|
|
|
this.fileList[this.fileList.findIndex(item => item.key === key)] = {
|
|
this.fileList[this.fileList.findIndex(item => item.key === key)] = {
|