<template>
  <el-row>
    <el-col :span="24">
      <el-form
        :model="operationForm"
        ref="operationForm"
        class="sub-form"
        :validate-on-rule-change="false"
        :rules="rules"
      >
        <el-form-item label="手术级别" label-width="110px" prop="opgrade">
          <el-select
            v-model="operationForm.opgrade"
            placeholder="请选择手术级别"
            style="width: 100%"
            ref="opgrade"
            clearable
            @change="handleValue('opgrade')"
          >
            <el-option label="0" value="0"></el-option>
            <el-option label="1" value="1"></el-option>
            <el-option label="2" value="2"></el-option>
            <el-option label="3" value="3"></el-option>
            <el-option label="4" value="4"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="高危条件" label-width="110px" v-if="operationForm.opgrade == 2">
          <span
            style="paddingLeft: 12px; color: #606266"
          >{{(operationForm.highriskcond === '' || operationForm.highriskcond === null)? '未设置': '已设置'}}</span>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>

<script>
export default {
  name: 'OperationForm',
  props: ['data'],
  data() {
    let checkFrequency = (rule, value, callback) => {
      let opgrade = this.$refs.opgrade.value;
      if (opgrade === '' || opgrade === null) {
        callback('请选择手术级别');
      } else {
        callback();
      }
    };

    return {
      operationForm: {
        opgrade: '',
        highriskcond: ''
      },
      rules: {
        opgrade: [
          {
            required: true,
            validator: checkFrequency,
            trigger: ['blur', 'change']
          }
        ]
      }
    };
  },
  computed: {},
  created() {
    this._initData();
  },
  mounted() {},
  methods: {
    _initData() {
      console.log(this.data, '===========');
      this.operationForm.opgrade = this.data.opgrade;
      this.operationForm.highriskcond = this.data.highriskcond;
    },
    // 传值
    handleValue(from) {
      this.$emit('handleInput', {
        type: from,
        value: this.operationForm[from]
      });
    }
  }
};
</script>

<style lang="less" scoped>
</style>