update
This commit is contained in:
parent
485197c75c
commit
249c59f701
|
@ -44,8 +44,8 @@
|
|||
<el-table-column label="产品编号" prop="code" show-overflow-tooltip />
|
||||
<el-table-column label="所属栏舍" width="200">
|
||||
<template #default="{ row }">
|
||||
<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.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>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品状态" align="center" prop="status">
|
||||
|
|
|
@ -86,11 +86,10 @@ class DeviceLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
return Db::name('device')->alias('d')
|
||||
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
|
||||
->leftJoin('user u','u.id = d.user_id')
|
||||
->leftJoin('farm f','f.user_id = u.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')
|
||||
->field('d.*, u.account, pd.product_id, p.name as product_name, f.id as farm_id, f.farm_name')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['d.id' => 'desc'])
|
||||
->select()->each(function($item, $key){
|
||||
|
|
|
@ -83,12 +83,11 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return Db::name('product')->alias('p')
|
||||
return Product::alias('p')
|
||||
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
|
||||
->with(['fenceHouse'])
|
||||
->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')
|
||||
->field('p.*, lp.land_id, l.title, u.account')
|
||||
->field('p.*, u.account')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['p.id' => 'desc'])
|
||||
->select()
|
||||
|
@ -107,8 +106,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace app\common\model\land;
|
|||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
use app\common\model\fence_house\FenceHouse;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -42,4 +42,8 @@ class Product extends BaseModel
|
|||
return $this->hasOne(\app\common\model\user\User::class, 'id', 'user_id');
|
||||
}
|
||||
|
||||
public function fenceHouse()
|
||||
{
|
||||
return $this->hasOne(FenceHouse::class, 'id', 'fence_house_id');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue