<template>
  <div class="kt-canvas-table-select">
    <div>
      <el-radio-group :value="value" @input="$emit('input', $event)">
        <el-radio
          v-for="(item, index) in list"
          :key="index"
          v-on="item"
          :label="item.value"
          class="kt-canvas-table-select-row"
        >{{ item.label }}</el-radio>
      </el-radio-group>
    </div>
    <div class="kt-canvas-table-select-footer">
      <el-button type="text" @click="onReset" :disabled="disabledReset">重 置</el-button>
      <el-button type="primary" @click="onConfirm" size="mini">确 认</el-button>
    </div>
  </div>
</template>

<script>
import ElRadioGroup from 'esc-system-ui/packages/radio/src/radio-group.vue';
import ElRadio from 'esc-system-ui/packages/radio';
import ElButton from 'esc-system-ui/packages/button';
import { isNull } from '../utils';
export default {
  components: { ElRadioGroup, ElRadio, ElButton },
  props: {
    list: Array,
    value: {
      type: [Number, String],
      default: '二次设备'
    }
  },
  computed: {
    disabledReset() {
      return isNull(this.value);
    }
  },
  methods: {
    onConfirm() {
      this.$emit('confirm');
    },
    onReset() {
      this.$emit('input', '');
    }
  }
};
</script>
