Ver Fonte

chore(api): 更新接口

wangcong há 3 meses atrás
pai
commit
26163e0bdb
2 ficheiros alterados com 117 adições e 3 exclusões
  1. 59 3
      src/api/index.ts
  2. 58 0
      src/types/index.ts

+ 59 - 3
src/api/index.ts

@@ -2,7 +2,13 @@ import qs from 'qs';
 
 import { request } from '@/utils';
 
-import type { DictTypeData, DictTypeDataParams } from '@/types';
+import type {
+  DictTypeData,
+  DictTypeDataParams,
+  ProtocolBaseInfo,
+  ProtocolParamData,
+  ProtocolParamSearchParams,
+} from '@/types';
 
 /**
  * 获取认证授权服务 url
@@ -77,6 +83,17 @@ export const addGateway = async () => {
   await request(apiBiz('/gateway/add'));
 };
 
+// 协议参数
+
+export const getProtocolParamList = async (params: ProtocolParamSearchParams) => {
+  const data = await request<ProtocolParamData>(apiBiz('/protocolParamInfo/getPageList'), {
+    method: 'POST',
+    body: JSON.stringify(params),
+  });
+
+  return data;
+};
+
 // 协议基本信息
 
 export const addProtocolBaseInfo = async () => {
@@ -94,8 +111,47 @@ export const uploadUserProtocol = async (protocolType: string, file: Blob) => {
   const formData = new FormData();
   formData.append('file', file);
 
-  await request(`/protocolBaseInfo/uploadUserTemplate/?protocolType=${protocolType}`, {
+  const data = await request<Pick<ProtocolBaseInfo, 'id' | 'protocolName' | 'protocolType'>>(
+    apiBiz('/protocolBaseInfo/uploadUserTemplate/', { protocolType }),
+    {
+      method: 'POST',
+      body: formData,
+    },
+  );
+
+  return data;
+};
+
+export const downloadUserProtocol = async (protocolType: string, protocolName: string) => {
+  const blob = await request<Blob>(
+    apiBiz('/protocolBaseInfo/downloadUserProtocol/', {
+      protocolType,
+      protocolName,
+    }),
+  );
+
+  return blob;
+};
+
+export const getUploadProtocol = async (protocolType: string, protocolName: string) => {
+  const data = await request<ProtocolBaseInfo>(
+    apiBiz('/protocolBaseInfo/findUploadProtocolBaseInfo/', {
+      protocolType,
+      protocolName,
+    }),
+  );
+
+  return data;
+};
+
+export const getProtocolBaseInfo = async (id: number) => {
+  const data = await request<ProtocolBaseInfo>(apiBiz(`/protocolBaseInfo/info/${id}`));
+  return data;
+};
+
+export const updateProtocolBaseInfo = async (params: ProtocolBaseInfo) => {
+  await request(apiBiz('/protocolBaseInfo/update'), {
     method: 'POST',
-    body: formData,
+    body: JSON.stringify(params),
   });
 };

+ 58 - 0
src/types/index.ts

@@ -19,11 +19,22 @@ export interface PageData<T> {
   pageNum: number;
 }
 
+export interface PageParams {
+  pageIndex: number;
+  pageSize: number;
+  pageSorts?: {
+    column: string;
+    asc: boolean;
+  }[];
+}
+
 export interface OptionItem<T> {
   value: T;
   label: string;
 }
 
+export type CheckedType = boolean | string | number;
+
 export type FormRules<T> = {
   [K in keyof T]?: Rule[];
 } & {
@@ -60,6 +71,7 @@ export interface UseGuideStepItem extends StepProps {
   contentOffset?: number;
   formLayout?: 'horizontal' | 'vertical' | 'inline';
   isLastStep?: boolean;
+  exportButtonShow?: boolean;
   nextStepButtonText?: string;
   nextStepButtonDisabled?: boolean;
 }
@@ -71,6 +83,7 @@ export interface UseGuideStepItemProps<T> {
 }
 
 export type UseGuideStepItemExpose = {
+  exportData?: () => void | Promise<void>;
   finish?: () => void | Promise<void>;
 };
 
@@ -126,3 +139,48 @@ export interface ProtocolBaseInfo {
   addrOrder: string;
   addrOrderCode: string;
 }
+
+export type ProtocolParamData = PageData<ProtocolParamInfo>;
+
+export interface ProtocolParamInfo {
+  id: number;
+  createTime: string;
+  updateTime: string;
+  createUserId: number;
+  updateUserId: number;
+  baseInfoId: number;
+  platformParamCode: string;
+  platformParamName: string;
+  gatewayParamCode: string;
+  gatewayParamName: string;
+  paramCode: string;
+  paramName: string;
+  unit: string;
+  module: string;
+  readWriteType: string;
+  readWriteTypeCode: string;
+  readFuncCode: string;
+  writeFuncCode: string;
+  registerAddr: string;
+  addrNumber: string | null;
+  registerType: string | null;
+  registerTypeCode: string | null;
+  parsingType: string;
+  parsingTypeCode: string;
+  addrLength: number;
+  wordLength: number | null;
+  wordLengthCode: string | null;
+  quantity: number | null;
+  coefficient: number;
+  isHighFreqParam: string;
+  isHighFreqParamCode: string;
+  readCalcFormula: string;
+  writeCalcFormula: string;
+  decimalPlace: number | null;
+}
+
+export interface ProtocolParamSearchParams extends PageParams {
+  baseInfoId: number;
+  paramCode?: string;
+  paramName?: string;
+}