This commit is contained in:
chenbo 2024-01-25 17:35:07 +08:00
parent 738d8d4285
commit 8cb963c213
7 changed files with 28 additions and 17 deletions

View File

@ -40,7 +40,11 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="设备编码" prop="code"> <el-form-item label="设备编码" prop="code" :rules="[{
required: true,
message: '请输入设备编码',
trigger: ['blur']
}]" v-if="formData.type ==1">
<el-select <el-select
v-model="formData.code" v-model="formData.code"
remote remote
@ -60,10 +64,10 @@
<!-- <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="硬件ICCID" prop="iccid"> <el-form-item label="硬件ICCID" prop="iccid" v-if="formData.type ==1">
<el-input v-model="formData.iccid" disabled placeholder="请输入ICCID" /> <el-input v-model="formData.iccid" disabled placeholder="请输入ICCID" />
</el-form-item> </el-form-item>
<el-form-item label="监测项" prop="monitor_item" > <el-form-item label="监测项" prop="monitor_item" v-if="formData.type ==1">
<el-select class="flex-1" v-model="formData.monitor_item" multiple disabled placeholder="请选择设备监测项"> <el-select class="flex-1" v-model="formData.monitor_item" multiple disabled placeholder="请选择设备监测项">
<el-option <el-option
v-for="(item, index) in dictData.monitor_item" v-for="(item, index) in dictData.monitor_item"
@ -183,11 +187,6 @@ const formData = reactive({
// //
const formRules = reactive<any>({ const formRules = reactive<any>({
code: [{
required: true,
message: '请输入设备编码',
trigger: ['blur']
}],
name: [{ name: [{
required: true, required: true,
message: '请输入设备名称', message: '请输入设备名称',

View File

@ -33,7 +33,18 @@
<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="养殖基地" prop="farm_id" show-overflow-tooltip /> <el-table-column label="养殖基地" prop="farm_id" show-overflow-tooltip >
<template #default="{ row }">
<el-tag class="mr-2" v-if="row.farm_id != null" type="info"
>ID: {{ row.farm_id }}</el-tag
>
<el-tag class="mr-2" v-if="row.farmAttr != null" type="info"
>名称: {{ row.farmAttr.farm_name }}</el-tag
>
</template>
</el-table-column>
<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 }">

View File

@ -45,7 +45,7 @@
<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.fence_house_id != null" type="info">ID: {{ row.fence_house_id }}</el-tag> <el-tag class="mr-2" v-if="row.fence_house_id != null" type="info">ID: {{ row.fence_house_id }}</el-tag>
<el-tag class="mr-2" v-if="row.fenceHouse.fence_house_name != null" type="info">名称: {{ row.fenceHouse.fence_house_name}}</el-tag> <el-tag class="mr-2" v-if="row.fenceHouse != null" type="info">名称: {{ row.fenceHouse.fence_house_name}}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="产品状态" align="center" prop="status"> <el-table-column label="产品状态" align="center" prop="status">

View File

@ -56,6 +56,7 @@ class FenceHouseLists extends BaseAdminDataLists implements ListsSearchInterface
public function lists(): array public function lists(): array
{ {
return FenceHouse::where($this->searchWhere) return FenceHouse::where($this->searchWhere)
->with(['farmAttr'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select() ->select()

View File

@ -52,6 +52,7 @@ class DeviceLogic extends BaseLogic
$device = Device::create([ $device = Device::create([
'user_id' => $userId, 'user_id' => $userId,
'code' => $params['code'], 'code' => $params['code'],
'iccid' => $params['iccid'],
'name' => $params['name'], 'name' => $params['name'],
'type' => $params['type'], 'type' => $params['type'],
'image' => $params['image'], 'image' => $params['image'],
@ -102,6 +103,7 @@ class DeviceLogic extends BaseLogic
$device = Device::where('id', $params['id'])->update([ $device = Device::where('id', $params['id'])->update([
'user_id' => $userId, 'user_id' => $userId,
'code' => $params['code'], 'code' => $params['code'],
'iccid' => $params['iccid'],
'name' => $params['name'], 'name' => $params['name'],
'type' => $params['type'], 'type' => $params['type'],
'image' => $params['image'], 'image' => $params['image'],

View File

@ -32,7 +32,7 @@ class DeviceValidate extends BaseValidate
*/ */
protected $rule = [ protected $rule = [
'id' => 'require', 'id' => 'require',
'code' => 'require', // 'code' => 'require',
'name' => 'require', 'name' => 'require',
'type' => 'require', 'type' => 'require',
'monitor_type' => 'require', 'monitor_type' => 'require',

View File

@ -34,17 +34,15 @@ class IndexController extends BaseApiController
{ {
$params = $this->request->get(); $params = $this->request->get();
//获取栏舍信息 //获取栏舍信息
if(isset($params['fence_house_id']) && $params['fence_house_id'] !=''){
$data = FenceHouse::where('user_id',$this->userId)->where('id',$params['fence_house_id'])->order('id desc')->findOrEmpty()->toArray(); $data = FenceHouse::where('id',$params['fence_house_id'])->order('id desc')->findOrEmpty()->toArray();
}else{
$data = FenceHouse::where('user_id',$this->userId)->order('id desc')->findOrEmpty()->toArray();
}
if(empty($data)){ if(empty($data)){
return $this->success('请求成功',[]); return $this->success('请求成功',[]);
} }
$product = Product::where('fence_house_id', $data['id'])->findOrEmpty()->toArray(); $product = Product::where('fence_house_id', $data['id'])->findOrEmpty()->toArray();
$deviceIds = ProductDevice::where('product_id', $product['id'])->column('device_id'); $deviceIds = ProductDevice::where('product_id', $product['id'])->column('device_id');
$device = Device::whereIn('id', $deviceIds)->where('device_type', 3)->findOrEmpty(); $device = Device::whereIn('id', $deviceIds)->where('type', 2)->findOrEmpty();
$data['video_url'] = $device['video_url']; $data['video_url'] = $device['video_url'];
$data['device_id'] = $device['id']; $data['device_id'] = $device['id'];
// 监控视频封面 // 监控视频封面