zhiyong.zhou
2024-02-26 60d911172b1dbebe0ab952ce10366b327d5744f1
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
<template>
  <component ref="form" :is="config.name" :mode="mode" v-bind="config.props" v-model="_value" />
</template>
<script>
 
import components from '@/views/common/form/ComponentExport'
 
export default {
  name: "FormRender",
  components: components,
  props:{
    mode:{
      type: String,
      default: 'DESIGN'
    },
    value: {
      default: undefined
    },
    config:{
      type: Object,
      default: ()=>{
        return {}
      }
    }
  },
  computed: {
    _value: {
      get() {
        const valueType = this.config.valueType
        const value = valueType === "Number" && this.value ? Number(this.value) : this.value;
        return value;
      },
      set(val) {
        const valueType = this.config.valueType
        const value = valueType === "Number" ? Number(val) : val
        this.$emit("input", value);
      }
    }
  },
  data() {
    return {}
  },
  methods: {
    validate(call){
      this.$refs.form.validate(call)
    }
  }
}
</script>
 
<style lang="less" scoped>
 
</style>