锚标签的链接也在Laravel Blade中打印

时间:2016-01-17 23:01:40

标签: php printing laravel-5.1 laravel-blade

我有一张员工工资清单表。我用anchor标签包装员工ID,以显示每个员工的工资历史。问题是当我打印表时,个人工资历史的link也会打印在员工ID下。

以下是屏幕截图打印预览:

enter image description here

刀片

<div class="d-section col-md-12">
    <table class="table table-striped table-condensed table-bordered">
        <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Position</th>
            <th>Start Date</th>
            <th>End Date</th>
            <th>Worked</th>
            <th>Basic</th>
            <th>OT Rate</th>
            <th>OT Hour</th>
            <th>OT Amount</th>
            <th>Basic Amount</th>
            <th>Total</th>
            <th>Signature</th>
            <th>Finger</th>
        </tr>
        </thead>
        <tbody>
        @foreach($employees as $employee)
            <tr>
                <td><a href="{{ action('SalaryController@show',[$employee->id]) }}">{{ $employee->eid }}</a></td>
                <td>{{ $employee->name }}</td>
                <td>{{ $employee->designation }}</td>
                <td>{{ $employee->start }}</td>
                <td>{{ $employee->end }}</td>
                <td>{{ $employee->worked }}</td>
                <td>{{ $employee->basic }}</td>
                <td>{{ $employee->ot_rate }}</td>
                <td>{{ $employee->ot_hour }}</td>
                <td>{{ $employee->ot_amount }}</td>
                <td>{{ $employee->basic_amount }}</td>
                <td>{{ $employee->ot_amount + $employee->basic_amount }}</td>
                <td></td>
                <td>
                    {!! Form::open(['action'=>['SalaryController@destroy',$employee->id],'class'=>'no-print','method'=>'delete','onsubmit'=>'return deleteConfirm()']) !!}
                    {!! Form::submit('X',['class'=>'element btnn btn-danger']) !!}
                    <br/>
                    <a href="{{ action('SalaryController@edit',[$employee->id]) }}" class="element btnn btn-warning" role="button"><span class="glyphicon glyphicon-edit"></span></a>
                    <br/>
                    <a href="{{ action('SalaryController@payment',[$employee->id]) }}" class="element btnn btn-success" role="button"><span class="glyphicon glyphicon-usd"></span></a>
                    {!! Form::close() !!}
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
</div>

1 个答案:

答案 0 :(得分:2)

为什么不直接为锚点创建一个CSS类并使用该类隐藏它们?

<a href="{{ action('SalaryController@show',[$employee->id]) }}" class="hiddenTab">foo</a>
<a href="#" class="only-print">foo</a>

在你的CSS中:

.only-print{
    display:none;
}
@media print{
    a.hiddenTab {
        display:none;
    }
    .only-print{
        display:block;
    }
}

您要隐藏的所有锚点都只使用class="hiddenTab"。 如果要隐藏所有已设置href的标记,可以执行以下操作:

a[href] { display: none; }