erp/app/admin/lists/supplier/SupplierLists.php
2024-05-10 16:51:19 +08:00

72 lines
1.7 KiB
PHP

<?php
namespace app\admin\lists\supplier;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\goods\GoodsLabel;
use app\common\model\supplier\Supplier;
use app\common\lists\ListsSearchInterface;
/**
* 供应商管理列表
* Class SupplierLists
* @package app\admin\listssupplier
*/
class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/27 14:33
*/
public function setSearch(): array
{
return [
'=' => ['category_id', 'type_id', 'mer_name'],
];
}
/**
* @notes 获取供应商管理列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/27 14:33
*/
public function lists(): array
{
return Supplier::where($this->searchWhere)->withoutField(['update_time','delete_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
if(!empty($data['sys_labels'])){
$goodslabel = GoodsLabel::where('id','in',trim($data['sys_labels'],','))->column('name');
$data['sys_labels_text'] = implode(',',$goodslabel);
}else{
$data['sys_labels_text'] = '';
}
})
->toArray();
}
/**
* @notes 获取供应商管理数量
* @return int
* @author likeadmin
* @date 2024/04/27 14:33
*/
public function count(): int
{
return Supplier::where($this->searchWhere)->count();
}
}