<script setup>
|
import { ref, computed, nextTick } from "vue";
|
import {
|
controllTestModel,
|
controllLLCBuckCurr,
|
controllLLCBuckVol,
|
controllVBusVref,
|
controllPowerOpen,
|
controllPowerClose,
|
} from "@/api/params";
|
import useElement from "@/hooks/useElement.js";
|
const { $alert, $loading, $message, $confirm } = useElement();
|
|
const emit = defineEmits(["setOk"]);
|
|
const props = defineProps({
|
info: {
|
type: Object,
|
// default: () => {
|
// return {};
|
// },
|
required: true,
|
},
|
});
|
const title = ref("设置测试模式");
|
const paramsVisible = ref(false);
|
const inputValue = ref();
|
const currentIdx = ref(0);
|
const input = ref();
|
|
const testModelab = computed(() => {
|
const obj = {
|
3: "逆变并网",
|
6: "PFC工作",
|
};
|
const lab = props.info.state?.testModelab || 0;
|
return obj[lab] || `未知 (${lab})`;
|
});
|
|
function edit(idx) {
|
currentIdx.value = idx;
|
switch (idx) {
|
case 0:
|
title.value = "设置测试模式";
|
inputValue.value = props.info.state.testModelab;
|
break;
|
case 1:
|
title.value = "设置VBus电压";
|
inputValue.value = props.info.state.vbusVerfVolSet;
|
break;
|
case 2:
|
title.value = "设置LLC Buck电压";
|
inputValue.value = props.info.state.llcBuckVolSet;
|
break;
|
case 3:
|
title.value = "设置LLC Buck电流";
|
inputValue.value = props.info.state.llcBuckCurrSet;
|
break;
|
default:
|
break;
|
}
|
paramsVisible.value = true;
|
|
if (idx) {
|
setTimeout(() => {
|
input.value.select();
|
}, 0);
|
}
|
}
|
function setParams() {
|
let setFn;
|
if (currentIdx.value !== 0 &&inputValue.value.trim() === '') {
|
$message.error("请输入参数");
|
return;
|
}
|
switch (currentIdx.value) {
|
case 0:
|
setFn = controllTestModel;
|
break;
|
case 1:
|
setFn = controllVBusVref;
|
break;
|
case 2:
|
setFn = controllLLCBuckVol;
|
break;
|
case 3:
|
setFn = controllLLCBuckCurr;
|
break;
|
default:
|
break;
|
}
|
|
let loading = $loading();
|
setFn(props.info.powerId, inputValue.value)
|
.then((res) => {
|
let { code, data } = res.data;
|
loading.close();
|
if (code && data) {
|
console.log(data);
|
$message.success("设置成功");
|
emit("setOk");
|
paramsVisible.value = false;
|
} else {
|
$message.error("设置失败");
|
}
|
})
|
.catch((err) => {
|
$message.error("设置失败");
|
loading.close();
|
console.log(err);
|
});
|
}
|
</script>
|
|
<template>
|
<div class="params">
|
<div class="item">
|
<div class="label">测试模式</div>
|
<div class="value">{{ testModelab }}</div>
|
<el-button size="small" type="primary" @click="edit(0)">修改</el-button>
|
</div>
|
<!-- <div class="item">
|
<div class="label">并网输出电流</div>
|
<div class="value">{{ info.state.gridIrefCurrSet }}</div>
|
<el-button size="small" type="primary" @click="edit">修改</el-button>
|
</div> -->
|
<!-- <div class="item">
|
<div class="label">VBus电压</div>
|
<div class="value">{{ info.state.vbusVerfVolSet }}</div>
|
<el-button size="small" type="primary" @click="edit(1)">修改</el-button>
|
</div> -->
|
<div class="item">
|
<div class="label">LLC Buck电压</div>
|
<div class="value">{{ info.state.llcBuckVolSet }}</div>
|
<el-button size="small" type="primary" @click="edit(2)">修改</el-button>
|
</div>
|
<div class="item">
|
<div class="label">LLC Buck电流</div>
|
<div class="value">{{ info.state.llcBuckCurrSet }}</div>
|
<el-button size="small" type="primary" @click="edit(3)">修改</el-button>
|
</div>
|
</div>
|
<!-- 弹窗 -->
|
<el-dialog
|
:title="title"
|
v-model="paramsVisible"
|
:close-on-click-modal="false"
|
class="dialog-center"
|
width="280px"
|
center
|
>
|
<el-select
|
v-model="inputValue"
|
v-if="currentIdx === 0"
|
placeholder="Select"
|
size="small"
|
>
|
<el-option :value="3" label="逆变并网"></el-option>
|
<el-option :value="6" label="PFC工作"></el-option>
|
</el-select>
|
<el-input
|
v-else
|
ref="input"
|
v-model="inputValue"
|
placeholder="Please input"
|
/>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="paramsVisible = false">取消</el-button>
|
<el-button type="primary" @click="setParams">确定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</template>
|
|
<style scoped lang="scss">
|
.params {
|
display: flex;
|
flex-direction: column;
|
.item {
|
display: flex;
|
align-items: center;
|
margin-bottom: 10px;
|
.label {
|
flex: 1;
|
margin-right: 10px;
|
text-align: right;
|
&::after {
|
content: ":";
|
}
|
}
|
.value {
|
width: 8em;
|
margin-right: 10px;
|
}
|
}
|
}
|
</style>
|