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
5d74b4df
authored
Dec 04, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打印
parent
c697e93b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
13 deletions
+44
-13
app/Admin/Controllers/PrescriptionPrintController.php
+44
-7
resources/views/admin/prescription-print.blade.php
+0
-6
No files found.
app/Admin/Controllers/PrescriptionPrintController.php
View file @
5d74b4df
...
...
@@ -51,7 +51,7 @@ public function search()
]);
}
try
{
//
try {
$pharmacy_id
=
Admin
::
user
()
->
pharmacy_id
;
// 获取处方信息
$prescription
=
PrescriptionModel
::
where
(
'id'
,
$prescriptionNo
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
where
(
'status'
,
PrescriptionModel
::
PRESCRIPTION_STATUS_SUCCESS
)
->
first
();
...
...
@@ -158,6 +158,7 @@ public function search()
// 初始 Y 坐标
$medicines
=
$prescription
->
drug_info
;
$yCoordinate
=
650
;
// 根据需要调整初始 Y 坐标
if
(
$prescription
->
prescription_type
==
PrescriptionModel
::
PRESCRIPTION_TYPE_WM
)
{
foreach
(
$medicines
as
$medicine
)
{
// 打印药品名称、规格和盒数
$medicineText
=
"
{
$medicine
[
'drug_name'
]
}
{
$medicine
[
'spec'
]
}
{
$medicine
[
'num'
]
}{
$medicine
[
'unit'
]
}
"
;
...
...
@@ -194,6 +195,42 @@ public function search()
$font
->
color
(
'#000000'
);
$font
->
align
(
'center'
);
});
}
if
(
$prescription
->
prescription_type
==
PrescriptionModel
::
PRESCRIPTION_TYPE_TCM
)
{
$lineHeight
=
100
;
// 每3条数据换行后的行间距
$horizontalSpacing
=
350
;
// 每行中的每条记录之间的水平间距
$xStart
=
400
;
// 起始x坐标值
foreach
(
$medicines
as
$k
=>
$medicine
)
{
// 每行显示3个记录,并且如果不是第一行,增加下一行的Y坐标
if
(
$k
%
3
==
0
)
{
if
(
$k
!=
0
)
{
$yCoordinate
+=
$lineHeight
;
}
}
// 计算当前记录的x坐标,每增加一个记录,x坐标就往后移动一些位置
$xCoordinate
=
$xStart
+
(
$k
%
3
)
*
$horizontalSpacing
;
// 固定药品名称12字符,数量单位12个字符,
$medicineText
=
sprintf
(
'%-12s %-12s'
,
$medicine
[
'drug_name'
],
"
{
$medicine
[
'num'
]
}{
$medicine
[
'unit'
]
}
"
);
$img
->
text
(
$medicineText
,
$xCoordinate
,
$yCoordinate
,
function
(
$font
)
{
$font
->
filename
(
public_path
(
'static/fonts/SimHei.ttf'
));
$font
->
size
(
40
);
$font
->
color
(
'#000000'
);
$font
->
align
(
'left'
);
});
}
$yCoordinate
+=
200
;
// 空白行间距
// 打印“以下空白”文字
$img
->
text
(
$prescription
->
doses
.
'剂'
,
$centerX
,
$yCoordinate
,
function
(
$font
)
{
$font
->
filename
(
public_path
(
'static/fonts/SimHei.ttf'
));
$font
->
size
(
64
);
$font
->
color
(
'#000000'
);
$font
->
align
(
'center'
);
});
}
// 医师签名图片
if
(
$prescription
->
doctor_signed_pic
)
{
...
...
@@ -255,11 +292,11 @@ public function search()
'dosage_list'
=>
$dosageList
,
],
]);
}
catch
(
\Exception
$e
)
{
return
response
()
->
json
([
'status'
=>
false
,
'message'
=>
'处方生成失败:'
.
$e
->
getMessage
(),
]);
}
//
} catch (\Exception $e) {
//
return response()->json([
//
'status' => false,
//
'message' => '处方生成失败:'.$e->getMessage(),
//
]);
//
}
}
}
resources/views/admin/prescription-print.blade.php
View file @
5d74b4df
...
...
@@ -65,13 +65,7 @@
};
$
(
'#is_eseal'
).
on
(
'change'
,
()
=>
this
.
search
());
<<<<<<<
HEAD
=======
>>>>>>>
master
console
.
log
(
'事件绑定完成'
);
}
search
()
{
...
...
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