在配置项中配置扩展字段,然后在对应新增处新增数据
DynamicFormItem 动态FormItem 组件
<template>
<div>
<el-divider content-position="left">扩展字段</el-divider>
<el-form-item
v-for="(item,key) in jsonList"
:key="key"
:label="item.name + ':'"
:prop="item.code"
>
<el-input v-if="item.valueType === 'text'" v-model="myData.formData[item.code]" />
<el-select
v-if="item.valueType === 'select'"
v-model="myData.formData[item.code]"
filterable
>
<el-option
label="请选择"
value=""
/>
<el-option
v-for="(d, itemIndex) in item.selectItem.split(',')"
:key="itemIndex"
:label="d"
:value="d"
/>
</el-select>
<el-date-picker
v-if="item.valueType === 'date'"
v-model="myData.formData[item.code]"
type="datetime"
placeholder="选择日期"
/>
<Upload v-if="item.valueType === 'upload'" v-model="myData.formData[item.code]" />
</el-form-item>
</div>
</template>
<script>
import Upload from '@/components/Upload'
var myData = {
formData: {
}
}
export default {
components: {
Upload },
props: {
jsonList: {
type: Array,
default: () => {
return []
}
},
jsonData: {
type: Object,
default: () => {
return null
},
requerd: false
}
},
data() {
return {
myData
}
},
created() {
this.getInit()
},
methods: {
submit() {
return JSON.stringify(this.myData.formData