| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -2,11 +2,11 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					namespace App\Admin\Actions\Grid; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Common\ProductStatus; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\IndustryProduct; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\Product; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Actions\Response; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Grid\BatchAction; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Traits\HasPermissions; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Illuminate\Contracts\Auth\Authenticatable; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Illuminate\Database\Eloquent\Model; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Illuminate\Http\Request; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/** | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -19,23 +19,25 @@ class BatchAuditProduct extends BatchAction | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @return string | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						protected $title = '批量审核'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						protected $action; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private ?string $title_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private $type = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public function __construct($title = null) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * BatchAuditProduct constructor. | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @param null $title | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @param int $action 1:通过;2:拒绝 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 * @param int $type 1:普通产品Product;2:行业产品IndustryProduct; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public function __construct($title = null, $action = 1, $type = 1) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							parent::__construct($title); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$this->action = $action; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$this->type = $type; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public function render() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$redirect = request()->fullUrl(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$this->title_text = $action == 1 ? '审核通过' : '审核拒绝'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$this->title = '<i class="fa '.($action == 1 ? 'fa-check-square' : 'fa-times-circle') . '"></i> ' . $this->title_text; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return <<<HTML | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					<a  data-name="{$this->parent->getName()}" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    data-action="batch-delete" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    data-redirect="{$redirect}" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    data-url="{$this->resource()}"><i class="fa fa-check-square"></i> {$this->title}</a> | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					HTML;//拒绝图标:fa-times-circle
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							parent::__construct($title); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -47,9 +49,15 @@ HTML;//拒绝图标:fa-times-circle | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public function handle(Request $request) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return $this->response() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ->success('Processed successfully: '.json_encode($this->getKey())) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ->redirect('/'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$status = $request->action == 1 ? ProductStatus::ON_SALE : ProductStatus::REFUSE; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if ($request->type == 1) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								Product::whereIn('id', $this->getKey())->update(['status' => $status]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								IndustryProduct::whereIn('id', $this->getKey())->update(['status' => $status]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return $this->response()->success('操作成功!')->refresh(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -57,24 +65,17 @@ HTML;//拒绝图标:fa-times-circle | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public function confirm() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							// return ['Confirm?', 'contents'];
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							 return "确定要批量{$this->title_text}吗?"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param Model|Authenticatable|HasPermissions|null $user | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @return bool | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    protected function authorize($user): bool | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @return array | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    protected function parameters() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return []; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        	'action' => $this->action, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								'type' => $this->type, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |