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

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"
: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>
3 years ago
<formList ref="formList" :value="selections" @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
selections: [],
}
},
methods: {
selectedHandler (ids) {
this.selections = Array.from(new Set(ids))
this.$emit('update', this.selections)
3 years ago
}
},
computed: {
fileList () {
return (this.file && this.fieldInfo?.field) ? this.file[this.fieldInfo.field] : []
3 years ago
},
3 years ago
},
3 years ago
watch: {
form: {
handler(newVal) {
this.selections = newVal[this.fieldInfo.field]
},
immediate: true
}
}
3 years ago
}
</script>
<style scoped lang="scss">
.upload {
margin-top: 10px;
}
</style>