Compare commits

...

2 Commits

Author SHA1 Message Date
vine_liutk 47f610eefc 固定打印4行信息 2023-06-16 12:13:39 +08:00
vine_liutk 1954065299 调整打印预览 2023-06-16 11:53:20 +08:00
2 changed files with 35 additions and 13 deletions

View File

@ -15,6 +15,7 @@ class PrintController extends Controller
$sn = ''; $sn = '';
//默认list最少N行最多N行 //默认list最少N行最多N行
$list = []; $list = [];
$total = 0;
$bigTotal = ''; $bigTotal = '';
$adminName = ''; $adminName = '';
$timeZone = ''; $timeZone = '';
@ -27,11 +28,27 @@ class PrintController extends Controller
$time = $flow->created_at->format('Y-m-d H:i:s'); $time = $flow->created_at->format('Y-m-d H:i:s');
$sn = $flow->sn; $sn = $flow->sn;
$ukeys = explode(',', $request->input('ukeys', '')); $ukeys = explode(',', $request->input('ukeys', ''));
$i = 0;
foreach($rows as $item){ foreach($rows as $item){
if(in_array($item['ukey'], $ukeys)){
$list[] = $item; if($i<4){
if(in_array($item['ukey'], $ukeys)){
$i++;
$list[] = $item;
}
}else{
break;
} }
} }
for($i; $i<4; $i++){
$list[] = [
'ukey' => '',
'name' => '',
'fee_name' => '',
'fee_value' => 0,
];
}
if(count($list) > 0){ if(count($list) > 0){
$total = collect($list)->sum('fee_value'); $total = collect($list)->sum('fee_value');
if($total > 0){ if($total > 0){
@ -44,7 +61,7 @@ class PrintController extends Controller
$timeZone = substr($flow->start_at, 0, 10).'至'.substr($flow->end_at, 0, 10); $timeZone = substr($flow->start_at, 0, 10).'至'.substr($flow->end_at, 0, 10);
} }
return view('print-const', compact('name', 'time', 'sn', 'list', 'bigTotal', 'timeZone', 'adminName')); return view('print-const', compact('name', 'time', 'sn', 'list', 'total', 'bigTotal', 'timeZone', 'adminName'));
} }

View File

@ -9,7 +9,7 @@
margin: 0; margin: 0;
} }
body { body {
margin: 1.6cm; margin: 0.8cm;
} }
} }
body { body {
@ -18,7 +18,6 @@
.container { .container {
/* width: 800px; */ /* width: 800px; */
text-align: center; text-align: center;
height: 800px;
} }
.tag { .tag {
overflow: hidden; /* 清除浮动 */ overflow: hidden; /* 清除浮动 */
@ -43,8 +42,8 @@
margin: 0 auto; margin: 0 auto;
table-layout: fixed; table-layout: fixed;
} }
td,th{ td, th{
line-height: 35px; line-height: 30px;
border: 1px solid black; border: 1px solid black;
} }
</style> </style>
@ -52,7 +51,7 @@
<body> <body>
<button type="button" class="print-hide" onclick="this.style.display='none';window.print();this.style.display='inline';">打印</button> <button type="button" class="print-hide" onclick="this.style.display='none';window.print();this.style.display='inline';">打印</button>
<div class="container" id="print-content"> <div class="container" id="print-content">
<p style="font-size:30px;">重庆市巴南区狮子山老年公寓收据</p> <p style="font-size:25px;margin-top: 10px">重庆市巴南区狮子山老年公寓收据</p>
<p class="tag" style="font-size:20px;"> <p class="tag" style="font-size:20px;">
<span class="left">客户姓名 {{$name}}</span> <span class="left">客户姓名 {{$name}}</span>
<span class="middle">日期 {{$time}}</span> <span class="middle">日期 {{$time}}</span>
@ -63,14 +62,14 @@
<th style="width: 5%;">序号</th> <th style="width: 5%;">序号</th>
<th style="width: 25%;">费用类别</th> <th style="width: 25%;">费用类别</th>
<th style="width: 30%;">起止日期</th> <th style="width: 30%;">起止日期</th>
<th style="width: 15%;">金额</th> <th style="width: 15%;">金额(元)</th>
<th style="width: 25%;">备注</th> <th style="width: 25%;">备注</th>
</tr> </tr>
@foreach($list as $item) @foreach($list as $item)
<tr> <tr>
<td>{{$loop->iteration}}</td> <td>{{$loop->iteration}}</td>
<td>{{$item['fee_name']}}</td> <td>{{$item['name']}}-{{$item['fee_name']}}</td>
<td>{{$timeZone}}</td> <td>@if(empty($item['name']))-@else{{$timeZone}}@endif</td>
<td>{{$item['fee_value']}}</td> <td>{{$item['fee_value']}}</td>
<td> <td>
<input type="text" style="border:none"> <input type="text" style="border:none">
@ -78,8 +77,9 @@
</tr> </tr>
@endforeach @endforeach
<tr> <tr>
<td colspan="3">合计大写:</td> <td colspan="3" style=" text-align: left;">合计大写:{{$bigTotal}}</td>
<td colspan="2">{{$bigTotal}}</td> <td >{{$total}}</td>
<td ></td>
</tr> </tr>
</table> </table>
<p class="tag" style="font-size:20px;"> <p class="tag" style="font-size:20px;">
@ -87,6 +87,11 @@
<span class="middle"> </span> <span class="middle"> </span>
<span class="right">收款人 {{$adminName}}</span> <span class="right">收款人 {{$adminName}}</span>
</p> </p>
<p class="tag" style="font-size:20px;">
<span class="left">白联:存根</span>
<span class="middle">红联:客户</span>
<span class="right">黄联:记账</span>
</p>
</div> </div>
</body> </body>
<script> <script>