Browse Source

省份限制

develop
lemon 5 years ago
parent
commit
f0426dd03d
  1. 6
      app/AdminAgent/Controllers/DemandBiddingController.php
  2. 5
      app/AdminAgent/Controllers/DemandController.php
  3. 6
      app/AdminGuide/Controllers/DemandBiddingController.php
  4. 164
      app/AdminGuide/Controllers/DemandController.php
  5. 5
      app/AdminSupplier/Controllers/DemandBiddingController.php
  6. 166
      app/AdminSupplier/Controllers/DemandController.php

6
app/AdminAgent/Controllers/DemandBiddingController.php

@ -3,6 +3,7 @@
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;
@ -92,6 +93,11 @@ class DemandBiddingController extends AdminController
$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()) {
//发布人身份

5
app/AdminAgent/Controllers/DemandController.php

@ -37,6 +37,8 @@ class DemandController extends AdminController
return Grid::make(new Demand(['publisher','biddingUser']), function (Grid $grid) {
if (\request('self',0)) {
$grid->model()->where(['publisher_id' => Admin::user()->id,'publisher_type' => DemandTraits::$col[0]]);
} else {
$grid->model()->where(['province_id' => Admin::user()->province_id]);
}
$grid->column('id')->sortable();
$grid->column('title');
@ -47,7 +49,7 @@ class DemandController extends AdminController
$grid->column('images','图片')->display(function ($image) {
return json_decode($image,true);
})->image('', 60, 60);
$grid->column('deadline');
//$grid->column('deadline');
$grid->column('publisher.name','发布人');
$grid->column('publisher_type')->using(DemandTraits::$polymorphic);
$grid->column('biddingUser.name','中标人');
@ -144,6 +146,7 @@ class DemandController extends AdminController
$form->display('id');
$form->text('title')->required();
$form->textarea('comment')->required();
$form->distpicker(['province_id', 'city_id', 'area_id'], '请选择区域')->required();
$form->multipleImage('images','图片')->limit(5)->saving(function ($path) {
return json_encode($path);
});

6
app/AdminGuide/Controllers/DemandBiddingController.php

@ -3,6 +3,7 @@
namespace App\AdminGuide\Controllers;
use App\AdminAgent\Repositories\DemandBidding;
use App\Models\Demand;
use App\Traits\DemandTraits;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
@ -92,6 +93,11 @@ class DemandBiddingController extends AdminController
$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()) {
//发布人身份

164
app/AdminGuide/Controllers/DemandController.php

@ -36,6 +36,8 @@ class DemandController extends AdminController
return Grid::make(new Demand(['publisher','biddingUser']), function (Grid $grid) {
if (\request('self',0)) {
$grid->model()->where(['publisher_id' => Admin::user()->id,'publisher_type' => DemandTraits::$col[2]]);
} else {
$grid->model()->where(['province_id' => Admin::user()->province_id]);
}
$grid->column('id')->sortable();
$grid->column('title');
@ -98,87 +100,87 @@ class DemandController extends AdminController
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Demand(['publisher','biddingUser']), function (Show $show) {
$show->field('id');
$show->field('title');
$show->field('comment');
$show->field('images')->image();
$show->field('deadline');
$show->field('bidding_user_type','竞标用户类型')->using(DemandTraits::$polymorphic);
$show->field('price');
$show->field('stock');
$show->field('publisher_type')->using(DemandTraits::$polymorphic);
$show->field('publisher.name','发布人');
$show->field('state')->using(DemandTraits::$state)->dot(
[
1 => 'yellow',
2 => 'danger',
3 => 'success',
]
);;
$show->field('created_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new Demand(), function (Form $form) {
$form->disableEditingCheck();
$form->disableCreatingCheck();
$form->disableViewCheck();
$form->display('id');
$form->text('title')->required();
$form->textarea('comment')->required();
$form->multipleImage('images','图片')->limit(5)->saving(function ($path) {
return json_encode($path);
});
$form->hidden('deadline')->required();
$form->select('bidding_user_type','竞标用户类型')
->when([2],function (Form $form){
$form->select('demand_product_id','产品')->options(function (){
return Product::query()->whereIn('agent_id',[0,Admin::user()->id])->pluck('title','id');
});
})
->options([
1 => '供应商',
2 => '地接'
])
->default(1)
->required();
$form->decimal('price')->required();
$form->number('stock')->required();
$form->hidden('publisher_type')->required();
$form->hidden('publisher_id')->required();
$form->saving(function (Form $form) {
// 判断是否是新增操作
if ($form->isCreating()) {
if ($form->bidding_user_type != 2) {
$form->demand_product_id = 0;
}
$form->bidding_user_type = DemandTraits::$col[$form->bidding_user_type];
//处理流拍时间
$form->deadline = now()->addDays(5);
//发布人身份
$form->publisher_type = DemandTraits::$col[2];
$form->publisher_id = Admin::user()->id;
}
});
});
}
///**
// * Make a show builder.
// *
// * @param mixed $id
// *
// * @return Show
// */
//protected function detail($id)
//{
// return Show::make($id, new Demand(['publisher','biddingUser']), function (Show $show) {
// $show->field('id');
// $show->field('title');
// $show->field('comment');
// $show->field('images')->image();
// $show->field('deadline');
// $show->field('bidding_user_type','竞标用户类型')->using(DemandTraits::$polymorphic);
// $show->field('price');
// $show->field('stock');
// $show->field('publisher_type')->using(DemandTraits::$polymorphic);
// $show->field('publisher.name','发布人');
// $show->field('state')->using(DemandTraits::$state)->dot(
// [
// 1 => 'yellow',
// 2 => 'danger',
// 3 => 'success',
// ]
// );;
// $show->field('created_at');
// });
//}
//
///**
// * Make a form builder.
// *
// * @return Form
// */
//protected function form()
//{
// return Form::make(new Demand(), function (Form $form) {
// $form->disableEditingCheck();
// $form->disableCreatingCheck();
// $form->disableViewCheck();
// $form->display('id');
// $form->text('title')->required();
// $form->textarea('comment')->required();
// $form->multipleImage('images','图片')->limit(5)->saving(function ($path) {
// return json_encode($path);
// });
// $form->hidden('deadline')->required();
// $form->select('bidding_user_type','竞标用户类型')
// ->when([2],function (Form $form){
// $form->select('demand_product_id','产品')->options(function (){
// return Product::query()->whereIn('agent_id',[0,Admin::user()->id])->pluck('title','id');
// });
// })
// ->options([
// 1 => '供应商',
// 2 => '地接'
// ])
// ->default(1)
// ->required();
// $form->decimal('price')->required();
// $form->number('stock')->required();
// $form->hidden('publisher_type')->required();
// $form->hidden('publisher_id')->required();
// $form->saving(function (Form $form) {
// // 判断是否是新增操作
// if ($form->isCreating()) {
// if ($form->bidding_user_type != 2) {
// $form->demand_product_id = 0;
// }
// $form->bidding_user_type = DemandTraits::$col[$form->bidding_user_type];
// //处理流拍时间
// $form->deadline = now()->addDays(5);
// //发布人身份
// $form->publisher_type = DemandTraits::$col[2];
// $form->publisher_id = Admin::user()->id;
// }
// });
// });
//}
//public function binding()
//{

5
app/AdminSupplier/Controllers/DemandBiddingController.php

@ -137,6 +137,11 @@ class DemandBiddingController extends AdminController
});
$form->saved(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->isEditing()) {
$productId = request('demand_product_id', 0);
if (!empty($productId)) {

166
app/AdminSupplier/Controllers/DemandController.php

@ -28,6 +28,8 @@ class DemandController extends AdminController
return Grid::make(new Demand(['publisher','biddingUser', 'bidding']), function (Grid $grid) {
if (\request('self',0)) {
$grid->model()->where(['publisher_id' => Admin::user()->id,'publisher_type' => DemandTraits::$col[1]]);
}else {
$grid->model()->where(['province_id' => Admin::user()->province_id]);
}
$grid->column('id')->sortable();
$grid->column('title');
@ -38,7 +40,7 @@ class DemandController extends AdminController
$grid->column('images','图片')->display(function ($image) {
return json_decode($image,true);
})->image('', 60, 60);
$grid->column('deadline');
//$grid->column('deadline');
$grid->column('publisher.name','发布人');
$grid->column('publisher_type')->using(DemandTraits::$polymorphic);
$grid->column('biddingUser.name','中标人');
@ -79,6 +81,7 @@ class DemandController extends AdminController
$grid->disableEditButton();
$grid->disableQuickEditButton();
$grid->disableViewButton();
$grid->disableCreateButton();
$grid->disableActions();
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');
@ -86,87 +89,88 @@ class DemandController extends AdminController
});
});
}
//
///**
// * Make a show builder.
// *
// * @param mixed $id
// *
// * @return Show
// */
//protected function detail($id)
//{
// return Show::make($id, new Demand(['publisher','biddingUser']), function (Show $show) {
// $show->field('id');
// $show->field('title');
// $show->field('comment');
// $show->field('images')->image();
// $show->field('deadline');
// $show->field('bidding_user_type','竞标用户类型')->using(DemandTraits::$polymorphic);
// $show->field('price');
// $show->field('stock');
// $show->field('publisher_type')->using(DemandTraits::$polymorphic);
// $show->field('publisher.name','发布人');
// $show->field('state')->using(DemandTraits::$state)->dot(
// [
// 1 => 'yellow',
// 2 => 'danger',
// 3 => 'success',
// ]
// );;
// $show->field('created_at');
// });
//}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Demand(['publisher','biddingUser']), function (Show $show) {
$show->field('id');
$show->field('title');
$show->field('comment');
$show->field('images')->image();
$show->field('deadline');
$show->field('bidding_user_type','竞标用户类型')->using(DemandTraits::$polymorphic);
$show->field('price');
$show->field('stock');
$show->field('publisher_type')->using(DemandTraits::$polymorphic);
$show->field('publisher.name','发布人');
$show->field('state')->using(DemandTraits::$state)->dot(
[
1 => 'yellow',
2 => 'danger',
3 => 'success',
]
);;
$show->field('created_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new Demand(), function (Form $form) {
$form->disableEditingCheck();
$form->disableCreatingCheck();
$form->disableViewCheck();
$form->display('id');
$form->text('title')->required();
$form->textarea('comment')->required();
$form->multipleImage('images','图片')->limit(5)->saving(function ($path) {
return json_encode($path);
});
$form->hidden('deadline');
$form->select('bidding_user_type','竞标用户类型')
->when([0],function (Form $form){
$form->select('demand_product_id','产品')->options(function (){
return DemandProduct::query()->where('supplier_id',Admin::user()->id)->where('status',1)->pluck('title','id');
});
})
->options([
'代理商'
])
->default(0)
->required();
$form->decimal('price')->required();
$form->number('stock')->required();
$form->hidden('publisher_type');
$form->hidden('publisher_id');
$form->saving(function (Form $form) {
// 判断是否是新增操作
if ($form->isCreating()) {
//if ($form->bidding_user_type != 2) {
// $form->demand_product_id = 0;
//}
$form->bidding_user_type = DemandTraits::$col[$form->bidding_user_type];
//处理流拍时间
$form->deadline = now()->addDays(5);
//发布人身份
$form->publisher_type = DemandTraits::$col[1];
$form->publisher_id = Admin::user()->id;
}
});
});
}
///**
// * Make a form builder.
// *
// * @return Form
// */
//protected function form()
//{
// return Form::make(new Demand(), function (Form $form) {
// $form->disableEditingCheck();
// $form->disableCreatingCheck();
// $form->disableViewCheck();
// $form->display('id');
// $form->text('title')->required();
// $form->textarea('comment')->required();
// $form->distpicker(['province_id', 'city_id', 'area_id'], '请选择区域')->required();
// $form->multipleImage('images','图片')->limit(5)->saving(function ($path) {
// return json_encode($path);
// });
// $form->hidden('deadline');
// $form->select('bidding_user_type','竞标用户类型')
// ->when([0],function (Form $form){
// $form->select('demand_product_id','产品')->options(function (){
// return DemandProduct::query()->where('supplier_id',Admin::user()->id)->where('status',1)->pluck('title','id');
// });
// })
// ->options([
// '代理商'
// ])
// ->default(0)
// ->required();
// $form->decimal('price')->required();
// $form->number('stock')->required();
// $form->hidden('publisher_type');
// $form->hidden('publisher_id');
// $form->saving(function (Form $form) {
// // 判断是否是新增操作
// if ($form->isCreating()) {
// //if ($form->bidding_user_type != 2) {
// // $form->demand_product_id = 0;
// //}
// $form->bidding_user_type = DemandTraits::$col[$form->bidding_user_type];
// //处理流拍时间
// $form->deadline = now()->addDays(5);
// //发布人身份
// $form->publisher_type = DemandTraits::$col[1];
// $form->publisher_id = Admin::user()->id;
// }
// });
// });
//}
//public function binding()
//{

Loading…
Cancel
Save