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 = '';
//默认list最少N行最多N行
$list = [];
$total = 0;
$bigTotal = '';
$adminName = '';
$timeZone = '';
@ -27,11 +28,27 @@ class PrintController extends Controller
$time = $flow->created_at->format('Y-m-d H:i:s');
$sn = $flow->sn;
$ukeys = explode(',', $request->input('ukeys', ''));
$i = 0;
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){
$total = collect($list)->sum('fee_value');
if($total > 0){
@ -44,7 +61,7 @@ class PrintController extends Controller
$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;
}
body {
margin: 1.6cm;
margin: 0.8cm;
}
}
body {
@ -18,7 +18,6 @@
.container {
/* width: 800px; */
text-align: center;
height: 800px;
}
.tag {
overflow: hidden; /* 清除浮动 */
@ -43,8 +42,8 @@
margin: 0 auto;
table-layout: fixed;
}
td,th{
line-height: 35px;
td, th{
line-height: 30px;
border: 1px solid black;
}
</style>
@ -52,7 +51,7 @@
<body>
<button type="button" class="print-hide" onclick="this.style.display='none';window.print();this.style.display='inline';">打印</button>
<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;">
<span class="left">客户姓名 {{$name}}</span>
<span class="middle">日期 {{$time}}</span>
@ -63,14 +62,14 @@
<th style="width: 5%;">序号</th>
<th style="width: 25%;">费用类别</th>
<th style="width: 30%;">起止日期</th>
<th style="width: 15%;">金额</th>
<th style="width: 15%;">金额(元)</th>
<th style="width: 25%;">备注</th>
</tr>
@foreach($list as $item)
<tr>
<td>{{$loop->iteration}}</td>
<td>{{$item['fee_name']}}</td>
<td>{{$timeZone}}</td>
<td>{{$item['name']}}-{{$item['fee_name']}}</td>
<td>@if(empty($item['name']))-@else{{$timeZone}}@endif</td>
<td>{{$item['fee_value']}}</td>
<td>
<input type="text" style="border:none">
@ -78,8 +77,9 @@
</tr>
@endforeach
<tr>
<td colspan="3">合计大写:</td>
<td colspan="2">{{$bigTotal}}</td>
<td colspan="3" style=" text-align: left;">合计大写:{{$bigTotal}}</td>
<td >{{$total}}</td>
<td ></td>
</tr>
</table>
<p class="tag" style="font-size:20px;">
@ -87,6 +87,11 @@
<span class="middle"> </span>
<span class="right">收款人 {{$adminName}}</span>
</p>
<p class="tag" style="font-size:20px;">
<span class="left">白联:存根</span>
<span class="middle">红联:客户</span>
<span class="right">黄联:记账</span>
</p>
</div>
</body>
<script>