-
+
+
编号
+
{{ item.deviceNo || ''}}
+
@@ -206,19 +119,36 @@ import createEditDialog from './createEditDialog.vue'
import 'swiper/css'
import { formatter } from 'element-plus'
+import { DICT_TYPE, getDictOptions } from '@/utils/dict'
+// DEVICE_TYPE
const router = useRouter() // 路由对象
const createEditDialogRef = ref(null)
const list = ref([])
const queryParams = reactive({
pageNo: 1,
pageSize: 100,
- robotNo: undefined
+ deviceNo: undefined,
+ deviceType: undefined
})
const spaceBetween = ref(20)
const navigation = ref({
nextEl: '.swiper-button-next-custome',
prevEl: '.swiper-button-prev-custome'
})
+const activeName = ref('-1')
+const handleClick = (tab, event) => {
+ console.log(tab, event)
+ queryParams.deviceType = tab.props.name !=-1?tab.props.name:undefined
+ getCarList()
+}
+const typeList = ref([])
+
+const getTypeList = () => {
+ typeList.value = getDictOptions(DICT_TYPE.DEVICE_TYPE)&&getDictOptions(DICT_TYPE.DEVICE_TYPE).length?JSON.parse(JSON.stringify(getDictOptions(DICT_TYPE.DEVICE_TYPE))):[]
+ console.log(typeList.value)
+ typeList.value.unshift({ label: '全部', value: '-1' })
+ getRobotInformationStatistics()
+}
// 在modules加入要使用的模块
const modules = [Autoplay, Navigation, Scrollbar]
// Pagination
@@ -233,6 +163,17 @@ const onSlideChange = (swiper) => {
// swiper是当前轮播的对象,里面可以获取到当前swiper的所有信息,当前索引是activeIndex
console.log(swiper.activeIndex)
}
+//根据type和列表返回对应中文
+const filterTypeFun = (type, list) => {
+ if (list.length) {
+ let obj = list.find(item => {
+ return item.value == type
+ })
+ return obj == undefined ? type : obj.label
+ } else {
+ return type
+ }
+}
// (1:充电桩,2:输送线,3:码垛机,4:自动门,5:提升机,6:信号灯,7:按钮盒,8:拆垛机)
const formatterDeviceType = (deviceType) => {
switch (deviceType) {
@@ -254,60 +195,18 @@ const formatterDeviceType = (deviceType) => {
return '拆垛机'
}
}
-const topList = ref([
- {
- name: '总数',
- count: 0,
- id: -1
- },
- {
- name: '充电桩',
- count: 0,
- id: 1
- },
- {
- name: '输送线',
- count: 0,
- id: 2
- },
- {
- name: '码垛机',
- count: 0,
- id: 3
- },
- {
- name: '自动门',
- count: 0,
- id: 4
- },
- {
- name: '提升机',
- count: 0
- },
- {
- name: '信号灯',
- count: 0
- },
- {
- name: '按钮盒',
- count: 0
- },
- {
- name: '拆垛机',
- count: 0
- }
-])
+
const timerRef = ref(null)
//查询车辆列表
const getCarList = async () => {
- if (timerRef.value) {
- clearInterval(timerRef.value)
- timerRef.value = null
- }
- timerRef.value = setInterval(() => {
- getCarList()
- getRobotInformationStatistics()
- }, 5000)
+ // if (timerRef.value) {
+ // clearInterval(timerRef.value)
+ // timerRef.value = null
+ // }
+ // timerRef.value = setInterval(() => {
+ // getCarList()
+ // getRobotInformationStatistics()
+ // }, 5000)
let res = await DeviceApi.deviceInformationPage(queryParams)
// console.log(res.list)
list.value = res.list
@@ -323,27 +222,25 @@ const carStatistics = ref({
})
//查询车辆统计
const getRobotInformationStatistics = async () => {
- let res = await DeviceApi.robotInformationStatistics({})
- console.log('车辆统计', res)
+ let res = await DeviceApi.deviceNumber({})
+ console.log('设备统计', res)
+ let total = 0
if (res) {
- carStatistics.value = res
- carStatistics.value.total =
- Number(carStatistics.value.standby) +
- Number(carStatistics.value.inTask) +
- Number(carStatistics.value.doLock) +
- Number(carStatistics.value.offline) +
- Number(carStatistics.value.fault) +
- Number(carStatistics.value.charge)
- } else {
- carStatistics.value = {
- standby: 0,
- inTask: 0,
- doLock: 0,
- offline: 0,
- fault: 0,
- charge: 0,
- total: 0
+ if(typeList.value.length){
+ typeList.value.forEach(item => {
+ res.forEach(resItem => {
+ if(item.value == resItem.deviceType){
+ item.number = resItem.number
+ total += Number(resItem.number)
+ }
+ })
+ })
}
+ typeList.value[0].number = total
+ } else {
+ typeList.value.forEach(item => {
+ item.number = 0
+ })
}
}
//新建编辑车辆
@@ -352,13 +249,13 @@ const openForm = (type, id) => {
}
//删除车辆
const deleteCar = (id) => {
- ElMessageBox.confirm('您确定要删除此车辆吗?', '提示', {
+ ElMessageBox.confirm('您确定要删除此设备吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
- DeviceApi.deleteRobotInformation(id).then((res) => {
+ DeviceApi.deleteDeviceInformation(id).then((res) => {
getCarList()
message.success('删除成功')
})
@@ -405,7 +302,9 @@ const goToMap = (item) => {
}
onMounted(() => {
getCarList()
- getRobotInformationStatistics()
+ getTypeList()
+ // getRobotInformationStatistics()
+
})
onBeforeUnmount(() => {
if (timerRef.value) {
@@ -439,7 +338,32 @@ onBeforeRouteLeave((to, from, next) => {
margin: 0px;
}
:deep(.is-active) {
- background-color: #1677ff;
+ background-color: #EBF1FF;
+ color: #0D162A;
+}
+:deep(.el-tabs__item) {
+ padding-left: 8px !important;
+ padding-right: 8px !important;
+ height: auto !important;
+ padding-top: 5px !important;
+ padding-bottom: 5px !important;
+}
+:deep(.el-tabs__active-bar) {
+ height: 0;
+}
+:deep(.el-tabs__nav-next) {
+ line-height: 34px !important;
+}
+:deep(.el-tabs__nav-prev) {
+ line-height: 34px !important;
+}
+:deep(.el-input-group__append){
+ background: none !important;
+}
+:deep(.el-input__wrapper){
+ border: 1px solid var(--el-input-border-color,var(--el-border-color));
+ border-right: none;
+ box-shadow: none !important;
}
.swiper-container {
@@ -771,4 +695,13 @@ input::-webkit-input-placeholder {
.m-b-10 {
margin-bottom: 10px;
}
+.item-inner-left-img-box-no{
+ width: 100%;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 13px;
+ color: #a4afca;
+}
diff --git a/src/views/carError/index.vue b/src/views/carError/index.vue
index e221bbd8..71a1ccc6 100644
--- a/src/views/carError/index.vue
+++ b/src/views/carError/index.vue
@@ -37,7 +37,8 @@
-
+
@@ -186,3 +187,8 @@ onMounted(() => {
getList()
})
+
diff --git a/src/views/mapPage/realTimeMap/components/indexPage.vue b/src/views/mapPage/realTimeMap/components/indexPage.vue
index 28edbcad..301098a6 100644
--- a/src/views/mapPage/realTimeMap/components/indexPage.vue
+++ b/src/views/mapPage/realTimeMap/components/indexPage.vue
@@ -39,10 +39,12 @@
diff --git a/src/views/mapPage/realTimeMap/index.vue b/src/views/mapPage/realTimeMap/index.vue
index 74abd98c..a6134592 100644
--- a/src/views/mapPage/realTimeMap/index.vue
+++ b/src/views/mapPage/realTimeMap/index.vue
@@ -22,6 +22,7 @@ import { ref, defineComponent, reactive, nextTick, onMounted } from 'vue'
import * as MapApi from '@/api/map/map'
import download from '@/utils/download'
+
defineOptions({ name: 'MapPageRealTimeMap' })
const indexPageRef = ref(null)
diff --git a/src/views/mapPage/realTimeMap/webSocket.js b/src/views/mapPage/realTimeMap/webSocket.js
new file mode 100644
index 00000000..4a19fc0d
--- /dev/null
+++ b/src/views/mapPage/realTimeMap/webSocket.js
@@ -0,0 +1,115 @@
+// websocket.js
+class WebSocketClient {
+ constructor(url) {
+ this.currentUrl = url;
+ this.socket = null;
+ this.heartbeatInterval = null;
+ this.messageCallback = null;
+ this.reconnectTimer = null;
+ this.reconnectAttempts = 0;
+ this.MAX_RECONNECT_ATTEMPTS = 5;
+ this.RECONNECT_DELAY = 5000; // 5 秒
+ this.HEARTBEAT_INTERVAL = 30000; // 30 秒
+ this.URL_CHECK_INTERVAL = 5000; // 每 5 秒检查一次 URL
+ this.init();
+ this.startUrlCheck();
+ }
+
+ init() {
+ try {
+ console.log('尝试创建 WebSocket 连接:', this.currentUrl);
+ this.socket = new WebSocket(this.currentUrl);
+
+ this.socket.onopen = () => {
+ console.log('WebSocket 连接已建立:', this.currentUrl);
+ this.startHeartbeat();
+ this.reconnectAttempts = 0;
+ };
+
+ this.socket.onmessage = (event) => {
+ if (this.messageCallback) {
+ this.messageCallback(event.data);
+ }
+ };
+
+ this.socket.onclose = () => {
+ console.log('WebSocket 连接已关闭:', this.currentUrl);
+ this.stopHeartbeat();
+ this.reconnect();
+ };
+
+ this.socket.onerror = (error) => {
+ console.error('WebSocket 发生错误:', error);
+ this.socket.close();
+ };
+ } catch (error) {
+ console.error('创建 WebSocket 连接时出错:', error);
+ }
+ }
+
+ startHeartbeat() {
+ this.heartbeatInterval = setInterval(() => {
+ if (this.socket && this.socket.readyState === WebSocket.OPEN) {
+ this.socket.send('ping');
+ }
+ }, this.HEARTBEAT_INTERVAL);
+ }
+
+ stopHeartbeat() {
+ if (this.heartbeatInterval) {
+ clearInterval(this.heartbeatInterval);
+ this.heartbeatInterval = null;
+ }
+ }
+
+ onMessage(callback) {
+ this.messageCallback = callback;
+ }
+
+ send(message) {
+ if (this.socket && this.socket.readyState === WebSocket.OPEN) {
+ this.socket.send(message);
+ } else {
+ console.error('WebSocket 连接未打开,无法发送消息');
+ }
+ }
+
+ disconnect() {
+ if (this.socket) {
+ this.stopHeartbeat();
+ this.socket.close();
+ this.socket = null;
+ }
+ }
+
+ reconnect() {
+ if (this.reconnectAttempts < this.MAX_RECONNECT_ATTEMPTS) {
+ this.reconnectTimer = setTimeout(() => {
+ console.log('尝试重新连接...', this.currentUrl);
+ this.reconnectAttempts++;
+ this.init();
+ }, this.RECONNECT_DELAY);
+ } else {
+ console.error('达到最大重连次数,停止重连');
+ }
+ }
+
+ startUrlCheck() {
+ setInterval(() => {
+ const newUrl = this.getUpdatedUrl();
+ if (newUrl && newUrl!== this.currentUrl) {
+ this.disconnect();
+ this.currentUrl = newUrl;
+ this.init();
+ }
+ }, this.URL_CHECK_INTERVAL);
+ }
+
+ // 这个方法需要根据实际情况重写,用于获取最新的 URL
+ getUpdatedUrl() {
+ // 这里只是示例,返回 null 表示没有更新的 URL
+ return null;
+ }
+}
+
+export default WebSocketClient;
\ No newline at end of file
diff --git a/src/views/parameterSetting/index.vue b/src/views/parameterSetting/index.vue
index e44b373a..45a79024 100644
--- a/src/views/parameterSetting/index.vue
+++ b/src/views/parameterSetting/index.vue
@@ -142,8 +142,7 @@
:step="1"
type="number"
:min="0"
- :max="99999"
- placeholder="充电阈值"
+ placeholder="充电周期"
>
天
@@ -172,7 +171,7 @@
:step="1"
type="number"
:min="0"
- :max="99"
+
placeholder="请输入等待时间"
>
秒