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.
		
		
		
		
		
			
		
			
				
					
					
						
							112 lines
						
					
					
						
							3.1 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							112 lines
						
					
					
						
							3.1 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\AdminAgent\Controllers;
							 | 
						|
								
							 | 
						|
								use App\AdminAgent\Repositories\DemandBidding;
							 | 
						|
								use App\Models\Demand;
							 | 
						|
								use App\Traits\DemandTraits;
							 | 
						|
								use Dcat\Admin\Admin;
							 | 
						|
								use Dcat\Admin\Form;
							 | 
						|
								use Dcat\Admin\Grid;
							 | 
						|
								use Dcat\Admin\Show;
							 | 
						|
								use Dcat\Admin\Http\Controllers\AdminController;
							 | 
						|
								use http\Env\Request;
							 | 
						|
								use Illuminate\Support\Arr;
							 | 
						|
								
							 | 
						|
								class DemandBiddingController extends AdminController
							 | 
						|
								{
							 | 
						|
								    /**
							 | 
						|
								     * Make a grid builder.
							 | 
						|
								     *
							 | 
						|
								     * @return Grid
							 | 
						|
								     */
							 | 
						|
								    protected function grid()
							 | 
						|
								    {
							 | 
						|
								        return Grid::make(new DemandBidding(['demand']), function (Grid $grid) {
							 | 
						|
											$grid->model()->where(['bidding_user_id' => Admin::user()->id,'bidding_user_type' => Arr::first(DemandTraits::$col)]);
							 | 
						|
								            $grid->column('id')->sortable();
							 | 
						|
								            $grid->column('price');
							 | 
						|
								            $grid->column('comment');
							 | 
						|
											$grid->column('demand.title','竞拍标题');
							 | 
						|
											$grid->column('demand.comment','竞拍内容')
							 | 
						|
												->display('查看')
							 | 
						|
												->modal('详情',function ($modal) {
							 | 
						|
													$modal->xl();
							 | 
						|
													return $this->demand->comment;
							 | 
						|
												});
							 | 
						|
								
							 | 
						|
											$grid->column('state','状态')->using(DemandTraits::$biddingState)->dot(
							 | 
						|
												[
							 | 
						|
													'yellow',
							 | 
						|
													'success',
							 | 
						|
													'danger',
							 | 
						|
												]
							 | 
						|
											);
							 | 
						|
								            $grid->column('created_at');
							 | 
						|
								            $grid->column('updated_at')->sortable();
							 | 
						|
											$grid->disableDeleteButton();
							 | 
						|
											$grid->disableEditButton();
							 | 
						|
											$grid->disableQuickEditButton();
							 | 
						|
											$grid->disableViewButton();
							 | 
						|
											$grid->disableCreateButton();
							 | 
						|
											$grid->disableActions();
							 | 
						|
											$grid->disableRowSelector();
							 | 
						|
								            $grid->filter(function (Grid\Filter $filter) {
							 | 
						|
								                $filter->equal('id');
							 | 
						|
								
							 | 
						|
								            });
							 | 
						|
								        });
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Make a show builder.
							 | 
						|
								     *
							 | 
						|
								     * @param mixed $id
							 | 
						|
								     *
							 | 
						|
								     * @return Show
							 | 
						|
								     */
							 | 
						|
								    protected function detail($id)
							 | 
						|
								    {
							 | 
						|
								        return Show::make($id, new DemandBidding(), function (Show $show) {
							 | 
						|
								            $show->field('id');
							 | 
						|
								            $show->field('price');
							 | 
						|
								            $show->field('comment');
							 | 
						|
								            $show->field('created_at');
							 | 
						|
								            $show->field('updated_at');
							 | 
						|
								        });
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Make a form builder.
							 | 
						|
								     *
							 | 
						|
								     * @return Form
							 | 
						|
								     */
							 | 
						|
								    protected function form()
							 | 
						|
								    {
							 | 
						|
								        return Form::make(new DemandBidding(), function (Form $form) {
							 | 
						|
											$form->disableEditingCheck();
							 | 
						|
											$form->disableCreatingCheck();
							 | 
						|
											$form->disableViewCheck();
							 | 
						|
								        	$form->display('id');
							 | 
						|
								            $form->text('price')->required();
							 | 
						|
								            $form->textarea('comment')->required();
							 | 
						|
											$form->hidden('demand_id')->value(request('demand_id',0));
							 | 
						|
											$form->hidden('bidding_user_type');
							 | 
						|
											$form->hidden('bidding_user_id');
							 | 
						|
											$form->saving(function (Form $form) {
							 | 
						|
												$provinceId = Demand::query()->where('id',$this->demand_id)->value('province_id');
							 | 
						|
								
							 | 
						|
												if ($provinceId != Admin::user()->province_id) {
							 | 
						|
													$form->response()->error('竞标失败,指能竞标跟自己相同省份的的需求');
							 | 
						|
												}
							 | 
						|
												// 判断是否是新增操作
							 | 
						|
												if ($form->isCreating()) {
							 | 
						|
													//发布人身份
							 | 
						|
													$form->bidding_user_type = DemandTraits::$col[0];
							 | 
						|
													$form->bidding_user_id = Admin::user()->id;
							 | 
						|
												}
							 | 
						|
												$form->response()->success('操作成功')->redirect('demand_bidding');
							 | 
						|
											});
							 | 
						|
								        });
							 | 
						|
								    }
							 | 
						|
								}
							 |