fix: 资产管理区分主子阵地v1.0
parent
d40145d562
commit
27c57d8c49
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { request } from '@cmp/cmp-element'
|
import { request } from '@cmp/cmp-element'
|
||||||
import { wrapperParams } from 'utils'
|
import { wrapperParams } from 'utils'
|
||||||
|
import { getSelectPosition } from '@/views/usePostion'
|
||||||
export function getPropertiesByCode(code) {
|
export function getPropertiesByCode(code) {
|
||||||
return request.get('/ims/v1/properties', {
|
return request.get('/ims/v1/properties', {
|
||||||
params: wrapperParams({ code }),
|
params: wrapperParams({ code }),
|
||||||
|
@ -70,7 +71,7 @@ export function getModuleGroupRoot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getModuleGroupChildren(groupId, params) {
|
export function getModuleGroupChildren(groupId, params) {
|
||||||
return request.get(`${baseUrl}/group/${groupId}/children`, { params })
|
return request.get(`${baseUrl}/group/${groupId}/children`, { params: { positionKey: getSelectPosition(), ...params } })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRootGroups(groupId) {
|
export function getRootGroups(groupId) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { request } from '@cmp/cmp-element'
|
import { request } from '@cmp/cmp-element'
|
||||||
|
import { getSelectPosition } from '@/views/usePostion'
|
||||||
|
|
||||||
export function getValidateRules(type: string) {
|
export function getValidateRules(type: string) {
|
||||||
return request.get('/ams/v1/regexps', {
|
return request.get('/ams/v1/regexps', {
|
||||||
|
@ -7,7 +8,11 @@ export function getValidateRules(type: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPropertyByModule(moduleId: number) {
|
export function getPropertyByModule(moduleId: number) {
|
||||||
return request.get(`/ams/v1/module/${moduleId}/properties`)
|
return request.get(`/ams/v1/module/${moduleId}/properties`, {
|
||||||
|
params: {
|
||||||
|
positionKey: getSelectPosition(),
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getModuleRelation(params: { sourceId: number; targetId: number; relationCategoryId: number }) {
|
export function getModuleRelation(params: { sourceId: number; targetId: number; relationCategoryId: number }) {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { request, downloadFile } from '@cmp/cmp-element'
|
import { request, downloadFile } from '@cmp/cmp-element'
|
||||||
|
import { getSelectPosition } from '@/views/usePostion'
|
||||||
|
|
||||||
const baseUrl = '/ams/v1/instances'
|
const baseUrl = '/ams/v1/instances'
|
||||||
export function getInstance(params: Base.IListParams) {
|
export function getInstance(params: Base.IListParams) {
|
||||||
return request.get(baseUrl, { params })
|
return request.get(baseUrl, { params: { positionKey: getSelectPosition(), ...params } })
|
||||||
}
|
}
|
||||||
export function getInstanceDetail(id: number) {
|
export function getInstanceDetail(id: number) {
|
||||||
return request.get(`${baseUrl}/${id}`)
|
return request.get(`${baseUrl}/${id}`)
|
||||||
|
|
|
@ -19,7 +19,6 @@ const codeMap = new Map([
|
||||||
['MULTILINETABLE', 'table-module'],
|
['MULTILINETABLE', 'table-module'],
|
||||||
])
|
])
|
||||||
const vueFiles = require.context('./', true, /\.vue$/)
|
const vueFiles = require.context('./', true, /\.vue$/)
|
||||||
console.log(vueFiles)
|
|
||||||
|
|
||||||
export const components = getModules(vueFiles)
|
export const components = getModules(vueFiles)
|
||||||
export function getCurrentComponent(type) {
|
export function getCurrentComponent(type) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<cb-advance-table :key="currentModule.id" v-if="!detailVisible" title="资源列表" :search-configs="searchConfigs" :data="list" :params="params" :columns="columns" :get-list="getList" :total="total" :loading="loading" @selection-change="handleSelectionChange">
|
<cb-advance-table :key="currentModule.id" v-if="!detailVisible" title="资源列表" :search-configs="searchConfigs" :data="list" :params="params" :columns="columns" :get-list="getList" :total="total" :loading="loading" @selection-change="handleSelectionChange">
|
||||||
<template #action>
|
<template #action v-if="isLeaderPosition">
|
||||||
<el-button type="primary" @click="handleCreate()" icon="el-icon-plus" :disabled="!currentModule.id">新增</el-button>
|
<el-button type="primary" @click="handleCreate()" icon="el-icon-plus" :disabled="!currentModule.id">新增</el-button>
|
||||||
<ImportData url="/api/ams/v1/instances/upload" @getData="getList" template-url="/ams/v1/instances/download" :disabled="!currentModule.id" :params="{ moduleId: currentModule.id, moduleCode: currentModule.code, type: '2007' }"></ImportData>
|
<ImportData url="/api/ams/v1/instances/upload" @getData="getList" template-url="/ams/v1/instances/download" :disabled="!currentModule.id" :params="{ moduleId: currentModule.id, moduleCode: currentModule.code, type: '2007' }"></ImportData>
|
||||||
<el-button @click="exportData" icon="el-icon-download" :disabled="!currentModule.id">导出</el-button>
|
<el-button @click="exportData" icon="el-icon-download" :disabled="!currentModule.id">导出</el-button>
|
||||||
|
@ -34,10 +34,12 @@
|
||||||
<span>{{ getMultileName(val, column.prop, propertyList) }}</span>
|
<span>{{ getMultileName(val, column.prop, propertyList) }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #operate="val, record" v-if="list.length">
|
<template #operate="val, record" v-if="list.length">
|
||||||
|
<template v-if="isLeaderPosition">
|
||||||
<el-button type="text" @click="handleCreate(record)" :disabled="!record.authEdit"><i class="el-icon-edit"></i> 编辑</el-button>
|
<el-button type="text" @click="handleCreate(record)" :disabled="!record.authEdit"><i class="el-icon-edit"></i> 编辑</el-button>
|
||||||
<div class="action-divider"></div>
|
<div class="action-divider"></div>
|
||||||
<el-button type="text" @click="handleDelete(record, { moduleCode: currentModule.code })" :disabled="!record.authDelete"><i class="el-icon-delete"></i> 删除</el-button>
|
<el-button type="text" @click="handleDelete(record, { moduleCode: currentModule.code })" :disabled="!record.authDelete"><i class="el-icon-delete"></i> 删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
</template>
|
||||||
</cb-advance-table>
|
</cb-advance-table>
|
||||||
<!--新增编辑界面-->
|
<!--新增编辑界面-->
|
||||||
<AddDialog :dialog="addDialog" v-if="addDialog.visible" @getData="getList"></AddDialog>
|
<AddDialog :dialog="addDialog" v-if="addDialog.visible" @getData="getList"></AddDialog>
|
||||||
|
@ -55,7 +57,7 @@ import BatchEditDialog from './BatchEditDialog.vue'
|
||||||
import AuthDialog from './detail/AuthDialog.vue'
|
import AuthDialog from './detail/AuthDialog.vue'
|
||||||
import TipDialog from './TipDialog.vue'
|
import TipDialog from './TipDialog.vue'
|
||||||
import { getInstance, removeInstance, exportInstance, batchRemove } from 'services/resource/moduleInstance'
|
import { getInstance, removeInstance, exportInstance, batchRemove } from 'services/resource/moduleInstance'
|
||||||
import { defineComponent, ref, Ref } from 'vue'
|
import { defineComponent, ref, Ref, inject } from 'vue'
|
||||||
import { Message, MessageBox } from 'element-ui'
|
import { Message, MessageBox } from 'element-ui'
|
||||||
import { useTable, useSelection } from '@cmp/cmp-element'
|
import { useTable, useSelection } from '@cmp/cmp-element'
|
||||||
import { getPropertyByModule } from 'services/index'
|
import { getPropertyByModule } from 'services/index'
|
||||||
|
@ -66,6 +68,7 @@ import ImportData from '@cmp/cmp-common/components/import-data/index.vue'
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { AddDialog, DetailItem, ImportData, BatchEditDialog, TipDialog, AuthDialog },
|
components: { AddDialog, DetailItem, ImportData, BatchEditDialog, TipDialog, AuthDialog },
|
||||||
setup(props, context) {
|
setup(props, context) {
|
||||||
|
const isLeaderPosition = inject('isLeaderPosition') as Ref<boolean>
|
||||||
const { list, total, params, handleDelete, loading, getList } = useTable({
|
const { list, total, params, handleDelete, loading, getList } = useTable({
|
||||||
getService: getInstance,
|
getService: getInstance,
|
||||||
removeService: removeInstance,
|
removeService: removeInstance,
|
||||||
|
@ -234,6 +237,7 @@ export default defineComponent({
|
||||||
tipDialog,
|
tipDialog,
|
||||||
batchOperate,
|
batchOperate,
|
||||||
authDialog,
|
authDialog,
|
||||||
|
isLeaderPosition,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<cb-advance-table ref="tableRef" :card-border="false" :search-configs="searchConfigs" :data="list" :params="params" :columns="columns" :get-list="getList" :total="total" :loading="loading">
|
<cb-advance-table ref="tableRef" :card-border="false" :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>
|
<el-button type="primary" @click="handleCreate()" icon="el-icon-plus">新增</el-button>
|
||||||
</template>
|
</template>
|
||||||
<template #operate="val, record">
|
<template #operate="val, record">
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getAuth, removeAuth } from 'services/resource/auth'
|
import { getAuth, removeAuth } from 'services/resource/auth'
|
||||||
import { defineComponent, reactive, toRefs, ref } from 'vue'
|
import { defineComponent, reactive, inject, ref } from 'vue'
|
||||||
import { Message, MessageBox } from 'element-ui'
|
import { Message, MessageBox } from 'element-ui'
|
||||||
import { useTable } from '@cmp/cmp-element'
|
import { useTable } from '@cmp/cmp-element'
|
||||||
import { cloneDeep } from 'lodash-es'
|
import { cloneDeep } from 'lodash-es'
|
||||||
|
@ -65,6 +65,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
const isLeaderPosition = inject('isLeaderPosition')
|
||||||
const searchConfigs = reactive(cloneDeep(searchConfig))
|
const searchConfigs = reactive(cloneDeep(searchConfig))
|
||||||
searchConfigs[0].initValue = props.detailData.moduleId
|
searchConfigs[0].initValue = props.detailData.moduleId
|
||||||
searchConfigs[1].initValue = props.detailData.id
|
searchConfigs[1].initValue = props.detailData.id
|
||||||
|
@ -109,6 +110,7 @@ export default defineComponent({
|
||||||
addDialog,
|
addDialog,
|
||||||
handleCreate,
|
handleCreate,
|
||||||
handleDelete,
|
handleDelete,
|
||||||
|
isLeaderPosition,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<split-pane :min-percent="10" :default-percent="15" split="vertical" style="height: calc(100vh - 110px)">
|
<split-pane :min-percent="10" :default-percent="15" split="vertical" style="height: calc(100vh - 110px)">
|
||||||
<template slot="paneL">
|
<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>
|
<SideMenu @handleNodeClick="handleNodeClick"></SideMenu>
|
||||||
</template>
|
</template>
|
||||||
<template slot="paneR">
|
<template slot="paneR">
|
||||||
|
@ -9,30 +13,57 @@
|
||||||
</split-pane>
|
</split-pane>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, ref, watch } from 'vue'
|
import { defineComponent, ref, unref } from 'vue'
|
||||||
import SplitPane from 'vue-splitpane'
|
import SplitPane from 'vue-splitpane'
|
||||||
import SideMenu from './SideMenu.vue'
|
import SideMenu from './SideMenu.vue'
|
||||||
import RightList from './List.vue'
|
import RightList from './List.vue'
|
||||||
import { useStore } from '@cmp/cmp-core'
|
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)
|
||||||
|
}
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { SplitPane, SideMenu, RightList },
|
components: { SplitPane, SideMenu, RightList },
|
||||||
setup() {
|
setup() {
|
||||||
const store = useStore()
|
// eslint-disable-next-line
|
||||||
console.log(store)
|
const { isLeaderPosition } = usePostion(() => {
|
||||||
const selectedPostion = computed(() => store.state.position.selectedPostion)
|
handleNodeClick(unref(lastNode))
|
||||||
watch(selectedPostion, (val) => {
|
|
||||||
console.log('阵地切换', val)
|
|
||||||
})
|
})
|
||||||
|
const lastNode = ref(null)
|
||||||
const listRef = ref()
|
const listRef = ref()
|
||||||
function handleNodeClick(node: any) {
|
function handleNodeClick(node: any) {
|
||||||
|
lastNode.value = node
|
||||||
const { type, id } = node
|
const { type, id } = node
|
||||||
if (type === 'module') {
|
if (type === 'module') {
|
||||||
listRef.value.init(node)
|
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 {
|
return {
|
||||||
listRef,
|
listRef,
|
||||||
handleNodeClick,
|
handleNodeClick,
|
||||||
|
isLeaderPosition,
|
||||||
|
setIsLeaderPosition,
|
||||||
|
select,
|
||||||
|
SET_SELECTED_POSITION,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { computed, onMounted, onUnmounted, provide, ref, unref, watch } from 'vue'
|
||||||
|
|
||||||
|
const usePostion = (cb?: Function) => {
|
||||||
|
const isLeaderPosition = ref(false)
|
||||||
|
const selectPostion = ref('')
|
||||||
|
provide(
|
||||||
|
'isLeaderPosition',
|
||||||
|
computed(() => unref(isLeaderPosition))
|
||||||
|
)
|
||||||
|
const handleStorageEvent = (event) => {
|
||||||
|
if (event.key === 'isLeaderPosition') {
|
||||||
|
isLeaderPosition.value = event.newValue === 'true'
|
||||||
|
}
|
||||||
|
if (event.key === 'selectPostion') {
|
||||||
|
selectPostion.value = event.newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
watch(selectPostion, () => {
|
||||||
|
if (typeof cb === 'function') {
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
onMounted(() => window.addEventListener('setItem', handleStorageEvent))
|
||||||
|
onUnmounted(() => window.removeEventListener('setItem', handleStorageEvent))
|
||||||
|
|
||||||
|
return {
|
||||||
|
isLeaderPosition,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const getSelectPosition = () => {
|
||||||
|
return window.sessionStorage.getItem('selectPostion')
|
||||||
|
}
|
||||||
|
export default usePostion
|
Loading…
Reference in New Issue