diff --git a/webs/ams-web/src/services/EnhancedRequestGet.ts b/webs/ams-web/src/services/EnhancedRequestGet.ts new file mode 100644 index 0000000..b7d9d98 --- /dev/null +++ b/webs/ams-web/src/services/EnhancedRequestGet.ts @@ -0,0 +1,14 @@ +import { request } from '@cmp/cmp-element' +import { getSelectPosition } from '@/views/usePostion' + +// 封装原始的 request.get 方法 +export default function enhancedRequestGet(url: string, config: any = {}) { + // 确保config.params对象存在 + if (!config.params) { + config.params = {} + } + // 添加positionKey到params对象 + config.params.positionKey = getSelectPosition() + // 调用原始的request.get方法 + return request.get(url, config) +} diff --git a/webs/ams-web/src/services/cmdb/module.js b/webs/ams-web/src/services/cmdb/module.js index fc23888..8850dcf 100644 --- a/webs/ams-web/src/services/cmdb/module.js +++ b/webs/ams-web/src/services/cmdb/module.js @@ -3,9 +3,9 @@ */ import { request } from '@cmp/cmp-element' import { wrapperParams } from 'utils' -import { getSelectPosition } from '@/views/usePostion' +import EnhancedRequestGet from '@/services/EnhancedRequestGet' export function getPropertiesByCode(code) { - return request.get('/ims/v1/properties', { + return EnhancedRequestGet('/ims/v1/properties', { params: wrapperParams({ code }), }) } @@ -13,11 +13,11 @@ export function getPropertiesByCode(code) { const baseUrl = '/ams/v1/module' export function getModules(params) { - return request.get(`${baseUrl}/collections`, { params }) + return EnhancedRequestGet(`${baseUrl}/collections`, { params }) } export function getModule() { - return request.get(baseUrl) + return EnhancedRequestGet(baseUrl) } // 新增模型 @@ -26,7 +26,7 @@ export function createModule(data) { } export function getModuleDetail(id) { - return request.get(`${baseUrl}/${id}`) + return EnhancedRequestGet(`${baseUrl}/${id}`) } // 新增分组 @@ -54,37 +54,37 @@ export function removeModuleGroup(id) { // 获取分组的树 export function getGroupTree() { - return request.get(`${baseUrl}/group`) + return EnhancedRequestGet(`${baseUrl}/group`) } export function getGroup() { - return request.get(`${baseUrl}/group/list`) + return EnhancedRequestGet(`${baseUrl}/group/list`) } // 模型分组采集结构查询 export function getModuleGroupCollections(params) { - return request.get(`${baseUrl}/group/collections`, { params }) + return EnhancedRequestGet(`${baseUrl}/group/collections`, { params }) } export function getModuleGroupRoot() { - return request.get(`${baseUrl}/group/roots`) + return EnhancedRequestGet(`${baseUrl}/group/roots`) } export function getModuleGroupChildren(groupId, params) { - return request.get(`${baseUrl}/group/${groupId}/children`, { params: { positionKey: getSelectPosition(), ...params } }) + return EnhancedRequestGet(`${baseUrl}/group/${groupId}/children`, { params }) } export function getRootGroups(groupId) { - return request.get(`${baseUrl}/group/root/${groupId}`) + return EnhancedRequestGet(`${baseUrl}/group/root/${groupId}`) } // 查询模型属性集合 export function getModulePropertyList(moduleId, params) { - return request.get(`/ams/v1/module/${moduleId}/list`, { params }) + return EnhancedRequestGet(`/ams/v1/module/${moduleId}/list`, { params }) } // 查询模型属性 export function getModuleProperties(id, params) { - return request.get(`/ams/v1/module/${id}/properties`, { params }) + return EnhancedRequestGet(`/ams/v1/module/${id}/properties`, { params }) } // 修改模型属性 @@ -94,13 +94,13 @@ export function updateModuleProperties(id, data) { // 关联类型分组查询所有 export function getRelationCategories() { - return request.get('/ams/v1/relation/category/all') + return EnhancedRequestGet('/ams/v1/relation/category/all') } const moduleRelationUrl = '/ams/v1/module/relation' // 获取模型关系详情 export function getModuleRelationDetail(id) { - return request.get(`${moduleRelationUrl}/${id}`) + return EnhancedRequestGet(`${moduleRelationUrl}/${id}`) } // 模型关系新增 export function createModuleRelation(data) { @@ -117,20 +117,20 @@ export function deleteModuleRelation(id) { // 获取模型拓扑 export function getModuleTopo(params) { - return request.get(`${moduleRelationUrl}/topo`, { params }) + return EnhancedRequestGet(`${moduleRelationUrl}/topo`, { params }) } // 根据拓扑,模型数据查询模型关系 export function getModuleRelation(params) { - return request.get(`${moduleRelationUrl}/relevancy`, { params }) + return EnhancedRequestGet(`${moduleRelationUrl}/relevancy`, { params }) } // 关联类型分组id查询模型集合 export function getModuleByRelationCategory(id) { - return request.get(`${moduleRelationUrl}/${id}/module`) + return EnhancedRequestGet(`${moduleRelationUrl}/${id}/module`) } // 关联类型分组id查询模型集合 export function getModuleInstance(params) { - return request.get(`${moduleRelationUrl}/instances`, { params }) + return EnhancedRequestGet(`${moduleRelationUrl}/instances`, { params }) } diff --git a/webs/ams-web/src/services/data-collection/plugins.ts b/webs/ams-web/src/services/data-collection/plugins.ts index dcbcd39..fc1b0b6 100644 --- a/webs/ams-web/src/services/data-collection/plugins.ts +++ b/webs/ams-web/src/services/data-collection/plugins.ts @@ -1,12 +1,13 @@ import { request } from '@cmp/cmp-element' +import EnhancedRequestGet from '@/services/EnhancedRequestGet' const baseUrl = '/ams/v1/collection/templates' export function getCollectionPlugins(params: Base.IListParams) { - return request.get(baseUrl, { params }) + return EnhancedRequestGet(baseUrl, { params }) } export function getCollectionPluginDetail(id: number) { - return request.get(`${baseUrl}/${id}`) + return EnhancedRequestGet(`${baseUrl}/${id}`) } export function createCollectionPlugin(params: any) { @@ -22,7 +23,7 @@ export function removeCollectionPlugin(id: number) { } export function getUser(params: any) { - return request.get('/sms/v1/users', { + return EnhancedRequestGet('/sms/v1/users', { params, }) } diff --git a/webs/ams-web/src/services/index.ts b/webs/ams-web/src/services/index.ts index 5d9d207..50025b2 100644 --- a/webs/ams-web/src/services/index.ts +++ b/webs/ams-web/src/services/index.ts @@ -30,3 +30,6 @@ export function getRuleByModuleId(moduleId: number, relationCategoryId: number) params: { relationCategoryId }, }) } +export function getSysconfQueryByCode(params) { + return request.get('/sms/v1/configs/queryByCode', { params }) +} diff --git a/webs/ams-web/src/services/pool.ts b/webs/ams-web/src/services/pool.ts index 612c11f..d1de240 100644 --- a/webs/ams-web/src/services/pool.ts +++ b/webs/ams-web/src/services/pool.ts @@ -1,11 +1,11 @@ import { request } from '@cmp/cmp-element' - +import EnhancedRequestGet from '@/services/EnhancedRequestGet' const baseUrl = '/ams/v1/property/pool' export function getPool(params: Base.IListParams) { - return request.get(baseUrl, { params }) + return EnhancedRequestGet(baseUrl, { params }) } export function getPoolDetail(id: number) { - return request.get(`${baseUrl}/${id}`) + return EnhancedRequestGet(`${baseUrl}/${id}`) } export function createPool(params: any) { return request.post(baseUrl, params) diff --git a/webs/ams-web/src/services/relation.ts b/webs/ams-web/src/services/relation.ts index 35cb274..e72e522 100644 --- a/webs/ams-web/src/services/relation.ts +++ b/webs/ams-web/src/services/relation.ts @@ -1,11 +1,11 @@ import { request } from '@cmp/cmp-element' - +import EnhancedRequestGet from '@/services/EnhancedRequestGet' const groupUrl = '/ams/v1/relation/category' export function getGroup() { - return request.get(groupUrl, { params: { simple: true } }) + return EnhancedRequestGet(groupUrl, { params: { simple: true } }) } export function getGroupDetail(id: number) { - return request.get(`${groupUrl}/${id}`) + return EnhancedRequestGet(`${groupUrl}/${id}`) } export function createGroup(params: any) { return request.post(groupUrl, params) @@ -18,15 +18,15 @@ export function removeGroup(id: number) { } export function getModuleRelation(params: any) { - return request.get(`${groupUrl}/${params.id}/module/relations`, { params }) + return EnhancedRequestGet(`${groupUrl}/${params.id}/module/relations`, { params }) } const baseUrl = '/ams/v1/relation' export function getRelation(params: Base.IListParams) { - return request.get(baseUrl, { params }) + return EnhancedRequestGet(baseUrl, { params }) } export function getRelationDetail(id: number) { - return request.get(`${baseUrl}/${id}`) + return EnhancedRequestGet(`${baseUrl}/${id}`) } export function createRelation(params: any) { return request.post(baseUrl, params) diff --git a/webs/ams-web/src/services/resource/topo.ts b/webs/ams-web/src/services/resource/topo.ts index b31fb34..609c929 100644 --- a/webs/ams-web/src/services/resource/topo.ts +++ b/webs/ams-web/src/services/resource/topo.ts @@ -1,19 +1,20 @@ import { request, downloadFile } from '@cmp/cmp-element' +import EnhancedRequestGet from '@/services/EnhancedRequestGet' const baseUrl = '/ams/v1/instance/topology' // 获取实例拓扑 export function getInstanceTopo(params: Object) { - return request.get(`${baseUrl}`, { params }) + return EnhancedRequestGet(`${baseUrl}`, { params }) } // 获取实例拓扑详情 export function getInstanceTopoDetail(id: Number) { - return request.get(`${baseUrl}/${id}`) + return EnhancedRequestGet(`${baseUrl}/${id}`) } // 获取拓扑路径 export function getInstanceTopoPath(params: Object) { - return request.get(`${baseUrl}/path`, { params }) + return EnhancedRequestGet(`${baseUrl}/path`, { params }) } // 新增实例拓扑 @@ -23,7 +24,7 @@ export function createInstanceTopo(data: Object) { // 根据起始模型查询最大拓扑层级 export function getTopoMaxLevel(params: Object) { - return request.get(`${baseUrl}/max/level`, { params }) + return EnhancedRequestGet(`${baseUrl}/max/level`, { params }) } // 更新实例拓扑 @@ -38,12 +39,12 @@ export function removeInstanceTopo(id: Number) { // 获取查询项以及列表项 export function getResourceListConfigs(id: Number) { - return request.get(`${baseUrl}/${id}/dynamic/item`) + return EnhancedRequestGet(`${baseUrl}/${id}/dynamic/item`) } // 查询资源列表 export function getResource(params: Object) { - return request.get(`${baseUrl}/resource`, { params }) + return EnhancedRequestGet(`${baseUrl}/resource`, { params }) } // 导出资源列表 @@ -53,20 +54,20 @@ export function downloadResource(id: Number) { // 根据实例拓扑id查询对应起始模型的实例集合 export function getStartModuleByInstance(id: Number) { - return request.get(`${baseUrl}/${id}/startmodule/instance`) + return EnhancedRequestGet(`${baseUrl}/${id}/startmodule/instance`) } // 查询模型实例关系记录 export function getModuleInstanceRelation(instanceId: number, id: number) { - return request.get(`${baseUrl}/topo`, { params: { instanceId, id } }) + return EnhancedRequestGet(`${baseUrl}/topo`, { params: { instanceId, id } }) } // 根据实例id查找下一层级实例拓扑 export function getInstanceNextTopo(params: Object) { - return request.get(`${baseUrl}/next/topo`, { params }) + return EnhancedRequestGet(`${baseUrl}/next/topo`, { params }) } // 查询模型实例拓扑 export function getInstanceTopology(instanceId: number, topoId: number) { - return request.get(`${baseUrl}/topo/instances/${instanceId}`, { params: { id: topoId } }) + return EnhancedRequestGet(`${baseUrl}/topo/instances/${instanceId}`, { params: { id: topoId } }) } diff --git a/webs/ams-web/src/views/AmsPosition.vue b/webs/ams-web/src/views/AmsPosition.vue new file mode 100644 index 0000000..5c13d23 --- /dev/null +++ b/webs/ams-web/src/views/AmsPosition.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/webs/ams-web/src/views/data-collection/components/Tree.vue b/webs/ams-web/src/views/data-collection/components/Tree.vue index b6c0919..7aabafa 100644 --- a/webs/ams-web/src/views/data-collection/components/Tree.vue +++ b/webs/ams-web/src/views/data-collection/components/Tree.vue @@ -99,6 +99,7 @@ export default defineComponent({ filterText, treeRef, handleNodeClick, + getData } }, }) diff --git a/webs/ams-web/src/views/data-collection/plugins/index.vue b/webs/ams-web/src/views/data-collection/plugins/index.vue index b92a425..6b553a6 100644 --- a/webs/ams-web/src/views/data-collection/plugins/index.vue +++ b/webs/ams-web/src/views/data-collection/plugins/index.vue @@ -1,8 +1,9 @@