<template>
  <div id="publicContent" :class="activeName == 'index0' && formClass ? formClass : ''">
    <div v-if="formTabs && formTabs.length > 0">
      <el-button class="draftButton">
        {{
        formType == 1 ? "临时保存" : "返回"
        }}
      </el-button>
      <el-tabs
        v-model="activeName"
        type="card"
        :style="{ width: formType == 1 ? '100%' : 'calc(100% - 200px)' }"
        class="publicTab"
        v-loading="fromLoading"
        @tab-click="handleTabClick"
      >
        <el-tab-pane
          :label="form.label"
          :name="'index' + index"
          v-for="(form, index) in formTabs"
          :key="form.id"
        >
          <transition mode="out-in" name="fade-transform">
            <div v-show="activeName === 'index' + index">
              <template v-if="form.formId">
                <form-tab
                  :patient-id="patientId"
                  :patient-standby-id="patientStandbyId"
                  :form="form"
                  :disabled="disabled"
                  contrast
                  @setFormJson="setFormJson"
                  @handleConfirm="handleConfirm"
                  @onPrev="onPrev"
                  :survivalFlag="survivalFlag"
                ></form-tab>
              </template>
            </div>
          </transition>
        </el-tab-pane>
      </el-tabs>
    </div>
    <el-empty v-else description="暂无数据"></el-empty>
  </div>
</template>

<script>
import mixin from "./mixin"
import CustomForm from "@/components/FormComponents/CustomForm/index"

export default {
  name: "ConfigForms",
  mixins: [mixin],
  props: {
    disabled: Boolean,
    formType: String,
    patientId: String,
    formClass: String,
  },
  data() {
    return {
      // showIndex:false,
      // survivalFlag:false
    }
  },
  methods: {
    handleConfirm(data, done, cb) {
      this.addPatient(data, done, cb)
    },
    onPrev(done) {
      this.prevTab(done)
    },
  },
  created() {
    // 字典formType 1 筛查表单
    this.getCurrentFormByType(this.formType)
  },
  watch: {
    // activeName(val){
    //   if(val=="index0" && this.formClass){
    //     this.showIndex = false
    //     // this.survivalFlag = true
    //     console.log(1)
    //   }
    //   else{
    //     this.showIndex = true
    //     // this.survivalFlag = false
    //     console.log(2)
    //   }
    // }
  },
  computed: {
    survivalFlag() {
      if (this.activeName == "index0" && this.formClass) {
        return true
      } else {
        return false
      }
    },
    showIndex() {
      if (this.activeName == "index0" && this.formClass) {
        return false
      } else {
        return true
      }
    },
  },
  provide() {
    return {
      configForms: this,
    }
  },
}
</script>

<style lang="scss" scoped>
#publicContent {
  padding: 32px 24px;
  position: relative;
  .draftButton {
    position: absolute;
    top: 46px;
    right: 40px;
    z-index: 999;
    border-radius: 4px;
    border: 1px solid #4e68ff;
    color: #4e68ff;
  }
}
.publicTab {
  // width: calc(100%);
  margin-top: 10px;
}
::v-deep {
  .el-tabs--card > .el-tabs__header {
    width: calc(100% - 100px);
    border-bottom: none;
  }
  .el-tabs--card > .el-tabs__header .el-tabs__nav {
    border: none;
  }
  .el-tabs--card > .el-tabs__header .el-tabs__item {
    min-width: 116px;
    text-align: center;
    background: #f0f1fa;
    font-size: 14px;
    border: none;
  }
  .el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
    background: #4e68ff;
    color: #fff;
  }
}
.my-form {
  overflow-x: scroll;
}
.follow-form {
  .publicTab {
    margin-bottom: 10px;
    ::v-deep {
      .el-collapse-item__header {
        border-width: 1px 0px 0px;
      }
      .row24 {
        border-top: 1px solid #cccccc;
      }
      .custom-form-item {
        border-width: 1px 0px 0px;
      }
      .el-collapse-item {
        margin-bottom: 20px;
        border-radius: 4px;
        overflow: hidden;
        border: 1px solid #cccccc;
      }
      .el-collapse-item__wrap {
        border: none;
      }
      // .row24.el-col-lg-12:nth-child(2n) {
      //   border-width: 0px 0px 0px 1px;
      // }
      .el-form-item {
        .el-form-item__label {
          text-align: left;
          background: #fafafa;
          font-size: 14px;
          color: #333333;
          border-right: 1px solid #cccccc;
          width: 80px !important;
          padding: 18px 10px;
          margin-right: 20px;
          text-align: center;
        }
      }
      .el-form-item {
        padding: 0px;
      }
    }
  }
}
</style>
