<template>
  <div class="form-container">
    <el-card class="box-card">
      <div style="width: 80%">
        <el-form
          ref="summarizeFrom"
          v-loading="loading"
          :rules="rules"
          :model="form"
          class="demo-ruleForm"
          label-width="150px"
        >
          <el-row>
            <el-col :span="14">
              <el-form-item
                :label="$t('system:reviewer:label:Summarize')"
                prop="Summarize"
              >
                <el-input
                  :disabled="$route.query.ReviewStatus === '1'"
                  v-model="form.Summarize"
                  type="textarea"
                  :rows="2"
                  :placeholder="
                    $t('curriculumVitae:summarize:form:placeholder:summarize')
                  "
                  size="small"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="14">
              <el-form-item prop="SummarizeEn">
                <el-input
                  :disabled="$route.query.ReviewStatus === '1'"
                  v-model="form.SummarizeEn"
                  type="textarea"
                  :rows="2"
                  :placeholder="
                    $t('curriculumVitae:summarize:form:placeholder:summarizeEN')
                  "
                  size="small"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-form-item>
            <el-button
              type="primary"
              :disabled="$route.query.ReviewStatus === '1'"
              size="small"
              :loading="loading"
              @click="handleSave"
            >
              {{ $t('common:button:save') }}
            </el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>
<script>
import { getDetail, updateGneralSituation } from '@/api/reviewers'
export default {
  props: {
    reviewerId: {
      type: String,
    },
  },
  data() {
    return {
      loading: false,
      form: {
        Summarize: null,
        SummarizeEn: null,
      },
      rules: {},
    }
  },
  mounted() {
    this.getDetail()
  },
  methods: {
    async handleSave() {
      try {
        let validate = await this.$refs.summarizeFrom.validate()
        if (!validate) return false
        this.form.Id = this.$route.query.Id || this.reviewerId
        this.loading = true
        if (this.$route.query.trialId) {
          this.form.TrialId = this.$route.query.trialId
        }
        let res = await updateGneralSituation(this.form)
        this.loading = false
        if (res.IsSuccess) {
        }
      } catch (err) {
        this.loading = false
        console.log(err)
      }
    },
    // 获取详情
    async getDetail() {
      try {
        let id = this.$route.query.Id || this.reviewerId
        if (!id) return false
        this.loading = true
        let res = await getDetail(id)
        this.loading = false
        if (res.IsSuccess) {
          Object.keys(this.form).forEach((key) => {
            this.form[key] = res.Result.SummarizeInfo[key]
          })
        }
      } catch (err) {
        this.loading = false
        console.log(err)
      }
    },
  },
}
</script>
  <style lang="scss" scoped>
.basic-form {
  .el-input--small {
    width: 220px !important;
  }
  .el-select--small {
    width: 220px !important;
  }
}
</style>