-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修改图层列表、图层颜色组件支持webmap3.0 review by xiongjj
- Loading branch information
1 parent
1c0f7cc
commit b64b211
Showing
16 changed files
with
389 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
class GroupUtil { | ||
getGroupVisible(catalogs, item) { | ||
const rootGroup = this.getRootGroup(catalogs, item); | ||
if (!rootGroup) return true; | ||
|
||
const { visible, children } = rootGroup; | ||
if (!visible) return false; | ||
|
||
return this.getGroupVisible(children, item); | ||
} | ||
|
||
getRootGroup(catalogs, item) { | ||
const isRootItem = catalogs.find(c => (c.id === item.id)); | ||
if (isRootItem) return; // 说明是顶层,不存在父图层组 | ||
|
||
// 图层组中的图层/图层组 | ||
const groups = catalogs.filter(catalog => catalog.type === 'group'); | ||
return groups.find((g) => this.isChild(g, item)); | ||
} | ||
|
||
// 是否是当前图层组的 子图层/子图层组 | ||
isChild(group, child) { | ||
const { children } = group; | ||
const target = children.find((c) => c.id === child.id); | ||
if (target) return true; | ||
|
||
const childrenGroup = children.filter(catalog => catalog.type === 'group'); | ||
return !!childrenGroup.find((c) => this.isChild(c, child)); | ||
} | ||
|
||
getGroupChildrenLayers(layerGroup) { | ||
const targetItems = []; | ||
for (const item of layerGroup) { | ||
// 图层组和图层都只选择可见的 | ||
if (item.visible === false) continue; | ||
|
||
if (item.type !== 'group') { | ||
targetItems.push(item); | ||
continue; | ||
} | ||
// 图层组 | ||
const group = item; | ||
targetItems.push(...this.getGroupChildrenLayers(group.children)); | ||
} | ||
return targetItems; | ||
} | ||
} | ||
export default GroupUtil; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<div> | ||
<sm-collapse | ||
v-for="(item, index) in layerCatalog" | ||
:key="index" | ||
:bordered="false" | ||
class="sm-component-layer-list__collapse" | ||
> | ||
<sm-collapse-panel v-if="item.type === 'group'" class="sm-component-layer-list__collapseitem" :showArrow="false"> | ||
<template slot="header"> | ||
<div | ||
class="header-wrap" | ||
:class="{ | ||
'header-wrap': true, | ||
'sm-component-layer-list__disabled': !item.visible | ||
}" | ||
> | ||
<div class="header-text"> | ||
<i | ||
:class="item.visible ? 'sm-components-icon-partially-visible' : 'sm-components-icon-hidden'" | ||
@click.stop="toggleItemVisibility(item)" | ||
/> | ||
<span class="add-ellipsis">{{ item.title }}</span> | ||
</div> | ||
<i class="sm-components-icon-solid-triangle-right header-arrow" /> | ||
<i class="sm-components-icon-solid-triangle-down header-arrow" /> | ||
</div> | ||
</template> | ||
<layer-group v-on="$listeners" :layerCatalog="item.children" :attributes="attributes" :checkAttributesEnabled="checkAttributesEnabled"></layer-group> | ||
</sm-collapse-panel> | ||
|
||
<div | ||
v-else | ||
:class="{ | ||
'sm-component-layer-list__elcarditem': true, | ||
'sm-component-layer-list__disabled': !item.visible | ||
}" | ||
> | ||
<div class="sm-component-layer-list__layer"> | ||
<i | ||
:class="item.visible ? 'sm-components-icon-visible' : 'sm-components-icon-hidden'" | ||
@click.stop="toggleItemVisibility(item)" | ||
/> | ||
<div class="sm-component-layer-list__layergroupname add-ellipsis" :title="item.title">{{ item.title }}</div> | ||
</div> | ||
<div v-if="attributesEnabled(item)" class="sm-component-layer-list__attributes"> | ||
<i | ||
:class="attributesIconClass" | ||
:style="!item.visible && { cursor: 'not-allowed' }" | ||
@click.stop="item.visible && toggleAttributesVisibility($event, item)" | ||
/> | ||
</div> | ||
</div> | ||
</sm-collapse> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Theme from 'vue-iclient/src/common/_mixin/Theme'; | ||
export default { | ||
name: 'LayerGroup', | ||
mixins: [Theme], | ||
props: { | ||
layerCatalog: { | ||
type: Array, | ||
default() { | ||
return []; | ||
} | ||
}, | ||
attributes: { | ||
type: Object, | ||
default() { | ||
return {}; | ||
} | ||
}, | ||
checkAttributesEnabled: { | ||
type: Function | ||
} | ||
}, | ||
computed: { | ||
attributesIconClass() { | ||
return (this.attributes && this.attributes.iconClass) || 'sm-components-icon-attribute'; | ||
}, | ||
attributesEnabled() { | ||
return (item) => { | ||
return this.attributes.enabled && (item.type === 'basic' && this.checkAttributesEnabled(item)); | ||
}; | ||
} | ||
}, | ||
methods: { | ||
toggleItemVisibility(item) { | ||
this.$emit('toggleItemVisibility', item); | ||
item.visible = !item.visible; | ||
}, | ||
toggleAttributesVisibility(e, item) { | ||
const { title, id } = item; | ||
this.$emit('toggleAttributesVisibility', e, id, title); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style> | ||
</style> |
Oops, something went wrong.