<template>
  <el-dialog v-dialogDrag z-index='1000' title="注册码配置" :visible.sync="jurisdiction" width="45%"
    :close-on-click-modal="false" :show-close="false" :close-on-press-escape="false" :before-close="cancel">
    <el-form :model="ruleForm" :rules="machineRules" ref="ruleForm" label-width="100px" class="diaForm">
      <el-form-item label="机器码：" prop="machineCode">
        <el-input style="width:100%" placeholder="请输入机器码" v-model="ruleForm.machineCode"></el-input>
      </el-form-item>
      <el-form-item label="注册码：" prop="password">
        <el-input style="width:100%" show-password placeholder="请输入注册码" v-model="ruleForm.password"></el-input>
      </el-form-item>
      <div class="btnClass">
        <el-button @click="submits('ruleForm')" size="mini" type="primary">确定</el-button>
        <!-- <el-button @click="cancel" size="mini" type="primary">取消</el-button> -->
      </div>
    </el-form>
  </el-dialog>
</template>
<script>
  import {
    saveDbMac
  } from "@/api/user";
  import {
    clearObjValue,
    message
  } from "@/utils/common"
  export default {
    props: {
      jurisdiction: {
        type: Boolean,
        default: () => false,
      },
      machineRules: {
        type: Object,
        default: () => {},
      },
      ruleForm: {
        type: Object,
        default: () => {},
      },

    },
    data() {
      return {

      }
    },
    methods: {
      cancel() {
        this.$emit("cancel")
      },
      submits(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            let data = {
              secretMac: this.ruleForm.password,
            };
            saveDbMac(data).then((res) => {

              message("success", "注册成功", 3000);
              this.$emit("cancel")
            });
          } else {
            console.log("error submit!!");
            return false;
          }
        });
      }
    }
  }

</script>
<style lang="scss" scoped>
  .btnClass {
    text-align: center;
  }

</style>
