|
|
|
@ -9,6 +9,7 @@ use App\AdminAgent\Repositories\AgentProduct; |
|
|
|
use App\Common\AgentType; |
|
|
|
use App\Common\ProductStatus; |
|
|
|
use App\Models\AgentProductItem; |
|
|
|
use App\Models\AgentSetting; |
|
|
|
use App\Models\Category; |
|
|
|
use App\Models\Channel; |
|
|
|
use App\Models\Guide; |
|
|
|
@ -168,7 +169,7 @@ class AgentProductController extends AdminController |
|
|
|
*/ |
|
|
|
protected function form() |
|
|
|
{ |
|
|
|
return Form::make(new AgentProduct(['spec.productSpec']), function (Form $form) { |
|
|
|
return Form::make(new AgentProduct(['product:id,title', 'spec.productSpec']), function (Form $form) { |
|
|
|
$agent_id = Admin::user()->id; |
|
|
|
//不允许查看非自己的数据
|
|
|
|
if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { |
|
|
|
@ -197,15 +198,23 @@ class AgentProductController extends AdminController |
|
|
|
} else { |
|
|
|
$form->hidden('type')->value(0)->default(0); |
|
|
|
$js = file_get_contents(resource_path('js/select-supplier-product-change.js')); |
|
|
|
$js = str_replace(['{{url}}', '{{class}}', '\\'], [route(admin_api_route_name('form')), LoadSupplierSpec::class, '\\\\'], $js); |
|
|
|
$form->selectTable('product_id', '供应商产品') |
|
|
|
->required() |
|
|
|
->help('产品列表显示的是该产品的标题和图片') |
|
|
|
->title('选择产品') |
|
|
|
->dialogWidth('80%;min-width:825px;') |
|
|
|
->from(SelectProduct::make(['ids' => $form->model()->product_ids])) |
|
|
|
->model(Product::class) |
|
|
|
->script($js); |
|
|
|
$js = str_replace( |
|
|
|
['{{url}}', '{{class}}', '{{profit}}', '\\'], |
|
|
|
[route(admin_api_route_name('form')), LoadSupplierSpec::class, AgentSetting::val(Admin::user()->id, 'profit'), '\\\\'], |
|
|
|
$js |
|
|
|
); |
|
|
|
if ($form->isCreating()) { |
|
|
|
$form->selectTable('product_id', '供应商产品') |
|
|
|
->required() |
|
|
|
->help('产品列表显示的是该产品的标题和图片') |
|
|
|
->title('选择产品') |
|
|
|
->dialogWidth('80%;min-width:825px;') |
|
|
|
->from(SelectProduct::make(['ids' => $form->model()->product_ids])) |
|
|
|
->model(Product::class) |
|
|
|
->script($js); |
|
|
|
} else { |
|
|
|
$form->display('product.title'); |
|
|
|
} |
|
|
|
|
|
|
|
$form->hasMany('spec', function (Form\NestedForm $form) { |
|
|
|
// $form->hidden('id'); hasMany时,ID会自动生成
|
|
|
|
|