index.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { defHttp } from '/@/utils/http/axios';
  2. import { AesEncryption } from '/@/utils/cipher';
  3. import { loginCipher } from '/@/settings/encryptionSetting';
  4. import { useVentStore } from '/@/store/modules/vent';
  5. enum Api {
  6. DEVICE_CONTROL = '/safety/ventanalyMonitorData/devicecontrol', // 开关控制
  7. SPRAY_CONTROL = '/ventanaly-device/safety/ventanalyMonitorData/batchDevicecontrol', // 皮带三级防灭火批量控制
  8. modalNameList = '/ventanaly-device/safety/modelAlarmInfo/getAllModelFileJson',
  9. }
  10. // Get personal center-basic settings
  11. export const deviceControlApi = (data) => {
  12. // 加密password
  13. const encryption = new AesEncryption({ key: loginCipher.key, iv: loginCipher.iv });
  14. data.password = encryption.encryptByAES(data.password);
  15. return defHttp.put({ url: Api.DEVICE_CONTROL, data });
  16. };
  17. // 皮带三级防灭火批量控制
  18. export const sprayControlApi = (data) => {
  19. const encryption = new AesEncryption({ key: loginCipher.key, iv: loginCipher.iv });
  20. // 判断传入是数组还是单个对象
  21. if (Array.isArray(data)) {
  22. // 批量:遍历每一条加密password
  23. const encryptList = data.map((item) => {
  24. return {
  25. ...item,
  26. password: encryption.encryptByAES(item.password),
  27. };
  28. });
  29. return defHttp.put({ url: Api.SPRAY_CONTROL, data: encryptList });
  30. } else {
  31. data.password = encryption.encryptByAES(data.password);
  32. return defHttp.put({ url: Api.SPRAY_CONTROL, data });
  33. }
  34. };
  35. export const getModalType = async () => {
  36. const res = await defHttp.get({ url: Api.modalNameList });
  37. // 处理文件名称
  38. debugger;
  39. };