删除旧版个人地图文件

This commit is contained in:
joylink_cuiweidong 2020-10-26 10:00:35 +08:00
parent c14814890f
commit 620d73bf54
7 changed files with 0 additions and 1353 deletions

View File

@ -1,238 +0,0 @@
<template>
<div v-loading="loading" class="joylink-card map-list-main">
<div class="clearfix">
<span>{{ $t('map.myMapList') }}</span>
</div>
<div class="text_item">
<el-input v-model="filterText" :placeholder="this.$t('global.filteringKeywords')" clearable />
<div class="tree_box">
<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">
<span slot-scope="{ node:tnode, data }">
<span class="el-icon-tickets" :style="{color: data.valid ? 'green':''}" />
<span>&nbsp;{{ tnode.label }}</span>
</span>
</el-tree>
</div>
<div class="buttonList">
<el-button size="small" type="primary" class="eachButton uploadDemo ">
<input ref="files" type="file" class="file_box" accept=".json, application/json" @change="importf">
{{ $t('map.importMap') }}
</el-button>
<el-button size="small" type="primary" class="eachButton" @click="createMap">{{ $t('map.newConstruction') }}</el-button>
</div>
</div>
<map-operate-menu
ref="menu"
:point="point"
:edit-model="editModel"
:line-code="lineCode"
@refresh="loadInitData"
@jlmap3d="jlmap3d"
/>
</div>
</template>
<script>
import { DeviceMenu } from '@/scripts/ConstDic';
import { postBuildMapImport, listMap } from '@/api/jmap/mapdraft';
import { UrlConfig } from '@/scripts/ConstDic';
import { removeSessionStorage } from '@/utils/auth';
import MapOperateMenu from './mapmanage/operateMenu';
export default {
name: 'UserMapList',
components: {
MapOperateMenu
},
data() {
return {
loading: true,
defaultShowKeys: [],
filterText: '',
treeData: [],
treeList: [],
selected: {},
defaultProps: {
children: 'children',
label: 'name'
},
point: {
x: 0,
y: 0
},
editModel: {},
lineCode: ''
};
},
computed: {
// role() {
// return this.$store.state.user.roles.includes('04') ||
// this.$store.state.user.roles.includes('05') ||
// this.$store.state.user.roles.includes('01');
// }
},
watch: {
filterText(val) {
this.$refs.tree.filter(val);
}
},
beforeDestroy () {
removeSessionStorage('demonList');
},
mounted() {
this.loadInitData();
},
methods: {
filterNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
createMap() {
this.$emit('createMap');
},
async loadInitData() {
this.loading = true;
this.treeData = this.treeList = [];
try {
const res = await listMap({ drawWay:false});
res.data && res.data.forEach(elem=>{
elem.type = 'map';
elem.children = [
{
id: '1',
name: this.$t('designPlatform.mapDesign'),
type: 'mapDesign',
mapId: elem.id,
mapName: elem.name,
lineCode: elem.lineCode
},
{
id: '4',
name: this.$t('designPlatform.runPlanDesign'),
type: 'runPlanDesign',
mapId: elem.id,
mapName: elem.name,
lineCode: elem.lineCode
}
];
});
this.treeData = res.data;
this.treeList = this.filterText
? res.data.filter(elem => { return elem.name.includes(this.filterText); })
: res.data;
this.loading = false;
} catch (error) {
this.loading = false;
this.$messageBox(this.$t('error.refreshFailed'));
}
},
clickEvent(obj, data, ele) {
switch (obj.type) {
case 'mapDesign': {
this.$router.push({ path: `${UrlConfig.designUser.mapDraw}/${obj.mapId}/draft`, query: { name: obj.mapName } });
break;
}
case 'runPlanDesign': {
this.$router.push({ path: `${UrlConfig.designUser.runPlan}/${obj.mapId}?lineCode=${obj.lineCode}` });
break;
}
}
this.$refs.menu.doClose();
},
showContextMenu(e, obj, node, vueElem) {
if (obj && obj.type == 'map') {
e.preventDefault();
const menu = DeviceMenu.Map;
this.point = {
x: e.clientX,
y: e.clientY
};
this.editModel = obj;
this.editModel.lineCode = obj.lineCode;
this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });
}
},
jlmap3d() {
this.$router.push({ path: '/design/jlmap3d/edit', query: { mapid: this.editModel.id } });
},
importf() {
const loading = this.$loading({
lock: true,
text: '正在导入中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
setTimeout(() => {
const obj = this.$refs.files;
if (!obj.files) return;
const f = obj.files[0];
const reader = new FileReader();
const that = this;
reader.readAsText(f, 'utf-8');
reader.onload = function(e) {
const data = e.target.result;
postBuildMapImport(JSON.parse(data)).then(res => {
loading.close();
that.$message.success('导入成功!');
that.loadInitData();
loading.close();
}).catch(error => {
loading.close();
that.$message.error('导入失败' + error.message);
});
obj.value = '';
};
});
}
}
};
</script>
<style lang="scss" scoped>
.clearfix{
padding: 0 20px;
border-bottom: 1px solid #EBEEF5;
box-sizing: border-box;
height: 47px;
line-height: 47px;
position: absolute;
width:100%;
}
.text_item{
height: 100%;
padding-top: 47px;
.tree_box{
height: calc(100% - 89px);
overflow-y: auto;
}
}
.buttonList{
padding: 8px 0px 8px 0px;
border-top: 1px #ccc solid;
}
.eachButton{
margin-left:10px;
}
.uploadDemo {
position: relative;
overflow: hidden;
// float: right;
padding: 9px 15px;
margin-right: 3px;
cursor: pointer;
input {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
opacity: 0;
cursor: pointer;
}
}
.map-list-main{
text-align:left;
height: 100%;
position: relative;
}
</style>

