TaskShow.php 5.1 KB
<?php
/**
+-----------------------------------------------------------------------------------------------------------------------
 * 管理端详情show trait层:渲染生成 ScoreTask 详情
+-----------------------------------------------------------------------------------------------------------------------
 *
 * PHP version 7
 *
 * @category  App\Admin\Shows\Score
 * @package   App\Admin\Shows\Score
 * @author    Richer <yangzi1028@163.com>
 * @date      2023年2月23日14:41:10
 * @copyright 2020-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
namespace App\Admin\Shows\Score;

/**
 * Trait TaskShow
 *
 * @package App\Admin\Shows\Score
 */
trait TaskShow
{
    /**
     * 为详情show渲染字段
     *
     * @return void
     */
    protected function renderShowFields()
    {
        $this->showTextField('id', __('ID'));
        $this->showTextField('year');
        $this->showTextField('month');
        $this->showTextField('description');
        $this->showTextField('family_count', '农户数量');
//        $this->showTextField('details_count', '已评分农户数量');
        $this->showTextField('status_color_show', __('status'));
        $this->showTextField('created_at', __('created_at'));
        $this->showTextField('updated_at', __('updated_at'));
        $this->show->divider();
        $this->show->details('评分记录明细')->as(function ($records) {
            $group_name = __('group_name');
            $house_number = __('house_number');
            $score = __('score');
            $star = __('star');
            $scored_at = __('scored_at');
            $confirmed_at = __('confirmed_at');
            $is_vetoed = __('is_vetoed');
            $html = '<table class="table grid-table" style="overflow: scroll;">';
            $html .= '<thead><tr>';
            $html .= '<th>#</th>';
            $html .= "<th>$group_name </th>";
            $html .= '<th>户主姓名</th>';
            $html .= '<th>户主手机</th>';
            $html .= "<th>$score </th>";
            $html .= "<th>$star </th>";
            $html .= "<th>$scored_at </th>";
            $html .= "<th>$confirmed_at </th>";
            $html .= "<th>$is_vetoed </th>";
            $html .= '</tr></thead>';
            $records->each(function ($record, $index) use (&$html) {
                $html .= '<tr>';
                $html .= '<td>'.($index+1).'</td>';
                $html .= '<td>'.optional($record->group)->name.'</td>';
                $html .= '<td>'.optional($record->user)->name.'</td>';
                $html .= '<td>'.optional($record->user)->mobile.'</td>';
                $html .= '<td>'.$record->score.'</td>';
                $html .= '<td>'.$record->star_show .'</td>';
                $html .= '<td>'.format_date($record->scored_at).'</td>';
                $html .= '<td>'.format_date($record->confirmed_at).'</td>';
                $html .= '<td>'.$record->vetoed_show .'</td>';

                $html .= '</tr>';
            });
            $html .= "</table>";
            return $html;
        })->setGroupClass('col-sm-12 clear-both')->setWidth(11, 1);

        $this->show->divider();

        $this->show->auditRecords('审核记录明细')->as(function ($records) {
            $html = '<div class="track-list track-list-date"><ul>';
            $records->each(function ($record, $index) use (&$html) {
                if ($index === 0) {
                    $html .= '<li class="afterdate  node-to-change track-node-0008  first">';
                } else {
                    $html .= '<li class="">';
                }
                $html .= '<i class="node-icon"><i class="dot"></i><i class="state-icon"></i></i>';
                $html .= ' <span class="date">' .$record->created_at . '</span>';
                $html .= ' <span class="auditor">' .optional($record->user)->name . '</span>';
                $html .= ' <span class="status">' .$record->audited_status_show_color . '</span>';
                $html .= ' <span class="txt">' .$record->audited_opinion . '</span>';
            });
            return $html;

            $html .= '</ul></div>';
            $html = '<table class="table grid-table" style="overflow: scroll;">';
            $html .= '<thead><tr>';
            $html .= '<th>#</th>';
            $html .= '<th>审核用户</th>';
            $html .= '<th>审核结论</th>';
            $html .= '<th>审核意见</th>';
            $html .= '<th>审核时间</th>';
            $html .= '</tr></thead>';
            $records->each(function ($record, $index) use (&$html) {
                $html .= '<tr>';
                $html .= '<td>'.($index+1).'</td>';
                $html .= '<td>'.optional($record->user)->name.'</td>';
                $html .= '<td>'.$record->audited_status_show_color.'</td>';
                $html .= '<td>'.$record->audited_opinion ?? "--".'</td>';
                $html .= '<td>'.format_date($record->created_at).'</td>';
                $html .= '</tr>';
            });
            $html .= "</table>";
            return $html;
        })->setGroupClass('col-sm-12 clear-both')->setWidth(11, 1);
    }
}