Commit 6115e4e0 by lujunyi

打印

parent 3e8336c8
......@@ -187,17 +187,23 @@ public function search()
$img->save($tempPath);
// 上传到腾讯云
// \Storage::disk('cos')->putFileAs('prescriptions', $tempPath, $prescriptionNo.'.jpg');
Storage::putFileAs('prescriptions', $tempPath, $prescriptionNo.'.jpg');
// 删除临时文件
// unlink($tempPath);
// return response()->json([
// 'status' => true,
// 'data' => [
// 'img_url' => \Storage::disk('cos')->url($cosPath),
// ],
// ]);
unlink($tempPath);
$cosPath = 'prescriptions/'.$prescriptionNo.'.jpg';
// 将生成的图片路径存储到数据库
$prescription->prescription_pic = $cosPath;
$prescription->save();
return response()->json([
'status' => true,
'data' => [
'img_url' => Storage::url($cosPath),
],
]);
} catch (\Exception $e) {
return response()->json([
'status' => false,
......
<?php
/*
* // +----------------------------------------------------------------------
* // | erp
* // +----------------------------------------------------------------------
* // | Copyright (c) 2006~2020 erp All rights reserved.
* // +----------------------------------------------------------------------
* // | Licensed ( LICENSE-1.0.0 )
* // +----------------------------------------------------------------------
* // | Author: yxx <1365831278@qq.com>
* // +----------------------------------------------------------------------
*/
namespace App\Admin\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class PrintController extends Controller
{
public function print(Request $request)
{
$url = $request->input('url');
$pageData = [
'pic' => $url,
];
return view('admin.print', $pageData);
}
}
......@@ -64,8 +64,10 @@
$router->resource('prescription-print', 'PrescriptionPrintController');
// 用法用量
$router->resource('dosage', 'DosageController');
// 搜索打印处方单
$router->get('prescription-search', 'PrescriptionPrintController@search');
// 搜索生成处方单
$router->post('prescription-search', 'PrescriptionPrintController@search');
// 打印处方单
$router->get('/print', 'PrintController@print');
});
$router->get('/auth/smscode', 'AuthController@getLoginSmsCode');
/** 药店菜单-end **/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
// -----------------------------------------------------------------------
// Eros Fratini - eros@recoding.it
// jqprint 0.3
//
// - 19/06/2009 - some new implementations, added Opera support
// - 11/05/2009 - first sketch
//
// Printing plug-in for jQuery, evolution of jPrintArea: http://plugins.jquery.com/project/jPrintArea
// requires jQuery 1.3.x
//
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
//------------------------------------------------------------------------
(function($) {
var opt;
$.fn.jqprint = function (options) {
opt = $.extend({}, $.fn.jqprint.defaults, options);
var $element = (this instanceof jQuery) ? this : $(this);
if (opt.operaSupport && $.browser.opera)
{
var tab = window.open("","jqPrint-preview");
tab.document.open();
var doc = tab.document;
}
else
{
var $iframe = $("<iframe />");
if (!opt.debug) { $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-600px", top: "-600px" }); }
$iframe.appendTo("body");
var doc = $iframe[0].contentWindow.document;
}
if (opt.importCSS)
{
if ($("link[media=print]").length > 0)
{
$("link[media=print]").each( function() {
doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' media='print' />");
});
}
else
{
$("link").each( function() {
doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' />");
});
}
}
if (opt.printContainer) { doc.write($element.outer()); }
else { $element.each( function() { doc.write($(this).html()); }); }
doc.close();
(opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).focus();
setTimeout( function() { (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).print(); if (tab) { tab.close(); } }, 1000);
}
$.fn.jqprint.defaults = {
debug: false,
importCSS: true,
printContainer: true,
operaSupport: true
};
// Thanks to 9__, found at http://users.livejournal.com/9__/380664.html
jQuery.fn.outer = function() {
return $($('<div></div>').html(this.clone())).html();
}
})(jQuery);
......@@ -11,7 +11,7 @@
<div class="prescription-preview" id="prescription-container" style="display:none">
<div class="text-center">
<img id="prescription-image" class="img-fluid" style="max-width:100%">
<img id="prescription-image" class="img-fluid" style="max-width:30%">
<div class="mt-3">
<button class="btn btn-success" id="download-btn">
<i class="fa fa-download"></i> 下载处方
......@@ -107,14 +107,14 @@
// 打印处方
print() {
let prescriptionNo = $('#prescription_no').val();
if (!prescriptionNo) {
let url = $('#download-btn').data('url');
if (!url) {
Dcat.error('请先搜索处方');
return;
}
// 打开新的打印页面
let printUrl = '{{ admin_url('prescription-print/view') }}' + '?prescription_no=' + encodeURIComponent(prescriptionNo);
let printUrl = '{{ admin_url('print') }}' + '?url=' + url;
window.open(printUrl, '_blank');
}
......
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>打印处方</title>
<link rel="stylesheet" href="{{asset('static/css/bootstrap.css')}}" crossorigin="anonymous">
<style>
.image-container {
text-align: center;
margin-top: 50px;
}
.image-container img {
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<div class="image-container">
<img src="{{$pic}}" alt="处方图片"/>
</div>
<script language="javascript" src="{{asset('static/js/jquery.js')}}"></script>
<script language="javascript" src="{{asset('static/js/jquery.print.js')}}"></script>
<script>
// 如果需要打印功能,可以在这里添加
$(".image-container").jqprint();
</script>
</body>
</html>
\ No newline at end of file
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