SelectDeviceType.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <script setup lang="ts">
  2. import { onMounted } from 'vue';
  3. import { t } from '@/i18n';
  4. import type { SetupProtocolForm, UseGuideStepItemExpose, UseGuideStepItemProps } from '@/types';
  5. const props = defineProps<UseGuideStepItemProps<SetupProtocolForm>>();
  6. const deviceTypes = ['离心空压机', '冷水主机'];
  7. const currentStep = props.steps[props.stepIndex];
  8. onMounted(() => {
  9. currentStep.title = t('setupProtocol.selectDeviceType');
  10. props.form.deviceType = undefined;
  11. Object.assign(props.form.protocolInfo, {
  12. id: undefined,
  13. protocolName: '',
  14. protocolType: undefined,
  15. deviceType: undefined,
  16. dataBit: 5,
  17. parityBit: 'N',
  18. stopBit: '1',
  19. baudRate: undefined,
  20. dataSendInterval: undefined,
  21. highFreqSendInterval: undefined,
  22. readTimeout: undefined,
  23. nextDataReadDelay: undefined,
  24. nextRoundDataReadDelay: undefined,
  25. readContinuousAddr: undefined,
  26. readContinuousAddrCode: undefined,
  27. readContinuousAddrLength: undefined,
  28. byteOrder: undefined,
  29. byteOrderCode: undefined,
  30. addrOrder: undefined,
  31. addrOrderCode: undefined,
  32. });
  33. });
  34. const finish = () => {
  35. const { protocolType, deviceType, protocolInfo } = props.form;
  36. currentStep.title = deviceType as string;
  37. protocolInfo.protocolType = protocolType;
  38. protocolInfo.deviceType = deviceType;
  39. };
  40. defineExpose<UseGuideStepItemExpose>({
  41. finish,
  42. });
  43. </script>
  44. <template>
  45. <div>
  46. <div class="use-guide-title">{{ $t('setupProtocol.selectDeviceType') }}</div>
  47. <div class="use-guide-description">{{ $t('setupProtocol.selectDeviceTypeTip') }}</div>
  48. <AFormItem :label="$t('setupProtocol.deviceType')" name="deviceType">
  49. <ASelect v-model:value="form.deviceType" class="device-select" :placeholder="$t('common.plzSelect')">
  50. <ASelectOption v-for="item in deviceTypes" :key="item" :value="item">
  51. {{ item }}
  52. </ASelectOption>
  53. </ASelect>
  54. </AFormItem>
  55. </div>
  56. </template>
  57. <style lang="scss" scoped>
  58. .device-select {
  59. width: 224px;
  60. }
  61. </style>