1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<template>
  <basic-container>
    <el-dialog v-if="dialogFormVisible" :title="title" :visible.sync="dialogFormVisible" @close="closeHandler" append-to-body>
      <avue-form v-model="form" :option="option" @submit="submitHandler" @reset-change="changeHandler">
        <template v-for="item in slotData" :slot="item.prop + 'Label'">
        <span>
          <span>{{ item.label }}</span>
          <el-tooltip
            v-if="item.keyAttr"
            class="item"
            content="该属性为关键属性"
            effect="dark"
            placement="top-start"
          >
            <i class="el-icon-star-on" style="font-size: 17px !important; color: red;vertical-align: baseline;"></i>
          </el-tooltip>
        </span>
        </template>
      </avue-form>
    </el-dialog>
  </basic-container>
</template>
 
<script>
export default {
  name: "dynamic-table-form",
  props: {
    componentVO: {
      type: Object,
      default: {}
    },
    inDialog: {
      type: Boolean,
      default: false
    },
    areasName: {
      type: String,
      default: ''
    },
    sourceData: {
      //菜单源数据或者弹窗时按钮所属区域的上一区域选中数据
      type: Object,
      default: {}
    },
    paramVOS: {
      type: Object,
      default: {}
    },
    visible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String
    },
    formList:{
      type:Array
    },
  },
  data() {
    return {
      form: {},
    }
  },
  computed: {
    dialogFormVisible: {
      get() {
        return this.visible;
      },
      set(val) {
        this.$emit("update:visible", val);
      },
    },
    option() {
      return {
        column: this.formColumn(this.formList)
      }
    },
    slotData(){
      return this.formColumn(this.formList)
    }
  },
  methods:{
    //表单提交
    submitHandler(form,done){
      done()
    },
    changeHandler(){
      this.form = {};
      // this.clearValidate() 清空校验
      // this.resetFields()
    },
    formColumn(formList) {
      return formList.map(item => {
        const typeValue = item.type === 'text' ? 'input' : item.type === 'combox' ? 'select' : item.type;
 
        return {
          label: item.text,
          prop: item.field,
          type: typeValue,
          value: item.defaultValue,
          dicData: item.type === 'combox' ? item.dicData : item.dicUrl,
          readonly: item.readOnly,
          disabled: item.disabled,
          labelSuffix: item.suffix,
          suffixIcon: item.prefix,
          placeholder:item.placeholder,
          clearable:item.clearable,
          tip: item.tooltips,
          keyAttr: item.keyAttr,
          rules: [{
            required: item.required,
            message: `请输入${item.text}!`,
            trigger: "blur"
          }]
        }
      })
    },
    closeHandler(){
      this.form = {};
    },
  }
}
</script>
 
<style scoped lang="scss">
 
</style>