<template>
  <div>
    <el-dialog
      title="设备使用记录自动生成配置"
      :visible.sync="dialogVisible"
      width="30%"
      center
    >
      <el-form :model="randerform" ref="randerform">
        <el-row>
          <el-form-item label="是否开启:">
            <el-radio-group v-model="randerform.run" @change="changeRun">
              <el-radio
                :label="gender.id"
                :value="gender.id"
                v-for="(gender, index) in Option"
                :key="gender.id"
                >{{ gender.name }}</el-radio
              >
            </el-radio-group>
          </el-form-item>
        </el-row>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
// eslint-disable-next-line no-unused-vars
import { changeRun, getRemanderData } from "@/api/manage";
export default {
  name: "RemanderForm",
  data() {
    return {
      dialogVisible: false,
      Option: [
        { id: 1, name: "是" },
        { id: 2, name: "否" }
      ],
      randerform: {
        run: 2
      }
    };
  },
  methods: {
    open: function() {
      this.dialogVisible = true;
    },
    changeRun(id) {
      // eslint-disable-next-line no-undef
      changeRun(id).then(response => {
        if (response.data.state === 1) {
          var id = response.data.data.id;
          // eslint-disable-next-line eqeqeq
          if (id == 1) {
            this.$message.success("开启成功");
          }
          // eslint-disable-next-line eqeqeq
          if (id == 2) {
            this.$message.success("关闭成功");
          }
        }
      });
    },
    getRemanderData() {
      getRemanderData().then(response => {
        // eslint-disable-next-line eqeqeq
        if (response.data.state == 1) {
          var remander = response.data.data.remander;
          // console.log('remander=================小夏', remander)
          this.randerform.run = remander.is_run;
        }
      });
    }
  },
  created() {
    this.getRemanderData();
  }
};
</script>

<style scoped></style>
