You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.1 KiB

3 years ago
<template>
<div>
<el-button size="small" type="primary" icon="el-icon-s-order" @click="$refs['formList'].show()"></el-button>
<el-button size="small" type="primary" icon="el-icon-plus">表单新增</el-button>
<el-upload
class="upload"
ref="upload"
:action="action"
:file-list="fileList"
3 years ago
:auto-upload="false"
:before-upload="beforeUpload"
:on-success="onSuccess"
:on-remove="onRemove"
:on-error="onError">
3 years ago
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
3 years ago
<el-button style="margin-left: 10px;" size="small" type="success" @click="$refs['upload'].submit()"></el-button>
3 years ago
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</el-upload>
3 years ago
<formList ref="formList" @selected="selectedHandler"></formList>
3 years ago
</div>
</template>
<script>
import formList from './formList.vue';
export default {
components: {
formList
},
props: {
form: Object,
fieldInfo: Object,
file: Object,
},
data() {
return {
action: process.env.VUE_APP_UPLOAD_API,
3 years ago
fileList: []
3 years ago
}
},
methods: {
3 years ago
selectedHandler (selections) {
this.fileList.push(...selections)
this.$emit('update', this.fileList)
},
3 years ago
3 years ago
beforeUpload (file) {
if (file.size / 1000 > 500) {
this.$message({
type: "warning",
message: "上传图片大小超过500kb",
});
return false;
}
},
onSuccess (response, file, fileList) {
this.fileList = fileList;
this.$emit('update', this.fileList)
},
onRemove (file, fileList) {
this.fileList = fileList;
},
onError (err, file, fileList) {
this.fileList = fileList;
this.$message({
type: "warning",
message: err,
});
},
3 years ago
},
computed: {
},
3 years ago
watch: {
3 years ago
'form.id_material_fujian_uploads_material_id_relation': {
handler (newVal) {
this.fileList = newVal
3 years ago
},
3 years ago
deep: true
3 years ago
}
}
3 years ago
}
</script>
<style scoped lang="scss">
.upload {
margin-top: 10px;
}
</style>