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
0743f6c9
authored
Nov 25, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打印处方
parent
f7b95d85
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
28 deletions
+74
-28
app/Admin/Controllers/PrescriptionPrintController.php
+36
-27
resources/views/admin/prescription-print.blade.php
+38
-1
No files found.
app/Admin/Controllers/PrescriptionPrintController.php
View file @
0743f6c9
...
...
@@ -3,7 +3,6 @@
namespace
App\Admin\Controllers
;
use
App\Models\PatientModel
;
use
App\Models\PharmacyDrugModel
;
use
App\Models\PrescriptionModel
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Http\Controllers\AdminController
;
...
...
@@ -40,6 +39,8 @@ public function search()
]);
}
$prescriptionNo
=
request
(
'prescription_no'
);
$dosageData
=
request
(
'dosage_custom'
);
// [{"pharmacy_drug_id":6,"dosage_desc":"一天3次1111"},{"pharmacy_drug_id":7,"dosage_desc":"2222每天一次"}]
$dosageData
=
json_decode
(
$dosageData
,
true
);
$isEseal
=
request
(
'is_eseal'
,
0
);
// 是否打印电子印章,实时生成
if
(
empty
(
$prescriptionNo
))
{
...
...
@@ -56,21 +57,23 @@ public function search()
return
response
()
->
json
([
'status'
=>
false
,
'message'
=>
'未找到该处方'
]);
}
// 检查处方图片是否已经生成
if
(
$isEseal
&&
$prescription
->
prescription_pic_eseal
)
{
return
response
()
->
json
([
'status'
=>
true
,
'data'
=>
[
'img_url'
=>
$prescription
->
prescription_pic_eseal
,
],
]);
}
elseif
(
$prescription
->
prescription_pic
)
{
return
response
()
->
json
([
'status'
=>
true
,
'data'
=>
[
'img_url'
=>
$prescription
->
prescription_pic
,
],
]);
}
// if ($isEseal && $prescription->prescription_pic_eseal) {
// return response()->json([
// 'status' => true,
// 'data' => [
// 'img_url' => $prescription->prescription_pic_eseal,
// 'drug_info' => $prescription->drug_info,
// ],
// ]);
// } elseif ($prescription->prescription_pic) {
// return response()->json([
// 'status' => true,
// 'data' => [
// 'img_url' => $prescription->prescription_pic,
// 'drug_info' => $prescription->drug_info,
// ],
// ]);
// }
// 创建处方图片
// 处方背景图宽1653,高2339
...
...
@@ -126,17 +129,22 @@ public function search()
});
$medicines
=
$prescription
->
drug_info
;
// 每个元素包含 'pharmacy_drug', 'num'
// $medicines = [];
// foreach ($drugInfo as $v) {
// $pharmacyDrug = PharmacyDrugModel::with(['drug', 'dosage'])->find($v['pharmacy_drug']);
// $medicines[] = [
// 'drug_name' => $v['drug_name'],
// 'spec' => $v['spec'],
// 'num' => $v['num'],
// 'dosage_desc' => $v['dosage_desc'],
// 'unit' => $v['unit'],
// ];
// }
// 根据传过来的用法用量进行修改替换
if
(
$dosageData
)
{
$dosageMap
=
[];
foreach
(
$dosageData
as
$dosage
)
{
$dosageMap
[
$dosage
[
'pharmacy_drug_id'
]]
=
$dosage
[
'dosage_desc'
];
}
// 更新 drug_info 中的 dosage_desc
foreach
(
$medicines
as
&
$medicine
)
{
if
(
isset
(
$dosageMap
[
$medicine
[
'pharmacy_drug_id'
]]))
{
$medicine
[
'dosage_desc'
]
=
$dosageMap
[
$medicine
[
'pharmacy_drug_id'
]];
}
}
// 重新保存处方信息
$prescription
->
drug_info
=
$medicines
;
// 更新药品信息
$prescription
->
save
();
// 保存更新后的处方
}
// 初始 Y 坐标
$yCoordinate
=
650
;
// 根据需要调整初始 Y 坐标
...
...
@@ -234,6 +242,7 @@ public function search()
'status'
=>
true
,
'data'
=>
[
'img_url'
=>
$imgUrl
,
'drug_info'
=>
$prescription
->
drug_info
,
],
]);
}
catch
(
\Exception
$e
)
{
...
...
resources/views/admin/prescription-print.blade.php
View file @
0743f6c9
...
...
@@ -79,7 +79,8 @@
data
:
{
prescription_no
:
prescriptionNo
,
is_eseal
:
isEseal
,
_token
:
'{{ csrf_token() }}'
_token
:
'{{ csrf_token() }}'
,
dosage_custom
:
this
.
getDosageData
()
},
success
:
(
response
)
=>
{
console
.
log
(
'请求成功:'
,
response
);
...
...
@@ -89,6 +90,8 @@
$
(
'#prescription-image'
).
attr
(
'src'
,
response
.
data
.
img_url
);
$
(
'#download-btn'
).
data
(
'url'
,
response
.
data
.
img_url
);
$
(
'#prescription-container'
).
show
();
this
.
showEditableForm
(
response
.
data
.
drug_info
);
}
else
{
Dcat
.
error
(
response
.
message
||
'获取处方失败'
);
}
...
...
@@ -124,6 +127,40 @@
window
.
open
(
printUrl
,
'_blank'
);
}
// 新增:展示可编辑的药品信息表单
showEditableForm
(
drugs
)
{
// 仅在 drugs 有值时生成表单
// 清空现有的药品信息表单
$
(
'#editable-drug-list'
).
remove
();
let
formHtml
=
'
<
div
id
=
"editable-drug-list"
class
=
"mt-3"
style
=
"max-width:30%"
>
'
;
drugs
.
forEach
(
drug
=>
{
formHtml
+=
`
<div class="drug-item input-group mb-2">
<input type="hidden" name="pharmacy_drug_id[]" value="
${
drug
.
pharmacy_drug_id
}
">
<label class="input-group-text">
${
drug
.
drug_name
}
||
${
drug
.
spec
}
||
${
drug
.
num
}${
drug
.
unit
}
</label>
<input type="text" class="form-control" name="dosage_desc[]" value="
${
drug
.
dosage_desc
}
" placeholder="请输入剂量">
</div>
`
;
});
formHtml
+=
'
<
/div>'
;
// 将表单添加到搜索表单下方
$
(
'.search-form'
).
after
(
formHtml
);
}
// 新增:获取剂量数据的方法
getDosageData
()
{
let
dosageData
=
[];
$
(
'#editable-drug-list .drug-item'
).
each
(
function
()
{
let
drugId
=
$
(
this
).
find
(
'input[name="pharmacy_drug_id[]"]'
).
val
();
let
dosageDesc
=
$
(
this
).
find
(
'input[name="dosage_desc[]"]'
).
val
();
dosageData
.
push
({
pharmacy_drug_id
:
parseInt
(
drugId
),
dosage_desc
:
dosageDesc
});
});
return
JSON
.
stringify
(
dosageData
);
}
}();
// 注意这里立即实例化类
});
</script>
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