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
263aa722
authored
Nov 21, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
药品导入
parent
50432b60
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
app/Admin/Extensions/ToolBar/Forms/DrugImportForm.php
+9
-2
app/Models/DrugModel.php
+1
-1
database/migrations/2024_11_21_173217_add_somefield_to_drug_table.php
+1
-1
No files found.
app/Admin/Extensions/ToolBar/Forms/DrugImportForm.php
View file @
263aa722
...
...
@@ -9,6 +9,10 @@
use
Dcat\EasyExcel\Support\SheetCollection
;
use
Exception
;
set_time_limit
(
600
);
ini_set
(
'memory_limit'
,
'-1'
);
ini_set
(
'max_execution_time'
,
600
);
ini_set
(
'max_input_time'
,
600
);
class
DrugImportForm
extends
Form
{
/**
...
...
@@ -32,6 +36,9 @@ public function handle(array $input): JsonResponse
return
is_string
(
$value
)
?
trim
(
$value
)
:
$value
;
},
$row
);
$drugModel
=
DrugModel
::
where
(
'product_id'
,
$item
[
'君元ID'
])
->
first
();
if
(
!
$drugModel
)
{
$drugModel
=
new
DrugModel
;
}
$drugModel
->
product_id
=
$item
[
'君元ID'
]
??
0
;
$drugModel
->
name
=
$item
[
'通用名'
];
$drugModel
->
product_name
=
$item
[
'商品名'
];
...
...
@@ -45,7 +52,6 @@ public function handle(array $input): JsonResponse
$drugModel
->
standard_code
=
$item
[
'本位码'
];
$drugModel
->
category_code
=
$item
[
'分类码'
];
$drugModel
->
category_name
=
$item
[
'分类名称'
];
$drugModel
->
code
=
''
;
$drugModel
->
is_foreign
=
self
::
toBool
(
$item
[
'是否进口药'
]);
$drugModel
->
is_rx
=
self
::
toBool
(
$item
[
'是否处方药'
]);
$drugModel
->
is_si
=
self
::
toBool
(
$item
[
'是否医保药'
]);
...
...
@@ -71,12 +77,13 @@ public function form()
$this
->
file
(
'import_file'
,
'文件'
)
->
disk
(
'local'
)
->
accept
(
'xls,xlsx,csv'
)
->
maxSize
(
1024
*
30
)
->
autoUpload
()
->
uniqueName
()
->
required
()
->
help
(
"导入要求:<br />
<span style='color:red;'>
1、支持xls、xlsx、csv三种格式
\n
1、支持xls、xlsx、csv三种格式
<br \>
2、更新的时候根据本位码唯一更新药品信息
</span>"
);
$downloadUrl
=
admin_url
(
'drug-template'
);
...
...
app/Models/DrugModel.php
View file @
263aa722
...
...
@@ -50,9 +50,9 @@ class DrugModel extends Model
public
function
setNameAttribute
(
$value
)
{
$this
->
attributes
[
'name'
]
=
$value
;
$pinyin
=
new
Pinyin
();
$abbr
=
$pinyin
->
abbr
(
$value
)
->
join
(
''
);
// 获取拼音首字母
// echo $abbr;exit;
$this
->
attributes
[
'code'
]
=
strtoupper
(
$abbr
);
}
...
...
database/migrations/2024_11_21_173217_add_somefield_to_drug_table.php
View file @
263aa722
...
...
@@ -12,7 +12,7 @@
public
function
up
()
:
void
{
Schema
::
table
(
'drug'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'preparation_pec'
,
128
)
->
default
(
''
)
->
comment
(
'制剂规格'
);
$table
->
string
(
'preparation_pec'
)
->
default
(
''
)
->
comment
(
'制剂规格'
);
$table
->
string
(
'product_name'
,
64
)
->
default
(
''
)
->
comment
(
'商品名'
);
$table
->
string
(
'mnemonic'
,
64
)
->
default
(
''
)
->
comment
(
'助记码'
);
$table
->
string
(
'category_code'
,
32
)
->
default
(
''
)
->
comment
(
'分类码'
);
...
...
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