田源
2024-03-20 d598404c814ad8556159c0922c90dccbb7ee649f
Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
@@ -1,7 +1,5 @@
<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">
  <avue-form v-model="form" :option="option">
        <template v-for="item in slotData" :slot="item.prop + 'Label'">
        <span>
          <span>{{ item.label }} </span>
@@ -16,9 +14,10 @@
          </el-tooltip>
        </span>
        </template>
    <template slot="menuForm">
      <dynamic-button type="form" :butttonList="componentVO.buttons" @buttonClick="buttonClick"></dynamic-button>
    </template>
      </avue-form>
    </el-dialog>
  </basic-container>
</template>
<script>
@@ -46,52 +45,30 @@
      type: Object,
      default: {}
    },
    visible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String
    },
    formList:{
      type:Array
    },
  },
  data() {
    return {
      form: {},
    }
  },
  mounted() {
    // console.log('componentVO--',this.componentVO.tableDefineVO.cols[0])
  },
  computed: {
    dialogFormVisible: {
      get() {
        return this.visible;
      },
      set(val) {
        this.$emit("update:visible", val);
      },
    },
    option() {
      return {
        column: this.formColumn(this.formList)
        submitBtn: false,
        emptyBtn: false,
        height: 300,
        column: this.formColumn(this.componentVO.tableDefineVO.cols[0])
      }
    },
    slotData(){
      return this.formColumn(this.formList)
      return this.formColumn(this.componentVO.tableDefineVO.cols[0])
    }
  },
  methods:{
    //表单提交
    submitHandler(form,done){
      console.log(form)
      console.log(this.slotData)
      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;
@@ -118,13 +95,13 @@
        }
      })
    },
    closeHandler(){
      this.form = {};
    buttonClick(item) {
      console.log(item.id)
    },
  }
}
</script>
<style scoped lang="scss">
<style scoped>
</style>