新型管道消毒机前端代码
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.

228 lines
7.3 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="air_switch_config_container">
  3. <div class="header">
  4. <svg
  5. xmlns="http://www.w3.org/2000/svg"
  6. xmlns:xlink="http://www.w3.org/1999/xlink"
  7. fill="none"
  8. version="1.1"
  9. width="28"
  10. height="28"
  11. viewBox="0 0 28 28"
  12. >
  13. <g>
  14. <path
  15. d="M14,0C6.26801,0,0,6.26802,0,14C0,21.732,6.26801,28,14,28C21.732,28,28,21.732,28,14C28,6.26802,21.732,0,14,0ZM9.10859,20.4807C9.097,21.0081,8.66847,21.431,8.14073,21.4356C7.6131,21.4405,7.17713,21.0253,7.15599,20.4979L7.15599,14.4761C7.15421,13.9358,7.59264,13.4974,8.1329,13.4992C8.39231,13.4979,8.64147,13.6004,8.8248,13.784C9.00814,13.9674,9.11035,14.2167,9.10859,14.4761L9.10859,20.4807ZM9.11277,16.4831L10.5775,16.4831L10.5775,13.9308C10.5771,12.598,11.3513,11.3866,12.5608,10.827C12.5414,10.7319,12.5318,10.635,12.5322,10.5379L12.5322,9.02199L8.39528,9.02199C8.06546,9.02229,7.74915,8.89097,7.51653,8.65716C7.2839,8.42333,7.15414,8.10636,7.15602,7.77653C7.15499,7.44753,7.2848,7.13161,7.51685,6.89839C7.74891,6.66514,8.06422,6.53379,8.39324,6.53331L19.6047,6.53331C19.935,6.53331,20.2516,6.66514,20.4843,6.89948C20.717,7.13381,20.8465,7.45138,20.844,7.78166C20.8444,8.46656,20.2895,9.02198,19.6047,9.02198L15.4668,9.02198L15.4668,10.5421C15.467,10.639,15.4581,10.7358,15.4401,10.831C16.6497,11.3886,17.4242,12.5989,17.4235,13.9308L17.4235,16.4831L18.8842,16.4831L18.8842,14.4761C18.8842,13.9363,19.3218,13.4987,19.8614,13.4987C20.4013,13.4987,20.8389,13.9363,20.8389,14.4761L20.8389,20.4847C20.8414,21.0244,20.4058,21.4641,19.8661,21.4667C19.3263,21.4691,18.8867,21.0336,18.8842,20.4939L18.8842,18.9728L18.8893,18.9728L18.8893,16.4831L18.8842,16.4831L18.8842,18.9697L17.2923,18.9697C16.8744,20.4411,15.5307,21.4564,14.001,21.4564C12.4714,21.4564,11.1276,20.441,10.7096,18.9697L9.11274,18.9697"
  16. fill="#FFFFFF"
  17. fill-opacity="1"
  18. />
  19. </g>
  20. </svg>
  21. <p class="title">选择空气阀配置</p>
  22. </div>
  23. <div class="opers_box">
  24. <div class="left_container">
  25. <div
  26. :class="activeTab == '1' ? 'tab mb active' : 'tab mb'"
  27. @click="changeTab('1')"
  28. >
  29. <p class="text">上管道</p>
  30. <div class="percent">{{ topText }}</div>
  31. <img :src="activeTab == 1 ? A2 : A1" class="icon" alt="" />
  32. </div>
  33. <div
  34. :class="activeTab == '2' ? 'tab active' : 'tab'"
  35. @click="changeTab('2')"
  36. >
  37. <p class="text">下管道</p>
  38. <div class="percent">{{ bottomText }}</div>
  39. <img :src="activeTab == 2 ? A2 : A1" class="icon" alt="" />
  40. </div>
  41. </div>
  42. <div class="right_container">
  43. <van-picker
  44. v-if="activeTab == 1"
  45. :columns="columns"
  46. :show-toolbar="false"
  47. visible-option-num="3"
  48. option-height="42"
  49. v-model="selectedValuesTop"
  50. @change="topChange"
  51. />
  52. <van-picker
  53. v-if="activeTab == 2"
  54. :columns="columns"
  55. :show-toolbar="false"
  56. visible-option-num="3"
  57. option-height="42"
  58. @change="bottomChange"
  59. v-model="selectedValuesBottom"
  60. />
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <script setup>
  66. import A1 from '@/assets/img/air/1.png'
  67. import A2 from '@/assets/img/air/2.png'
  68. import { useSealStore, useWebSocketStore } from '@/store'
  69. import {
  70. AirInletProportionalValve_setStateJSON,
  71. AirOutletProportionalValve_setStateJSON,
  72. airInletProportionalValve_getStateJSON,
  73. AirOutletProportionalValve_getStateJSON,
  74. } from '@/mock/command'
  75. import { ref, onMounted, watch } from 'vue'
  76. const activeTab = ref('1')
  77. const sealStore = useSealStore()
  78. const webSocketStore = useWebSocketStore()
  79. const changeTab = tab => {
  80. activeTab.value = tab
  81. }
  82. const topText = ref('0%')
  83. const bottomText = ref('0%')
  84. const topChange = ({ selectedOptions, selectedValues }) => {
  85. topText.value = selectedOptions[0].text
  86. webSocketStore.sendCommandMsg(
  87. AirInletProportionalValve_setStateJSON([parseInt(selectedValues[0])]),
  88. )
  89. sealStore.updateAirInletProportionalValue(parseInt(selectedValues[0]))
  90. }
  91. const bottomChange = ({ selectedOptions, selectedValues }) => {
  92. bottomText.value = selectedOptions[0].text
  93. webSocketStore.sendCommandMsg(
  94. AirOutletProportionalValve_setStateJSON([parseInt(selectedValues[0])]),
  95. )
  96. sealStore.updateAirOutletProportionalValue(parseInt(selectedValues[0]))
  97. }
  98. const columns = ref([
  99. { text: '0%', value: '0' },
  100. { text: '10%', value: '10' },
  101. { text: '20%', value: '20' },
  102. { text: '30%', value: '30' },
  103. { text: '40%', value: '40' },
  104. { text: '50%', value: '50' },
  105. { text: '60%', value: '60' },
  106. { text: '70%', value: '70' },
  107. { text: '80%', value: '80' },
  108. { text: '90%', value: '90' },
  109. { text: '100%', value: '100' },
  110. ])
  111. const selectedValuesTop = ref(['0'])
  112. const selectedValuesBottom = ref(['0'])
  113. onMounted(() => {
  114. setTimeout(() => {
  115. webSocketStore.sendCommandMsg(airInletProportionalValve_getStateJSON)
  116. webSocketStore.sendCommandMsg(AirOutletProportionalValve_getStateJSON)
  117. }, 1000)
  118. })
  119. watch(
  120. () => sealStore.airInletProportionalInitVal,
  121. (newVal, oldVal) => {
  122. console.log('airInletProportionalInitVal', newVal)
  123. selectedValuesTop.value = [newVal + '']
  124. topText.value = `${newVal}%`
  125. },
  126. )
  127. watch(
  128. () => sealStore.airOutletProportionalInitVal,
  129. (newVal, oldVal) => {
  130. console.log('airOutletProportionalInitVal', newVal)
  131. selectedValuesBottom.value = [newVal + '']
  132. bottomText.value = `${newVal}%`
  133. },
  134. )
  135. </script>
  136. <style lang="scss" scoped>
  137. .air_switch_config_container {
  138. box-sizing: border-box;
  139. .header {
  140. display: flex;
  141. align-items: center;
  142. margin-bottom: 12px;
  143. .title {
  144. margin-left: 8px;
  145. font-family: 思源黑体;
  146. font-size: 24px;
  147. font-weight: 500;
  148. line-height: normal;
  149. letter-spacing: 0.06em;
  150. color: #ffffff;
  151. }
  152. }
  153. .opers_box {
  154. display: flex;
  155. align-items: center;
  156. height: 151px;
  157. justify-content: space-between;
  158. .left_container {
  159. width: 337px;
  160. height: 151px;
  161. .tab {
  162. width: 337px;
  163. height: 68px;
  164. border-radius: 6px;
  165. background: #1f6397;
  166. box-sizing: border-box;
  167. padding-left: 25px;
  168. padding-right: 22px;
  169. display: flex;
  170. align-items: center;
  171. justify-content: space-between;
  172. .text {
  173. font-family: 思源黑体;
  174. font-size: 16px;
  175. font-weight: normal;
  176. line-height: normal;
  177. letter-spacing: 0.06em;
  178. color: #ffffff;
  179. }
  180. .percent {
  181. width: 69px;
  182. height: 36px;
  183. border-radius: 8px;
  184. display: flex;
  185. align-items: center;
  186. justify-content: center;
  187. font-family: Source Han Sans;
  188. font-size: 20px;
  189. font-weight: bold;
  190. line-height: normal;
  191. letter-spacing: 0.06em;
  192. font-feature-settings: 'kern' on;
  193. color: #ffffff;
  194. }
  195. .icon {
  196. width: 22px;
  197. height: 22px;
  198. }
  199. }
  200. .active {
  201. .percent {
  202. background: #06518b;
  203. }
  204. }
  205. .mb {
  206. margin-bottom: 15px;
  207. }
  208. }
  209. .right_container {
  210. width: 339px;
  211. height: 146px;
  212. border-radius: 6px;
  213. box-sizing: border-box;
  214. background: #fff;
  215. overflow: hidden;
  216. }
  217. }
  218. }
  219. </style>