A8000
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.

269 lines
6.0 KiB

8 months ago
7 months ago
1 month ago
7 months ago
3 weeks ago
7 months ago
1 month ago
7 months ago
1 month ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
1 month ago
7 months ago
1 month ago
7 months ago
8 months ago
8 months ago
7 months ago
8 months ago
3 weeks ago
7 months ago
7 months ago
7 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
1 month ago
1 month ago
7 months ago
  1. <template>
  2. <div v-if="!lisVisible" class="lis-setting">
  3. <div class="setting-item">
  4. <span class="label">类型</span>
  5. <div class="options">
  6. {{ LISTypeMap[lisSettings && lisSettings.lisType || ''] }}
  7. </div>
  8. </div>
  9. <div class="setting-item">
  10. <span class="label">自动上报</span>
  11. <div class="options">
  12. {{ lisSettings?.lisAutoExport ? '开启' : '关闭' }}
  13. </div>
  14. </div>
  15. <div class="setting-item">
  16. <span class="label">协议</span>
  17. <div class="options">
  18. Boditech
  19. </div>
  20. </div>
  21. <div class="setting-item">
  22. <span class="label">接口</span>
  23. <div class="options">
  24. {{ LISInterfaceMap[lisSettings && lisSettings.lisIf || ''] }}
  25. </div>
  26. </div>
  27. <div
  28. v-if="lisSettings && lisSettings.lisIf === 'NETWORK'"
  29. class="setting-item"
  30. >
  31. <span class="label">Host's IP</span>
  32. <div class="options">
  33. {{ lisSettings.lisNetIp }}
  34. </div>
  35. </div>
  36. <div
  37. v-if="lisSettings && lisSettings.lisIf === 'NETWORK'"
  38. class="setting-item"
  39. >
  40. <span class="label">Host's Port</span>
  41. <div class="options">
  42. {{ lisSettings.LISNetPortStr }}
  43. </div>
  44. </div>
  45. <div
  46. v-if="lisSettings && lisSettings.lisIf === 'SERIAL'"
  47. class="setting-item"
  48. >
  49. <span class="label">传输速度</span>
  50. <div class="options">
  51. {{ LISSerialBaudrateMap[lisSettings && lisSettings.lisSerialBaudrate || '']}}
  52. </div>
  53. </div>
  54. <div class="lis-btn">
  55. <button class="edit-lis" @click="onEditList" >
  56. 编辑LIS
  57. </button>
  58. </div>
  59. </div>
  60. <EditLis v-else @save-success="saveSuccess" @close="onCloseDialog"/>
  61. <!-- 键盘 -->
  62. <transition name="slide-up">
  63. <div class="keyboard" v-if="keyboardVisible">
  64. <SoftKeyboard
  65. ref="softKeyboardRef"
  66. v-model="inputValue"
  67. :is-visible="keyboardVisible"
  68. :keyboard-type="keyboardType"
  69. @update-keyboard-visible="(visible) => keyboardVisible = visible"
  70. @confirm="()=>{}"
  71. @close="keyboardVisible = false"
  72. />
  73. </div>
  74. </transition>
  75. </template>
  76. <script setup lang="ts">
  77. import {
  78. getLISSetting,
  79. LISInterfaceMap,
  80. LISSerialBaudrateMap,
  81. LISSettings,
  82. LISTypeMap,
  83. } from '@/services'
  84. import { onMounted, onUnmounted, ref, watch } from 'vue'
  85. import SoftKeyboard from '@/components/SoftKeyboard.vue'
  86. import EditLis from '@/pages/Index/Settings/EditLis.vue'
  87. const inputValue = ref('')
  88. const keyboardType = ref<'text' | 'number'>('number')
  89. const softKeyboardRef = ref()
  90. const lisVisible = ref(false)
  91. const lisSettings = ref<(LISSettings & { LISNetPortStr: string, lisAutoExport: boolean }) | undefined>(
  92. undefined,
  93. )
  94. const getLisSetting = async () => {
  95. const res = await getLISSetting()
  96. if (res && res.success) {
  97. lisSettings.value = {
  98. ...res.data,
  99. LISNetPortStr: res.data.lisNetPort.toString(),
  100. }
  101. }
  102. }
  103. onMounted(() => {
  104. console.log()
  105. getLisSetting()
  106. })
  107. // 键盘相关状态
  108. const keyboardVisible = ref(false)
  109. const currentInputValue = ref('')
  110. const currentInputField = ref<'ip' | 'port' | ''>('')
  111. // 处理键盘输入
  112. const handleKeyboardInput = (value: string) => {
  113. if (!inputValue.value) return
  114. // 更新当前输入值
  115. inputValue.value = value
  116. // 更新对应字段的值
  117. if (currentInputField.value === 'ip') {
  118. lisSettings.value!.lisNetIp = value
  119. } else {
  120. lisSettings.value!.LISNetPortStr = value
  121. }
  122. }
  123. watch(inputValue, (newVal: string) => {
  124. if(newVal){
  125. handleKeyboardInput(newVal)
  126. }
  127. })
  128. // 隐藏键盘
  129. const hideKeyboard = () => {
  130. keyboardVisible.value = false
  131. currentInputField.value = ''
  132. currentInputValue.value = ''
  133. }
  134. const onEditList = () => {
  135. lisVisible.value = true
  136. }
  137. const saveSuccess = () => {
  138. onCloseDialog()
  139. getLisSetting()
  140. }
  141. const onCloseDialog = () => {
  142. lisVisible.value = false
  143. }
  144. // 在组件卸载时清理状态
  145. onUnmounted(() => {
  146. hideKeyboard()
  147. })
  148. </script>
  149. <style lang="less" scoped>
  150. .lis-setting {
  151. background-color: #f5f7fa;
  152. width: 100%;
  153. height: 87vh;
  154. box-sizing: border-box;
  155. padding: 20px;
  156. display: flex;
  157. flex-direction: column;
  158. gap: 20px;
  159. .setting-item {
  160. background-color: #fff;
  161. border-radius: 12px;
  162. padding: 24px 32px;
  163. display: flex;
  164. align-items: center;
  165. justify-content: space-between;
  166. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
  167. transition: all 0.3s ease;
  168. height: 4rem;
  169. .label {
  170. font-size: 28px;
  171. font-weight: 500;
  172. color: #303133;
  173. }
  174. input {
  175. padding: 8px;
  176. border: 1px solid #ccc;
  177. font-size: 30px;
  178. transition: box-shadow 0.2s ease;
  179. border-radius: 10px;
  180. }
  181. .options {
  182. display: flex;
  183. gap: 12px;
  184. flex-wrap: wrap;
  185. font-size: 1.75rem;
  186. button {
  187. min-width: 120px;
  188. height: 56px;
  189. padding: 0 24px;
  190. border: 1px solid #dcdfe6;
  191. background-color: #fff;
  192. border-radius: 8px;
  193. font-size: 24px;
  194. color: #606266;
  195. cursor: pointer;
  196. transition: all 0.3s ease;
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. &.active {
  201. color: #fff;
  202. background-color: #409eff;
  203. border-color: #409eff;
  204. box-shadow: 0 2px 8px rgba(64, 158, 255, 0.3);
  205. }
  206. }
  207. }
  208. }
  209. }
  210. .edit-lis{
  211. width: 100vw;
  212. height: 5rem;
  213. padding: 0 24px;
  214. border: 1px solid #dcdfe6;
  215. border-radius: 8px;
  216. font-size: 24px;
  217. cursor: pointer;
  218. transition: all 0.3s ease;
  219. color: #fff;
  220. background-color: #409eff;
  221. }
  222. .lis-btn{
  223. width: 100%;
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. }
  228. .keyboard {
  229. position: fixed;
  230. bottom: 0;
  231. left: 0;
  232. width: 100%;
  233. height: 300px;
  234. background-color: #f5f7fa;
  235. border-top-left-radius: 16px;
  236. border-top-right-radius: 16px;
  237. box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
  238. z-index: 1000;
  239. }
  240. // 键盘动画
  241. .slide-up-enter-active,
  242. .slide-up-leave-active {
  243. transition: transform 0.3s ease;
  244. }
  245. .slide-up-enter-from,
  246. .slide-up-leave-to {
  247. transform: translateY(100%);
  248. }
  249. </style>