Commit e63c5879 authored by 纪泽龙's avatar 纪泽龙

socket完成

parent e65747c5
...@@ -4,5 +4,6 @@ ENV = 'development' ...@@ -4,5 +4,6 @@ ENV = 'development'
# 燃气安全管理系统/开发环境 # 燃气安全管理系统/开发环境
VUE_APP_BASE_API = '/dev-api' VUE_APP_BASE_API = '/dev-api'
# 路由懒加载 # 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true VUE_CLI_BABEL_TRANSPILE_MODULES = true
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
<el-dialog <el-dialog
:title="title" :title="title"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
:before-close="handleClose" :before-close="handleClose">
>
<el-row> <el-row>
<el-form ref="form" :model="form" :rules="rules" label-width="135px"> <el-form ref="form" :model="form" :rules="rules" label-width="135px">
<el-row> <el-row>
...@@ -25,19 +24,13 @@ ...@@ -25,19 +24,13 @@
<el-row> <el-row>
<el-col :span="11"> <el-col :span="11">
<el-form-item label="设备名称" prop="deviceName"> <el-form-item label="设备名称" prop="deviceName">
<el-input <el-input v-model="form.deviceName" placeholder="请输入设备名称" />
v-model="form.deviceName"
placeholder="请输入设备名称"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="11"> <el-col :span="11">
<el-form-item label="设备型号" prop="deviceModel"> <el-form-item label="设备型号" prop="deviceModel">
<el-input <el-input v-model="form.deviceModel" placeholder="请输入设备型号" />
v-model="form.deviceModel"
placeholder="请输入设备型号"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
...@@ -56,7 +49,7 @@ ...@@ -56,7 +49,7 @@
<el-col :span="22"> <el-col :span="22">
<el-form-item label="经纬度坐标" prop=""> <el-form-item label="经纬度坐标" prop="">
<el-card shadow="newver" class="box-card"> <el-card class="box-card">
<div v-text="`[[${form.longitude},${form.latitude}]]`"></div> <div v-text="`[[${form.longitude},${form.latitude}]]`"></div>
</el-card> </el-card>
</el-form-item> </el-form-item>
...@@ -146,7 +139,35 @@ export default { ...@@ -146,7 +139,35 @@ export default {
dialogVisible: false, dialogVisible: false,
fileList: [], fileList: [],
// 表单校验 // 表单校验
rules: {}, rules: {
pipeCode: [
{ required: true, message: "请选择所属管道", trigger: "blur" },
// { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
],
deviceName: [
{ required: true, message: "请输入设备名称", trigger: "blur" },
],
deviceModel: [
{ required: true, message: "请输入设备型号", trigger: "blur" },
],
deviceAddr: [
{ required: true, message: "请输入所在地址", trigger: "blur" },
],
iotNo: [
{ required: true, message: "请输入物联网编号", trigger: "blur" },
],
linkman: [{ required: true, message: "请输入联系人", trigger: "blur" }],
phone: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
iconUrl: [{ required: true, message: "请上传图片", trigger: "change" }],
installationTime: [
{
// type: "date",
required: true,
message: "请选择日期",
trigger: "change",
},
],
},
map: null, map: null,
obj: null, obj: null,
gaoMap: null, gaoMap: null,
...@@ -202,19 +223,19 @@ export default { ...@@ -202,19 +223,19 @@ export default {
this.form.url = ""; this.form.url = "";
this.fileArr = []; this.fileArr = [];
}, },
getPipeInfos(){ getPipeInfos() {
pipeAllInfoList({}).then((response) => { pipeAllInfoList({}).then((response) => {
this.pipeList = response.data; this.pipeList = response.data;
}); });
}
}, },
watch:{ },
dialogVisible(val){ watch: {
if(val){ dialogVisible(val) {
if (val) {
this.getPipeInfos(); this.getPipeInfos();
} }
} },
} },
}; };
</script> </script>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import regulatorBox from "../components/PopWindow/regulatorBox.vue"; import regulatorBox from "../components/PopWindow/regulatorBox.vue";
import valveWell from "../components/PopWindow/valveWell.vue"; import valveWell from "../components/PopWindow/valveWell.vue";
import flowMeter from "../components/PopWindow/flowMeter.vue"; import flowMeter from "../components/PopWindow/flowMeter.vue";
import pressureGage from "../components/PopWindow/pressureGage.vue";
import pipelineView from "../components/PopWindow/pipelineView.vue"; import pipelineView from "../components/PopWindow/pipelineView.vue";
import lineInfoWindow from "../components/PopWindow/lineInfoWindow.vue"; import lineInfoWindow from "../components/PopWindow/lineInfoWindow.vue";
import { delDeviceInfo } from "@/api/device/deviceInfo"; import { delDeviceInfo } from "@/api/device/deviceInfo";
...@@ -816,7 +817,7 @@ class gaodeMap { ...@@ -816,7 +817,7 @@ class gaodeMap {
}); });
} }
case DEVICE_TYPE.PRESSUREGAGE: { case DEVICE_TYPE.PRESSUREGAGE: {
return createPop(flowMeter, { return createPop(pressureGage, {
title: val+ "压力表" title: val+ "压力表"
}); });
} }
......
...@@ -328,7 +328,12 @@ class gaodeMap { ...@@ -328,7 +328,12 @@ class gaodeMap {
function infoOpen(e) { function infoOpen(e) {
if (e.target.getExtData().alarmState == 1) { if (e.target.getExtData().alarmState == 1) {
that.markerType = e.target.getExtData().deviceType; if(e.target.getExtData().deviceType==4){
that.markerType = "7";
}else if(e.target.getExtData().deviceType<=3){
that.markerType = +e.target.getExtData().deviceType+1+"";
}
console.log("that.markerType",that.markerType )
// 警告状态这样就要换infowindow // 警告状态这样就要换infowindow
e.target.content = that.getMarketContent( e.target.content = that.getMarketContent(
e.target.getExtData(), e.target.getExtData(),
...@@ -336,11 +341,17 @@ class gaodeMap { ...@@ -336,11 +341,17 @@ class gaodeMap {
); );
} else { } else {
// 初始化为1的时候是没有的,所以需要判断一下 // 初始化为1的时候是没有的,所以需要判断一下
that.markerType = // that.markerType =
e.target.getExtData().deviceType + "" == 1 // e.target.getExtData().deviceType + "" == 1
? "2" // ? "2"
: e.target.getExtData().deviceType + ""; // : e.target.getExtData().deviceType + "";
console.log(typeof e.target.getExtData().deviceType); // 上图状态跟后台状态不统一,所以需要判断一下
if(e.target.getExtData().deviceType==4){
that.markerType = "7";
}else if(e.target.getExtData().deviceType<=3){
that.markerType = +e.target.getExtData().deviceType+1+"";
}
console.log("that.markerType")
e.target.content = that.getMarketContent( e.target.content = that.getMarketContent(
e.target.getExtData(), e.target.getExtData(),
markerInfoWindow markerInfoWindow
...@@ -474,6 +485,7 @@ class gaodeMap { ...@@ -474,6 +485,7 @@ class gaodeMap {
* @param marker * @param marker
*/ */
setMarkerIcon(marker) { setMarkerIcon(marker) {
console.log(this.markerType)
switch (this.markerType) { switch (this.markerType) {
case DEVICE_TYPE.REGEULATORBOX: { case DEVICE_TYPE.REGEULATORBOX: {
let icon = new AMap.Icon({ let icon = new AMap.Icon({
...@@ -763,6 +775,7 @@ class gaodeMap { ...@@ -763,6 +775,7 @@ class gaodeMap {
// const // const
}); });
polyline.on("mouseout", e => { polyline.on("mouseout", e => {
// console.log("polyline.getExtData().lineData.alarmState",polyline.getExtData().lineData.alarmState)
if (polyline.getExtData().lineData.alarmState == 1) return; if (polyline.getExtData().lineData.alarmState == 1) return;
polyline.setOptions({ strokeColor: "#F7FE38" }); polyline.setOptions({ strokeColor: "#F7FE38" });
// infoWindow.close(); // infoWindow.close();
......
...@@ -307,9 +307,9 @@ export default { ...@@ -307,9 +307,9 @@ export default {
getSelectAlarmDevice() { getSelectAlarmDevice() {
selectAlarmDevice().then((res) => { selectAlarmDevice().then((res) => {
if (res.length > 0) { if (res.length > 0) {
}
console.log("报警设备", res); console.log("报警设备", res);
this.statusChange(res); this.statusChange(res);
}
}); });
}, },
// 遍历设备改变状态 polyLines markers // 遍历设备改变状态 polyLines markers
...@@ -327,24 +327,33 @@ export default { ...@@ -327,24 +327,33 @@ export default {
polyLineArr.forEach((item) => { polyLineArr.forEach((item) => {
// 获取循报警设备的id // 获取循报警设备的id
const { deviceId, alarmType, alarmValue, endTime } = item; const { deviceId, alarmType, alarmValue, endTime } = item;
console.log("endTime", endTime);
// 获取polyLine // 获取polyLine
const polyline = this.gaoMap.polyLines.filter((item) => { const polyline = this.gaoMap.polyLines.filter((item) => {
const pipeId = item.getExtData().lineData.pipeId; const pipeId = item.getExtData().lineData.pipeId;
return deviceId == pipeId; return deviceId == pipeId;
})[0]; })[0];
polyline.setOptions({ strokeColor: "#ff0000" }); let options = polyline.getExtData();
const options = polyline.getExtData();
// 增加一个报警状态 // 增加一个报警状态
// 如果有endtime说明状态已经不是报警状态了,要归位,所有东西都要变回来 // 如果有endtime说明状态已经不是报警状态了,要归位,所有东西都要变回来
if (endTime) { if (endTime) {
polyline.setOptions({ strokeColor: "#F7FE38" });
options.lineData.alarmState = 0; options.lineData.alarmState = 0;
// 报警类型
options.lineData.alarmType = null;
// 报警信息
options.lineData.alarmValue = null;
console.log("管道回复");
} else { } else {
polyline.setOptions({ strokeColor: "#ff0000" });
options.lineData.alarmState = 1; options.lineData.alarmState = 1;
}
// 报警类型 // 报警类型
options.lineData.alarmType = alarmType; options.lineData.alarmType = alarmType;
// 报警信息 // 报警信息
options.lineData.alarmValue = alarmValue; options.lineData.alarmValue = alarmValue;
console.log("管道报警");
}
polyline.setExtData(options); polyline.setExtData(options);
}); });
} }
...@@ -354,6 +363,7 @@ export default { ...@@ -354,6 +363,7 @@ export default {
deviceArr.forEach((item) => { deviceArr.forEach((item) => {
// 获取循报警设备的id // 获取循报警设备的id
const { deviceId, alarmType, alarmValue, endTime } = item; const { deviceId, alarmType, alarmValue, endTime } = item;
console.log("endTime", endTime);
// 获取polyLine // 获取polyLine
const device = this.gaoMap.markers.filter((item) => { const device = this.gaoMap.markers.filter((item) => {
const id = item.getExtData().deviceId; const id = item.getExtData().deviceId;
...@@ -365,57 +375,82 @@ export default { ...@@ -365,57 +375,82 @@ export default {
// 增加一个报警状态 // 增加一个报警状态
// 如果有endtime说明状态已经不是报警状态了,要归位,所有东西都要变回来 // 如果有endtime说明状态已经不是报警状态了,要归位,所有东西都要变回来
if (endTime) { if (endTime) {
options.lineData.alarmState = 0; console.log("设备恢复");
options.alarmState = 0;
// 报警类型
options.alarmType = null;
// 报警信息
options.alarmValue = null;
} else { } else {
options.lineData.alarmState = 1; console.log("设备报警");
} options.alarmState = 1;
// 报警类型 // 报警类型
options.alarmType = alarmType; options.alarmType = alarmType;
// 报警信息 // 报警信息
options.alarmValue = alarmValue; options.alarmValue = alarmValue;
}
device.setExtData(options); device.setExtData(options);
// const imageName = device.getExtData() // const imageName = device.getExtData()
// console.log(imageName) // console.log(imageName)
console.log(
"device.getExtData().deviceType============",
device.getExtData().deviceType
);
// 3是流量计 4是压力表 // 3是流量计 4是压力表
if (device.getExtData().deviceType == 3) { if (device.getExtData().deviceType == 3) {
// 如果有endtime说明已经维护好了
if (endTime) {
this.gaoMap.changeMarkIcon(
device,
require(`@/assets/images/liuliangji.png`)
);
} else {
this.gaoMap.changeMarkIcon( this.gaoMap.changeMarkIcon(
device, device,
require(`@/assets/images/lljWran.png`) require(`@/assets/images/lljWran.png`)
); );
}
} else if (device.getExtData().deviceType == 4) { } else if (device.getExtData().deviceType == 4) {
if (endTime) {
this.gaoMap.changeMarkIcon(
device,
require(`@/assets/images/yalibiao.png`)
);
} else {
this.gaoMap.changeMarkIcon( this.gaoMap.changeMarkIcon(
device, device,
require(`@/assets/images/ylbWran.png`) require(`@/assets/images/ylbWran.png`)
); );
} }
}
}); });
} }
if (this.ws) return;
this.socket(); this.socket();
}, },
socket() { socket() {
this.ws = new WebSocket("ws://36.148.23.59:8901/gassafety/websocketServer"); console.log("socket执行");
this.ws = new WebSocket(
"ws://36.148.23.59:8901/gassafety/websocketServer"
);
// this.ws = new WebSocket( // this.ws = new WebSocket(
// "ws://192.168.2.23:8903/gassafety/websocketServer" // "ws://192.168.2.23:8903/gassafety/websocketServer"
// ); // );
this.ws.onopen = (evt) => { this.ws.onopen = (evt) => {
console.log("WebSockets=======gogogog"); console.log("WebSockets=======gogogog");
this.ws.send("WebSockets!========================="); // this.ws.send("WebSockets!=========================");
}; };
this.ws.onmessage = (evt) => { this.ws.onmessage = (evt) => {
console.log("Received Message: " + evt.data); console.log("推送", evt);
// console.log("Received Message: " + evt.data);
// ws.close(); // ws.close();
this.statusChange([evt.data]); const obj = JSON.parse(evt.data);
this.statusChange([obj]);
}; };
this.ws.onclose = () => { this.ws.onclose = () => {
console.log("ws协议关闭"); console.log("ws协议关闭");
}; };
// this.ws.onclose = function (evt) { this.ws.onclose = function (evt) {
// console.log("Connection closed."); console.log("关闭");
// }; };
}, },
// 选择新建项目哪个 // 选择新建项目哪个
...@@ -625,7 +660,10 @@ export default { ...@@ -625,7 +660,10 @@ export default {
console.log("移除window事件"); console.log("移除window事件");
window.removeEventListener("click", this.barClose); window.removeEventListener("click", this.barClose);
// 关闭scoket // 关闭scoket
if (this.ws) {
this.ws.close(); this.ws.close();
this.ws=null;
}
}, },
}; };
</script> </script>
......
'use strict' "use strict";
const path = require('path') const path = require("path");
const defaultSettings = require('./src/settings.js') const defaultSettings = require("./src/settings.js");
function resolve(dir) { function resolve(dir) {
return path.join(__dirname, dir) return path.join(__dirname, dir);
} }
const name = defaultSettings.title || '燃气安全管理系统' // 标题 const name = defaultSettings.title || "燃气安全管理系统"; // 标题
const port = process.env.port || process.env.npm_config_port || 80 // 端口 const port = process.env.port || process.env.npm_config_port || 80; // 端口
// vue.config.js 配置说明 // vue.config.js 配置说明
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions //官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
...@@ -18,104 +18,113 @@ module.exports = { ...@@ -18,104 +18,113 @@ module.exports = {
// 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
publicPath: process.env.NODE_ENV === "production" ? "/" : "/", publicPath: process.env.NODE_ENV === "production" ? "/" : "/",
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
outputDir: 'dist', outputDir: "dist",
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
assetsDir: 'static', assetsDir: "static",
// 是否开启eslint保存检测,有效值:ture | false | 'error' // 是否开启eslint保存检测,有效值:ture | false | 'error'
lintOnSave: process.env.NODE_ENV === 'development', lintOnSave: process.env.NODE_ENV === "development",
// 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。 // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
productionSourceMap: false, productionSourceMap: false,
// webpack-dev-server 相关配置 // webpack-dev-server 相关配置
devServer: { devServer: {
host: '0.0.0.0', host: "0.0.0.0",
port: port, port: port,
open: true, open: true,
proxy: { proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
// target: `http://36.148.23.59:8901/gassafety`,
target: `http://36.148.23.59:8901/gassafety`, target: `http://36.148.23.59:8901/gassafety`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ["^" + process.env.VUE_APP_BASE_API]: ""
}
} }
}, },
// "/websocket": {
// target: "ws://192.168.2.23:8903/gassafety/websocketServer",
// ws: true,
// changeOrigin: true,
// logLevel: "debug",
// secure: false,
// pathRewrite: {
// "^/websocket": ""
// }
// }
},
disableHostCheck: true disableHostCheck: true
}, },
configureWebpack: { configureWebpack: {
name: name, name: name,
resolve: { resolve: {
alias: { alias: {
'@': resolve('src'), "@": resolve("src"),
'utils' : resolve('src/utils') utils: resolve("src/utils")
} }
}, },
externals: { externals: {
'AMap': 'AMap' AMap: "AMap"
} }
}, },
chainWebpack(config) { chainWebpack(config) {
config.plugins.delete('preload') // TODO: need test config.plugins.delete("preload"); // TODO: need test
config.plugins.delete('prefetch') // TODO: need test config.plugins.delete("prefetch"); // TODO: need test
// set svg-sprite-loader // set svg-sprite-loader
config.module config.module
.rule('svg') .rule("svg")
.exclude.add(resolve('src/assets/icons')) .exclude.add(resolve("src/assets/icons"))
.end() .end();
config.module config.module
.rule('icons') .rule("icons")
.test(/\.svg$/) .test(/\.svg$/)
.include.add(resolve('src/assets/icons')) .include.add(resolve("src/assets/icons"))
.end() .end()
.use('svg-sprite-loader') .use("svg-sprite-loader")
.loader('svg-sprite-loader') .loader("svg-sprite-loader")
.options({ .options({
symbolId: 'icon-[name]' symbolId: "icon-[name]"
}) })
.end() .end();
config.when(process.env.NODE_ENV !== "development", config => {
config config
.when(process.env.NODE_ENV !== 'development', .plugin("ScriptExtHtmlWebpackPlugin")
config => { .after("html")
config .use("script-ext-html-webpack-plugin", [
.plugin('ScriptExtHtmlWebpackPlugin') {
.after('html')
.use('script-ext-html-webpack-plugin', [{
// `runtime` must same as runtimeChunk name. default is `runtime` // `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/ inline: /runtime\..*\.js$/
}]) }
.end() ])
config .end();
.optimization.splitChunks({ config.optimization.splitChunks({
chunks: 'all', chunks: "all",
cacheGroups: { cacheGroups: {
libs: { libs: {
name: 'chunk-libs', name: "chunk-libs",
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
priority: 10, priority: 10,
chunks: 'initial' // only package third parties that are initially dependent chunks: "initial" // only package third parties that are initially dependent
}, },
elementUI: { elementUI: {
name: 'chunk-elementUI', // split elementUI into a single package name: "chunk-elementUI", // split elementUI into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
}, },
commons: { commons: {
name: 'chunk-commons', name: "chunk-commons",
test: resolve('src/components'), // can customize your rules test: resolve("src/components"), // can customize your rules
minChunks: 3, // minimum common number minChunks: 3, // minimum common number
priority: 5, priority: 5,
reuseExistingChunk: true reuseExistingChunk: true
} }
} }
}) });
config.optimization.runtimeChunk('single'), config.optimization.runtimeChunk("single"),
{ {
from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件 from: path.resolve(__dirname, "./public/robots.txt"), //防爬虫文件
to: './', //到根目录下 to: "./" //到根目录下
};
});
} }
} };
)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment