<template>
  <div class="reading-rule-config-form">
    <!-- 配置信息表单 -->
    <el-form
      ref="readingRulesForm"
      v-loading="loading"
      :model="form"
      style="width: 800px"
      :rules="rules"
      label-width="340px"
      size="small"
    >
      <!-- 阅片平台 -->
      <el-form-item
        :label="$t('trials:processCfg:form:imagePlatform')"
        prop="ImagePlatform"
      >
        <el-radio-group
          v-model="form.ImagePlatform"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <template v-if="isUSA">
            <el-radio
              v-for="item of $d.ImagePlatformUSA"
              :key="item.id"
              :label="item.value"
            >
              {{ item.label }}
            </el-radio>
          </template>
          <template v-else>
            <el-radio
              v-for="item of $d.ImagePlatform"
              :key="item.id"
              :label="item.value"
            >
              {{ item.label }}
            </el-radio>
          </template>
        </el-radio-group>
      </el-form-item>
      <!-- 阅片工具 -->
      <el-form-item
        v-if="form.ImagePlatform === 3"
        :label="$t('trials:readingUnit:readingRules:title:readingTool')"
        prop="ReadingTool"
      >
        <el-radio-group
          v-model="form.ReadingTool"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.ReadingTool"
            :key="item.id"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!--检查类型筛选-->
      <el-form-item
        :label="$t('trials:processCfg:form:IsImageFilter')"
        prop="IsImageFilter"
      >
        <el-radio-group
          v-model="form.IsImageFilter"
          @input="IsImageFilterChange"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            :label="item.value"
            v-for="item in $d.YesOrNoModality"
            :key="item.id"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- 影像模态 -->
      <el-form-item
        :label="$t('trials:readingUnit:readingRules:title:CriterionModalitys')"
        prop="CriterionModalitys"
        style="position: relative"
        v-if="form.IsImageFilter"
      >
        <el-checkbox-group
          v-model="CriterionModalitys"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-checkbox v-for="item in modalityList" :label="item" :key="item">{{
            item
          }}</el-checkbox>
        </el-checkbox-group>
        <el-button
          v-if="
            !isConfirm &&
            hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
          size="mini"
          style="position: absolute; top: 0; right: -40px"
          @click.stop="handleCheckAllChange"
          type="success"
          >{{
            CriterionModalitys.length === modalityList.length
              ? $t(
                  'trials:readingUnit:readingRules:title:CriterionModalitysCancel'
                )
              : $t(
                  'trials:readingUnit:readingRules:title:CriterionModalitysAll'
                )
          }}</el-button
        >
      </el-form-item>
      <el-form-item
        :label="$t('trials:consistencyAnalysis:table:isUrgent')"
        prop="DigitPlaces"
      >
        <el-radio-group
          v-model="form.IsUrgent"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.YesOrNo"
            :key="item.id"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- 存在附加评估 -->
      <el-form-item
        :label="$t('trials:processCfg:form:IsAdditionalAssessment')"
        prop="IsAdditionalAssessment"
        v-if="CriterionType === 1"
      >
        <el-radio-group
          v-model="form.IsAdditionalAssessment"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.YesOrNo"
            :key="`IsAdditionalAssessment${item.value}`"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- 阅片任务生成方式 -->
      <el-form-item
        :label="$t('trials:processCfg:form:IsAutoCreate')"
        prop="IsAutoCreate"
      >
        <el-radio-group
          v-model="form.IsAutoCreate"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.YesOrNoAuto"
            :key="`IsAutoCreate${item.value}`"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!--阅片模式-->
      <el-form-item
        :label="$t('trials:processCfg:form:readingType')"
        prop="ReadingType"
      >
        <el-radio-group
          v-model="form.ReadingType"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
          @change="
            () => {
              form.IsArbitrationReading = false
            }
          "
        >
          <el-radio
            v-for="item of $d.ReadingMethod"
            :key="item.id"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!--仲裁阅片-->
      <el-form-item
        :label="$t('trials:processCfg:form:ad')"
        prop="IsArbitrationReading"
      >
        <el-radio-group
          v-model="form.IsArbitrationReading"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit']) ||
            form.ReadingType !== 2
          "
        >
          <el-radio
            v-for="item of $d.YesOrNo"
            :key="`IsArbitrationReading${item.value}`"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- 是否阅片期 -->
      <el-form-item
        :label="$t('trials:readingUnit:readingRules:title:isReadingPeriod')"
        prop="IsReadingPeriod"
      >
        <el-radio-group
          v-model="form.IsReadingPeriod"
          :disabled="
            isConfirm ||
            IsMustGlobalReading ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
          @change="
            (v) => {
              if (!v) {
                form.IsGlobalReading = v
                form.IsOncologyReading = v
              }
            }
          "
        >
          <el-radio
            v-for="item of $d.YesOrNo"
            :key="`IsReadingPeriod${item.value}`"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        :label="$t('trials:processCfg:form:global')"
        prop="IsGlobalReading"
      >
        <el-radio-group
          v-model="form.IsGlobalReading"
          :disabled="
            !form.IsReadingPeriod ||
            IsMustGlobalReading ||
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.YesOrNo"
            :key="`IsGlobalReading${item.value}`"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        :label="$t('trials:processCfg:form:clinical')"
        prop="IsOncologyReading"
      >
        <el-radio-group
          v-model="form.IsOncologyReading"
          :disabled="
            !form.IsReadingPeriod ||
            !form.IsSystemSetOncology ||
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.YesOrNo"
            :key="`IsOncologyReading${item.value}`"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- 任务展示方式 -->
      <el-form-item
        :label="
          $t('trials:readingUnit:readingRules:title:readingTaskViewInOrder')
        "
        prop="IsReadingTaskViewInOrder"
      >
        <el-radio-group
          v-model="form.IsReadingTaskViewInOrder"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
          @change="
            (v) => {
              form.ImageDownloadEnum = 0
              form.ImageUploadEnum = 0
              if (v) {
                form.IsReadingShowSubjectInfo = true
                form.IsReadingShowPreviousResults = true
                form.ReadingTaskViewEnum = 0
                form.IseCRFShowInDicomReading = false
              } else {
                form.ReadingTaskViewEnum = 2
              }
            }
          "
        >
          <el-radio
            v-for="item of $d.IsReadingTaskViewInOrder"
            :key="'IsReadingTaskViewInOrder' + item.value"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- 任务组织级别 -->
      <el-form-item
        :label="$t('trials:readingUnit:readingRules:title:readingTaskViewEnum')"
        prop="ReadingTaskViewEnum"
      >
        <el-radio-group
          v-model="form.ReadingTaskViewEnum"
          :disabled="
            isConfirm ||
            !!!isReadingTaskViewInOrder ||
            !!isReadingTaskViewInOrder ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.ReadingTaskViewEnum"
            :key="item.id"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!--支持影像下载v-if="CriterionType === 0"-->
      <el-form-item
        :label="$t('trials:processCfg:form:ImageDownloadEnum')"
        prop="ImageDownloadEnum"
      >
        <el-radio-group
          v-model="form.ImageDownloadEnum"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.ImageDownloadEnum"
            :key="item.id"
            :label="item.value"
            :disabled="
              (form.IsReadingTaskViewInOrder === 1 ||
                form.IsReadingTaskViewInOrder === 0) &&
              item.value === 1
            "
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!--支持上传DICOM影像-->
      <el-form-item
        :label="$t('trials:processCfg:form:ImageUploadEnum')"
        prop="ImageUploadEnum"
      >
        <el-radio-group
          v-model="form.ImageUploadEnum"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.ImageUploadEnum"
            :key="item.id"
            :label="item.value"
            :disabled="
              (form.IsReadingTaskViewInOrder === 1 ||
                form.IsReadingTaskViewInOrder === 0) &&
              item.value === 1
            "
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- IR阅片页面是否显示受试者信息 -->
      <el-form-item
        :label="
          $t('trials:readingUnit:readingRules:title:isReadingShowSubjectInfo')
        "
        prop="IsReadingShowSubjectInfo"
      >
        <el-radio-group
          v-model="form.IsReadingShowSubjectInfo"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit']) ||
            !!form.IsReadingTaskViewInOrder
          "
        >
          <el-radio
            v-for="item of $d.YesOrNo"
            :key="'IsReadingShowSubjectInfo' + item.value"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- IR阅片页面是否可以查看既往任务结果 -->
      <el-form-item
        :label="
          $t(
            'trials:readingUnit:readingRules:title:isReadingShowPreviousResults'
          )
        "
        prop="IsReadingShowPreviousResults"
      >
        <el-radio-group
          v-model="form.IsReadingShowPreviousResults"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit']) ||
            !!form.IsReadingTaskViewInOrder
          "
          @change="
            (v) => {
              if (!v) {
                form.IseCRFShowInDicomReading = true
              }
            }
          "
        >
          <el-radio
            v-for="item of $d.YesOrNo"
            :key="'IsReadingShowPreviousResults' + item.value"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- eCRF是否显示在影像阅片页面 -->
      <el-form-item
        :label="
          $t('trials:readingUnit:readingRules:title:isECRFShowInDicomReading')
        "
        prop="IseCRFShowInDicomReading"
      >
        <el-radio-group
          v-model="form.IseCRFShowInDicomReading"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit']) ||
            !form.IsReadingShowPreviousResults
          "
        >
          <el-radio
            v-for="item of $d.YesOrNo"
            :key="item.label"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- 修约小数位数 -->
      <el-form-item
        :label="$t('trials:processCfg:form:digitPlaces')"
        prop="DigitPlaces"
      >
        <el-radio-group
          v-model="form.DigitPlaces"
          :disabled="
            isConfirm ||
            !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
          "
        >
          <el-radio
            v-for="item of $d.DigitPlaces"
            :key="item.id"
            :label="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        :label="
          $t(
            'trials:trials-panel:setting:reading-unit:TrialCriterionAdditionalAssessmentTypeList'
          )
        "
        v-if="
          form.IsAdditionalAssessment &&
          form.TrialCriterionAdditionalAssessmentTypeList &&
          form.TrialCriterionAdditionalAssessmentTypeList.length > 0
        "
      >
      </el-form-item>
      <template v-for="item of form.TrialCriterionAdditionalAssessmentTypeList">
        <el-form-item
          :key="item.Id"
          :prop="`AdditionalAssessmentType${item.Id}`"
          :rules="[
            {
              required: true,
              message: $t('common:ruleMessage:select'),
              trigger: ['blur'],
            },
          ]"
          :label="
            $fd('AdditionalAssessmentType', item.AdditionalAssessmentType)
          "
          v-if="
            form.IsAdditionalAssessment &&
            form.TrialCriterionAdditionalAssessmentTypeList
          "
        >
          <el-radio-group
            v-model="item.IsSelected"
            :disabled="
              isConfirm ||
              !hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
            "
            @change="
              (v) => {
                $set(form, 'AdditionalAssessmentType' + item.Id, v)
              }
            "
          >
            <el-radio
              v-for="item of $d.YesOrNo"
              :key="`AdditionalAssessmentType${item.value}`"
              :label="item.value"
            >
              {{ item.label }}
            </el-radio>
          </el-radio-group>
        </el-form-item>
      </template>
      <el-form-item
        v-if="
          !isConfirm &&
          hasPermi(['trials:trials-panel:setting:reading-unit:edit'])
        "
      >
        <!-- 保存 -->
        <el-button type="primary" @click="handleSave(true)">
          {{ $t('common:button:save') }}
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { getCriterionReadingInfo, setCriterionReadingInfo } from '@/api/trials'
export default {
  name: 'ReadingRules',
  props: {
    trialReadingCriterionId: {
      type: String,
      default() {
        return ''
      },
    },
    CriterionType: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      additionalAssessmentOptionList: [],
      form: {
        TrialId: '',
        ImagePlatform: null,
        ReadingTool: 0,
        ReadingTaskViewEnum: null,
        IsImageLabeled: null,
        IsReadingShowSubjectInfo: null,
        IsReadingShowPreviousResults: null,
        ReadingType: 1,
        IsGlobalReading: false,
        IsArbitrationReading: false,
        IsOncologyReading: 0,
        IsReadingTaskViewInOrder: false,
        IsReadingPeriod: false,
        IsSystemSetOncology: false,
        // IsReadingTaskViewInOrder: null,
        ArbitrationRule: null,
        GlobalUpdateType: null,
        IsSystemCriterion: true,
        DigitPlaces: null,
        IseCRFShowInDicomReading: false,
        IsAutoCreate: null,
        IsAdditionalAssessment: null,
        CriterionType: null,
        AdditionalAssessmentType: null,
        IsUrgent: false,
        TrialCriterionAdditionalAssessmentTypeList: [],
        CriterionModalitys: null,
        ImageDownloadEnum: null,
        ImageUploadEnum: null,
        IsImageFilter: false,
      },
      rules: {
        IsAutoCreate: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsAdditionalAssessment: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        ImagePlatform: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        ReadingTool: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        ImageDownloadEnum: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        ImageUploadEnum: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsImageFilter: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        ReadingTaskViewEnum: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsImageLabeled: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsReadingShowSubjectInfo: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsReadingShowPreviousResults: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        ReadingType: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsReadingTaskViewInOrder: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsGlobalReading: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsArbitrationReading: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsOncologyReading: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        DigitPlaces: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IseCRFShowInDicomReading: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        IsReadingPeriod: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
        ],
        CriterionModalitys: [
          {
            required: true,
            message: this.$t('common:ruleMessage:select'),
            trigger: ['blur', 'change'],
          },
          {
            validator: (rule, value, callback) => {
              if (value && Array.isArray(value) && value.length < 0) {
                callback(new Error(this.$t('common:ruleMessage:select')))
              } else {
                callback()
              }
            },
            trigger: ['blur', 'change'],
          },
        ],
        // IsReadingTaskViewInOrder: [
        //   { required: true, message: this.$t('common:ruleMessage:select'), trigger: ['blur', 'change'] }
        // ]
      },
      loading: false,
      readingInfo: {},
      isConfirm: true,
      isReadingTaskViewInOrder: null,
      IsMustGlobalReading: false,
      IsNotReadingShowSubjectInfoChange: false,

      modalityList: [],
      CriterionModalitys: [],
      modalityIsCheck: false, // 是否允许影像筛选
    }
  },
  mounted() {
    this.initPage()
  },
  computed: {
    isUSA() {
      return process.env.NODE_ENV === 'usa'
    },
  },
  watch: {
    CriterionModalitys: {
      handler() {
        this.form.CriterionModalitys = this.CriterionModalitys.join('|')
      },
      deep: true,
    },
  },
  methods: {
    // 检查类型筛选值变更
    IsImageFilterChange(data) {
      if (data) {
        this.CriterionModalitys = this.modalityList
      } else {
        this.CriterionModalitys = []
      }
    },
    // 影像模态全选
    handleCheckAllChange() {
      this.CriterionModalitys =
        this.CriterionModalitys.length <= 0 ? this.modalityList : []
    },
    initPage() {
      this.loading = true
      const trialId = this.$route.query.trialId
      // getTrialCriterionAdditionalAssessmentOptionList(this.trialReadingCriterionId).then(res => {
      //   this.additionalAssessmentOptionList = res.Result
      //   if (this.additionalAssessmentOptionList.length > 0) {
      //     this.additionalAssessmentOptionList.forEach(v => {
      //       this.$set(this.form, 'AdditionalAssessmentType'+v.Id, v.IsSelected)
      //     })
      //   }
      getCriterionReadingInfo({
        trialId,
        TrialReadingCriterionId: this.trialReadingCriterionId,
      })
        .then((res) => {
          this.loading = false
          this.modalityList = res.Result.TrialModalitys.split('|').filter(
            (item) => item && item.trim()
          )
          for (const k in this.form) {
            if (res.Result.hasOwnProperty(k)) {
              this.form[k] = res.Result[k]
            }
          }
          this.CriterionModalitys = this.form.CriterionModalitys
            ? this.form.CriterionModalitys.split('|')
            : []
          this.form.TrialCriterionAdditionalAssessmentTypeList.forEach((v) => {
            this.$set(v, 'IsSelected', v.IsSelected || false)
            this.$set(
              this.form,
              'AdditionalAssessmentType' + v.Id,
              v.IsSelected
            )
          })
          this.isReadingTaskViewInOrder = res.Result.IsReadingTaskViewInOrder
          this.isConfirm = res.Result.IsSign
          this.IsMustGlobalReading = res.Result.IsMustGlobalReading
          this.$emit('setConfirm', res.Result.IsSign)
          this.$emit('setArbitrationReading', res.Result.IsArbitrationReading)
          this.$emit(
            'setAdditionalAssessment',
            this.form.IsAdditionalAssessment
          )
          this.$emit('setIsClinicalReading', res.Result.IsClinicalReading)
          this.$emit('setGlobalReading', res.Result.IsGlobalReading)
          this.$emit('setOncologyReading', res.Result.IsOncologyReading)
          this.$emit('setDigitPlaces', res.Result.DigitPlaces)
          if (res.Result.ReadingType === 1) {
            this.$emit('setArbitrationReading', false)
          }
        })
        .catch(() => {
          this.loading = false
        })
      // }).catch(() => {
      //   this.loading = false
      // })
    },
    // 配置信息保存
    handleSave(isPrompt = true) {
      return new Promise((resolve, reject) => {
        this.$refs['readingRulesForm'].validate((valid) => {
          if (!valid) {
            resolve(false)
          } else {
            this.loading = true
            if (this.form.ReadingType === 1) {
              this.form.IsArbitrationReading = false
            }
            // 保存配置信息
            this.form.TrialReadingCriterionId = this.trialReadingCriterionId
            setCriterionReadingInfo(this.form)
              .then((res) => {
                this.loading = false
                this.$emit('reloadArbitrationRules')
                this.$emit(
                  'setArbitrationReading',
                  this.form.IsArbitrationReading
                )
                this.$emit(
                  'setAdditionalAssessment',
                  this.form.IsAdditionalAssessment
                )
                this.$emit('setIsClinicalReading', this.form.IsClinicalReading)
                this.$emit('setGlobalReading', this.form.IsGlobalReading)
                this.$emit('setOncologyReading', this.form.IsOncologyReading)
                this.$emit('setDigitPlaces', this.form.DigitPlaces)
                if (this.form.ReadingType === 1) {
                  this.$emit('setArbitrationReading', false)
                }
                if (res.IsSuccess && isPrompt) {
                  this.$message.success(
                    this.$t('common:message:savedSuccessfully')
                  )
                }
                resolve(true)
              })
              .catch((_) => {
                this.loading = false
                resolve(false)
              })
          }
        })
      })
    },
  },
}
</script>
<style lang="scss" scoped>
.reading-rule-config-form {
  .fontColor {
    color: red;
  }
}
</style>
