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
8eeac34b
authored
Nov 30, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导入药店复制药品用量
parent
f883b50a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
app/Admin/Extensions/ToolBar/Forms/PharmacyImportForm.php
+20
-0
No files found.
app/Admin/Extensions/ToolBar/Forms/PharmacyImportForm.php
View file @
8eeac34b
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
namespace
App\Admin\Extensions\ToolBar\Forms
;
namespace
App\Admin\Extensions\ToolBar\Forms
;
use
App\Models\DosageModel
;
use
App\Models\PharmacyDrugModel
;
use
App\Models\PharmacyModel
;
use
App\Models\PharmacyModel
;
use
Dcat\Admin\Http\JsonResponse
;
use
Dcat\Admin\Http\JsonResponse
;
use
Dcat\Admin\Widgets\Form
;
use
Dcat\Admin\Widgets\Form
;
...
@@ -36,10 +38,12 @@ public function handle(array $input): JsonResponse
...
@@ -36,10 +38,12 @@ public function handle(array $input): JsonResponse
return
is_string
(
$value
)
?
trim
(
$value
)
:
$value
;
return
is_string
(
$value
)
?
trim
(
$value
)
:
$value
;
},
$row
);
},
$row
);
$pharmacyModel
=
null
;
$pharmacyModel
=
null
;
$flagNew
=
false
;
if
(
isset
(
$item
[
'药店管理员手机号'
])
&&
$item
[
'药店管理员手机号'
])
{
if
(
isset
(
$item
[
'药店管理员手机号'
])
&&
$item
[
'药店管理员手机号'
])
{
$pharmacyModel
=
PharmacyModel
::
where
(
'mobile'
,
$item
[
'药店管理员手机号'
])
->
first
();
$pharmacyModel
=
PharmacyModel
::
where
(
'mobile'
,
$item
[
'药店管理员手机号'
])
->
first
();
}
}
if
(
!
$pharmacyModel
)
{
if
(
!
$pharmacyModel
)
{
$flagNew
=
true
;
$pharmacyModel
=
new
PharmacyModel
;
$pharmacyModel
=
new
PharmacyModel
;
}
}
$pharmacyModel
->
name
=
$item
[
'药店名称'
]
??
0
;
$pharmacyModel
->
name
=
$item
[
'药店名称'
]
??
0
;
...
@@ -51,6 +55,22 @@ public function handle(array $input): JsonResponse
...
@@ -51,6 +55,22 @@ public function handle(array $input): JsonResponse
if
(
$pharmacyModel
->
save
())
{
if
(
$pharmacyModel
->
save
())
{
$successNum
++
;
$successNum
++
;
}
}
if
(
$flagNew
)
{
// 复制药品
$originalPharmacyModels
=
PharmacyDrugModel
::
where
(
'pharmacy_id'
,
1
)
->
get
();
foreach
(
$originalPharmacyModels
as
$originalPharmacyModel
)
{
$pharmacyNewModel
=
$originalPharmacyModel
->
replicate
();
$pharmacyNewModel
->
pharmacy_id
=
$pharmacyModel
->
id
;
$pharmacyNewModel
->
save
();
}
// 复制用法用量
$originalDosageModels
=
DosageModel
::
where
(
'pharmacy_id'
,
1
)
->
get
();
foreach
(
$originalDosageModels
as
$dosageModel
)
{
$dosageNewModel
=
$dosageModel
->
replicate
();
$dosageNewModel
->
pharmacy_id
=
$pharmacyModel
->
id
;
$dosageNewModel
->
save
();
}
}
}
}
});
});
$return
=
$this
->
response
()
->
success
(
"导入成功
{
$successNum
}
条"
)
->
refresh
();
$return
=
$this
->
response
()
->
success
(
"导入成功
{
$successNum
}
条"
)
->
refresh
();
...
...
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