update
This commit is contained in:
parent
0485c5e639
commit
485197c75c
|
@ -24,3 +24,7 @@ export function apiFenceHouseDelete(params: any) {
|
||||||
export function apiFenceHouseDetail(params: any) {
|
export function apiFenceHouseDetail(params: any) {
|
||||||
return request.get({ url: '/fence_house.fence_house/detail', params })
|
return request.get({ url: '/fence_house.fence_house/detail', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function apiFarmLists(params: any) {
|
||||||
|
return request.get({ url: '/farm.farm/datas', params })
|
||||||
|
}
|
|
@ -24,3 +24,7 @@ export function apiMonitorThresholdDelete(params: any) {
|
||||||
export function apiMonitorThresholdDetail(params: any) {
|
export function apiMonitorThresholdDetail(params: any) {
|
||||||
return request.get({ url: '/device.monitor_threshold/detail', params })
|
return request.get({ url: '/device.monitor_threshold/detail', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function apiFenceHouseLists(params: any) {
|
||||||
|
return request.get({ url: '/fence_house.fence_house/datas', params })
|
||||||
|
}
|
|
@ -43,7 +43,7 @@
|
||||||
<el-form-item label="设备编码" prop="code">
|
<el-form-item label="设备编码" prop="code">
|
||||||
<el-input v-model="formData.code" clearable placeholder="请输入设备编码" />
|
<el-input v-model="formData.code" clearable placeholder="请输入设备编码" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="产品图" prop="image">
|
<el-form-item label="设备图" prop="image">
|
||||||
<el-upload
|
<el-upload
|
||||||
class="avatar-uploader"
|
class="avatar-uploader"
|
||||||
:accept="acceptFileTypes"
|
:accept="acceptFileTypes"
|
||||||
|
@ -240,10 +240,17 @@ const handleSubmit = async () => {
|
||||||
popupRef.value?.close()
|
popupRef.value?.close()
|
||||||
emit('success')
|
emit('success')
|
||||||
}
|
}
|
||||||
|
const generateUuid = () => {
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||||
|
const r = (Math.random() * 16) | 0
|
||||||
|
const v = c == 'x' ? r : (r & 0x3) | 0x8
|
||||||
|
return v.toString(16)
|
||||||
|
})
|
||||||
|
}
|
||||||
//打开弹窗
|
//打开弹窗
|
||||||
const open = (type = 'add') => {
|
const open = (type = 'add') => {
|
||||||
mode.value = type
|
mode.value = type
|
||||||
|
formData.code = generateUuid()
|
||||||
popupRef.value?.open()
|
popupRef.value?.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,21 @@
|
||||||
@close="handleClose"
|
@close="handleClose"
|
||||||
>
|
>
|
||||||
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
|
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
|
||||||
<el-form-item label="养殖基地id" prop="farm_id">
|
<el-form-item label="养殖基地" prop="farm_id">
|
||||||
<el-input v-model="formData.farm_id" clearable placeholder="请输入养殖基地id" />
|
<el-select
|
||||||
|
v-model="formData.farm_id"
|
||||||
|
remote
|
||||||
|
filterable
|
||||||
|
:remote-method="queryFarm"
|
||||||
|
:loading="loading"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(item, index) in optionsData.farmList"
|
||||||
|
:key="index"
|
||||||
|
:label="item.farminfo"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="栏舍名称" prop="fence_house_name">
|
<el-form-item label="栏舍名称" prop="fence_house_name">
|
||||||
<el-input v-model="formData.fence_house_name" clearable placeholder="请输入栏舍名称" />
|
<el-input v-model="formData.fence_house_name" clearable placeholder="请输入栏舍名称" />
|
||||||
|
@ -56,9 +69,11 @@
|
||||||
<script lang="ts" setup name="fenceHouseEdit">
|
<script lang="ts" setup name="fenceHouseEdit">
|
||||||
import type { FormInstance } from 'element-plus'
|
import type { FormInstance } from 'element-plus'
|
||||||
import Popup from '@/components/popup/index.vue'
|
import Popup from '@/components/popup/index.vue'
|
||||||
import { apiFenceHouseAdd, apiFenceHouseEdit, apiFenceHouseDetail } from '@/api/fence_house'
|
import {apiFenceHouseAdd, apiFenceHouseEdit, apiFenceHouseDetail, apiFenceHouseLists, apiFarmLists} from '@/api/fence_house'
|
||||||
import { timeFormat } from '@/utils/util'
|
import { timeFormat } from '@/utils/util'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
|
import {useDictOptions} from "@/hooks/useDictOptions";
|
||||||
|
import {ref} from "vue";
|
||||||
defineProps({
|
defineProps({
|
||||||
dictData: {
|
dictData: {
|
||||||
type: Object as PropType<Record<string, any[]>>,
|
type: Object as PropType<Record<string, any[]>>,
|
||||||
|
@ -96,6 +111,27 @@ const formRules = reactive<any>({
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { optionsData } = useDictOptions<{
|
||||||
|
farmList: any[]
|
||||||
|
}>({
|
||||||
|
farmList: {
|
||||||
|
api: apiFarmLists,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
const queryFarm= async (query: string) => {
|
||||||
|
loading.value = true
|
||||||
|
const farmList = await apiFarmLists({
|
||||||
|
farm_name: query ?? ''
|
||||||
|
})
|
||||||
|
optionsData.farmList = farmList
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
console.log(optionsData)
|
||||||
|
|
||||||
|
|
||||||
// 获取详情
|
// 获取详情
|
||||||
const setFormData = async (data: Record<any, any>) => {
|
const setFormData = async (data: Record<any, any>) => {
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" />
|
<el-table-column type="selection" width="55" />
|
||||||
<el-table-column label="养殖基地id" prop="farm_id" show-overflow-tooltip />
|
<el-table-column label="养殖基地" prop="farm_id" show-overflow-tooltip />
|
||||||
<el-table-column label="栏舍名称" prop="fence_house_name" show-overflow-tooltip />
|
<el-table-column label="栏舍名称" prop="fence_house_name" show-overflow-tooltip />
|
||||||
<el-table-column label="动物类型" prop="animal_type">
|
<el-table-column label="动物类型" prop="animal_type">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
|
|
|
@ -9,66 +9,74 @@
|
||||||
@close="handleClose"
|
@close="handleClose"
|
||||||
>
|
>
|
||||||
<el-form ref="formRef" :model="formData" label-width="170px" :rules="formRules">
|
<el-form ref="formRef" :model="formData" label-width="170px" :rules="formRules">
|
||||||
<el-form-item label="土壤最高温度" prop="soil_temp_max">
|
|
||||||
<el-input v-model="formData.soil_temp_max" clearable placeholder="请输入土壤最高温度" />
|
<el-form-item label="所属栏舍" prop="product_id">
|
||||||
</el-form-item>
|
<el-select
|
||||||
<el-form-item label="土壤最低温度" prop="soil_temp_min">
|
v-model="formData.fence_house_id"
|
||||||
<el-input v-model="formData.soil_temp_min" clearable placeholder="请输入土壤最低温度" />
|
remote
|
||||||
</el-form-item>
|
filterable
|
||||||
<el-form-item label="土壤最高湿度" prop="soil_mois_max">
|
:remote-method="queryFenceHouse"
|
||||||
<el-input v-model="formData.soil_mois_max" clearable placeholder="请输入土壤最高湿度" />
|
:loading="loading"
|
||||||
</el-form-item>
|
>
|
||||||
<el-form-item label="土壤最低湿度" prop="soil_mois_min">
|
<el-option
|
||||||
<el-input v-model="formData.soil_mois_min" clearable placeholder="请输入土壤最低湿度" />
|
v-for="(item, index) in optionsData.fenceHouse"
|
||||||
</el-form-item>
|
:key="index"
|
||||||
<el-form-item label="土壤最高PH值" prop="soil_ph_max">
|
:label="item.fencehouseinfo"
|
||||||
<el-input v-model="formData.soil_ph_max" clearable placeholder="请输入土壤最高PH值" />
|
:value="item.id"
|
||||||
</el-form-item>
|
/>
|
||||||
<el-form-item label="土壤最低PH值" prop="soil_ph_min">
|
</el-select>
|
||||||
<el-input v-model="formData.soil_ph_min" clearable placeholder="请输入土壤最低PH值" />
|
</el-form-item>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="土壤最高氮含量" prop="soil_n_content_max">
|
<el-form-item label="室温(高)" prop="air_temp_max">
|
||||||
<el-input v-model="formData.soil_n_content_max" clearable placeholder="请输入土壤最高氮含量" />
|
<el-input v-model="formData.air_temp_max" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="土壤最低氮含量" prop="soil_n_content_min">
|
<el-form-item label="室温(低)" prop="air_temp_min">
|
||||||
<el-input v-model="formData.soil_n_content_min" clearable placeholder="请输入土壤最低氮含量" />
|
<el-input v-model="formData.air_temp_min" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="土壤最高磷含量" prop="soil_p_content_max">
|
|
||||||
<el-input v-model="formData.soil_p_content_max" clearable placeholder="请输入土壤最高磷含量" />
|
<el-form-item label="湿度(高)" prop="air_mois_max">
|
||||||
</el-form-item>
|
<el-input v-model="formData.air_mois_max" clearable />
|
||||||
<el-form-item label="土壤最低磷含量" prop="soil_p_content_min">
|
</el-form-item>
|
||||||
<el-input v-model="formData.soil_p_content_min" clearable placeholder="请输入土壤最低磷含量" />
|
<el-form-item label="湿度(低)" prop="air_mois_min">
|
||||||
</el-form-item>
|
<el-input v-model="formData.air_mois_min" clearable />
|
||||||
<el-form-item label="土壤最高钾含量" prop="soil_k_content_max">
|
</el-form-item>
|
||||||
<el-input v-model="formData.soil_k_content_max" clearable placeholder="请输入土壤最高钾含量" />
|
|
||||||
</el-form-item>
|
<el-form-item label="氮气含量(高)" prop="nitrogen_max">
|
||||||
<el-form-item label="土壤最低钾含量" prop="soil_k_content_min">
|
<el-input v-model="formData.nitrogen_max" clearable/>
|
||||||
<el-input v-model="formData.soil_k_content_min" clearable placeholder="请输入土壤最低钾含量" />
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="氮气含量(低)" prop="nitrogen_min">
|
||||||
<el-form-item label="空气最高温度" prop="air_temp_max">
|
<el-input v-model="formData.nitrogen_min" clearable/>
|
||||||
<el-input v-model="formData.air_temp_max" clearable placeholder="请输入空气最高温度" />
|
</el-form-item>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="空气最低温度" prop="air_temp_min">
|
<el-form-item label="防火(高)" prop="wind_speed_min">
|
||||||
<el-input v-model="formData.air_temp_min" clearable placeholder="请输入空气最低温度" />
|
<el-input v-model="formData.fireproof_max" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="空气最高湿度" prop="air_mois_max">
|
<el-form-item label="防火(低)" prop="wind_speed_max">
|
||||||
<el-input v-model="formData.air_mois_max" clearable placeholder="请输入空气最高湿度" />
|
<el-input v-model="formData.fireproof_min" clearable/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="空气最低湿度" prop="air_mois_min">
|
|
||||||
<el-input v-model="formData.air_mois_min" clearable placeholder="请输入空气最低湿度" />
|
<el-form-item label="甲烷(高)" prop="methane_max">
|
||||||
</el-form-item>
|
<el-input v-model="formData.methane_max" clearable />
|
||||||
<el-form-item label="空气最大二氧化碳含量" prop="air_co2_content_max">
|
</el-form-item>
|
||||||
<el-input v-model="formData.air_co2_content_max" clearable placeholder="请输入空气最大二氧化碳含量" />
|
<el-form-item label="甲烷(低)" prop="methane_min">
|
||||||
</el-form-item>
|
<el-input v-model="formData.methane_min" clearable/>
|
||||||
<el-form-item label="空气最小二氧化碳含量" prop="air_co2_content_min">
|
</el-form-item>
|
||||||
<el-input v-model="formData.air_co2_content_min" clearable placeholder="请输入空气最小二氧化碳含量" />
|
|
||||||
</el-form-item>
|
<el-form-item label="噪音(高)" prop="noise_max">
|
||||||
<el-form-item label="最大风速" prop="wind_speed_max">
|
<el-input v-model="formData.noise_max" clearable />
|
||||||
<el-input v-model="formData.wind_speed_max" clearable placeholder="请输入最大风速" />
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="噪音(低)" prop="noise_min">
|
||||||
<el-form-item label="最小风速" prop="wind_speed_min">
|
<el-input v-model="formData.noise_min" clearable/>
|
||||||
<el-input v-model="formData.wind_speed_min" clearable placeholder="请输入最小风速" />
|
</el-form-item>
|
||||||
</el-form-item>
|
|
||||||
|
<el-form-item label="体温(高)" prop="temperature_max">
|
||||||
|
<el-input v-model="formData.temperature_max" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="体温(低)" prop="temperature_min">
|
||||||
|
<el-input v-model="formData.temperature_min" clearable/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
</popup>
|
</popup>
|
||||||
</div>
|
</div>
|
||||||
|
@ -77,9 +85,12 @@
|
||||||
<script lang="ts" setup name="monitorThresholdEdit">
|
<script lang="ts" setup name="monitorThresholdEdit">
|
||||||
import type { FormInstance } from 'element-plus'
|
import type { FormInstance } from 'element-plus'
|
||||||
import Popup from '@/components/popup/index.vue'
|
import Popup from '@/components/popup/index.vue'
|
||||||
import { apiMonitorThresholdAdd, apiMonitorThresholdEdit, apiMonitorThresholdDetail } from '@/api/monitor_threshold'
|
import { apiMonitorThresholdAdd, apiMonitorThresholdEdit, apiMonitorThresholdDetail, apiFenceHouseLists } from '@/api/monitor_threshold'
|
||||||
import { timeFormat } from '@/utils/util'
|
import { timeFormat } from '@/utils/util'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
|
import {useDictOptions} from "@/hooks/useDictOptions";
|
||||||
|
import {apiProductLists} from "@/api/device";
|
||||||
|
import {ref} from "vue";
|
||||||
defineProps({
|
defineProps({
|
||||||
dictData: {
|
dictData: {
|
||||||
type: Object as PropType<Record<string, any[]>>,
|
type: Object as PropType<Record<string, any[]>>,
|
||||||
|
@ -100,134 +111,49 @@ const popupTitle = computed(() => {
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
id: '',
|
id: '',
|
||||||
soil_temp_max: '',
|
fence_house_id: '',
|
||||||
soil_temp_min: '',
|
|
||||||
soil_mois_max: '',
|
|
||||||
soil_mois_min: '',
|
|
||||||
soil_ph_max: '',
|
|
||||||
soil_ph_min: '',
|
|
||||||
soil_n_content_max: '',
|
|
||||||
soil_n_content_min: '',
|
|
||||||
soil_p_content_max: '',
|
|
||||||
soil_p_content_min: '',
|
|
||||||
soil_k_content_max: '',
|
|
||||||
soil_k_content_min: '',
|
|
||||||
air_temp_max: '',
|
air_temp_max: '',
|
||||||
air_temp_min: '',
|
air_temp_min: '',
|
||||||
air_mois_max: '',
|
air_mois_max: '',
|
||||||
air_mois_min: '',
|
air_mois_min: '',
|
||||||
air_co2_content_max: '',
|
nitrogen_min: '',
|
||||||
air_co2_content_min: '',
|
nitrogen_max: '',
|
||||||
wind_speed_max: '',
|
fireproof_min: '',
|
||||||
wind_speed_min: '',
|
fireproof_max: '',
|
||||||
|
methane_min: '',
|
||||||
|
methane_max: '',
|
||||||
|
noise_min: '',
|
||||||
|
noise_max: '',
|
||||||
|
temperature_min: '',
|
||||||
|
temperature_max: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// 表单验证
|
// 表单验证
|
||||||
const formRules = reactive<any>({
|
const formRules = reactive<any>({})
|
||||||
soil_temp_max: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最高温度',
|
const { optionsData } = useDictOptions<{
|
||||||
trigger: ['blur']
|
fenceHouse: any[]
|
||||||
}],
|
}>({
|
||||||
soil_temp_min: [{
|
fenceHouse: {
|
||||||
required: true,
|
api: apiFenceHouseLists,
|
||||||
message: '请输入土壤最低温度',
|
params: {
|
||||||
trigger: ['blur']
|
all: 1
|
||||||
}],
|
}
|
||||||
soil_mois_max: [{
|
}
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最高湿度',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
soil_mois_min: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最低湿度',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
soil_ph_max: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最高PH值',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
soil_ph_min: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最低PH值',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
soil_n_content_max: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最高氮含量',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
soil_n_content_min: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最低氮含量',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
soil_p_content_max: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最高磷含量',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
soil_p_content_min: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最低磷含量',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
soil_k_content_max: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最高钾含量',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
soil_k_content_min: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入土壤最低钾含量',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
air_temp_max: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入空气最高温度',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
air_temp_min: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入空气最低温度',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
air_mois_max: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入空气最高湿度',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
air_mois_min: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入空气最低湿度',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
air_co2_content_max: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入空气最大二氧化碳含量',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
air_co2_content_min: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入空气最小二氧化碳含量',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
wind_speed_max: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入最大风速',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
wind_speed_min: [{
|
|
||||||
required: true,
|
|
||||||
message: '请输入最小风速',
|
|
||||||
trigger: ['blur']
|
|
||||||
}],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
const queryFenceHouse = async (query: string) => {
|
||||||
|
loading.value = true
|
||||||
|
const fenceHouseList = await apiFenceHouseLists({
|
||||||
|
fence_house_name: query ?? ''
|
||||||
|
})
|
||||||
|
optionsData.fenceHouse = fenceHouseList
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
// 获取详情
|
// 获取详情
|
||||||
const setFormData = async (data: Record<any, any>) => {
|
const setFormData = async (data: Record<any, any>) => {
|
||||||
for (const key in formData) {
|
for (const key in formData) {
|
||||||
|
|
|
@ -1,19 +1,71 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||||
|
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||||
|
<el-button v-perms="['device.monitor_threshold/add']" type="primary" @click="handleAdd">
|
||||||
|
<template #icon>
|
||||||
|
<icon name="el-icon-Plus" />
|
||||||
|
</template>
|
||||||
|
新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-perms="['device.monitor_threshold/delete']"
|
||||||
|
:disabled="!selectData.length"
|
||||||
|
@click="handleDelete(selectData)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</el-card>
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column label="栏舍" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{row.fenceHousrAttr.fence_house_name}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="室温" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{row.air_temp_min}} ~ {{row.air_temp_max}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="湿度" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{row.air_mois_min}} ~ {{row.air_mois_max}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="氮气含量" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{row.nitrogen_min}} ~ {{row.nitrogen_max}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="防火" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{row.fireproof_min}} ~ {{row.fireproof_max}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="甲烷" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{row.fireproof_min}} ~ {{row.fireproof_max}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="噪音" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{row.noise_min}} ~ {{row.noise_max}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="体温" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{row.temperature_min}} ~ {{row.temperature_max}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="土壤最高温度" prop="soil_temp_max" show-overflow-tooltip />
|
|
||||||
<el-table-column label="土壤最低温度" prop="soil_temp_min" show-overflow-tooltip />
|
|
||||||
<el-table-column label="土壤最高湿度" prop="soil_mois_max" show-overflow-tooltip />
|
|
||||||
<el-table-column label="土壤最低湿度" prop="soil_mois_min" show-overflow-tooltip />
|
|
||||||
<el-table-column label="土壤最高PH值" prop="soil_ph_max" show-overflow-tooltip />
|
|
||||||
<el-table-column label="土壤最低PH值" prop="soil_ph_min" show-overflow-tooltip />
|
|
||||||
<el-table-column label="土壤最高氮含量" prop="soil_n_content_max" show-overflow-tooltip />
|
|
||||||
<el-table-column label="土壤最低氮含量" prop="soil_n_content_min" show-overflow-tooltip />
|
|
||||||
<el-table-column label="最大风速" prop="wind_speed_max" show-overflow-tooltip />
|
|
||||||
<el-table-column label="最小风速" prop="wind_speed_min" show-overflow-tooltip />
|
|
||||||
<el-table-column label="操作" width="120" align="center" fixed="right">
|
<el-table-column label="操作" width="120" align="center" fixed="right">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-button
|
<el-button
|
||||||
|
@ -43,6 +95,7 @@ import { apiMonitorThresholdLists, apiMonitorThresholdDelete } from '@/api/monit
|
||||||
import { timeFormat } from '@/utils/util'
|
import { timeFormat } from '@/utils/util'
|
||||||
import feedback from '@/utils/feedback'
|
import feedback from '@/utils/feedback'
|
||||||
import EditPopup from './edit.vue'
|
import EditPopup from './edit.vue'
|
||||||
|
import {getRoutePath} from "@/router";
|
||||||
|
|
||||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||||
// 是否显示编辑框
|
// 是否显示编辑框
|
||||||
|
|
|
@ -62,19 +62,19 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="所属养殖基地" prop="farm_id">
|
<el-form-item label="所属栏舍" prop="fence_house_id">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="formData.farm_id"
|
v-model="formData.fence_house_id"
|
||||||
remote
|
remote
|
||||||
filterable
|
filterable
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
:remote-method="queryLand"
|
:remote-method="queryFenceHouse"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(item, index) in optionsData.land"
|
v-for="(item, index) in optionsData.fenceHouse"
|
||||||
:key="index"
|
:key="index"
|
||||||
:label="item.landinfo"
|
:label="item.fencehouseinfo"
|
||||||
:value="item.id"
|
:value="item.id"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
@ -97,6 +97,7 @@ import useUserStore from "@/stores/modules/user";
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import config from "@/config";
|
import config from "@/config";
|
||||||
|
import {apiFenceHouseLists} from "@/api/monitor_threshold";
|
||||||
defineProps({
|
defineProps({
|
||||||
dictData: {
|
dictData: {
|
||||||
type: Object as PropType<Record<string, any[]>>,
|
type: Object as PropType<Record<string, any[]>>,
|
||||||
|
@ -131,7 +132,7 @@ const formData = reactive({
|
||||||
id: '',
|
id: '',
|
||||||
user_id: '',
|
user_id: '',
|
||||||
root: 0,
|
root: 0,
|
||||||
farm_id: '',
|
fence_house_id: '',
|
||||||
code: '',
|
code: '',
|
||||||
name: '',
|
name: '',
|
||||||
desc: '',
|
desc: '',
|
||||||
|
@ -176,12 +177,12 @@ const getDetail = async (row: Record<string, any>) => {
|
||||||
|
|
||||||
const { optionsData } = useDictOptions<{
|
const { optionsData } = useDictOptions<{
|
||||||
user: any[]
|
user: any[]
|
||||||
land: any[]
|
fenceHouse: any[]
|
||||||
}>({
|
}>({
|
||||||
user: {
|
user: {
|
||||||
api: getUserList
|
api: getUserList
|
||||||
},
|
},
|
||||||
land: {
|
fenceHouse: {
|
||||||
api: apiLandLists
|
api: apiLandLists
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -198,18 +199,16 @@ const queryUser = async (query: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedUser = (value: any) => {
|
const selectedUser = (value: any) => {
|
||||||
optionsData.land = []
|
optionsData.fenceHouse = []
|
||||||
formData.land_id = ''
|
formData.fence_house_id = ''
|
||||||
queryLand(value)
|
queryFenceHouse(value)
|
||||||
}
|
}
|
||||||
|
const queryFenceHouse = async (user_id: string) => {
|
||||||
const queryLand = async (user_id: string) => {
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const landList = await apiLandLists({
|
const fenceHouseList = await apiFenceHouseLists({
|
||||||
user_id: user_id ?? ''
|
user_id: user_id ?? ''
|
||||||
})
|
})
|
||||||
loading.value = false
|
optionsData.fenceHouse = fenceHouseList
|
||||||
optionsData.land = landList
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +239,7 @@ const open = (type = 'add') => {
|
||||||
const root = res.user.root ?? 0
|
const root = res.user.root ?? 0
|
||||||
formData.root = root
|
formData.root = root
|
||||||
if (type == 'edit') {
|
if (type == 'edit') {
|
||||||
queryLand(formData.user_id)
|
queryFenceHouse(formData.user_id)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
</el-table-column> -->
|
</el-table-column> -->
|
||||||
<el-table-column label="产品名称" prop="name" show-overflow-tooltip />
|
<el-table-column label="产品名称" prop="name" show-overflow-tooltip />
|
||||||
<el-table-column label="产品编号" prop="code" show-overflow-tooltip />
|
<el-table-column label="产品编号" prop="code" show-overflow-tooltip />
|
||||||
<el-table-column label="所属土地" width="200">
|
<el-table-column label="所属栏舍" width="200">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tag class="mr-2" v-if="row.land_id != null" type="info">ID: {{ row.land_id }}</el-tag>
|
<el-tag class="mr-2" v-if="row.fence_house_id != null" type="info">ID: {{ row.land_id }}</el-tag>
|
||||||
<el-tag class="mr-2" v-if="row.title != null" type="info">名称: {{ row.title }}</el-tag>
|
<el-tag class="mr-2" v-if="row.title != null" type="info">名称: {{ row.title }}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<dict-value :options="dictData.product_status" :value="row.status" />
|
<dict-value :options="dictData.product_status" :value="row.status" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建时间" width="180" align="center" prop="create_time">
|
<el-table-column label="创建时间" width="180" align="center" prop="create_time">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
|
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace app\adminapi\controller\farm;
|
||||||
use app\adminapi\controller\BaseAdminController;
|
use app\adminapi\controller\BaseAdminController;
|
||||||
use app\adminapi\lists\farm\FarmLists;
|
use app\adminapi\lists\farm\FarmLists;
|
||||||
use app\adminapi\logic\farm\FarmLogic;
|
use app\adminapi\logic\farm\FarmLogic;
|
||||||
|
use app\adminapi\logic\user\UserLogic;
|
||||||
use app\adminapi\validate\farm\FarmValidate;
|
use app\adminapi\validate\farm\FarmValidate;
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,5 +105,10 @@ class FarmController extends BaseAdminController
|
||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function datas()
|
||||||
|
{
|
||||||
|
$datas = (new FarmLogic())->datas(input(''));
|
||||||
|
return $this->success('', $datas);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,8 +18,10 @@ namespace app\adminapi\controller\fence_house;
|
||||||
|
|
||||||
use app\adminapi\controller\BaseAdminController;
|
use app\adminapi\controller\BaseAdminController;
|
||||||
use app\adminapi\lists\fence_house\FenceHouseLists;
|
use app\adminapi\lists\fence_house\FenceHouseLists;
|
||||||
|
use app\adminapi\logic\farm\FarmLogic;
|
||||||
use app\adminapi\logic\fence_house\FenceHouseLogic;
|
use app\adminapi\logic\fence_house\FenceHouseLogic;
|
||||||
use app\adminapi\validate\fence_house\FenceHouseValidate;
|
use app\adminapi\validate\fence_house\FenceHouseValidate;
|
||||||
|
use app\common\model\fence_house\FenceHouse;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,5 +106,10 @@ class FenceHouseController extends BaseAdminController
|
||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function datas()
|
||||||
|
{
|
||||||
|
$datas = (new FenceHouseLogic())->datas(input(''));
|
||||||
|
return $this->success('', $datas);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -55,7 +55,7 @@ class MonitorThresholdLists extends BaseAdminDataLists implements ListsSearchInt
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return MonitorThreshold::where($this->searchWhere)
|
return MonitorThreshold::where($this->searchWhere)
|
||||||
->field(['id', 'soil_temp_max', 'soil_temp_min', 'soil_mois_max', 'soil_mois_min', 'soil_ph_max', 'soil_ph_min', 'soil_n_content_max', 'soil_n_content_min', 'soil_p_content_max', 'soil_p_content_min', 'soil_k_content_max', 'soil_k_content_min', 'air_temp_max', 'air_temp_min', 'air_mois_max', 'air_mois_min', 'air_co2_content_max', 'air_co2_content_min', 'wind_speed_max', 'wind_speed_min'])
|
->with(['fenceHousrAttr'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
|
|
|
@ -41,26 +41,21 @@ class MonitorThresholdLogic extends BaseLogic
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
MonitorThreshold::create([
|
MonitorThreshold::create([
|
||||||
'soil_temp_max' => $params['soil_temp_max'],
|
'fence_house_id' => $params['fence_house_id'],
|
||||||
'soil_temp_min' => $params['soil_temp_min'],
|
|
||||||
'soil_mois_max' => $params['soil_mois_max'],
|
|
||||||
'soil_mois_min' => $params['soil_mois_min'],
|
|
||||||
'soil_ph_max' => $params['soil_ph_max'],
|
|
||||||
'soil_ph_min' => $params['soil_ph_min'],
|
|
||||||
'soil_n_content_max' => $params['soil_n_content_max'],
|
|
||||||
'soil_n_content_min' => $params['soil_n_content_min'],
|
|
||||||
'soil_p_content_max' => $params['soil_p_content_max'],
|
|
||||||
'soil_p_content_min' => $params['soil_p_content_min'],
|
|
||||||
'soil_k_content_max' => $params['soil_k_content_max'],
|
|
||||||
'soil_k_content_min' => $params['soil_k_content_min'],
|
|
||||||
'air_temp_max' => $params['air_temp_max'],
|
'air_temp_max' => $params['air_temp_max'],
|
||||||
'air_temp_min' => $params['air_temp_min'],
|
'air_temp_min' => $params['air_temp_min'],
|
||||||
'air_mois_max' => $params['air_mois_max'],
|
'air_mois_max' => $params['air_mois_max'],
|
||||||
'air_mois_min' => $params['air_mois_min'],
|
'air_mois_min' => $params['air_mois_min'],
|
||||||
'air_co2_content_max' => $params['air_co2_content_max'],
|
'nitrogen_min' => $params['nitrogen_min'],
|
||||||
'air_co2_content_min' => $params['air_co2_content_min'],
|
'nitrogen_max' => $params['nitrogen_max'],
|
||||||
'wind_speed_max' => $params['wind_speed_max'],
|
'fireproof_min' => $params['fireproof_min'],
|
||||||
'wind_speed_min' => $params['wind_speed_min'],
|
'fireproof_max' => $params['fireproof_max'],
|
||||||
|
'methane_min' => $params['methane_min'],
|
||||||
|
'methane_max' => $params['methane_max'],
|
||||||
|
'noise_min' => $params['noise_min'],
|
||||||
|
'noise_max' => $params['noise_max'],
|
||||||
|
'temperature_min' => $params['temperature_min'],
|
||||||
|
'temperature_max' => $params['temperature_max'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
@ -85,26 +80,21 @@ class MonitorThresholdLogic extends BaseLogic
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
MonitorThreshold::where('id', $params['id'])->update([
|
MonitorThreshold::where('id', $params['id'])->update([
|
||||||
'soil_temp_max' => $params['soil_temp_max'],
|
'fence_house_id' => $params['fence_house_id'],
|
||||||
'soil_temp_min' => $params['soil_temp_min'],
|
|
||||||
'soil_mois_max' => $params['soil_mois_max'],
|
|
||||||
'soil_mois_min' => $params['soil_mois_min'],
|
|
||||||
'soil_ph_max' => $params['soil_ph_max'],
|
|
||||||
'soil_ph_min' => $params['soil_ph_min'],
|
|
||||||
'soil_n_content_max' => $params['soil_n_content_max'],
|
|
||||||
'soil_n_content_min' => $params['soil_n_content_min'],
|
|
||||||
'soil_p_content_max' => $params['soil_p_content_max'],
|
|
||||||
'soil_p_content_min' => $params['soil_p_content_min'],
|
|
||||||
'soil_k_content_max' => $params['soil_k_content_max'],
|
|
||||||
'soil_k_content_min' => $params['soil_k_content_min'],
|
|
||||||
'air_temp_max' => $params['air_temp_max'],
|
'air_temp_max' => $params['air_temp_max'],
|
||||||
'air_temp_min' => $params['air_temp_min'],
|
'air_temp_min' => $params['air_temp_min'],
|
||||||
'air_mois_max' => $params['air_mois_max'],
|
'air_mois_max' => $params['air_mois_max'],
|
||||||
'air_mois_min' => $params['air_mois_min'],
|
'air_mois_min' => $params['air_mois_min'],
|
||||||
'air_co2_content_max' => $params['air_co2_content_max'],
|
'nitrogen_min' => $params['nitrogen_min'],
|
||||||
'air_co2_content_min' => $params['air_co2_content_min'],
|
'nitrogen_max' => $params['nitrogen_max'],
|
||||||
'wind_speed_max' => $params['wind_speed_max'],
|
'fireproof_min' => $params['fireproof_min'],
|
||||||
'wind_speed_min' => $params['wind_speed_min'],
|
'fireproof_max' => $params['fireproof_max'],
|
||||||
|
'methane_min' => $params['methane_min'],
|
||||||
|
'methane_max' => $params['methane_max'],
|
||||||
|
'noise_min' => $params['noise_min'],
|
||||||
|
'noise_max' => $params['noise_max'],
|
||||||
|
'temperature_min' => $params['temperature_min'],
|
||||||
|
'temperature_max' => $params['temperature_max'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
|
|
@ -129,4 +129,17 @@ class FarmLogic extends BaseLogic
|
||||||
{
|
{
|
||||||
return Farm::findOrEmpty($params['id'])->toArray();
|
return Farm::findOrEmpty($params['id'])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function datas($params)
|
||||||
|
{
|
||||||
|
$queryWhere = [];
|
||||||
|
if (!empty($params['farm_name'])) {
|
||||||
|
$queryWhere[] = ['farm_name', 'like', '%' . $params['farm_name'] . '%'];
|
||||||
|
}
|
||||||
|
$lists = Db::name('farm')->where($queryWhere)->order(['id' => 'desc'])->select()->toArray();
|
||||||
|
foreach ($lists as &$item) {
|
||||||
|
$item['farminfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['farm_name'];
|
||||||
|
}
|
||||||
|
return $lists;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
namespace app\adminapi\logic\fence_house;
|
namespace app\adminapi\logic\fence_house;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\farm\Farm;
|
||||||
use app\common\model\fence_house\FenceHouse;
|
use app\common\model\fence_house\FenceHouse;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
@ -117,4 +118,22 @@ class FenceHouseLogic extends BaseLogic
|
||||||
{
|
{
|
||||||
return FenceHouse::findOrEmpty($params['id'])->toArray();
|
return FenceHouse::findOrEmpty($params['id'])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function datas($params)
|
||||||
|
{
|
||||||
|
$queryWhere = [];
|
||||||
|
if (!empty($params['fence_house_name'])) {
|
||||||
|
$queryWhere[] = ['fence_house_name', 'like', '%' . $params['fence_house_name'] . '%'];
|
||||||
|
}
|
||||||
|
if (!empty($params['user_id'])) {
|
||||||
|
$farmIds = Farm::where('user_id', $params['user_id'])->column('id');
|
||||||
|
$queryWhere[] = ['farm_id', 'in', $farmIds];
|
||||||
|
}
|
||||||
|
$lists = Db::name('fence_house')->where($queryWhere)->order(['id' => 'desc'])->select()->toArray();
|
||||||
|
foreach ($lists as &$item) {
|
||||||
|
$item['fencehouseinfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['fence_house_name'];
|
||||||
|
}
|
||||||
|
return $lists;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
namespace app\adminapi\logic\land;
|
namespace app\adminapi\logic\land;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\fence_house\FenceHouse;
|
||||||
use app\common\model\land\Land;
|
use app\common\model\land\Land;
|
||||||
use app\common\model\land\Product;
|
use app\common\model\land\Product;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
@ -41,38 +42,23 @@ class ProductLogic extends BaseLogic
|
||||||
{
|
{
|
||||||
$root = (request()->adminInfo)['root'];
|
$root = (request()->adminInfo)['root'];
|
||||||
$userId = (request()->adminInfo)['user_id'];
|
$userId = (request()->adminInfo)['user_id'];
|
||||||
$status = 1;
|
|
||||||
if ($root && !empty($params['user_id'])) {
|
if ($root && !empty($params['user_id'])) {
|
||||||
$userId = $params['user_id'];
|
$userId = $params['user_id'];
|
||||||
}
|
}
|
||||||
if (!empty($params['land_id'])) {
|
|
||||||
$land = Land::findOrEmpty($params['land_id'])->toArray();
|
|
||||||
$userId = $land['user_id'] ?? 0;
|
|
||||||
$status = 2;
|
|
||||||
}
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
try {
|
||||||
$product = Product::create([
|
Product::create([
|
||||||
'user_id' => $userId,
|
'user_id' => $userId,
|
||||||
|
'fence_house_id' => $params['fence_house_id'],
|
||||||
'code' => $params['code'],
|
'code' => $params['code'],
|
||||||
'name' => $params['name'],
|
'name' => $params['name'],
|
||||||
'desc' => $params['desc'],
|
'desc' => $params['desc'],
|
||||||
'image' => $params['image'],
|
'image' => $params['image'],
|
||||||
'status' => $status,
|
'status' => 2,
|
||||||
]);
|
]);
|
||||||
if (!empty($params['land_id'])) {
|
|
||||||
Db::name('land_product')->where('land_id', $params['land_id'])->delete();
|
|
||||||
Db::name('land_product')->insert([
|
|
||||||
'land_id' => $params['land_id'],
|
|
||||||
'product_id' => $product['id'],
|
|
||||||
'create_time' => time(),
|
|
||||||
'update_time' => time()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
Db::commit();
|
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -90,41 +76,22 @@ class ProductLogic extends BaseLogic
|
||||||
{
|
{
|
||||||
$root = (request()->adminInfo)['root'];
|
$root = (request()->adminInfo)['root'];
|
||||||
$userId = (request()->adminInfo)['user_id'];
|
$userId = (request()->adminInfo)['user_id'];
|
||||||
$status = 1;
|
|
||||||
if ($root && !empty($params['user_id'])) {
|
if ($root && !empty($params['user_id'])) {
|
||||||
$userId = $params['user_id'];
|
$userId = $params['user_id'];
|
||||||
}
|
}
|
||||||
if (!empty($params['land_id'])) {
|
|
||||||
$land = Land::findOrEmpty($params['land_id'])->toArray();
|
|
||||||
$userId = $land['user_id'] ?? 0;
|
|
||||||
$status = 2;
|
|
||||||
}
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
try {
|
||||||
Product::where('id', $params['id'])->update([
|
Product::where('id', $params['id'])->update([
|
||||||
'user_id' => $userId,
|
'user_id' => $userId,
|
||||||
|
'fence_house_id' => $params['fence_house_id'],
|
||||||
'code' => $params['code'],
|
'code' => $params['code'],
|
||||||
'name' => $params['name'],
|
'name' => $params['name'],
|
||||||
'desc' => $params['desc'],
|
'desc' => $params['desc'],
|
||||||
'image' => $params['image'],
|
'image' => $params['image'],
|
||||||
'status' => $status,
|
'status' => 2,
|
||||||
]);
|
]);
|
||||||
if (!empty($params['land_id'])) {
|
|
||||||
Db::name('land_product')->where('land_id', $params['land_id'])->delete();
|
|
||||||
}
|
|
||||||
Db::name('land_product')->where('product_id', $params['id'])->delete();
|
|
||||||
if (!empty($params['land_id'])) {
|
|
||||||
Db::name('land_product')->insert([
|
|
||||||
'land_id' => $params['land_id'],
|
|
||||||
'product_id' => $params['id'],
|
|
||||||
'create_time' => time(),
|
|
||||||
'update_time' => time()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
Db::commit();
|
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,27 +31,7 @@ class MonitorThresholdValidate extends BaseValidate
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'id' => 'require',
|
|
||||||
'soil_temp_max' => 'require',
|
|
||||||
'soil_temp_min' => 'require',
|
|
||||||
'soil_mois_max' => 'require',
|
|
||||||
'soil_mois_min' => 'require',
|
|
||||||
'soil_ph_max' => 'require',
|
|
||||||
'soil_ph_min' => 'require',
|
|
||||||
'soil_n_content_max' => 'require',
|
|
||||||
'soil_n_content_min' => 'require',
|
|
||||||
'soil_p_content_max' => 'require',
|
|
||||||
'soil_p_content_min' => 'require',
|
|
||||||
'soil_k_content_max' => 'require',
|
|
||||||
'soil_k_content_min' => 'require',
|
|
||||||
'air_temp_max' => 'require',
|
|
||||||
'air_temp_min' => 'require',
|
|
||||||
'air_mois_max' => 'require',
|
|
||||||
'air_mois_min' => 'require',
|
|
||||||
'air_co2_content_max' => 'require',
|
|
||||||
'air_co2_content_min' => 'require',
|
|
||||||
'wind_speed_max' => 'require',
|
|
||||||
'wind_speed_min' => 'require',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,29 +39,7 @@ class MonitorThresholdValidate extends BaseValidate
|
||||||
* 参数描述
|
* 参数描述
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $field = [
|
protected $field = [];
|
||||||
'id' => 'id',
|
|
||||||
'soil_temp_max' => '土壤最高温度',
|
|
||||||
'soil_temp_min' => '土壤最低温度',
|
|
||||||
'soil_mois_max' => '土壤最高湿度',
|
|
||||||
'soil_mois_min' => '土壤最低湿度',
|
|
||||||
'soil_ph_max' => '土壤最高PH值',
|
|
||||||
'soil_ph_min' => '土壤最低PH值',
|
|
||||||
'soil_n_content_max' => '土壤最高氮含量',
|
|
||||||
'soil_n_content_min' => '土壤最低氮含量',
|
|
||||||
'soil_p_content_max' => '土壤最高磷含量',
|
|
||||||
'soil_p_content_min' => '土壤最低磷含量',
|
|
||||||
'soil_k_content_max' => '土壤最高钾含量',
|
|
||||||
'soil_k_content_min' => '土壤最低钾含量',
|
|
||||||
'air_temp_max' => '空气最高温度',
|
|
||||||
'air_temp_min' => '空气最低温度',
|
|
||||||
'air_mois_max' => '空气最高湿度',
|
|
||||||
'air_mois_min' => '空气最低湿度',
|
|
||||||
'air_co2_content_max' => '空气最大二氧化碳含量',
|
|
||||||
'air_co2_content_min' => '空气最小二氧化碳含量',
|
|
||||||
'wind_speed_max' => '最大风速',
|
|
||||||
'wind_speed_min' => '最小风速',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace app\common\model\device;
|
||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\fence_house\FenceHouse;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +29,9 @@ class MonitorThreshold extends BaseModel
|
||||||
|
|
||||||
protected $name = 'monitor_threshold';
|
protected $name = 'monitor_threshold';
|
||||||
|
|
||||||
|
public function fenceHousrAttr()
|
||||||
|
{
|
||||||
|
return $this->hasOne(FenceHouse::class, 'id', 'fence_house_id');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue