This commit is contained in:
白菜
2025-12-12 17:38:26 +08:00
parent 9b14d96e24
commit dd4fa36597
13 changed files with 851 additions and 679 deletions

View File

@ -1,6 +1,7 @@
<template>
<el-button :size="size" :type="type" :circle='circle' @click="switchStatus"
icon="el-icon-refresh-left">
<el-button :size="size" :type="type" :round="round" @click="switchStatus"
>
{{ label }}
</el-button>
</template>
@ -8,6 +9,7 @@
</style>
<script>
import {updateDeviceStatus} from "@/api/ems/site";
export default {
props: {
@ -16,26 +18,21 @@ export default {
default: 'mini',
required: false
},
round: {
type: Boolean,
default: false,
required: false
},
type: {
type: String,
default: 'primary',
required: false
},
// plain: {
// type: Boolean,
// default: true,
// required: false
// },
circle: {
type: Boolean,
default: true,
required: false
},
data: {
type: Object,
default: () => {
return {
runningStatus: null,
deviceStatus: null,
deviceId: null,
deviceName: null,
}
@ -45,12 +42,13 @@ export default {
},
computed: {
label() {
return this.data.runningStatus === '4' ? '开机' : '关机'
return this.data.deviceStatus === '4' ? '开机' : '关机'
}
},
methods: {
switchStatus() {
const {runningStatus, deviceId, deviceName} = this.data
console.log(this.data, 11111111)
const {deviceStatus, deviceId, deviceName, siteId} = this.data
this.$confirm(`确认要${this.label}设备${deviceName || ''}吗?`, {
confirmButtonText: "确定",
cancelButtonText: "取消",
@ -61,17 +59,17 @@ export default {
if (action === "confirm") {
instance.confirmButtonLoading = true;
//做开关机操作,更新成功后刷新表格
setTimeout(() => {
instance.confirmButtonLoading = false; //todo delete
done()
}, 2000)
// deleteProtectPlan(row.id)
// .then((response) => {
// response.code === 200 && done();
// })
// .finally(() => {
// instance.confirmButtonLoading = false;
// });
updateDeviceStatus({
siteId,
deviceStatus,
deviceId
})
.then((response) => {
response.code === 200 && done();
})
.finally(() => {
instance.confirmButtonLoading = false;
});
} else {
done();
}