
<!-- 自动称重步骤表单 -->
<template>
  <div class="flex">
      <div class="form-label">选择</div>
      <HandleFormItem 
        class = "w-120"
        :item="fieldConfigs.notes"
        v-model="formData.notes"
      />
  </div>
</template>

<script>
import HandleFormItem from '../HandleFormItem.vue'
import Input from '../Input.vue'
export default {
  name: 'AutoWeighStep',
  components: {
    HandleFormItem,
    Input
  },
  props: ['stepData'],
  data() {
    return {
      formData: {
        targetWeight: '123',
        tolerance: '',
        sampleName: '',
        containerWeight: '',
        notes: ''
      },
      // 字段配置
      fieldConfigs: {
        targetWeight: {
          label: '目标重量',
          placeholder: '请输入目标重量',
          maxlength: 50
        },
        tolerance: {
          label: '允许误差',
          placeholder: '请输入允许误差',
          maxlength: 20
        },
        sampleName: {
          label: '样品名称',
          placeholder: '请输入样品名称',
          maxlength: 100
        },
        containerWeight: {
          label: '容器重量',
          placeholder: '请输入容器重量',
          maxlength: 20
        },
        notes: {
          label: '备注',
          placeholder: '请输入备注信息',
          maxlength: 500
        }
      }
    }
  },
  created() {
    // 合并传入的数据
    if (this.stepData) {
      this.formData = { ...this.formData, ...this.stepData }
    }
  },
  watch: {
    formData: {
      handler(newVal) {
        this.$emit('update', newVal)
      },
      deep: true
    }
  },
  methods: {
    onFieldChange(field, value) {
      this.formData[field] = value
    },
  }
}
</script>

<style lang="scss" scoped>
.w-120{
    width: 120px;
}
</style>