<template>
  <el-form v-if="isShow" ref="researchBSForm" size="small" :model="form" :rules="rules" style="width:80%"
    label-position="left" v-loading="loading">
    <!-- 项目编号 -->
    <el-form-item :label="$t('trials:researchForm:form:trialId')">
      <el-input v-model="form.TrialCode" disabled />
    </el-form-item>
    <!-- 试验方案号 -->
    <el-form-item :label="$t('trials:researchForm:form:researchNo')">
      <el-input v-model="form.ResearchProgramNo" disabled />
    </el-form-item>
    <!-- 试验名称 -->
    <el-form-item :label="$t('trials:researchForm:form:researchName')">
      <el-input v-model="form.ExperimentName" disabled />
    </el-form-item>
    <!-- 适应症类型 -->
    <el-form-item :label="$t('trials:researchForm:form:decleareType')">
      <el-input v-model="form.IndicationType" disabled />
    </el-form-item>
    <!-- 中心名称 -->
    <el-form-item :label="$t('trials:researchForm:form:siteName')" prop="TrialSiteId">
      <el-select v-model="form.TrialSiteId" filterable style="width:100%;"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" @change="handleSiteChange">
        <el-option v-for="(item, index) of siteOptions" :key="index" :label="item.TrialSiteAliasName"
          :value="item.TrialSiteId" />
      </el-select>
    </el-form-item>
    <!-- 中心编号 -->
    <el-form-item v-if="form.TrialSiteId" :label="$t('trials:researchForm:form:siteId')">
      <el-input v-model="form.TrialSiteCode" disabled />
    </el-form-item>
    <!-- 联系人 -->
    <el-form-item :label="$t('trials:researchForm:form:contactor')" prop="UserName">
      <el-input v-model="form.UserName" :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" />
    </el-form-item>
    <!-- 联系电话 -->
    <el-form-item :label="$t('trials:researchForm:form:contactorPhone')" prop="Phone">
      <el-input v-model="form.Phone" :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" />
    </el-form-item>
    <!-- 联系邮箱 -->
    <el-form-item :label="$t('trials:researchForm:form:contactorEmail')" prop="Email">
      <el-input v-model="form.Email" disabled />
    </el-form-item>
    <el-form-item :label="$t('trials:researchForm:form:CommonUploadRecordId')
      " v-if="IsSupportUploadFile" class="file">
      <el-input v-model="form.SiteSurveyFile.FileName" type="textarea" :autosize="{ minRows: 1, maxRows: 3 }"
        style="width: 30%;margin-right: 5px;" disabled />
      <div class="upload" v-if="!(!(state === 0 && userTypeEnumInt === 0) || isHistory)">
        <input accept=".pdf,.docx,.doc" type="file" name="uploadFolder" class="select-file" title=""
          @change="beginScanFiles($event)" />
        <div class="btn-select">
          {{ $t('dictionary:template:basicData:button:selectFile') }}
        </div>
      </div>
      <el-button type="primary" @click="viewManualFile"
        :disabled="!this.form.SiteSurveyFile || !this.form.SiteSurveyFile.Path">{{
          $t('trials:researchForm:form:preview') }}</el-button>
      <el-button type="primary" @click="downLoad"
        :disabled="!this.form.SiteSurveyFile || !this.form.SiteSurveyFile.Path">{{
          $t('trials:researchForm:form:download') }}</el-button>
    </el-form-item>
    <!-- <el-divider /> -->
    <!-- 平均刻盘周期（天） -->
    <el-form-item v-if="!notShowFieldList.includes('AverageEngravingCycle')"
      :label="$t('trials:researchForm:form:engravingCycle')">
      <el-input-number v-model="form.AverageEngravingCycle"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" controls-position="right"
        :min="0" />
    </el-form-item>
    <!-- MRI-PDFF 是否为本中心该适应症的常规诊疗检查项目？ -->
    <el-form-item v-if="!notShowFieldList.includes('IsRoutineMRIPDEE')"
      :label="$t('trials:researchForm:form:IsRoutineMRIPDEE')" prop="IsRoutineMRIPDEE">
      <el-radio-group v-model="form.IsRoutineMRIPDEE"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM">
        <el-radio v-for="item of $d.YesOrNo" :key="`IsRoutineMRIPDEE${item.value}`" :label="item.value">{{
          item.label }}</el-radio>
      </el-radio-group>
    </el-form-item>
    <!-- MRI-PDFF 检查的检测周期（含单次检查时长、预约等待时长等） -->
    <el-form-item
      v-if="!notShowFieldList.includes('MRIPDFFScanTime') || !notShowFieldList.includes('MRIPDFFLeadTime') || !notShowFieldList.includes('MRIPDFFOther')"
      :label="$t('trials:researchForm:form:IsMRIPDFF')">
    </el-form-item>
    <!-- 单次检查时长（分钟） -->
    <el-form-item v-if="!notShowFieldList.includes('MRIPDFFScanTime')"
      :label="$t('trials:researchForm:form:MRIPDFFScanTime')">
      <el-input-number v-model="form.MRIPDFFScanTime"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" controls-position="right"
        :min="0" />
    </el-form-item>
    <!-- 平均预约等待时长（天） -->
    <el-form-item v-if="!notShowFieldList.includes('MRIPDFFLeadTime')"
      :label="$t('trials:researchForm:form:MRIPDFFLeadTime')">
      <el-input-number v-model="form.MRIPDFFLeadTime"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" controls-position="right"
        :min="0" />
    </el-form-item>
    <!-- 特殊情况备注-->
    <el-form-item v-if="!notShowFieldList.includes('MRIPDFFOther')"
      :label="$t('trials:researchForm:form:MRIPDFFOther')">
      <el-input v-model="form.MRIPDFFOther" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" />
    </el-form-item>
    <!-- 如已选择研究者评估，项目是否会授权影像科老师参与本试验？如不单独授权，是否可在试验中保持 1-2 名固定技师操作？-->
    <el-form-item
      v-if="!notShowFieldList.includes('IsAuthorizeRadiologistsParticipate') || !notShowFieldList.includes('AssignFixedTechnologists')"
      :label="$t('trials:researchForm:form:IsAuthorize')" prop="IsAuthorize">
      <el-radio-group v-model="form.IsAuthorize"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" @input="handleIsAuthorizeInput">
        <el-radio label="IsAuthorizeRadiologistsParticipate">{{
          $t('trials:researchForm:form:IsAuthorizeRadiologistsParticipate') }}</el-radio>
        <el-radio label="AssignFixedTechnologists">{{
          $t('trials:researchForm:form:AssignFixedTechnologists') }}</el-radio>
      </el-radio-group>
    </el-form-item>
    <!-- 请确认参与本项目影像采集的影像技师具备对应的资质（如：“技师证”，对应设备的“大型设备上岗证”） -->
    <el-form-item v-if="!notShowFieldList.includes('IsConfirmImagingTechnologist')"
      :label="$t('trials:researchForm:form:isQualified')" prop="IsConfirmImagingTechnologist">
      <el-radio-group v-model="form.IsConfirmImagingTechnologist"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM">
        <el-radio v-for="item of $d.YesOrNo" :key="`IsConfirmImagingTechnologist${item.value}`" :label="item.value">{{
          item.label }}</el-radio>
      </el-radio-group>
    </el-form-item>
    <!-- 原因 -->
    <el-form-item v-if="!notShowFieldList.includes('NotConfirmReson') && form.IsConfirmImagingTechnologist === false"
      :label="$t('trials:researchForm:form:notQualifiedReason')" prop="NotConfirmReson">
      <el-input v-model="form.NotConfirmReson" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" />
    </el-form-item>
    <!-- 研究单位疗效评估人员类型 -->
    <el-form-item v-if="!notShowFieldList.includes('EfficacyEvaluatorType')"
      :label="$t('trials:researchForm:form:staffType')">
      <el-radio-group v-model="form.EfficacyEvaluatorType"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM">
        <el-radio v-for="item of $d.EfficacyEvaluatorType" :key="`EfficacyEvaluatorType${item.value}`"
          :label="item.value">{{ item.label }}</el-radio>
      </el-radio-group>
    </el-form-item>
    <!-- 是否严格按照研究单位影像手册参数完成图像采集 -->
    <el-form-item v-if="!notShowFieldList.includes('IsFollowStudyParameters')" prop="IsFollowStudyParameters">
      <span slot="label" v-html="$t('trials:researchForm:form:isFollowStudyParam')" />
      <el-radio-group v-model="form.IsFollowStudyParameters"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" style="margin-right: 10px;">
        <el-radio v-for="item of $d.YesOrNo" :key="`IsFollowStudyParameters${item.value}`" :label="item.value">{{
          item.label }}</el-radio>
      </el-radio-group>
      <el-button type="primary" size="small" @click="viewManual">
        {{ $t('trials:researchForm:button:viewManual') }}
      </el-button>
    </el-form-item>
    <!-- 不能严格按照研究单位影像手册参数采集图像原因 -->
    <el-form-item v-if="!notShowFieldList.includes('NotFollowReson') && !form.IsFollowStudyParameters"
      prop="NotFollowReson">
      <span slot="label" v-html="$t('trials:researchForm:form:notFollowStudyParam')" />
      <el-input v-model="form.NotFollowReson" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" />
    </el-form-item>
    <!-- 是否严格按照影像手册参数完成刻盘 -->
    <el-form-item v-if="!notShowFieldList.includes('ISStrictManualBurnFlag')" prop="ISStrictManualBurnFlag">
      <span slot="label" v-html="$t('trials:researchForm:form:ISStrictManualBurnFlag')" />
      <el-radio-group v-model="form.ISStrictManualBurnFlag"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" style="margin-right: 10px;">
        <el-radio v-for="item of $d.YesOrNo" :key="`ISStrictManualBurnFlag${item.value}`" :label="item.value">{{
          item.label }}</el-radio>
      </el-radio-group>
    </el-form-item>
    <!-- 不能严格按照影像手册参数完成刻盘原因 -->
    <el-form-item v-if="!notShowFieldList.includes('NotStrictManualBurnFlagReason') && !form.ISStrictManualBurnFlag"
      prop="NotStrictManualBurnFlagReason">
      <span slot="label" v-html="$t('trials:researchForm:form:NotStrictManualBurnFlagReason')" />
      <el-input v-model="form.NotStrictManualBurnFlagReason" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }"
        :disabled="(!(state === 0 && userTypeEnumInt === 0) || isHistory) && !isPM" />
    </el-form-item>
    <el-form-item>
      <!-- 保存 -->
      <el-button v-if="state === 0 && userTypeEnumInt === 0 && !isHistory" type="primary" :loading="btnLoading"
        size="small" @click="handleSave(false)">
        {{ $t('common:button:save') }}
      </el-button>
    </el-form-item>
    <attachmentPreview :visible.sync="perview_visible" :isView="true" :isExternal="true" :ExternalList="ExternalList"
      v-if="perview_visible" />
  </el-form>
