Commit 65619364 authored by 沈翠玲's avatar 沈翠玲

生产版本上传文件对接接口

parent c90a2aa3
......@@ -187,7 +187,8 @@
<template slot-scope="scope">
<el-button
size="mini"
icon="el-icon-upload"
:icon="scope.row.drawingList && scope.row.drawingList.length > 0 ? 'el-icon-reading' : 'el-icon-upload'"
:title="scope.row.drawingList && scope.row.drawingList.length > 0 ? '查看文件' : '文件上传'"
@click="openUploadDialog(scope.row, scope.$index)"
>
</el-button>
......@@ -628,7 +629,7 @@ export default {
this.tableData[this.currentRowIndex].processItemList = items;
},
updateItemUpload(items) {
// this.tableData[this.currentRowIndex].processItemList = items;
this.tableData[this.currentRowIndex].drawingList = items;
},
openSetProd(row, idx) {
this.currentRow = row;
......
......@@ -11,29 +11,33 @@
<el-row>
<el-col :span="3">
<el-upload
class="upload-demo"
class="tuzhi-upload"
ref="upload"
:action="baseURL + '/common/uploadMinio '"
:action="baseURL + '/common/upload'"
:before-upload="handleBeforeUpload"
:on-success="handleUploadSuccess"
:on-error="handleUploadError"
name="file"
:headers="headers"
:show-file-list="false">
multiple
:file-list="fileList"
:headers="headers">
<el-button size="small" type="primary" :loading="loading">选择文件上传</el-button>
</el-upload>
</el-col>
</el-row>
<div class="upload-list">
<el-table :data="uploadlist">
<el-table-column align="left" label="名称" width="215" prop="name" >
<el-table :data="drawingList">
<el-table-column align="left" label="名称" width="315" prop="fileOriginalName" >
<template slot-scope="scope">
<i class="el-icon-document"></i>
{{scope.row.name}}
<div @click="openFilename">
<i class="el-icon-document"></i>
{{scope.row.fileOriginalName}}
</div>
</template>
</el-table-column>
<el-table-column align="center" label="大小" prop="size" />
<el-table-column align="left" label="大小" prop="fileSize" >
</el-table-column>
<el-table-column align="center" label="操作" >
<template slot-scope="scope">
<el-button size="small" type="primary" @click="delItem(scope.row, scope.$index)">删除</el-button>
......@@ -56,7 +60,8 @@ export default {
},
data() {
return {
uploadlist: [{name: 'sadas', url: 'ads'}],
drawingList: [],
fileList: [],
baseURL: process.env.VUE_APP_BASE_API,
headers: {
Authorization: "Bearer " + getToken()
......@@ -65,13 +70,22 @@ export default {
loading: false
}
},
watch: {
process(val) {
if (val && val.drawingList && val.drawingList.length > 0) {
this.drawingList = val.drawingList
} else {
this.drawingList = []
}
}
},
created (){
},
methods: {
openFilename() {},
beforeClose(done) {
// 更新父组件的processItemList
this.$emit("updateItem", this.uploadlist);
this.$emit("updateItem", this.drawingList);
done();
},
handleBeforeUpload(file) {
......@@ -86,18 +100,35 @@ export default {
// }
},
delItem(item, index) {
this.uploadlist.splice(index, 1)
this.drawingList.splice(index, 1)
},
handleUploadSuccess(res, file) {
this.loading = false
// 如果上传成功
if (res.code == 200) {
this.uploadlist.push({url: url, name: file.name, size: file.size})
this.$message.success("文件上传成功");
} else {
this.$message.error("文件上传失败");
handleUploadSuccess(res, file, fileList) {
if (fileList.every(item => item.status == 'success')) {
fileList.map((item, index) => {
/** 这时只需要push进带有response的数据就好 */
console.log('item', item)
if(item.response) {
this.fileList.push({
name: item.response.data.originalFilename,
url: item.response.data.filePath
})
this.drawingList.push({filePath: item.response.data.filePath, fileOriginalName: item.response.data.originalFilename, fileSize: item.response.data.size})
}
if(index === fileList.length - 1) {
console.log('清除')
this.$refs.upload.clearFiles();
}
})
}
this.$refs.upload.clearFiles();
// console.log('resresres', res, fileList)
this.loading = false
// // 如果上传成功
// if (res.code == 200) {
// this.$message.success("文件上传成功");
// } else {
// this.$message.error("文件上传失败");
// }
// this.$refs.upload.clearFiles();
},
handleUploadError() {
this.loading = false
......@@ -106,8 +137,11 @@ export default {
}
}
</script>
<style lang="scss" scoped>
<style lang="scss">
.el-icon-document {
color: #3578ff;
}
.tuzhi-upload .el-upload-list {
display: none !important;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment