具有rowspan的Foreach循环表行(PHP Laravel)

时间:2019-10-29 05:06:47

标签: php html laravel vue.js html-table

视频显示

enter image description here

<tbody>
   <template v-for="cash in list_cash">
    <tr class="tt">
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
                <td class="td-text" :rowspan="cash.payment.length">abc</td>
            </tr>
            <template v-for="payment in cash.payment">
            <tr class="tt">
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
                <td class="td-text">abc</td>
            </tr>
            </template>
        </template>
    </tbody>

您好,我有一张桌子,如第一张图片,它使用2循环进行渲染(我使用Vue带有模板标签和rowspan属性)。 红场有很多孩子(黄场)。我怎么能用php laravel渲染这样的表。我在下面尝试了一些代码,但是没有用 对不起,我的英语不好,这是我第一次在这里问问题

<tbody>
        @foreach ($data['list_cash'] as $cash)
        <tr class="tt">
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['contract_name'] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['contract_id'] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['client_name'] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $data['contract_stage'][$cash['stage']] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['actual_start'] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['actual_end'] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['contract_value'] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['actual_sold'] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['other_tax'] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['vat']*100 }}%</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['total'] }}</td>
            <td class="td-text" rowspan="{{ count($cash['payment_list']) }}">{{ $cash['poc']*100 }}%</td>
        </tr>
        @foreach ($cash['payment_list'] as $payment)
        <tr class="tt">
            <td class="td-text">{{ $payment['payment'] }}</td>
            <td class="td-text">{{ $data['payment_type'][$payment['type']] }}</td>
            <td class="td-text">{{ $payment['deposit']*100 }}%</td>
            <td class="td-text">{{ $payment['value'] }}</td>
            <td class="td-text">{{ $payment['cash_in'] }}</td>
            <td class="td-text">{{ $payment['payment_term'] }}</td>
            <td class="td-text">{{ $payment['request_day'] }}</td>
            <td class="td-text">{{ $payment['invoice_day'] }}</td>
            <td class="td-text">{{ $payment['invoice_no'] }}</td>
            <td class="td-text">{{ $payment['payment_day'] }}</td>
            <td class="td-text">{{ $data['payment_status'][$payment['status']] }}</td>
        </tr>
        @endforeach
        @endforeach
    </tbody>

这是显示的 php显示

enter image description here

0 个答案:

没有答案