Browse Source

fix:正负压调整不再弹窗

master
白凤吉 2 weeks ago
parent
commit
f88e91ab58
  1. 55
      src/components/home/HomeSetting.vue
  2. 81
      src/components/home/PressureControl.vue
  3. 2
      src/views/home/index.vue

55
src/components/home/HomeSetting.vue

@ -157,46 +157,6 @@ const setRealtimeConfig = async (key: string, val: string) => {
}
/**
* @function 打开压力控制模态框
* @desc 初始化压力类型和强度选项
*/
const onSetPressure = () => {
const pressureVal = pressureConfig.value
const { typeDisplayNames, types, intensitys } = pressureVal || {}
//
const leftOptions: System.Option[]
= typeDisplayNames?.map((name: string, index: number) => ({
label: name,
value: types[index],
})) || []
//
const rightOptions: System.Option[] = []
if (types?.includes('positivePressure')) {
intensitys?.positivePressure?.forEach((intensity: string) => {
rightOptions.push({ label: `${intensity}%`, value: intensity })
})
}
optionsLeft.value = leftOptions
optionsRight.value = rightOptions
//
syncSendCmd({
className: 'PipelinePressureControl',
fnName: 'getState',
}).then((res) => {
if (res.ackcode === 0) {
defaultIntensityValue.value = res.rely.intensity
homeStore.updateDefaultIntensityValue(res.rely.intensity)
homeStore.updateDefaultIntensityTypeValue(res.rely.type)
isModalOpen.value = true
}
})
}
/**
* @function 确认压力选择
* @param {string|number[]} value - 选中的压力配置值[类型, 强度]
* @desc 关闭模态框并更新压力配置
@ -228,26 +188,11 @@ const settingWidth = computed(() => {
}
return '7.5rem'
})
const deviceType = computed(() => {
return __DEVICE_TYPE__
})
</script>
<template>
<div class="home-start-opt">
<div class="home-opt-flex">
<div v-if="deviceType === deviceStore.deviceTypeMap.PipeDM">
<BtButton
button-text="压力控制"
text-size="1.3rem"
border-radius="5px"
width="7.5rem"
text-color="#1989fa"
height="3rem"
@click="onSetPressure"
/>
</div>
<div class="home-opt-ml">
<BtButton
button-text="查看图表"

81
src/components/home/PressureControl.vue

@ -0,0 +1,81 @@
<script lang="ts" setup>
import { syncSendCmd } from 'apis/system'
import { useDeviceStore } from 'stores/deviceStore'
import { computed, onMounted, ref } from 'vue'
import { useHomeStore } from '@/stores/homeStore'
const selected = ref<string[]>([])
// [{ label, value, children: [{ label, value }] }]
const cascaderOptions = ref<{ label: string, value: string, children: { label: string, value: string }[] }[]>([])
const homeStore = useHomeStore()
const deviceStore = useDeviceStore()
// cascaderOptions
const getPressureConfig = async () => {
const res = await syncSendCmd({ className: 'PipelinePressureControl', fnName: 'getConfig' })
if (res.ackcode === 0) {
homeStore.updatePressureConfig(res.rely)
const { typeDisplayNames, types, intensitys } = res.rely
cascaderOptions.value = typeDisplayNames.map((name: string, idx: number) => {
const children = (intensitys[types[idx]] || []).map((val: string) => ({ label: `${val}%`, value: val }))
return { label: name, value: types[idx], children }
})
//
const stateRes = await syncSendCmd({ className: 'PipelinePressureControl', fnName: 'getState' })
if (stateRes.ackcode === 0) {
const { type, intensity } = stateRes.rely
selected.value = intensity ? [type, intensity] : [type]
}
}
}
onMounted(getPressureConfig)
const deviceType = computed(() => {
return __DEVICE_TYPE__
})
//
const confirm = (val: string[]) => {
if (!val || !val.length)
return
homeStore.updatePressure(val)
}
</script>
<template>
<div v-if="deviceType === deviceStore.deviceTypeMap.PipeDM" class="pressure-wrapper">
<el-cascader
v-model="selected"
:options="cascaderOptions"
placeholder="请选择压力类型和强度"
class="pressure-cascader"
input-props="{ style: 'text-align: center;' }"
popper-class="pressure-cascader-popper"
@change="confirm"
/>
</div>
</template>
<style scoped>
.pressure-wrapper {
display: flex;
justify-content: center;
padding: 0.5rem 0;
}
.pressure-cascader {
width: 100%;
max-width: 7.5rem;
}
</style>
<!-- 全局样式作用于弹出面板 -->
<style>
.pressure-cascader-popper .el-cascader-menu__item {
text-align: center;
}
</style>

2
src/views/home/index.vue

@ -4,6 +4,7 @@ import HomeFormula from 'components/home/HomeFormula.vue'
import HomeLogLevel from 'components/home/HomeLogLevel.vue'
import HomeOperation from 'components/home/HomeOperation.vue'
import HomeSetting from 'components/home/HomeSetting.vue'
import PressureControl from 'components/home/PressureControl.vue'
import { useDeviceStore } from 'stores/deviceStore'
import { useHomeStore } from 'stores/homeStore'
import { useLiquidStore } from 'stores/liquidStore'
@ -132,6 +133,7 @@ const deviceType = computed(() => {
</div>
<!-- 消毒设置 -->
<div class="bottom">
<PressureControl />
<HomeSetting />
</div>
</div>

Loading…
Cancel
Save