| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- import request, { tenantRequest } from '@/utils/request'
- import {
- add,
- update,
- del,
- addTenant,
- messageSend
- } from './base'
- export function getMeshes (query) {
- const { pageNum: pageIndex, pageSize, ...params } = query
- return tenantRequest({
- url: '/device/mesh/pageQuery',
- method: 'GET',
- params: addTenant({
- pageIndex, pageSize,
- ...params
- })
- })
- }
- export function addMesh (data) {
- return add({
- url: '/device/mesh',
- method: 'POST',
- data: addTenant(data)
- }, tenantRequest)
- }
- export function deleteMesh ({ meshId, name }) {
- return del({
- url: '/device/mesh',
- method: 'DELETE',
- params: { meshId }
- }, name)
- }
- export function updateMesh (data) {
- return update({
- url: '/device/mesh',
- method: 'PUT',
- data
- })
- }
- export function getMesh (meshId) {
- return request({
- url: '/device/mesh/getMeshStructure',
- method: 'GET',
- params: { meshId }
- })
- }
- export function addNodeToMesh (meshId, node) {
- return add({
- url: '/device/mesh/node',
- method: 'POST',
- data: {
- meshId,
- ...node
- }
- })
- }
- export function updateNode (node) {
- return update({
- url: '/device/mesh/node',
- method: 'PUT',
- data: node
- })
- }
- export function deleteNode ({ id }) {
- return messageSend({
- url: '/device/mesh/node',
- method: 'DELETE',
- params: { nodeId: id }
- }, '删除')
- }
- export function addNodeAfterNode (targetNode, node, port = -1) {
- return add({
- url: '/device/bind/insertAfter',
- method: 'POST',
- data: {
- id: targetNode.id,
- port,
- node: {
- meshId: targetNode.meshId,
- ...node
- }
- }
- })
- }
- export function addNodeBeforeNode (targetNode, node, port = -1) {
- return add({
- url: '/device/bind/insertAhead',
- method: 'POST',
- data: {
- id: targetNode.id,
- port,
- node: {
- meshId: targetNode.meshId,
- ...node
- }
- }
- })
- }
- export function insertNodeToEdge (edge, node, port = -1) {
- return add({
- url: '/device/bind/insertBetween',
- method: 'POST',
- data: {
- id: edge.nodeBondId,
- port,
- node: {
- meshId: edge.meshId,
- ...node
- }
- }
- })
- }
- export function addEdgeToMesh (meshId, sourceNode, targetNode, port = -1) {
- return messageSend({
- url: '/device/bind/nodeBond',
- method: 'POST',
- data: {
- meshId,
- preNodeId: sourceNode.id,
- preNodeType: sourceNode.nodeType,
- nextNodeId: targetNode.id,
- nextNodeType: targetNode.nodeType,
- port
- }
- }, '连接')
- }
- export function deleteEdge ({ nodeBondId }) {
- return messageSend({
- url: `/device/bind/nodeBond?bondId=${nodeBondId}`,
- method: 'DELETE'
- }, '删除连接')
- }
- export function updateEdgePort ({ meshId, nodeBondId, preNodeId, preNodeType, nextNodeId, nextNodeType }, port) {
- const edge = {
- meshId,
- nodeBondId,
- preNodeId,
- preNodeType,
- nextNodeId,
- nextNodeType,
- port
- }
- return messageSend({
- url: '/device/bind/nodeBond',
- method: 'PUT',
- data: edge
- }, '更新端口').then(() => {
- return { data: edge }
- })
- }
- export function reverseEdge ({ meshId, nodeBondId, preNodeId, preNodeType, nextNodeId, nextNodeType, port }) {
- const edge = {
- meshId,
- nodeBondId,
- preNodeId: nextNodeId,
- preNodeType: nextNodeType,
- nextNodeId: preNodeId,
- nextNodeType: preNodeType,
- port
- }
- return messageSend({
- url: '/device/bind/nodeBond',
- method: 'PUT',
- data: edge
- }, '反转').then(() => {
- return { data: edge }
- })
- }
- export function bindInstanceToNode ({ meshId, id, nodeType }, instance) {
- return messageSend({
- url: '/device/mesh/nodeAndInstance',
- method: 'POST',
- data: {
- meshId, id, nodeType,
- instanceId: instance.id
- }
- }, '绑定')
- }
- export function releaseInstanceFormNode ({ id }) {
- return messageSend({
- url: `/device/bind/nodeAndInstance?nodeId=${id}`,
- method: 'DELETE'
- }, '解绑')
- }
- export function getMeshByBox (deviceId) {
- return request({
- url: '/device/mesh/getStructureByDeviceId',
- method: 'GET',
- params: { deviceId }
- })
- }
- export function getMeshByInstance (instanceId) {
- return request({
- url: '/device/mesh/getMeshByInstanceId',
- method: 'GET',
- params: { instanceId }
- })
- }
- export function getThirdPartyDevicesByThirdPartyDevice (instanceId, typeList, options) {
- return request({
- url: '/device/bind/listAssignedNode',
- method: 'POST',
- data: {
- instanceId,
- typeList
- },
- ...options
- })
- }
- export function getFollowThirdPartyDevicesByThirdPartyDevice (instanceId, typeList, options) {
- return request({
- url: '/device/bind/listAssignedBindNode',
- method: 'POST',
- data: {
- instanceId,
- typeList
- },
- ...options
- })
- }
|