Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1fe5a024
authored
Nov 13, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
药店权限
parent
f4a611f2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
12 deletions
+63
-12
app/Admin/Controllers/DosageController.php
+22
-2
app/Admin/Controllers/PharmacyDrugController.php
+23
-0
app/Admin/Extensions/ToolBar/Forms/AddPharmacyDrugForm.php
+6
-2
app/Admin/routes.php
+11
-7
database/migrations/2024_11_11_055836_create_pharmacy_drug_table.php
+1
-1
No files found.
app/Admin/Controllers/DosageController.php
View file @
1fe5a024
...
...
@@ -3,10 +3,11 @@
namespace
App\Admin\Controllers
;
use
App\Admin\Repositories\DosageRepository
;
use
App\Models\PharmacyModel
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Show
;
// 用法用量
...
...
@@ -20,8 +21,14 @@ class DosageController extends AdminController
protected
function
grid
()
{
return
Grid
::
make
(
new
DosageRepository
(
'pharmacy'
),
function
(
Grid
$grid
)
{
// 权限判断和数据过滤
if
(
!
Admin
::
user
()
->
pharmacy_id
)
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
}
$grid
->
model
()
->
orderBy
(
'id'
,
'DESC'
);
$grid
->
model
()
->
where
(
'pharmacy_id'
,
Admin
::
user
()
->
pharmacy_id
);
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'pharmacy.name'
,
'药店'
);
$grid
->
column
(
'dosage_desc'
);
...
...
@@ -50,6 +57,8 @@ protected function grid()
*/
protected
function
detail
(
$id
)
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
return
Show
::
make
(
$id
,
new
DosageRepository
(),
function
(
Show
$show
)
{
$show
->
field
(
'id'
);
$show
->
field
(
'dosage_desc'
);
...
...
@@ -71,14 +80,25 @@ protected function detail($id)
protected
function
form
()
{
return
Form
::
make
(
new
DosageRepository
(),
function
(
Form
$form
)
{
// 权限判断和数据过滤
if
(
!
Admin
::
user
()
->
pharmacy_id
)
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
}
if
(
$form
->
isEditing
()
&&
(
Admin
::
user
()
->
pharmacy_id
!=
$form
->
model
()
->
pharmacy_id
))
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
}
$form
->
display
(
'id'
)
->
width
(
4
);
$form
->
select
(
'pharmacy_id'
)
->
options
(
PharmacyModel
::
all
()
->
pluck
(
'name'
,
'id'
))
->
width
(
4
)
->
required
(
);
$form
->
hidden
(
'pharmacy_id'
);
$form
->
text
(
'dosage_desc'
)
->
width
(
4
)
->
required
();
$form
->
textarea
(
'dosage_show'
)
->
width
(
4
)
->
required
();
$form
->
display
(
'created_at'
)
->
width
(
4
);
$form
->
display
(
'updated_at'
)
->
width
(
4
);
$form
->
saving
(
function
(
Form
$form
)
{
// 不能动
$form
->
pharmacy_id
=
Admin
::
user
()
->
pharmacy_id
;
});
// 右上角按钮控制
$form
->
disableDeleteButton
();
// 去掉删除按钮
});
...
...
app/Admin/Controllers/PharmacyDrugController.php
View file @
1fe5a024
...
...
@@ -7,9 +7,11 @@
use
App\Models\DosageModel
;
use
App\Models\DrugModel
;
use
App\Models\DrugUnitModel
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Show
;
// 药店-药品
...
...
@@ -23,8 +25,14 @@ class PharmacyDrugController extends AdminController
protected
function
grid
()
{
return
Grid
::
make
(
new
PharmacyDrugRepository
([
'drug'
,
'dosage'
,
'pharmacy'
]),
function
(
Grid
$grid
)
{
// 权限判断和数据过滤
if
(
!
Admin
::
user
()
->
pharmacy_id
)
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
}
$grid
->
model
()
->
orderBy
(
'id'
,
'DESC'
);
$grid
->
model
()
->
where
(
'pharmacy_id'
,
Admin
::
user
()
->
pharmacy_id
);
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'pharmacy.name'
,
'药店'
);
// $grid->column('drug_id');
...
...
@@ -74,6 +82,8 @@ protected function grid()
*/
protected
function
detail
(
$id
)
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
return
Show
::
make
(
$id
,
new
PharmacyDrugRepository
([
'drug'
,
'dosage'
,
'pharmacy'
]),
function
(
Show
$show
)
{
$show
->
field
(
'id'
)
->
width
(
4
);
$show
->
field
(
'pharmacy.name'
,
'药店'
)
->
width
(
4
);
...
...
@@ -97,7 +107,15 @@ protected function detail($id)
protected
function
form
()
{
return
Form
::
make
(
new
PharmacyDrugRepository
([
'drug'
,
'dosage'
,
'pharmacy'
]),
function
(
Form
$form
)
{
// 权限判断和数据过滤
if
(
!
Admin
::
user
()
->
pharmacy_id
)
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
}
if
(
$form
->
isEditing
()
&&
(
Admin
::
user
()
->
pharmacy_id
!=
$form
->
model
()
->
pharmacy_id
))
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
}
$form
->
display
(
'id'
)
->
width
(
4
);
$form
->
hidden
(
'pharmacy_id'
);
$form
->
text
(
'pharmacy.name'
,
'药店'
)
->
disable
()
->
width
(
4
);
$form
->
text
(
'drug.name'
,
'药品名称'
)
->
disable
()
->
width
(
4
);
$form
->
select
(
'unit'
)
->
options
(
DrugUnitModel
::
all
()
->
pluck
(
'name'
,
'id'
))
->
width
(
4
)
->
required
();
...
...
@@ -108,6 +126,11 @@ protected function form()
$form
->
display
(
'created_at'
)
->
width
(
4
);
$form
->
display
(
'updated_at'
)
->
width
(
4
);
$form
->
saving
(
function
(
Form
$form
)
{
// 不能动
$form
->
pharmacy_id
=
Admin
::
user
()
->
pharmacy_id
;
});
// 右上角按钮控制
$form
->
disableDeleteButton
();
// 去掉删除按钮
});
...
...
app/Admin/Extensions/ToolBar/Forms/AddPharmacyDrugForm.php
View file @
1fe5a024
...
...
@@ -5,7 +5,9 @@
use
App\Admin\Renderable\DrugTable
;
use
App\Models\DrugModel
;
use
App\Models\PharmacyDrugModel
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Contracts\LazyRenderable
;
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Traits\LazyWidget
;
use
Dcat\Admin\Widgets\Form
;
...
...
@@ -24,6 +26,9 @@ public function form()
public
function
handle
(
array
$input
)
{
if
(
!
Admin
::
user
()
->
isRole
(
'pharmacy'
)
||
!
Admin
::
user
()
->
pharmacy_id
)
{
admin_exit
(
Content
::
make
()
->
withError
(
trans
(
'admin.deny'
)));
}
$ids
=
$input
[
'ids'
];
if
(
!
$ids
)
{
...
...
@@ -33,9 +38,8 @@ public function handle(array $input)
// $drug = DrugModel::find($id);
$where
=
[
'drug_id'
=>
$id
];
$data
=
[
'pharmacy_id'
=>
$
id
,
'pharmacy_id'
=>
Admin
::
user
()
->
pharmacy_
id
,
'drug_id'
=>
$id
,
'dosage_id'
=>
0
,
];
PharmacyDrugModel
::
updateOrCreate
(
$where
,
$data
);
}
...
...
app/Admin/routes.php
View file @
1fe5a024
...
...
@@ -54,12 +54,16 @@
/** 平台菜单-end **/
/** 药店菜单-start **/
// 药品管理
$router
->
resource
(
'pharmacy-drug'
,
'PharmacyDrugController'
);
// 处方打印
$router
->
resource
(
'prescription-print'
,
'PrescriptionPrintController'
);
// 用法用量
$router
->
resource
(
'dosage'
,
'DosageController'
);
// 默认判断只有药店管理员角色才能访问
Route
::
group
([
'middleware'
=>
'admin.permission:allow,pharmacy'
,
],
function
(
$router
)
{
// 药品管理
$router
->
resource
(
'pharmacy-drug'
,
'PharmacyDrugController'
);
// 处方打印
$router
->
resource
(
'prescription-print'
,
'PrescriptionPrintController'
);
// 用法用量
$router
->
resource
(
'dosage'
,
'DosageController'
);
});
/** 药店菜单-end **/
});
database/migrations/2024_11_11_055836_create_pharmacy_drug_table.php
View file @
1fe5a024
...
...
@@ -17,7 +17,7 @@ public function up(): void
$table
->
bigInteger
(
'pharmacy_id'
)
->
comment
(
'药店ID'
);
$table
->
bigInteger
(
'drug_id'
)
->
comment
(
'药品池ID'
);
$table
->
integer
(
'unit'
)
->
nullable
()
->
comment
(
'单位'
);
$table
->
bigInteger
(
'dosage_id'
)
->
default
(
0
)
->
comment
(
'用法用量表ID'
);
$table
->
bigInteger
(
'dosage_id'
)
->
nullable
(
)
->
comment
(
'用法用量表ID'
);
$table
->
string
(
'batch_no'
,
64
)
->
nullable
()
->
comment
(
'批次号'
);
$table
->
unique
([
'pharmacy_id'
,
'drug_id'
],
'uk_pharmacyid_drugid'
);
$table
->
timestamps
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment