|
@@ -8,6 +8,7 @@ use App\Distributor\Repositories\BaseProduct;
|
|
|
use App\Admin\Repositories\BaseProductCategory;
|
|
|
use App\Distributor\Actions\BatchCopy;
|
|
|
use App\Distributor\Repositories\DistProductCategory;
|
|
|
+use App\Libraries\CommonHelper;
|
|
|
use Dcat\Admin\Form;
|
|
|
use Dcat\Admin\Grid;
|
|
|
use Dcat\Admin\Show;
|
|
@@ -24,9 +25,9 @@ class ImportProductController extends AdminController
|
|
|
public function index(Content $content)
|
|
|
{
|
|
|
return $content
|
|
|
- ->header('产品导入')
|
|
|
+ ->header('Product Import')
|
|
|
->description('<span style="color: red; font-weight: bold;">'.admin_trans_label('select_products_to_import').'</span>')
|
|
|
- ->breadcrumb(['text'=>'列表','url'=>''])
|
|
|
+ ->breadcrumb(['text'=>'list','url'=>''])
|
|
|
->body($this->grid());
|
|
|
}
|
|
|
|
|
@@ -58,15 +59,14 @@ class ImportProductController extends AdminController
|
|
|
*/
|
|
|
protected function grid()
|
|
|
{
|
|
|
- return Grid::make(new BaseProduct(), function (Grid $grid) {
|
|
|
+ return Grid::make(BaseProduct::with(['baseProductCategory','images']), function (Grid $grid) {
|
|
|
$grid->column('id')->sortable();
|
|
|
$grid->column('title');
|
|
|
+ $grid->column('sku');
|
|
|
+ $grid->column('base_product_category.name',admin_trans_label('category_name'));
|
|
|
$grid->column('keywords');
|
|
|
$grid->column('description');
|
|
|
- $grid->column('sku');
|
|
|
- $grid->column('category_id');
|
|
|
$grid->column('issuance_date');
|
|
|
-
|
|
|
// 筛选
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
|
$filter->panel();
|
|
@@ -74,7 +74,7 @@ class ImportProductController extends AdminController
|
|
|
$filter->equal('sku')->width(2);
|
|
|
$filter->like('title')->width(2);
|
|
|
$filter->equal('category_id',admin_trans_label('category'))->select(BaseProductCategory::selectOptions())->width(2);
|
|
|
- $filter->equal('enabled', admin_trans_label('enabled'))->select(array_map('admin_trans_label', config('dictionary.enabled')))->width(2);
|
|
|
+ //$filter->equal('enabled', admin_trans_label('enabled'))->select(array_map('admin_trans_label', config('dictionary.enabled')))->width(2);
|
|
|
});
|
|
|
//$grid->column('order');
|
|
|
//$grid->column('enabled');
|
|
@@ -105,7 +105,7 @@ class ImportProductController extends AdminController
|
|
|
new DistProductImportForm(),
|
|
|
]);
|
|
|
|
|
|
-
|
|
|
+ $grid->model()->where('enabled',1)->orderBy("is_pinned",'desc')->orderBy("order",'desc');
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -118,21 +118,42 @@ class ImportProductController extends AdminController
|
|
|
*/
|
|
|
protected function detail($id)
|
|
|
{
|
|
|
- return Show::make($id, new BaseProduct(), function (Show $show) {
|
|
|
+ return Show::make($id, BaseProduct::with(['baseProductCategory','images']), function (Show $show) {
|
|
|
$show->field('id');
|
|
|
$show->field('title');
|
|
|
+ $show->field('sku');
|
|
|
+ $show->field('base_product_category.name',admin_trans_label('category_name'));
|
|
|
$show->field('keywords');
|
|
|
$show->field('description');
|
|
|
- $show->field('sku');
|
|
|
- $show->field('category_id');
|
|
|
$show->field('issuance_date');
|
|
|
- $show->field('order');
|
|
|
- $show->field('enabled');
|
|
|
- $show->field('content');
|
|
|
- $show->field('parameters');
|
|
|
- $show->field('is_pinned');
|
|
|
- $show->field('created_at');
|
|
|
- $show->field('updated_at');
|
|
|
+ $show->field('parameters')->as(function ($items) {
|
|
|
+ if (is_array($items)) {
|
|
|
+ // 创建表格的表头
|
|
|
+ $table = '<table class="table">';
|
|
|
+ $table .= '<tr><th>key</th><th>value</th></tr>';
|
|
|
+ // 遍历数组并将数据填充到表格中
|
|
|
+ foreach ($items as $item) {
|
|
|
+ $table .= '<tr>';
|
|
|
+ $table .= '<td>' . $item['key'] . '</td>'; // 商品名称
|
|
|
+ $table .= '<td>' . $item['value'] . '</td>'; // 数量
|
|
|
+ $table .= '</tr>';
|
|
|
+ }
|
|
|
+ $table .= '</table>';
|
|
|
+ return $table;
|
|
|
+ }
|
|
|
+ return ''; // 当没有数组数据时
|
|
|
+ })->unescape();
|
|
|
+ $show->field('images')->as(function ($images) {
|
|
|
+ // 开始生成 HTML
|
|
|
+ $dataImages = array_column($images, 'image_url');
|
|
|
+ return CommonHelper::displayImage($dataImages,150);
|
|
|
+ })->unescape();
|
|
|
+ $show->field('content')->unescape();
|
|
|
+ //$show->field('created_at');
|
|
|
+ //$show->field('updated_at');
|
|
|
+ // 禁用操作
|
|
|
+ $show->disableEditButton();
|
|
|
+ $show->disableDeleteButton();
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -141,25 +162,25 @@ class ImportProductController extends AdminController
|
|
|
*
|
|
|
* @return Form
|
|
|
*/
|
|
|
- protected function form()
|
|
|
- {
|
|
|
- return Form::make(new BaseProduct(), function (Form $form) {
|
|
|
- $form->display('id');
|
|
|
- $form->text('title');
|
|
|
- $form->text('keywords');
|
|
|
- $form->text('description');
|
|
|
- $form->text('sku');
|
|
|
- $form->text('category_id');
|
|
|
- $form->text('issuance_date');
|
|
|
- $form->text('order');
|
|
|
- $form->text('enabled');
|
|
|
- $form->text('content');
|
|
|
- $form->text('parameters');
|
|
|
- $form->text('is_pinned');
|
|
|
-
|
|
|
- $form->display('created_at');
|
|
|
- $form->display('updated_at');
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
+// protected function form()
|
|
|
+// {
|
|
|
+// return Form::make(new BaseProduct(), function (Form $form) {
|
|
|
+// $form->display('id');
|
|
|
+// $form->text('title');
|
|
|
+// $form->text('keywords');
|
|
|
+// $form->text('description');
|
|
|
+// $form->text('sku');
|
|
|
+// $form->text('category_id');
|
|
|
+// $form->text('issuance_date');
|
|
|
+// $form->text('order');
|
|
|
+// $form->text('enabled');
|
|
|
+// $form->text('content');
|
|
|
+// $form->text('parameters');
|
|
|
+// $form->text('is_pinned');
|
|
|
+//
|
|
|
+// $form->display('created_at');
|
|
|
+// $form->display('updated_at');
|
|
|
+//
|
|
|
+// });
|
|
|
+// }
|
|
|
}
|