|
@@ -1,13 +1,17 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { onMounted } from 'vue';
|
|
|
|
|
|
+import { onMounted, ref } from 'vue';
|
|
|
|
|
|
|
|
+import { useRequest } from '@/hooks/request';
|
|
import { t } from '@/i18n';
|
|
import { t } from '@/i18n';
|
|
|
|
+import { groupList } from '@/api';
|
|
|
|
|
|
-import type { SetupProtocolForm, UseGuideStepItemExpose, UseGuideStepItemProps } from '@/types';
|
|
|
|
|
|
+import type { DefaultOptionType, SelectValue } from 'ant-design-vue/es/select';
|
|
|
|
+import type { EquipmentTypeItem, SetupProtocolForm, UseGuideStepItemExpose, UseGuideStepItemProps } from '@/types';
|
|
|
|
|
|
const props = defineProps<UseGuideStepItemProps<SetupProtocolForm>>();
|
|
const props = defineProps<UseGuideStepItemProps<SetupProtocolForm>>();
|
|
|
|
|
|
-const deviceTypes = ['离心空压机', '冷水主机'];
|
|
|
|
|
|
+const { handleRequest } = useRequest();
|
|
|
|
+const deviceTypes = ref<EquipmentTypeItem[]>([]);
|
|
const currentStep = props.steps[props.stepIndex];
|
|
const currentStep = props.steps[props.stepIndex];
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
@@ -19,6 +23,7 @@ onMounted(() => {
|
|
protocolName: '',
|
|
protocolName: '',
|
|
protocolType: undefined,
|
|
protocolType: undefined,
|
|
deviceType: undefined,
|
|
deviceType: undefined,
|
|
|
|
+ deviceTypeId: undefined,
|
|
dataBit: 5,
|
|
dataBit: 5,
|
|
parityBit: 'N',
|
|
parityBit: 'N',
|
|
stopBit: '1',
|
|
stopBit: '1',
|
|
@@ -36,13 +41,26 @@ onMounted(() => {
|
|
addrOrder: undefined,
|
|
addrOrder: undefined,
|
|
addrOrderCode: undefined,
|
|
addrOrderCode: undefined,
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ handleRequest(async () => {
|
|
|
|
+ deviceTypes.value = await groupList({
|
|
|
|
+ dataType: 1,
|
|
|
|
+ });
|
|
|
|
+ });
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+let deviceTypeId: number;
|
|
|
|
+
|
|
|
|
+const handleDeviceTypeChange = (_value: SelectValue, option: DefaultOptionType) => {
|
|
|
|
+ deviceTypeId = option.key;
|
|
|
|
+};
|
|
|
|
+
|
|
const finish = () => {
|
|
const finish = () => {
|
|
const { protocolType, deviceType, protocolInfo } = props.form;
|
|
const { protocolType, deviceType, protocolInfo } = props.form;
|
|
currentStep.title = deviceType as string;
|
|
currentStep.title = deviceType as string;
|
|
protocolInfo.protocolType = protocolType;
|
|
protocolInfo.protocolType = protocolType;
|
|
protocolInfo.deviceType = deviceType;
|
|
protocolInfo.deviceType = deviceType;
|
|
|
|
+ protocolInfo.deviceTypeId = deviceTypeId;
|
|
};
|
|
};
|
|
|
|
|
|
defineExpose<UseGuideStepItemExpose>({
|
|
defineExpose<UseGuideStepItemExpose>({
|
|
@@ -53,9 +71,14 @@ defineExpose<UseGuideStepItemExpose>({
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
<AFormItem :label="$t('setupProtocol.deviceType')" name="deviceType">
|
|
<AFormItem :label="$t('setupProtocol.deviceType')" name="deviceType">
|
|
- <ASelect v-model:value="form.deviceType" class="device-select" :placeholder="$t('common.plzSelect')">
|
|
|
|
- <ASelectOption v-for="item in deviceTypes" :key="item" :value="item">
|
|
|
|
- {{ item }}
|
|
|
|
|
|
+ <ASelect
|
|
|
|
+ v-model:value="form.deviceType"
|
|
|
|
+ class="device-select"
|
|
|
|
+ :placeholder="$t('common.plzSelect')"
|
|
|
|
+ @change="handleDeviceTypeChange"
|
|
|
|
+ >
|
|
|
|
+ <ASelectOption v-for="item in deviceTypes" :key="item.id" :value="item.dataName">
|
|
|
|
+ {{ item.dataName }}
|
|
</ASelectOption>
|
|
</ASelectOption>
|
|
</ASelect>
|
|
</ASelect>
|
|
</AFormItem>
|
|
</AFormItem>
|