FormContent2.vue 3.55 KB
<template>
  <!-- 删除display isShowIm item.importantField item.style-->
  <el-row :gutter="options.gutter" class="form-content">
    <template v-for="(item, columnIndex) in columns.column || columns.children.column">
      <el-col
        v-if="item.type === 'title'"
        :key="columnIndex"
        class="row12"
        :xs="item.xs || 24"
        :sm="item.sm || 24"
        :md="item.md || 24"
        :lg="item.span || 12"
      >
        <div class="form_title">
          <span>{{ item.value }}</span>
        </div>
      </el-col>

      <el-col
        v-else
        :key="columnIndex"
        class="row24"
        :xs="item.xs || 24"
        :sm="item.sm || 24"
        :md="item.md || 24"
        :lg="item.lg || item.span || 12"
        :xl="item.span || 12"
      >
        <form-item-self
          :form="form"
          :column-index="columnIndex"
          :item="item"
          :columns="columns.column || columns.children.column"
          :group="options.group"
          @formChange="formChange"
          :showIndex="showIndex"
        ></form-item-self>
      </el-col>
    </template>
  </el-row>
</template>

<script>
/**
 * @description 自定义表单
 */
import FormItemSelf from "./FormItemSelf2.vue"

export default {
  name: "FormContent",
  components: { FormItemSelf },

  props: {
    form: {
      type: Object,
      default: () => {
        return {}
      },
    },
    options: {
      type: Object,
      default: () => {
        return {}
      },
    }, //配置 数据
    columns: Object, //表单数据
    size: { type: String, default: "small" },
    formStyle: Object,
    formEdit: {
      type: Object,
      default: () => {
        return {}
      },
    },
    isShowImportant: {
      type: Boolean,
      default: false,
    },
    showIndex: {
      type: Boolean,
    },
  },
  data() {
    return {}
  },
  provide(){
    return{
      showIndex: this.showIndex
    }
  },
  computed: {
    isShowIm() {
      return function (val) {
        return !this.isShowImportant ? true : val
      }
    },
    paddingLeft() {
      const columns = this.columns
      return columns.labelWidth ? `${columns.labelWidth}px` : ""
    },
  },
  methods: {
    handleChange(key, val) {
      if (this.form.hasOwnProperty(key)) this.form[key] = val
    },
    // 切换不符合筛查条件的显示
    formChange() {
      console.log(this.form)
      let arr = [
        "is_one_year",
        "is_subtotal_history",
        "is_ppi",
        "is_symptom",
        "is_subtotal_history",
        "is_disease",
        "is_tumour",
      ]
      let flag = 0
      for (let i = 0; i < arr.length; i++) {
        if (this.form[arr[i]] && this.form[arr[i]] == 0) {
          flag++
        }
      }
      if (flag == 0) {
        this.$emit("showError", false)
      } else {
        this.$emit("showError", true)
      }
    },
  },
  watch: {
  },
  mounted(){
  }
}
</script>

<style lang="scss" scoped>
::v-deep {
  .row24.el-col-lg-12 {
    &:nth-child(2n) {
      border-left: 1px solid #ccc;
    }
  }
}
.form-content ::v-deep {
  display: flex;
  flex-wrap: wrap;
  .el-form-item {
    display: flex;
    align-items: center;
    .el-form-item__label {
      line-height: 1.2;
    }
    .el-form-item__content {
      margin-left: 0 !important;
      flex: 1;
      display: flex;
      align-items: center;
    }
  }
}

.form_title {
  background-color: #fff;
  padding: 10px 0px;
  margin: 3px;
  span {
    height: 33px;
    line-height: 33px;
  }
}
.dynamic-form-container {
  &_lable {
    font-weight: bold;
    font-size: 16px;
    line-height: 40px;
  }
}
</style>