filled('date.start')) { $request->offsetSet('date.start', now()->startOfMonth()->format('Y-m-d')); } if (!$request->filled('date.end')) { $request->offsetSet('date.end', now()->format('Y-m-d')); } return Grid::make(new StoreTockRepository, function (Grid $grid) { $tags = StockLog::tags()->get(); $grid->column('store_name', '门店'); $grid->column('name', '产品'); $grid->column('category_name', '分类'); $grid->column('cost_price', '成本单价'); $grid->column('sell_price', '售价'); $grid->column('init_stock', '初期库存'); $grid->column('tag_in', '入库数'); $grid->column('tag_sell', '销售数'); $grid->column('tag_online', '线上销售数'); $grid->column('tag_loss', '报损数'); $grid->column('tag_self', '自用数'); $grid->column('tag_out', '调货数'); $grid->column('stock', '现有库存')->sortable(); $grid->column('total_profit', '商品总毛利'); $grid->disableActions(); $grid->filter(function (Grid\Filter $filter) use ($tags) { $filter->panel(); $filter->equal('store_id', '门店')->select(Store::pluck('title', 'id'))->width(3); $filter->equal('category_id', '分类')->select(ProductCategory::selectOptions())->width(3); $filter->equal('product_name', '商品')->width(3); $filter->between('date', '时间')->date()->width(6); }); $grid->footer(function ($collection) use ($grid) { $total = $grid->model()->repository()->getTotal($grid->model()); $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= '
入库总成本: '.data_get($total, 'total_in').'销售总金额: '.data_get($total, 'total_sell').'线上销售总金额: '.data_get($total, 'total_online').'报损总成本: '.data_get($total, 'total_loss').'自用总成本: '.data_get($total, 'total_self').'调货总金额: '.data_get($total, 'total_out').'现有总成本: '.data_get($total, 'total_cost_price').'现有总价值: '.data_get($total, 'total_sell_price').'产品毛利汇总: '.data_get($total, 'total_profit').'
'; return $html; }); }); } }