feat: 资产管理修改 2.0

develop
时启龙 2024-08-28 15:20:00 +08:00
parent 6f85d92020
commit 4467ff700c
19 changed files with 253 additions and 113 deletions

View File

@ -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)
}

View File

@ -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 })
}

View File

@ -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,
})
}

View File

@ -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 })
}

View File

@ -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)

View File

@ -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)

View File

@ -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 } })
}

View File

@ -0,0 +1,87 @@
<template>
<el-card v-if="isLeaderPosition" class="m-b">
<el-form>
<el-form-item label="所属阵地:">
<el-radio-group v-model="selectPostion" @change="SET_SELECTED_POSITION">
<el-radio v-for="item in positionList" :key="item.value" :label="item.value">{{ item.name }}</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
</el-card>
</template>
<script>
import { getDictChildren } from '@/services/platform'
import { getSysconfQueryByCode } from '@/services'
import { ref, onUnmounted } from 'vue'
const addStorageEvent = (key, data) => {
// StorageEvent
var newStorageEvent = document.createEvent('StorageEvent')
const storage = {
setItem: function (k, val) {
sessionStorage.setItem(k, val)
//
newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null)
//
window.dispatchEvent(newStorageEvent)
},
}
return storage.setItem(key, data)
}
export default {
setup() {
//
const isLeaderPosition = ref(false)
//
const positionList = ref([])
//
const value = window.sessionStorage.getItem('selectPostion') || ''
const selectPostion = ref(value)
const SET_SELECTED_POSITION = () => {
addStorageEvent('selectPostion', selectPostion.value)
}
async function init() {
const res = await getSysconfQueryByCode({ code: 'isLeaderPosition' })
if (!res.success) return
isLeaderPosition.value = res.data.value === 'true'
addStorageEvent('isLeaderPosition', res.data.value)
if (isLeaderPosition.value) {
const res = await getDictChildren({ value: 'POSITION_DATA' })
if (!res.success) return
positionList.value = [
{
name: '主中心',
value: '',
},
...res.data,
]
} else {
addStorageEvent('selectPostion', '')
}
}
init()
onUnmounted(() => {
// addStorageEvent('isLeaderPosition', '')
// addStorageEvent('selectPostion', '')
})
return {
isLeaderPosition,
positionList,
selectPostion,
SET_SELECTED_POSITION,
}
},
}
</script>
<style scoped lang="scss">
::v-deep {
.el-card__body {
padding: 5px 10px;
}
.el-form-item {
margin-bottom: 0;
}
}
</style>

View File

@ -99,6 +99,7 @@ export default defineComponent({
filterText,
treeRef,
handleNodeClick,
getData
}
},
})

View File

@ -1,8 +1,9 @@
<template>
<div class="warpper">
<AmsPosition></AmsPosition>
<split-pane class="split-pane" :min-percent="10" :default-percent="20" split="vertical">
<template slot="paneL">
<Tree category="template" @handleNodeClick="handleNodeClick"></Tree>
<Tree ref="Tree" category="template" @handleNodeClick="handleNodeClick"></Tree>
</template>
<template slot="paneR">
<List ref="listRef" :currentModuleId="currentModuleId" @handleCreate="handleCreate" @getDetail="getDetail"></List>
@ -14,7 +15,7 @@
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs, ref } from 'vue'
import { defineComponent, reactive, toRefs, ref, getCurrentInstance } from 'vue'
import SplitPane from 'vue-splitpane'
import Tree from '@/views/data-collection/components/Tree.vue'
import List from './List.vue'
@ -22,7 +23,8 @@ import AddData from './AddData/index.vue'
import { getCollectionPluginDetail } from 'services/data-collection/plugins'
import Detail from './detail/index.vue'
import { decrypt } from '@cmp/cmp-element'
import usePostion from '@/views/usePostion'
import AmsPosition from '@/views/AmsPosition.vue'
export default defineComponent({
components: {
SplitPane,
@ -30,8 +32,14 @@ export default defineComponent({
List,
AddData,
Detail,
AmsPosition,
},
setup() {
const instance = getCurrentInstance()
usePostion(() => {
if (instance.proxy?.$refs?.Tree) (instance.proxy.$refs.Tree as any).getData()
listRef.value.refresh()
})
const state = reactive({
currentModuleId: '' as any,
visible: false,

View File

@ -1,14 +1,17 @@
<template>
<div>
<AmsPosition></AmsPosition>
<cb-advance-table ref="tableRef" title="属性列表" :search-configs="searchConfigs" :data="list" :params="params" :columns="columns" :get-list="getList" :total="total" :loading="loading">
<template #action>
<template #action v-if="isLeaderPosition">
<el-button type="primary" @click="handleCreate()" icon="el-icon-plus">新增</el-button>
</template>
<template #operate="val, record">
<template v-if="isLeaderPosition">
<el-button type="text" @click="handleCreate(record)"><i class="el-icon-edit"></i> 编辑</el-button>
<div class="action-divider"></div>
<el-button type="text" @click="handleDelete(record)"><i class="el-icon-delete"></i> 删除</el-button>
</template>
</template>
</cb-advance-table>
<AddDialog :dialog="addDialog" v-if="addDialog.visible" @getData="getList"></AddDialog>
</div>
@ -19,10 +22,13 @@ import { defineComponent, reactive, toRefs, ref } from 'vue'
import AddDialog from './AddDialog.vue'
import { columns, searchConfigs } from './config'
import { useTable } from '@cmp/cmp-element'
import usePostion from '@/views/usePostion'
import AmsPosition from '@/views/AmsPosition.vue'
export default defineComponent({
components: { AddDialog },
components: { AddDialog, AmsPosition },
setup() {
const { isLeaderPosition } = usePostion(() => getList())
const { list, total, params, handleDelete, loading, getList } = useTable({
getService: getPool,
removeService: removePool,
@ -54,6 +60,7 @@ export default defineComponent({
getList,
addDialog,
handleCreate,
isLeaderPosition,
}
},
})

View File

@ -1,5 +1,6 @@
<template>
<div class="wrapper">
<AmsPosition></AmsPosition>
<!-- 左侧树形目录 -->
<split-pane v-show="!detailVisible" class="cmdb-split" v-on:resize="resize" :min-percent="10" :default-percent="15" split="vertical">
<template slot="paneL">
@ -11,7 +12,7 @@
<div class="m-b-sm m-l-xs">配置模型</div>
<!-- 搜索区域 -->
<cb-table-search :configs="searchConfigs" :onSearch="handleSearch" class="service-search m-b-sm">
<template #operate>
<template #operate v-if="isLeaderPosition">
<el-button type="primary" icon="el-icon-plus" @click="handlCreate()"> </el-button>
</template>
</cb-table-search>
@ -27,7 +28,7 @@
</div>
</div>
<div class="card-remark">{{ row.remark || '暂无描述' }}</div>
<div class="card-footer">
<div class="card-footer" v-if="isLeaderPosition">
<el-button type="text" class="operate" @click.stop="handlCreate(row)"> 编辑 </el-button>
<el-button type="text" class="operate" @click.stop="handleRemove(row)"> 删除 </el-button>
</div>
@ -51,9 +52,12 @@
</template>
<script>
import { mapState } from 'vuex'
import { getCurrentInstance } from 'vue'
import splitPane from 'vue-splitpane'
import ModuleDetail from './ModuleDetail.vue'
import { getModules, removeModule } from 'services/cmdb/module'
import usePostion from '@/views/usePostion'
import AmsPosition from '@/views/AmsPosition.vue'
function getSearchConfigs(moduleGroupId, flag) {
return [
@ -67,6 +71,7 @@ export default {
Tree: () => import('./side/index'),
splitPane,
ModuleDetail,
AmsPosition,
},
data() {
return {
@ -85,6 +90,16 @@ export default {
activeName: '',
}
},
setup() {
const instance = getCurrentInstance()
const { isLeaderPosition } = usePostion(() => {
instance.proxy.getList()
instance.proxy.$refs.treeRef.$refs.tree.loadGroups()
})
return {
isLeaderPosition,
}
},
methods: {
async getList() {
const res = await getModules(this.params)

View File

@ -1,10 +1,11 @@
<template>
<el-row :gutter="10">
<AmsPosition></AmsPosition>
<el-col :span="6" style="width: 286px">
<el-card class="group">
<div slot="header">
关系分组
<el-button class="pull-right button-plus" type="text" @click="handleCreateGroup()" icon="el-icon-plus"></el-button>
<el-button v-if="isLeaderPosition" class="pull-right button-plus" type="text" @click="handleCreateGroup()" icon="el-icon-plus"></el-button>
</div>
<el-row>
<el-col :span="24">
@ -14,7 +15,7 @@
<span class="custom-tree-node-label">
{{ data.name }}
</span>
<span class="operate-btns">
<span class="operate-btns" v-if="isLeaderPosition">
<dot-dropdown :data="data" @editNode="handleCreateGroup" @deleteNode="handleDelete" />
</span>
</div>
@ -50,10 +51,15 @@ import DotDropdown from './DotDropdown.vue'
import RelationList from './list.vue'
import { getGroup, createGroup, modifyGroup, removeGroup } from 'services/relation'
import { useDelete } from '@cmp/cmp-element'
import usePostion from '@/views/usePostion'
import AmsPosition from '@/views/AmsPosition.vue'
export default defineComponent({
components: { DotDropdown, RelationList },
components: { DotDropdown, RelationList, AmsPosition },
setup() {
const { isLeaderPosition } = usePostion(() => {
getCategoryList()
})
const loading = ref(false)
//
const categoryList = ref([])
@ -106,6 +112,7 @@ export default defineComponent({
handleDelete,
saveGroup,
listRef,
isLeaderPosition,
}
},
})

View File

@ -1,14 +1,16 @@
<template>
<div>
<cb-advance-table ref="tableRef" title="关联类型" :search-configs="searchConfigs" :data="list" :params="params" :columns="columns" :get-list="getList" :total="total" :loading="loading">
<template #action>
<template #action v-if="isLeaderPosition">
<el-button type="primary" @click="handleCreate()" icon="el-icon-plus" :disabled="!categoryList.length">新增</el-button>
</template>
<template #operate="val, record">
<template v-if="isLeaderPosition">
<el-button type="text" @click="handleCreate(record)"><i class="el-icon-edit"></i> 编辑</el-button>
<div class="action-divider"></div>
<el-button type="text" @click="handleDelete(record)"><i class="el-icon-delete"></i> 删除</el-button>
</template>
</template>
</cb-advance-table>
<el-dialog :title="record.id ? '编辑关联类型' : '新增关联类型'" :close-on-click-modal="false" v-if="dialogVisible" :visible.sync="dialogVisible" width="35%">
<cb-form :model="record" ref="formRef" label-width="130px">
@ -36,7 +38,7 @@
</template>
<script lang="ts">
import { getRelation, createRelation, modifyRelation, removeRelation } from 'services/relation'
import { defineComponent, reactive, toRefs, ref } from 'vue'
import { defineComponent, reactive, toRefs, ref, inject } from 'vue'
import { Message } from 'element-ui'
import { useTable } from '@cmp/cmp-element'
import { cloneDeep } from 'lodash-es'
@ -83,6 +85,7 @@ export default defineComponent({
},
},
setup() {
const isLeaderPosition = inject('isLeaderPosition')
const searchConfigs = ref(cloneDeep(searchConfig))
const { list, total, params, handleDelete, loading, getList } = useTable({
getService: getRelation,
@ -139,6 +142,7 @@ export default defineComponent({
handleSearch,
formRef,
save,
isLeaderPosition,
}
},
})

View File

@ -2,7 +2,7 @@
<el-card class="leftC" shadow="never">
<div slot="header" class="side-header">
<el-input placeholder="输入关键字进行过滤" v-model="filterText" clearable> </el-input>
<el-tooltip content="添加模型分组">
<el-tooltip content="添加模型分组" v-if="isLeaderPosition">
<i class="el-icon-plus cur-point m-l-xs" @click="handleCreateNode({ title: '新增根分组', operateType: 'create', isRoot: true, type: 'group' })"></i>
</el-tooltip>
</div>
@ -14,7 +14,7 @@
</template>
<script>
import { reactive, toRefs, ref } from 'vue'
import { reactive, toRefs, ref, inject } from 'vue'
import { getRootGroups, removeModuleGroup, removeModule } from 'services/cmdb/module'
import { MessageBox, Message } from 'element-ui'
export default {
@ -29,6 +29,7 @@ export default {
},
},
setup(props, { emit }) {
const isLeaderPosition = inject('isLeaderPosition')
const state = reactive({
addData: {
data: {},
@ -79,6 +80,7 @@ export default {
remove,
updateSuccess,
tree,
isLeaderPosition,
}
},
}

View File

@ -1,16 +1,15 @@
<template>
<div>
<AmsPosition></AmsPosition>
<split-pane :min-percent="10" :default-percent="15" split="vertical" style="height: calc(100vh - 110px)">
<template slot="paneL">
<!-- <el-button @click="setIsLeaderPosition"> {{ isLeaderPosition }}</el-button>
<el-radio-group v-model="select" @change="SET_SELECTED_POSITION" v-if="isLeaderPosition">
<el-radio v-for="item in ['sma-1', 'ams-2']" :key="item" :label="item">{{ item }}</el-radio>
</el-radio-group> -->
<SideMenu @handleNodeClick="handleNodeClick"></SideMenu>
</template>
<template slot="paneR">
<RightList ref="listRef"></RightList>
</template>
</split-pane>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, unref } from 'vue'
@ -18,28 +17,15 @@ import SplitPane from 'vue-splitpane'
import SideMenu from './SideMenu.vue'
import RightList from './List.vue'
import usePostion from '@/views/usePostion'
const addStorageEvent = (key, data) => {
// StorageEvent
var newStorageEvent = document.createEvent('StorageEvent')
const storage = {
setItem: function (k, val) {
sessionStorage.setItem(k, val)
//
newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null)
//
window.dispatchEvent(newStorageEvent)
},
}
return storage.setItem(key, data)
}
import AmsPosition from '@/views/AmsPosition.vue'
export default defineComponent({
components: { SplitPane, SideMenu, RightList },
components: { SplitPane, SideMenu, RightList, AmsPosition },
setup() {
// eslint-disable-next-line
const { isLeaderPosition } = usePostion(() => {
const lastNode = ref({})
usePostion(() => {
handleNodeClick(unref(lastNode))
})
const lastNode = ref(null)
const listRef = ref()
function handleNodeClick(node: any) {
lastNode.value = node
@ -48,22 +34,9 @@ export default defineComponent({
listRef.value.init(node)
}
}
const select = ref('')
const SET_SELECTED_POSITION = () => {
addStorageEvent('selectPostion', unref(select))
}
const setIsLeaderPosition = () => {
const val = Math.random() > 0.5
addStorageEvent('isLeaderPosition', val)
if (!val) addStorageEvent('selectPostion', '')
}
return {
listRef,
handleNodeClick,
isLeaderPosition,
setIsLeaderPosition,
select,
SET_SELECTED_POSITION,
}
},
})

View File

@ -1,17 +1,20 @@
<template>
<div>
<AmsPosition></AmsPosition>
<cb-advance-table title="拓扑列表" :search-configs="searchConfigs" :data="list" :params="params" :columns="columns" :get-list="getList" :total="total" :loading="loading">
<template #action>
<template #action v-if="isLeaderPosition">
<el-button type="primary" @click="handleCreate()" icon="el-icon-plus">新增</el-button>
</template>
<template #name="name, record">
<span class="detail-href" @click="getDetail(record.id)">{{ name }}</span>
</template>
<template #operate="val, record">
<template v-if="isLeaderPosition">
<el-button type="text" @click="handleCreate(record)"><i class="el-icon-edit"></i> 编辑</el-button>
<div class="action-divider"></div>
<el-button type="text" @click="handleDelete(record)"><i class="el-icon-delete"></i> 删除</el-button>
</template>
</template>
</cb-advance-table>
<Detail :detail="detail" v-if="visible" @goBack="visible = false"></Detail>
<AddData :add-data="addData" v-if="addData.dialog" @getList="getList"></AddData>
@ -23,13 +26,17 @@ import { defineComponent, reactive, toRefs } from 'vue'
import { useTable } from '@cmp/cmp-element'
import { columns, searchConfigs } from './config'
import { getInstanceTopo, removeInstanceTopo, getInstanceTopoDetail } from 'services/resource'
import usePostion from '@/views/usePostion'
import AmsPosition from '@/views/AmsPosition.vue'
export default defineComponent({
components: {
AddData: () => import('./components/AddData.vue'),
Detail: () => import('./detail/index.vue'),
AmsPosition,
},
setup() {
const { isLeaderPosition } = usePostion(() => getList())
const { list, total, loading, getList, params, handleDelete } = useTable({
getService: getInstanceTopo,
removeService: removeInstanceTopo,
@ -81,6 +88,7 @@ export default defineComponent({
handleDelete,
getDetail,
...toRefs(state),
isLeaderPosition,
}
},
})

View File

@ -1,17 +1,20 @@
<template>
<div>
<AmsPosition></AmsPosition>
<cb-advance-table title="拓扑列表" :search-configs="searchConfigs" :data="list" :params="params" :columns="columns" :get-list="getList" :total="total" :loading="loading">
<template #action>
<template #action v-if="isLeaderPosition">
<el-button type="primary" @click="handleCreate()" icon="el-icon-plus">新增</el-button>
</template>
<template #name="name, record">
<span class="detail-href" @click="getDetail(record.id)">{{ name }}</span>
</template>
<template #operate="val, record">
<template v-if="isLeaderPosition">
<el-button type="text" @click="handleCreate(record)"><i class="el-icon-edit"></i> 编辑</el-button>
<div class="action-divider"></div>
<el-button type="text" @click="handleDelete(record)"><i class="el-icon-delete"></i> 删除</el-button>
</template>
</template>
</cb-advance-table>
<Detail :detail="detail" v-if="visible" @goBack="visible = false"></Detail>
<AddData :add-data="addData" v-if="addData.dialog" @getList="getList"></AddData>
@ -23,13 +26,17 @@ import { defineComponent, reactive, toRefs } from 'vue'
import { useTable } from '@cmp/cmp-element'
import { columns, searchConfigs } from './config'
import { getInstanceTopo, removeInstanceTopo, getInstanceTopoDetail } from 'services/resource'
import usePostion from '@/views/usePostion'
import AmsPosition from '@/views/AmsPosition.vue'
export default defineComponent({
components: {
AddData: () => import('./components/AddData.vue'),
Detail: () => import('./detail/index.vue'),
AmsPosition,
},
setup() {
const { isLeaderPosition } = usePostion(() => getList())
const { list, total, loading, getList, params, handleDelete } = useTable({
getService: getInstanceTopo,
removeService: removeInstanceTopo,
@ -81,6 +88,7 @@ export default defineComponent({
handleDelete,
getDetail,
...toRefs(state),
isLeaderPosition,
}
},
})

View File

@ -2,7 +2,8 @@ import { computed, onMounted, onUnmounted, provide, ref, unref, watch } from 'vu
const usePostion = (cb?: Function) => {
const isLeaderPosition = ref(false)
const selectPostion = ref('')
const value = window.sessionStorage.getItem('selectPostion') || ''
const selectPostion = ref(value)
provide(
'isLeaderPosition',
computed(() => unref(isLeaderPosition))