增加导出部分地图数据
This commit is contained in:
parent
bce66f2f22
commit
dc0b5301e0
@ -18,6 +18,7 @@
|
|||||||
"axios": "0.18.0",
|
"axios": "0.18.0",
|
||||||
"echarts": "^4.2.1",
|
"echarts": "^4.2.1",
|
||||||
"element-ui": "2.7.2",
|
"element-ui": "2.7.2",
|
||||||
|
"file-saver": "^1.3.3",
|
||||||
"js-cookie": "2.2.0",
|
"js-cookie": "2.2.0",
|
||||||
"js-md5": "^0.7.3",
|
"js-md5": "^0.7.3",
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.11",
|
||||||
@ -49,8 +50,8 @@
|
|||||||
"babel-eslint": "10.0.1",
|
"babel-eslint": "10.0.1",
|
||||||
"babel-jest": "23.6.0",
|
"babel-jest": "23.6.0",
|
||||||
"chalk": "2.4.2",
|
"chalk": "2.4.2",
|
||||||
"copy-webpack-plugin": "^4.5.2",
|
|
||||||
"connect": "3.6.6",
|
"connect": "3.6.6",
|
||||||
|
"copy-webpack-plugin": "^4.5.2",
|
||||||
"eslint": "5.15.3",
|
"eslint": "5.15.3",
|
||||||
"eslint-plugin-vue": "5.2.2",
|
"eslint-plugin-vue": "5.2.2",
|
||||||
"file-loader": "^3.0.1",
|
"file-loader": "^3.0.1",
|
||||||
@ -60,7 +61,7 @@
|
|||||||
"runjs": "^4.3.2",
|
"runjs": "^4.3.2",
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"script-ext-html-webpack-plugin": "2.1.3",
|
"script-ext-html-webpack-plugin": "2.1.3",
|
||||||
"script-loader": "0.7.2",
|
"script-loader": "^0.7.2",
|
||||||
"serve-static": "^1.13.2",
|
"serve-static": "^1.13.2",
|
||||||
"svg-sprite-loader": "4.1.3",
|
"svg-sprite-loader": "4.1.3",
|
||||||
"svgo": "1.2.2",
|
"svgo": "1.2.2",
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
export default {
|
export default {
|
||||||
scriptTitle: "Task Recording",
|
scriptTitle: 'Task Recording',
|
||||||
saveMaplocation: "Update Location",
|
saveMaplocation: 'Update Location',
|
||||||
saveBackground: "Save Background",
|
saveBackground: 'Save Background',
|
||||||
saveData: "Save Data",
|
saveData: 'Save Data',
|
||||||
roleManage: "Role Manage",
|
roleManage: 'Role Manage',
|
||||||
targetCondition: "Task Target",
|
targetCondition: 'Task Target',
|
||||||
taskScript: "Task Script",
|
taskScript: 'Task Script',
|
||||||
roleName: "Role Name",
|
roleName: 'Role Name',
|
||||||
roleType: "Role Type",
|
roleType: 'Role Type',
|
||||||
deviceCode: "Device Code",
|
deviceCode: 'Device Code',
|
||||||
roleList: "Role List",
|
roleList: 'Role List',
|
||||||
operation:"Operation",
|
operation: 'Operation',
|
||||||
roleAdd: "Add",
|
roleAdd: 'Add',
|
||||||
delete: "Delete",
|
delete: 'Delete',
|
||||||
behaviorOperate: "Behavior Operate",
|
behaviorOperate: 'Behavior Operate',
|
||||||
conditionTitle: "Target condition",
|
conditionTitle: 'Target condition',
|
||||||
deviceType: "Device Type",
|
deviceType: 'Device Type',
|
||||||
deviceCondition: "Device Condition",
|
deviceCondition: 'Device Condition',
|
||||||
paramDeviceType: "Param DeviceType",
|
paramDeviceType: 'Param DeviceType',
|
||||||
paramDeviceCode: "Param DeviceCode",
|
paramDeviceCode: 'Param DeviceCode'
|
||||||
};
|
};
|
||||||
|
@ -32,6 +32,7 @@ export default {
|
|||||||
pulishManage: '发布内容管理',
|
pulishManage: '发布内容管理',
|
||||||
publishMapManage: '发布地图管理',
|
publishMapManage: '发布地图管理',
|
||||||
productStateManage: '产品状态管理',
|
productStateManage: '产品状态管理',
|
||||||
|
publishLessonManage: '发布课程管理',
|
||||||
runPlanTemplateManage: '模板运行图管理',
|
runPlanTemplateManage: '模板运行图管理',
|
||||||
runPlanCommonManage: '通用运行图管理',
|
runPlanCommonManage: '通用运行图管理',
|
||||||
runPlanEveryDayManage: '每日运行图管理',
|
runPlanEveryDayManage: '每日运行图管理',
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
export default {
|
export default {
|
||||||
scriptTitle: "任务录制",
|
scriptTitle: '任务录制',
|
||||||
saveMaplocation: "更新定位",
|
saveMaplocation: '更新定位',
|
||||||
saveBackground: "保存背景",
|
saveBackground: '保存背景',
|
||||||
saveData: "保存数据",
|
saveData: '保存数据',
|
||||||
roleManage:"角色管理",
|
roleManage: '角色管理',
|
||||||
targetCondition:"任务目标",
|
targetCondition: '任务目标',
|
||||||
taskScript:"任务剧本",
|
taskScript: '任务剧本',
|
||||||
roleName: "角色名称",
|
roleName: '角色名称',
|
||||||
roleType: "角色类型",
|
roleType: '角色类型',
|
||||||
deviceCode: "设备编码",
|
deviceCode: '设备编码',
|
||||||
roleList: "角色列表",
|
roleList: '角色列表',
|
||||||
operation: "操作",
|
operation: '操作',
|
||||||
roleAdd: "添加",
|
roleAdd: '添加',
|
||||||
delete: "删除",
|
delete: '删除',
|
||||||
behaviorOperate: "行为操作",
|
behaviorOperate: '行为操作',
|
||||||
conditionTitle: "目标条件",
|
conditionTitle: '目标条件',
|
||||||
deviceType: "设备类型",
|
deviceType: '设备类型',
|
||||||
deviceCondition: "设备条件",
|
deviceCondition: '设备条件',
|
||||||
paramDeviceType: "参数设备类型",
|
paramDeviceType: '参数设备类型',
|
||||||
paramDeviceCode: "参数设备编号",
|
paramDeviceCode: '参数设备编号'
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
require('script-loader!file-saver');
|
||||||
|
require('script-loader!@/utils/Blob');
|
||||||
import XLSX from 'xlsx';
|
import XLSX from 'xlsx';
|
||||||
|
import { translate } from '@/scripts/translate';
|
||||||
|
|
||||||
|
|
||||||
function generateArray(table) {
|
function generateArray(table) {
|
||||||
var out = [];
|
var out = [];
|
||||||
@ -81,7 +85,6 @@ function sheet_from_array_of_arrays(data, opts) {
|
|||||||
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
|
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
|
||||||
return ws;
|
return ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
function encode_row(row) { return "" + (row + 1); };
|
function encode_row(row) { return "" + (row + 1); };
|
||||||
function encode_col(col) { var s = ""; for (++col; col; col = Math.floor((col - 1) / 26)) s = String.fromCharCode(((col - 1) % 26) + 65) + s; return s; }
|
function encode_col(col) { var s = ""; for (++col; col; col = Math.floor((col - 1) / 26)) s = String.fromCharCode(((col - 1) % 26) + 65) + s; return s; }
|
||||||
function safe_format_cell(cell, v) {
|
function safe_format_cell(cell, v) {
|
||||||
@ -179,7 +182,6 @@ export function sheet_to_json(sheet, opts) {
|
|||||||
out.length = outi;
|
out.length = outi;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function safe_decode_range(range) {
|
function safe_decode_range(range) {
|
||||||
var o = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
|
var o = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
|
||||||
var idx = 0, i = 0, cc = 0;
|
var idx = 0, i = 0, cc = 0;
|
||||||
@ -227,12 +229,14 @@ function s2ab(s) {
|
|||||||
|
|
||||||
export function export_table_to_excel(id) {
|
export function export_table_to_excel(id) {
|
||||||
var theTable = document.getElementById(id);
|
var theTable = document.getElementById(id);
|
||||||
|
console.log('a')
|
||||||
var oo = generateArray(theTable);
|
var oo = generateArray(theTable);
|
||||||
var ranges = oo[1];
|
var ranges = oo[1];
|
||||||
|
|
||||||
/* original data */
|
/* original data */
|
||||||
var data = oo[0];
|
var data = oo[0];
|
||||||
var ws_name = "SheetJS";
|
var ws_name = "SheetJS";
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
var wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
|
var wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
|
||||||
|
|
||||||
@ -249,6 +253,9 @@ export function export_table_to_excel(id) {
|
|||||||
saveAs(new Blob([s2ab(wbout)], { type: "application/octet-stream" }), "test.xlsx")
|
saveAs(new Blob([s2ab(wbout)], { type: "application/octet-stream" }), "test.xlsx")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatJson(filterVal, jsonData) {
|
||||||
|
return jsonData.map(v => filterVal.map(j => v[j]))
|
||||||
|
}
|
||||||
export function export_json_to_excel(th, jsonData, defaultTitle) {
|
export function export_json_to_excel(th, jsonData, defaultTitle) {
|
||||||
|
|
||||||
/* original data */
|
/* original data */
|
||||||
@ -268,3 +275,43 @@ export function export_json_to_excel(th, jsonData, defaultTitle) {
|
|||||||
var title = defaultTitle || '列表'
|
var title = defaultTitle || '列表'
|
||||||
saveAs(new Blob([s2ab(wbout)], { type: "application/octet-stream" }), title + ".xlsx")
|
saveAs(new Blob([s2ab(wbout)], { type: "application/octet-stream" }), title + ".xlsx")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function export_json_excel(jsonData, defaultTitle) {
|
||||||
|
|
||||||
|
let data = jsonData;
|
||||||
|
let wb = new Workbook();
|
||||||
|
|
||||||
|
for (let index in data) {
|
||||||
|
let filterVal = handelData(index);
|
||||||
|
if (filterVal.tHeader.length) {
|
||||||
|
let dataDetail = formatJson(filterVal.tHeaderF, data[index]);
|
||||||
|
dataDetail.unshift(filterVal.tHeader); // 设置表头的
|
||||||
|
let ws = sheet_from_array_of_arrays(dataDetail);
|
||||||
|
/* add worksheet to workbook */
|
||||||
|
|
||||||
|
let title = translate[index].sheetName || index;
|
||||||
|
wb.SheetNames.push(title);
|
||||||
|
wb.Sheets[`${title}`] = ws;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary' });
|
||||||
|
|
||||||
|
var title = defaultTitle || '列表'
|
||||||
|
saveAs(new Blob([s2ab(wbout)], { type: "application/octet-stream" }), title + ".xlsx")
|
||||||
|
}
|
||||||
|
// 转换数据格式
|
||||||
|
function handelData(key) {
|
||||||
|
let tHeader = [];
|
||||||
|
let tHeaderF = [];
|
||||||
|
if (translate[key]) {
|
||||||
|
translate[key].columns.forEach(item => {
|
||||||
|
tHeader.push(item.tHeader);
|
||||||
|
tHeaderF.push(item.key);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let filterVal = {
|
||||||
|
tHeader: tHeader,
|
||||||
|
tHeaderF: tHeaderF,
|
||||||
|
};
|
||||||
|
return filterVal;
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
import { getPublishMapList, delPublishMap, getPublishMapExport, putMapOnLine, putMapOffLine } from '@/api/jmap/map';
|
import { getPublishMapList, delPublishMap, getPublishMapExport, putMapOnLine, putMapOffLine } from '@/api/jmap/map';
|
||||||
import { getSkinStyleList } from '@/api/management/mapskin';
|
import { getSkinStyleList } from '@/api/management/mapskin';
|
||||||
import { UrlConfig } from '@/router/index';
|
import { UrlConfig } from '@/router/index';
|
||||||
|
import deviceType from '@/jmap/constant/deviceType';
|
||||||
import localStore from 'storejs';
|
import localStore from 'storejs';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -68,7 +69,7 @@ export default {
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: '380',
|
width: '420',
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
name: '上架',
|
name: '上架',
|
||||||
@ -95,6 +96,11 @@ export default {
|
|||||||
{
|
{
|
||||||
name: '导出地图',
|
name: '导出地图',
|
||||||
handleClick: this.handleExportMap
|
handleClick: this.handleExportMap
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '导出',
|
||||||
|
handleClick: this.handleExportMapSame,
|
||||||
|
showControl: () => { return process.env.NODE_ENV === 'development'; }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -217,6 +223,24 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 部分导出
|
||||||
|
async handleExportMapSame(index, row) {
|
||||||
|
const res = await getPublishMapExport(row.id);
|
||||||
|
const resultData = res.data;
|
||||||
|
if (resultData === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
import('@/utils/Export2Excel').then(excel => {
|
||||||
|
self.queryExportDataSame(resultData).then(data => {
|
||||||
|
excel.export_json_excel(data, resultData.name);
|
||||||
|
}).catch(error => {
|
||||||
|
self.$message.error('导出执行异常:' + error.message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
formatJson(filterVal, jsonData) {
|
formatJson(filterVal, jsonData) {
|
||||||
return jsonData.map(v => filterVal.map(j => v[j]));
|
return jsonData.map(v => filterVal.map(j => v[j]));
|
||||||
},
|
},
|
||||||
@ -245,6 +269,101 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.base.push(obj);
|
||||||
|
resolve(result);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 格式化数据列表
|
||||||
|
queryExportDataSame(data) {
|
||||||
|
const mapProps = {};
|
||||||
|
const switchType = `${deviceType.Switch.toLowerCase()}List`;
|
||||||
|
const signalType = `${deviceType.Signal.toLowerCase()}List`;
|
||||||
|
const sectionType = `${deviceType.Section.toLowerCase()}List`;
|
||||||
|
|
||||||
|
mapProps[switchType] = {
|
||||||
|
filter: item => { return true; },
|
||||||
|
propList: {
|
||||||
|
'name': item =>{
|
||||||
|
return item.name;
|
||||||
|
},
|
||||||
|
'code': item => {
|
||||||
|
return item.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mapProps[signalType] = {
|
||||||
|
filter: item => { return true; },
|
||||||
|
propList: {
|
||||||
|
'name': item =>{
|
||||||
|
return item.name;
|
||||||
|
},
|
||||||
|
'code': item => {
|
||||||
|
return item.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mapProps[sectionType] = {
|
||||||
|
filter: item => { return item.type == '01'; },
|
||||||
|
propList: {
|
||||||
|
'name': (item, devices) =>{
|
||||||
|
let name = item.name;
|
||||||
|
if (item.isSwitchSection) {
|
||||||
|
const swchList = devices[switchType];
|
||||||
|
const swch = swchList.find(elem => { return item.relSwitchCode == elem.code; });
|
||||||
|
if (swch) {
|
||||||
|
if (item.code == swch.sectionACode) {
|
||||||
|
name = `${name} (${swch.name}-A)`;
|
||||||
|
} else if (item.code == swch.sectionBCode) {
|
||||||
|
name = `${name} (${swch.name}-B)`;
|
||||||
|
} else if (item.code == swch.sectionCCode) {
|
||||||
|
name = `${name} (${swch.name}-C)`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
},
|
||||||
|
'code': item => {
|
||||||
|
return item.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const result = {
|
||||||
|
base: []
|
||||||
|
};
|
||||||
|
const obj = {};
|
||||||
|
for (const i in data) {
|
||||||
|
if (i == 'devices') {
|
||||||
|
for (const v in data[i]) {
|
||||||
|
if (data[i][v].length) {
|
||||||
|
if (mapProps[v]) {
|
||||||
|
const list = [];
|
||||||
|
data[i][v].forEach(device => {
|
||||||
|
if (mapProps[v].filter(device)) {
|
||||||
|
const obj = {};
|
||||||
|
Object.keys(mapProps[v].propList || []).forEach(key => {
|
||||||
|
obj[key] = mapProps[v].propList[key](device, data[i]);
|
||||||
|
});
|
||||||
|
list.push(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result[v] = list;
|
||||||
|
}
|
||||||
|
} else if (v == 'skinVO') {
|
||||||
|
result[v] = [data[i][v]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (data[i] instanceof Object || typeof data[i] != 'object') {
|
||||||
|
obj[i] = data[i];
|
||||||
|
} else if (data[i] instanceof Array) {
|
||||||
|
if (data[i].length) {
|
||||||
|
obj[i] = [...data[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result.base.push(obj);
|
result.base.push(obj);
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
;
|
|
||||||
// import { getBasePathConfig } from '@/utils/baseUrl'
|
// import { getBasePathConfig } from '@/utils/baseUrl'
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
@ -13,7 +13,6 @@ function resolve(dir) {
|
|||||||
const name = defaultSettings.title; // page title
|
const name = defaultSettings.title; // page title
|
||||||
const port = 9527; // dev port
|
const port = 9527; // dev port
|
||||||
|
|
||||||
|
|
||||||
// All configuration item explanations can be find in https://cli.vuejs.org/config/
|
// All configuration item explanations can be find in https://cli.vuejs.org/config/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
/**
|
||||||
@ -143,6 +142,6 @@ module.exports = {
|
|||||||
config.optimization.runtimeChunk('single');
|
config.optimization.runtimeChunk('single');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user