</template>
<script>
import { getTrialSiteSelect, getTrialDocumentList, addOrUpdateCommonUploadRecord } from '@/api/trials'
import { addOrUpdateTrialSiteSurvey } from '@/api/research'
import attachmentPreview from '@/views/dictionary/attachment/components/SignatureTemplate/attachmentPreview'
import { downLoadFile } from '@/utils/stream.js'
export default {
  name: 'QuestionForm',
  components: { attachmentPreview },
  props: {
    isHistory: {
      type: Boolean,
      default: false
    },
    IsOnlyUploadFile: {
      type: Boolean,
      default: false
    },
    IsSupportUploadFile: {
      type: Boolean,
      default: false
    },
    isPM: {
      type: Boolean,
      default: false
    },
  },
  data() {
    var checkPhone = (rule, value, callback) => {
      console.log(value)
      // const phoneReg = /^1[3|4|5|7|8][0-9]{9}$/
      const phoneReg = /^[0-9]+$/
      if (!value) {
        callback(new Error(this.$t('trials:researchForm:formRule:specify')))
      } else {
        setTimeout(() => {
          // if (!Number.isInteger(value)) {
          //   callback(new Error(this.$t('trials:researchForm:formRule:phone')))
          // } else {

          // }
          if (phoneReg.test(value)) {
            callback()
          } else {
            callback(new Error(this.$t('trials:researchForm:formRule:phone')))
          }
        }, 100)
      }
    }
    return {
      loading: false,
      form: {
        Id: '',
        Sponsor: '', // 申办方
        ResearchProgramNo: '', // 方案号
        ExperimentName: '',
        TrialCode: '', // 项目编号
        TrialSiteCode: '',
        TrialSiteAliasName: '',
        IndicationType: '', // 适应症
        TrialSiteId: '', // 研究单位名称
        UserName: '', // 联系人
        Phone: '', // 联系人电话
        Email: '', // 联系人邮箱
        AverageEngravingCycle: '',
        IsRoutineMRIPDEE: '',
        MRIPDFFScanTime: '',
        MRIPDFFLeadTime: '',
        MRIPDFFOther: '',
        IsAuthorize: '',
        IsAuthorizeRadiologistsParticipate: '',
        AssignFixedTechnologists: '',
        ISStrictManualBurnFlag: '',
        NotStrictManualBurnFlagReason: '',
        IsConfirmImagingTechnologist: '',
        NotConfirmReson: '',
        EfficacyEvaluatorType: '',
        IsFollowStudyParameters: '',
        NotFollowReson: '',
        CommonUploadRecordId: null,
        SiteSurveyFile: []
      },
      rules: {
        TrialSiteId: [
          { required: true, message: this.$t('trials:researchForm:formRule:specify'), trigger: 'blur' }
        ],
        IsRoutineMRIPDEE: [
          { required: true, message: this.$t('common:ruleMessage:select'), trigger: 'blur' }
        ],
        IsAuthorize: [
          { required: true, message: this.$t('common:ruleMessage:select'), trigger: 'blur' }
        ],
        ISStrictManualBurnFlag: [
          { required: true, message: this.$t('common:ruleMessage:select'), trigger: 'blur' }
        ],
        IsFollowStudyParameters: [
          { required: true, message: this.$t('common:ruleMessage:select'), trigger: 'blur' }
        ],
        IsConfirmImagingTechnologist: [
          { required: true, message: this.$t('common:ruleMessage:select'), trigger: 'blur' }
        ],
        NotConfirmReson: [
          { required: true, message: this.$t('trials:researchForm:formRule:specify'), trigger: 'blur' }
        ],
        NotFollowReson: [
          { required: true, message: this.$t('trials:researchForm:formRule:specify'), trigger: 'blur' }
        ],
        NotStrictManualBurnFlagReason: [
          { required: true, message: this.$t('trials:researchForm:formRule:specify'), trigger: 'blur' }
        ],
        UserName: [
          { required: true, validator: (rule, value, callback) => { !value ? callback(new Error(this.$t('trials:researchForm:formRule:specify'))) : callback() }, trigger: 'blur' },
          { min: 0, max: 50, message: this.$t('trials:researchForm:formRule:maxLength'), trigger: ['blur', 'change'] }
        ],
        Phone: [
          { required: true, validator: checkPhone, trigger: 'blur' }
        ],
        Email: [
          {
            pattern: new RegExp(this.$reg().EmailRegexStr),
            message: 'Please input the correct email address',
            trigger: 'blur,change',
          }
        ]
      },
      siteOptions: [],
      btnLoading: false,
      state: null,
      userTypeEnumInt: zzSessionStorage.getItem('userTypeEnumInt') * 1,
      isShow: false,
      notShowFieldList: [],
      perview_visible: false,
      ExternalList: []
    }
  },
  methods: {
    async beginScanFiles(e) {
      try {
        let file = e.target.files[0]
        let name = file.name
        if (!this.checkFileSuffix(name)) return this.$message.warning(this.$t("trials:researchRecord:ImageManual:message:checkFileSuffix"))
        this.loading = true
        file = await this.fileToBlob(file)
        let scope = this
        var index = name.lastIndexOf('.')
        var type = name.substring(index + 1, name.length)
        let res = await this.OSSclient.put(
          `/${this.$route.query.trialId}/InspectionUpload/SiteSurvey/${this.form.TrialSiteId}/${scope.getGuid(Date.now() + '_' + name.split('.')[0])}.${type}`,
          file
        )
        let data = {
          Path: this.$getObjectName(res.url),
          FileName: name,
          FileSize: file.size,
          FileType: type

        }
        res = await addOrUpdateCommonUploadRecord(data)
        this.loading = false
        if (res.IsSuccess) {
          this.form.CommonUploadRecordId = res.Result
          data.Id = res.Result
          this.form.SiteSurveyFile = data
        }
      } catch (err) {
        console.log(err)
        this.loading = false;
      }
    },
    checkFileSuffix(fileName) {
      var index = fileName.lastIndexOf('.')
      var suffix = fileName.substring(index + 1, fileName.length)
      if ('.pdf'.toLocaleLowerCase().search(suffix.toLocaleLowerCase()) === -1 && '.docx'.toLocaleLowerCase().search(suffix.toLocaleLowerCase()) === -1 && '.doc'.toLocaleLowerCase().search(suffix.toLocaleLowerCase()) === -1) {
        return false
      } else {
        return true
      }
    },
    handleIsAuthorizeInput(label) {
      this.form.IsAuthorizeRadiologistsParticipate = false
      this.form.AssignFixedTechnologists = false
      this.form[label] = true
    },
    async viewManualFile() {
      if (!this.form.SiteSurveyFile || !this.form.SiteSurveyFile.Path) return this.$message.warning(this.$t("trials:researchForm:message:notFile"))
      this.$preview({
        path: this.form.SiteSurveyFile.Path,
        type: this.form.SiteSurveyFile.FileType,
        title: this.form.SiteSurveyFile.Path.FileName,
      })
    },
    async downLoad() {
      if (!this.form.SiteSurveyFile || !this.form.SiteSurveyFile.Path) return this.$message.warning(this.$t("trials:researchForm:message:notFile"))
      return await downLoadFile(
        this.OSSclientConfig.basePath + this.form.SiteSurveyFile.Path,
        this.form.SiteSurveyFile.FileName
      )
    },
    async viewManual() {
      try {
        let data = {
          PageIndex: 1,
          PageSize: 20,
          TrialId: this.$route.query.trialId,
          IsPublish: true,
          FileTypeCode: 4,
          IsDeleted: false
        }
        let res = await getTrialDocumentList(data)
        if (res.IsSuccess) {
          const { CurrentPageData } = res.Result
          if (CurrentPageData.length <= 0) return this.$message.warning(this.$t("trials:researchRecord:ImageManual:message:noImageManual"))
          this.ExternalList = []
          CurrentPageData.forEach(item => {
            let obj = {
              FilePath: item.Path,
              FileFormat: 'pdf',
              Name: item.Name
            }
            this.ExternalList.push(obj)
          });
          this.perview_visible = true
        }
      } catch (err) {
        console.log(err)
      }
    },
    // 保存基本信息
    handleSave(isAutoCommit, isCheck = false) {
      return new Promise((resolve, reject) => {
        isCheck = false
        if (this.IsOnlyUploadFile && !isCheck) {
          if (!this.form.UserName) {
            this.$message.warning(this.$t("trials:researchForm:message:notUserName"))
            return resolve(false)
          }
          if (!this.form.Phone) {
            this.$message.warning(this.$t("trials:researchForm:message:notPhone"))
            return resolve(false)
          }
          if (!this.form.CommonUploadRecordId) {
            this.$message.warning(this.$t("trials:researchForm:message:notCommonUploadRecordId"))
            return resolve(false)
          }
          this.btnLoading = true
          const param = {
            id: this.form.Id,
            trialId: this.$route.query.trialId,
            trialSiteId: this.form.TrialSiteId,
            userName: this.form.UserName,
            phone: this.form.Phone,
            email: this.form.Email,
            averageEngravingCycle: this.form.AverageEngravingCycle,
            IsRoutineMRIPDEE: this.form.IsRoutineMRIPDEE,
            MRIPDFFScanTime: this.form.MRIPDFFScanTime,
            MRIPDFFLeadTime: this.form.MRIPDFFLeadTime,
            MRIPDFFOther: this.form.MRIPDFFOther,
            IsAuthorizeRadiologistsParticipate: this.form.IsAuthorizeRadiologistsParticipate,
            AssignFixedTechnologists: this.form.AssignFixedTechnologists,
            ISStrictManualBurnFlag: this.form.ISStrictManualBurnFlag,
            NotStrictManualBurnFlagReason: this.form.NotStrictManualBurnFlagReason,
            isConfirmImagingTechnologist: this.form.IsConfirmImagingTechnologist,
            notConfirmReson: this.form.NotConfirmReson,
            efficacyEvaluatorType: this.form.EfficacyEvaluatorType,
            isFollowStudyParameters: this.form.IsFollowStudyParameters,
            notFollowReson: this.form.NotFollowReson,
            CommonUploadRecordId: this.form.CommonUploadRecordId
          }
          addOrUpdateTrialSiteSurvey(param).then(res => {
            this.btnLoading = false
            if (res.IsSuccess && !isAutoCommit) {
              this.$message.success(this.$t('common:message:savedSuccessfully'))
            }
            resolve(true)
          }).catch(() => {
            this.btnLoading = false
            reject(false)
          })
          return resolve(true)
        }
        this.$refs['researchBSForm'].validate(valid => {
          if (valid) {
            this.btnLoading = true
            const param = {
              id: this.form.Id,
              trialId: this.$route.query.trialId,
              trialSiteId: this.form.TrialSiteId,
              userName: this.form.UserName,
              phone: this.form.Phone,
              email: this.form.Email,
              averageEngravingCycle: this.form.AverageEngravingCycle,
              IsRoutineMRIPDEE: this.form.IsRoutineMRIPDEE,
              MRIPDFFScanTime: this.form.MRIPDFFScanTime,
              MRIPDFFLeadTime: this.form.MRIPDFFLeadTime,
              MRIPDFFOther: this.form.MRIPDFFOther,
              IsAuthorizeRadiologistsParticipate: this.form.IsAuthorizeRadiologistsParticipate,
              AssignFixedTechnologists: this.form.AssignFixedTechnologists,
              ISStrictManualBurnFlag: this.form.ISStrictManualBurnFlag,
              NotStrictManualBurnFlagReason: this.form.NotStrictManualBurnFlagReason,
              isConfirmImagingTechnologist: this.form.IsConfirmImagingTechnologist,
              notConfirmReson: this.form.NotConfirmReson,
              efficacyEvaluatorType: this.form.EfficacyEvaluatorType,
              isFollowStudyParameters: this.form.IsFollowStudyParameters,
              notFollowReson: this.form.NotFollowReson,
              CommonUploadRecordId: this.form.CommonUploadRecordId
            }
            addOrUpdateTrialSiteSurvey(param).then(res => {
              this.btnLoading = false
              if (res.IsSuccess && !isAutoCommit) {
                this.$message.success(this.$t('common:message:savedSuccessfully'))
              }
              resolve(true)
            }).catch(() => {
              this.btnLoading = false
              reject(false)
            })
          } else {
            if (isAutoCommit) {
              this.$message.error(this.$t('trials:researchForm:button:msg1'))
            }
            resolve(false)
          }
        })
      })
    },

    // 初始化
    async initForm(trialInfo, trialSiteSurvey, notShowFieldList) {
      // 获取项目下的site
      const { Result } = await getTrialSiteSelect(this.$route.query.trialId, { IgnoreDisable: true })
      this.siteOptions = Result
      this.form.Id = trialSiteSurvey.Id
      this.form.Sponsor = trialInfo.Sponsor // 申办方
      this.form.ResearchProgramNo = trialInfo.ResearchProgramNo // 方案号
      this.form.ExperimentName = trialInfo.ExperimentName
      this.form.TrialCode = trialInfo.TrialCode // 项目编号
      this.form.TrialSiteCode = trialSiteSurvey.TrialSiteCode
      this.form.TrialSiteAliasName = trialSiteSurvey.TrialSiteAliasName // 项目别称
      this.form.IndicationType = trialInfo.IndicationType // 适应症
      this.form.TrialSiteId = trialSiteSurvey.TrialSiteId
      this.form.UserName = trialSiteSurvey.UserName // 联系人
      this.form.Phone = trialSiteSurvey.Phone // 联系人电话
      this.form.Email = trialSiteSurvey.Email // 联系人邮箱
      this.form.CommonUploadRecordId = trialSiteSurvey.CommonUploadRecordId
      this.form.SiteSurveyFile = trialSiteSurvey.SiteSurveyFile || {}
      this.form.fileStr = this.form.SiteSurveyFile.FileName
      this.form.AverageEngravingCycle = trialSiteSurvey.AverageEngravingCycle
      this.form.IsRoutineMRIPDEE = trialSiteSurvey.IsRoutineMRIPDEE
      this.form.MRIPDFFScanTime = trialSiteSurvey.MRIPDFFScanTime
      this.form.MRIPDFFLeadTime = trialSiteSurvey.MRIPDFFLeadTime
      this.form.MRIPDFFOther = trialSiteSurvey.MRIPDFFOther
      this.form.IsAuthorizeRadiologistsParticipate = trialSiteSurvey.IsAuthorizeRadiologistsParticipate
      this.form.AssignFixedTechnologists = trialSiteSurvey.AssignFixedTechnologists
      if (this.form.IsAuthorizeRadiologistsParticipate) this.form.IsAuthorize = 'IsAuthorizeRadiologistsParticipate'
      if (this.form.AssignFixedTechnologists) this.form.IsAuthorize = 'AssignFixedTechnologists'
      this.form.ISStrictManualBurnFlag = trialSiteSurvey.ISStrictManualBurnFlag
      this.form.NotStrictManualBurnFlagReason = trialSiteSurvey.NotStrictManualBurnFlagReason
      this.form.IsConfirmImagingTechnologist = trialSiteSurvey.IsConfirmImagingTechnologist
      this.form.NotConfirmReson = trialSiteSurvey.NotConfirmReson
      this.form.EfficacyEvaluatorType = trialSiteSurvey.EfficacyEvaluatorType
      this.form.IsFollowStudyParameters = trialSiteSurvey.IsFollowStudyParameters
      this.form.NotFollowReson = trialSiteSurvey.NotFollowReson
      this.state = trialSiteSurvey.State
      this.isShow = true
      if (!notShowFieldList) return
      this.notShowFieldList = notShowFieldList
    },
    handleSiteChange(val) {
      var selected = this.siteOptions.find(item => item.TrialSiteId === val)
      if (selected) {
        this.form.TrialSiteCode = selected.TrialSiteCode
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.upload {
  display: inline-block;
  height: 30px;
  width: 90px;
  padding: 2px 10px;
  line-height: 23px;
  position: relative;
  text-decoration: none;
  border-radius: 3px;
  overflow: hidden;
  text-align: center;
  background: #428bca;
  border-color: #428bca;
  color: #fff;
  margin-right: 5px;

  .select-file {
    height: 30px;
    width: 90px;
    position: absolute;
    overflow: hidden;
    left: 0;
    top: 0;
    opacity: 0;
    font-size: 0;
  }

  .btn-select {
    //给显示在页面上的按钮写样式
    width: 90px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    border-radius: 24px;
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none; //pointer-events:none用来控制该标签的点击穿透事件
  }
}

.file {
  ::v-deep .el-form-item__content {
    display: flex;
    align-items: center;
  }
}
</style>
