You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							51 lines
						
					
					
						
							1.4 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							51 lines
						
					
					
						
							1.4 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\AdminSupplier\Renderable;
							 | 
						|
								use App\Common\ProductStatus;
							 | 
						|
								use App\AdminAgent\Repositories\Product;
							 | 
						|
								use App\Models\DemandProduct;
							 | 
						|
								use Dcat\Admin\Admin;
							 | 
						|
								use Dcat\Admin\Grid;
							 | 
						|
								use Dcat\Admin\Grid\LazyRenderable;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * 选择产品
							 | 
						|
								 * Class SelectProduct
							 | 
						|
								 * @package App\AdminAgent\Renderable
							 | 
						|
								 */
							 | 
						|
								class SelectProduct extends LazyRenderable
							 | 
						|
								{
							 | 
						|
									public function grid(): Grid
							 | 
						|
									{
							 | 
						|
										// 获取外部传递的参数
							 | 
						|
								//		$id = $this->id;
							 | 
						|
										Admin::translation('product');
							 | 
						|
										return Grid::make(new DemandProduct(['supplier:id,name']), function (Grid $grid) {
							 | 
						|
											$grid->disableActions();
							 | 
						|
											$grid->disableBatchDelete();
							 | 
						|
											$grid->disableBatchActions();
							 | 
						|
								
							 | 
						|
											//$grid->model()->where('status', ProductStatus::ON_SALE);
							 | 
						|
											$grid->model()->where([
							 | 
						|
												'supplier_id' => Admin::user()->id,
							 | 
						|
												'status' => ProductStatus::ON_SALE
							 | 
						|
											]);
							 | 
						|
											$grid->quickSearch(['title', 'supplier.name'])->placeholder('搜索产品名称、供应商');
							 | 
						|
								
							 | 
						|
											$grid->column('id');
							 | 
						|
											$grid->column('supplier.name', '供应商')->display(fn($v) => $v);
							 | 
						|
											$grid->column('title');
							 | 
						|
											$grid->column('picture')->image('',60, 60);
							 | 
						|
											$grid->column('sale');
							 | 
						|
											$grid->column('updated_at');
							 | 
						|
								
							 | 
						|
											$grid->paginate(15);
							 | 
						|
								
							 | 
						|
											$grid->filter(function (Grid\Filter $filter) {
							 | 
						|
												$filter->equal('id')->width(2);
							 | 
						|
												$filter->like('title')->width(4);
							 | 
						|
												$filter->like('supplier.name', '供应商名称')->width(4);
							 | 
						|
											});
							 | 
						|
										});
							 | 
						|
									}
							 | 
						|
								}
							 |