api.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import {
  2. add,
  3. update,
  4. send
  5. } from '@/api/base'
  6. import {
  7. AlarmStrategy,
  8. AlarmStrategies
  9. } from '@/constant'
  10. const AlarmLevel = {
  11. 0: '提示性预警',
  12. 1: '中级预警',
  13. 2: '紧急预警'
  14. }
  15. export function getInformStrategy (tenant) {
  16. return send({
  17. url: '/tenant/informStrategy',
  18. method: 'GET',
  19. params: { tenant }
  20. }).then(({ data: { strategy } }) => Object.keys(strategy).sort().map(key => {
  21. return {
  22. level: key,
  23. name: AlarmLevel[key],
  24. options: getStrategyOptions(strategy[key])
  25. }
  26. }))
  27. }
  28. function getStrategyOptions (strategy) {
  29. return AlarmStrategies.map(key => {
  30. return {
  31. key,
  32. label: AlarmStrategy[key],
  33. value: strategy[key]
  34. }
  35. })
  36. }
  37. export function updateInformStrategy (tenant, strategy) {
  38. return update({
  39. url: '/tenant/informStrategy',
  40. method: 'POST',
  41. data: {
  42. tenant,
  43. strategy
  44. }
  45. })
  46. }
  47. export function getTenantServiceConfig (tenant, type) {
  48. return send({
  49. url: '/device/deviceAudit/tenant/serviceConfig',
  50. method: 'GET',
  51. params: { tenant, type }
  52. })
  53. }
  54. export function addTenantServiceConfig (data) {
  55. return add({
  56. url: '/device/deviceAudit/tenant/serviceConfig',
  57. method: 'POST',
  58. data
  59. })
  60. }
  61. export function updateTenantServiceConfig (data) {
  62. return update({
  63. url: '/device/deviceAudit/tenant/serviceConfig',
  64. method: 'PUT',
  65. data
  66. })
  67. }