Commit 5d74b4df by lujunyi

打印

parent c697e93b
...@@ -51,7 +51,7 @@ public function search() ...@@ -51,7 +51,7 @@ public function search()
]); ]);
} }
try { // try {
$pharmacy_id = Admin::user()->pharmacy_id; $pharmacy_id = Admin::user()->pharmacy_id;
// 获取处方信息 // 获取处方信息
$prescription = PrescriptionModel::where('id', $prescriptionNo)->where('pharmacy_id', $pharmacy_id)->where('status', PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS)->first(); $prescription = PrescriptionModel::where('id', $prescriptionNo)->where('pharmacy_id', $pharmacy_id)->where('status', PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS)->first();
...@@ -158,6 +158,7 @@ public function search() ...@@ -158,6 +158,7 @@ public function search()
// 初始 Y 坐标 // 初始 Y 坐标
$medicines = $prescription->drug_info; $medicines = $prescription->drug_info;
$yCoordinate = 650; // 根据需要调整初始 Y 坐标 $yCoordinate = 650; // 根据需要调整初始 Y 坐标
if ($prescription->prescription_type == PrescriptionModel::PRESCRIPTION_TYPE_WM) {
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']}";
...@@ -194,6 +195,42 @@ public function search() ...@@ -194,6 +195,42 @@ public function search()
$font->color('#000000'); $font->color('#000000');
$font->align('center'); $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) { if ($prescription->doctor_signed_pic) {
...@@ -255,11 +292,11 @@ public function search() ...@@ -255,11 +292,11 @@ public function search()
'dosage_list' => $dosageList, 'dosage_list' => $dosageList,
], ],
]); ]);
} catch (\Exception $e) { // } catch (\Exception $e) {
return response()->json([ // return response()->json([
'status' => false, // 'status' => false,
'message' => '处方生成失败:'.$e->getMessage(), // 'message' => '处方生成失败:'.$e->getMessage(),
]); // ]);
} // }
} }
} }
...@@ -65,13 +65,7 @@ ...@@ -65,13 +65,7 @@
}; };
$('#is_eseal').on('change', () => this.search()); $('#is_eseal').on('change', () => this.search());
<<<<<<< HEAD
=======
>>>>>>> master
console.log('事件绑定完成'); console.log('事件绑定完成');
} }
search() { search() {
......
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