Commit 6e0776be by lujunyi

打印

parent 48841c6e
...@@ -60,14 +60,14 @@ public function search() ...@@ -60,14 +60,14 @@ public function search()
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'data' => [ 'data' => [
'img_url' => Storage::url($prescription->prescription_pic_eseal), 'img_url' => $prescription->prescription_pic_eseal,
], ],
]); ]);
} elseif ($prescription->prescription_pic) { } elseif ($prescription->prescription_pic) {
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'data' => [ 'data' => [
'img_url' => Storage::url($prescription->prescription_pic), 'img_url' => $prescription->prescription_pic,
], ],
]); ]);
} }
...@@ -144,7 +144,7 @@ public function search() ...@@ -144,7 +144,7 @@ public function search()
foreach ($medicines as $medicine) { foreach ($medicines as $medicine) {
// 打印药品名称、规格和盒数 // 打印药品名称、规格和盒数
$medicineText = "{$medicine['drug_name']} {$medicine['spec']} {$medicine['num']}{$medicine['unit']}"; $medicineText = "{$medicine['drug_name']} {$medicine['spec']} {$medicine['num']}{$medicine['unit']}";
$img->text($medicineText, 550, $yCoordinate, function ($font) { $img->text($medicineText, 450, $yCoordinate, function ($font) {
$font->filename(public_path('static/fonts/SimHei.ttf')); $font->filename(public_path('static/fonts/SimHei.ttf'));
$font->size(32); $font->size(32);
$font->color('#000000'); $font->color('#000000');
...@@ -155,11 +155,11 @@ public function search() ...@@ -155,11 +155,11 @@ public function search()
$yCoordinate += 40; // 根据字体大小调整行间距 $yCoordinate += 40; // 根据字体大小调整行间距
// 打印 sig 信息 // 打印 sig 信息
$img->text('Sig: '.$medicine['dosage_desc'], 550, $yCoordinate, function ($font) { $img->text('Sig: '.$medicine['dosage_desc'], 450, $yCoordinate, function ($font) {
$font->filename(public_path('static/fonts/SimHei.ttf')); $font->filename(public_path('static/fonts/SimHei.ttf'));
$font->size(32); $font->size(32);
$font->color('#000000'); $font->color('#000000');
$font->align('center'); $font->align('left');
}); });
// 增加 Y 坐标以准备打印下一个药品 // 增加 Y 坐标以准备打印下一个药品
...@@ -180,16 +180,16 @@ public function search() ...@@ -180,16 +180,16 @@ public function search()
// 医师签名图片 // 医师签名图片
if ($prescription->doctor_signed_pic) { if ($prescription->doctor_signed_pic) {
$pharmacistSignPath = Storage::url($prescription->doctor_signed_pic); $pharmacistSignPath = file_get_contents($prescription->doctor_signed_pic);
$doctorSign = Image::read(file_get_contents($pharmacistSignPath)); $doctorSign = Image::read($pharmacistSignPath);
$doctorSign->rotate(90); $doctorSign->rotate(90);
$doctorSign->resize(150, 100); $doctorSign->resize(150, 100);
$img->place($doctorSign, 'bottom-left', 400, 410); $img->place($doctorSign, 'bottom-left', 400, 410);
} }
// 药师签名图片 // 药师签名图片
if ($prescription->pharmacist_signed_pic) { if ($prescription->pharmacist_signed_pic) {
$pharmacistSignPath = Storage::url($prescription->pharmacist_signed_pic); $pharmacistSignPath = file_get_contents($prescription->pharmacist_signed_pic);
$pharmacistSign = Image::read(file_get_contents($pharmacistSignPath)); $pharmacistSign = Image::read($pharmacistSignPath);
$pharmacistSign->rotate(90); $pharmacistSign->rotate(90);
$pharmacistSign->resize(150, 100); $pharmacistSign->resize(150, 100);
$img->place($pharmacistSign, 'bottom-left', 870, 410); $img->place($pharmacistSign, 'bottom-left', 870, 410);
...@@ -204,7 +204,7 @@ public function search() ...@@ -204,7 +204,7 @@ public function search()
// 电子印章版处方图片生成 // 电子印章版处方图片生成
$eseal = Image::read(public_path('static/images/dianzizhang.png')); $eseal = Image::read(public_path('static/images/dianzizhang.png'));
// $eseal->rotate(90); // $eseal->rotate(90);
$eseal->resize(150, 150); // $eseal->resize(500, 500);
$img->place($eseal, 'bottom-right', 180, 500); $img->place($eseal, 'bottom-right', 180, 500);
$picEsealName = $prescriptionNo.'-eseal.jpg'; $picEsealName = $prescriptionNo.'-eseal.jpg';
$tempEsealPath = storage_path('app/public').$picEsealName; $tempEsealPath = storage_path('app/public').$picEsealName;
......
...@@ -72,4 +72,13 @@ public function getPrescriptionPicAttribute($value) ...@@ -72,4 +72,13 @@ public function getPrescriptionPicAttribute($value)
return Storage::url($value); return Storage::url($value);
} }
public function getPrescriptionPicEsealAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
return $value;
}
return Storage::url($value);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment