pcs开关机,设备列表上传、下载
This commit is contained in:
96
src/views/ems/site/sblb/PcsSwitch.vue
Normal file
96
src/views/ems/site/sblb/PcsSwitch.vue
Normal file
@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<el-button :size="size" :type="type" :circle='circle' @click="switchStatus"
|
||||
icon="el-icon-refresh-left">
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
<script>
|
||||
|
||||
export default {
|
||||
props: {
|
||||
size: {
|
||||
type: String,
|
||||
default: 'mini',
|
||||
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,
|
||||
deviceId: null,
|
||||
deviceName: null,
|
||||
}
|
||||
},
|
||||
required: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
label() {
|
||||
return this.data.runningStatus === '4' ? '开机' : '关机'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
switchStatus() {
|
||||
const {runningStatus, deviceId, deviceName} = this.data
|
||||
this.$confirm(`确认要${this.label}设备${deviceName || ''}吗?`, {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
showClose: false,
|
||||
closeOnClickModal: false,
|
||||
type: "warning",
|
||||
beforeClose: (action, instance, done) => {
|
||||
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;
|
||||
// });
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
//只有在废弃成功的情况下会走到这里
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: `${deviceName}${this.label}成功!`,
|
||||
});
|
||||
this.$emit('updateSuccess')
|
||||
//调用接口 更新表格数据
|
||||
})
|
||||
.catch(() => {
|
||||
//取消关机
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user