diff --git a/src/views/dashboard/echarts/permission.vue b/src/views/dashboard/echarts/permission.vue
index 108f08584..6205fa426 100644
--- a/src/views/dashboard/echarts/permission.vue
+++ b/src/views/dashboard/echarts/permission.vue
@@ -47,7 +47,8 @@ export default {
}],
xAxis: {
type: 'value',
- show: false
+ show: false,
+ minInterval: 1
},
yAxis: {
type: 'category',
diff --git a/src/views/map/mapdraft/mapmanage/maplist.vue b/src/views/map/mapdraft/mapmanage/maplist.vue
index 47dd0f945..37f469eab 100644
--- a/src/views/map/mapdraft/mapmanage/maplist.vue
+++ b/src/views/map/mapdraft/mapmanage/maplist.vue
@@ -4,12 +4,19 @@
{{ $t('map.sketchMap') }}
{{ $t('map.newConstruction') }}
- -->
+
{{ $t('map.importMap') }}
@@ -50,12 +57,12 @@ import { DeviceMenu } from '@/scripts/ConstDic';
import { getMapTree, getMapDetail, postBuildMapImport } from '@/api/jmap/mapdraft';
// import { UrlConfig } from '@/router/index';
import { translate, translateSheetTitle } from '@/scripts/translate';
-import { sheet_to_json } from '@/utils/Export2Excel';
+// import { sheet_to_json } from '@/utils/Export2Excel';
// import PopMenu from '@/components/PopMenu';
import MapOperateMenu from './operateMenu';
import MapCreate from './create';
import WindowResizeHandler from '@/mixin/WindowResizeHandler';
-import XLSX from 'xlsx';
+// import XLSX from 'xlsx';
export default {
name: 'MapListDraft',
@@ -145,7 +152,66 @@ export default {
});
},
- importf() { // 导入
+ importf() {
+ // const loading = this.$loading({
+ // lock: true,
+ // text: '正在导入中...',
+ // spinner: 'el-icon-loading',
+ // background: 'rgba(0, 0, 0, 0.7)'
+ // });
+ // const obj = this.$refs.files;
+ // let wb;
+ // if (!obj.files) return;
+ // const f = obj.files[0];
+ // 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 = { 'devices': {} };
+ // 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') {
+ // Object.assign(resultJSONData, data[0]);
+ // } else if (key === 'skinVO') {
+ // resultJSONData['devices'][key] = data[0];
+ // } else {
+ // resultJSONData['devices'][key] = data;
+ // }
+ // }
+ // that.resultJSON = resultJSONData;
+ // if (that.resultJSON) {
+ // postBuildMapImport(that.resultJSON).then(res => {
+ // loading.close();
+ // that.$message.success('导入成功!');
+ // that.refresh();
+ // }).catch(error => {
+ // loading.close();
+ // that.$message.error('导入失败' + error.message);
+ // });
+ // }
+ // obj.value = ''; // 清空上次导入文件
+ // };
+ // if (that.rABS) {
+ // reader.readAsArrayBuffer(f);
+ // } else {
+ // reader.readAsBinaryString(f);
+ // }
+
const loading = this.$loading({
lock: true,
text: '正在导入中...',
@@ -153,57 +219,24 @@ export default {
background: 'rgba(0, 0, 0, 0.7)'
});
const obj = this.$refs.files;
- let wb;
if (!obj.files) return;
const f = obj.files[0];
const reader = new FileReader();
const that = this;
- reader.onload = function (e) {
+ reader.readAsText(f, 'utf-8');
+ 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 = { 'devices': {} };
- 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') {
- Object.assign(resultJSONData, data[0]);
- } else if (key === 'skinVO') {
- resultJSONData['devices'][key] = data[0];
- } else {
- resultJSONData['devices'][key] = data;
- }
- }
- that.resultJSON = resultJSONData;
- if (that.resultJSON) {
- postBuildMapImport(that.resultJSON).then(res => {
- loading.close();
- that.$message.success('导入成功!');
- that.refresh();
- }).catch(error => {
- loading.close();
- that.$message.error('导入失败' + error.message);
- });
- }
- obj.value = ''; // 清空上次导入文件
+ postBuildMapImport(JSON.parse(data)).then(res => {
+ loading.close();
+ that.$message.success('导入成功!');
+ that.refresh();
+ }).catch(error => {
+ loading.close();
+ that.$message.error('导入失败' + error.message);
+ });
+ obj.value = '';
+ loading.close();
};
- if (that.rABS) {
- reader.readAsArrayBuffer(f);
- } else {
- reader.readAsBinaryString(f);
- }
},
// 转换数据格式
handelData(key) {
diff --git a/src/views/publish/publishMap/index.vue b/src/views/publish/publishMap/index.vue
index c7eece291..f3194b2bf 100644
--- a/src/views/publish/publishMap/index.vue
+++ b/src/views/publish/publishMap/index.vue
@@ -202,14 +202,24 @@ export default {
if (resultData === false) {
return;
}
- const self = this;
- import('@/utils/Export2Excel').then(excel => {
- self.queryExportData(resultData).then(data => {
- excel.export_json_excel(data, resultData.name);
- }).catch(error => {
- self.$message.error('导出执行异常:' + error.message);
- });
- });
+
+ // const self = this;
+ // import('@/utils/Export2Excel').then(excel => {
+ // self.queryExportData(resultData).then(data => {
+ // excel.export_json_excel(data, resultData.name);
+ // }).catch(error => {
+ // self.$message.error('导出执行异常:' + error.message);
+ // });
+ // });
+
+ const content = new Blob([JSON.stringify(resultData)]);
+ const urlObject = window.URL || window.webkitURL || window;
+ const url = urlObject.createObjectURL(content);
+ const el = document.createElement('a');
+ el.href = url;
+ el.download =`${resultData.name}.json`;
+ el.click();
+ urlObject.revokeObjectURL(url);
},
// 部分导出