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
2b128d86
authored
Nov 21, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增药品字段
parent
7a37a5c6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
63 deletions
+111
-63
app/Admin/Controllers/DrugController.php
+51
-55
app/Models/DrugModel.php
+13
-2
database/migrations/2024_11_04_000511_create_drug_table.php
+1
-1
database/migrations/2024_11_21_173217_add_somefield_to_drug_table.php
+33
-0
lang/zh_CN/drug.php
+13
-5
No files found.
app/Admin/Controllers/DrugController.php
View file @
2b128d86
...
...
@@ -33,20 +33,28 @@ protected function grid()
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'name'
);
$grid
->
column
(
'code'
);
$grid
->
column
(
'unit'
);
$grid
->
column
(
'is_rx'
,
'处方药'
)
->
using
(
DrugModel
::
RX_MAP
);
$grid
->
column
(
'is_si'
,
'医保'
)
->
using
(
DrugModel
::
SI_MAP
);
$grid
->
column
(
'product_name'
);
$grid
->
column
(
'spec'
);
$grid
->
column
(
'preparation_pec'
);
$grid
->
column
(
'dosage_form'
);
$grid
->
column
(
'unit'
);
$grid
->
column
(
'factory'
);
$grid
->
column
(
'approval_no'
);
$grid
->
column
(
'mnemonic'
);
$grid
->
column
(
'standard_code'
);
$grid
->
column
(
'category_code'
);
$grid
->
column
(
'category_name'
);
$grid
->
column
(
'is_foreign'
)
->
using
(
DrugModel
::
FOREIGN_MAP
);
$grid
->
column
(
'is_rx'
)
->
using
(
DrugModel
::
RX_MAP
);
$grid
->
column
(
'is_si'
)
->
using
(
DrugModel
::
SI_MAP
);
$grid
->
column
(
'limit_buy_7'
);
$grid
->
column
(
'tag'
)
->
display
(
function
(
$tags
)
{
return
collect
(
$tags
)
->
map
(
function
(
$tag
)
{
return
"<span class='label' style='background:#6d8be6'>
{
$tag
->
tag_name
}
</span>"
;
})
->
implode
(
' '
);
});
$grid
->
column
(
'standard_code'
);
$grid
->
column
(
'product_id'
);
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
...
...
@@ -87,29 +95,7 @@ protected function grid()
* @param mixed $id
* @return Show
*/
protected
function
detail
(
$id
)
{
return
Show
::
make
(
$id
,
new
DrugRepository
(),
function
(
Show
$show
)
{
$show
->
field
(
'id'
)
->
width
(
4
);
$show
->
field
(
'name'
)
->
width
(
4
);
$show
->
field
(
'code'
)
->
width
(
4
);
$show
->
field
(
'unit'
)
->
width
(
4
);
$show
->
field
(
'spec'
)
->
width
(
4
);
$show
->
field
(
'dosage_form'
)
->
width
(
4
);
$show
->
field
(
'factory'
)
->
width
(
4
);
$show
->
field
(
'approval_no'
)
->
width
(
4
);
$show
->
field
(
'limit_buy_7'
)
->
width
(
4
);
$show
->
field
(
'is_rx'
)
->
using
(
DrugModel
::
RX_MAP
)
->
width
(
4
);
$show
->
field
(
'tag'
)
->
width
(
4
);
$show
->
field
(
'standard_code'
)
->
width
(
4
);
$show
->
field
(
'created_at'
)
->
width
(
4
);
$show
->
field
(
'updated_at'
)
->
width
(
4
);
$show
->
panel
()
->
tools
(
function
(
$tools
)
{
$tools
->
disableDelete
();
// 禁止删除按钮
});
});
}
protected
function
detail
(
$id
)
{}
/**
* Make a form builder.
...
...
@@ -119,35 +105,45 @@ protected function detail($id)
protected
function
form
()
{
return
Form
::
make
(
new
DrugRepository
(
'tag'
),
function
(
Form
$form
)
{
$form
->
display
(
'id'
)
->
width
(
4
);
$form
->
text
(
'name'
)
->
width
(
4
)
->
required
()
->
maxLength
(
64
,
'最多输入64个字符'
);
$form
->
display
(
'code'
)
->
width
(
4
);
$form
->
select
(
'unit'
)
->
options
(
DrugUnitModel
::
all
()
->
pluck
(
'name'
,
'name'
))
->
width
(
4
);
$form
->
text
(
'spec'
)
->
width
(
4
)
->
required
()
->
maxLength
(
128
,
'最多输入128个字符'
);
$form
->
text
(
'dosage_form'
)
->
width
(
4
)
->
required
()
->
maxLength
(
128
,
'最多输入128个字符'
);
$form
->
text
(
'factory'
)
->
width
(
4
)
->
required
()
->
maxLength
(
128
,
'最多输入128个字符'
);
$form
->
text
(
'approval_no'
)
->
width
(
4
)
->
required
()
->
maxLength
(
64
,
'最多输入64个字符'
);
$array
=
range
(
1
,
10
);
$limitOption
=
array_combine
(
$array
,
$array
);
$form
->
select
(
'limit_buy_7'
)
->
placeholder
(
'请选择限购数量'
)
->
width
(
4
)
->
options
(
$limitOption
)
->
help
(
'限购数量'
)
->
required
();
$form
->
switch
(
'is_rx'
)
->
width
(
4
);
$form
->
text
(
'standard_code'
)
->
width
(
4
)
->
required
()
->
rules
(
function
(
Form
$form
)
{
// 如果不是编辑状态,则添加字段唯一验证
if
(
!
$id
=
$form
->
model
()
->
id
)
{
return
'unique:App\Models\DrugModel,standard_code'
;
}
$form
->
column
(
6
,
function
(
Form
$form
)
{
$form
->
display
(
'id'
);
$form
->
display
(
'code'
);
$form
->
text
(
'name'
)
->
required
()
->
maxLength
(
64
);
$form
->
text
(
'product_name'
)
->
maxLength
(
64
);
$form
->
text
(
'spec'
)
->
required
()
->
maxLength
(
128
);
$form
->
text
(
'preparation_pec'
)
->
maxLength
(
128
);
$form
->
text
(
'dosage_form'
)
->
required
()
->
maxLength
(
128
);
$form
->
select
(
'unit'
)
->
options
(
DrugUnitModel
::
all
()
->
pluck
(
'name'
,
'name'
));
$form
->
text
(
'factory'
)
->
required
()
->
maxLength
(
128
);
$form
->
text
(
'approval_no'
)
->
required
()
->
maxLength
(
64
);
$form
->
text
(
'mnemonic'
)
->
maxLength
(
64
);
});
$form
->
column
(
6
,
function
(
Form
$form
)
{
$form
->
text
(
'standard_code'
)
->
required
()
->
rules
(
function
(
Form
$form
)
{
// 如果不是编辑状态,则添加字段唯一验证
if
(
!
$id
=
$form
->
model
()
->
id
)
{
return
'unique:App\Models\DrugModel,standard_code'
;
}
});
$form
->
text
(
'category_code'
)
->
maxLength
(
32
);
$form
->
text
(
'category_name'
)
->
maxLength
(
32
);
$form
->
switch
(
'is_foreign'
);
$form
->
switch
(
'is_rx'
);
$form
->
switch
(
'is_si'
);
$array
=
range
(
1
,
10
);
$limitOption
=
array_combine
(
$array
,
$array
);
$form
->
select
(
'limit_buy_7'
)
->
placeholder
(
'请选择限购数量'
)
->
options
(
$limitOption
)
->
help
(
'限购数量'
)
->
required
();
$form
->
multipleSelect
(
'tag'
,
'标签'
)
->
options
(
function
()
{
return
DrugTagModel
::
all
()
->
pluck
(
'tag_name'
,
'id'
);
})
->
customFormat
(
function
(
$v
)
{
return
array_column
(
$v
,
'id'
);
});
$form
->
display
(
'created_at'
);
$form
->
display
(
'updated_at'
);
});
$form
->
multipleSelect
(
'tag'
,
'标签'
)
->
options
(
function
()
{
return
DrugTagModel
::
all
()
->
pluck
(
'tag_name'
,
'id'
);
})
->
customFormat
(
function
(
$v
)
{
return
array_column
(
$v
,
'id'
);
})
->
width
(
4
);
$form
->
display
(
'created_at'
)
->
width
(
4
);
$form
->
display
(
'updated_at'
)
->
width
(
4
);
// 右上角按钮控制
$form
->
disableDeleteButton
();
// 去掉删除按钮
$form
->
disableViewButton
();
// 去掉跳转详情页按钮
...
...
app/Models/DrugModel.php
View file @
2b128d86
...
...
@@ -14,7 +14,7 @@ class DrugModel extends Model
protected
$table
=
'drug'
;
// 是否处方药[0=
不是
,1=是]
// 是否处方药[0=
否
,1=是]
const
RX_TRUE
=
0
;
const
RX_FALSE
=
1
;
...
...
@@ -25,7 +25,7 @@ class DrugModel extends Model
self
::
RX_FALSE
=>
'否'
,
];
// 是否医保药品[0=
不是
,1=是]
// 是否医保药品[0=
否
,1=是]
const
SI_TRUE
=
0
;
const
SI_FALSE
=
1
;
...
...
@@ -36,6 +36,17 @@ class DrugModel extends Model
self
::
RX_FALSE
=>
'否'
,
];
// 是否进口药[0=否,1=是]
const
FOREIGN_TRUE
=
0
;
const
FOREIGN_FALSE
=
1
;
// 是否进口药-文字映射
const
FOREIGN_MAP
=
[
self
::
FOREIGN_TRUE
=>
'是'
,
self
::
FOREIGN_FALSE
=>
'否'
,
];
public
function
setNameAttribute
(
$value
)
{
$this
->
attributes
[
'name'
]
=
$value
;
...
...
database/migrations/2024_11_04_000511_create_drug_table.php
View file @
2b128d86
...
...
@@ -19,7 +19,7 @@ public function up(): void
$table
->
string
(
'code'
,
64
)
->
index
(
'idx_code'
)
->
comment
(
'简码'
);
$table
->
string
(
'standard_code'
,
64
)
->
unique
(
'uk_standardcode'
)
->
comment
(
'本位码'
);
$table
->
string
(
'unit'
,
20
)
->
nullable
()
->
comment
(
'单位'
);
$table
->
string
(
'spec'
,
128
)
->
comment
(
'规格'
);
$table
->
string
(
'spec'
,
128
)
->
comment
(
'
包装
规格'
);
$table
->
string
(
'dosage_form'
,
128
)
->
comment
(
'剂型'
);
$table
->
string
(
'factory'
,
128
)
->
index
(
'idx_factory'
)
->
comment
(
'生产厂家'
);
$table
->
string
(
'approval_no'
,
64
)
->
comment
(
'批准文号'
);
...
...
database/migrations/2024_11_21_173217_add_somefield_to_drug_table.php
0 → 100644
View file @
2b128d86
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*/
public
function
up
()
:
void
{
Schema
::
table
(
'drug'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'preparation_pec'
,
128
)
->
default
(
''
)
->
comment
(
'制剂规格'
);
$table
->
string
(
'product_name'
,
64
)
->
default
(
''
)
->
comment
(
'商品名'
);
$table
->
string
(
'mnemonic'
,
64
)
->
default
(
''
)
->
comment
(
'助记码'
);
$table
->
string
(
'category_code'
,
32
)
->
default
(
''
)
->
comment
(
'分类码'
);
$table
->
string
(
'category_name'
,
32
)
->
default
(
''
)
->
comment
(
'分类名称'
);
$table
->
boolean
(
'is_foreign'
)
->
default
(
false
)
->
comment
(
'是否进口药'
);
});
}
/**
* Reverse the migrations.
*/
public
function
down
()
:
void
{
Schema
::
table
(
'drug'
,
function
(
Blueprint
$table
)
{
//
});
}
};
lang/zh_CN/drug.php
View file @
2b128d86
...
...
@@ -5,17 +5,25 @@
'drug'
=>
'药品'
,
],
'fields'
=>
[
'name'
=>
'药品名称'
,
'product_id'
=>
'君元商品ID'
,
'name'
=>
'通用名'
,
'product_name'
=>
'商品名'
,
'code'
=>
'简码'
,
'
unit'
=>
'单位
'
,
'
spec'
=>
'
规格'
,
'
spec'
=>
'包装规格
'
,
'
preparation_pec'
=>
'制剂
规格'
,
'dosage_form'
=>
'剂型'
,
'unit'
=>
'单位'
,
'factory'
=>
'生产厂家'
,
'approval_no'
=>
'批准文号'
,
'limit_buy_7'
=>
'7天限购'
,
'mnemonic'
=>
'助记码'
,
'standard_code'
=>
'本位码'
,
'category_code'
=>
'分类码'
,
'category_name'
=>
'分类名称'
,
'is_foreign'
=>
'是否进口药'
,
'is_rx'
=>
'是否处方药'
,
'is_si'
=>
'是否医保药'
,
'limit_buy_7'
=>
'7天限购'
,
'tag'
=>
'标签'
,
'standard_code'
=>
'本位码'
,
],
'options'
=>
[
],
...
...
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