<template>
  <div class="coat-step">
    <el-form label-width="120px">
      <el-form-item label="包被物质">
        <el-input v-model="formData.coatMaterial" placeholder="请输入包被物质名称"></el-input>
      </el-form-item>
      
      <el-form-item label="包被浓度">
        <el-input v-model="formData.concentration" placeholder="请输入浓度值">
          <el-select v-model="formData.concentrationUnit" slot="append" style="width: 80px;">
            <el-option label="mg/ml" value="mg/ml"></el-option>
            <el-option label="μg/ml" value="μg/ml"></el-option>
            <el-option label="ng/ml" value="ng/ml"></el-option>
            <el-option label="%" value="%"></el-option>
          </el-select>
        </el-input>
      </el-form-item>
      
      <el-form-item label="包被体积">
        <el-input v-model="formData.volume" placeholder="请输入体积">
          <el-select v-model="formData.unit" slot="append" style="width: 80px;">
            <el-option label="ml" value="ml"></el-option>
            <el-option label="μl" value="μl"></el-option>
            <el-option label="l" value="l"></el-option>
          </el-select>
        </el-input>
      </el-form-item>
      
      <el-form-item label="包被时间">
        <el-input v-model="formData.time" placeholder="请输入时间">
          <el-select v-model="formData.timeUnit" 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-input v-model="formData.temperature" placeholder="请输入温度">
          <el-select v-model="formData.temperatureUnit" 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="pH值">
        <el-input-number 
          v-model="formData.pH" 
          :min="1" 
          :max="14" 
          :step="0.1"
          :precision="1"
          placeholder="请输入pH值"
        ></el-input-number>
      </el-form-item>
      
      <el-form-item label="容器类型">
        <el-select v-model="formData.containerType" placeholder="请选择容器类型">
          <el-option label="微孔板" value="microplate"></el-option>
          <el-option label="培养皿" value="petriDish"></el-option>
          <el-option label="载玻片" value="slide"></el-option>
          <el-option label="试管" value="testTube"></el-option>
        </el-select>
      </el-form-item>
      
      <el-form-item label="包被方法">
        <el-radio-group v-model="formData.method">
          <el-radio label="passive">被动吸附</el-radio>
          <el-radio label="active">共价结合</el-radio>
        </el-radio-group>
      </el-form-item>
      
      <el-form-item label="洗涤步骤">
        <el-checkbox-group v-model="formData.washSteps">
          <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-switch v-model="formData.blocking"></el-switch>
      </el-form-item>
      
      <el-form-item v-if="formData.blocking" label="封闭剂">
        <el-input v-model="formData.blockingAgent" placeholder="请输入封闭剂名称"></el-input>
      </el-form-item>
      
      <el-form-item v-if="formData.blocking" label="封闭时间">
        <el-input v-model="formData.blockingTime" placeholder="请输入封闭时间">
          <el-select v-model="formData.blockingTimeUnit" slot="append" style="width: 80px;">
            <el-option label="min" value="min"></el-option>
            <el-option label="h" value="h"></el-option>
          </el-select>
        </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: 'CoatStep',
  props: ['stepData'],
  data() {
    return {
      formData: {
        coatMaterial: '',
        concentration: '',
        concentrationUnit: 'mg/ml',
        volume: '',
        unit: 'ml',
        time: '',
        timeUnit: 'h',
        temperature: '',
        temperatureUnit: '℃',
        pH: '',
        containerType: '',
        method: 'passive',
        washSteps: [],
        blocking: false,
        blockingAgent: '',
        blockingTime: '',
        blockingTimeUnit: 'min',
        notes: ''
      }
    }
  },
  created() {
    this.formData = { ...this.formData, ...this.stepData }
  },
  watch: {
    formData: {
      handler(newVal) {
        this.$emit('update', newVal)
      },
      deep: true
    }
  }
}
</script>