scene.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. import { http } from '@/utils/http/axios';
  2. /** 场景标签信息 */
  3. export type SceneLabelOrModuleItem = {
  4. /** 标签id */
  5. id: number;
  6. /** 标签代码 */
  7. code: string;
  8. /** 创建时间 */
  9. createdAt: string;
  10. /** 0-未删除,大于0-已删除 */
  11. isDeleted: number;
  12. /** 标签名称 */
  13. name: string;
  14. /** 说明 */
  15. remark: string;
  16. /** 状态: 0-正常,1-不正常 */
  17. status: number;
  18. /** 更新时间 */
  19. updatedAt: string;
  20. };
  21. /** 工位信息 */
  22. export type WorkSpaceInfoItem = {
  23. /** 工位id */
  24. id: number;
  25. /** 所属工厂id */
  26. workshopId: number;
  27. /** 工位名称 */
  28. name: string;
  29. /** 工位code */
  30. code: string;
  31. /** 工位描述 */
  32. remark: string;
  33. /** 状态: 0-启用, 1-禁用 */
  34. status: number;
  35. /** 创建时间 */
  36. createdAt: string;
  37. /** 更新时间 */
  38. updatedAt: string;
  39. /** 0-未删除,大于0-已删除 */
  40. isDeleted: number;
  41. /** 工位负责人 */
  42. principal: string;
  43. /** 排序序号 */
  44. serial: number;
  45. };
  46. /** 工厂信息 */
  47. export type WorkShopInfoItem = {
  48. /** 工厂id */
  49. id: number;
  50. /** 所属公司id */
  51. companyId: number;
  52. /** 1-生产安全 2-安全环保 */
  53. type: number;
  54. /** 工厂名称 */
  55. name: string;
  56. /** 工厂code */
  57. code: string;
  58. /** 工厂描述 */
  59. remark: string;
  60. /** 状态: 0-启用, 1-禁用 */
  61. status: number;
  62. /** 创建时间 */
  63. createdAt: string;
  64. /** 更新时间 */
  65. updatedAt: string;
  66. /** 0-未删除,大于0-已删除 */
  67. isDeleted: number;
  68. /** 下属工位列表 */
  69. children: WorkSpaceInfoItem[];
  70. /** 场景标签 */
  71. labelName: string;
  72. /** 场景标签id */
  73. sceneLabelId: number;
  74. /** 排序序号 */
  75. serial: number;
  76. /** 车间模板 */
  77. workshopModule: SceneLabelOrModuleItem;
  78. };
  79. /** 公司信息 */
  80. export type CompanyInfoItem = {
  81. /** 公司id */
  82. id: number;
  83. /** 上级公司ID, 无上级为0 */
  84. parentId: number;
  85. /** 公司名称 */
  86. name: string;
  87. /** 公司code */
  88. code: string;
  89. /** 公司描述 */
  90. remark: string;
  91. /** 状态: 0-启用, 1-禁用 */
  92. status: number;
  93. /** 创建时间 */
  94. createdAt: string;
  95. /** 更新时间 */
  96. updatedAt: string;
  97. /** 排序序号 */
  98. serial: number;
  99. /** 0-未删除,大于0-已删除 */
  100. isDeleted: number;
  101. /** 下属工厂列表 */
  102. children: WorkShopInfoItem[];
  103. /** 场景标签列表 */
  104. labelList: SceneLabelOrModuleItem[];
  105. /** 场景模板列表 */
  106. moduleList: SceneLabelOrModuleItem[];
  107. };
  108. /** 获取公司-工厂-工位数据 */
  109. export const getShopSpaceList = () => {
  110. return http.request<CompanyInfoItem[]>({
  111. url: '/scene/getList',
  112. method: 'get',
  113. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  114. });
  115. };
  116. interface LayoutResp {
  117. /** 创建时间 */
  118. createdAt: string;
  119. /** 自增主键 */
  120. id: number;
  121. /** 页面布局json */
  122. layout: string;
  123. /** 目标id: 对应公司ID/车间ID */
  124. targetId: number;
  125. viewType: ViewType;
  126. }
  127. /** 查询地图布局 */
  128. export const getLayoutApi = (param: { workshopId: string; viewType: ViewType }) => {
  129. return http.request<LayoutResp[]>(
  130. {
  131. url: `/api/layout/getWorkshopLayout?viewType=${param.viewType}&workshopId=${param.workshopId}`,
  132. method: 'get',
  133. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  134. },
  135. {
  136. urlPrefix: 'temp',
  137. },
  138. );
  139. };
  140. /** 查询车间小地图布局 */
  141. export const getWorkshopMiniMapLayoutApi = (workshopId: string) => {
  142. return getLayoutApi({ viewType: ViewType.minMap, workshopId }).then((res) => res[0]);
  143. };
  144. enum ViewType {
  145. safety = 1,
  146. minMap = 2,
  147. }
  148. interface UpdateViewLayoutParam {
  149. layout: string;
  150. targetId: string;
  151. viewType: ViewType;
  152. }
  153. /** 更新-新增小地图页面布局 */
  154. export const updateLayoutApi = (data: UpdateViewLayoutParam) => {
  155. return http.request<LayoutResp[]>(
  156. {
  157. url: `/api/layout/updateViewLayout`,
  158. method: 'post',
  159. data: new URLSearchParams(data as any).toString(),
  160. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  161. },
  162. {
  163. urlPrefix: 'temp',
  164. },
  165. );
  166. };
  167. /** 更新-新增小地图页面布局 */
  168. export const updateMinMapViewLayoutApi = (
  169. param: Pick<UpdateViewLayoutParam, 'layout' | 'targetId'>,
  170. ) => {
  171. return updateLayoutApi({ viewType: ViewType.minMap, ...param });
  172. };
  173. export type CameraItem = {
  174. /** 相机名称 */
  175. name: string;
  176. /** 相机code */
  177. code: string;
  178. /** 相机IP地址 */
  179. cameraIp: string;
  180. /** 相机描述 */
  181. remark: string;
  182. /** 状态: 0-启用, 1-禁用 */
  183. status: number;
  184. };
  185. export type WorkSpaceCameraRelative = WorkSpaceInfoItem & { cameraList: CameraItem[] };
  186. export const getCamerasByWorkSpace = (params: { workshopId: number }) => {
  187. return http.request<WorkSpaceCameraRelative[]>({
  188. url: '/api/workshop/getWorkspaceCameraList',
  189. method: 'get',
  190. params,
  191. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  192. });
  193. };