172 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			172 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
<template>
 | 
						|
  <el-form
 | 
						|
    ref="subjectForm"
 | 
						|
    v-loading="loading"
 | 
						|
    :model="form"
 | 
						|
    :rules="rules"
 | 
						|
    size="small"
 | 
						|
    label-width="120px"
 | 
						|
  >
 | 
						|
    <div class="base-dialog-body" style="border: none">
 | 
						|
      <!-- Site -->
 | 
						|
      <el-form-item :label="$t('trials:subject:table:site')" prop="SiteId">
 | 
						|
        <el-select
 | 
						|
          v-model="form.SiteId"
 | 
						|
          clearable
 | 
						|
          filterable
 | 
						|
          style="width:100%"
 | 
						|
          disabled
 | 
						|
        >
 | 
						|
          <el-option
 | 
						|
            v-for="item of siteOptions"
 | 
						|
            :key="item.Id"
 | 
						|
            :label="item.TrialSiteCode"
 | 
						|
            :value="item.SiteId"
 | 
						|
          />
 | 
						|
        </el-select>
 | 
						|
      </el-form-item>
 | 
						|
      <!-- 受试者编号 -->
 | 
						|
      <el-form-item :label="$t('trials:subject:table:subjectId')" prop="Code">
 | 
						|
        <el-input v-model="form.Code" disabled />
 | 
						|
        <span v-show="otherInfo.IsNoticeSubjectCodeRule" style="color:#F56C6C;font-size:12px;">{{ otherInfo.SubjectCodeRule }}</span>
 | 
						|
      </el-form-item>
 | 
						|
      <!-- 访视基准日期 -->
 | 
						|
      <el-form-item
 | 
						|
        v-show="otherInfo.IsHaveFirstGiveMedicineDate"
 | 
						|
        :label="$t('trials:subject:table:firstGiveMedicineTime')"
 | 
						|
        prop="FirstGiveMedicineTime"
 | 
						|
      >
 | 
						|
        <el-date-picker
 | 
						|
          v-model="form.FirstGiveMedicineTime"
 | 
						|
          type="date"
 | 
						|
          :picker-options="pickerOption"
 | 
						|
          value-format="yyyy-MM-dd"
 | 
						|
          format="yyyy-MM-dd"
 | 
						|
        />
 | 
						|
      </el-form-item>
 | 
						|
    </div>
 | 
						|
    <div class="base-dialog-footer" style="text-align:right;margin-top:10px;">
 | 
						|
      <el-form-item>
 | 
						|
        <!-- 取消 -->
 | 
						|
        <el-button
 | 
						|
          :disabled="btnLoading"
 | 
						|
          size="small"
 | 
						|
          type="primary"
 | 
						|
          @click="handleCancel"
 | 
						|
        >
 | 
						|
          {{ $t('common:button:cancel') }}
 | 
						|
        </el-button>
 | 
						|
        <!-- 保存 -->
 | 
						|
        <el-button size="small" type="primary" :loading="btnLoading" @click="handleSave">
 | 
						|
          {{ $t('common:button:save') }}
 | 
						|
        </el-button>
 | 
						|
      </el-form-item>
 | 
						|
    </div>
 | 
						|
 | 
						|
  </el-form>
 | 
						|
 | 
						|
</template>
 | 
						|
<script>
 | 
						|
import { getTrialSiteSelect, addOrUpdateSubject } from '@/api/trials'
 | 
						|
export default {
 | 
						|
  name: 'SubjectForm',
 | 
						|
  props: {
 | 
						|
    data: {
 | 
						|
      type: Object,
 | 
						|
      default() { return {} }
 | 
						|
    },
 | 
						|
    otherInfo: {
 | 
						|
      type: Object,
 | 
						|
      default() { return {} }
 | 
						|
    }
 | 
						|
  },
 | 
						|
 | 
						|
  data() {
 | 
						|
    return {
 | 
						|
      form: {
 | 
						|
        Id: '',
 | 
						|
        Code: '',
 | 
						|
        ShortName: '',
 | 
						|
        Height: '',
 | 
						|
        Weight: '',
 | 
						|
        Age: '',
 | 
						|
        Sex: '',
 | 
						|
        BirthDate: '',
 | 
						|
        SiteId: '',
 | 
						|
        MedicalNo: '',
 | 
						|
        Status: 1,
 | 
						|
        FirstGiveMedicineTime: '',
 | 
						|
        OutEnrollmentTime: '',
 | 
						|
        VisitOverTime: '',
 | 
						|
        Reason: '',
 | 
						|
        StudyCount: '',
 | 
						|
        SignDate: '',
 | 
						|
        IsUrgent: false
 | 
						|
      },
 | 
						|
      isHaveSubjectAge: false,
 | 
						|
      rules: {
 | 
						|
        Code: [
 | 
						|
          { required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' },
 | 
						|
          { max: 50, message: `${this.$t('common:ruleMessage:maxLength')} 50` }
 | 
						|
        ],
 | 
						|
        FirstGiveMedicineTime: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }]
 | 
						|
      },
 | 
						|
      pickerOption: {
 | 
						|
        disabledDate: time => {
 | 
						|
          return time.getTime() > Date.now()
 | 
						|
        }
 | 
						|
      },
 | 
						|
      btnLoading: false,
 | 
						|
      siteOptions: [],
 | 
						|
      loading: false,
 | 
						|
      trialId: ''
 | 
						|
    }
 | 
						|
  },
 | 
						|
  computed: {
 | 
						|
    isEdit() {
 | 
						|
      return (!!this.form.Id) && this.hasPermi(['role:crc'])
 | 
						|
    }
 | 
						|
  },
 | 
						|
  mounted() {
 | 
						|
    this.trialId = this.$route.query.trialId
 | 
						|
    this.initForm()
 | 
						|
  },
 | 
						|
  methods: {
 | 
						|
    async initForm() {
 | 
						|
      this.loading = true
 | 
						|
      const res = await getTrialSiteSelect(this.trialId)
 | 
						|
      this.loading = false
 | 
						|
      this.siteOptions = res.Result
 | 
						|
      if (Object.keys(this.data).length > 0) {
 | 
						|
        for (const k in this.form) {
 | 
						|
          if (this.data.hasOwnProperty(k)) {
 | 
						|
            this.form[k] = this.data[k]
 | 
						|
          }
 | 
						|
        }
 | 
						|
      }
 | 
						|
      this.form.TrialId = this.trialId
 | 
						|
    },
 | 
						|
    handleSave() {
 | 
						|
      this.$refs.subjectForm.validate(valid => {
 | 
						|
        if (!valid) return
 | 
						|
        this.btnLoading = true
 | 
						|
        addOrUpdateSubject(this.form).then(res => {
 | 
						|
          this.btnLoading = false
 | 
						|
          this.$emit('submitFirstGiveMedicineTime', this.form.FirstGiveMedicineTime)
 | 
						|
          // this.$message.success(this.$t('common:message:savedSuccessfully'))
 | 
						|
        })
 | 
						|
          .catch(() => {
 | 
						|
            this.btnLoading = false
 | 
						|
          })
 | 
						|
      })
 | 
						|
    },
 | 
						|
    handleCancel() {
 | 
						|
      this.$emit('close')
 | 
						|
    },
 | 
						|
    getSite() {
 | 
						|
      getTrialSiteSelect(this.trialId).then(res => { this.siteList = res.Result })
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
</script>
 |