Files
emsfront/src/views/ems/dzjk/clpz/ClContainer.vue

120 lines
2.8 KiB
Vue
Raw Normal View History

2025-06-26 01:29:16 +08:00
<template>
<el-container class="clyx-container">
<el-header class="clyx-header">
2025-07-13 00:29:19 +08:00
<div class="clyx-title">策略状态<span class="clyx-status save">{{strategyStatusOptions[info.status]}}</span></div>
2025-06-26 01:29:16 +08:00
<div class="clyx-btns">
2025-07-13 00:29:19 +08:00
<el-button v-if="!hideSettingBtn" size="small" @click="$emit('showSetting')">配置</el-button>
<el-button v-if="info.status === '1'" type="warning" class="alarm-btn" size="small" @click='close'>停止策略</el-button>
2025-06-26 01:29:16 +08:00
</div>
</el-header>
<el-main class="clyx-main">
<slot name="default"></slot>
</el-main>
</el-container>
</template>
<script>
2025-07-13 00:29:19 +08:00
import {mapState} from "vuex";
import {stopStrategyRunning} from '@/api/ems/dzjk'
2025-06-26 01:29:16 +08:00
export default {
name:'DzjkClpzClContainer',
props:{
hideSettingBtn:{
type:Boolean,
default:false
2025-07-13 00:29:19 +08:00
},
info:{
type:Object,
default:()=>{return {}},
2025-06-26 01:29:16 +08:00
}
},
2025-07-13 00:29:19 +08:00
computed:{
...mapState({
strategyStatusOptions: state => state.ems.strategyStatusOptions,
})
},
2025-06-26 01:29:16 +08:00
data() {
return {
2025-07-13 00:29:19 +08:00
loading:true
2025-06-26 01:29:16 +08:00
}
},
methods:{
close(){
this.$confirm('确认要停止策略吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
showClose:false,
closeOnClickModal:false,
type: 'warning',
beforeClose: (action, instance, done) => {
if (action === 'confirm') {
instance.confirmButtonLoading = true;
2025-07-13 00:29:19 +08:00
this.loading = true
stopStrategyRunning(this.info.id).then(response => {
response.code === 200 && done();
}).finally(() => {
this.loading = false
2025-06-26 01:29:16 +08:00
instance.confirmButtonLoading = false;
2025-07-13 00:29:19 +08:00
})
2025-06-26 01:29:16 +08:00
} else {
done();
}
}
}).then(() => {
//只有在故障复位成功的情况下会走到这里
this.$message({
type: 'success',
message: '停止策略成功!'
});
2025-07-13 00:29:19 +08:00
this.$emit('update')
2025-06-26 01:29:16 +08:00
}).catch(() => {
//取消复位
});
}
},
mounted(){
}
}
</script>
<style scoped lang="scss">
.clyx-container{
border:1px solid #eee;
.clyx-header{
background: #F1F5FB;
display: flex;
position: relative;
justify-content: flex-start;
align-items: center;
padding: 0;
height: 60px;
border-radius: 6px 6px 0 0;
.clyx-title{
color: #333333;
line-height: 20px;
padding: 0 50px 0 25px;
.clyx-status{
font-weight: 500;
font-size: 16px;
&.danger{
color:#FC6B69;
}
&.save{
color:#09ADA3;
}
&.keep{
color:#3C81FF;
}
}
}
.clyx-btns{
position: absolute;
right: 25px;
top: 50%;
transform: translateY(-50%);
}
}
}
</style>