
<template>
  <el-row>
    <el-col :span="24">
      <el-form
        :model="pacsDetailForm"
        ref="pacsDetailForm"
        class="sub-form"
        :validate-on-rule-change="false"
      >
        <el-form-item label="单位" label-width="110px" prop="unit">
          <el-input v-model.trim="pacsDetailForm.unit" placeholder="请输入单位" @blur="handleValue('unit')"></el-input>
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="数值范围" label-width="110px" prop="minval">
              <el-input v-model.trim="pacsDetailForm.minval" placeholder="请输入最小值" @blur="handleValue('minval')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <div class="turns">——</div>
          </el-col>
          <el-col :span="10">
            <el-form-item label label-width="0px" prop="maxval">
              <el-input v-model.trim="pacsDetailForm.maxval" placeholder="请输入最大值" @blur="handleValue('maxval')"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label label-width="110px" prop="range">
          <el-radio-group v-model="pacsDetailForm.range" @change="handleValue('range')">
            <el-radio :label="0">范围内</el-radio>
            <el-radio :label="1">范围外</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>

<script>
export default {
  name: 'PacsDetailForm',
  props: ['data'],
  data() {
    return {
      pacsDetailForm: {
        unit: '',
        range: 0,
        maxval: '',
        minval: ''
      }
    };
  },
  computed: {},
  created() {
    this._initData();
  },
  mounted() {},
  methods: {
    _initData() {
      this.pacsDetailForm.unit = this.data.unit;
      this.pacsDetailForm.range = this.data.range;
      this.pacsDetailForm.maxval = this.data.maxval;
      this.pacsDetailForm.minval = this.data.minval;
    },
    // 传值
    handleValue(from) {
      this.$emit('handleInput', {
        type: from,
        value: this.pacsDetailForm[from]
      });
    }
  }
};
</script>

<style lang="less" scoped>
.turns {
  text-align: center;
  height: 40px;
  line-height: 40px;
  color: #dcdfe6;
}
</style>