<template>
  <!-- 随访调查录入 -->
  <div style="positon: relative">
    <div class="goback" v-if="formType == 1">
      <el-button icon="el-icon-back" @click="backInfoce">返 回</el-button>
    </div>
    <ConfigForms
      v-if="refreshFlag"
      :form-type="formType"
      form-class="follow-form"
      :disabled="disabled"
      :tab-disabled="tabDisabled"
      :get-data="getData"
      :contrast="formType == 1 ? false : true"
      :patient-id="patientId"
      :screenList="screenList"
      @refreshData="refreshData"
      @changeShow="changeShow"
    ></ConfigForms>
  </div>
</template>

<script>
import ConfigForms from "@/views/screening/components/ConfigForms.vue"
import { getFollowList } from "@/api/patient"
export default {
  name: "FollowupEntry",
  components: {
    ConfigForms,
  },
  data() {
    return {
      disabled: false,
      tabDisabled: true,
      refreshFlag: true,
      screenList: [
        // {
        //   create_time: "2020-12-12 11:11:11",
        //   create_user_name: "",
        //   title: "修改第一次随访计划",
        // },
      ],
    }
  },
  provide() {
    return {
      tabFollowId: () => this.followId,
    }
  },
  computed: {
    patientId() {
      return this.$route.query.patientId
    },
    model() {
      return this.$route.query.model
    },
    followId() {
      return this.$route.query.followId
    },
    formType() {
      return this.$route.query.formType
    },
    getData() {
      return Boolean(this.$route.query.getData - 0)
    },
  },
  mounted() {
    if (this.model == "view") {
      this.disabled = true
      this.tabDisabled = false
    } else {
      this.disabled = false
      this.tabDisabled = true
    }
    this.$nextTick(() => {
      if (this.formType == 2) {
        this.getFollowList()
      }
    })
  },
  methods: {
    changeShow(isRefresh) {
      this.$emit("changeShow", isRefresh)
    },
    refreshData(data) {
      // this.refreshFlag = false
      // this.$nextTick(() => {
      //   this.refreshFlag = true
      // })
    },
    backInfoce() {
      this.$router.push({ path: "/followupquery", query: {} })
    },
    getFollowList() {
      const followId = this.followId
      const key = followId ? "followId" : "patientId"
      getFollowList({
        [key]: this[key],
      }).then((res) => {
        if (res.code == 1) {
          this.screenList = res.data || []
        }
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.goback {
  position: absolute;
  right: 24px;
  top: 24px;
  z-index: 99;
}
</style>