View File

@ -1,100 +0,0 @@
<template>
<div class="app-wrapper">
<map-create ref="mapCreate" :line-code="lineCode" @refresh="refresh1" />
<div class="examList" :style="{width: widthLeft+'px'}">
<demon-list ref="demonList" @createMap="createMap" />
</div>
<drap-left :width-left="widthLeft" @drapWidth="drapWidth" />
<transition>
<router-view :product-list="productList" />
</transition>
</div>
</template>
<script>
import demonList from './demonList';
import drapLeft from '@/views/components/drapLeft/index';
import { launchFullscreen } from '@/utils/screen';
import localStore from 'storejs';
import { getSessionStorage, setSessionStorage } from '@/utils/auth';
import MapCreate from './mapmanage/create';
export default {
name: 'DesignPlatform',
components: {
demonList,
drapLeft,
MapCreate
},
data() {
return {
widthLeft: Number(localStore.get('LeftWidth')) || 450,
productList: [],
lineCode: ''
};
},
computed: {
width() {
return this.$store.state.app.width;
}
},
watch: {
widthLeft(val) {
this.setMapResize(val);
},
'$store.state.app.windowSizeCount': function() {
this.resize();
}
},
mounted() {
const againEnter = getSessionStorage('againEnter') || null;
if (!againEnter) {
launchFullscreen();
setSessionStorage('againEnter', true);
}
this.resize();
this.widthLeft = Number(localStore.get('LeftWidth'));
},
methods: {
refresh() {
this.$refs && this.$refs.demonList && this.$refs.demonList.loadInitData();
},
drapWidth(width) {
this.widthLeft = Number(width);
},
createMap() {
this.$refs.mapCreate.show();
},
refresh1() {
this.$refs.demonList.loadInitData();
},
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 });
},
setMapResize(LeftWidth) {
const widths = this.$store.state.app.width - 521 - LeftWidth;
const heights = this.$store.state.app.height - 90;
this.$store.dispatch('config/resize', { width: widths, height: heights });
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.app-wrapper {
@include clearfix;
position: relative;
height: 100%;
width: 100%;
overflow: hidden;
}
.examList {
float: left;
height: 100%;
}
</style>

View File

@ -1,310 +0,0 @@
<template>
<el-dialog v-dialogDrag v-dialogLoading="loadingUpload" :title="$t('map.createNewMap')" :visible.sync="dialogShow" width="30%" :close-on-click-modal="false" :before-close="handleClose">
<div>
<el-tabs v-model="activeTab" type="card">
<el-tab-pane :label="$t('map.normalCreate')" name="first">
<el-form ref="newForm" label-position="right" :model="newModel" label-width="140px" size="mini" :rules="newRules" @submit.native.prevent>
<el-form-item :label="$t('map.lineCode')" prop="lineCode">
<el-select v-model="newModel.lineCode" :placeholder="$t('map.pleaseSelect')">
<el-option
v-for="item in lineCodeList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
<el-form-item :label="$t('map.mapName')" prop="name">
<el-input v-model.trim="newModel.name" />
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane :label="$t('map.publishMapCreation')" name="second">
<el-form ref="pullForm" label-position="right" :model="pullModel" :rules="pullRules" label-width="140px" size="mini">
<el-form-item :label="$t('map.publishMap')+ ':'" prop="id">
<el-select v-model="pullModel.id" :placeholder="$t('map.pleaseSelect')" @change="handlePullModel">
<el-option
v-for="item in publishMapList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item :label="$t('map.mapName')" prop="name">
<el-input v-model.trim="pullModel.name" />
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
<el-button type="primary" :loading="loading" @click="create">{{ $t('map.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { newMap, newUsePublishMap } from '@/api/jmap/mapdraft';
// import XLSX from 'xlsx';
// import { translate, translateSheetTitle } from '@/scripts/translate';
// import { sheet_to_json } from '@/utils/Export2Excel';
import { getLineCodeList } from '@/api/management/mapline';
import { getMapListByProject } from '@/utils/mapList';
export default {
name: 'MapCreate',
props: {
lineCode: {
type: String,
default() {
return '';
}
}
},
data() {
return {
dialogShow: false,
loading: false,
file: null,
rABS: false,
loadingUpload: false,
resultJSON: {},
activeTab: 'first',
lineCodeList: [],
publishMapList: [],
newModel: {
id: '',
name: '',
lineCode: ''
},
pullModel: {
id: '',
name: ''
},
newRules: {
name: [
{ required: true, message: this.$t('rules.pleaseEnterMapName'), trigger: 'blur' }
],
lineCode: [
{ required: true, message: this.$t('rules.pleaseChooseLineCode'), trigger: 'change' }
]
},
pullRules: {
id: [
{ required: true, message: this.$t('rules.pleaseSelectMapSource'), trigger: 'change' }
],
name: [
{ required: true, message: this.$t('rules.pleaseEnterMapName'), trigger: 'blur' }
]
},
cityList: []
};
},
watch: {
lineCode(val) {
this.newModel.lineCode = val;
}
},
methods: {
show() {
this.dialogShow = true;
this.initLoadData();
},
close() {
if (this.$refs.newForm) {
this.$refs.newForm.resetFields();
}
if (this.$refs.pullForm) {
this.$refs.pullForm.resetFields();
}
this.dialogShow = false;
},
handlePullModel(id) {
const obj = this.publishMapList.find(ele => ele.id == id);
this.pullModel.name = obj.name;
},
handleClose() {
this.close();
},
initLoadData() {
this.lineCodeList = [];
this.$Dictionary.cityType().then(list => {
this.cityList = list;
});
getLineCodeList().then(response => {
this.lineCodeList = response.data;
});
const drawWay = false;
getMapListByProject(drawWay).then(response => {
this.publishMapList = response.data;
}).catch(() => {
this.$messageBox(this.$t('map.failedLoadListPublishedMaps'));
});
},
create() {
if (this.activeTab === 'first') {
this.$refs['newForm'].validate((valid) => {
if (valid) {
this.loading = true;
this.newModel['drawWay'] = false;
newMap(this.newModel).then(response => {
this.loading = false;
this.$emit('refresh');
this.$message.success(this.$t('map.creatingSuccessful'));
this.close();
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('map.createFailure'));
this.close();
});
}
});
} else {
this.$refs['pullForm'].validate((valid) => {
if (valid) {
this.loading = true;
newUsePublishMap(this.pullModel).then(response => {
this.loading = false;
this.$emit('refresh');
this.$message.success(this.$t('map.creatingSuccessful'));
this.close();
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('map.createFailure'));
this.close();
});
}
});
}
}
// importf() { //
// const obj = this.$refs.files;
// let wb;
// if (!obj.files) return;
// const f = obj.files[0];
// this.loadingUpload = true;
// const reader = new FileReader();
// const that = this;
// reader.onload = function (e) {
// const data = e.target.result;
// if (that.rABS) {
// wb = XLSX.read(btoa(that.fixdata(data)), {//
// type: 'base64'
// });
// } else {
// wb = XLSX.read(data, {
// type: 'binary'
// });
// }
// const resultJSONData = {};
// for (const index in wb.Sheets) {
// const titleNum = that.formatSheetTitle(index);
// const key = translateSheetTitle.sheetName[titleNum];
// const filterVal = that.handelData(key);
// const jsonData = sheet_to_json(wb.Sheets[index]);
// const data = that.formatJson(filterVal, jsonData, key);
// if (key === 'base') {
// for (const i in data[0]) {
// resultJSONData[i] = data[0][i];
// }
// } else {
// resultJSONData[key] = data;
// }
// }
// that.resultJSON = resultJSONData;
// if (that.resultJSON) {
// postBuildMapImport(that.resultJSON).then(res => {
// that.loadingUpload = false;
// that.$message.success(this.$t('map.importSuccessful'));
// that.$emit('refresh');
// that.close();
// }).catch(error => {
// that.loadingUpload = false;
// that.$message.error(this.$t('map.importFailure') + error.message);
// });
// }
// obj.value = ''; //
// };
// if (that.rABS) {
// reader.readAsArrayBuffer(f);
// } else {
// reader.readAsBinaryString(f);
// }
// },
// //
// handelData(key) {
// const tHeader = [];
// const tHeaderF = [];
// if (translate[key]) {
// translate[key].columns.forEach(item => {
// tHeader.push(item.tHeader);
// tHeaderF.push(item.key);
// });
// }
// const filterVal = {
// tHeader: tHeader,
// tHeaderF: tHeaderF
// };
// return filterVal;
// },
// // BinaryString
// fixdata(data) {
// var o = '';
// var l = 0;
// var w = 10240;
// for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
// o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
// return o;
// },
// //
// formatJson(filterVal, jsonData, key) {
// jsonData.map((item, index) => {
// const json = {};
// filterVal.tHeader.map((j, o) => {
// if (item[j] != undefined) {
// json[filterVal.tHeaderF[o]] = translate[key].columns[o].formatter(item[j]);
// }
// });
// jsonData.splice(index, 1, json);
// });
// return jsonData;
// },
// // sheet
// formatSheetTitle(title) {
// let index;
// translateSheetTitle.sheetTitle.forEach((v, i) => {
// if (title == v) index = i;
// });
// return index;
// }
}
};
</script>
<style scoped rel="stylesheet/scss" lang="scss">
.uploadDemo {
.el-upload-dragger {
margin: 0 auto;
}
.file_box {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
opacity: 0;
cursor: pointer;
}
}
</style>
<style>
.el-loading-mask {
background-color: rgba(0, 0, 0, 0.3);
}
</style>

View File

@ -1,229 +0,0 @@
<template>
<el-dialog v-dialogDrag :title="$t('map.mapEditor')" :visible.sync="dialogShow" :close-on-click-modal="false" width="30%" :before-close="handleClose">
<div>
<template v-if="basicInfo">
<el-form ref="edit" label-position="right" :model="editModel" :rules="editRules" label-width="120px" size="mini" @submit.native.prevent>
<el-form-item :label="$t('map.lineCode')" prop="lineCode">
<el-select v-model="editModel.lineCode" :placeholder="$t('map.pleaseSelect')" size="mini" disabled>
<el-option
v-for="item in lineCodeList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
<el-form-item :label="$t('map.mapName')" prop="name">
<el-input v-model.trim="editModel.name" />
</el-form-item>
</el-form>
</template>
<template v-else>
<el-form ref="updt" label-position="right" :model="updtModel" :rules="updtRules" label-width="120px" size="mini" @submit.native.prevent>
<el-form-item :label="$t('map.offsetXColon')" :prop="'origin.x'">
<el-input v-model="updtModel.origin.x" :label="$t('map.offsetX')" disabled />
</el-form-item>
<el-form-item :label="$t('map.offsetYColon')" :prop="'origin.y'">
<el-input v-model="updtModel.origin.y" :label="$t('map.offsetY')" disabled />
</el-form-item>
<el-form-item :label="$t('map.scalingColon')" prop="scaling">
<el-input-number v-model="updtModel.scaling" :precision="1" :step="0.2" disabled />
</el-form-item>
</el-form>
</template>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
<el-button type="primary" :loading="loading" @click="save">{{ $t('map.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { updateMap, getMapDetail } from '@/api/jmap/mapdraft';
import { getLineCodeList } from '@/api/management/mapline';
import { saveMap } from '@/api/jmap/mapdraft';
export default {
name: 'MapEdit',
props: {
map: {
type: Object,
required: true
},
basicInfo: {
type: Boolean,
required: true,
default: function () {
return true;
}
},
lineCode: {
type: String,
required: true
}
},
data() {
return {
dialogShow: false,
loading: false,
lineCodeList: [],
cityList: [],
editModel: {
id: '',
name: '',
lineCode: '01',
cityCode: ''
},
updtModel: {
code: '',
scaling: '',
origin: {
x: '',
y: ''
}
},
isUpdate: false
};
},
computed: {
editRules() {
return {
name: [
{ required: true, message: this.$t('rules.pleaseEnterMapName'), trigger: 'blur' }
],
lineCode: [
{ required: true, message: this.$t('rules.pleaseSelectAssociatedSkin'), trigger: 'change' }
]
};
},
updtRules() {
return {
'origin.x': [
{ required: true, message: this.$t('rules.enterXOffset'), trigger: 'blur' }
],
'origin.y': [
{ required: true, message: this.$t('rules.enterYOffset'), trigger: 'blur' }
],
scaling: [
{ required: true, message: this.$t('rules.enterScale'), trigger: 'blur' }
]
};
}
},
watch: {
map: function (val, old) {
if (val) {
Object.assign(this.editModel, this.map);
}
},
'$store.state.map.mapDataLoadedCount': function () {
if (this.$jlmap.lineCode) {
this.isUpdate = true;
}
}
},
mounted() {
this.initLoadData();
},
methods: {
show(type) {
const dataZoom = this.$store.state.map.dataZoom;
if (type == 'editCode') {
this.editModel.lineCode = this.editModel.lineCode ? this.editModel.lineCode : '';
this.editModel.name = this.editModel.name ? this.editModel.name : '';
} else if (type == 'editPoint') {
if (dataZoom && dataZoom.offsetX) {
this.updtModel.origin.x = Number.parseInt(dataZoom.offsetX);
this.updtModel.origin.y = Number.parseInt(dataZoom.offsetY);
this.updtModel.scaling = dataZoom.scaleRate;
}
}
this.dialogShow = true;
},
close() {
if (this.basicInfo) {
this.$refs.edit.resetFields();
} else {
this.$refs.updt.resetFields();
}
this.dialogShow = false;
},
handleClose() {
this.close();
},
save() {
this.loading = true;
if (this.basicInfo) {
this.$refs['edit'].validate((valid) => {
if (valid) {
updateMap(this.editModel).then(response => {
this.loading = false;
if (this.isUpdate && this.$route.params.mapId) {
getMapDetail(this.$route.params.mapId).then(response => {
this.$store.dispatch('map/setMapData', response.data);
});
}
this.$message.success(this.$t('map.mapUpdateSuccessful'));
this.$emit('refresh');
this.close();
}).catch(error => {
this.loading = false;
this.$message.error(this.$t('map.operationUnusual') + error.message);
});
} else {
this.loading = false;
}
});
} else {
this.updtModel.code = this.lineCode;
const map = this.$store.state.map.map;
this.$refs['updt'].validate((valid) => {
if (valid) {
this.$store.dispatch('map/saveMapDeviceDefaultRelations').then(() => {
const param = {
mapId: this.$route.params.mapId,
skinVO: {
code: this.$store.state.map.map.skinVO.code,
name: this.$store.state.map.map.skinVO.name,
origin: {
x: this.updtModel.origin.x,
y: this.updtModel.origin.y
},
scaling: this.updtModel.scaling
}
};
saveMap(Object.assign(map, param)).then(response => {
this.loading = false;
this.close();
this.$message.success(this.$t('map.updateSuccessfully'));
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('map.updateFailed'));
});
});
} else {
this.loading = false;
}
});
}
},
initLoadData() {
this.cityList = [];
this.$Dictionary.cityType().then(list => {
this.cityList = list;
}).catch(() => {
this.$messageBox(this.$t('map.failedLoadCityList'));
});
this.lineCodeList = [];
getLineCodeList().then(response => {
this.lineCodeList = response.data;
});
}
}
};
</script>

View File

@ -1,265 +0,0 @@
<template>
<div>
<pop-menu ref="popMenu" :menu="menu" />
<map-edit ref="edit" :basic-info="true" :map="editModel" :line-code="lineCode" @refresh="refresh" />
<!-- <map-edit ref="axisEdit" :basic-info="false" :map="editModel" :skin-code="skinCode" @refresh="refresh" /> -->
<map-save-as ref="saveAs" :map="editModel" @refresh="refresh" />
<map-publish ref="publish" :map="editModel" />
</div>
</template>
<script>
import { deleteMap } from '@/api/jmap/mapdraft';
import { DeviceMenu } from '@/scripts/ConstDic';
import { UrlConfig } from '@/scripts/ConstDic';
import PopMenu from '@/components/PopMenu';
import MapEdit from './edit';
import MapSaveAs from './saveAs';
import MapPublish from './publish';
import { mapGetters } from 'vuex';
import { saveMap } from '@/api/jmap/mapdraft';
export default {
name: 'MapOperateMenu',
components: {
PopMenu,
MapEdit,
MapSaveAs,
MapPublish
},
props: {
point: {
type: Object,
required: true
},
lineCode: {
type: String,
required: true
},
editModel: {
type: Object,
required: true
}
},
data() {
return {
menuMap: [
{
label: this.$t('map.updateObj'),
handler: this.updateObj
},
{
label: this.$t('map.updateObjAxis'),
handler: this.updateObjAxis
},
{
label: this.$t('map.saveAs'),
handler: this.saveAs
},
{
label: this.$t('map.deleteObj'),
handler: this.deleteObj
},
{
label: this.$t('map.jlmap3d'),
handler: this.jlmap3d
}
],
publishMapMenu: {
label: this.$t('map.publish'),
handler: this.publish
},
menuNormal: [],
menu: [],
updtModel: {
code: '',
scaling: '',
origin: {
x: '',
y: ''
}
}
};
},
computed: {
...mapGetters('map', [
'stationList'
]),
hasRelease() {
return this.$store.state.user.roles.includes('04') ||
this.$store.state.user.roles.includes('05');
}
},
watch: {
'$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Map)) {
this.menu = [...this.menuMap];
if (this.hasRelease) {
this.menu.push(this.publishMapMenu);
}
this.doShow(this.$store.state.menuOperation.menuPosition);
} else if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Cancel)) {
this.initCancelMenu();
this.doShow(this.$store.state.menuOperation.menuPosition);
} else {
this.doClose();
}
}
},
mounted() {
this.closeEvent();
},
methods: {
closeEvent() {
const self = this;
window.onclick = function (e) {
self.doClose();
};
},
doShow(point) {
this.closeEvent();
if (this.$refs && this.$refs.popMenu) {
this.$refs.popMenu.resetShowPosition(point);
}
},
doClose() {
if (this.$refs && this.$refs.popMenu) {
this.$refs.popMenu.close();
}
},
updateObj() {
this.doClose();
if (this.$refs && this.$refs.edit) {
this.$refs.edit.show('editCode');
}
},
updateObjAxis() {
this.doClose();
this.getMapOrigin();
this.$confirm('您确认按当前绘图位置更新坐标及缩放比例?', this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
const map = this.$store.state.map.map;
this.$store.dispatch('map/saveMapDeviceDefaultRelations').then(() => {
const param = {
mapId: this.$route.params.mapId,
skinVO: {
code: this.$store.state.map.map.skinVO.code,
name: this.$store.state.map.map.skinVO.name,
origin: {
x: this.updtModel.origin.x,
y: this.updtModel.origin.y
},
scaling: this.updtModel.scaling
}
};
saveMap(Object.assign(map, param)).then(response => {
this.$message.success(this.$t('map.updateSuccessfully'));
}).catch(() => {
this.$messageBox(this.$t('map.updateFailed'));
});
});
}).catch(() => { });
},
getMapOrigin() {
const dataZoom = this.$store.state.map.dataZoom;
if (dataZoom && dataZoom.offsetX) {
this.updtModel.origin.x = Number.parseInt(dataZoom.offsetX);
this.updtModel.origin.y = Number.parseInt(dataZoom.offsetY);
this.updtModel.scaling = dataZoom.scaleRate;
}
},
saveAs() {
this.doClose();
if (this.$refs && this.$refs.saveAs) {
this.$refs.saveAs.show();
}
},
publish() {
this.doClose();
if (this.$refs && this.$refs.publish) {
this.$refs.publish.show();
}
},
deleteObj() {
this.doClose();
const _that = this;
this.$confirm(this.$t('tip.confirmDeletion'), this.$t('tip.hint'), {
confirmButtonText: this.$t('map.confirm'),
cancelButtonText: this.$t('map.cancel'),
type: 'warning'
}).then(() => {
deleteMap(this.editModel.id).then(response => {
if (this.editModel.id == this.$route.params.mapId) {
this.$store.dispatch('map/mapClear').then(() => {
_that.$emit('editMap', null);
// _that.$router.push({ path: `${UrlConfig.map.draft}/0/draft` });
_that.$router.push({ path: `${UrlConfig.designUser.prefix}` });
});
}
_that.refresh();
_that.$message.success(this.$t('map.successfullyDelete'));
}).catch(error => {
_that.$message.error(this.$t('map.failDelete') + error.message);
});
}).catch(() => {
});
},
jlmap3d() {
this.$emit('jlmap3d');
},
refresh() {
this.$emit('refresh');
},
initCancelMenu() {
this.menuNormal = [];
this.stationList.forEach(station => {
if (station.code === station.concentrateStationCode) {
const node = {
label: station.name,
children: []
};
this.stationList.forEach(elem => {
if (elem.visible) {
let next = elem;
while (next.code != next.concentrateStationCode || !next.concentrateStationCode) {
next = this.$store.getters['map/getDeviceByCode'](next.concentrateStationCode);
}
if (station.code == next.code) {
node.children.push({
code: elem.code,
label: elem.name,
handler: this.mapLocation
});
}
}
});
this.menuNormal.push(node);
}
});
this.menu = [...this.menuNormal];
},
mapLocation(item) {
if (item) {
this.doClose();
this.$store.dispatch('training/updateOffsetStationCode', { offsetStationCode: item.code });
}
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
/deep/ {
.menu-item{
background: #f1ecec;
.pop-menu {
background: #5F9EA0;
}
}
}
</style>

View File

@ -1,137 +0,0 @@
<template>
<el-dialog v-dialogDrag :title="$t('map.mapPublished')" :visible.sync="dialogShow" width="30%" :before-close="handleClose">
<div>
<el-form ref="form" label-position="right" :model="editModel" label-width="120px" :rules="editRules" size="mini" @submit.native.prevent>
<el-form-item :label="$t('map.publishingAssociatedCity')" prop="cityCode">
<el-select v-model="editModel.cityCode" :placeholder="$t('map.pleaseSelect')">
<el-option v-for="item in cityList" :key="item.code" :label="item.name" :value="item.code" />
</el-select>
</el-form-item>
<el-form-item :label="$t('map.publishMapName')" prop="name">
<el-input v-model="editModel.name" />
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
<el-button type="primary" :loading="loading" @click="publish">{{ $t('map.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { publishMap } from '@/api/jmap/mapdraft';
import { checkMapName } from '@/api/jmap/map';
export default {
name: 'MapPublish',
props: {
map: {
type: Object,
required: true
}
},
data() {
return {
dialogShow: false,
loading: false,
cityList: [],
editModel: {
id: '',
name: '',
cityCode: '000000'
},
editRules: {
cityCode: [
{ required: true, message: this.$t('rules.pleaseEnterMapName'), trigger: 'change' }
],
name: [
{ required: true, message: this.$t('rules.pleaseEnterMapName'), trigger: 'blur' }
]
}
};
},
watch: {
map: function (val, old) {
if (val) {
Object.assign(this.editModel, this.map);
}
}
},
mounted() {
this.$Dictionary.cityType().then(list => {
this.cityList = list;
});
},
methods: {
show() {
this.dialogShow = true;
},
close() {
this.$refs.form.resetFields();
this.dialogShow = false;
},
handleClose() {
this.close();
},
publish() {
this.$refs.form.validate((valid) => {
if (valid) {
this.loading = true;
delete this.editModel.children;
this.verifyMapName();
}
});
},
async verifyMapName() { //
try {
const res = await checkMapName(this.editModel.name);
if (res.data) {
this.confirmPublish();
} else {
this.publishMap();
}
} catch (error) {
console.log(error);
}
},
confirmPublish() {
this.$confirm(this.$t('map.verifyMapName'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
this.publishMap();
}).catch(() => { this.loading = false; });
},
publishMap() {
publishMap(this.editModel).then(response => {
this.loading = false;
if (response.data && response.data.length) {
this.tableToExcel(response.data);
this.$messageBox(this.$t('map.dataValidationFailed'));
} else {
this.$message.success(this.$t('map.releaseSuccess'));
}
this.close();
}).catch((error) => {
this.loading = false;
this.$messageBox(`${this.$t('map.abnormalOperation')}, ${error.message}`);
});
},
tableToExcel(data) {
const filterVal = ['index'];
const arr = [];
data.forEach(item => {
arr.push({ index: item });
});
const dataList = this.formatJson(filterVal, arr);
import('@/utils/Export2Excel').then(excel => {
excel.export_json_to_excel([this.$t('map.datQuestion')], dataList, this.$t('map.dataList'));
});
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]));
}
}
};
</script>

View File

@ -1,74 +0,0 @@
<template>
<el-dialog v-dialogDrag :title="$t('map.saveMapAs')" :visible.sync="dialogShow" width="30%" :before-close="handleClose">
<div>
<el-form ref="form" label-position="right" :model="editModel" label-width="100px" :rules="editRules" size="mini" @submit.native.prevent>
<el-form-item :label="$t('map.mapName')" prop="name">
<el-input v-model="editModel.name" />
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
<el-button type="primary" :loading="loading" @click="saveAs">{{ $t('map.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { saveAsMap } from '@/api/jmap/mapdraft';
export default {
name: 'MapSaveAs',
props: {
map: {
type: Object,
required: true
}
},
data() {
return {
dialogShow: false,
loading: false,
editModel: {
id: '',
name: ''
},
editRules: {
name: [
{ required: true, message: this.$t('rules.pleaseEnterMapName'), trigger: 'blur' }
]
}
};
},
watch: {
map: function (val, old) {
if (val) {
Object.assign(this.editModel, this.map);
}
}
},
methods: {
show() {
this.dialogShow = true;
},
close() {
this.$refs.form.resetFields();
this.dialogShow = false;
},
handleClose() {
this.close();
},
saveAs() {
this.loading = true;
saveAsMap(this.editModel).then(response => {
this.loading = false;
this.$emit('refresh');
this.close();
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('map.saveFailed'));
});
}
}
};
</script>