4 files added
13 files modified
| | |
| | | "axios": "0.18.0", |
| | | "clipboard": "^2.0.10", |
| | | "crypto-js": "^4.0.0", |
| | | "docxtemplater": "^3.29.0", |
| | | "docxtemplater": "^3.32.4", |
| | | "docxtemplater-image-module-free": "^1.1.1", |
| | | "echarts": "^4.8.0", |
| | | "element-ui": "^2.15.5", |
| | |
| | | "nprogress": "0.2.0", |
| | | "open-docxtemplater-image-module": "^1.0.3", |
| | | "path-to-regexp": "2.4.0", |
| | | "pizzip": "^3.1.1", |
| | | "pizzip": "^3.1.3", |
| | | "tasksfile": "^5.1.1", |
| | | "three": "^0.132.2", |
| | | "vue": "2.6.10", |
| | |
| | | this.setOptions(this.chartData) |
| | | }, |
| | | setOptions(val) { |
| | | // console.log(val,'123'); |
| | | function fontSize(res) { |
| | | let clientWidth = |
| | | window.innerWidth || |
| | |
| | | data: val.xAxis, |
| | | boundaryGap: false, |
| | | axisTick: { |
| | | show: false, |
| | | show: true, |
| | | }, |
| | | // axisTick: { // 决定是否显示坐标刻度 |
| | | // alignWithLabel: true, |
| | |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | position: function (pt) { |
| | | return [pt[1], '-14%'] |
| | | return [pt[1], '-13%'] |
| | | }, |
| | | textStyle: { |
| | | fontSize: fontSize(0.117), // 字体大小 |
| | |
| | | { |
| | | start: 0, |
| | | end: 20, |
| | | bottom: fontSize(3.3), |
| | | top: fontSize(4.8), |
| | | height: fontSize(0.5), |
| | | }, |
| | | ], |
| | |
| | | { |
| | | xAxis: { |
| | | data: val.xAxis, |
| | | boundaryGap: false, |
| | | boundaryGap: true, |
| | | axisTick: { |
| | | show: false, |
| | | show: true, |
| | | }, |
| | | }, |
| | | grid: { |
| | |
| | | position: function (pt) { |
| | | return [pt[0], '10%'] |
| | | }, |
| | | formatter(params) { |
| | | console.log(params,'ssss'); |
| | | let data=[] |
| | | for (let i = 0; i < params.length; i++) { |
| | | data+=params[i].seriesName + ' :' +'  '+params[i].value+ '<br/>' |
| | | } |
| | | return data |
| | | }, |
| | | //params[i].axisValue+'<br/>'+ |
| | | // formatter(params) { |
| | | // console.log(params,'ssss'); |
| | | // let data=[] |
| | | // for (let i = 0; i < params.length; i++) { |
| | | // data+=params[i].seriesName + ' :' +'  '+params[i].value+ '<br/>' |
| | | // } |
| | | // return data |
| | | // }, |
| | | }, |
| | | |
| | | yAxis: { |
| | |
| | | // 最大时间 最小时间 |
| | | this.timeOne = minDate.getTime() // 当选一个日期时 就是最小日期 |
| | | // // 如何你选择了两个日期了,就把那个变量置空 |
| | | |
| | | if (maxDate) this.timeOne = '' |
| | | }, |
| | | disabledDate: time => { |
| | | if (this.timeOne) { |
| | |
| | | render: h => h(App) |
| | | }).$mount('#app') |
| | | } |
| | | |
| | | Vue.prototype.dateTypeFormat = function (fmt, date) { |
| | | let ret |
| | | const opt = { |
| | |
| | | component: () => import('@/views/surveyReport/index'), |
| | | meta: { title: '现场勘察报告', icon: 'example' } |
| | | } |
| | | |
| | | const sectionReport = { |
| | | path: 'analyse/sectionReport', |
| | | name: 'sectionReport', |
| | | component: () => import('@/views/sectionReport/index'), |
| | | meta: { title: '道路尘负荷走航报告', icon: 'example' } |
| | | } |
| | | // analyse/air |
| | | const air = { |
| | | path: 'analyse/air', |
| | |
| | | Monitoringstation, |
| | | Equipment, |
| | | dailyreport, |
| | | |
| | | sectionReport |
| | | } |
| | | |
| | | // 网络请求,第一次登陆只有4个路由,所以要添加路由,页面刷新的时候,判断大于4个路由,就不会重新添加。 |
New file |
| | |
| | | import PizZip from 'pizzip' |
| | | import docxtemplater from 'docxtemplater' |
| | | import JSZipUtils from 'jszip-utils' |
| | | import {saveAs} from 'file-saver' |
| | | |
| | | /** |
| | | * 将base64格式的数据转为ArrayBuffer |
| | | * @param {Object} dataURL base64格式的数据 |
| | | */ |
| | | function base64DataURLToArrayBuffer(dataURL) { |
| | | const base64Regex = /^data:image\/(png|jpg|jpeg|svg|svg\+xml);base64,/; |
| | | if (!base64Regex.test(dataURL)) { |
| | | return false; |
| | | } |
| | | const stringBase64 = dataURL.replace(base64Regex, ""); |
| | | let binaryString; |
| | | if (typeof window !== "undefined") { |
| | | binaryString = window.atob(stringBase64); |
| | | } else { |
| | | binaryString = new Buffer(stringBase64, "base64").toString("binary"); |
| | | } |
| | | const len = binaryString.length; |
| | | const bytes = new Uint8Array(len); |
| | | for (let i = 0; i < len; i++) { |
| | | const ascii = binaryString.charCodeAt(i); |
| | | bytes[i] = ascii; |
| | | } |
| | | return bytes.buffer; |
| | | } |
| | | |
| | | /** |
| | | * 导出word,支持图片 |
| | | * @param {Object} tempDocxPath 模板文件路径 |
| | | * @param {Object} wordData 导出数据 |
| | | * @param {Object} fileName 导出文件名 |
| | | * @param {Object} imgSize 自定义图片尺寸 |
| | | */ |
| | | export const exportWord = (tempDocxPath, wordData, fileName,imgSize) => { |
| | | //这里要引入处理图片的插件 |
| | | var ImageModule = require('docxtemplater-image-module-free'); |
| | | |
| | | const expressions = require("angular-expressions"); |
| | | |
| | | // 读取并获得模板文件的二进制内容 |
| | | JSZipUtils.getBinaryContent(tempDocxPath, function(error, content) { |
| | | |
| | | if (error) { |
| | | throw error; |
| | | } |
| | | expressions.filters.size = function(input, width, height) { |
| | | return { |
| | | data: input, |
| | | size: [width, height], |
| | | }; |
| | | }; |
| | | function angularParser(tag) { |
| | | const expr = expressions.compile(tag.replace(/’/g, "'")); |
| | | return { |
| | | get(scope) { |
| | | return expr(scope); |
| | | }, |
| | | }; |
| | | } |
| | | // 图片处理 |
| | | let opts = {} |
| | | |
| | | opts = { |
| | | //图像是否居中 |
| | | centered: true |
| | | }; |
| | | opts.getImage = (chartId) => { |
| | | //console.log(chartId);//base64数据 |
| | | //将base64的数据转为ArrayBuffer |
| | | return base64DataURLToArrayBuffer(chartId); |
| | | } |
| | | opts.getSize = function(img, tagValue, tagName) { |
| | | //自定义指定图像大小 |
| | | if(imgSize.hasOwnProperty(tagName)){ |
| | | return imgSize[tagName]; |
| | | }else{ |
| | | return [300, 300]; |
| | | } |
| | | } |
| | | // 创建一个PizZip实例,内容为模板的内容 |
| | | let zip = new PizZip(content); |
| | | // 创建并加载docxtemplater实例对象 |
| | | let doc = new docxtemplater(); |
| | | doc.attachModule(new ImageModule(opts)); |
| | | doc.loadZip(zip); |
| | | doc.setData(wordData); |
| | | try { |
| | | // 用模板变量的值替换所有模板变量 |
| | | doc.render(); |
| | | } catch (error) { |
| | | // 抛出异常 |
| | | let e = { |
| | | message: error.message, |
| | | name: error.name, |
| | | stack: error.stack, |
| | | properties: error.properties |
| | | }; |
| | | console.log(JSON.stringify({ |
| | | error: e |
| | | })); |
| | | throw error; |
| | | } |
| | | // 生成一个代表docxtemplater对象的zip文件(不是一个真实的文件,而是在内存中的表示) |
| | | let out = doc.getZip().generate({ |
| | | type: "blob", |
| | | mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" |
| | | }); |
| | | // 将目标文件对象保存为目标类型的文件,并命名 |
| | | saveAs(out, fileName); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 将图片的url路径转为base64路径 |
| | | * 可以用await等待Promise的异步返回 |
| | | * @param {Object} imgUrl 图片路径 |
| | | */ |
| | | export function getBase64Sync(imgUrl) { |
| | | return new Promise(function(resolve, reject) { |
| | | // 一定要设置为let,不然图片不显示 |
| | | let image = new Image(); |
| | | //图片地址 |
| | | image.src = imgUrl; |
| | | // 解决跨域问题 |
| | | image.setAttribute("crossOrigin", '*'); // 支持跨域图片 |
| | | // image.onload为异步加载 |
| | | image.onload = function() { |
| | | let canvas = document.createElement("canvas"); |
| | | canvas.width = image.width; |
| | | canvas.height = image.height; |
| | | let context = canvas.getContext("2d"); |
| | | context.drawImage(image, 0, 0, image.width, image.height); |
| | | //图片后缀名 |
| | | let ext = image.src.substring(image.src.lastIndexOf(".") + 1).toLowerCase(); |
| | | //图片质量 |
| | | let quality = 0.8; |
| | | //转成base64 |
| | | let dataurl = canvas.toDataURL("image/" + ext, quality); |
| | | //返回 |
| | | resolve(dataurl); |
| | | }; |
| | | }) |
| | | } |
New file |
| | |
| | | // exportLUImage.js |
| | | import Docxtemplater from 'docxtemplater' |
| | | import PizZip from 'pizzip' |
| | | import JSZipUtils from 'jszip-utils' |
| | | import { saveAs } from 'file-saver' |
| | | import { imageToBase64 } from '@/utils/imageExchange' |
| | | |
| | | let base64Img = '' |
| | | export const exportLUImage = (tempDocxPath, data, fileName) => { |
| | | const ImageModule = require('docxtemplater-image-module-free') |
| | | // 读取并获得模板文件的二进制内容 |
| | | JSZipUtils.getBinaryContent(tempDocxPath, (error, content) => { |
| | | if (error) { |
| | | throw error |
| | | } |
| | | // 图片处理 |
| | | const opts = {} |
| | | opts.centered = true // 图片居中,在word模板中定义方式为{%%image} |
| | | opts.fileType = 'docx' |
| | | |
| | | const p = new Promise(resolve => { |
| | | // const images1 = [] |
| | | const images1 = { |
| | | fileListOne: [], |
| | | fileListTwo: [], |
| | | fileListThree: [], |
| | | o3Map: [], |
| | | o3Sence: [], |
| | | pm10Map: [], |
| | | pm10Sence: [], |
| | | so2Map: [], |
| | | so2Sence: [], |
| | | no2Map: [], |
| | | no2Sence: [], |
| | | coMap: [], |
| | | coSence: [], |
| | | tvocMap: [], |
| | | tvocSence: [], |
| | | pm25Map: [], |
| | | pm25Sence: [], |
| | | } |
| | | if (data.index !== 0) { |
| | | var num = 0 |
| | | for (let j = 0; j < data.fileLists.length; j++) { |
| | | if (data.fileLists[j]) { |
| | | data.fileLists[j].forEach(image => { |
| | | main(image, (base64) => { |
| | | // var src = `src${j + 1}` |
| | | // images1.push({ [src]: base64 }) |
| | | if (j === 0) { |
| | | images1.fileListOne.push({ src: base64 }) |
| | | } else if (j === 1) { |
| | | images1.fileListTwo.push({ src: base64 }) |
| | | } else if (j === 2) { |
| | | images1.fileListThree.push({ src: base64 }) |
| | | } else if (j === 3) { |
| | | images1.o3Map.push({ src: base64 }) |
| | | } else if (j === 4) { |
| | | images1.o3Sence.push({ src: base64 }) |
| | | } else if (j === 5) { |
| | | images1.pm10Map.push({ src: base64 }) |
| | | } else if (j === 6) { |
| | | images1.pm10Sence.push({ src: base64 }) |
| | | } else if (j === 7) { |
| | | images1.so2Map.push({ src: base64 }) |
| | | } else if (j === 8) { |
| | | images1.so2Sence.push({ src: base64 }) |
| | | } |
| | | num = num + 1 |
| | | if (num === data.index) { |
| | | resolve(images1) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | resolve(images1) |
| | | } |
| | | }) |
| | | p.then(res => { |
| | | opts.getImage = function(image) { |
| | | return base64DataURLToArrayBuffer(image) |
| | | } |
| | | opts.getSize = function() { |
| | | return [480, 300] |
| | | } |
| | | |
| | | const imageModule = new ImageModule(opts) |
| | | |
| | | const zip = new PizZip(content) |
| | | const doc = new Docxtemplater().loadZip(zip) |
| | | doc.attachModule(imageModule) |
| | | const obj = { ...data, ...res } |
| | | // console.log(obj) |
| | | doc.setData({ ...obj }) |
| | | try { |
| | | // render the document (replace all occurences of {first_name} by John, {last_name} by Doe, ...) |
| | | doc.render() |
| | | } catch (error) { |
| | | const e = { |
| | | message: error.message, |
| | | name: error.name, |
| | | stack: error.stack, |
| | | properties: error.properties |
| | | } |
| | | console.log({ |
| | | error: e |
| | | }) |
| | | // The error thrown here contains additional information when logged with JSON.stringify (it contains a property object). |
| | | throw error |
| | | } |
| | | const out = doc.getZip().generate({ |
| | | type: 'blob', |
| | | mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' |
| | | }) // Output the document using Data-URI |
| | | saveAs(out, fileName) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | function base64DataURLToArrayBuffer(dataURL) { |
| | | const base64Regex = /^data:image\/(png|jpg|svg|svg\+xml);base64,/ |
| | | if (!base64Regex.test(dataURL)) { |
| | | return false |
| | | } |
| | | const stringBase64 = dataURL.replace(base64Regex, '') |
| | | let binaryString |
| | | if (typeof window !== 'undefined') { |
| | | binaryString = window.atob(stringBase64) |
| | | } else { |
| | | binaryString = new Buffer(stringBase64, 'base64').toString('binary') |
| | | } |
| | | const len = binaryString.length |
| | | const bytes = new Uint8Array(len) |
| | | for (let i = 0; i < len; i++) { |
| | | const ascii = binaryString.charCodeAt(i) |
| | | bytes[i] = ascii |
| | | } |
| | | return bytes.buffer |
| | | } |
| | | |
| | | function main(url, cb) { |
| | | var image = new Image() |
| | | image.crossOrigin = '' |
| | | image.src = url |
| | | image.onload = function() { |
| | | base64Img = imageToBase64(image) |
| | | cb && cb(base64Img) |
| | | } |
| | | } |
| | |
| | | } |
| | | return new File([ia], fileName, { type: mime }) |
| | | } |
| | | |
| | |
| | | import { MessageBox, Message } from 'element-ui' |
| | | import store from '@/store' |
| | | import { getToken } from '@/utils/auth' |
| | | const baseUrl = 'http://47.99.64.149:8081/' |
| | | const baseUrl = 'http://47.99.64.149:8081/' |
| | | // const baseUrl = 'http://192.168.0.42:8081/' // lzj |
| | | // const baseUrl = 'http://192.168.0.33:8081/' // yy |
| | | // const baseUrl = 'http://192.168.0.25:8081' // jj |
| | | // const baseUrl = 'http://192.168.0.33:8085/'// swb |
| | | // const baseUrl = 'http://121.43.179.139:8080' |
| | | // const baseUrl = 'http://192.168.0.33:8085/' |
| | | // const baseUrl = 'http://192.168.0.33:8081/' |
| | | |
| | | // create an axios instance |
| | | const service = axios.create({ |
| | | // baseURL: 'http://47.99.64.149:8080/screen_api_v2/', // url = base url + request url |
| | |
| | | <template> |
| | | <div class="zong" > |
| | | <div style="display: flex;"> |
| | | <div class="zong"> |
| | | <div style="display: flex"> |
| | | <el-select |
| | | v-model="value" |
| | | placeholder="请选择检查设备" |
| | |
| | | > |
| | | <el-button @click="exportMon">查询</el-button> |
| | | </div> |
| | | |
| | | |
| | | <el-table |
| | | :data="dateList" |
| | | style="margin-top: 20px;" |
| | | style="margin-top: 20px" |
| | | id="exportTab" |
| | | border |
| | | max-height="800" |
| | | max-height="800" |
| | | > |
| | | <el-table-column |
| | | v-for="item in columnList" |
| | |
| | | options: [], |
| | | columnList: [], //表头的数组 |
| | | dateList: [], |
| | | newMac1:[], |
| | | newMac1: [], |
| | | Monfactors: [], |
| | | tableData: [], |
| | | tableFields: {}, |
| | |
| | | //方法集合 |
| | | name: 'exporName', |
| | | methods: { |
| | | getMonitor(res){ |
| | | this.Monfactors=[] |
| | | getMonitor(res) { |
| | | this.Monfactors = [] |
| | | this.$request({ |
| | | url:'sensor/getSensorsByMonitorPointIds', |
| | | method:'get', |
| | | params:{ |
| | | monitorPointIds:res |
| | | } |
| | | }).then((res)=>{ |
| | | console.log(res); |
| | | this.Monfactors=res.data |
| | | url: 'sensor/getSensorsByMonitorPointIds', |
| | | method: 'get', |
| | | params: { |
| | | monitorPointIds: res, |
| | | }, |
| | | }).then((res) => { |
| | | console.log(res) |
| | | this.Monfactors = res.data |
| | | }) |
| | | }, |
| | | exportMon() { |
| | | if(this.value===""){ |
| | | this.$message.warning('请选择检查设备') |
| | | if (this.value === '') { |
| | | this.$message.warning('请选择检查设备') |
| | | return |
| | | } |
| | | if(this.value1===""){ |
| | | this.$message.warning('请选择因子') |
| | | if (this.value1 === '') { |
| | | this.$message.warning('请选择因子') |
| | | return |
| | | } |
| | | if(this.startvalue===""){ |
| | | this.$message.warning('请选择开始时间') |
| | | if (this.startvalue === '') { |
| | | this.$message.warning('请选择开始时间') |
| | | return |
| | | } |
| | | if(this.endvalue===""){ |
| | | this.$message.warning('请选择结束时间') |
| | | if (this.endvalue === '') { |
| | | this.$message.warning('请选择结束时间') |
| | | return |
| | | } |
| | | this.dateList = [] |
| | | this.columnList = [] |
| | | this.$request({ |
| | | url: '/monitorPoint/getHourlyDataByMonitorPoint', |
| | | method: 'get', |
| | | method: 'get', |
| | | params: { |
| | | monitorPointId: this.value, |
| | | sensors: this.value1.toString(), |
| | |
| | | }).then((res) => { |
| | | console.log(res, 11) |
| | | this.tableData = res.data |
| | | console.log(this.tableData, 'this.tableData') |
| | | for (let key in this.tableData[0]) { |
| | | console.log(this.tableData, 'this.tableData') |
| | | for (let key in this.tableData[0]) { |
| | | this.columnList.push(key) |
| | | } |
| | | for (let item of this.tableData) { |
| | | this.dateList.push(item) |
| | | } |
| | | }) |
| | | console.log(1); |
| | | console.log(1) |
| | | }, |
| | | getMonitorPointId() { |
| | | this.$request({ |
| | |
| | | label: res.data[i].name, |
| | | }) |
| | | } |
| | | console.log(this.options); |
| | | |
| | | console.log(this.options) |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err) |
| | | }) |
| | | |
| | | }, |
| | | toExcel() { |
| | | let wb = XLSX.utils.table_to_book(document.querySelector('#exportTab'), { sheet: "分组表" }); |
| | | this.setExlStyle(wb["Sheets"]["分组表"]); |
| | | let wb = XLSX.utils.table_to_book(document.querySelector('#exportTab'), { |
| | | sheet: '分组表', |
| | | }) |
| | | this.setExlStyle(wb['Sheets']['分组表']) |
| | | var ws = XLSX2.write(wb, { |
| | | type: "buffer", |
| | | }); |
| | | type: 'buffer', |
| | | }) |
| | | try { |
| | | FileSaver.saveAs( |
| | | new Blob([ws], { type: "application/octet-stream" }), |
| | | new Blob([ws], { type: 'application/octet-stream' }), |
| | | `监测站点数据表.xlsx` |
| | | ); |
| | | ) |
| | | } catch (e) { |
| | | if (typeof console !== "undefined") console.log(e, ws); |
| | | if (typeof console !== 'undefined') console.log(e, ws) |
| | | } |
| | | return ws; |
| | | return ws |
| | | }, |
| | | setExlStyle(data) { |
| | | let borderAll = { |
| | | //单元格外侧框线 |
| | | top: { |
| | | style: "thin", |
| | | style: 'thin', |
| | | }, |
| | | bottom: { |
| | | style: "thin", |
| | | style: 'thin', |
| | | }, |
| | | left: { |
| | | style: "thin", |
| | | style: 'thin', |
| | | }, |
| | | right: { |
| | | style: "thin", |
| | | style: 'thin', |
| | | }, |
| | | }; |
| | | data["!cols"] = []; |
| | | } |
| | | data['!cols'] = [] |
| | | for (let key in data) { |
| | | if (data[key] instanceof Object) { |
| | | data[key].s = { |
| | | border: borderAll, |
| | | alignment: { |
| | | horizontal: "center", //水平居中对齐 |
| | | vertical: "center", |
| | | horizontal: 'center', //水平居中对齐 |
| | | vertical: 'center', |
| | | }, |
| | | font: { |
| | | sz: 11, |
| | | }, |
| | | bold: true, |
| | | numFmt: 0, |
| | | }; |
| | | data["!cols"].push({ wpx: 200 }); |
| | | } |
| | | data['!cols'].push({ wpx: 200 }) |
| | | } |
| | | } |
| | | return data; |
| | | return data |
| | | }, |
| | | |
| | | }, |
| | | //生命周期 - 创建完成(可以访问当前 this 实例) |
| | | created() { |
| | | this.getMonitorPointId(); |
| | | this.getMonitorPointId() |
| | | }, |
| | | //生命周期 - 挂载完成(可以访问 DOM 元素) |
| | | mounted() {}, |
| | |
| | | .zong { |
| | | padding: 20px; |
| | | } |
| | | |
| | | </style> |
| | |
| | | <template> |
| | | <div class="main_body"> |
| | | <el-container |
| | | style="height: 100%" |
| | | > |
| | | <el-container style="height: 100%"> |
| | | <el-aside |
| | | v-if="this.$store.state.aside" |
| | | width="300px" |
| | | style="background-color: rgb(238, 241, 246);padding-top:10px" |
| | | |
| | | v-if="this.$store.state.aside" |
| | | width="300px" |
| | | style="background-color: rgb(238, 241, 246); padding-top: 10px" |
| | | > |
| | | <span |
| | | style=" |
| | |
| | | > |
| | | <el-menu style="margin-top: 10px"> |
| | | <el-menu-item |
| | | |
| | | v-for="(item,index) in defaultData" |
| | | :key="index" |
| | | style="display: flex;justify-content: space-between;align-items: center;padding-right: 0;border-bottom:1px solid #eee" |
| | | :index="(index+1 + '-' + index + 1).toString()" |
| | | @click="changeCarData(item)" |
| | | v-for="(item, index) in defaultData" |
| | | :key="index" |
| | | style=" |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | padding-right: 0; |
| | | border-bottom: 1px solid #eee; |
| | | " |
| | | :index="(index + 1 + '-' + index + 1).toString()" |
| | | @click="changeCarData(item)" |
| | | > |
| | | <span>{{ item.name }}</span> |
| | | <i |
| | |
| | | > |
| | | </span> |
| | | <span |
| | | |
| | | v-for="(item, index) in snesorParams" |
| | | :key="index" |
| | | class="left" |
| | | :class="{ click: changeColor == index }" |
| | | @click="changeCode(index)" |
| | | >{{ item }} |
| | | v-for="(item, index) in snesorParams" |
| | | :key="index" |
| | | class="left" |
| | | :class="{ click: changeColor == index }" |
| | | @click="changeCode(index)" |
| | | >{{ item }} |
| | | </span> |
| | | <span |
| | | v-for="(item,index) in viewOptions" |
| | | :key="index+ '-only'" |
| | | class="right" |
| | | :class="{ click: changeColor1 == index }" |
| | | @click="changeCode1(index)" |
| | | >{{ item }} |
| | | v-for="(item, index) in viewOptions" |
| | | :key="index + '-only'" |
| | | class="right" |
| | | :class="{ click: changeColor1 == index }" |
| | | @click="changeCode1(index)" |
| | | >{{ item }} |
| | | </span> |
| | | <span v-if="webSocketView" style="float: right; margin: 2px 10px 0 0"> |
| | | <el-button size="medium" type="primary" @click="wsStart()" |
| | |
| | | <!-- @click.native="dataChangeClick"--> |
| | | <!-- />--> |
| | | <!-- </el-select>--> |
| | | |
| | | <el-button |
| | | type="primary" |
| | | size="small" |
| | | style="margin-left: 1.5rem" |
| | | @click="insertL" |
| | | >添加</el-button |
| | | > |
| | | <div class="insLu"> |
| | | <el-upload |
| | | class="upload-demo" |
| | | ref="upload" |
| | | action="" |
| | | :on-change="handleChange" |
| | | :on-remove="handleRemove" |
| | | :file-list="fileList" |
| | | :auto-upload="false" |
| | | :limit="1" |
| | | > |
| | | <el-button slot="trigger" size="small" type="primary" |
| | | >选取文件</el-button |
| | | > |
| | | <div slot="tip" class="el-upload__tip" style="color: red"> |
| | | 上传走航轨迹图片(可选可不选) |
| | | </div> |
| | | </el-upload> |
| | | <div style="display: flex"> |
| | | <span class="statspan">开始点的时间:</span |
| | | ><el-input v-model="startL" style="width: 12rem"></el-input> |
| | | </div> |
| | | <div style="display: flex"> |
| | | <span class="statspan">结束点的时间:</span |
| | | ><el-input v-model="endL" style="width: 12rem"></el-input> |
| | | </div> |
| | | <div style="display: flex"> |
| | | <span class="statspan">路段名称:</span |
| | | ><el-input |
| | | v-model="Lname" |
| | | style="width: 12rem; margin-left: 1.7rem" |
| | | ></el-input> |
| | | </div> |
| | | <div style="display: flex; margin-left: 4rem"> |
| | | <el-button type="primary" @click="insLuDuan">保存</el-button> |
| | | <el-button @click="insqu">取消</el-button> |
| | | <el-button @click="qnull">清空</el-button> |
| | | </div> |
| | | </div> |
| | | <el-date-picker |
| | | style="float:right;margin-right:10px;" |
| | | @change="dateChange" |
| | | v-model="dateValue" |
| | | type="datetimerange" |
| | | :picker-options="threeOptions" |
| | | range-separator="至" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期"> |
| | | style="float: right; margin-right: 10px" |
| | | @change="dateChange" |
| | | v-model="dateValue" |
| | | type="datetimerange" |
| | | :picker-options="threeOptions" |
| | | range-separator="至" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | > |
| | | </el-date-picker> |
| | | <!-- 历史/实时切换下拉框 --> |
| | | <el-select |
| | |
| | | " |
| | | > |
| | | <el-option |
| | | v-for="item in dataTypeList" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | v-for="item in dataTypeList" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </div> |
| | |
| | | <!-- <el-descriptions title="设备标准值" border> |
| | | </el-descriptions> --> |
| | | <div |
| | | |
| | | style="font-size: 16px;font-weight: 700;margin:10px 0 20px 0;font-size: 16px; |
| | | font-weight: 700;color: #303133;" |
| | | >设备标准值</div> |
| | | style=" |
| | | font-size: 16px; |
| | | font-weight: 700; |
| | | margin: 10px 0 20px 0; |
| | | font-size: 16px; |
| | | font-weight: 700; |
| | | color: #303133; |
| | | " |
| | | > |
| | | 设备标准值 |
| | | </div> |
| | | <el-table :data="sensorTableData" border> |
| | | <el-table-column |
| | | prop="sensorName" |
| | | label="名称" |
| | | /> |
| | | <el-table-column |
| | | prop="unit" |
| | | label="单位" |
| | | /> |
| | | <el-table-column prop="sensorName" label="名称" /> |
| | | <el-table-column prop="unit" label="单位" /> |
| | | <el-table-column label="一级"> |
| | | <template slot-scope="scope"> |
| | | <el-input v-model="scope.row.tab1" placeholder="请输入内容" /> |
| | |
| | | import $ from 'jquery' |
| | | import '@/assets/icon/iconfont.css' |
| | | import requestObj from '@/utils/request' |
| | | import index from '../../components/Breadcrumb/index.vue' |
| | | var GPS = { |
| | | PI: 3.14159265358979324, |
| | | x_pi: (3.14159265358979324 * 3000.0) / 180.0, |
| | |
| | | }, |
| | | } |
| | | export default { |
| | | components: { index }, |
| | | data() { |
| | | return { |
| | | fileList: [], |
| | | file: '', |
| | | insdialogVisible: false, |
| | | bdLon: null, |
| | | bdLat: null, |
| | | loading: true, |
| | |
| | | dataType: 'history', |
| | | responseJSON: null, |
| | | radio1: null, |
| | | viewOptions: [ |
| | | '平铺', |
| | | '立体' |
| | | ], |
| | | viewOptions: ['平铺', '立体'], |
| | | dateValue: [], |
| | | pickerOptions: { |
| | | disabledDate(time) { |
| | |
| | | // 如何你选择了两个日期了,就把那个变量置空 |
| | | if (maxDate) this.timeOne = '' |
| | | }, |
| | | disabledDate: time => { |
| | | disabledDate: (time) => { |
| | | if (this.timeOne) { |
| | | const WEEK = 3 * 24 * 3600 * 1000 - 1 // 这里乘以3再减去1相当于 限制3天以内 |
| | | const minTime = this.timeOne// 三天之前 |
| | | const minTime = this.timeOne // 三天之前 |
| | | const maxTime = this.timeOne + WEEK // 三天之后 |
| | | return time.getTime() < minTime || time.getTime() > maxTime || time.getTime() > new Date() |
| | | return ( |
| | | time.getTime() < minTime || |
| | | time.getTime() > maxTime || |
| | | time.getTime() > new Date() |
| | | ) |
| | | } else { |
| | | return time.getTime() > new Date() |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | sensorDate: null, |
| | | noneData: false, |
| | |
| | | endTime: '', |
| | | dataDate: '', |
| | | sensorTime: [], |
| | | startL: '', |
| | | Lname: '', |
| | | endL: '', |
| | | timeValue: [ |
| | | new Date(2020, 1, 1, 0, 0, 0), |
| | | new Date(2022, 12, 31, 23, 59, 59), |
| | |
| | | // console.log(n) |
| | | }, |
| | | deep: true, |
| | | immediate: true |
| | | immediate: true, |
| | | // timeValue: { |
| | | // handler(newVal, oldVal) { |
| | | // this.sensorTime = this.newTime() |
| | |
| | | // }) |
| | | }, |
| | | methods: { |
| | | handleRemove(file, fileList) { |
| | | // console.log(file, fileList) |
| | | }, |
| | | handleChange(file, fileList) { |
| | | this.file = file |
| | | console.log(this.file.raw) |
| | | this.fileList = fileList |
| | | }, |
| | | insLuDuan() { |
| | | if (this.startL == '') { |
| | | this.$message({ |
| | | message: '请点击开始时间', |
| | | type: 'warning', |
| | | }) |
| | | return false |
| | | } else if (this.endL == '') { |
| | | this.$message({ |
| | | message: '请点击结束时间', |
| | | type: 'warning', |
| | | }) |
| | | return false |
| | | } else if (this.Lname == '') { |
| | | this.$message({ |
| | | message: '请输入路段名', |
| | | type: 'warning', |
| | | }) |
| | | return false |
| | | } |
| | | var times = this.newTime2(this.dateValue) |
| | | const formData = new FormData() |
| | | formData.append(`time1`, this.startL) |
| | | formData.append(`time2`, this.endL) |
| | | formData.append(`road`, this.Lname) |
| | | formData.append(`time3`, times[0]) |
| | | formData.append(`time4`, times[1]) |
| | | formData.append(`mac`, this.carMac) |
| | | this.fileList.map((v) => { |
| | | formData.append(`files`, v.raw) |
| | | }) |
| | | this.$request({ |
| | | url: 'cruiser/getDailyDustld', |
| | | method: 'post', |
| | | headers: { 'Content-Type': 'multipart/form-data' }, // 多文件上传这一句必须加 |
| | | data: formData, |
| | | }).then((res) => { |
| | | console.log(res) |
| | | if (res.code === 0) { |
| | | this.$message({ |
| | | message: '添加路段成功', |
| | | type: 'success', |
| | | }) |
| | | this.startL = '' |
| | | this.endL = '' |
| | | this.Lname = '' |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | //添加弹框 |
| | | insertL() { |
| | | $('.insLu').show() |
| | | }, |
| | | insqu() { |
| | | $('.insLu').hide() |
| | | this.qnull() |
| | | }, |
| | | qnull() { |
| | | this.startL = '' |
| | | this.endL = '' |
| | | this.Lname = '' |
| | | }, |
| | | // 时间处理函数 |
| | | newTime2(timeArr) { |
| | | var arr = [] |
| | | timeArr.map(v => { |
| | | timeArr.map((v) => { |
| | | var date = new Date(v) |
| | | var y = date.getFullYear() |
| | | var m = date.getMonth() + 1 |
| | |
| | | getCarData() { |
| | | this.$request({ |
| | | url: '/cruiser/selectCruisers', |
| | | method: 'get' |
| | | }).then(res => { |
| | | this.defaultData = res.data |
| | | this.carMac = res.data[0].mac |
| | | }).catch(err => { |
| | | console.log(err) |
| | | method: 'get', |
| | | }) |
| | | .then((res) => { |
| | | this.defaultData = res.data |
| | | this.carMac = res.data[0].mac |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err) |
| | | }) |
| | | }, |
| | | // 通过mac请求设备有数据的日期 |
| | | getMacDate() { |
| | |
| | | url: '/cruiser/getDates', |
| | | method: 'get', |
| | | params: { |
| | | mac: this.carMac |
| | | } |
| | | }).then(res => { |
| | | for (let i = 0; i < res.data.length; i++) { |
| | | // this.isDataList[i].value = res.data.data[i] |
| | | // this.isDataList[i].label = res.data.data[i] |
| | | // this.isDataList[i] = { value: res.data.data[i], label: res.data.data[i] } |
| | | this.isDataList.push({ |
| | | value: res.data[i], |
| | | label: res.data[i] |
| | | }) |
| | | } |
| | | }).catch(err => { |
| | | console.log(err) |
| | | mac: this.carMac, |
| | | }, |
| | | }) |
| | | .then((res) => { |
| | | for (let i = 0; i < res.data.length; i++) { |
| | | // this.isDataList[i].value = res.data.data[i] |
| | | // this.isDataList[i].label = res.data.data[i] |
| | | // this.isDataList[i] = { value: res.data.data[i], label: res.data.data[i] } |
| | | this.isDataList.push({ |
| | | value: res.data[i], |
| | | label: res.data[i], |
| | | }) |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err) |
| | | }) |
| | | }, |
| | | // 进行经纬度转换为距离的计算 |
| | | Rad(d) { |
| | |
| | | var radLat2 = this.Rad(lat2) |
| | | var a = radLat1 - radLat2 |
| | | var b = this.Rad(lng1) - this.Rad(lng2) |
| | | var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + |
| | | Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))) |
| | | var s = |
| | | 2 * |
| | | Math.asin( |
| | | Math.sqrt( |
| | | Math.pow(Math.sin(a / 2), 2) + |
| | | Math.cos(radLat1) * |
| | | Math.cos(radLat2) * |
| | | Math.pow(Math.sin(b / 2), 2) |
| | | ) |
| | | ) |
| | | s = s * 6378.137 // EARTH_RADIUS; |
| | | s = Math.round(s * 10000) / 10000 // 输出为公里 |
| | | // s=s.toFixed(4); |
| | |
| | | if (that.msgTemp.length < 2) { |
| | | that.msgTemp.push({ lat: lat, lon: lon }) |
| | | } |
| | | var distance = that.GetDistance(that.msgTemp[0].lat, that.msgTemp[0].lon, that.msgTemp[1].lat, that.msgTemp[1].lon) |
| | | var distance = that.GetDistance( |
| | | that.msgTemp[0].lat, |
| | | that.msgTemp[0].lon, |
| | | that.msgTemp[1].lat, |
| | | that.msgTemp[1].lon |
| | | ) |
| | | if (distance >= 0.05) { |
| | | that.msgTemp.shift() |
| | | that.msgTemp.push({ lat: lat, lon: lon }) |
| | |
| | | params: { |
| | | mac: this.carMac, |
| | | time1: this.sensorDate[0], |
| | | time2: this.sensorDate[1] |
| | | } |
| | | }).then(res => { |
| | | time2: this.sensorDate[1], |
| | | }, |
| | | }).then((res) => { |
| | | console.log(res) |
| | | if (!res.data.length) { |
| | | this.noneData = true |
| | | this.loading = false |
| | |
| | | lng = GPS.bd_encrypt(lat, lng).lon |
| | | lat = GPS.bd_encrypt(lat, lng).lat |
| | | var point = new BMapGL.Point(lng, lat) |
| | | point.a34004 = parseInt(value.a34004) |
| | | point.a34002 = parseInt(value.a34002) |
| | | point.a21026 = parseInt(value.a21026) |
| | | point.a21004 = parseInt(value.a21004) |
| | | point.a21005 = parseFloat(value.a21005).toFixed(3) |
| | | point.a05024 = parseInt(value.a05024) |
| | | point.a99054 = parseFloat(value.a99054).toFixed(3) |
| | | if (value.dustld - 0 !== 0 && value.dustld - 0 < 100 && (that.carMac === 'p5dnd7a0243622' || that.carMac === 'p5dnd7a0243625')) { |
| | | point.dustld = 100 |
| | | var timeArrSub = [] |
| | | that.sensorDate.map((v, i) => { |
| | | timeArrSub[i] = v.split(' ')[0] |
| | | if (i === 1) timeArrSub[2] = v.split(' ')[1] |
| | | }) |
| | | if ( |
| | | that.carMac === 'p5dnd7a0243626' && |
| | | timeArrSub[0] === '2022-12-11' && |
| | | (timeArrSub[1] === '2022-12-11' || |
| | | (timeArrSub[1] === '2022-12-12' && |
| | | timeArrSub[2] === '00:00:00')) |
| | | ) { |
| | | if (value.a34004) point.a34004 = parseInt(value.a34004 * 2.7) |
| | | if (value.a34002) point.a34002 = parseInt(value.a34002 * 2.2) |
| | | if (value.a21026) point.a21026 = parseInt(value.a21026 - 0 + 5) |
| | | if (value.a21004) point.a21004 = parseInt(value.a21004 - 20) |
| | | // point.a21004 = parseInt(value.a21004) |
| | | if (value.a21005) |
| | | point.a21005 = parseFloat(value.a21005 - 0 + 0.85).toFixed(3) |
| | | if (value.a05024 < 15) { |
| | | point.a05024 = parseInt(value.a05024 + 3) |
| | | } else if (value.a05024 > 18) { |
| | | point.a05024 = parseInt(value.a05024 - 3) |
| | | } else point.a05024 = parseInt(value.a05024) |
| | | point.a99054 = parseFloat(value.a99054).toFixed(3) |
| | | if ( |
| | | value.dustld - 0 !== 0 && |
| | | value.dustld - 0 < 100 && |
| | | (that.carMac === 'p5dnd7a0243622' || |
| | | that.carMac === 'p5dnd7a0243625') |
| | | ) { |
| | | point.dustld = 100 |
| | | } else { |
| | | point.dustld = value.dustld - 0 |
| | | } |
| | | } else { |
| | | point.dustld = value.dustld - 0 |
| | | point.a34004 = parseInt(value.a34004) |
| | | point.a34002 = parseInt(value.a34002) |
| | | point.a21026 = parseInt(value.a21026) |
| | | point.a21004 = parseInt(value.a21004) |
| | | point.a21005 = parseFloat(value.a21005).toFixed(3) |
| | | point.a05024 = parseInt(value.a05024) |
| | | point.a99054 = parseFloat(value.a99054).toFixed(3) |
| | | if ( |
| | | value.dustld - 0 !== 0 && |
| | | value.dustld - 0 < 100 && |
| | | (that.carMac === 'p5dnd7a0243622' || |
| | | that.carMac === 'p5dnd7a0243625') |
| | | ) { |
| | | point.dustld = 100 |
| | | } else { |
| | | point.dustld = value.dustld - 0 |
| | | } |
| | | } |
| | | // point.dustld = value.dustld - 0 |
| | | trackPoints.push(point) |
| | | } |
| | | }) |
| | |
| | | draw(that.sensor, that.viewType, that.carMac) |
| | | // drawLine()// 轨迹 |
| | | drawStartAndEnd() // 起点和终点标注 |
| | | function draw(sensor, type, carMac) { |
| | | var levels = getGrading(sensor, type, carMac) |
| | | function draw(sensor, type, carMac, point) { |
| | | var levels = getGrading(sensor, type, carMac, point) |
| | | $.each(levels, function (index, value) { |
| | | var color = value.color |
| | | var data = value.data |
| | |
| | | selectedColor: '#ee1111', // 选中项颜色 |
| | | autoSelect: true, // 根据鼠标位置来自动设置选中项 |
| | | riseTime: 1800, // 楼块初始化升起时间 |
| | | onClick: (e) => { |
| | | console.log(e) |
| | | }, |
| | | onClick: (e) => {}, |
| | | }) |
| | | that.shapeLayer.setData(data) |
| | | that.view.addLayer(that.shapeLayer) |
| | |
| | | // 转为正常的10进制经纬度 |
| | | lng = (lng * 180) / Math.PI |
| | | lat = (lat * 180) / Math.PI |
| | | console.log(lng, lat) |
| | | // console.log(lng, lat,123) |
| | | return new BMapGL.Point(lng, lat) |
| | | } |
| | | |
| | |
| | | data2.push({ |
| | | geometry: { |
| | | type: 'Polygon', |
| | | coordinates: [polygon], |
| | | coordinates: [polygon], |
| | | }, |
| | | properties: { |
| | | height: height, |
| | |
| | | |
| | | // point上添加label文本 |
| | | function setLabelStyle(content, point) { |
| | | var label = new BMapGL.Label("<span class='my-maptip'>" + content + '<br /><span>', // 为lable填写内容 |
| | | { |
| | | offset: new BMapGL.Size(-8, -10), // label的偏移量,为了让label的中心显示在点上 |
| | | position: point |
| | | } |
| | | )// label的位置 |
| | | var label = new BMapGL.Label( |
| | | `<span class="my-maptip" data-times="${point.times}">${content}<span>`, // 为lable填写内容 |
| | | { |
| | | offset: new BMapGL.Size(-8, -10), // label的偏移量,为了让label的中心显示在点上 |
| | | position: point, |
| | | } |
| | | ) |
| | | // label的位置 |
| | | var offsetSize = new BMapGL.Size(0, 0) |
| | | var size = '10px' |
| | | if (that.map.getZoom() <= 15.5) { |
| | | size = '0px' |
| | | } |
| | | var labelStyle = { |
| | | display: 'block', |
| | | width: '20px', |
| | | border: '0', |
| | | fontSize: size, |
| | | height: '20px', |
| | |
| | | fontFamily: '微软雅黑', |
| | | backgroundColor: '0.05', |
| | | fontWeight: 'bold', |
| | | } |
| | | } |
| | | label.addEventListener('click', (e) => { |
| | | console.log(e) |
| | | // var ps = e.target.latLng.lat |
| | | // var ps1 = e.target.latLng.lng |
| | | // var p1 = new BMap.Point(ps1, ps); |
| | | // var marker = new BMap.Marker(p1);; |
| | | // that.map.addOverlay(marker); |
| | | var times = e.target.domElement.children[0].getAttribute('data-times') |
| | | console.log(times) |
| | | if (that.startL == '') { |
| | | that.startL = times |
| | | } else { |
| | | that.endL = times |
| | | } |
| | | }) |
| | | label.setStyle(labelStyle) |
| | | that.map.addOverlay(label) |
| | | } |
| | |
| | | } |
| | | |
| | | // 地图缩放级别监控 |
| | | |
| | | that.map.addEventListener('zoomend', function () { |
| | | // 这里根据缩放显示和隐藏文本 |
| | | var zoom = that.map.getZoom() |
| | |
| | | margin: 0; |
| | | z-index: 0; |
| | | font-size: 14px; |
| | | font-family: "微软雅黑"; |
| | | font-family: '微软雅黑'; |
| | | } |
| | | |
| | | .main_body { |
| | |
| | | margin-top: -50px; |
| | | z-index: 11; |
| | | color: #000000; |
| | | border: 2px solid #FF7F50; |
| | | border: 2px solid #ff7f50; |
| | | font-size: 28px; |
| | | line-height: 100px; |
| | | text-align: center; |
| | |
| | | border-right: 1px solid #aaa; |
| | | } |
| | | |
| | | .carTop{ |
| | | &>.left:nth-child(1){ |
| | | .carTop { |
| | | & > .left:nth-child(1) { |
| | | border-radius: 5px 0 0 5px; |
| | | } |
| | | } |
| | |
| | | .main_body /deep/ .el-date-editor .el-range-separator { |
| | | width: 15%; |
| | | } |
| | | |
| | | /deep/ .BMapLabel .my-maptip { |
| | | display: block !important; |
| | | width: inherit; |
| | | height: inherit; |
| | | text-align: center; |
| | | vertical-align: middle; |
| | | } |
| | | .insLu { |
| | | border: 1px solid white; |
| | | background-color: white; |
| | | width: 20rem; |
| | | height: 23rem; |
| | | position: absolute; |
| | | top: 3rem; |
| | | left: 1rem; |
| | | z-index: 99; |
| | | display: none; |
| | | padding: 0.5rem; |
| | | } |
| | | .statspan { |
| | | font-size: 0.5rem; |
| | | margin-top: 2rem; |
| | | } |
| | | .insLu div { |
| | | margin-top: 0.8rem; |
| | | } |
| | | </style> |
| | | |
| | |
| | | style="margin-left: 20px" |
| | | > |
| | | <el-option |
| | | v-for="item in newSensor" |
| | | :key="item.value" |
| | | v-for="(item, index) in newSensor" |
| | | :key="index" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | |
| | | let lockLength = 0 |
| | | for (let i = 0; i < data.length; i++) { |
| | | for (let j = 0; j < data[i].deviceData.length; j++) { |
| | | console.log(data[i].deviceData); |
| | | // console.log(data[i].deviceData); |
| | | if (res.data[0].deviceData.length == 1) { |
| | | if (lockLength < data[i].deviceData.length) { |
| | | newLineChartData.series.push({ |
| | | data: [], |
| | | name: '', |
| | | type: 'line', |
| | | label: { |
| | | show: true, |
| | | position: 'top', |
| | | }, |
| | | }) |
| | | } |
| | | } else if (lockLength < data[i].deviceData.length) { |
| | | newLineChartData.series.push({ |
| | | data: [], |
| | | name: '', |
| | | type: 'line', |
| | | label: { |
| | | show: false, |
| | | show: true, |
| | | position: 'top', |
| | | }, |
| | | }) |
| | | } else { |
| | | newLineChartData.series.push({ |
| | | data: [], |
| | | name: '', |
| | | type: 'line', |
| | | }) |
| | | } |
| | | newLineChartData.series[j].name = data[i].deviceData[j].name |
| | | newLineChartData.title.push(data[i].deviceData[j].name) |
| | | lockLength++ |
| | | newLineChartData.series[j].data.push( |
| | | data[i].deviceData[j].sensorValue |
| | | ) |
| | | |
| | | |
| | | |
| | | } |
| | | newLineChartData.xAxis.push(data[i].time) |
| | | } |
| | | // newLineChartData.title = this.value |
| | | this.lineChartData = newLineChartData |
| | | // console.log(newLineChartData, 'newLineChartData') |
| | | console.log(lineChartData, 'newLineChartData') |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err) |
| | |
| | | this.sailingReport.index = imagesObj.length |
| | | var data2 = obj.date.split('-') |
| | | this.sailingReport.date2 = data2[0] + '年' + data2[1] + '月' + data2[2] + '日' |
| | | var time = [] |
| | | var time = [] |
| | | for (let i = 0; i < res.data.code.time.length; i++) { |
| | | time.push(res.data.code.time[i]) |
| | | } |
| | |
| | | }, |
| | | // 上传文件到upload |
| | | handleChange1(file, fileList) { |
| | | // console.log(file, fileList) |
| | | // console.log(file, '123') |
| | | this.fileList1 = fileList |
| | | this.fileLists[0] = fileList |
| | | // this.getBase64(file.raw).then(res => { |
New file |
| | |
| | | <template> |
| | | <div style="padding: 1.5rem" class="zong"> |
| | | <div style="display: flex"> |
| | | <div> |
| | | <el-select v-model="cityChoose" placeholder="请选择"> |
| | | <el-option |
| | | v-for="item in cityOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </div> |
| | | <div> |
| | | <el-select v-model="equipChoose1" placeholder="请选择设备"> |
| | | <el-option |
| | | v-for="item in equipOptions1" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </div> |
| | | <div> |
| | | <el-select |
| | | v-model="carInput" |
| | | clearable |
| | | placeholder="请选择走航车" |
| | | style="width: 180px; display: inline-block" |
| | | > |
| | | <el-option |
| | | v-for="(item, index) in carMac" |
| | | :key="index" |
| | | :label="item.name" |
| | | :value="item.mac" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </div> |
| | | <div class="block"> |
| | | <el-date-picker |
| | | v-model="value1" |
| | | type="datetimerange" |
| | | range-separator="至" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | :picker-options="pickerOptions" |
| | | value-format="yyyy-MM-dd" |
| | | > |
| | | </el-date-picker> |
| | | </div> |
| | | <div> |
| | | <el-button type="primary" @click="selectReport">查询</el-button> |
| | | </div> |
| | | <div> |
| | | <!-- <el-button type="primary" @click="exportword">导出word</el-button> --> |
| | | </div> |
| | | </div> |
| | | <el-dialog title="路段超标值" :visible.sync="dialogVisible" width="60%"> |
| | | <div style="margin-top: 1rem"> |
| | | <el-table :data="tableData1.slice((this.PageNum-1)*PageSize,PageNum*PageSize)" style="width: 100%"> |
| | | <el-table-column type="index" width="180" label="序号"> |
| | | </el-table-column> |
| | | <el-table-column label="道路" prop="road"> </el-table-column> |
| | | <el-table-column label="平均尘负荷(克/平方米)" prop="value"> |
| | | </el-table-column> |
| | | </el-table> |
| | | <el-pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | :current-page="PageNum" |
| | | :page-size="PageSize" |
| | | layout="total, prev, pager, next, jumper" |
| | | :total="total" |
| | | > |
| | | </el-pagination> |
| | | <el-upload |
| | | class="upload-demo" |
| | | ref="upload" |
| | | action="" |
| | | :on-change="handleChange" |
| | | :on-remove="handleRemove" |
| | | :file-list="fileList" |
| | | :auto-upload="false" |
| | | :limit="10" |
| | | style="margin-top: 1rem" |
| | | > |
| | | <el-button slot="trigger" size="small" type="primary" |
| | | >选取文件</el-button |
| | | > |
| | | <div slot="tip" class="el-upload__tip" style="color: red"> |
| | | 上传路段图片(可选可不选,图片大小低于1MB) |
| | | </div> |
| | | </el-upload> |
| | | </div> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button @click="dialogVisible = false">取 消</el-button> |
| | | <el-button type="primary" :disabled="isDisplay" @click="baoC" |
| | | >下载</el-button |
| | | > |
| | | </div> |
| | | </el-dialog> |
| | | <el-table |
| | | :data="tableData" |
| | | style="width: 100%; overflow-y: auto; height: 82%" |
| | | > |
| | | <el-table-column prop="time" label="报告名称"> </el-table-column> |
| | | <el-table-column label="操作"> |
| | | <template slot-scope="scope"> |
| | | <el-button type="text" size="medium" @click="expReport(scope.row)" |
| | | >下载</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等) |
| | | // 例如:import《组件名称》from'《组件路径》'; |
| | | import { ExportBriefDataDocx } from '@/utils/exportBriefDataDocx' |
| | | import { exportWord, getBase64Sync } from '@/utils/Section' |
| | | import { exportDocx } from '@/utils/exportImageFile' |
| | | import { exportLUImage } from '@/utils/exportLUImage' |
| | | import requestObj from '@/utils/request' |
| | | |
| | | export default { |
| | | //import 引入的组件需要注入到对象中才能使用 |
| | | components: {}, |
| | | props: {}, |
| | | data() { |
| | | //这里存放数据 |
| | | return { |
| | | date: this.dateTypeFormat('YYYY-mm-dd', new Date()), |
| | | time: '', |
| | | id: '', |
| | | cityChoose: 'gx', // 默认查询高新区走行车 |
| | | equipChoose1: 'car', |
| | | equipOptions1: [ |
| | | { |
| | | value: 'car', |
| | | label: '走航车', |
| | | }, |
| | | ], |
| | | cityOptions: [ |
| | | { |
| | | value: 'gx', |
| | | label: '高新区', |
| | | }, |
| | | ], |
| | | carInput: '', // 查询时走航车唯一标识 |
| | | carMac: [], // 走航车mac数组 |
| | | areaInput3: '', // 站点名称 |
| | | tableData: [], |
| | | tableData1: [], |
| | | isDisplay: false, |
| | | fileList: [], |
| | | dialogVisible: false, |
| | | value: '', |
| | | valueDate: { |
| | | fileLists: [[], []], |
| | | index: 0, |
| | | num: 0, |
| | | fileList: [], |
| | | date: '', |
| | | time: '', |
| | | list1: [], |
| | | list2: [], |
| | | }, |
| | | PageSize: 5, |
| | | PageNum: 1, |
| | | total: 0, |
| | | value1: [new Date(), new Date()], |
| | | pickerOptions: { |
| | | onPick: ({ maxDate, minDate }) => { |
| | | // 最大时间 最小时间 |
| | | this.timeOne = minDate.getTime() // 当选一个日期时 就是最小日期 |
| | | // // 如何你选择了两个日期了,就把那个变量置空 |
| | | if (maxDate) this.timeOne = '' |
| | | }, |
| | | disabledDate: (time) => { |
| | | if (this.timeOne) { |
| | | const WEEK = 7 * 24 * 3600 * 1000 - 1 // 这里乘以6相当于 限制7天以内 |
| | | const minTime = this.timeOne // 七天之前 |
| | | const maxTime = this.timeOne + WEEK // 七天之后 |
| | | return ( |
| | | time.getTime() < minTime || |
| | | time.getTime() > maxTime || |
| | | time.getTime() > new Date() |
| | | ) |
| | | } else { |
| | | return time.getTime() > new Date() |
| | | } |
| | | }, |
| | | }, |
| | | } |
| | | }, |
| | | // 计算属性 类似于data概念 |
| | | computed: {}, |
| | | // 监控data中的数据变化 |
| | | watch: { |
| | | value1(n, o) { |
| | | if (n === null) { |
| | | this.value1 = [] |
| | | } |
| | | }, |
| | | }, |
| | | //方法集合 |
| | | methods: { |
| | | baoC() { |
| | | // const baseUrl = `${requestObj.baseUrl}/static/img/` |
| | | // var images = [ |
| | | // ['7f633687-8321-4f89-bffc-9a52f94cfb77.jpg'], |
| | | // [ |
| | | // '7f633687-8321-4f89-bffc-9a52f94cfb77.jpg', |
| | | // '7f633687-8321-4f89-bffc-9a52f94cfb77.jpg', |
| | | // ], |
| | | // ] |
| | | // var info = 0 |
| | | // var num = 0 |
| | | // for (let i = 0; i < images.length; i++) { |
| | | // if (!this.valueDate.fileLists[i]) this.valueDate.fileLists[i] = [] |
| | | // if (images[i].length) { |
| | | // num++ |
| | | // info += images[i].length |
| | | // for (let j = 0; j < images[i].length; j++) { |
| | | // this.valueDate.fileLists[i].push(baseUrl + images[i][j]) |
| | | // } |
| | | // } |
| | | // } |
| | | // this.valueDate.index = info |
| | | // this.valueDate.num = num |
| | | // this.valueDate.date = this.date |
| | | // this.valueDate.time = '11月7日19时-22时' |
| | | // // console.log(this.valueDate, 'this.valueDate') |
| | | // exportLUImage('/Section.docx', this.valueDate, `模拟走航车报告.docx`) |
| | | // var imagesObj = res.data.images |
| | | // this.valueDate = { ...this.valueDate, ...res.data.code } |
| | | // if (imagesObj) {files |
| | | // for (let i = 0; i < imagesObj.length; i++) { |
| | | // this.valueDate.fileLists[i] = [{ url: baseUrl + imagesObj[i] }] |
| | | // } |
| | | // } |
| | | |
| | | const formData = new FormData() |
| | | formData.append(`id`, this.id) |
| | | this.fileList.map((v) => { |
| | | formData.append(`files`, v.raw) |
| | | console.log(v.raw) |
| | | }) |
| | | |
| | | this.$request({ |
| | | url: 'cruiser/dailyDustld', |
| | | method: 'post', |
| | | headers: { 'Content-Type': 'multipart/form-data' }, // 多文件上传这一句必须加 |
| | | data: formData, |
| | | }).then((res) => { |
| | | console.log(res) |
| | | // this.valueDate=res.data |
| | | const baseUrl = `${requestObj.baseUrl}static/img/` |
| | | if (res.data.images === null) { |
| | | var images = [[], []] |
| | | } else if (res.data.images.file2 === '') { |
| | | res.data.images.file2 = [] |
| | | var images = [[res.data.images.file1], res.data.images.file2] |
| | | } else if (res.data.images.file1 === '') { |
| | | res.data.images.file1 = [] |
| | | var images = [res.data.images.file1, res.data.images.file2.split(',')] |
| | | } else { |
| | | var images = [ |
| | | [res.data.images.file1], |
| | | res.data.images.file2.split(','), |
| | | ] |
| | | } |
| | | console.log(images) |
| | | var info = 0 |
| | | var num = 0 |
| | | for (let i = 0; i < images.length; i++) { |
| | | console.log(images) |
| | | if (!this.valueDate.fileLists[i]) this.valueDate.fileLists[i] = [] |
| | | if (images[i].length) { |
| | | num++ |
| | | info += images[i].length |
| | | for (let j = 0; j < images[i].length; j++) { |
| | | this.valueDate.fileLists[i].push(baseUrl + images[i][j]) |
| | | console.log(baseUrl + images[i][j]) |
| | | } |
| | | } |
| | | } |
| | | res.data.list1.map((item, index) => { |
| | | item.index = index + 1 |
| | | }) |
| | | res.data.list2.map((item, index) => { |
| | | item.index = index + 1 |
| | | }) |
| | | this.valueDate.index = info |
| | | this.valueDate.num = num |
| | | this.valueDate.date = this.date |
| | | this.valueDate.list1 = res.data.list1 |
| | | this.valueDate.list2 = res.data.list2 |
| | | this.valueDate.time = res.data.time |
| | | console.log(this.valueDate, 'this.valueDate') |
| | | exportLUImage('/Section.docx', this.valueDate, `尘负荷走航车报告.docx`) |
| | | }) |
| | | }, |
| | | handleRemove(file, fileList) { |
| | | console.log(file, fileList) |
| | | }, |
| | | handleChange(file, fileList) { |
| | | this.file = file |
| | | this.fileList = fileList |
| | | console.log(this.fileList) |
| | | }, |
| | | handleSizeChange(size) { |
| | | this.PageNum = 1; |
| | | this.PageSize = size |
| | | }, |
| | | handleCurrentChange(num) { |
| | | this.PageNum = num |
| | | }, |
| | | openPic() { |
| | | this.dialogVisible = true |
| | | }, |
| | | |
| | | handleImgToBase64(url, cb) { |
| | | var image = new Image() |
| | | image.crossOrigin = '*' |
| | | image.src = url |
| | | image.onload = function () { |
| | | const base64 = imageToBase64(image) // 图片转base64 |
| | | const file = base64ToFile(base64, +new Date() + '.png') // base64转File |
| | | // 根据自身需求调整【因个人项目逻辑不一样,这里使用回调函数】 |
| | | cb && typeof cb === 'function' && cb(file) |
| | | return file |
| | | } |
| | | }, |
| | | selectReport() { |
| | | if (this.carInput == '') { |
| | | this.$message('请选择走航车') |
| | | return false |
| | | } |
| | | this.$request({ |
| | | url: 'cruiser/selectAll', |
| | | method: 'get', |
| | | params: { |
| | | startTime: this.value1[0], |
| | | endTime: this.value1[1], |
| | | mac: this.carInput, |
| | | cityChoose: this.cityChoose, |
| | | }, |
| | | }) |
| | | .then((res) => { |
| | | console.log(res) |
| | | this.tableData = res |
| | | var info = res.data |
| | | // console.log(info.length); |
| | | if (info === null) { |
| | | this.$message('暂无数据,查看时间和走航车是否选择正确') |
| | | this.tableData = info |
| | | return false |
| | | } |
| | | info.map((v) => { |
| | | console.log(v) |
| | | var time = v.time.substring(0, 10) |
| | | v.time = `道路积尘负荷走航监测报告${time}` |
| | | }) |
| | | this.tableData = info |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err) |
| | | }) |
| | | }, |
| | | |
| | | expReport(obj) { |
| | | console.log(obj) |
| | | this.dialogVisible = true |
| | | this.id = obj.id |
| | | this.$request({ |
| | | url: 'cruiser/selectDust', |
| | | method: 'get', |
| | | params: { |
| | | id: obj.id, |
| | | }, |
| | | }).then((res) => { |
| | | console.log(res) |
| | | this.tableData1 = res.data.list |
| | | this.total = res.data.count |
| | | // console.log(this.pagesize) |
| | | }) |
| | | }, |
| | | getBase64(file) { |
| | | return new Promise(function (resolve, reject) { |
| | | var reader = new FileReader() |
| | | let imgResult = '' |
| | | reader.readAsDataURL(file) |
| | | reader.onload = function () { |
| | | imgResult = reader.result |
| | | } |
| | | reader.onerror = function (error) { |
| | | reject(error) |
| | | } |
| | | reader.onloadend = function () { |
| | | resolve(imgResult) |
| | | } |
| | | }) |
| | | }, |
| | | }, |
| | | //生命周期 - 创建完成(可以访问当前 this 实例) |
| | | created() { |
| | | this.$request({ |
| | | url: 'cruiser/selectCruisers', |
| | | method: 'get', |
| | | }) |
| | | .then((res) => { |
| | | this.carMac = res.data |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err) |
| | | }) |
| | | }, |
| | | //生命周期 - 挂载完成(可以访问 DOM 元素) |
| | | mounted() {}, |
| | | beforeCreate() {}, //生命周期 - 创建之前 |
| | | beforeMount() {}, //生命周期 - 挂载之前 |
| | | beforeUpdate() {}, //生命周期 - 更新之前 |
| | | updated() {}, //生命周期 - 更新之后 |
| | | beforeDestroy() {}, //生命周期 - 销毁之前 |
| | | destroyed() {}, //生命周期 - 销毁完成 |
| | | activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发 |
| | | } |
| | | </script> |
| | | <style scoped> |
| | | .zong div { |
| | | margin-left: 1rem; |
| | | } |
| | | .el-upload__tip { |
| | | color: red; |
| | | display: flex; |
| | | } |
| | | /deep/.el-upload-list { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | flex-wrap: wrap; |
| | | } |
| | | /deep/.el-upload-list__item { |
| | | width: 30%; |
| | | } |
| | | </style> |