| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- import request from '@/utils/request'
- import {
- add,
- update,
- del,
- confirm,
- messageSend,
- send,
- confirmAndSend
- } from './base'
- export function getRatios () {
- return request({
- url: '/device/resolutionRatio',
- method: 'GET'
- }).then(({ data }) => {
- return {
- data: Object.keys(data).map(key => {
- return {
- value: key,
- label: key,
- devices: data[key].map(device => device.name).join(', ')
- }
- })
- }
- })
- }
- export function addDevice (data) {
- return add({
- url: '/device',
- method: 'POST',
- data
- })
- }
- export function updateDevice (data) {
- return update({
- url: '/device',
- method: 'put',
- data
- })
- }
- export function deleteDevice ({ id, name }) {
- return send({
- url: `/device/${id}/standbyDevice`,
- method: 'GET',
- params: { pageNum: 1, pageSize: 1 }
- }).then(({ data }) => {
- return confirm(data.length
- ? `删除主设备 ${name} 后备份设备也将删除,确定删除?`
- : `确定删除 ${name}?`
- ).then(() => messageSend({
- url: `/device/${id}`,
- method: 'DELETE'
- }, '删除'))
- })
- }
- export function getDevices (query) {
- const { pageNum: pageIndex, pageSize, ...params } = query
- return request({
- url: '/device/list',
- method: 'GET',
- params: {
- pageIndex, pageSize,
- ...params
- }
- })
- }
- export function activateDevice ({ id, name }) {
- return confirmAndSend('激活', name, {
- url: '/device/batch/activate',
- method: 'put',
- data: [id]
- })
- }
- export function deactivateDevice ({ id, name }) {
- return confirmAndSend('停用', name, {
- url: '/device/batch/deactivate',
- method: 'put',
- data: [id]
- })
- }
- export function getDevice (id) {
- return request({
- url: `/device/${id}`,
- method: 'GET'
- })
- }
- export function getSubDevices (query) {
- const { id, pageNum: pageIndex, pageSize, ...params } = query
- return request({
- url: `/device/${id}/standbyDevice`,
- method: 'GET',
- params: {
- pageIndex, pageSize,
- ...params
- }
- })
- }
- export function addSubDevice ({ id }, data) {
- return add({
- url: `/device/${id}/addStandby`,
- method: 'POST',
- data
- })
- }
- export function addProductType (data) {
- return add({
- url: '/productType',
- method: 'POST',
- data
- })
- }
- export function updateProductType (data) {
- return update({
- url: '/productType',
- method: 'put',
- data
- })
- }
- export function deleteProductType ({ id, name }) {
- return del({
- url: `/productType/${id}`,
- method: 'DELETE'
- }, name)
- }
- export function getProductTypes (query) {
- const { pageNum: pageIndex, pageSize, ...params } = query
- return request({
- url: '/productType/list',
- method: 'GET',
- params: {
- pageIndex, pageSize,
- ...params
- }
- })
- }
- export function addProduct (data) {
- return add({
- url: '/product',
- method: 'POST',
- data
- })
- }
- export function updateProduct (data) {
- return update({
- url: '/product',
- method: 'put',
- data
- })
- }
- export function deleteProduct ({ id, name }) {
- return del({
- url: `/product/${id}`,
- method: 'DELETE'
- }, name)
- }
- export function getProducts (query) {
- const { pageNum: pageIndex, pageSize, ...params } = query
- return request({
- url: '/product/list',
- method: 'GET',
- params: {
- pageIndex, pageSize,
- ...params
- }
- })
- }
- export function addDeviceGroup (data) {
- return add({
- url: '/deviceGroup',
- method: 'POST',
- data
- })
- }
- export function updateDeviceGroup (data) {
- return update({
- url: '/deviceGroup',
- method: 'put',
- data
- })
- }
- export function deleteDeviceGroup ({ id, name }) {
- return del({
- url: `/deviceGroup/${id}`,
- method: 'DELETE'
- }, name)
- }
- export function getDeviceGroups (query) {
- const { pageNum: pageIndex, pageSize, ...params } = query
- return request({
- url: '/deviceGroup/list',
- method: 'GET',
- params: {
- pageIndex, pageSize,
- ...params
- }
- })
- }
- export function getDevicesByGroup (id) {
- return request({
- url: `/deviceGroup/${id}/device`,
- method: 'GET'
- })
- }
- export function getDeviceTree () {
- return request({
- url: '/deviceGroup/deviceTree',
- method: 'GET'
- })
- }
- export function addDeviceToGroup (id, deviceId) {
- return add({
- url: `/deviceGroup/${id}/device`,
- method: 'POST',
- data: [].concat(deviceId)
- })
- }
- export function deleteDeviceFromGroup (id, { id: deviceId, name }) {
- return confirmAndSend('移除', name, {
- url: `/deviceGroup/${id}/device`,
- method: 'DELETE',
- params: { deviceId }
- })
- }
- export function getDeviceStatistics (productId) {
- return request({
- url: '/device/listDeviceTotal',
- method: 'GET',
- params: { productId }
- })
- }
- export function getDeviceAlarms (query) {
- const { pageNum: pageIndex, pageSize, ...params } = query
- return request({
- url: '/deviceException/list',
- method: 'GET',
- params: {
- pageIndex, pageSize,
- ...params
- }
- })
- }
|