消毒机设备
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.8 KiB

  1. <script lang="ts" setup>
  2. import { syncSendCmd } from 'apis/system'
  3. import { FtMessageBox } from 'libs/messageBox'
  4. import { useDeviceStore } from 'stores/deviceStore'
  5. import { useSealStore } from 'stores/sealStore'
  6. import { computed, onMounted, ref } from 'vue'
  7. import { useHomeStore } from '@/stores/homeStore'
  8. const selected = ref<string[]>([])
  9. // 级联数据:[{ label, value, children: [{ label, value }] }]
  10. const cascaderOptions = ref<{ label: string, value: string, children: { label: string, value: string }[] }[]>([])
  11. const homeStore = useHomeStore()
  12. const deviceStore = useDeviceStore()
  13. // 拉取配置并构建 cascaderOptions
  14. const getPressureConfig = async () => {
  15. if (__DEVICE_TYPE__ !== useDeviceStore().deviceTypeMap.LargeSpaceDM_B) {
  16. const res = await syncSendCmd({ className: 'PipelinePressureControl', fnName: 'getConfig' })
  17. if (res.ackcode === 0) {
  18. homeStore.updatePressureConfig(res.rely)
  19. const { typeDisplayNames, types, intensitys } = res.rely
  20. cascaderOptions.value = typeDisplayNames.map((name: string, idx: number) => {
  21. const children = (intensitys[types[idx]] || []).map((val: string) => ({ label: `${val}%`, value: val }))
  22. return { label: name, value: types[idx], children }
  23. })
  24. // 初始化当前状态
  25. const stateRes = await syncSendCmd({ className: 'PipelinePressureControl', fnName: 'getState' })
  26. if (stateRes.ackcode === 0) {
  27. const { type, intensity } = stateRes.rely
  28. selected.value = intensity ? [type, intensity] : [type]
  29. }
  30. }
  31. }
  32. }
  33. onMounted(getPressureConfig)
  34. const deviceType = computed(() => {
  35. return __DEVICE_TYPE__
  36. })
  37. const sealStore = useSealStore()
  38. const sealInfo = computed(() => sealStore.sealInfo)
  39. // 用户选择后立即更新压力配置(支持仅选择类型的情况)
  40. const confirm = async (val: string[]) => {
  41. // 判断设备当前的状态
  42. if (sealInfo.value.workState === 'stopping' || sealInfo.value.workState === 'idle') {
  43. if (!val || !val.length)
  44. return
  45. await homeStore.updatePressure(val)
  46. }
  47. else {
  48. FtMessageBox.error('密封性测试中,禁止修改正负压')
  49. }
  50. }
  51. </script>
  52. <template>
  53. <div v-if="deviceType === deviceStore.deviceTypeMap.PipeDM" class="pressure-wrapper">
  54. <el-cascader
  55. v-model="selected"
  56. :options="cascaderOptions"
  57. placeholder="请选择"
  58. class="pressure-cascader"
  59. input-props="{ style: 'text-align: center;' }"
  60. popper-class="pressure-cascader-popper"
  61. @change="confirm"
  62. />
  63. </div>
  64. </template>
  65. <style scoped>
  66. .pressure-wrapper {
  67. display: flex;
  68. justify-content: center;
  69. padding: 0.5rem 0;
  70. }
  71. .pressure-cascader {
  72. width: 100%;
  73. max-width: 7.5rem;
  74. }
  75. </style>
  76. <!-- 全局样式作用于弹出面板 -->
  77. <style>
  78. .pressure-cascader-popper .el-cascader-menu__item {
  79. text-align: center;
  80. }
  81. </style>