Merge branch 'yaooo' into dev

This commit is contained in:
yaooo 2023-11-29 17:49:41 +08:00
commit d2d605cf22
18 changed files with 459 additions and 73 deletions

View File

@ -9,7 +9,7 @@
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"@element-plus/icons-vue": "^2.0.6",
"@element-plus/icons-vue": "^2.3.1",
"@highlightjs/vue-plugin": "^2.1.0",
"@wangeditor/editor": "^5.1.12",
"@wangeditor/editor-for-vue": "^5.1.12",
@ -17,6 +17,7 @@
"css-color-function": "^1.3.3",
"echarts": "^5.3.3",
"element-plus": "^2.2.9",
"flv.js": "^1.6.2",
"highlight.js": "^11.6.0",
"nprogress": "^0.2.0",
"pinia": "^2.0.14",
@ -564,9 +565,12 @@
}
},
"node_modules/@element-plus/icons-vue": {
"version": "2.0.6",
"resolved": "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.0.6.tgz",
"integrity": "sha512-lPpG8hYkjL/Z97DH5Ei6w6o22Z4YdNglWCNYOPcB33JCF2A4wye6HFgSI7hEt9zdLyxlSpiqtgf9XcYU+m5mew=="
"version": "2.3.1",
"resolved": "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.3.1.tgz",
"integrity": "sha512-XxVUZv48RZAd87ucGS48jPf6pKu0yV5UCg9f4FFwtrYxXOwWuVJo6wOvSLKEoMQKjv8GsX/mhP6UsC1lRwbUWg==",
"peerDependencies": {
"vue": "^3.2.0"
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.14.53",
@ -2626,6 +2630,11 @@
"es6-symbol": "^3.1.1"
}
},
"node_modules/es6-promise": {
"version": "4.2.8",
"resolved": "https://registry.npmmirror.com/es6-promise/-/es6-promise-4.2.8.tgz",
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
},
"node_modules/es6-symbol": {
"version": "3.1.3",
"resolved": "https://registry.npmmirror.com/es6-symbol/-/es6-symbol-3.1.3.tgz",
@ -3615,6 +3624,15 @@
"integrity": "sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ==",
"dev": true
},
"node_modules/flv.js": {
"version": "1.6.2",
"resolved": "https://registry.npmmirror.com/flv.js/-/flv.js-1.6.2.tgz",
"integrity": "sha512-xre4gUbX1MPtgQRKj2pxJENp/RnaHaxYvy3YToVVCrSmAWUu85b9mug6pTXF6zakUjNP2lFWZ1rkSX7gxhB/2A==",
"dependencies": {
"es6-promise": "^4.2.8",
"webworkify-webpack": "^2.1.5"
}
},
"node_modules/follow-redirects": {
"version": "1.15.1",
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.1.tgz",
@ -7307,6 +7325,11 @@
"integrity": "sha512-h9atBP/bsZohWpHnr+2sic8Iecb60GxftXsWNLLLSqewgIsGzByd2gcIID4nXcG+3tNe4GQG3dLcff3kXupdRA==",
"dev": true
},
"node_modules/webworkify-webpack": {
"version": "2.1.5",
"resolved": "https://registry.npmmirror.com/webworkify-webpack/-/webworkify-webpack-2.1.5.tgz",
"integrity": "sha512-2akF8FIyUvbiBBdD+RoHpoTbHMQF2HwjcxfDvgztAX5YwbZNyrtfUMgvfgFVsgDhDPVTlkbb5vyasqDHfIDPQw=="
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz",
@ -7790,9 +7813,10 @@
"integrity": "sha512-ej5oVy6lykXsvieQtqZxCOaLT+xD4+QNarq78cIYISHmZXshCvROLudpQN3lfL8G0NL7plMSSK+zlyvCaIJ4Iw=="
},
"@element-plus/icons-vue": {
"version": "2.0.6",
"resolved": "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.0.6.tgz",
"integrity": "sha512-lPpG8hYkjL/Z97DH5Ei6w6o22Z4YdNglWCNYOPcB33JCF2A4wye6HFgSI7hEt9zdLyxlSpiqtgf9XcYU+m5mew=="
"version": "2.3.1",
"resolved": "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.3.1.tgz",
"integrity": "sha512-XxVUZv48RZAd87ucGS48jPf6pKu0yV5UCg9f4FFwtrYxXOwWuVJo6wOvSLKEoMQKjv8GsX/mhP6UsC1lRwbUWg==",
"requires": {}
},
"@esbuild/linux-loong64": {
"version": "0.14.53",
@ -9567,6 +9591,11 @@
"es6-symbol": "^3.1.1"
}
},
"es6-promise": {
"version": "4.2.8",
"resolved": "https://registry.npmmirror.com/es6-promise/-/es6-promise-4.2.8.tgz",
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
},
"es6-symbol": {
"version": "3.1.3",
"resolved": "https://registry.npmmirror.com/es6-symbol/-/es6-symbol-3.1.3.tgz",
@ -10254,6 +10283,15 @@
"integrity": "sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ==",
"dev": true
},
"flv.js": {
"version": "1.6.2",
"resolved": "https://registry.npmmirror.com/flv.js/-/flv.js-1.6.2.tgz",
"integrity": "sha512-xre4gUbX1MPtgQRKj2pxJENp/RnaHaxYvy3YToVVCrSmAWUu85b9mug6pTXF6zakUjNP2lFWZ1rkSX7gxhB/2A==",
"requires": {
"es6-promise": "^4.2.8",
"webworkify-webpack": "^2.1.5"
}
},
"follow-redirects": {
"version": "1.15.1",
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.1.tgz",
@ -13253,6 +13291,11 @@
"integrity": "sha512-h9atBP/bsZohWpHnr+2sic8Iecb60GxftXsWNLLLSqewgIsGzByd2gcIID4nXcG+3tNe4GQG3dLcff3kXupdRA==",
"dev": true
},
"webworkify-webpack": {
"version": "2.1.5",
"resolved": "https://registry.npmmirror.com/webworkify-webpack/-/webworkify-webpack-2.1.5.tgz",
"integrity": "sha512-2akF8FIyUvbiBBdD+RoHpoTbHMQF2HwjcxfDvgztAX5YwbZNyrtfUMgvfgFVsgDhDPVTlkbb5vyasqDHfIDPQw=="
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz",

View File

@ -10,7 +10,7 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@element-plus/icons-vue": "^2.0.6",
"@element-plus/icons-vue": "^2.3.1",
"@highlightjs/vue-plugin": "^2.1.0",
"@wangeditor/editor": "^5.1.12",
"@wangeditor/editor-for-vue": "^5.1.12",
@ -18,6 +18,7 @@
"css-color-function": "^1.3.3",
"echarts": "^5.3.3",
"element-plus": "^2.2.9",
"flv.js": "^1.6.2",
"highlight.js": "^11.6.0",
"nprogress": "^0.2.0",
"pinia": "^2.0.14",

View File

@ -33,4 +33,9 @@ export function apiDeviceDelete(params: any) {
// 监测设备详情
export function apiDeviceDetail(params: any) {
return request.get({ url: '/device.device/detail', params })
}
// 设备监控数据
export function apiDeviceMonitorData(params: any) {
return request.get({ url: '/device.device/monitorData', params })
}

View File

@ -2,8 +2,8 @@ const config = {
terminal: 1, //终端
title: '后台管理系统', //网站默认标题
version: '1.6.0', //版本号
baseUrl: `${import.meta.env.VITE_APP_BASE_URL || ''}/`, //请求接口域名
// baseUrl: 'http://127.0.0.1:30005/',
// baseUrl: `${import.meta.env.VITE_APP_BASE_URL || ''}/`, //请求接口域名
baseUrl: 'http://127.0.0.1:30005/',
urlPrefix: 'adminapi', //请求默认前缀
timeout: 10 * 1000 //请求超时时长
}

View File

@ -0,0 +1,213 @@
<template>
<div>
<el-card class="!border-none" shadow="never">
<el-page-header content="设备详情" @back="$router.back()" />
</el-card>
<el-card class="!border-none mt-4 flex-1" shadow="never">
<template #header>
<div>
<span class="card-title">设备资料</span>
</div>
</template>
<div class="flex flex-wrap">
<div v-if="deviceData.device.land_id != ''" class="w-1/2 md:w-1/3 mb-4">
<div class="leading-10">所属土地</div>
<div class="text-3xl text-tx-secondary">ID{{ deviceData.device.land_id }} / 名称{{ deviceData.device.land_title }}</div>
</div>
<div v-if="deviceData.device.product_id != ''" class="w-1/2 md:w-1/3 mb-4">
<div class="leading-10">所属产品</div>
<div class="text-3xl text-tx-secondary">ID{{ deviceData.device.product_id }} / 名称{{ deviceData.device.land_title }}</div>
</div>
</div>
<div class="flex flex-wrap">
<div class="w-1/2 md:w-1/6 mb-4">
<div class="leading-10">设备名称</div>
<div class="text-3xl text-tx-secondary">{{ deviceData.device.name }}</div>
</div>
<div class="w-1/2 md:w-1/6 mb-4">
<div class="leading-10">设备编码</div>
<div class="text-3xl text-tx-secondary">{{ deviceData.device.code }}</div>
</div>
<div class="w-1/2 md:w-1/6 mb-4">
<div class="leading-10">设备类型</div>
<div class="text-3xl text-tx-secondary">
<dict-value :options="dictData.device_type" :value="deviceData.device.type" />
</div>
</div>
<div class="w-1/2 md:w-1/6 mb-4">
<div class="leading-10">设备状态</div>
<div class="text-3xl text-tx-secondary">
<dict-value :options="dictData.device_status" :value="deviceData.device.status" />
</div>
</div>
<div class="w-1/2 md:w-1/6 mb-4">
<div class="leading-10">是否在线</div>
<div class="text-3xl text-tx-secondary">
<dict-value :options="dictData.device_online_status" :value="deviceData.device.is_online" />
</div>
</div>
<div class="w-1/2 md:w-1/6 mb-4">
<div class="leading-10">是否绑定产品</div>
<div class="text-3xl text-tx-secondary">
<dict-value :options="dictData.device_bind_status" :value="deviceData.device.is_bind" />
</div>
</div>
</div>
</el-card>
<el-card class="!border-none mt-4 flex-1" shadow="never">
<el-tabs v-model="activeName" class="">
<el-tab-pane label="监控数据" name="monitor_item">
<el-row :gutter="12">
<el-col :span="6" v-for="item in deviceData.monitor_item" :key="item">
<el-card shadow="always" class="mb-4">
<div class="flex justify-between mb-2">
<div class="mt-2 text-sm text-tx-secondary">{{ item.name }}</div>
<div class="mt-2 text-sm text-tx-secondary" @click="handleClick(item.device_id, item.value)">
历史数据
</div>
</div>
<div class="my-6 text-3xl">{{ item.monitor_value }}</div>
<div class="mt-2 text-sm text-tx-secondary"><el-tag class="mr-2" type="info">只读</el-tag>{{ item.last_time }}</div>
</el-card>
</el-col>
</el-row>
</el-tab-pane>
<el-tab-pane v-if="deviceData.device.type==3" label="监控视频" name="monitor_video">
<video
v-if="deviceData.device.video_url != ''"
:src="deviceData.device.video_url"
controls
></video>
</el-tab-pane>
</el-tabs>
</el-card>
</div>
<el-dialog v-model="dialogTableVisible" title="历史数据">
<el-table :data="monitorData.gridData">
<el-table-column property="id" label="ID" width="80" />
<el-table-column property="date" label="时间" width="250" />
<el-table-column property="value" label="数据" />
</el-table>
<el-pagination
small
background
layout="prev, pager, next"
:page-size="queryMonitorData.page_size"
:total="queryMonitorData.total"
class="mt-4"
@current-change="handleCurrentChange"
/>
</el-dialog>
</template>
<script lang="ts" setup name="deviceDetail">
import { ref } from 'vue'
import { useDictData } from '@/hooks/useDictOptions'
import { apiDeviceDetail, apiDeviceMonitorData } from '@/api/device'
import { timeFormat } from '@/utils/util'
const activeName = ref('monitor_item')
const deviceData: any = reactive({
device: {},
monitor_item: []
})
const queryMonitorData: any = reactive({
device_id: '',
monitor_type: '',
page_no: 1,
page_size: 15,
total: ''
})
const { dictData } = useDictData('device_type,device_status,device_online_status,device_bind_status,monitor_item')
const route = useRoute()
const getDetails = async () => {
apiDeviceDetail({
id: route.query.device_id
})
.then((res: any) => {
deviceData.device.name = res.name
deviceData.device.code = res.code
deviceData.device.type = res.type
deviceData.device.status = res.status
deviceData.device.is_online = res.is_online
deviceData.device.is_bind = res.is_bind
deviceData.device.land_id = res.land_id == null ? '' : res.land_id
deviceData.device.land_title = res.land_title == null ? '' : res.land_title
deviceData.device.product_id = res.product_id == null ? '' : res.product_id
deviceData.device.product_name = res.product_name == null ? '' : res.product_name
deviceData.monitor_item = res.monitor_item
deviceData.device.video_url = res.video_url
})
.catch((err: any) => {
console.log('err', err)
})
}
getDetails()
const dialogTableVisible = ref(false)
const monitorData = reactive({
gridData: [{}]
})
const handleClick = (id: any, type: any) => {
monitorData.gridData = [{}]
queryMonitorData.device_id = id
queryMonitorData.monitor_type = type
apiDeviceMonitorData({
id: id,
monitor_type: type,
page_no: queryMonitorData.page_no,
page_size: queryMonitorData.page_size
})
.then((res: any) => {
dialogTableVisible.value = true
queryMonitorData.total = res.count
res.lists.map((data: any) => {
queryMonitorData.total = res.count
monitorData.gridData.push({
id: data.id,
date: data.create_time
? timeFormat(data.create_time, 'yyyy-mm-dd hh:MM:ss')
: '',
value: data.monitor_value
})
})
})
.catch((err: any) => {
console.log('err', err)
})
}
const handleCurrentChange = (val: number) => {
console.log(`current page: ${val}`)
monitorData.gridData = [{}]
apiDeviceMonitorData({
id: queryMonitorData.device_id,
monitor_type: queryMonitorData.monitor_type,
page_no: val,
page_size: queryMonitorData.page_size
})
.then((res: any) => {
dialogTableVisible.value = true
queryMonitorData.total = res.count
res.lists.map((data: any) => {
monitorData.gridData.push({
id: data.id,
date: data.create_time
? timeFormat(data.create_time, 'yyyy-mm-dd hh:MM:ss')
: '',
value: data.monitor_value
})
})
})
.catch((err: any) => {
console.log('err', err)
})
}
</script>

View File

@ -70,6 +70,9 @@
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="视频地址" prop="video_url">
<el-input v-model="formData.video_url" clearable placeholder="请输入视频地址" />
</el-form-item>
<el-form-item label="设备状态" prop="status">
<el-select class="flex-1" v-model="formData.status" clearable placeholder="请选择设备状态">
@ -136,6 +139,7 @@ const formData = reactive({
product_id: '',
code: '',
name: '',
video_url: '',
type: '',
monitor_item: '',
status: '',
@ -171,11 +175,6 @@ const formRules = reactive<any>({
message: '请选择设备类型',
trigger: ['blur']
}],
monitor_item: [{
required: true,
message: '请选择设备监测项',
trigger: ['blur']
}],
status: [{
required: true,
message: '请选择设备状态',
@ -202,7 +201,6 @@ const setFormData = async (data: Record<any, any>) => {
formData[key] = data[key]
}
}
console.log(dictData.monitor_item)
}
interface ListItem {

View File

@ -94,31 +94,31 @@
<el-table :data="pager.lists" @selection-change="handleSelectionChange" style="width: 100%">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" width="80" show-overflow-tooltip />
<el-table-column label="用户信息" width="200">
<!-- <el-table-column label="用户信息" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="success">账户: {{ row.account }}</el-tag>
<el-tag class="mr-2" type="info">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="info">账户: {{ row.account }}</el-tag>
</template>
</el-table-column>
<el-table-column label="土地信息" width="200">
</el-table-column> -->
<el-table-column label="设备名称" width="200" prop="name" show-overflow-tooltip />
<el-table-column label="设备类型" width="150" prop="type">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.land_id }}</el-tag>
<el-tag class="mr-2" type="success">名称: {{ row.land_title }}</el-tag>
<dict-value :options="dictData.device_type" :value="row.type" />
</template>
</el-table-column>
<el-table-column label="产品信息" width="200">
<el-table-column label="所属土地" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.product_id }}</el-tag>
<el-tag class="mr-2" type="success">名称: {{ row.product_name }}</el-tag>
<el-tag class="mr-2" type="info">ID: {{ row.land_id }}</el-tag>
<el-tag class="mr-2" type="info">名称: {{ row.land_title }}</el-tag>
</template>
</el-table-column>
<el-table-column label="所属产品" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="info">ID: {{ row.product_id }}</el-tag>
<el-tag class="mr-2" type="info">名称: {{ row.product_name }}</el-tag>
</template>
</el-table-column>
<el-table-column label="设备编码" width="120" prop="code" show-overflow-tooltip />
<el-table-column label="设备名称" width="200" prop="name" show-overflow-tooltip />
<el-table-column label="设备类型" width="150" prop="type">
<template #default="{ row }">
<dict-value :options="dictData.device_type" :value="row.type" />
</template>
</el-table-column>
<el-table-column label="设备状态" width="100" align="center" prop="status">
<template #default="{ row }">
<dict-value :options="dictData.device_status" :value="row.status" />
@ -139,7 +139,7 @@
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="200" align="center" fixed="right">
<el-table-column label="操作" width="260" align="center" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['device.device/edit']"
@ -149,6 +149,22 @@
>
编辑
</el-button>
<el-button
v-perms="['device.device/detail']"
type="primary"
link
>
<router-link
:to="{
path: getRoutePath('device.device/detail'),
query: {
device_id: row.id
}
}"
>
查看详情
</router-link>
</el-button>
<el-button
v-perms="['device.monitor_alarm/lists']"
type="primary"

View File

@ -43,15 +43,15 @@
<el-table :data="pager.lists" @selection-change="handleSelectionChange" style="width: 100%">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" width="80" show-overflow-tooltip />
<el-table-column label="用户信息" width="200">
<!-- <el-table-column label="用户信息" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="success">账户: {{ row.user.account }}</el-tag>
<el-tag class="mr-2" type="info">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="info">账户: {{ row.user.account }}</el-tag>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column label="土地名称">
<template #default="{ row }">
<el-tag class="mr-2" type="success">{{ row.title }}</el-tag>
<el-tag class="mr-2" type="info">{{ row.title }}</el-tag>
</template>
</el-table-column>
<el-table-column label="土地面积" prop="total_area" show-overflow-tooltip />

View File

@ -50,16 +50,16 @@
<el-table :data="pager.lists" @selection-change="handleSelectionChange" style="width: 100%">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" width="80" show-overflow-tooltip />
<el-table-column label="用户信息" width="200">
<!-- <el-table-column label="用户信息" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="success">账户: {{ row.account }}</el-tag>
<el-tag class="mr-2" type="info">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="info">账户: {{ row.account }}</el-tag>
</template>
</el-table-column>
<el-table-column label="土地信息" width="200">
</el-table-column> -->
<el-table-column label="所属土地" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.land_id }}</el-tag>
<el-tag class="mr-2" type="success">名称: {{ row.title }}</el-tag>
<el-tag class="mr-2" type="info">ID: {{ row.land_id }}</el-tag>
<el-tag class="mr-2" type="info">名称: {{ row.title }}</el-tag>
</template>
</el-table-column>
<el-table-column label="种植种类" prop="kind" show-overflow-tooltip />

View File

@ -40,16 +40,16 @@
<el-table :data="pager.lists" @selection-change="handleSelectionChange" style="width: 100%">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" width="80" show-overflow-tooltip />
<el-table-column label="用户信息" width="200">
<!-- <el-table-column label="用户信息" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="success">账户: {{ row.account }}</el-tag>
<el-tag class="mr-2" type="info">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="info">账户: {{ row.account }}</el-tag>
</template>
</el-table-column>
<el-table-column label="土地种植信息" width="200">
</el-table-column> -->
<el-table-column label="所属土地种植" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.plant_id }}</el-tag>
<el-tag class="mr-2" type="success">类型: {{ row.kind }} 品牌: {{ row.breed }}</el-tag>
<el-tag class="mr-2" type="info">ID: {{ row.plant_id }}</el-tag>
<el-tag class="mr-2" type="info">类型: {{ row.kind }} 品牌: {{ row.breed }}</el-tag>
</template>
</el-table-column>
<el-table-column label="种植操作类型" align="center" prop="type">

View File

@ -39,8 +39,8 @@
<el-table-column label="ID" prop="id" width="80" show-overflow-tooltip />
<el-table-column label="设备信息" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.device_id }}</el-tag>
<el-tag class="mr-2" type="success">名称: {{ row.device.name }}</el-tag>
<el-tag class="mr-2" type="info">ID: {{ row.device_id }}</el-tag>
<el-tag class="mr-2" type="info">名称: {{ row.device.name }}</el-tag>
</template>
</el-table-column>
<el-table-column label="监测类型" align="center" prop="type">

View File

@ -60,20 +60,20 @@
<el-table :data="pager.lists" @selection-change="handleSelectionChange" style="width: 100%">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" width="80" show-overflow-tooltip />
<el-table-column label="用户信息" width="200">
<!-- <el-table-column label="用户信息" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="success">账户: {{ row.account }}</el-tag>
<el-tag class="mr-2" type="info">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="info">账户: {{ row.account }}</el-tag>
</template>
</el-table-column>
<el-table-column label="土地信息" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="success">ID: {{ row.land_id }}</el-tag>
<el-tag class="mr-2" type="success">名称: {{ row.title }}</el-tag>
</template>
</el-table-column>
<el-table-column label="产品编号" prop="code" show-overflow-tooltip />
</el-table-column> -->
<el-table-column label="产品名称" prop="name" show-overflow-tooltip />
<el-table-column label="产品编号" prop="code" show-overflow-tooltip />
<el-table-column label="所属土地" width="200">
<template #default="{ row }">
<el-tag class="mr-2" type="info">ID: {{ row.land_id }}</el-tag>
<el-tag class="mr-2" type="info">名称: {{ row.title }}</el-tag>
</template>
</el-table-column>
<el-table-column label="产品状态" align="center" prop="status">
<template #default="{ row }">
<dict-value :options="dictData.product_status" :value="row.status" />
@ -84,7 +84,7 @@
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="140" align="center" fixed="right">
<el-table-column label="操作" width="200" align="center" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['land.product/edit']"
@ -94,6 +94,18 @@
>
编辑
</el-button>
<el-button v-perms="['device.device/lists']" type="primary" link >
<router-link
:to="{
path: getRoutePath('device.device/lists'),
query: {
product_id: row.id
}
}"
>
查看设备
</router-link>
</el-button>
<el-button
v-perms="['land.product/delete']"
type="danger"
@ -116,6 +128,7 @@
<script lang="ts" setup name="productLists">
import { usePaging } from '@/hooks/usePaging'
import { getRoutePath } from '@/router'
import { useDictData } from '@/hooks/useDictOptions'
import { apiProductLists, apiProductDelete } from '@/api/product'
import { timeFormat } from '@/utils/util'

View File

@ -291,10 +291,10 @@
resolved "https://registry.npmmirror.com/@ctrl/tinycolor/-/tinycolor-3.4.1.tgz"
integrity sha512-ej5oVy6lykXsvieQtqZxCOaLT+xD4+QNarq78cIYISHmZXshCvROLudpQN3lfL8G0NL7plMSSK+zlyvCaIJ4Iw==
"@element-plus/icons-vue@^2.0.6":
version "2.0.6"
resolved "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.0.6.tgz"
integrity sha512-lPpG8hYkjL/Z97DH5Ei6w6o22Z4YdNglWCNYOPcB33JCF2A4wye6HFgSI7hEt9zdLyxlSpiqtgf9XcYU+m5mew==
"@element-plus/icons-vue@^2.0.6", "@element-plus/icons-vue@^2.3.1":
version "2.3.1"
resolved "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.3.1.tgz"
integrity sha512-XxVUZv48RZAd87ucGS48jPf6pKu0yV5UCg9f4FFwtrYxXOwWuVJo6wOvSLKEoMQKjv8GsX/mhP6UsC1lRwbUWg==
"@eslint/eslintrc@^1.3.0":
version "1.3.0"
@ -1794,6 +1794,11 @@ es6-iterator@^2.0.3:
es5-ext "^0.10.35"
es6-symbol "^3.1.1"
es6-promise@^4.2.8:
version "4.2.8"
resolved "https://registry.npmmirror.com/es6-promise/-/es6-promise-4.2.8.tgz"
integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==
es6-symbol@^3.1.1, es6-symbol@^3.1.3:
version "3.1.3"
resolved "https://registry.npmmirror.com/es6-symbol/-/es6-symbol-3.1.3.tgz"
@ -2178,6 +2183,14 @@ flatted@^3.1.0:
resolved "https://registry.npmmirror.com/flatted/-/flatted-3.2.6.tgz"
integrity sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ==
flv.js@^1.6.2:
version "1.6.2"
resolved "https://registry.npmmirror.com/flv.js/-/flv.js-1.6.2.tgz"
integrity sha512-xre4gUbX1MPtgQRKj2pxJENp/RnaHaxYvy3YToVVCrSmAWUu85b9mug6pTXF6zakUjNP2lFWZ1rkSX7gxhB/2A==
dependencies:
es6-promise "^4.2.8"
webworkify-webpack "^2.1.5"
follow-redirects@^1.14.9:
version "1.15.1"
resolved "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.1.tgz"
@ -4293,7 +4306,7 @@ vue-tsc@^0.38.1:
dependencies:
"@volar/vue-typescript" "0.38.9"
vue@^3.2.2, vue@^3.2.37:
vue@^3.2.0, vue@^3.2.2, vue@^3.2.37:
version "3.2.37"
resolved "https://registry.npmmirror.com/vue/-/vue-3.2.37.tgz"
integrity sha512-bOKEZxrm8Eh+fveCqS1/NkG/n6aMidsI6hahas7pa0w/l7jkbssJVsRhVDs07IdDq7h9KHswZOgItnwJAgtVtQ==
@ -4330,6 +4343,11 @@ webpack-virtual-modules@^0.4.4:
resolved "https://registry.npmmirror.com/webpack-virtual-modules/-/webpack-virtual-modules-0.4.4.tgz"
integrity sha512-h9atBP/bsZohWpHnr+2sic8Iecb60GxftXsWNLLLSqewgIsGzByd2gcIID4nXcG+3tNe4GQG3dLcff3kXupdRA==
webworkify-webpack@^2.1.5:
version "2.1.5"
resolved "https://registry.npmmirror.com/webworkify-webpack/-/webworkify-webpack-2.1.5.tgz"
integrity sha512-2akF8FIyUvbiBBdD+RoHpoTbHMQF2HwjcxfDvgztAX5YwbZNyrtfUMgvfgFVsgDhDPVTlkbb5vyasqDHfIDPQw==
which@^2.0.1:
version "2.0.2"
resolved "https://registry.npmmirror.com/which/-/which-2.0.2.tgz"

View File

@ -104,5 +104,17 @@ class DeviceController extends BaseAdminController
return $this->data($result);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 15:30
*/
public function monitorData()
{
$params = (new DeviceValidate())->goCheck('monitorData');
$result = DeviceLogic::monitorData($params);
return $this->data($result);
}
}

View File

@ -17,9 +17,9 @@ namespace app\adminapi\logic\device;
use app\common\model\device\Device;
use app\common\logic\BaseLogic;
use think\facade\Config;
use think\facade\Db;
/**
* Device逻辑
* Class DeviceLogic
@ -51,6 +51,7 @@ class DeviceLogic extends BaseLogic
'name' => $params['name'],
'type' => $params['type'],
'monitor_item' => $params['monitor_item'],
'video_url' => $params['video_url'],
'status' => $params['status'],
'is_online' => $params['is_online'],
'is_bind' => $params['is_bind'],
@ -94,6 +95,7 @@ class DeviceLogic extends BaseLogic
'name' => $params['name'],
'type' => $params['type'],
'monitor_item' => $params['monitor_item'],
'video_url' => $params['video_url'],
'status' => $params['status'],
'is_online' => $params['is_online'],
'is_bind' => $params['is_bind'],
@ -125,6 +127,9 @@ class DeviceLogic extends BaseLogic
*/
public static function delete(array $params): bool
{
Db::name('product_device')->where('device_id', $params['id'])->delete();
Db::name('device_monitor_data')->where('device_id', $params['id'])->delete();
Db::name('monitor_alarm')->where('device_id', $params['id'])->delete();
return Device::destroy($params['id']);
}
@ -138,6 +143,54 @@ class DeviceLogic extends BaseLogic
*/
public static function detail($params): array
{
return Device::findOrEmpty($params['id'])->toArray();
$detail = Db::name('device')->alias('d')
->where('d.id', $params['id'])
->leftJoin('user u','u.id = d.user_id')
->leftJoin('product_device pd','pd.device_id = d.id')
->leftJoin('product p','p.id = pd.product_id')
->leftJoin('land_product lp','lp.product_id = pd.product_id')
->leftJoin('land l','l.id = lp.land_id')
->field('d.*, u.account, pd.product_id, p.name as product_name, lp.land_id, l.title as land_title')
->findOrEmpty();
$monitorItemArray = [];
if (!empty($detail['monitor_item'])) {
$monitorItemArray = explode(',', $detail['monitor_item']);
}
$dictTypeId = Db::name('dict_type')->where('type', 'monitor_item')->value('id');
$monitorItemArray = Db::name('dict_data')->where('type_id', $dictTypeId)->whereIn('value', $monitorItemArray)->field(['name', 'value'])->select()->toArray();
foreach($monitorItemArray as $k=>$v) {
$monitorItemArray[$k]['device_id'] = $params['id'];
$monitorItemArray[$k]['monitor_value'] = '-';
$monitorItemArray[$k]['last_time'] = '-';
$monitorData = Db::name('device_monitor_data')->where('device_id', $params['id'])->where('monitor_item', $v['value'])->order(['id' => 'desc'])->find();
if (!empty($monitorData)) {
$monitorItemArray[$k]['monitor_value'] = $monitorData['monitor_value'];
$monitorItemArray[$k]['last_time'] = date('Y-m-d H:i:s', $monitorData['create_time']);
}
}
$detail['monitor_item'] = $monitorItemArray;
return $detail;
}
public static function monitorData($params): array
{
$pageSizeMax = Config::get('project.lists.page_size_max');
$pageSize = Config::get('project.lists.page_size');
$pageNo = $page_no = request()->get('page_no', 1) ?: 1;
$pageSize = $page_size = request()->get('page_size', $pageSize) ?: $pageSize;
$limitOffset = ($pageNo - 1) * $pageSize;
$limitLength = $pageSize;
$where['device_id'] = $params['id'];
$where['monitor_item'] = $params['monitor_type'];
$lists = Db::name('device_monitor_data')
->where($where)
->limit($limitOffset, $limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
$count = Db::name('device_monitor_data')->where($where)->count();
return compact('lists', 'count', 'page_no', 'page_size');
}
}

View File

@ -108,6 +108,7 @@ class LandPlantLogic extends BaseLogic
*/
public static function delete(array $params): bool
{
Db::name('land_plant_action')->where('plant_id', $params['id'])->delete();
return LandPlant::destroy($params['id']);
}

View File

@ -106,6 +106,7 @@ class ProductLogic extends BaseLogic
public static function delete(array $params): bool
{
Db::name('land_product')->where('product_id', $params['id'])->delete();
Db::name('monitor_data')->where('product_id', $params['id'])->delete();
return Product::destroy($params['id']);
}

View File

@ -35,6 +35,7 @@ class DeviceValidate extends BaseValidate
'code' => 'require',
'name' => 'require',
'type' => 'require',
'monitor_type' => 'require',
'status' => 'require',
'is_online' => 'require',
'is_bind' => 'require',
@ -103,4 +104,15 @@ class DeviceValidate extends BaseValidate
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return DeviceValidate
* @author likeadmin
* @date 2023/11/24 15:30
*/
public function sceneMonitorData()
{
return $this->only(['id', 'monitor_type']);
}
}