2019-09-25 14:52:21 +08:00
|
|
|
<template>
|
2019-10-18 17:15:04 +08:00
|
|
|
<div>
|
2019-10-25 14:41:23 +08:00
|
|
|
<el-card v-loading="loading" class="map-list-main" :header="$t('map.publishedMapList')">
|
2019-10-18 18:36:45 +08:00
|
|
|
<filter-city ref="filerCity" filter-empty :query-function="queryFunction" :local-param-name="localParamName" @filterSelectChange="refresh" />
|
2019-10-18 17:15:04 +08:00
|
|
|
<el-input v-model="filterText" :placeholder="this.$t('global.filteringKeywords')" clearable />
|
|
|
|
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: (height-125) +'px' }">
|
|
|
|
<el-tree
|
|
|
|
ref="tree"
|
|
|
|
:data="treeList"
|
|
|
|
node-key="id"
|
|
|
|
:props="defaultProps"
|
|
|
|
highlight-current
|
|
|
|
:span="22"
|
|
|
|
:filter-node-method="filterNode"
|
|
|
|
@node-click="clickEvent"
|
|
|
|
>
|
|
|
|
<!-- @node-contextmenu="showContextMenu" -->
|
2019-10-25 10:39:41 +08:00
|
|
|
<span slot-scope="{ node:tnode, data }" >
|
2019-09-27 18:16:27 +08:00
|
|
|
<span
|
2019-10-18 17:15:04 +08:00
|
|
|
class="el-icon-tickets"
|
|
|
|
:style="{color: data.valid ? 'green':''}"
|
2019-10-23 17:41:24 +08:00
|
|
|
></span>
|
|
|
|
<span> {{ tnode.label }}</span>
|
2019-10-18 17:15:04 +08:00
|
|
|
</span>
|
|
|
|
</el-tree>
|
|
|
|
</el-scrollbar>
|
2019-09-25 14:52:21 +08:00
|
|
|
</el-card>
|
2019-10-18 17:15:04 +08:00
|
|
|
</div>
|
2019-09-25 14:52:21 +08:00
|
|
|
</template>
|
|
|
|
<script>
|
2019-10-18 18:35:17 +08:00
|
|
|
import { listPublishMap } from '@/api/jmap/map';
|
2019-10-18 17:15:04 +08:00
|
|
|
import { UrlConfig } from '@/router/index';
|
2019-10-24 18:11:58 +08:00
|
|
|
import { superAdmin, admin } from '@/router';
|
2019-10-18 17:15:04 +08:00
|
|
|
import { getSessionStorage, setSessionStorage, removeSessionStorage } from '@/utils/auth';
|
|
|
|
import FilterCity from '@/views/components/filterCity';
|
|
|
|
import localStore from 'storejs';
|
2019-09-25 14:52:21 +08:00
|
|
|
|
2019-10-18 17:15:04 +08:00
|
|
|
export default {
|
|
|
|
name: 'PublicMapList',
|
|
|
|
components: {
|
|
|
|
FilterCity
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
height: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: true,
|
|
|
|
defaultShowKeys: [],
|
2019-10-18 18:35:17 +08:00
|
|
|
queryFunction: listPublishMap,
|
2019-10-18 17:15:04 +08:00
|
|
|
filterText: '',
|
|
|
|
treeData: [],
|
|
|
|
treeList: [],
|
|
|
|
selected: {},
|
|
|
|
defaultProps: {
|
|
|
|
children: 'children',
|
|
|
|
label: 'name'
|
|
|
|
},
|
|
|
|
node: {
|
|
|
|
},
|
|
|
|
point: {
|
|
|
|
x: 0,
|
|
|
|
y: 0
|
|
|
|
},
|
2019-10-18 17:23:25 +08:00
|
|
|
editModel: {},
|
2019-10-21 10:02:49 +08:00
|
|
|
localParamName: 'publish_cityCode',
|
|
|
|
cityCode: ''
|
2019-10-18 17:15:04 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
filterText(val) {
|
|
|
|
this.treeList = this.treeData.filter((res) => {
|
|
|
|
return res.name.includes(val);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy () {
|
|
|
|
removeSessionStorage('demonList');
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
filterNode(value, data) {
|
|
|
|
if (!value) return true;
|
|
|
|
return data.name.indexOf(value) !== -1;
|
|
|
|
},
|
|
|
|
showContextMenu(e, obj, node, vueElem) {
|
|
|
|
if (obj) {
|
|
|
|
this.node = node;
|
|
|
|
this.selected = obj;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
clickEvent(obj, data, ele) {
|
|
|
|
switch (obj.type) {
|
2019-10-24 18:11:58 +08:00
|
|
|
case 'scriptDesign': {
|
|
|
|
setSessionStorage('designType', 'scriptDesign');
|
|
|
|
this.$router.push({ path: `${UrlConfig.design.scriptHome}/${obj.mapId}?skinCode=${obj.skinCode}` });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'lessonDesign': {
|
|
|
|
setSessionStorage('designType', 'lessonDesign');
|
|
|
|
this.$router.push({ path: `${UrlConfig.design.lessonHome}/${obj.mapId}/${obj.skinCode}`, query: {cityCode: this.cityCode} });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'runPlanDesign': {
|
|
|
|
setSessionStorage('designType', 'runPlanDesign');
|
|
|
|
this.$router.push({ path: `${UrlConfig.design.runPlan}/${obj.mapId}?skinCode=${obj.skinCode}` });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'map': {
|
|
|
|
setSessionStorage('demonList', obj.id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'mapPreview':{
|
|
|
|
this.$router.push({ path: `${UrlConfig.design.mapPreview}/${obj.mapId}` });
|
|
|
|
break;
|
|
|
|
}
|
2019-10-18 17:15:04 +08:00
|
|
|
}
|
|
|
|
// this.$refs.menu.doClose();
|
|
|
|
},
|
|
|
|
// async myrefresh(filterSelect){
|
2019-09-27 18:16:27 +08:00
|
|
|
|
2019-10-18 17:15:04 +08:00
|
|
|
// },
|
|
|
|
async refresh(filterSelect) {
|
2019-10-21 10:02:49 +08:00
|
|
|
this.cityCode=filterSelect;
|
2019-10-18 17:15:04 +08:00
|
|
|
this.loading = true;
|
|
|
|
this.treeData = this.treeList = [];
|
|
|
|
try {
|
2019-10-21 10:02:49 +08:00
|
|
|
const res = await listPublishMap({cityCode: filterSelect});
|
2019-10-25 10:39:41 +08:00
|
|
|
|
2019-10-18 17:15:04 +08:00
|
|
|
res.data.forEach(elem=>{
|
|
|
|
// debugger;
|
|
|
|
// elem.children.find(n => { return n.name.includes("行调")})
|
|
|
|
elem.children=[
|
2019-10-24 18:11:58 +08:00
|
|
|
{
|
|
|
|
id:'1',
|
2019-10-25 14:41:23 +08:00
|
|
|
name:this.$t('designPlatform.mapPreview'),
|
2019-10-24 18:11:58 +08:00
|
|
|
type:'mapPreview',
|
2019-10-25 10:39:41 +08:00
|
|
|
mapId: elem.id
|
|
|
|
}
|
|
|
|
];
|
2019-10-25 14:41:23 +08:00
|
|
|
this.isAdministrator()?elem.children.push({id: '2',name: this.$t('designPlatform.lessonDesign'),type: 'lessonDesign',mapId: elem.id,skinCode: elem.skinCode}):'';
|
2019-10-25 10:39:41 +08:00
|
|
|
elem.children.push(
|
2019-10-18 17:15:04 +08:00
|
|
|
{
|
|
|
|
id: '3',
|
2019-10-25 14:41:23 +08:00
|
|
|
name: this.$t('designPlatform.scriptDesign'),
|
2019-10-18 17:15:04 +08:00
|
|
|
type: 'scriptDesign',
|
|
|
|
mapId: elem.id,
|
2019-10-25 10:39:41 +08:00
|
|
|
skinCode: elem.skinCode
|
2019-10-18 17:15:04 +08:00
|
|
|
// code:elem.children.find(n => { return n.name.includes("行调")})
|
2019-10-25 10:39:41 +08:00
|
|
|
});
|
|
|
|
elem.children.push(
|
2019-10-18 17:15:04 +08:00
|
|
|
{
|
|
|
|
id: '4',
|
2019-10-25 14:41:23 +08:00
|
|
|
name: this.$t('designPlatform.runPlanDesign'),
|
2019-10-18 17:15:04 +08:00
|
|
|
type: 'runPlanDesign',
|
|
|
|
mapId: elem.id,
|
2019-10-25 10:39:41 +08:00
|
|
|
skinCode: elem.skinCode
|
2019-10-18 17:15:04 +08:00
|
|
|
}
|
2019-10-25 10:39:41 +08:00
|
|
|
);
|
2019-10-18 17:15:04 +08:00
|
|
|
});
|
|
|
|
this.treeData = res.data;
|
|
|
|
this.treeList = this.filterText
|
|
|
|
? res.data.filter(elem => { return elem.name.includes(this.filterText); })
|
|
|
|
: res.data;
|
|
|
|
this.$nextTick(() => {
|
|
|
|
const mapId = getSessionStorage('demonList') || null;
|
|
|
|
this.$refs.tree.setCurrentKey(mapId);
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
this.loading = false;
|
|
|
|
this.$messageBox(this.$t('error.refreshFailed'));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
resize() {
|
|
|
|
this.widthLeft = Number(localStore.get('LeftWidth')) || this.widthLeft;
|
|
|
|
const width = this.$store.state.app.width - 521 - this.widthLeft;
|
|
|
|
const height = this.$store.state.app.height - 90;
|
|
|
|
this.$store.dispatch('config/resize', { width: width, height: height });
|
2019-10-24 18:11:58 +08:00
|
|
|
},
|
|
|
|
isAdministrator() {
|
2019-10-25 10:39:41 +08:00
|
|
|
return this.$store.state.user.roles.includes(superAdmin) || this.$store.state.user.roles.includes(admin);
|
2019-10-24 18:11:58 +08:00
|
|
|
},
|
2019-10-18 17:15:04 +08:00
|
|
|
// createMap() {
|
|
|
|
// this.$emit("createMap");
|
|
|
|
// },
|
|
|
|
}
|
|
|
|
};
|
2019-09-25 14:52:21 +08:00
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
.back-home {
|
|
|
|
float: right;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: #3ea726;
|
|
|
|
}
|
|
|
|
}
|
2019-09-26 15:51:22 +08:00
|
|
|
|
2019-09-29 14:21:06 +08:00
|
|
|
.map-list-main{
|
|
|
|
text-align:left;
|
2019-09-26 15:51:22 +08:00
|
|
|
}
|
2019-09-25 14:52:21 +08:00
|
|
|
</style>
|
|
|
|
<style>
|
|
|
|
.el-tree {
|
|
|
|
overflow-x: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-tree-node.is-current>.el-tree-node__content {
|
|
|
|
background-color: #e4e3e3 !important;
|
|
|
|
}
|
|
|
|
</style>
|