index.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import { request } from '../../utils/axios';
  2. // 隔离点 VO 类型
  3. export interface SegregationPointVO {
  4. id?: number; // 详情接口返回的 id 字段
  5. pointId?: number;
  6. pointCode: string;
  7. pointName: string;
  8. pointIcon?: string;
  9. pointPicture?: string;
  10. pointNfc: string | null; // pointNfc 可能为 null
  11. workstationId: number;
  12. lotoId: number | null; // lotoId 可能为 null
  13. powerType?: string;
  14. pointSerialNumber?: string | null; // pointSerialNumber 可能为 null
  15. remark?: string;
  16. createTime?: Date;
  17. // 扩展字段(用于显示)
  18. workstationName?: string;
  19. lotoName?: string;
  20. machineryId?: number;
  21. machineryName?: string;
  22. switchStatus?: number | string | null;
  23. }
  24. // 分页参数类型
  25. export interface PageParam {
  26. current?: number;
  27. size?: number;
  28. pageNo?: number; // 兼容旧参数
  29. pageSize?: number; // 兼容旧参数
  30. pointCode?: string;
  31. pointName?: string;
  32. workstationId?: number;
  33. lotoId?: number;
  34. machineryId?: number;
  35. powerType?: string;
  36. [key: string]: any;
  37. }
  38. // 分页响应类型
  39. export interface PageResponse<T> {
  40. list: T[];
  41. total: number;
  42. records?: T[]; // 兼容其他响应格式
  43. data?: {
  44. list: T[];
  45. total: number;
  46. };
  47. }
  48. // 隔离点管理 API
  49. export const segregationPointApi = {
  50. // 查询隔离点列表(分页)
  51. getIsIsolationPointPage: async (params?: PageParam): Promise<PageResponse<SegregationPointVO>> => {
  52. const response = await request.get({
  53. url: '/iscs/isolation-point/getIsolationPointPage',
  54. params: {
  55. pageNo: params?.pageNo || params?.current || 1,
  56. pageSize: params?.pageSize || params?.size || 10,
  57. ...params,
  58. }
  59. });
  60. // 处理响应数据格式
  61. if (response && typeof response === 'object') {
  62. if ('data' in response && response.data) {
  63. return response.data;
  64. } else if ('list' in response || 'records' in response) {
  65. return {
  66. list: response.list || response.records || [],
  67. total: response.total || 0,
  68. };
  69. }
  70. }
  71. return response;
  72. },
  73. // 查询隔离点详情
  74. selectIsIsolationPointById: async (id: number): Promise<SegregationPointVO> => {
  75. const response = await request.get({
  76. url: '/iscs/isolation-point/selectIsolationPointById',
  77. params: { id }
  78. });
  79. return response?.data || response;
  80. },
  81. // 新增隔离点
  82. addinsertIsIsolationPoint: async (data: SegregationPointVO): Promise<void> => {
  83. return await request.post({
  84. url: '/iscs/isolation-point/insertIsolationPoint',
  85. data
  86. });
  87. },
  88. // 修改隔离点
  89. updateIsIsolationPoint: async (data: SegregationPointVO): Promise<void> => {
  90. return await request.put({
  91. url: '/iscs/isolation-point/updateIsolationPoint',
  92. data
  93. });
  94. },
  95. // 删除隔离点
  96. deleteIsIsolationPointByPointIds: async (pointIds: number | number[]): Promise<void> => {
  97. const ids = Array.isArray(pointIds) ? pointIds.join(',') : pointIds;
  98. return await request.delete({
  99. url: '/iscs/isolation-point/deleteIsolationPointList',
  100. params: { ids },
  101. });
  102. },
  103. // 查询车间列表
  104. getWorkshopList: async () => {
  105. return await request.get({ url: '/mes/md/workshop/listAll' });
  106. },
  107. // 查询工作区域列表
  108. getWorkareaList: async (workshopId: number) => {
  109. return await request.get({
  110. url: '/iscs/workarea/getIsWorkareaList',
  111. params: { workshopId },
  112. });
  113. },
  114. };