|
@@ -3,7 +3,7 @@ import { onMounted, ref } from 'vue';
|
|
|
|
|
|
import { useRequest } from '@/hooks/request';
|
|
|
import { t } from '@/i18n';
|
|
|
-import { groupList } from '@/api';
|
|
|
+import { addTempProtocol, deleteProtocolBaseInfo, groupList } from '@/api';
|
|
|
|
|
|
import type { DefaultOptionType, SelectValue } from 'ant-design-vue/es/select';
|
|
|
import type { EquipmentTypeItem, SetupProtocolForm, UseGuideStepItemExpose, UseGuideStepItemProps } from '@/types';
|
|
@@ -14,7 +14,8 @@ const { handleRequest } = useRequest();
|
|
|
const deviceTypes = ref<EquipmentTypeItem[]>([]);
|
|
|
const currentStep = props.steps[props.stepIndex];
|
|
|
|
|
|
-onMounted(() => {
|
|
|
+onMounted(async () => {
|
|
|
+ const { id } = props.form.protocolInfo;
|
|
|
currentStep.title = t('setupProtocol.selectDeviceType');
|
|
|
props.form.deviceType = undefined;
|
|
|
|
|
@@ -42,6 +43,15 @@ onMounted(() => {
|
|
|
addrOrderCode: undefined,
|
|
|
});
|
|
|
|
|
|
+ // 协议 id 存在时删除草稿协议
|
|
|
+ try {
|
|
|
+ if (id) {
|
|
|
+ await deleteProtocolBaseInfo(id);
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+
|
|
|
handleRequest(async () => {
|
|
|
deviceTypes.value = await groupList({
|
|
|
dataType: 1,
|
|
@@ -55,12 +65,18 @@ const handleDeviceTypeChange = (_value: SelectValue, option: DefaultOptionType)
|
|
|
deviceTypeId = option.key;
|
|
|
};
|
|
|
|
|
|
-const finish = () => {
|
|
|
+const finish = async () => {
|
|
|
const { protocolType, deviceType, protocolInfo } = props.form;
|
|
|
currentStep.title = deviceType as string;
|
|
|
protocolInfo.protocolType = protocolType;
|
|
|
protocolInfo.deviceType = deviceType;
|
|
|
protocolInfo.deviceTypeId = deviceTypeId;
|
|
|
+
|
|
|
+ protocolInfo.id = await addTempProtocol({
|
|
|
+ protocolType,
|
|
|
+ deviceType,
|
|
|
+ deviceTypeId,
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
defineExpose<UseGuideStepItemExpose>({
|