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.

68 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<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"
:auto-upload="false">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<el-button style="margin-left: 10px;" size="small" type="success" @click="">上传到服务器</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</el-upload>
<formList ref="formList" :value="selections" @selected="selectedHandler"></formList>
</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,
selections: [],
}
},
methods: {
selectedHandler (ids) {
this.selections = Array.from(new Set(ids))
this.$emit('update', this.selections)
}
},
computed: {
fileList () {
return (this.file && this.fieldInfo?.field) ? this.file[this.fieldInfo.field] : []
},
},
watch: {
form: {
handler(newVal) {
this.selections = newVal[this.fieldInfo.field]
},
immediate: true
}
}
}
</script>
<style scoped lang="scss">
.upload {
margin-top: 10px;
}
</style>