|
@@ -4,26 +4,11 @@
|
|
|
<div v-show="displayTitle" class="title">
|
|
|
<span v-show="displayStar" style="color: red">*</span> {{ title }}
|
|
|
</div>
|
|
|
- <el-upload
|
|
|
- :disabled="display"
|
|
|
- class="upload-demo"
|
|
|
- ref="upload"
|
|
|
- :multiple="multiple"
|
|
|
- action="#"
|
|
|
- :accept="accept"
|
|
|
- :on-preview="handlePreview"
|
|
|
- :on-remove="handleRemove"
|
|
|
- :on-change="handleChange"
|
|
|
- :file-list="fileList"
|
|
|
- :limit="limit"
|
|
|
- :on-exceed="handleExceed"
|
|
|
- :http-request="handleUpload"
|
|
|
- :auto-upload="true"
|
|
|
- style="margin-top: 10px; margin-left: 10px"
|
|
|
- >
|
|
|
- <el-button v-show="!display" slot="trigger" size="small" type="primary"
|
|
|
- >点击上传</el-button
|
|
|
- >
|
|
|
+ <el-upload :disabled="display" class="upload-demo" ref="upload" :multiple="multiple" action="#" :accept="accept"
|
|
|
+ :on-preview="handlePreview" :on-remove="handleRemove" :on-change="handleChange" :file-list="fileList"
|
|
|
+ :limit="limit" :on-exceed="handleExceed" :http-request="handleUpload" :auto-upload="true"
|
|
|
+ style="margin-top: 10px; margin-left: 10px">
|
|
|
+ <el-button v-show="!display" slot="trigger" size="small" type="primary">点击上传</el-button>
|
|
|
<!-- <el-button
|
|
|
v-show="!display"
|
|
|
style="margin-left: 10px"
|
|
@@ -32,21 +17,12 @@
|
|
|
@click="submitUpload"
|
|
|
>开始上传</el-button
|
|
|
> -->
|
|
|
- <el-button v-if="templateCode !== ''" size="small" @click="downloadTemplate">下载模板</el-button>
|
|
|
+ <el-button v-if="templateCode !== ''" size="small" @click="downloadTemplate">下载模板</el-button>
|
|
|
</el-upload>
|
|
|
</el-col>
|
|
|
<!-- 图片预览 -->
|
|
|
- <el-dialog
|
|
|
- title="图片预览"
|
|
|
- :append-to-body="true"
|
|
|
- :visible.sync="previewVisible"
|
|
|
- width="50%"
|
|
|
- >
|
|
|
- <img
|
|
|
- :src="previewPath"
|
|
|
- :alt="previewName"
|
|
|
- style="width: 100%; height: 100%"
|
|
|
- />
|
|
|
+ <el-dialog title="图片预览" :append-to-body="true" :visible.sync="previewVisible" width="50%">
|
|
|
+ <img :src="previewPath" :alt="previewName" style="width: 100%; height: 100%" />
|
|
|
</el-dialog>
|
|
|
</section>
|
|
|
</template>
|
|
@@ -95,14 +71,15 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
- fileList (newVal) {
|
|
|
+ fileList(newVal) {
|
|
|
this.$emit('uploadSuccess', newVal)
|
|
|
},
|
|
|
- fileObjList (newVal) {
|
|
|
+ fileObjList(newVal) {
|
|
|
+ console.log(newVal)
|
|
|
this.fileList = newVal
|
|
|
}
|
|
|
},
|
|
|
- data () {
|
|
|
+ data() {
|
|
|
return {
|
|
|
fileList: [],
|
|
|
uploadUrl: uploadUrl,
|
|
@@ -112,8 +89,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- handleUpload (file) {
|
|
|
- function getBase64 (file) {
|
|
|
+ handleUpload(file) {
|
|
|
+ function getBase64(file) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
const reader = new FileReader()
|
|
|
reader.readAsDataURL(file)
|
|
@@ -143,7 +120,7 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
// 上传
|
|
|
- submitUpload () {
|
|
|
+ submitUpload() {
|
|
|
this.$refs.upload.submit()
|
|
|
// // 判断是否有文件
|
|
|
// if (this.fileList.length === 0) {
|
|
@@ -175,11 +152,11 @@ export default {
|
|
|
// });
|
|
|
},
|
|
|
// 移除
|
|
|
- handleRemove (file, fileList) {
|
|
|
+ handleRemove(file, fileList) {
|
|
|
this.fileList = fileList
|
|
|
},
|
|
|
// 预览
|
|
|
- handlePreview (file) {
|
|
|
+ handlePreview(file) {
|
|
|
if (!file || !file.name || !file.url) {
|
|
|
this.$message.error('没有可预览的文件!')
|
|
|
return
|
|
@@ -195,20 +172,19 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
// 改变上传内容
|
|
|
- handleChange (file, fileList) {
|
|
|
+ handleChange(file, fileList) {
|
|
|
console.log('fileList:', fileList)
|
|
|
this.fileList = fileList
|
|
|
},
|
|
|
// 超限
|
|
|
- handleExceed (files, fileList) {
|
|
|
+ handleExceed(files, fileList) {
|
|
|
this.$message.warning(
|
|
|
- `当前限制选择 ${this.limit} 个文件,本次选择了 ${
|
|
|
- files.length
|
|
|
+ `当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length
|
|
|
} 个文件,共选择了 ${files.length + fileList.length} 个文件`
|
|
|
)
|
|
|
},
|
|
|
// 下载模板
|
|
|
- downloadTemplate () {
|
|
|
+ downloadTemplate() {
|
|
|
if (this.templateCode !== '') {
|
|
|
location.href = this.$http.adornUrl(`/file-service/minio-file/systemTable/download/${this.templateCode}`)
|
|
|
}
|