田源
2024-03-20 d598404c814ad8556159c0922c90dccbb7ee649f
Source/ProjectWeb/src/components/dynamic-components/dynamic-form.vue
@@ -1,8 +1,6 @@
<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'">
  <avue-form v-model="form" :option="option">
    <template v-for="item in slotData" :slot="item.prop + 'Label'">
        <span>
          <span>{{ item.label }} </span>
          <el-tooltip
@@ -15,10 +13,11 @@
            <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>
    <template slot="menuForm">
      <dynamic-button type="form" :butttonList="componentVO.buttons" @buttonClick="buttonClick"></dynamic-button>
    </template>
  </avue-form>
</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)
    slotData() {
      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()
    },
  methods: {
    //转化数据
    formColumn(formList) {
      return formList.map(item => {
        const typeValue = item.type === 'text' ? 'input' : item.type === 'combox' ? 'select' : item.type;
@@ -106,8 +83,8 @@
          disabled: item.disabled,
          labelSuffix: item.suffix,
          suffixIcon: item.prefix,
          placeholder:item.placeholder,
          clearable:item.clearable,
          placeholder: item.placeholder,
          clearable: item.clearable,
          tip: item.tooltips,
          keyAttr: item.keyAttr,
          rules: [{
@@ -118,13 +95,13 @@
        }
      })
    },
    closeHandler(){
      this.form = {};
    buttonClick(item) {
      console.log(item.id)
    },
  }
}
</script>
<style scoped lang="scss">
<style scoped>
</style>