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

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

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