|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Distributor\Controllers;
|
|
|
|
|
|
|
|
|
+use App\Distributor\Repositories\DistProduct;
|
|
|
use App\Distributor\Repositories\NullRepository;
|
|
|
use App\Distributor\Actions\Extensions\DistProductImportForm;
|
|
|
use App\Distributor\Repositories\RpcAlbum;
|
|
@@ -22,12 +23,6 @@ class ImportProductController extends AdminDistController
|
|
|
*/
|
|
|
public function index(Content $content)
|
|
|
{
|
|
|
-// return $content
|
|
|
-// ->header(admin_trans( 'admin.product_import'))
|
|
|
-// ->description('<span style="color: red; font-weight: bold;">'.admin_trans_label('select_products_to_import').'</span>')
|
|
|
-// ->breadcrumb(['text'=>'list','url'=>''])
|
|
|
-// ->body($this->grid());
|
|
|
-
|
|
|
//记录folder_id
|
|
|
$folderId = isset($_GET['folder_id']) ? intval($_GET['folder_id']) : 0;
|
|
|
//保存临时变量
|
|
@@ -165,9 +160,18 @@ JS
|
|
|
$grid->column('title');
|
|
|
}
|
|
|
|
|
|
- $grid->column('created_at')->sortable();
|
|
|
+ //$grid->column('created_at')->sortable();
|
|
|
$grid->column('updated_at')->sortable();
|
|
|
|
|
|
+ $grid->column('imported')->display(function ($status) {
|
|
|
+ $status = DistProduct::isAlbumImport($this->id);
|
|
|
+ if ($status) {
|
|
|
+ return '<span class="label label-success" style="background:#5cb85c">'.admin_trans_label('Yes').'</span>';
|
|
|
+ } else {
|
|
|
+ return '<span class="label label-default" style="background:#ccc">'.admin_trans_label('No').'</span>';
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
// 筛选
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
|
$filter->panel();
|
|
@@ -179,6 +183,8 @@ JS
|
|
|
$filter->equal('title')->width(3);
|
|
|
}
|
|
|
$filter->equal('folder_id',admin_trans_label('product_category'))->select(RpcAlbumFolder::selectOptions($lang))->width(3);
|
|
|
+ //是否导入
|
|
|
+ $filter->equal('imported')->select([1 => admin_trans_label('Yes'),0 => admin_trans_label('No')])->width(3);
|
|
|
});
|
|
|
|
|
|
// 删除新增按钮
|
|
@@ -204,6 +210,8 @@ JS
|
|
|
|
|
|
protected function detail($id)
|
|
|
{
|
|
|
+ CommonHelper::viewDownloadEnlarge();
|
|
|
+
|
|
|
return Show::make($id, new \App\Admin\Repositories\RpcAlbum(), function (Show $show) {
|
|
|
$lang = config('app.locale');//当前语言
|
|
|
if ($lang == 'en') {
|
|
@@ -212,95 +220,112 @@ JS
|
|
|
$show->field('title');
|
|
|
}
|
|
|
|
|
|
- $show->field('model');
|
|
|
- $show->field('parameters',admin_trans_label('attribute'))->as(function ($items) {
|
|
|
- $items = json_decode($items);
|
|
|
- if (is_array($items)) {
|
|
|
- // 创建表格的表头
|
|
|
- $table = '<table class="table table-bordered table-condensed">';
|
|
|
- // 遍历数组并将数据填充到表格中
|
|
|
- foreach ($items as $item) {
|
|
|
- $item = (array)$item;
|
|
|
- $table .= '<tr>';
|
|
|
- $table .= '<td style="vertical-align: middle !important;width: 20%">' . $item['key'] . '</td>'; // 商品名称
|
|
|
- $table .= '<td style="vertical-align: middle !important;">' . $item['value'] . '</td>'; // 数量
|
|
|
- $table .= '</tr>';
|
|
|
+ if ($show->model()->model) {
|
|
|
+ $show->field('model');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($show->model()->parameters && $show->model()->parameters != '[]') {
|
|
|
+ $show->field('parameters',admin_trans_label('attribute'))->as(function ($items) {
|
|
|
+ $items = json_decode($items);
|
|
|
+ if (is_array($items)) {
|
|
|
+ // 创建表格的表头
|
|
|
+ $table = '<table class="table table-bordered table-condensed">';
|
|
|
+ // 遍历数组并将数据填充到表格中
|
|
|
+ foreach ($items as $item) {
|
|
|
+ $item = (array)$item;
|
|
|
+ $table .= '<tr>';
|
|
|
+ $table .= '<td style="vertical-align: middle !important;width: 20%">' . $item['key'] . '</td>'; // 商品名称
|
|
|
+ $table .= '<td style="vertical-align: middle !important;">' . $item['value'] . '</td>'; // 数量
|
|
|
+ $table .= '</tr>';
|
|
|
+ }
|
|
|
+ $table .= '</table>';
|
|
|
+ return $table;
|
|
|
}
|
|
|
- $table .= '</table>';
|
|
|
- return $table;
|
|
|
- }
|
|
|
- return ''; // 当没有数组数据时
|
|
|
- })->unescape();
|
|
|
- $show->field('cover')->as(function ($images) {
|
|
|
- $images = json_decode($images);
|
|
|
- return CommonHelper::displayImage($images,150,1024,2);
|
|
|
- })->unescape();
|
|
|
+ return ''; // 当没有数组数据时
|
|
|
+ })->unescape();
|
|
|
+ }
|
|
|
|
|
|
- $show->field('en_detail')->as(function ($images) {
|
|
|
- $images = json_decode($images);
|
|
|
- $html = '<div style="text-align: center">';
|
|
|
- foreach ($images as $key => $image) {
|
|
|
- $url = CommonHelper::albumUrl($image);
|
|
|
- $html .= '<img src="' . $url . '" style="max-width:90%;margin-bottom:10px">';
|
|
|
- }
|
|
|
- $html .= '</div>';
|
|
|
- return $html;
|
|
|
- })->unescape();
|
|
|
+ if ($show->model()->cover && $show->model()->cover != '[]') {
|
|
|
+ $show->field('cover')->as(function ($images) {
|
|
|
+ $images = json_decode($images);
|
|
|
+ return CommonHelper::displayImage($images,200,1024,2,false);
|
|
|
+ })->unescape();
|
|
|
+ }
|
|
|
|
|
|
- $show->field('cn_detail')->as(function ($images) {
|
|
|
- $images = json_decode($images);
|
|
|
- $html = '<div style="text-align: center">';
|
|
|
- foreach ($images as $key => $image) {
|
|
|
- $url = CommonHelper::albumUrl($image);
|
|
|
- $html .= '<img src="' . $url . '" style="max-width:90%;margin-bottom:10px">';
|
|
|
- }
|
|
|
- $html .= '</div>';
|
|
|
- return $html;
|
|
|
- })->unescape();
|
|
|
|
|
|
- $show->field('video')->as(function ($items) {
|
|
|
- $items = json_decode($items);
|
|
|
- return CommonHelper::displayVideo($items,'cover','video_src','150',2);
|
|
|
- })->unescape();
|
|
|
|
|
|
- $show->field('poster')->as(function ($images) {
|
|
|
- $images = json_decode($images);
|
|
|
- return CommonHelper::displayImage($images,150,1024,2);
|
|
|
- })->unescape();
|
|
|
+ if ($show->model()->en_detail && $show->model()->en_detail != '[]') {
|
|
|
+ $show->field('en_detail')->as(function ($images) {
|
|
|
+ $images = json_decode($images);
|
|
|
+ $html = '<div style="text-align: center">';
|
|
|
+ foreach ($images as $key => $image) {
|
|
|
+ $url = CommonHelper::albumUrl($image);
|
|
|
+ $html .= '<img src="' . $url . '" style="max-width:90%;margin-bottom:10px">';
|
|
|
+ }
|
|
|
+ $html .= '</div>';
|
|
|
+ return $html;
|
|
|
+ })->unescape();
|
|
|
+ }
|
|
|
|
|
|
- $show->field('cert')->as(function ($images) {
|
|
|
- $images = json_decode($images);
|
|
|
- return CommonHelper::displayImage($images,150,1024,2);
|
|
|
- })->unescape();
|
|
|
+ if ($show->model()->cn_detail && $show->model()->cn_detail != '[]') {
|
|
|
+ $show->field('cn_detail')->as(function ($images) {
|
|
|
+ $images = json_decode($images);
|
|
|
+ $html = '<div style="text-align: center">';
|
|
|
+ foreach ($images as $key => $image) {
|
|
|
+ $url = CommonHelper::albumUrl($image);
|
|
|
+ $html .= '<img src="' . $url . '" style="max-width:90%;margin-bottom:10px">';
|
|
|
+ }
|
|
|
+ $html .= '</div>';
|
|
|
+ return $html;
|
|
|
+ })->unescape();
|
|
|
+ }
|
|
|
|
|
|
- $show->field('cert')->as(function ($images) {
|
|
|
- $images = json_decode($images);
|
|
|
- return CommonHelper::displayImage($images,150,1024,2);
|
|
|
- })->unescape();
|
|
|
-
|
|
|
- $show->field('pdf')->as(function ($items) {
|
|
|
- $items = json_decode($items);
|
|
|
- if (is_array($items)) {
|
|
|
- // 创建表格的表头
|
|
|
- $table = '<table class="table table-bordered table-condensed">';
|
|
|
- // 遍历数组并将数据填充到表格中
|
|
|
- foreach ($items as $item) {
|
|
|
- $table .= '<tr>';
|
|
|
- $table .= '<td style="vertical-align: middle !important;width: 20%">' . $item->pdf_title . '</td>'; // 商品名称
|
|
|
- $table .= '<td style="vertical-align: middle !important;"><a target="_blank" href="' . CommonHelper::albumUrl($item->pdf_src). '">查看</a></td>'; // 数量
|
|
|
- $table .= '</tr>';
|
|
|
+ if ($show->model()->video && $show->model()->video != '[]') {
|
|
|
+ $show->field('video')->as(function ($items) {
|
|
|
+ $items = json_decode($items);
|
|
|
+ return CommonHelper::displayVideo($items,'cover','video_src','150',2);
|
|
|
+ })->unescape();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($show->model()->poster && $show->model()->poster != '[]') {
|
|
|
+ $show->field('poster')->as(function ($images) {
|
|
|
+ $images = json_decode($images);
|
|
|
+ return CommonHelper::displayImage($images,200,1024,2,false);
|
|
|
+ })->unescape();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($show->model()->cert && $show->model()->cert != '[]') {
|
|
|
+ $show->field('cert')->as(function ($images) {
|
|
|
+ $images = json_decode($images);
|
|
|
+ return CommonHelper::displayImage($images,200,1024,2,false);
|
|
|
+ })->unescape();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($show->model()->pdf && $show->model()->pdf != '[]') {
|
|
|
+ $show->field('pdf')->as(function ($items) {
|
|
|
+ $items = json_decode($items);
|
|
|
+ if (is_array($items)) {
|
|
|
+ // 创建表格的表头
|
|
|
+ $table = '<table class="table table-bordered table-condensed">';
|
|
|
+ // 遍历数组并将数据填充到表格中
|
|
|
+ foreach ($items as $item) {
|
|
|
+ $table .= '<tr>';
|
|
|
+ $table .= '<td style="vertical-align: middle !important;width: 20%">' . $item->pdf_title . '</td>'; // 商品名称
|
|
|
+ $table .= '<td style="vertical-align: middle !important;"><a target="_blank" href="' . CommonHelper::albumUrl($item->pdf_src). '">查看</a></td>'; // 数量
|
|
|
+ $table .= '</tr>';
|
|
|
+ }
|
|
|
+ $table .= '</table>';
|
|
|
+ return $table;
|
|
|
}
|
|
|
- $table .= '</table>';
|
|
|
- return $table;
|
|
|
- }
|
|
|
- return ''; // 当没有数组数据时
|
|
|
- })->unescape();
|
|
|
+ return ''; // 当没有数组数据时
|
|
|
+ })->unescape();
|
|
|
+ }
|
|
|
|
|
|
// 禁用操作
|
|
|
$show->disableEditButton();
|
|
|
$show->disableDeleteButton();
|
|
|
|
|
|
-
|
|
|
+ $show->html(CommonHelper::viewDownloadEnlargeHtml());
|
|
|
});
|
|
|
}
|
|
|
|