|
@@ -40,45 +40,43 @@ class VaccineController extends AdminController
|
|
$grid->disableCreateButton(false);
|
|
$grid->disableCreateButton(false);
|
|
$grid->column('id', __('ID'));
|
|
$grid->column('id', __('ID'));
|
|
$grid->column('name', __('疫苗名称'));
|
|
$grid->column('name', __('疫苗名称'));
|
|
-// $grid->column('organizations', '机构库存')->display(function (){
|
|
|
|
-// return '点击查看';
|
|
|
|
-// })->modal('机构库存', function ($model) {
|
|
|
|
-// $org = $model->organizationvaccines()->get()->map(function ($comment) {
|
|
|
|
-// return $comment->only(['org_id','vaccine_id','stock']);
|
|
|
|
-// });
|
|
|
|
-// $org = $org->toArray();
|
|
|
|
-// for($i=0;$i<count($org);$i++)
|
|
|
|
-// {
|
|
|
|
-// $id = $org[$i]['org_id'];
|
|
|
|
-// $org[$i]['vaccine_id'] = $this->name;
|
|
|
|
-// $org[$i]['org_name'] = Organization::where('id',$id)->value('name');
|
|
|
|
-// }
|
|
|
|
-// return new Table(['ID','疫苗','库存','机构名称'], $org);
|
|
|
|
-// });
|
|
|
|
- $grid->column('stocks', __('剩余库存'))->display(function (){
|
|
|
|
- return OrganizationVaccine::where(['vaccine_id'=>$this->id])->sum('stock');
|
|
|
|
|
|
+
|
|
|
|
+ $grid->column('type', __('疫苗类型'))->using(OrganizationVaccine::getType())->label('info');
|
|
|
|
+ $grid->column('price', __('价格'))->display(function ($p){
|
|
|
|
+ $t = $this->type;
|
|
|
|
+ if($t == 1)return '免费';
|
|
|
|
+ return ($p / 100).'元';
|
|
|
|
+ });
|
|
|
|
+ $grid->actions(function ($actions){
|
|
|
|
+
|
|
|
|
+ $actions->disableDelete();
|
|
});
|
|
});
|
|
- $grid->column('org_id', __('已使用量'))->display(function () {
|
|
|
|
- return Order::where(['product_type'=>4])->wherehas('orderVaccine',function ($query){
|
|
|
|
- $query->where('vaccine_id',$this->id);
|
|
|
|
- })->count();
|
|
|
|
|
|
+
|
|
|
|
+// $grid->column('stock', __('库存'));
|
|
|
|
+
|
|
|
|
+ $grid->column('stock', __('剩余库存'))->display(function ($w){
|
|
|
|
+ return !empty($w) ? $w : 0;
|
|
});
|
|
});
|
|
- $grid->column('today_num', __('今日预约'))->display(function () {
|
|
|
|
- return Order::where(['product_type'=>4])->wherehas('orderVaccine',function ($query){
|
|
|
|
- $query->where('vaccine_id',$this->id);
|
|
|
|
- })->count();
|
|
|
|
- });;
|
|
|
|
|
|
+// $grid->column('org_id', __('已使用量'))->display(function () {
|
|
|
|
+// return Order::where(['product_type'=>4])->wherehas('orderVaccine',function ($query){
|
|
|
|
+// $query->where('vaccine_id',$this->id);
|
|
|
|
+// })->count();
|
|
|
|
+// });
|
|
|
|
+// $grid->column('today_num', __('今日预约'))->display(function () {
|
|
|
|
+// return Order::where(['product_type'=>4])->wherehas('orderVaccine',function ($query){
|
|
|
|
+// $query->where('vaccine_id',$this->id);
|
|
|
|
+// })->count();
|
|
|
|
+// });
|
|
|
|
+ $grid->column('supplier', __('厂家'));
|
|
|
|
+ $grid->column('remark', __('备注'));
|
|
$grid->filter(function ($fliter){
|
|
$grid->filter(function ($fliter){
|
|
-// $fliter->equal('type','类别')->select(OrganizationVaccine::getType());
|
|
|
|
$fliter->like('name','疫苗');
|
|
$fliter->like('name','疫苗');
|
|
});
|
|
});
|
|
- $grid->actions(function ($actions) {
|
|
|
|
|
|
|
|
- // append一个操作
|
|
|
|
- $actions->append('<a href=""><i class="fa fa-header">跳转</i></a>');
|
|
|
|
|
|
+ $grid->column('created_at', __('创建时间'));
|
|
|
|
+ $grid->column('updated_at', __('更新时间'));
|
|
|
|
|
|
- // prepend一个操作
|
|
|
|
- $actions->prepend('<a href="http://www.baidu.com" target="_blank"><i class="fa fa-cab"></i></a>');
|
|
|
|
|
|
+ $grid->actions(function ($actions) {
|
|
|
|
|
|
$actions->disableDelete();
|
|
$actions->disableDelete();
|
|
});
|
|
});
|
|
@@ -96,7 +94,13 @@ class VaccineController extends AdminController
|
|
$show = new Show(Vaccine::findOrFail($id));
|
|
$show = new Show(Vaccine::findOrFail($id));
|
|
|
|
|
|
$show->field('id', __('Id'));
|
|
$show->field('id', __('Id'));
|
|
- $show->field('name', __('疫苗名称'));
|
|
|
|
|
|
+ $show->field('name', __('疫苗'));
|
|
|
|
+ $show->field('type', __('疫苗类型'))->using(OrganizationVaccine::getType());
|
|
|
|
+ $show->field('price', __('价格'))->as(function ($w){
|
|
|
|
+ return round($w/100, 2).'元';
|
|
|
|
+ });
|
|
|
|
+ $show->field('supplier', __('厂家'));
|
|
|
|
+ $show->field('reamrk', __('备注'));
|
|
$show->field('created_at', __('创建时间'));
|
|
$show->field('created_at', __('创建时间'));
|
|
$show->field('updated_at', __('更新时间'));
|
|
$show->field('updated_at', __('更新时间'));
|
|
|
|
|
|
@@ -113,29 +117,36 @@ class VaccineController extends AdminController
|
|
$form = new Form(new Vaccine());
|
|
$form = new Form(new Vaccine());
|
|
|
|
|
|
$orglist = Organization::pluck('name','id');
|
|
$orglist = Organization::pluck('name','id');
|
|
|
|
+ $is_admin = Admin::user()->isAdministrator();
|
|
$org_id = Admin::user()->org_id;
|
|
$org_id = Admin::user()->org_id;
|
|
-// if($org_id){
|
|
|
|
-// $orglist = Organization::where(['id'=>$org_id])->pluck('name','id');
|
|
|
|
-// }
|
|
|
|
-// $form->editing(function ($f){
|
|
|
|
-// $f->model()->price /= 100;
|
|
|
|
-// });
|
|
|
|
- $form->hidden('org_id', __('类型'))->value($org_id);
|
|
|
|
-// $form->select('type', __('类型'))->options([1=>'一类',2=>'二类'])->default(1);
|
|
|
|
-// $form->select('org_id','机构')->options($orglist)->rules('required',['requried'=>'请选择机构']);
|
|
|
|
|
|
+ if($org_id && $is_admin){
|
|
|
|
+ $orglist = Organization::pluck('name','id');
|
|
|
|
+ }
|
|
|
|
+ $form->editing(function ($f){
|
|
|
|
+ $f->model()->price /= 100;
|
|
|
|
+ });
|
|
|
|
+ if($is_admin ){
|
|
|
|
+ $form->select('org_id','机构')->options($orglist)->rules('required',['requried'=>'请选择机构']);
|
|
|
|
+ } else {
|
|
|
|
+ $form->hidden('org_id', __('类型'))->value($org_id);
|
|
|
|
+ }
|
|
$form->text('name', __('疫苗名称'))->rules('required',['required'=>'请输入疫苗']);
|
|
$form->text('name', __('疫苗名称'))->rules('required',['required'=>'请输入疫苗']);
|
|
-// $form->text('name', __('疫苗名称'))->creationRules(['required', "unique:vaccines"])
|
|
|
|
-// ->updateRules(['required', "unique:vaccines,name,{{id}}"]);
|
|
|
|
|
|
+ $form->select('type', __('疫苗类型'))->options(OrganizationVaccine::getType())->when(1,function () use($form){
|
|
|
|
+ $form->hidden('price','价格')->value(0);
|
|
|
|
+ })->when(2,function () use($form){
|
|
|
|
+ $form->text('price','价格');
|
|
|
|
+ });
|
|
$states = [
|
|
$states = [
|
|
'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
|
|
'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
|
|
'on' => ['value' => 1, 'text' => '启用', 'color' => 'success'],
|
|
'on' => ['value' => 1, 'text' => '启用', 'color' => 'success'],
|
|
];
|
|
];
|
|
|
|
+ $form->text('stock', __('库存'))->rules('required',['requried'=>'请填写库存']);
|
|
|
|
+ $form->text('supplier','厂家');
|
|
$form->switch('states','状态')->states($states)->default(1);
|
|
$form->switch('states','状态')->states($states)->default(1);
|
|
-// $form->text('stock', __('库存'))->rules('required',['requried'=>'请填写库存']);
|
|
|
|
-// $form->textarea('remark', __('备注'));
|
|
|
|
-// $form->saving(function ($form){
|
|
|
|
-// $form->price = $form->price*100;
|
|
|
|
-// });
|
|
|
|
|
|
+ $form->textarea('remark', __('备注'));
|
|
|
|
+ $form->saving(function ($form){
|
|
|
|
+ $form->price = $form->price*100;
|
|
|
|
+ });
|
|
|
|
|
|
return $form;
|
|
return $form;
|
|
}
|
|
}
|