2025-03-14 23:48:59 +08:00
|
|
|
|
<template>
|
2025-04-05 21:03:46 +08:00
|
|
|
|
<el-dialog :visible.sync="visible" width="400px" center>
|
|
|
|
|
|
<div
|
|
|
|
|
|
style="margin: 0 10px 10px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
|
|
|
|
|
|
<div
|
|
|
|
|
|
style="width: 40px;height: 40px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
|
2025-03-18 21:49:57 +08:00
|
|
|
|
<img src="@/assets/home/equipment.png" alt="" style="width: 18px;height: 15px;" />
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
添加设备
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="height: 1px;background: #e8f0ff;" />
|
2025-03-18 21:49:57 +08:00
|
|
|
|
<div style="margin: 22px 15px;">
|
2025-03-14 23:48:59 +08:00
|
|
|
|
<div style="font-weight: 400;font-size: 14px;text-align: left;color: #3d4566;">
|
2025-03-18 21:49:57 +08:00
|
|
|
|
<div style="color: red;display: inline-block;">*</div>
|
|
|
|
|
|
<span style="font-size: 11px"> 验证码:</span>
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</div>
|
2025-03-18 21:49:57 +08:00
|
|
|
|
<div class="input-46" style="margin-top: 12px;">
|
2025-04-05 21:03:46 +08:00
|
|
|
|
<el-input placeholder="请输入设备播报的6位数验证码.." v-model="deviceCode" @keyup.enter.native="confirm" />
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-03-18 21:49:57 +08:00
|
|
|
|
<div style="display: flex;margin: 15px 15px;gap: 7px;">
|
2025-03-14 23:48:59 +08:00
|
|
|
|
<div class="dialog-btn" @click="confirm">
|
|
|
|
|
|
确定
|
|
|
|
|
|
</div>
|
2025-04-05 21:03:46 +08:00
|
|
|
|
<div class="dialog-btn" style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;" @click="cancel">
|
2025-03-14 23:48:59 +08:00
|
|
|
|
取消
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-04-05 21:03:46 +08:00
|
|
|
|
import Api from '@/apis/api';
|
|
|
|
|
|
|
2025-03-14 23:48:59 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'AddDeviceDialog',
|
|
|
|
|
|
props: {
|
2025-03-27 17:54:05 +08:00
|
|
|
|
visible: { type: Boolean, required: true },
|
|
|
|
|
|
agentId: { type: String, required: true }
|
2025-03-14 23:48:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
data() {
|
2025-03-27 17:54:05 +08:00
|
|
|
|
return {
|
|
|
|
|
|
deviceCode: "",
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
}
|
2025-03-14 23:48:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
confirm() {
|
2025-03-27 17:54:05 +08:00
|
|
|
|
if (!/^\d{6}$/.test(this.deviceCode)) {
|
|
|
|
|
|
this.$message.error('请输入6位数字验证码');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.loading = true;
|
2025-04-05 21:03:46 +08:00
|
|
|
|
Api.device.bindDevice(
|
|
|
|
|
|
this.agentId,
|
|
|
|
|
|
this.deviceCode, ({ data }) => {
|
2025-03-27 17:54:05 +08:00
|
|
|
|
this.loading = false;
|
2025-04-05 21:03:46 +08:00
|
|
|
|
if (data.code === 0) {
|
|
|
|
|
|
this.$emit('refresh');
|
|
|
|
|
|
this.$message.success({
|
|
|
|
|
|
message: '设备绑定成功',
|
|
|
|
|
|
showClose: true
|
|
|
|
|
|
});
|
|
|
|
|
|
this.closeDialog();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error({
|
|
|
|
|
|
message: data.msg || '绑定失败',
|
|
|
|
|
|
showClose: true
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
2025-03-27 17:54:05 +08:00
|
|
|
|
},
|
|
|
|
|
|
closeDialog() {
|
|
|
|
|
|
this.$emit('update:visible', false);
|
|
|
|
|
|
this.deviceCode = '';
|
|
|
|
|
|
|
2025-03-14 23:48:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
cancel() {
|
|
|
|
|
|
this.$emit('update:visible', false)
|
|
|
|
|
|
this.deviceCode = ""
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.input-46 {
|
|
|
|
|
|
border: 1px solid #e4e6ef;
|
|
|
|
|
|
background: #f6f8fb;
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.dialog-btn {
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
border-radius: 23px;
|
|
|
|
|
|
background: #5778ff;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
height: 40px;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
font-weight: 500;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
font-size: 12px;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
color: #fff;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
line-height: 40px;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
2025-03-18 21:49:57 +08:00
|
|
|
|
|
|
|
|
|
|
::v-deep .el-dialog {
|
|
|
|
|
|
border-radius: 15px;
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
}
|
2025-04-05 21:03:46 +08:00
|
|
|
|
|
2025-03-18 21:49:57 +08:00
|
|
|
|
::v-deep .el-dialog__headerbtn {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
2025-04-05 21:03:46 +08:00
|
|
|
|
|
2025-03-18 21:49:57 +08:00
|
|
|
|
::v-deep .el-dialog__body {
|
|
|
|
|
|
padding: 4px 6px;
|
|
|
|
|
|
}
|
2025-04-05 21:03:46 +08:00
|
|
|
|
|
|
|
|
|
|
::v-deep .el-dialog__header {
|
2025-03-18 21:49:57 +08:00
|
|
|
|
padding: 10px;
|
|
|
|
|
|
}
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</style>
|