| xqd
@@ -32,25 +32,29 @@ class VaccineController extends AdminController
|
|
|
{
|
|
|
$grid = new Grid(new Vaccine());
|
|
|
$grid->model()->orderByDesc('id');
|
|
|
+ $org_id = Admin::user()->org_id;
|
|
|
+ if(!empty($org_id)){
|
|
|
+ $grid->model()->where(['org_id'=>$org_id]);
|
|
|
+ }
|
|
|
|
|
|
$grid->disableCreateButton(false);
|
|
|
$grid->column('id', __('ID'));
|
|
|
$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('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');
|
|
|
});
|
| xqd
@@ -110,17 +114,23 @@ class VaccineController extends AdminController
|
|
|
|
|
|
$orglist = Organization::pluck('name','id');
|
|
|
$org_id = Admin::user()->org_id;
|
|
|
- if($org_id){
|
|
|
- $orglist = Organization::where(['id'=>$org_id])->pluck('name','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'=>'请选择机构']);
|
|
|
- $form->text('name', __('疫苗名称'))->creationRules(['required', "unique:vaccines"])
|
|
|
- ->updateRules(['required', "unique:vaccines,name,{{id}}"]);
|
|
|
- $form->hidden('states')->value(1);
|
|
|
+ $form->text('name', __('疫苗名称'))->rules('required',['required'=>'请输入疫苗']);
|
|
|
+// $form->text('name', __('疫苗名称'))->creationRules(['required', "unique:vaccines"])
|
|
|
+// ->updateRules(['required', "unique:vaccines,name,{{id}}"]);
|
|
|
+ $states = [
|
|
|
+ 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
|
|
|
+ 'on' => ['value' => 1, 'text' => '启用', 'color' => 'success'],
|
|
|
+ ];
|
|
|
+ $form->switch('states','状态')->states($states)->default(1);
|
|
|
// $form->text('stock', __('库存'))->rules('required',['requried'=>'请填写库存']);
|
|
|
// $form->textarea('remark', __('备注'));
|
|
|
// $form->saving(function ($form){
|