<template>
  <el-form label-width="auto">
    <el-row :gutter="20" style="margin-top: 20px">
      <el-col :span="8">
        <el-form-item label="关机：">
          <el-button type="primary" @click="handelControl(1)">关机</el-button>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="重启：">
          <el-button type="primary" @click="handelControl(2)">重启</el-button>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20" style="margin-top: 20px">
      <el-col :span="8">
        <el-form-item label="恢复出厂：">
          <el-button type="primary" @click="handelControl(3)">恢复出厂</el-button>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="获取实时定位：">
          <el-button type="primary" @click="handelControl(4)">获取实时定位</el-button>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="模式选择：">
          <el-select placeholder="请选择模式" v-model="modelValue.mode" style="width: 230px" @change="handelControl(5)">
            <el-option label="常规模式" :value="0" />
            <el-option label="审讯模式" :value="1" />
            <el-option label="户外押送模式" :value="2" />
          </el-select>
        </el-form-item>
      </el-col>
      <!-- <el-col :span="12">
        <el-form-item label="定位模式：">
          <el-select placeholder="请选择定位模式" v-model="modelValue.mode" style="width: 240px" @change="handelControl(6)">
            <el-option label="室内" :value="0" />
            <el-option label="室外" :value="1" />
          </el-select>
        </el-form-item>
      </el-col> -->
    </el-row>
  </el-form>
</template>

<script setup lang="ts" name="basetable">
import { ElMessageBox } from "element-plus";
const emit = defineEmits(["change"]);

const { modelValue } = defineProps({
  modelValue: {
    type: Object,
    default: () => ({}),
  },
});

const handelControl = (type: number) => {
  if (type <= 4) {
    enum msgEnum {
      "确定要关机吗？" = 1,
      "确定要重启吗？",
      "确定要恢复出厂吗？",
      "确定要获取实时定位吗？",
    }
    ElMessageBox.confirm(msgEnum[type], "提示", {
      type: "warning",
    }).then(async () => {
      emit("change", type);
    });
  } else {
    emit("change", type);
  }
};

// const model = useVModel(props, "modelValue", emit);
</script>
