Commit 889ff121 authored by yangkaiyi's avatar yangkaiyi

存档

parent 7eb1fa4a
...@@ -123,12 +123,12 @@ export default { ...@@ -123,12 +123,12 @@ export default {
] + ] +
"]" "]"
: ""), : ""),
messages[store.state.common.system.lang].map.popupMileage + // messages[store.state.common.system.lang].map.popupMileage +
":" + // ":" +
(attributes.todaytrip ? attributes.todaytrip : 0) + // (attributes.todaytrip ? attributes.todaytrip : 0) +
"/" + // "/" +
(attributes.trip ? attributes.trip : 0) + // (attributes.trip ? attributes.trip : 0) +
" km", // " km",
messages[store.state.common.system.lang].common.time + messages[store.state.common.system.lang].common.time +
":" + ":" +
this.dateFormat(device.position.time, "YYYY-MM-DD HH:mm:ss"), this.dateFormat(device.position.time, "YYYY-MM-DD HH:mm:ss"),
......
import { Message } from "element-ui"; import { Message, Notification } from "element-ui";
import util from "./util";
let token = ""; let token = "";
if (localStorage.user) { if (localStorage.user) {
...@@ -31,18 +32,56 @@ const ws = { ...@@ -31,18 +32,56 @@ const ws = {
} }
}; };
this.websocket.onmessage = function (evt) { this.websocket.onmessage = function (evt) {
console.log("evt", JSON.parse(evt.data));
if (evt.data) { if (evt.data) {
let socketMsg = JSON.parse(evt.data); let socketMsg = JSON.parse(evt.data);
if (socketMsg.positions) { if (socketMsg.positions) {
self.$store.dispatch("updateDevicePosition", socketMsg.positions); self.$store.dispatch("updateDevicePosition", socketMsg.positions);
} else if (socketMsg.devices) { } else if (socketMsg.devices) {
self.$store.dispatch("updateDeviceStatus", socketMsg.devices); self.$store.dispatch("updateDeviceStatus", socketMsg.devices);
const name =
self.$store.state.user.devices.list[
self.$store.state.user.devices.index[
socketMsg.devices[0].deviceId
]
].name;
let type;
try {
type = JSON.parse(socketMsg.devices[0].attributes).alarm;
} catch (e) {
type = socketMsg.devices[0].attributes.alarm;
}
const txt = {
sos: "求救报警",
idle: "静默报警",
vibration: "vibration",
powerOff: "断电,请及时查看",
powerCut: "断电,请及时查看",
lowBattery: "低电报警",
removing: "拆除报警",
fault: "fault",
};
Notification({
title: `${name} ${txt[type]}`,
message: util.dateFormat(
socketMsg.devices[0].time,
"YYYY-MM-DD HH:mm:ss"
),
duration: 0,
type: "warning",
});
} else if (socketMsg.commands) { } else if (socketMsg.commands) {
self.$store.dispatch("responseCommand", socketMsg.commands); self.$store.dispatch("responseCommand", socketMsg.commands);
} }
} }
}; };
this.websocket.onerror = function (evt) {}; this.websocket.onerror = function (evt) {};
// test代码
// let str = {
// data:
// '{"devices":[{"attributes":"{\\"alarm\\":\\"powerCut\\"}","deviceId":45,"id":45,"status":9,"time":1621495646355}]}',
// };
// this.websocket.onmessage(str);
}, },
reconnection: function (val) { reconnection: function (val) {
ws.connection = false; ws.connection = false;
......
This diff is collapsed.
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
> >
<el-option :key="-1" label="全部" :value="-1" /> <el-option :key="-1" label="全部" :value="-1" />
<el-option <el-option
v-for="item in $store.state.user.devices.list" v-for="(item, i) in $store.state.user.devices.list"
:key="item.id" :key="i"
:label="item.name" :label="item.name"
:value="item.id" :value="item.id"
> >
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
<el-select size="mini" v-model="typeId" placeholder="请类型" @change="init"> <el-select size="mini" v-model="typeId" placeholder="请类型" @change="init">
<el-option label="全部" :value="-1" /> <el-option label="全部" :value="-1" />
<el-option <el-option
v-for="item in eventTypes" v-for="(item, i) in eventTypes"
:key="item.id" :key="i"
:label="item.name" :label="item.name"
:value="item.id" :value="item.id"
> >
......
...@@ -155,71 +155,80 @@ ...@@ -155,71 +155,80 @@
:devices="selectDevices" :devices="selectDevices"
@visible="closeDialog" @visible="closeDialog"
></TransferDevice> ></TransferDevice>
<!-- 编辑 --> <!-- 新增、编辑弹窗 -->
<el-dialog <el-dialog
:title="`${isEdit ? '编辑' : '添加'}重要有害植物`" :title="`${isEdit ? '编辑' : '添加'}重要有害植物`"
:visible.sync="editDialogVisible" :visible.sync="editDialogVisible"
width="40%" width="50%"
> >
<el-form <el-row :gutter="20">
:model="editForm" <el-col :span="12">
ref="editFormRef" <el-form
label-width="100px" :model="editForm"
class="demo-ruleForm" ref="editFormRef"
> label-width="100px"
<!-- 新增、编辑弹窗 --> class="demo-ruleForm"
<el-form-item >
label="名称" <el-form-item
prop="name" label="名称"
:rules="[ prop="name"
{ :rules="[
required: true, {
message: '请输入有害植物名称', required: true,
trigger: ['blur', 'change'], message: '请输入有害植物名称',
}, trigger: ['blur', 'change'],
]" },
> ]"
<el-input >
v-model="editForm.name" <el-input
auto-complete="off" v-model="editForm.name"
:disabled="isEdit" auto-complete="off"
></el-input> :disabled="isEdit"
</el-form-item> ></el-input>
<el-form-item </el-form-item>
label="IMEI" <el-form-item
prop="imei" label="IMEI"
:rules="[ prop="imei"
{ :rules="[
required: true, {
message: '请输入IMEI', required: true,
trigger: ['blur', 'change'], message: '请输入IMEI',
}, trigger: ['blur', 'change'],
]" },
> ]"
<el-input v-model="editForm.imei" auto-complete="off"></el-input> >
</el-form-item> <el-input v-model="editForm.imei" auto-complete="off"></el-input>
<el-form-item label="报关号" prop="clearanceID"> </el-form-item>
<el-input <el-form-item label="报关号" prop="clearanceID">
v-model="editForm.clearanceID" <el-input
auto-complete="off" v-model="editForm.clearanceID"
></el-input> auto-complete="off"
</el-form-item> ></el-input>
<el-form-item label="来源国" prop="countryOfOrigin"> </el-form-item>
<el-input <el-form-item label="来源国" prop="countryOfOrigin">
v-model="editForm.countryOfOrigin" <el-input
auto-complete="off" v-model="editForm.countryOfOrigin"
></el-input> auto-complete="off"
</el-form-item> ></el-input>
<el-form-item label="携带有害生物" prop="carryPestName"> </el-form-item>
<el-input <el-form-item label="携带有害生物" prop="carryPestName">
v-model="editForm.carryPestName" <el-input
auto-complete="off" v-model="editForm.carryPestName"
></el-input> auto-complete="off"
</el-form-item> ></el-input>
<el-form-item label="备注" prop="remarks"> </el-form-item>
<el-input v-model="editForm.remarks"></el-input> <el-form-item label="备注" prop="remarks">
</el-form-item> <el-input v-model="editForm.remarks"></el-input>
</el-form> </el-form-item>
</el-form>
</el-col>
<el-col :span="12">
<GroupTree
@handleNodeClick="handleNodeClick"
:currentKey="editForm.groupId"
></GroupTree>
</el-col>
</el-row>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="editDialogVisible = false">取 消</el-button> <el-button @click="editDialogVisible = false">取 消</el-button>
...@@ -234,6 +243,7 @@ import moment from "moment"; ...@@ -234,6 +243,7 @@ import moment from "moment";
import util from "@/utils/util"; import util from "@/utils/util";
import InDevice from "./components/InDevice"; import InDevice from "./components/InDevice";
import TransferDevice from "./components/TransferDevice"; import TransferDevice from "./components/TransferDevice";
import GroupTree from "../map/components/menu/GroupTree";
import { import {
getAllDevices, getAllDevices,
getDevices, getDevices,
...@@ -307,6 +317,9 @@ export default { ...@@ -307,6 +317,9 @@ export default {
this.data = data; this.data = data;
}); });
}, },
handleNodeClick(node) {
this.editForm.groupId = node.id;
},
// 弹窗提交 // 弹窗提交
handlerSubmit() { handlerSubmit() {
this.$refs["editFormRef"].validate((valid) => { this.$refs["editFormRef"].validate((valid) => {
...@@ -478,6 +491,7 @@ export default { ...@@ -478,6 +491,7 @@ export default {
components: { components: {
InDevice, InDevice,
TransferDevice, TransferDevice,
GroupTree,
}, },
}; };
</script> </script>
......
...@@ -77,12 +77,12 @@ export const moduleUser = { ...@@ -77,12 +77,12 @@ export const moduleUser = {
enable: false, enable: false,
}, },
status: { status: {
0: "eventOffline", 0: "eventOffline", //上线
1: "eventOnline", 1: "eventOnline", //下线
2: "eventFenceEnter", 2: "eventFenceEnter", //进围栏
3: "eventFenceExit", 3: "eventFenceExit", //出围栏
4: "eventOverSpeed", 4: "eventOverSpeed", //超速
9: "eventAlarm", 9: "eventAlarm", //重要有害植物报警
}, //事件状态字典 }, //事件状态字典
alarms: { alarms: {
sos: "求救报警", sos: "求救报警",
...@@ -185,8 +185,8 @@ export const moduleUser = { ...@@ -185,8 +185,8 @@ export const moduleUser = {
userConfig: { userConfig: {
events: { events: {
0: false, 0: false,
1: true, 1: false,
2: true, 2: false,
3: true, 3: true,
4: true, 4: true,
5: false, 5: false,
......
...@@ -120,6 +120,7 @@ export default { ...@@ -120,6 +120,7 @@ export default {
); );
} }
if (state.user.userConfig.events[devstatus.status]) { if (state.user.userConfig.events[devstatus.status]) {
// TODO:需不需要提示?devstatus.status是配置什么
Notification({ Notification({
title: title:
state.user.devices.list[index].name + state.user.devices.list[index].name +
...@@ -129,8 +130,7 @@ export default { ...@@ -129,8 +130,7 @@ export default {
], ],
message: util.dateFormat(devstatus.time, "YYYY-MM-DD HH:mm:ss"), message: util.dateFormat(devstatus.time, "YYYY-MM-DD HH:mm:ss"),
type: devstatus.status == 1 ? "success" : "warning", type: devstatus.status == 1 ? "success" : "warning",
duration: 60000, duration: 0,
offset: 60,
}); });
state.user.playAlarmSound = true; state.user.playAlarmSound = true;
} }
......
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