Merge branch 'yaooo' into dev

This commit is contained in:
yaooo 2023-11-28 17:22:25 +08:00
commit 08e41e416c
42 changed files with 508 additions and 2000 deletions

View File

@ -1,26 +0,0 @@
import request from '@/utils/request'
// 空气监测列表
export function apiAirMonitorLists(params: any) {
return request.get({ url: '/device.air_monitor/lists', params })
}
// 添加空气监测
export function apiAirMonitorAdd(params: any) {
return request.post({ url: '/device.air_monitor/add', params })
}
// 编辑空气监测
export function apiAirMonitorEdit(params: any) {
return request.post({ url: '/device.air_monitor/edit', params })
}
// 删除空气监测
export function apiAirMonitorDelete(params: any) {
return request.post({ url: '/device.air_monitor/delete', params })
}
// 空气监测详情
export function apiAirMonitorDetail(params: any) {
return request.get({ url: '/device.air_monitor/detail', params })
}

View File

@ -1,5 +1,15 @@
import request from '@/utils/request'
// 用户列表
export function getUserList(params: any) {
return request.get({ url: '/user.user/lists', params }, { ignoreCancelToken: true })
}
// 产品列表列表
export function apiProductLists(params: any) {
return request.get({ url: '/land.product/lists', params })
}
// 监测设备列表
export function apiDeviceLists(params: any) {
return request.get({ url: '/device.device/lists', params })

View File

@ -1,26 +0,0 @@
import request from '@/utils/request'
// 土壤监测列表
export function apiSoilMonitorLists(params: any) {
return request.get({ url: '/device.soil_monitor/lists', params })
}
// 添加土壤监测
export function apiSoilMonitorAdd(params: any) {
return request.post({ url: '/device.soil_monitor/add', params })
}
// 编辑土壤监测
export function apiSoilMonitorEdit(params: any) {
return request.post({ url: '/device.soil_monitor/edit', params })
}
// 删除土壤监测
export function apiSoilMonitorDelete(params: any) {
return request.post({ url: '/device.soil_monitor/delete', params })
}
// 土壤监测详情
export function apiSoilMonitorDetail(params: any) {
return request.get({ url: '/device.soil_monitor/detail', params })
}

View File

@ -1,181 +0,0 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
<el-form-item label="设备ID" prop="device_id">
<el-input v-model="formData.device_id" disabled clearable placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="风向" prop="wind_direction">
<el-input v-model="formData.wind_direction" disabled clearable placeholder="请输入风向" />
</el-form-item>
<el-form-item label="风速" prop="wind_speed">
<el-input v-model="formData.wind_speed" disabled clearable placeholder="请输入风速" />
</el-form-item>
<el-form-item label="空气温度" prop="temperature">
<el-input v-model="formData.temperature" disabled clearable placeholder="请输入空气温度" />
</el-form-item>
<el-form-item label="空气湿度" prop="moisture">
<el-input v-model="formData.moisture" disabled clearable placeholder="请输入空气湿度" />
</el-form-item>
<el-form-item label="二氧化碳含量" prop="co2_content">
<el-input v-model="formData.co2_content" disabled clearable placeholder="请输入二氧化碳含量" />
</el-form-item>
<el-form-item label="大气压强" prop="pressure">
<el-input v-model="formData.pressure" disabled clearable placeholder="请输入大气压强" />
</el-form-item>
<el-form-item label="降雨量" prop="rainfall">
<el-input v-model="formData.rainfall" disabled clearable placeholder="请输入降雨量" />
</el-form-item>
<el-form-item label="光照强度" prop="light_intensity">
<el-input v-model="formData.light_intensity" disabled clearable placeholder="请输入光照强度" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="airMonitorEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiAirMonitorAdd, apiAirMonitorEdit, apiAirMonitorDetail } from '@/api/air_monitor'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '空气监测数据' : '新增空气监测'
})
//
const formData = reactive({
id: '',
device_id: '',
wind_direction: '',
wind_speed: '',
temperature: '',
moisture: '',
co2_content: '',
pressure: '',
rainfall: '',
light_intensity: '',
})
//
const formRules = reactive<any>({
device_id: [{
required: true,
message: '请输入设备ID',
trigger: ['blur']
}],
wind_direction: [{
required: true,
message: '请输入风向',
trigger: ['blur']
}],
wind_speed: [{
required: true,
message: '请输入风速',
trigger: ['blur']
}],
temperature: [{
required: true,
message: '请输入空气温度',
trigger: ['blur']
}],
moisture: [{
required: true,
message: '请输入空气湿度',
trigger: ['blur']
}],
co2_content: [{
required: true,
message: '请输入二氧化碳含量',
trigger: ['blur']
}],
pressure: [{
required: true,
message: '请输入大气压强',
trigger: ['blur']
}],
rainfall: [{
required: true,
message: '请输入降雨量',
trigger: ['blur']
}],
light_intensity: [{
required: true,
message: '请输入光照强度',
trigger: ['blur']
}],
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiAirMonitorDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiAirMonitorEdit(data)
: await apiAirMonitorAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -1,189 +0,0 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="设备ID" prop="device_id">
<el-input class="w-[280px]" v-model="queryParams.device_id" clearable placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="监测时间" prop="create_time">
<daterange-picker
v-model:startTime="queryParams.start_time"
v-model:endTime="queryParams.end_time"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" show-overflow-tooltip />
<el-table-column label="设备ID" prop="device_id" show-overflow-tooltip />
<el-table-column label="设备名称" prop="device.name" show-overflow-tooltip />
<el-table-column label="风向" prop="wind_direction" show-overflow-tooltip />
<el-table-column label="风速" prop="wind_speed" show-overflow-tooltip />
<el-table-column label="空气温度" prop="temperature" show-overflow-tooltip />
<el-table-column label="空气湿度" prop="moisture" show-overflow-tooltip />
<el-table-column label="二氧化碳含量" prop="co2_content" show-overflow-tooltip />
<el-table-column label="大气压强" prop="pressure" show-overflow-tooltip />
<el-table-column label="降雨量" prop="rainfall" show-overflow-tooltip />
<el-table-column label="光照强度" prop="light_intensity" show-overflow-tooltip />
<el-table-column label="监测时间" width="160" prop="create_time" show-overflow-tooltip />
<el-table-column label="操作" width="140" align="center" fixed="right">
<template #default="{ row }">
<el-button text @click="handleDetail(row)"
>
详情
</el-button>
<el-button
v-perms="['device.air_monitor/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
<el-dialog v-model="dialogTableVisible" title="空气监测数据">
<el-table :data="detailData.gridData">
<el-table-column property="item" label="监测项" width="150" />
<el-table-column property="value" label="监测数据" />
</el-table>
</el-dialog>
</template>
<script lang="ts" setup name="airMonitorLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiAirMonitorLists, apiAirMonitorDelete } from '@/api/air_monitor'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const { query } = useRoute()
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
var device_id = query.device_id
if (typeof(device_id) == 'undefined') {
device_id = ''
}
//
const queryParams = reactive({
device_id: device_id,
start_time: '',
end_time: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiAirMonitorLists,
params: queryParams
})
const dialogTableVisible = ref(false)
const detailData = reactive({
gridData : [{}]
})
//
const handleDetail = (data: any) => {
detailData.gridData = [{}]
detailData.gridData.unshift({
item: '光照强度',
value: data.light_intensity
})
detailData.gridData.unshift({
item: '降雨量',
value: data.rainfall
})
detailData.gridData.unshift({
item: '大气压强',
value: data.pressure
})
detailData.gridData.unshift({
item: '二氧化碳含量',
value: data.co2_content
})
detailData.gridData.unshift({
item: '空气湿度',
value: data.moisture
})
detailData.gridData.unshift({
item: '空气温度',
value: data.temperature
})
detailData.gridData.unshift({
item: '风速',
value: data.wind_speed
})
detailData.gridData.unshift({
item: '风向',
value: data.wind_direction
})
detailData.gridData.unshift({
item: '设备名称',
value: data.device.name
})
detailData.gridData.unshift({
item: '设备ID',
value: data.device_id
})
dialogTableVisible.value = true
}
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiAirMonitorDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -9,6 +9,42 @@
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
<el-form-item label="用户ID" prop="user_id">
<el-select
v-model="formData.user_id"
filterable
remote
reserve-keyword
placeholder="请输入用户信息"
:remote-method="queryUser"
:loading="loading"
>
<el-option
v-for="item in userOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="产品ID" prop="product_id">
<el-select
v-model="formData.product_id"
filterable
remote
reserve-keyword
placeholder="请输入产品信息"
:remote-method="queryProduct"
:loading="loading"
>
<el-option
v-for="item in productOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="设备编码" prop="code">
<el-input v-model="formData.code" clearable placeholder="请输入设备编码" />
</el-form-item>
@ -24,6 +60,16 @@
:value="parseInt(item.value)"
/>
</el-select>
</el-form-item>
<el-form-item label="监测项" prop="monitor_item">
<el-select class="flex-1" v-model="formData.monitor_item" multiple clearable placeholder="请选择设备监测项">
<el-option
v-for="(item, index) in dictData.monitor_item"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="设备状态" prop="status">
<el-select class="flex-1" v-model="formData.status" clearable placeholder="请选择设备状态">
@ -63,7 +109,7 @@
<script lang="ts" setup name="deviceEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiDeviceAdd, apiDeviceEdit, apiDeviceDetail } from '@/api/device'
import { apiDeviceAdd, apiDeviceEdit, apiDeviceDetail, getUserList, apiProductLists} from '@/api/device'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
@ -86,9 +132,12 @@ const popupTitle = computed(() => {
//
const formData = reactive({
id: '',
user_id: '',
product_id: '',
code: '',
name: '',
type: '',
monitor_item: '',
status: '',
is_online: '',
is_bind: '',
@ -97,6 +146,16 @@ const formData = reactive({
//
const formRules = reactive<any>({
user_id: [{
required: true,
message: '请输入用户ID',
trigger: ['blur']
}],
product_id: [{
required: true,
message: '请输入产品id',
trigger: ['blur']
}],
code: [{
required: true,
message: '请输入设备编码',
@ -112,6 +171,11 @@ const formRules = reactive<any>({
message: '请选择设备类型',
trigger: ['blur']
}],
monitor_item: [{
required: true,
message: '请选择设备监测项',
trigger: ['blur']
}],
status: [{
required: true,
message: '请选择设备状态',
@ -138,10 +202,58 @@ const setFormData = async (data: Record<any, any>) => {
formData[key] = data[key]
}
}
console.log(dictData.monitor_item)
}
interface ListItem {
value: string
label: string
}
const productOptions = ref<ListItem[]>([])
const userOptions = ref<ListItem[]>([])
const loading = ref(false)
const queryUser = async (query: string) => {
if (query) {
loading.value = true
const userList = await getUserList({
keyword: query
})
loading.value = false
if (userList.count > 0) {
userOptions.value = userList.lists.map((user: any) => {
return { value: `${user.id}`, label: `ID: ${user.id} / 账户: ${user.account}` }
})
} else {
userOptions.value = []
}
loading.value = false
} else {
userOptions.value = []
}
}
const queryProduct = async (query: string) => {
if (query) {
loading.value = true
const productList = await apiProductLists({
name: query
})
loading.value = false
if (productList.count > 0) {
productOptions.value = productList.lists.map((product: any) => {
return { value: `${product.id}`, label: `ID: ${product.id} / 名称: ${product.name}` }
})
} else {
productOptions.value = []
}
loading.value = false
} else {
productOptions.value = []
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiDeviceDetail({
id: row.id

View File

@ -6,6 +6,20 @@
:model="queryParams"
inline
>
<el-form-item label="用户ID" prop="user_id">
<el-input class="w-[280px]" v-model="queryParams.user_id" clearable placeholder="请输入用户ID" />
</el-form-item>
<el-form-item label="土地ID" prop="land_id">
<el-input class="w-[280px]" v-model="queryParams.land_id" clearable placeholder="请输入土地ID" />
</el-form-item>
<el-form-item label="产品ID" prop="product_id">
<el-input
class="w-[280px]"
v-model="queryParams.product_id"
clearable
placeholder="请输入产品ID"
/>
</el-form-item>
<el-form-item label="设备编码" prop="code">
<el-input class="w-[280px]" v-model="queryParams.code" clearable placeholder="请输入设备编码" />
</el-form-item>
@ -63,40 +77,69 @@
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<el-button v-perms="['device.device/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<el-button
v-perms="['device.device/delete']"
:disabled="!selectData.length"
@click="handleDelete(selectData)"
>
删除
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<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" show-overflow-tooltip />
<el-table-column label="设备编码" prop="code" show-overflow-tooltip />
<el-table-column label="设备名称" prop="name" show-overflow-tooltip />
<el-table-column label="土地ID" prop="land_id" show-overflow-tooltip />
<el-table-column label="土地名称" prop="title" show-overflow-tooltip />
<el-table-column label="设备类型" prop="type">
<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.user_id }}</el-tag>
<el-tag class="mr-2" type="success">账户: {{ 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.land_title }}</el-tag>
</template>
</el-table-column>
<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>
</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="设备状态" prop="status">
<el-table-column label="设备状态" width="100" align="center" prop="status">
<template #default="{ row }">
<dict-value :options="dictData.device_status" :value="row.status" />
</template>
</el-table-column>
<el-table-column label="是否在线" prop="is_online">
<el-table-column label="是否在线" width="100" align="center" prop="is_online">
<template #default="{ row }">
<dict-value :options="dictData.device_online_status" :value="row.is_online" />
</template>
</el-table-column>
<el-table-column label="是否绑定土地" prop="is_bind">
<el-table-column label="是否绑定土地" width="150" align="center" prop="is_bind">
<template #default="{ row }">
<dict-value :options="dictData.device_bind_status" :value="row.is_bind" />
</template>
</el-table-column>
<el-table-column label="创建时间" width="160" prop="create_time">
<el-table-column label="创建时间" width="160" align="center" prop="create_time">
<template #default="{ row }">
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="300" align="center" fixed="right">
<el-table-column label="操作" width="200" align="center" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['device.device/edit']"
@ -106,46 +149,6 @@
>
编辑
</el-button>
<el-button v-if="row.type == 1"
v-perms="['device.soil_monitor/lists']"
type="primary"
link
>
<router-link
:to="{
path: getRoutePath('device.soil_monitor/lists'),
query: {
device_id: row.id
}
}"
>
查看土壤
</router-link>
</el-button>
<el-button v-if="row.type == 2"
v-perms="['device.air_monitor/lists']"
type="primary"
link
>
<router-link
:to="{
path: getRoutePath('device.air_monitor/lists'),
query: {
device_id: row.id
}
}"
>
查看空气
</router-link>
</el-button>
<el-button v-if="row.type == 3"
v-perms="['device.device/edit']"
type="primary"
link
@click="handleEdit(row)"
>
查看视频
</el-button>
<el-button
v-perms="['device.monitor_alarm/lists']"
type="primary"
@ -191,19 +194,27 @@ import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const { query } = useRoute()
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
let product_id = query.product_id
if (typeof product_id == 'undefined') {
product_id = ''
}
//
const queryParams = reactive({
user_id: '',
land_id: '',
product_id: product_id,
code: '',
name: '',
type: '',
status: '',
is_online: '',
is_bind: '',
is_bind: ''
})
//
@ -215,7 +226,7 @@ const handleSelectionChange = (val: any[]) => {
}
//
const { dictData } = useDictData('device_type,device_status,device_online_status,device_bind_status')
const { dictData } = useDictData('device_type,device_status,device_online_status,device_bind_status,monitor_item')
//
const { pager, getLists, resetParams, resetPage } = usePaging({

View File

@ -83,6 +83,9 @@
</el-form-item>
<el-form-item label="负责人电话" prop="master_phone">
<el-input v-model="formData.master_phone" clearable placeholder="请输入负责人电话" />
</el-form-item>
<el-form-item label="土地图片" prop="pic">
<material-picker v-model="formData.pic" :limit="4" />
</el-form-item>
</el-form>
</popup>
@ -134,6 +137,7 @@ const formData = reactive({
latitude: '',
master_name: '',
master_phone: '',
pic: ''
})
//
@ -167,10 +171,11 @@ const setFormData = async (data: Record<any, any>) => {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
if (key == 'pic') {
formData[key] = ''
}
}
}
}
const getDetail = async (row: Record<string, any>) => {

View File

@ -40,21 +40,25 @@
删除
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<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">
<template #default="{ row }">
<el-tag class="ml-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="ml-2" type="success">账户: {{ row.user.account }}</el-tag>
<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>
</template>
</el-table-column>
<el-table-column label="土地名称" prop="title" show-overflow-tooltip />
<el-table-column label="土地名称">
<template #default="{ row }">
<el-tag class="mr-2" type="success">{{ row.title }}</el-tag>
</template>
</el-table-column>
<el-table-column label="土地面积" prop="total_area" show-overflow-tooltip />
<el-table-column label="剩余面积" prop="residual_area" show-overflow-tooltip />
<el-table-column label="土地负责人" prop="master_name" show-overflow-tooltip />
<el-table-column label="负责人电话" prop="master_phone" show-overflow-tooltip />
<el-table-column label="操作" width="280" align="center" fixed="right">
<el-table-column label="操作" width="350" align="center" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['land.land/edit']"
@ -64,22 +68,6 @@
>
编辑
</el-button>
<el-button
v-perms="['land.land_plant/lists']"
type="primary"
link
>
<router-link
:to="{
path: getRoutePath('land.land_plant/lists'),
query: {
land_id: row.id
}
}"
>
种植信息
</router-link>
</el-button>
<el-button
v-perms="['land.product/lists']"
type="primary"
@ -96,6 +84,26 @@
产品信息
</router-link>
</el-button>
<el-button type="primary" link @click="handleDetail(row)"
>
土地图片
</el-button>
<el-button
v-perms="['land.land_plant/lists']"
type="primary"
link
>
<router-link
:to="{
path: getRoutePath('land.land_plant/lists'),
query: {
land_id: row.id
}
}"
>
种植信息
</router-link>
</el-button>
<el-button
v-perms="['land.land/delete']"
type="danger"
@ -114,6 +122,22 @@
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
<el-dialog v-model="dialogPicVisible" title="土地图片" center>
<div style="display: inline-block; margin: 12px" v-for="img in detailData.picData" :key="img">
<el-image
style="width: 200px; height: 200px"
:src="img"
:zoom-rate="1.2"
:max-scale="5"
:min-scale="0.2"
:preview-src-list="detailData.picData"
:initial-index="4"
fit="cover"
center
/>
</div>
</el-dialog>
</template>
<script lang="ts" setup name="landLists">
@ -131,7 +155,7 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
let user_id = query.user_id
if (typeof(user_id) == 'undefined') {
if (typeof user_id == 'undefined') {
user_id = ''
}
@ -160,6 +184,22 @@ const { pager, getLists, resetParams, resetPage } = usePaging({
params: queryParams
})
const dialogPicVisible = ref(false)
const detailData = reactive({
picData: [] as any[]
})
//
const handleDetail = (data: any) => {
detailData.picData = []
const picList = JSON.parse(data.pic)
for (const key in picList) {
detailData.picData.unshift(picList[key])
}
console.log(detailData.picData)
dialogPicVisible.value = true
}
//
const handleAdd = async () => {
showEdit.value = true

View File

@ -126,7 +126,7 @@ const formData = reactive({
status: '',
pic: '',
qr_code: '',
plant_date: '',
plant_date: ''
})
@ -176,6 +176,9 @@ const setFormData = async (data: Record<any, any>) => {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
if (key == 'pic') {
formData[key] = ''
}
}
}

View File

@ -52,36 +52,36 @@
<el-table-column label="ID" prop="id" width="80" show-overflow-tooltip />
<el-table-column label="用户信息" width="200">
<template #default="{ row }">
<el-tag class="ml-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="ml-2" type="success">账户: {{ row.account }}</el-tag>
<el-tag class="mr-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="success">账户: {{ row.account }}</el-tag>
</template>
</el-table-column>
<el-table-column label="土地信息" width="200">
<template #default="{ row }">
<el-tag class="ml-2" type="success">ID: {{ row.land_id }}</el-tag>
<el-tag class="ml-2" type="success">名称: {{ row.title }}</el-tag>
<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="kind" show-overflow-tooltip />
<el-table-column label="种植品牌" prop="breed" show-overflow-tooltip />
<el-table-column label="种植面积" prop="area" show-overflow-tooltip />
<el-table-column label="种植人员" prop="user" show-overflow-tooltip />
<el-table-column label="生长状态" prop="status">
<el-table-column label="生长状态" align="center" prop="status">
<template #default="{ row }">
<dict-value :options="dictData.plant_status" :value="row.status" />
</template>
</el-table-column>
<el-table-column label="溯源二维码" width="150" prop="qr_code">
<el-table-column label="溯源二维码" width="150" align="center" prop="qr_code">
<template #default="{ row }">
<el-image style="width:50px;height:50px;" :src="row.qr_code" />
</template>
</el-table-column>
<el-table-column label="播种时间" width="180" prop="plant_date">
<el-table-column label="播种时间" width="180" align="center" prop="plant_date">
<template #default="{ row }">
<span>{{ row.plant_date ? timeFormat(row.plant_date, '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="300" align="center" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['land.land_plant/edit']"
@ -91,6 +91,10 @@
>
编辑
</el-button>
<el-button type="primary" link @click="handleDetail(row)"
>
种植图片
</el-button>
<el-button v-perms="['land.land_plant_action/lists']" type="primary" link >
<router-link
:to="{
@ -121,6 +125,22 @@
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
<el-dialog v-model="dialogPicVisible" title="种植图片" center>
<div style="display: inline-block; margin: 12px" v-for="img in detailData.picData" :key="img">
<el-image
style="width: 200px; height: 200px"
:src="img"
:zoom-rate="1.2"
:max-scale="5"
:min-scale="0.2"
:preview-src-list="detailData.picData"
:initial-index="4"
fit="cover"
center
/>
</div>
</el-dialog>
</template>
<script lang="ts" setup name="landPlantLists">
@ -138,7 +158,7 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
let land_id = query.land_id
if (typeof(land_id) == 'undefined') {
if (typeof land_id == 'undefined') {
land_id = ''
}
@ -172,6 +192,22 @@ const { pager, getLists, resetParams, resetPage } = usePaging({
params: queryParams
})
const dialogPicVisible = ref(false)
const detailData = reactive({
picData: [] as any[]
})
//
const handleDetail = (data: any) => {
detailData.picData = []
const picList = JSON.parse(data.pic)
for (const key in picList) {
detailData.picData.unshift(picList[key])
}
console.log(detailData.picData)
dialogPicVisible.value = true
}
//
const handleAdd = async () => {
showEdit.value = true

View File

@ -42,24 +42,24 @@
<el-table-column label="ID" prop="id" width="80" show-overflow-tooltip />
<el-table-column label="用户信息" width="200">
<template #default="{ row }">
<el-tag class="ml-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="ml-2" type="success">账户: {{ row.account }}</el-tag>
<el-tag class="mr-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="success">账户: {{ row.account }}</el-tag>
</template>
</el-table-column>
<el-table-column label="土地种植信息" width="200">
<template #default="{ row }">
<el-tag class="ml-2" type="success">ID: {{ row.plant_id }}</el-tag>
<el-tag class="ml-2" type="success">类型: {{ row.kind }} 品牌: {{ row.breed }}</el-tag>
<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>
</template>
</el-table-column>
<el-table-column label="种植操作类型" prop="type">
<el-table-column label="种植操作类型" align="center" prop="type">
<template #default="{ row }">
<dict-value :options="dictData.land_plant_action" :value="row.type" />
</template>
</el-table-column>
<el-table-column label="种植操作" prop="type_text" show-overflow-tooltip />
<el-table-column label="种植操作详情" prop="detail" show-overflow-tooltip />
<el-table-column label="种植操作时间" width="180" prop="plant_date">
<el-table-column label="种植操作时间" width="180" align="center" prop="plant_date">
<template #default="{ row }">
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
</template>
@ -108,7 +108,7 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
let plant_id = query.plant_id
if (typeof(plant_id) == 'undefined') {
if (typeof plant_id == 'undefined') {
plant_id = ''
}

View File

@ -36,24 +36,28 @@
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" show-overflow-tooltip />
<el-table-column label="设备ID" prop="device_id" show-overflow-tooltip />
<el-table-column label="设备名称" prop="device.name" show-overflow-tooltip />
<el-table-column label="监测类型" prop="type">
<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>
</template>
</el-table-column>
<el-table-column label="监测类型" align="center" prop="type">
<template #default="{ row }">
<dict-value :options="dictData.alarm_type" :value="row.type" />
</template>
</el-table-column>
<el-table-column label="报警内容" prop="content" show-overflow-tooltip />
<el-table-column label="报警内容" width="300" prop="content" show-overflow-tooltip />
<el-table-column label="报警数值" prop="value" show-overflow-tooltip />
<el-table-column label="报警时间" prop="plant_date">
<el-table-column label="报警时间" align="center" prop="create_time">
<template #default="{ row }">
<span>{{ row.create_time ? timeFormat(row.plant_date, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
<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">
<template #default="{ row }">
<el-button text @click="handleDetail(row)"
<el-button type="primary" link @click="handleDetail(row)"
>
详情
</el-button>
@ -81,7 +85,7 @@
<el-table-column property="item" label="监测项" width="150" />
<el-table-column property="value" label="监测数据" />
</el-table>
</el-dialog>
</el-dialog>
</template>
<script lang="ts" setup name="monitorAlarmLists">
@ -97,13 +101,13 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
var device_id = query.device_id
if (typeof(device_id) == 'undefined') {
let device_id = query.device_id
if (typeof device_id == 'undefined') {
device_id = ''
}
//
const queryParams = reactive({
const queryParams = reactive({
device_id: device_id,
type: '',
start_time: '',
@ -141,6 +145,10 @@ const handleDetail = (data: any) => {
deviceType = dictData['alarm_type'][key]['name']
}
}
detailData.gridData.unshift({
item: '报警时间',
value: data.create_time ? timeFormat(data.create_time, 'yyyy-mm-dd hh:MM:ss') : ''
})
detailData.gridData.unshift({
item: '解决方案',
value: data.solution

View File

@ -50,7 +50,7 @@
/>
<el-table-column label="部门状态" prop="status" min-width="100">
<template #default="{ row }">
<el-tag class="ml-2" :type="row.status ? '' : 'danger'">{{
<el-tag class="mr-2" :type="row.status ? '' : 'danger'">{{
row.status_desc
}}</el-tag>
</template>

View File

@ -54,7 +54,7 @@
<el-table-column label="添加时间" prop="create_time" min-width="180" />
<el-table-column label="状态" prop="status" min-width="100">
<template #default="{ row }">
<el-tag class="ml-2" :type="row.status ? '' : 'danger'">
<el-tag class="mr-2" :type="row.status ? '' : 'danger'">
{{ row.status_desc }}
</el-tag>
</template>

View File

@ -62,24 +62,24 @@
<el-table-column label="ID" prop="id" width="80" show-overflow-tooltip />
<el-table-column label="用户信息" width="200">
<template #default="{ row }">
<el-tag class="ml-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="ml-2" type="success">账户: {{ row.account }}</el-tag>
<el-tag class="mr-2" type="success">ID: {{ row.user_id }}</el-tag>
<el-tag class="mr-2" type="success">账户: {{ row.account }}</el-tag>
</template>
</el-table-column>
<el-table-column label="土地信息" width="200">
<template #default="{ row }">
<el-tag class="ml-2" type="success">ID: {{ row.land_id }}</el-tag>
<el-tag class="ml-2" type="success">名称: {{ row.title }}</el-tag>
<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 label="产品名称" prop="name" show-overflow-tooltip />
<el-table-column label="产品状态" prop="status">
<el-table-column label="产品状态" align="center" prop="status">
<template #default="{ row }">
<dict-value :options="dictData.product_status" :value="row.status" />
</template>
</el-table-column>
<el-table-column label="创建时间" width="180" prop="create_time">
<el-table-column label="创建时间" width="180" align="center" prop="create_time">
<template #default="{ row }">
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
</template>
@ -128,7 +128,7 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
let land_id = query.land_id
if (typeof(land_id) == 'undefined') {
if (typeof land_id == 'undefined') {
land_id = ''
}
//

View File

@ -1,173 +0,0 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
<el-form-item label="设备ID" prop="device_id">
<el-input v-model="formData.device_id" disabled clearable placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="土壤温度" prop="temperature">
<el-input v-model="formData.temperature" disabled clearable placeholder="请输入土壤温度" />
</el-form-item>
<el-form-item label="土壤湿度" prop="moisture">
<el-input v-model="formData.moisture" disabled clearable placeholder="请输入土壤湿度" />
</el-form-item>
<el-form-item label="电导率" prop="conductivity">
<el-input v-model="formData.conductivity" disabled clearable placeholder="请输入电导率" />
</el-form-item>
<el-form-item label="土壤酸碱度" prop="ph">
<el-input v-model="formData.ph" disabled clearable placeholder="请输入土壤酸碱度" />
</el-form-item>
<el-form-item label="氮含量" prop="n_content">
<el-input v-model="formData.n_content" disabled clearable placeholder="请输入氮含量" />
</el-form-item>
<el-form-item label="磷含量" prop="p_content">
<el-input v-model="formData.p_content" disabled clearable placeholder="请输入磷含量" />
</el-form-item>
<el-form-item label="钾含量" prop="k_content">
<el-input v-model="formData.k_content" disabled clearable placeholder="请输入钾含量" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="soilMonitorEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiSoilMonitorAdd, apiSoilMonitorEdit, apiSoilMonitorDetail } from '@/api/soil_monitor'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '土壤监测数据' : '新增土壤监测'
})
//
const formData = reactive({
id: '',
device_id: '',
temperature: '',
moisture: '',
conductivity: '',
ph: '',
n_content: '',
p_content: '',
k_content: '',
})
//
const formRules = reactive<any>({
device_id: [{
required: true,
message: '请输入设备ID',
trigger: ['blur']
}],
temperature: [{
required: true,
message: '请输入土壤温度',
trigger: ['blur']
}],
moisture: [{
required: true,
message: '请输入土壤湿度',
trigger: ['blur']
}],
conductivity: [{
required: true,
message: '请输入电导率',
trigger: ['blur']
}],
ph: [{
required: true,
message: '请输入土壤酸碱度',
trigger: ['blur']
}],
n_content: [{
required: true,
message: '请输入氮含量',
trigger: ['blur']
}],
p_content: [{
required: true,
message: '请输入磷含量',
trigger: ['blur']
}],
k_content: [{
required: true,
message: '请输入钾含量',
trigger: ['blur']
}],
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
//@ts-ignore
formData.create_time = timeFormat(formData.create_time,'yyyy-mm-dd hh:MM:ss')
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiSoilMonitorDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiSoilMonitorEdit(data)
: await apiSoilMonitorAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -1,191 +0,0 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="设备ID" prop="device_id">
<el-input class="w-[280px]" v-model="queryParams.device_id" clearable placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="监测时间" prop="create_time">
<daterange-picker
v-model:startTime="queryParams.start_time"
v-model:endTime="queryParams.end_time"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" show-overflow-tooltip />
<el-table-column label="设备ID" prop="device_id" show-overflow-tooltip />
<el-table-column label="设备名称" prop="device.name" show-overflow-tooltip />
<el-table-column label="土壤温度" prop="temperature" show-overflow-tooltip />
<el-table-column label="土壤湿度" prop="moisture" show-overflow-tooltip />
<el-table-column label="电导率" prop="conductivity" show-overflow-tooltip />
<el-table-column label="土壤酸碱度" prop="ph" show-overflow-tooltip />
<el-table-column label="氮含量" prop="n_content" show-overflow-tooltip />
<el-table-column label="磷含量" prop="p_content" show-overflow-tooltip />
<el-table-column label="钾含量" prop="k_content" show-overflow-tooltip />
<el-table-column label="监测时间" width="160" prop="create_time">
<template #default="{ row }">
<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">
<template #default="{ row }">
<el-button text @click="handleDetail(row)"
>
详情
</el-button>
<el-button
v-perms="['device.soil_monitor/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
<el-dialog v-model="dialogTableVisible" title="土壤监测数据">
<el-table :data="detailData.gridData">
<el-table-column property="item" label="监测项" width="150" />
<el-table-column property="value" label="监测数据" />
</el-table>
</el-dialog>
</template>
<script lang="ts" setup name="soilMonitorLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiSoilMonitorLists, apiSoilMonitorDelete } from '@/api/soil_monitor'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import type EditPopup from './edit.vue'
const { query } = useRoute()
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
var device_id = query.device_id
if (typeof(device_id) == 'undefined') {
device_id = ''
}
//
const queryParams = reactive({
device_id: device_id,
start_time: '',
end_time: ''
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiSoilMonitorLists,
params: queryParams
})
const dialogTableVisible = ref(false)
const detailData = reactive({
gridData : [{}]
})
//
const handleDetail = (data: any) => {
detailData.gridData = [{}]
detailData.gridData.unshift({
item: '钾含量',
value: data.k_content
})
detailData.gridData.unshift({
item: '磷含量',
value: data.p_content
})
detailData.gridData.unshift({
item: '氮含量',
value: data.n_content
})
detailData.gridData.unshift({
item: '土壤酸碱度',
value: data.ph
})
detailData.gridData.unshift({
item: '电导率',
value: data.conductivity
})
detailData.gridData.unshift({
item: '土壤湿度',
value: data.moisture
})
detailData.gridData.unshift({
item: '土壤温度',
value: data.temperature
})
detailData.gridData.unshift({
item: '设备名称',
value: data.device.name
})
detailData.gridData.unshift({
item: '设备ID',
value: data.device_id
})
dialogTableVisible.value = true
}
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiSoilMonitorDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -36,7 +36,7 @@ class UploadController extends BaseAdminController
{
try {
$cid = $this->request->post('cid', 0);
$result = UploadService::image($cid);
$result = UploadService::image($cid, $this->adminInfo['user_id']);
return $this->success('上传成功', $result);
} catch (Exception $e) {
return $this->fail($e->getMessage());
@ -53,7 +53,7 @@ class UploadController extends BaseAdminController
{
try {
$cid = $this->request->post('cid', 0);
$result = UploadService::video($cid);
$result = UploadService::video($cid, $this->adminInfo['user_id']);
return $this->success('上传成功', $result);
} catch (Exception $e) {
return $this->fail($e->getMessage());

View File

@ -1,108 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\device;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\device\AirMonitorLists;
use app\adminapi\logic\device\AirMonitorLogic;
use app\adminapi\validate\device\AirMonitorValidate;
/**
* AirMonitor控制器
* Class AirMonitorController
* @package app\adminapi\controller\device
*/
class AirMonitorController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function lists()
{
return $this->dataLists(new AirMonitorLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function add()
{
$params = (new AirMonitorValidate())->post()->goCheck('add');
$result = AirMonitorLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(AirMonitorLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function edit()
{
$params = (new AirMonitorValidate())->post()->goCheck('edit');
$result = AirMonitorLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(AirMonitorLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function delete()
{
$params = (new AirMonitorValidate())->post()->goCheck('delete');
AirMonitorLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function detail()
{
$params = (new AirMonitorValidate())->goCheck('detail');
$result = AirMonitorLogic::detail($params);
return $this->data($result);
}
}

View File

@ -1,108 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\device;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\device\SoilMonitorLists;
use app\adminapi\logic\device\SoilMonitorLogic;
use app\adminapi\validate\device\SoilMonitorValidate;
/**
* SoilMonitor控制器
* Class SoilMonitorController
* @package app\adminapi\controller\device
*/
class SoilMonitorController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function lists()
{
return $this->dataLists(new SoilMonitorLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function add()
{
$params = (new SoilMonitorValidate())->post()->goCheck('add');
$result = SoilMonitorLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SoilMonitorLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function edit()
{
$params = (new SoilMonitorValidate())->post()->goCheck('edit');
$result = SoilMonitorLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SoilMonitorLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function delete()
{
$params = (new SoilMonitorValidate())->post()->goCheck('delete');
SoilMonitorLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function detail()
{
$params = (new SoilMonitorValidate())->goCheck('detail');
$result = SoilMonitorLogic::detail($params);
return $this->data($result);
}
}

View File

@ -1,92 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\device;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\device\AirMonitor;
use app\common\lists\ListsSearchInterface;
/**
* AirMonitor列表
* Class AirMonitorLists
* @package app\adminapi\listsdevice
*/
class AirMonitorLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function setSearch(): array
{
$allowSearch = ['start_time', 'end_time'];
if (!empty($this->params['device_id'])) {
$allowSearch[] = 'device_id';
}
return array_intersect(array_keys($this->params), $allowSearch);
}
public function userSearch(): array
{
$userWhere['user_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['user_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['user_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function lists(): array
{
return AirMonitor::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->with('device')
->field(['id', 'device_id', 'wind_direction', 'wind_speed', 'temperature', 'moisture', 'co2_content', 'pressure', 'rainfall', 'light_intensity', 'create_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function count(): int
{
return AirMonitor::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->count();
}
}

View File

@ -41,10 +41,23 @@ class DeviceLists extends BaseAdminDataLists implements ListsSearchInterface
public function setSearch(): array
{
return [
'=' => ['d.code', 'd.name', 'd.type', 'd.status', 'd.is_online', 'd.is_bind'],
'%like%' => ['d.name'],
'=' => ['d.user_id', 'd.code', 'd.type', 'd.status', 'd.is_online', 'd.is_bind'],
];
}
public function querySearch(): array
{
$queryWhere = [];
if (!empty($this->params['land_id'])) {
$queryWhere['lp.land_id'] = $this->params['land_id'];
}
if (!empty($this->params['product_id'])) {
$queryWhere['pd.product_id'] = $this->params['product_id'];
}
return $queryWhere;
}
public function userSearch(): array
{
$userWhere['d.user_id'] = 0;
@ -71,13 +84,23 @@ class DeviceLists extends BaseAdminDataLists implements ListsSearchInterface
public function lists(): array
{
return Db::name('device')->alias('d')
->where($this->searchWhere)->where($this->userSearch())
// ->leftJoin('land_device ld','ld.device_id = d.id')
// ->leftJoin('land l','l.id = ld.land_id')
// ->field('d.*, ld.land_id, l.title')
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
->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')
->limit($this->limitOffset, $this->limitLength)
->order(['d.id' => 'desc'])
->select()
->select()->each(function($item, $key){
$monitorItemArray = [];
if (!empty($item['monitor_item'])) {
$monitorItemArray = explode(',', $item['monitor_item']);
}
$item['monitor_item'] = $monitorItemArray;
return $item;
})
->toArray();
}
@ -90,7 +113,13 @@ class DeviceLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function count(): int
{
return Db::name('device')->alias('d')->where($this->searchWhere)->where($this->userSearch())->count();
return Db::name('device')->alias('d')->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
->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')
->count();
}
}

View File

@ -1,92 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\device;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\device\SoilMonitor;
use app\common\lists\ListsSearchInterface;
/**
* SoilMonitor列表
* Class SoilMonitorLists
* @package app\adminapi\listsdevice
*/
class SoilMonitorLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function setSearch(): array
{
$allowSearch = ['start_time', 'end_time'];
if (!empty($this->params['device_id'])) {
$allowSearch[] = 'device_id';
}
return array_intersect(array_keys($this->params), $allowSearch);
}
public function userSearch(): array
{
$userWhere['user_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['user_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['user_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function lists(): array
{
return SoilMonitor::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->with('device')
->field(['id', 'device_id', 'temperature', 'moisture', 'conductivity', 'ph', 'n_content', 'p_content', 'k_content', 'create_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function count(): int
{
return SoilMonitor::withSearch($this->setSearch(), $this->params)->where($this->userSearch())->count();
}
}

View File

@ -42,6 +42,19 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface
];
}
public function userSearch(): array
{
$userWhere['source_id'] = 0;
// 超级管理员数据
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
unset($userWhere['source_id']);
}
// 普通用户数据
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
$userWhere['source_id'] = $this->adminInfo['user_id'];
}
return $userWhere;
}
/**
* @notes 获取文件列表
@ -57,7 +70,8 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface
$lists = (new File())->field(['id,cid,type,name,uri,create_time'])
->order('id', 'desc')
->where($this->searchWhere)
->where('source', FileEnum::SOURCE_ADMIN)
->where($this->userSearch())
// ->where('source', FileEnum::SOURCE_ADMIN)
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
@ -79,8 +93,8 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function count(): int
{
return (new File())->where($this->searchWhere)
->where('source', FileEnum::SOURCE_ADMIN)
return (new File())->where($this->searchWhere)->where($this->userSearch())
// ->where('source', FileEnum::SOURCE_ADMIN)
->count();
}
}

View File

@ -69,7 +69,7 @@ class LandLists extends BaseAdminDataLists implements ListsSearchInterface
public function lists(): array
{
return Land::where($this->searchWhere)->where($this->userSearch())->with('user')
->field(['id', 'user_id', 'title', 'total_area', 'residual_area', 'province_code', 'province_name', 'city_code', 'city_name', 'county_code', 'county_name', 'town_code', 'town_name', 'village_code', 'village_name', 'group_code', 'group_name', 'longitude', 'latitude', 'master_name', 'master_phone'])
->field(['id', 'user_id', 'title', 'total_area', 'residual_area', 'province_code', 'province_name', 'city_code', 'city_name', 'county_code', 'county_name', 'town_code', 'town_name', 'village_code', 'village_name', 'group_code', 'group_name', 'longitude', 'latitude', 'master_name', 'master_phone', 'pic'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()

View File

@ -104,7 +104,11 @@ class LandPlantActionLists extends BaseAdminDataLists implements ListsSearchInte
*/
public function count(): int
{
return Db::name('land_plant_action')->alias('lpa')->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())->count();
return Db::name('land_plant_action')->alias('lpa')
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
->leftJoin('user u','u.id = lpa.user_id')
->leftJoin('land_plant lp','lp.id = lpa.plant_id')
->count();
}
}

View File

@ -108,7 +108,11 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function count(): int
{
return Db::name('land_plant')->alias('lp')->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())->count();
return Db::name('land_plant')->alias('lp')
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
->leftJoin('user u','u.id = lp.user_id')
->leftJoin('land l','l.id = lp.land_id')
->count();
}
}

View File

@ -38,7 +38,8 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
public function setSearch(): array
{
return [
'=' => ['p.user_id', 'p.code', 'p.name', 'p.status'],
'%like%' => ['p.name'],
'=' => ['p.user_id', 'p.code', 'p.status'],
];
}
@ -103,7 +104,12 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function count(): int
{
return Db::name('product')->alias('p')->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())->count();
return Db::name('product')->alias('p')
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
->leftJoin('user u','u.id = p.user_id')
->leftJoin('land_product lp','lp.product_id = p.id')
->leftJoin('land l','l.id = lp.land_id')
->count();
}
}

View File

@ -1,122 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\device;
use app\common\model\device\AirMonitor;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* AirMonitor逻辑
* Class AirMonitorLogic
* @package app\adminapi\logic\device
*/
class AirMonitorLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 16:49
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
AirMonitor::create([
'device_id' => $params['device_id'],
'wind_direction' => $params['wind_direction'],
'wind_speed' => $params['wind_speed'],
'temperature' => $params['temperature'],
'moisture' => $params['moisture'],
'co2_content' => $params['co2_content'],
'pressure' => $params['pressure'],
'rainfall' => $params['rainfall'],
'light_intensity' => $params['light_intensity'],
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 16:49
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
AirMonitor::where('id', $params['id'])->update([
'device_id' => $params['device_id'],
'wind_direction' => $params['wind_direction'],
'wind_speed' => $params['wind_speed'],
'temperature' => $params['temperature'],
'moisture' => $params['moisture'],
'co2_content' => $params['co2_content'],
'pressure' => $params['pressure'],
'rainfall' => $params['rainfall'],
'light_intensity' => $params['light_intensity'],
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 16:49
*/
public static function delete(array $params): bool
{
return AirMonitor::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/11/24 16:49
*/
public static function detail($params): array
{
return AirMonitor::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -38,17 +38,30 @@ class DeviceLogic extends BaseLogic
*/
public static function add(array $params): bool
{
if (is_array($params['monitor_item'])) {
$params['monitor_item'] = implode(',', $params['monitor_item']);
} else {
$params['monitor_item'] = trim($params['monitor_item']);
}
Db::startTrans();
try {
Device::create([
'code' => $params['code'],
'name' => $params['name'],
'type' => $params['type'],
'status' => $params['status'],
'is_online' => $params['is_online'],
$device = Device::create([
'user_id' => $params['user_id'],
'code' => $params['code'],
'name' => $params['name'],
'type' => $params['type'],
'monitor_item' => $params['monitor_item'],
'status' => $params['status'],
'is_online' => $params['is_online'],
'is_bind' => $params['is_bind'],
]);
Db::name('product_device')->insert([
'product_id' => $params['product_id'],
'device_id' => $device['id'],
'device_type' => $params['type'],
'create_time' => time(),
'update_time' => time()
]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -68,17 +81,31 @@ class DeviceLogic extends BaseLogic
*/
public static function edit(array $params): bool
{
if (is_array($params['monitor_item'])) {
$params['monitor_item'] = implode(',', $params['monitor_item']);
} else {
$params['monitor_item'] = trim($params['monitor_item']);
}
Db::startTrans();
try {
Device::where('id', $params['id'])->update([
'code' => $params['code'],
'name' => $params['name'],
'type' => $params['type'],
'status' => $params['status'],
'is_online' => $params['is_online'],
$device = Device::where('id', $params['id'])->update([
'user_id' => $params['user_id'],
'code' => $params['code'],
'name' => $params['name'],
'type' => $params['type'],
'monitor_item' => $params['monitor_item'],
'status' => $params['status'],
'is_online' => $params['is_online'],
'is_bind' => $params['is_bind'],
]);
Db::name('product_device')->where('device_id', $params['id'])->delete();
Db::name('product_device')->insert([
'product_id' => $params['product_id'],
'device_id' => $params['id'],
'device_type' => $params['type'],
'create_time' => time(),
'update_time' => time()
]);
Db::commit();
return true;
} catch (\Exception $e) {

View File

@ -1,120 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\device;
use app\common\model\device\SoilMonitor;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* SoilMonitor逻辑
* Class SoilMonitorLogic
* @package app\adminapi\logic\device
*/
class SoilMonitorLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 17:02
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
SoilMonitor::create([
'device_id' => $params['device_id'],
'temperature' => $params['temperature'],
'moisture' => $params['moisture'],
'conductivity' => $params['conductivity'],
'ph' => $params['ph'],
'n_content' => $params['n_content'],
'p_content' => $params['p_content'],
'k_content' => $params['k_content'],
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 17:02
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SoilMonitor::where('id', $params['id'])->update([
'device_id' => $params['device_id'],
'temperature' => $params['temperature'],
'moisture' => $params['moisture'],
'conductivity' => $params['conductivity'],
'ph' => $params['ph'],
'n_content' => $params['n_content'],
'p_content' => $params['p_content'],
'k_content' => $params['k_content'],
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 17:02
*/
public static function delete(array $params): bool
{
return SoilMonitor::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/11/24 17:02
*/
public static function detail($params): array
{
return SoilMonitor::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -61,6 +61,7 @@ class LandLogic extends BaseLogic
'latitude' => $params['latitude'],
'master_name' => $params['master_name'],
'master_phone' => $params['master_phone'],
'pic' => json_encode($params['pic']),
]);
Db::commit();
@ -105,6 +106,7 @@ class LandLogic extends BaseLogic
'latitude' => $params['latitude'],
'master_name' => $params['master_name'],
'master_phone' => $params['master_phone'],
'pic' => json_encode($params['pic']),
]);
Db::commit();

View File

@ -1,112 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\device;
use app\common\validate\BaseValidate;
/**
* AirMonitor验证器
* Class AirMonitorValidate
* @package app\adminapi\validate\device
*/
class AirMonitorValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'device_id' => 'require',
'wind_direction' => 'require',
'wind_speed' => 'require',
'temperature' => 'require',
'moisture' => 'require',
'co2_content' => 'require',
'pressure' => 'require',
'rainfall' => 'require',
'light_intensity' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'device_id' => '设备ID',
'wind_direction' => '风向',
'wind_speed' => '风速',
'temperature' => '空气温度',
'moisture' => '空气湿度',
'co2_content' => '二氧化碳含量',
'pressure' => '大气压强',
'rainfall' => '降雨量',
'light_intensity' => '光照强度',
];
/**
* @notes 添加场景
* @return AirMonitorValidate
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function sceneAdd()
{
return $this->only(['device_id','wind_direction','wind_speed','temperature','moisture','co2_content','pressure','rainfall','light_intensity']);
}
/**
* @notes 编辑场景
* @return AirMonitorValidate
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function sceneEdit()
{
return $this->only(['id','device_id','wind_direction','wind_speed','temperature','moisture','co2_content','pressure','rainfall','light_intensity']);
}
/**
* @notes 删除场景
* @return AirMonitorValidate
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return AirMonitorValidate
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -31,13 +31,13 @@ class DeviceValidate extends BaseValidate
* @var string[]
*/
protected $rule = [
'id' => 'require',
'code' => 'require',
'name' => 'require',
'type' => 'require',
'status' => 'require',
'is_online' => 'require',
'is_bind' => 'require',
'id' => 'require',
'code' => 'require',
'name' => 'require',
'type' => 'require',
'status' => 'require',
'is_online' => 'require',
'is_bind' => 'require',
];
@ -46,13 +46,13 @@ class DeviceValidate extends BaseValidate
* @var string[]
*/
protected $field = [
'id' => 'id',
'code' => '设备编码',
'name' => '设备名称',
'type' => '设备类型',
'status' => '设备状态',
'is_online' => '是否在线',
'is_bind' => '是否绑定土地',
'id' => 'id',
'code' => '设备编码',
'name' => '设备名称',
'type' => '设备类型',
'status' => '设备状态',
'is_online' => '是否在线',
'is_bind' => '是否绑定土地',
];

View File

@ -1,110 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\device;
use app\common\validate\BaseValidate;
/**
* SoilMonitor验证器
* Class SoilMonitorValidate
* @package app\adminapi\validate\device
*/
class SoilMonitorValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'device_id' => 'require',
'temperature' => 'require',
'moisture' => 'require',
'conductivity' => 'require',
'ph' => 'require',
'n_content' => 'require',
'p_content' => 'require',
'k_content' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'device_id' => '设备ID',
'temperature' => '土壤温度',
'moisture' => '土壤湿度',
'conductivity' => '电导率',
'ph' => '土壤酸碱度',
'n_content' => '氮含量',
'p_content' => '磷含量',
'k_content' => '钾含量',
];
/**
* @notes 添加场景
* @return SoilMonitorValidate
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function sceneAdd()
{
return $this->only(['device_id','temperature','moisture','conductivity','ph','n_content','p_content','k_content']);
}
/**
* @notes 编辑场景
* @return SoilMonitorValidate
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function sceneEdit()
{
return $this->only(['id','device_id','temperature','moisture','conductivity','ph','n_content','p_content','k_content']);
}
/**
* @notes 删除场景
* @return SoilMonitorValidate
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SoilMonitorValidate
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -16,6 +16,7 @@ namespace app\adminapi\validate\land;
use app\common\validate\BaseValidate;
use think\facade\Db;
/**
@ -82,6 +83,7 @@ class LandValidate extends BaseValidate
'master_name' => '土地负责人',
'master_phone' => '负责人电话',
'status' => '土地状态1-未种植 2-部分种植 3-全部种植',
'pic' => '土地图片',
];
@ -117,7 +119,7 @@ class LandValidate extends BaseValidate
*/
public function sceneDelete()
{
return $this->only(['id']);
return $this->only(['id'])->append('id', 'require|checkLand');
}
@ -132,4 +134,13 @@ class LandValidate extends BaseValidate
return $this->only(['id']);
}
public function checkLand($value, $rule, $data)
{
$landProduct = Db::name('land_product')->where('land_id', $value)->findOrEmpty();
if (!empty($landProduct)) {
return '存在关联产品,无法删除';
}
return true;
}
}

View File

@ -16,7 +16,7 @@ namespace app\adminapi\validate\land;
use app\common\validate\BaseValidate;
use think\facade\Db;
/**
* Product验证器
@ -31,11 +31,11 @@ class ProductValidate extends BaseValidate
* @var string[]
*/
protected $rule = [
'id' => 'require',
'user_id' => 'require',
'code' => 'require',
'name' => 'require',
'status' => 'require',
'id' => 'require',
'user_id' => 'require',
'code' => 'require',
'name' => 'require',
'status' => 'require',
];
@ -44,11 +44,11 @@ class ProductValidate extends BaseValidate
* @var string[]
*/
protected $field = [
'id' => 'id',
'user_id' => '用户id',
'code' => '产品编号',
'name' => '产品名称',
'status' => '产品状态',
'id' => 'id',
'user_id' => '用户id',
'code' => '产品编号',
'name' => '产品名称',
'status' => '产品状态',
];
@ -84,7 +84,7 @@ class ProductValidate extends BaseValidate
*/
public function sceneDelete()
{
return $this->only(['id']);
return $this->only(['id'])->append('id', 'require|checkProduct');
}
@ -99,4 +99,13 @@ class ProductValidate extends BaseValidate
return $this->only(['id']);
}
public function checkProduct($value, $rule, $data)
{
$productDevice = Db::name('product_device')->where('product_id', $value)->findOrEmpty();
if (!empty($productDevice)) {
return '存在关联设备,无法删除';
}
return true;
}
}

View File

@ -1,77 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\device;
use app\common\model\BaseModel;
/**
* AirMonitor模型
* Class AirMonitor
* @package app\common\model\device
*/
class AirMonitor extends BaseModel
{
protected $name = 'air_monitor';
/**
* @notes 关联device
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function device()
{
return $this->hasOne(\app\common\model\device\Device::class, 'id', 'device_id');
}
/**
* @notes 搜索器-注册时间
* @param $query
* @param $value
* @param $data
* @author 段誉
* @date 2022/9/22 16:13
*/
public function searchStartTimeAttr($query, $value, $data)
{
if ($value) {
$query->where('create_time', '>=', strtotime($value));
}
}
/**
* @notes 搜索器-注册时间
* @param $query
* @param $value
* @param $data
* @author 段誉
* @date 2022/9/22 16:13
*/
public function searchEndTimeAttr($query, $value, $data)
{
if ($value) {
$query->where('create_time', '<=', strtotime($value));
}
}
}

View File

@ -1,76 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\device;
use app\common\model\BaseModel;
/**
* SoilMonitor模型
* Class SoilMonitor
* @package app\common\model\device
*/
class SoilMonitor extends BaseModel
{
protected $name = 'soil_monitor';
/**
* @notes 关联device
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function device()
{
return $this->hasOne(\app\common\model\device\Device::class, 'id', 'device_id');
}
/**
* @notes 搜索器-注册时间
* @param $query
* @param $value
* @param $data
* @author 段誉
* @date 2022/9/22 16:13
*/
public function searchStartTimeAttr($query, $value, $data)
{
if ($value) {
$query->where('create_time', '>=', strtotime($value));
}
}
/**
* @notes 搜索器-注册时间
* @param $query
* @param $value
* @param $data
* @author 段誉
* @date 2022/9/22 16:13
*/
public function searchEndTimeAttr($query, $value, $data)
{
if ($value) {
$query->where('create_time', '<=', strtotime($value));
}
}
}

View File

@ -1,10 +0,0 @@
<?php
namespace app\common\model\monitor;
use app\common\model\BaseModel;
class AirMonitor extends BaseModel
{
protected $name = 'air_monitor';
}

View File

@ -1,10 +0,0 @@
<?php
namespace app\common\model\monitor;
use app\common\model\BaseModel;
class SoilMonitor extends BaseModel
{
protected $name = 'soil_monitor';
}