<template>
  <el-dialog title="提示" :visible.sync="autoDialog" width="30%" @close="autoRelateClose">
    <div id="autoRelate">
      <p>请选择使用哪个信息点对应原始点位的设备标识：</p>
      <p>
        <el-radio v-model="autoType" label="objectLocalName">{{TypeName}}实例本地名称</el-radio>
      </p>
      <p>
        <el-radio v-model="autoType" label="objectLocalCode">{{TypeName}}实例本地编码</el-radio>
      </p>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="autoRelateClose">取消</el-button>
      <el-button size="small" type="primary" @click="confirm">确认</el-button>
    </span>
  </el-dialog>
</template>
<script>
import {
  dynamicAutoRelate
} from "@/api/scan/request"
export default {
  data() {
    return {
      autoDialog: false,
      autoType: "objectLocalName",
      TypeName: '',
      TypeCode: ''
    }
  },
  methods: {
    showDialog(TypeName, TypeCode) {
      this.TypeName = TypeName;
      this.TypeCode = TypeCode;
      this.autoDialog = true;
    },
    autoRelateClose() {
      this.autoDialog = false;
    },
    confirm() {
      let pa = {
        MatchKey: this.autoType,
        TypeName: this.TypeName
      }
      this.autoDialog = false;
      this.$message('正在执行');
      this.$emit('autoRelateSuc', this.TypeCode);
      dynamicAutoRelate(pa, res => {
        this.$message.success('匹配成功');
      })
    }
  },
}
</script>
<style lang="scss" scoped>
#autoRelate {
  /deep/ .el-radio__input.is-checked + .el-radio__label {
    color: #000;
  }
  p {
    font-size: 12px;
    margin-bottom: 8px;
    padding-left: 24px;
  }
}
</style>