<template>
  <div class="static-end-step">
    <el-form label-width="120px">
      <el-form-item label="实际时间">
        <el-input v-model="formData.actualDuration" placeholder="请输入实际静置时间">
          <el-select v-model="formData.actualDurationUnit" slot="append" style="width: 80px;">
            <el-option label="min" value="min"></el-option>
            <el-option label="h" value="h"></el-option>
            <el-option label="d" value="d"></el-option>
          </el-select>
        </el-input>
      </el-form-item>
      
      <el-form-item label="结束时间">
        <el-date-picker
          v-model="formData.endTime"
          type="datetime"
          placeholder="请选择结束时间"
          format="yyyy-MM-dd HH:mm"
          value-format="yyyy-MM-dd HH:mm:ss"
        ></el-date-picker>
      </el-form-item>
      
      <el-form-item label="实际温度">
        <el-input v-model="formData.actualTemperature" placeholder="请输入实际温度">
          <el-select v-model="formData.actualTemperatureUnit" slot="append" style="width: 60px;">
            <el-option label="℃" value="℃"></el-option>
            <el-option label="℉" value="℉"></el-option>
          </el-select>
        </el-input>
      </el-form-item>
      
      <el-form-item label="样品状态">
        <el-select v-model="formData.sampleState" placeholder="请选择样品状态">
          <el-option label="正常" value="normal"></el-option>
          <el-option label="异常" value="abnormal"></el-option>
          <el-option label="有变化" value="changed"></el-option>
          <el-option label="无变化" value="unchanged"></el-option>
        </el-select>
      </el-form-item>
      
      <el-form-item label="观察结果">
        <el-checkbox-group v-model="formData.observationResults">
          <el-checkbox label="颜色变化">颜色变化</el-checkbox>
          <el-checkbox label="沉淀形成">沉淀形成</el-checkbox>
          <el-checkbox label="相分离">相分离</el-checkbox>
          <el-checkbox label="结晶">结晶</el-checkbox>
          <el-checkbox label="无异常">无异常</el-checkbox>
          <el-checkbox label="其他">其他</el-checkbox>
        </el-checkbox-group>
      </el-form-item>
      
      <el-form-item label="容器状态">
        <el-select v-model="formData.finalContainerState" placeholder="请选择最终容器状态">
          <el-option label="密封" value="sealed"></el-option>
          <el-option label="半密封" value="semiSealed"></el-option>
          <el-option label="开放" value="open"></el-option>
        </el-select>
      </el-form-item>
      
      <el-form-item label="后续处理">
        <el-checkbox-group v-model="formData.nextSteps">
          <el-checkbox label="直接进行下一步">直接进行下一步</el-checkbox>
          <el-checkbox label="需要预处理">需要预处理</el-checkbox>
          <el-checkbox label="需要检测">需要检测</el-checkbox>
          <el-checkbox label="需要储存">需要储存</el-checkbox>
          <el-checkbox label="需要转移">需要转移</el-checkbox>
        </el-checkbox-group>
      </el-form-item>
      
      <el-form-item label="处理结果">
        <el-radio-group v-model="formData.processResult">
          <el-radio label="success">静置成功</el-radio>
          <el-radio label="partial">部分成功</el-radio>
          <el-radio label="failed">静置失败</el-radio>
        </el-radio-group>
      </el-form-item>
      
      <el-form-item v-if="formData.processResult !== 'success'" label="失败原因">
        <el-input v-model="formData.failureReason" placeholder="请输入失败原因"></el-input>
      </el-form-item>
      
      <el-form-item label="质量评估">
        <el-rate v-model="formData.qualityScore" show-text></el-rate>
      </el-form-item>
      
      <el-form-item label="最终观察">
        <el-input 
          v-model="formData.finalObservation" 
          type="textarea" 
          :rows="3" 
          placeholder="请输入最终观察结果"
        ></el-input>
      </el-form-item>
      
      <el-form-item label="备注">
        <el-input 
          v-model="formData.notes" 
          type="textarea" 
          :rows="3" 
          placeholder="请输入备注信息"
        ></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'StaticEndStep',
  props: ['stepData'],
  data() {
    return {
      formData: {
        actualDuration: '',
        actualDurationUnit: 'h',
        endTime: '',
        actualTemperature: '',
        actualTemperatureUnit: '℃',
        sampleState: '',
        observationResults: [],
        finalContainerState: '',
        nextSteps: [],
        processResult: 'success',
        failureReason: '',
        qualityScore: 5,
        finalObservation: '',
        notes: ''
      }
    }
  },
  created() {
    this.formData = { ...this.formData, ...this.stepData }
  },
  watch: {
    formData: {
      handler(newVal) {
        this.$emit('update', newVal)
      },
      deep: true
    }
  }
}
</script>