| 
					
					
						
							
						
					
					
				 | 
				@ -11,11 +11,13 @@ use App\Common\ProductStatus; | 
			
		
		
	
		
			
				 | 
				 | 
				use App\Models\AgentProductItem; | 
				 | 
				 | 
				use App\Models\AgentProductItem; | 
			
		
		
	
		
			
				 | 
				 | 
				use App\Models\Category; | 
				 | 
				 | 
				use App\Models\Category; | 
			
		
		
	
		
			
				 | 
				 | 
				use App\Models\Channel; | 
				 | 
				 | 
				use App\Models\Channel; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				use App\Models\DiyForm; | 
			
		
		
	
		
			
				 | 
				 | 
				use App\Models\Guide; | 
				 | 
				 | 
				use App\Models\Guide; | 
			
		
		
	
		
			
				 | 
				 | 
				use App\Models\Product; | 
				 | 
				 | 
				use App\Models\Product; | 
			
		
		
	
		
			
				 | 
				 | 
				use App\Models\Supplier; | 
				 | 
				 | 
				use App\Models\Supplier; | 
			
		
		
	
		
			
				 | 
				 | 
				use Dcat\Admin\Admin; | 
				 | 
				 | 
				use Dcat\Admin\Admin; | 
			
		
		
	
		
			
				 | 
				 | 
				use Dcat\Admin\Form; | 
				 | 
				 | 
				use Dcat\Admin\Form; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				use Dcat\Admin\Form\NestedForm; | 
			
		
		
	
		
			
				 | 
				 | 
				use Dcat\Admin\Grid; | 
				 | 
				 | 
				use Dcat\Admin\Grid; | 
			
		
		
	
		
			
				 | 
				 | 
				use Dcat\Admin\Show; | 
				 | 
				 | 
				use Dcat\Admin\Show; | 
			
		
		
	
		
			
				 | 
				 | 
				use Dcat\Admin\Http\Controllers\AdminController; | 
				 | 
				 | 
				use Dcat\Admin\Http\Controllers\AdminController; | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
						
							
						
					
					
				 | 
				@ -168,7 +170,7 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
								return $form->response()->error('数据不存在'); | 
				 | 
				 | 
								return $form->response()->error('数据不存在'); | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							$form->display('id'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				//			$form->display('id');
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							//计调版旅行社不允许选择计调云产品
 | 
				 | 
				 | 
							//计调版旅行社不允许选择计调云产品
 | 
			
		
		
	
		
			
				 | 
				 | 
							if (Admin::user()->type == AgentType::OPERATOR) { | 
				 | 
				 | 
							if (Admin::user()->type == AgentType::OPERATOR) { | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -188,12 +190,11 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
								$form->editor('know'); | 
				 | 
				 | 
								$form->editor('know'); | 
			
		
		
	
		
			
				 | 
				 | 
								$form->editor('content'); | 
				 | 
				 | 
								$form->editor('content'); | 
			
		
		
	
		
			
				 | 
				 | 
							} else { | 
				 | 
				 | 
							} else { | 
			
		
		
	
		
			
				 | 
				 | 
								$form->hidden('type')->value(0); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								if ($form->isCreating()) { | 
				 | 
				 | 
								if ($form->isCreating()) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$form->radio('type')->options([0 => '从供应商进货', 3 => '自营产品'])->default(0) | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										->when(0, function (Form $form) { | 
			
		
		
	
		
			
				 | 
				 | 
											$form->selectTable('product_id', '供应商产品') | 
				 | 
				 | 
											$form->selectTable('product_id', '供应商产品') | 
			
		
		
	
		
			
				 | 
				 | 
										->required() | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										->help('产品列表显示的是该产品的标题和图片') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										->title('选择产品') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
												->title('选择产品')->default(0) | 
			
		
		
	
		
			
				 | 
				 | 
												->dialogWidth('80%;min-width:825px;') | 
				 | 
				 | 
												->dialogWidth('80%;min-width:825px;') | 
			
		
		
	
		
			
				 | 
				 | 
												->from(SelectProduct::make(['ids' => $form->model()->product_ids])) | 
				 | 
				 | 
												->from(SelectProduct::make(['ids' => $form->model()->product_ids])) | 
			
		
		
	
		
			
				 | 
				 | 
												->model(Product::class) | 
				 | 
				 | 
												->model(Product::class) | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -204,34 +205,36 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
													}); | 
				 | 
				 | 
													}); | 
			
		
		
	
		
			
				 | 
				 | 
												}); | 
				 | 
				 | 
												}); | 
			
		
		
	
		
			
				 | 
				 | 
											");
 | 
				 | 
				 | 
											");
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											//关联供应商规格
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											$this->related_spec($form); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										})->when(3, function (Form $form) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											//自营产品表单
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											$this->self_form($form); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										}); | 
			
		
		
	
		
			
				 | 
				 | 
								} else { | 
				 | 
				 | 
								} else { | 
			
		
		
	
		
			
				 | 
				 | 
									$form->hidden('product_id'); | 
				 | 
				 | 
									$form->hidden('product_id'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									if ($form->model()->type == 0) { | 
			
		
		
	
		
			
				 | 
				 | 
										$form->display('product.title'); | 
				 | 
				 | 
										$form->display('product.title'); | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->hasMany('spec', function (Form\NestedForm $form) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				//					$form->hidden('id'); hasMany时,ID会自动生成
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->hidden('product_spec_id'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->text('supplier_name', '规格')->disable()->customFormat(fn() => $this->product_spec['name'] ?? '供应商已删除规格'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->date('supplier_date', '日期')->disable()->customFormat(fn() => $this->product_spec['date'] ?? '供应商已删除规格'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->text('supplier_stock', '供应商库存')->disable()->customFormat(fn() => $this->product_spec['stock'] ?? 0); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->text('supplier_cost_price', '供应商成本价')->disable()->customFormat(fn() => $this->product_spec['cost_price'] ?? 0); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->text('supplier_price', '建议销售价')->disable()->customFormat(fn() => $this->product_spec['price'] ?? 0); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->text('stock', '您的库存')->required() | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										//如果库存大于供应商库存,则取供应商库存
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										->customFormat(fn() => isset($this->product_spec['stock'], $this->stock) && $this->stock > $this->product_spec['stock'] ? $this->product_spec['stock'] : $this->stock); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->text('original_price', '您的市场价')->required(); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->text('price', '您的销售价')->required() | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										//如果代理商价格小于供应商建议售价,则取供应商售价
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										->customFormat(fn() => isset($this->product_spec['price'], $this->price) && $this->price < $this->product_spec['price'] ? $this->product_spec['price'] : $this->price); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										//关联供应商规格
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										$this->related_spec($form); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									} else if ($form->model()->type == 3) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										//自营产品表单
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										$this->self_form($form); | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
									Admin::style('.has-many-spec .add.btn{display:none;} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									.has-many-spec .field_supplier_date{width:100px!important;} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									.has-many-spec .col-md-12{padding:0;} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									.has-many-spec .form-group{margin-bottom:0;} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									.has-many-spec .form-group .remove{margin-top:10px;} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									.has-many-spec .input-group-prepend{display:none;} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									.has-many-spec .input-group>.form-control:not(:first-child){border-radius:.25rem;}'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										//再加这个hasMany才能正常保存
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										$form->hasMany('spec', function (Form\NestedForm $form) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											$form->hidden('name'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											$form->hidden('date'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											$form->hidden('stock'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											$form->hidden('original_price'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											$form->hidden('price'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										})->useTable()->script('$(function(){ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
											$(".has-many-spec").parent().parent().remove(); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
										});'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
								$js = file_get_contents(resource_path('js/agent-spec-edit.js')); | 
				 | 
				 | 
								$js = file_get_contents(resource_path('js/agent-spec-edit.js')); | 
			
		
		
	
		
			
				 | 
				 | 
								$class = str_replace('\\', '\\\\', LoadSupplierSpec::class); | 
				 | 
				 | 
								$class = str_replace('\\', '\\\\', LoadSupplierSpec::class); | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -241,57 +244,14 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
									$js | 
				 | 
				 | 
									$js | 
			
		
		
	
		
			
				 | 
				 | 
								); | 
				 | 
				 | 
								); | 
			
		
		
	
		
			
				 | 
				 | 
								Admin::script($js); | 
				 | 
				 | 
								Admin::script($js); | 
			
		
		
	
		
			
				 | 
				 | 
								})->useTable()->required(); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
								if ($form->isCreating()) { | 
				 | 
				 | 
								if ($form->isCreating()) { | 
			
		
		
	
		
			
				 | 
				 | 
									Admin::style('.has-many-spec .spec-sync{display:none;}'); | 
				 | 
				 | 
									Admin::style('.has-many-spec .spec-sync{display:none;}'); | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
								/*$form->radio('type') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->options(['单品销售']) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->default(Admin::user()->type == AgentType::OPERATOR ? 1 : 0)->required() | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									//->help('单品销售无需审核,组合销售需要审核才能上架')
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->help('单品销售无需审核') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->when(0, function (Form $form) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										// 单品销售
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										$form->selectTable('product_id', '供应商产品') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->help('产品列表显示的是该产品的标题和图片') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->title('选择产品') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->dialogWidth('80%;min-width:825px;') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->from(SelectProduct::make(['ids' => $form->model()->product_ids])) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->model(Product::class); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									})->when(1, function (Form $form) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										// 组合销售
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										$form->multipleSelectTable('product_ids', '供应商产品') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->help('可单选或多选组合销售') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->title('选择产品') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->dialogWidth('80%;min-width:825px;') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->from(SelectProduct::make(['ids' => $form->model()->product_ids])) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->model(Product::class); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										// 自定义内容
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										$form->text('title'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										$form->multipleImage('pictures')->removable(false)->uniqueName(); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										$form->editor('know'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										$form->editor('content'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									})->when(2, function (Form $form) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										// 计调云产品
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										$form->selectTable('agent_cloud_pid', '计调云产品') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->help('产品列表显示的是该产品的标题和图片') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->title('选择产品') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->dialogWidth('80%;min-width:825px;') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->from(SelectAgentCloudProduct::make()) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->model(\App\Models\AgentProduct::class); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									});*/ | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
							/*$form->decimal('price',)->rules('required|numeric|min:0|not_in:0',[ | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								'*' => '金额为必填字段且必须大于0', | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							])->required(); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							$form->decimal('original_price')->rules('required|numeric|min:0|not_in:0',[ | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								'*' => '金额为必填字段且必须大于0', | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							])->required();*/ | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				            $form->number('sale')->min(0)->default(0); | 
				 | 
				 | 
				            $form->number('sale')->min(0)->default(0); | 
			
		
		
	
		
			
				 | 
				 | 
				//            $form->number('stock')->min(0)->default(8888)->required();
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							$options = Category::selectOptions(fn($query) => $query->where('agent_id', $agent_id)); | 
				 | 
				 | 
							$options = Category::selectOptions(fn($query) => $query->where('agent_id', $agent_id)); | 
			
		
		
	
		
			
				 | 
				 | 
				            $form->select('category_id') | 
				 | 
				 | 
				            $form->select('category_id') | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -309,13 +269,6 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
									]) | 
				 | 
				 | 
									]) | 
			
		
		
	
		
			
				 | 
				 | 
									->required(); | 
				 | 
				 | 
									->required(); | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
							//$form->selectTable('verifier')
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							//	->title('选择核销人员')
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							//	->dialogWidth('50%;min-width:600px;') //不起作用
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							//	->from(SelectUser::make(['is_verify' => 1]))
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							//	->model(User::class, 'id', 'nickname')
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							//	->customFormat(fn($v) => !$v ? '' : $v)
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							//	->required();
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							//计调版旅行社可以选择地接
 | 
				 | 
				 | 
							//计调版旅行社可以选择地接
 | 
			
		
		
	
		
			
				 | 
				 | 
							if (Admin::user()->type == AgentType::OPERATOR) { | 
				 | 
				 | 
							if (Admin::user()->type == AgentType::OPERATOR) { | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -324,9 +277,6 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
									->dialogWidth('50%;min-width:600px;') //不起作用
 | 
				 | 
				 | 
									->dialogWidth('50%;min-width:600px;') //不起作用
 | 
			
		
		
	
		
			
				 | 
				 | 
									->from(SelectGuide::make()) | 
				 | 
				 | 
									->from(SelectGuide::make()) | 
			
		
		
	
		
			
				 | 
				 | 
									->model(Guide::class, 'id', 'name'); | 
				 | 
				 | 
									->model(Guide::class, 'id', 'name'); | 
			
		
		
	
		
			
				 | 
				 | 
								if ($form->isEditing()) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->confirm('提示', '如果修改了标题、价格、产品图片、旅游须知、产品详情需要重新审核,同时<span class="btn-danger">下架所有</span>关联的代理商产品,是否继续?'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							} else { | 
				 | 
				 | 
							} else { | 
			
		
		
	
		
			
				 | 
				 | 
								$form->switch('is_rec')->help('推荐后将在小程序“我的”页面下方显示'); | 
				 | 
				 | 
								$form->switch('is_rec')->help('推荐后将在小程序“我的”页面下方显示'); | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -346,14 +296,6 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->number('deposit_timeout')->min(0) | 
				 | 
				 | 
								$form->number('deposit_timeout')->min(0) | 
			
		
		
	
		
			
				 | 
				 | 
									->default(0)->help('单位:分钟。超过这个时间未支付尾款,订单将自动关闭,且订金不退'); | 
				 | 
				 | 
									->default(0)->help('单位:分钟。超过这个时间未支付尾款,订单将自动关闭,且订金不退'); | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								/*$form->tree('channel_id', '所属频道') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->expand(false) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->nodes(Channel::where('agent_id', Admin::user()->id)->get()->toArray()) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->setIdColumn('id') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->setTitleColumn('name') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->setParentColumn('pid');*/ | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									//->exceptParentNode(); //禁止过滤父节点的值
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
				        })->saving(function (Form $form) { | 
				 | 
				 | 
				        })->saving(function (Form $form) { | 
			
		
		
	
		
			
				 | 
				 | 
							//不允许修改非自己的数据
 | 
				 | 
				 | 
							//不允许修改非自己的数据
 | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -361,7 +303,7 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
								return $form->response()->error('数据不存在'); | 
				 | 
				 | 
								return $form->response()->error('数据不存在'); | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							if ($form->isEditing() && $form->type === null) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							if ($form->isEditing() && $form->product_id === null) { | 
			
		
		
	
		
			
				 | 
				 | 
								//推荐按钮开关
 | 
				 | 
				 | 
								//推荐按钮开关
 | 
			
		
		
	
		
			
				 | 
				 | 
								if ($form->is_rec !== null) { | 
				 | 
				 | 
								if ($form->is_rec !== null) { | 
			
		
		
	
		
			
				 | 
				 | 
									$form->model()->is_rec = $form->is_rec ? 1 : 0; | 
				 | 
				 | 
									$form->model()->is_rec = $form->is_rec ? 1 : 0; | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
						
							
						
					
					
				 | 
				@ -411,8 +353,16 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							if (is_null($form->type)) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								return $form->response()->error('请选择销售类型!'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							if ($form->isCreating() && is_null($form->type)) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								return $form->response()->error('请选择产品类型!'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							} else if ($form->isEditing()) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->type = $form->model()->type; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							//自营产品规格
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							if ($form->type == 3) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->spec = $form->spec_self; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->deleteInput('spec_self'); | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							$form->hidden(['stock', 'price']); | 
				 | 
				 | 
							$form->hidden(['stock', 'price']); | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -420,6 +370,9 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
								return $form->response()->error('请选择产品,并设置产品规格'); | 
				 | 
				 | 
								return $form->response()->error('请选择产品,并设置产品规格'); | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
							$spec = array_filter($form->spec, fn($v) => !$v['_remove_']); | 
				 | 
				 | 
							$spec = array_filter($form->spec, fn($v) => !$v['_remove_']); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							if (!$spec) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								return $form->response()->error('产品规格不能为空'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
							$form->stock = array_sum(array_column($spec, 'stock')); | 
				 | 
				 | 
							$form->stock = array_sum(array_column($spec, 'stock')); | 
			
		
		
	
		
			
				 | 
				 | 
							$form->original_price = min(array_column($spec, 'original_price')); | 
				 | 
				 | 
							$form->original_price = min(array_column($spec, 'original_price')); | 
			
		
		
	
		
			
				 | 
				 | 
							$form->price = min(array_column($spec, 'price')); | 
				 | 
				 | 
							$form->price = min(array_column($spec, 'price')); | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
						
							
						
					
					
				 | 
				@ -446,86 +399,12 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
								$form->pictures = $product->pictures; | 
				 | 
				 | 
								$form->pictures = $product->pictures; | 
			
		
		
	
		
			
				 | 
				 | 
								$form->know = $product->know; | 
				 | 
				 | 
								$form->know = $product->know; | 
			
		
		
	
		
			
				 | 
				 | 
								$form->content = $product->content; | 
				 | 
				 | 
								$form->content = $product->content; | 
			
		
		
	
		
			
				 | 
				 | 
							/*} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							//组合销售
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							else if ($form->type == 1) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								if (!$form->product_ids) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									return $form->response()->error('请选择产品'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$product_ids = explode(',', $form->product_ids); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								if (count($product_ids) < 2) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									return $form->response()->error('组合销售必须选择两个以上产品,否则请选择单品销售'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->product_id = $product_ids[0]; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$required_fields = ['title', 'pictures', 'know', 'content']; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								foreach ($required_fields as $field) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									if (!$form->$field) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										return $form->response()->error('内容输入不完整,标题、产品图片、旅游须知、产品详情必填'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							} else if ($form->type == 3) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								if (!$form->title || !$form->pictures || !$form->know || !$form->content) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									return $form->response()->error('标题、产品图片、旅游须知、产品详情不能为空'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								} else if (!$form->diy_form_id) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									return $form->response()->error('请选择信息收集表单'); | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								//判断供应商产品是否存在或下架
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$not_in_id = Product::query() | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->whereIn('id', $product_ids) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->where(function ($query) use ($form) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										$query->where('status', '<>', ProductStatus::ON_SALE) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
											->orWhere('stock', '<', $form->stock); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									}) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->pluck('id') | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									->toArray(); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								if ($not_in_id) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									return $form->response()->error('产品ID ' . join(',', $not_in_id) . ' 库存小于你设置的库存' . $form->stock . ',或已下架'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$total_price = Product::query()->whereIn('id', $product_ids)->sum('price'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								if ($form->price < $total_price) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									return $form->response()->error("产品销售价不能小于供应商产品总销售价{$total_price}"); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								//如果是计调版旅行社,标记为是云产品
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								if (Admin::user()->type == AgentType::OPERATOR) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->hidden('is_cloud'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									$form->is_cloud = 1; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							//计调云产品
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							else if ($form->type == 2) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->agent_cloud_pid = (int)$form->agent_cloud_pid; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								if (!$form->agent_cloud_pid) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									return $form->response()->error('请选择产品'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								//产品信息预判断
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$cloud_product = \App\Models\AgentProduct::where([ | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									['stock', '>', 0], | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									['status', '=', ProductStatus::ON_SALE], | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									['is_cloud', '=', 1], | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									['type', '=', 1], | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									['agent_id', '<>', Admin::user()->id], | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								])->whereDoesntHave('agentProductItem', function ($query) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									return $query->whereHas('product', function ($query) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
										return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									}); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								})->find($form->agent_cloud_pid); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								if (!$cloud_product) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									return $form->response()->error('你选择的计调云产品库存不足或已下架,请重新选择'); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} else if ($cloud_product->stock < $form->stock) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									return $form->response()->error("计调云产品当前库存为{$cloud_product->stock},你设置的库存不能超过该数值"); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} else if ($form->price < $cloud_product->price) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
									return $form->response()->error("产品销售价不能小于计调云产品销售价{$cloud_product->price}"); | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								//同步关键字段信息
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->product_id =  $cloud_product->product_id; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->product_ids =  $cloud_product->product_ids; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->guide_id =  $cloud_product->guide_id; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->title = $cloud_product->title; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->pictures = $cloud_product->pictures; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->know = $cloud_product->know; | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
								$form->content = $cloud_product->content;*/ | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
							} else { | 
				 | 
				 | 
							} else { | 
			
		
		
	
		
			
				 | 
				 | 
								return $form->response()->error('不存在此销售方式'); | 
				 | 
				 | 
								return $form->response()->error('不存在此销售方式'); | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -533,15 +412,31 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
							$agent_id = Admin::user()->id; | 
				 | 
				 | 
							$agent_id = Admin::user()->id; | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							//处理特殊字段
 | 
				 | 
				 | 
							//处理特殊字段
 | 
			
		
		
	
		
			
				 | 
				 | 
							$form->hidden(['agent_id', 'status']); //表单没有的字段,必须加这句才能够重写
 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->hidden(['agent_id', 'status', 'longitude', 'latitude', 'address']); //表单没有的字段,必须加这句才能够重写
 | 
			
		
		
	
		
			
				 | 
				 | 
							$form->agent_id = $agent_id; | 
				 | 
				 | 
							$form->agent_id = $agent_id; | 
			
		
		
	
		
			
				 | 
				 | 
							$form->agent_cloud_pid = $form->type ==2 ? ($form->agent_cloud_pid ?? 0) : 0; | 
				 | 
				 | 
							$form->agent_cloud_pid = $form->type ==2 ? ($form->agent_cloud_pid ?? 0) : 0; | 
			
		
		
	
		
			
				 | 
				 | 
							if (array_key_exists('guide_id', $form->input())) { | 
				 | 
				 | 
							if (array_key_exists('guide_id', $form->input())) { | 
			
		
		
	
		
			
				 | 
				 | 
								$form->guide_id = $form->guide_id ?? 0; | 
				 | 
				 | 
								$form->guide_id = $form->guide_id ?? 0; | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							//产品模板
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							if ($form->isEditing()) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->tpl_type = $form->model()->tpl_type; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							//经度,纬度,地址
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							if ($form->tpl_type == 0) { //旅游线路用出发地保存
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->longitude = $form->extends['field_0_departure_place_longitude'] ?? 0; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->latitude = $form->extends['field_0_departure_place_latitude'] ?? 0; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->address = $form->extends['field_0_departure_place'] ?? ''; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							} else { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->longitude = $form->extends['field_'.$form->tpl_type.'_longitude'] ?? 0; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->latitude = $form->extends['field_'.$form->tpl_type.'_latitude'] ?? 0; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->address = $form->extends['field_'.$form->tpl_type.'_address'] ?? ''; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							//组合销售需要审核,编辑时是否需要审核在saved里面判断
 | 
				 | 
				 | 
							//组合销售需要审核,编辑时是否需要审核在saved里面判断
 | 
			
		
		
	
		
			
				 | 
				 | 
							if ($form->type == 1) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							if ($form->type == 1 || $form->type == 3) { | 
			
		
		
	
		
			
				 | 
				 | 
								if ($form->isCreating()) { | 
				 | 
				 | 
								if ($form->isCreating()) { | 
			
		
		
	
		
			
				 | 
				 | 
									$form->status = ProductStatus::UNAUDITED; | 
				 | 
				 | 
									$form->status = ProductStatus::UNAUDITED; | 
			
		
		
	
		
			
				 | 
				 | 
								} else if ($form->isEditing() && in_array($form->model()->status, [ProductStatus::UNAUDITED, ProductStatus::REFUSE])) { | 
				 | 
				 | 
								} else if ($form->isEditing() && in_array($form->model()->status, [ProductStatus::UNAUDITED, ProductStatus::REFUSE])) { | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
						
							
						
					
					
				 | 
				@ -598,9 +493,9 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
							}, $product); | 
				 | 
				 | 
							}, $product); | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							//组合产品编辑关键字段需要审核
 | 
				 | 
				 | 
							//组合产品编辑关键字段需要审核
 | 
			
		
		
	
		
			
				 | 
				 | 
							if ($form->isEditing() && $form->type == 1 && $form->model()->wasChanged(['title', 'pictures', 'know', 'content'])) { | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							/*if ($form->isEditing() && $form->type == 1 && $form->model()->wasChanged(['title', 'pictures', 'know', 'content'])) { | 
			
		
		
	
		
			
				 | 
				 | 
								$form->model()->update(['status' => ProductStatus::UNAUDITED]); | 
				 | 
				 | 
								$form->model()->update(['status' => ProductStatus::UNAUDITED]); | 
			
		
		
	
		
			
				 | 
				 | 
							} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							}*/ | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
							if ($form->isCreating()) { | 
				 | 
				 | 
							if ($form->isCreating()) { | 
			
		
		
	
		
			
				 | 
				 | 
								AgentProductItem::insert($insert_data); | 
				 | 
				 | 
								AgentProductItem::insert($insert_data); | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
						
							
						
					
					
				 | 
				@ -649,4 +544,167 @@ class AgentProductController extends AdminController | 
			
		
		
	
		
			
				 | 
				 | 
							AgentProductItem::query()->whereIn('agent_product_id',$ids)->delete(); | 
				 | 
				 | 
							AgentProductItem::query()->whereIn('agent_product_id',$ids)->delete(); | 
			
		
		
	
		
			
				 | 
				 | 
						}); | 
				 | 
				 | 
						}); | 
			
		
		
	
		
			
				 | 
				 | 
				    } | 
				 | 
				 | 
				    } | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					/** | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					 * 关联供应商规格 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					 * @param Form $form | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					 */ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					private function related_spec(&$form) | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					{ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						//关联供应商规格
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						$form->hasMany('spec', function (Form\NestedForm $form) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				//			$form->hidden('id'); hasMany时,ID会自动生成
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->hidden('product_spec_id'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->hidden('name')->saving(fn($v) => is_null($v) ? '' : $v); //必须加上这一句,自营产品规格才能正常保存
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->hidden('date'); //必须加上这一句,自营产品规格才能正常保存
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('supplier_name', '规格')->disable()->customFormat(fn() => $this->product_spec['name'] ?? '供应商已删除规格'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->date('supplier_date', '日期')->disable()->customFormat(fn() => $this->product_spec['date'] ?? '供应商已删除规格'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('supplier_stock', '供应商库存')->disable()->customFormat(fn() => $this->product_spec['stock'] ?? 0); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('supplier_cost_price', '供应商成本价')->disable()->customFormat(fn() => $this->product_spec['cost_price'] ?? 0); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('supplier_price', '建议销售价')->disable()->customFormat(fn() => $this->product_spec['price'] ?? 0); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('stock', '您的库存')->required() | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								//如果库存大于供应商库存,则取供应商库存
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								->customFormat(fn() => isset($this->product_spec['stock'], $this->stock) && $this->stock > $this->product_spec['stock'] ? $this->product_spec['stock'] : $this->stock); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('original_price', '您的市场价')->required(); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('price', '您的销售价')->required() | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								//如果代理商价格小于供应商建议售价,则取供应商售价
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								->customFormat(fn() => isset($this->product_spec['price'], $this->price) && $this->price < $this->product_spec['price'] ? $this->product_spec['price'] : $this->price); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						})->useTable(); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						Admin::style('.has-many-spec .add.btn{display:none;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec .field_supplier_date{width:100px!important;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec .col-md-12{padding:0;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec .form-group{margin-bottom:0;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec .form-group .remove{margin-top:10px;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec .input-group-prepend{display:none;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec .input-group>.form-control:not(:first-child){border-radius:.25rem;}'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					/** | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					 * 自营产品表单 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					 * @param Form $form | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					 */ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					private function self_form(&$form) | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					{ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						//信息收集表单
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						$options = DiyForm::where(['merchant_id' => Admin::user()->id, 'type' => 1])->pluck('name', 'id'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						if ($options->isEmpty()) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->select('diy_form_id', '信息收集表单') | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								->help('提示:信息收集表单为空,请前往“<a href="' . admin_url('diy_form') . '">信息收集表单</a>”处新增') | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								->options($options)->saving(fn($v) => is_null($v) ? 0 : $v); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						} else { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->select('diy_form_id', '信息收集表单')->options($options)->saving(fn($v) => is_null($v) ? 0 : $v); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						$form->text('title'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						$form->multipleImage('pictures')->removable(false)->uniqueName(); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						$form->editor('know'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						$form->editor('content'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						//自营产品规格
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						$form->hasMany('spec_self', '产品规格', function (Form\NestedForm $form) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('name', '规格')->readOnly(); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->date('date', '日期'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('stock', '库存'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('original_price', '市场价'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							$form->text('price', '销售价'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						})->useTable()->customFormat(fn() => $form->model()->spec); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						Admin::style('.has-many-spec_self .add.btn{display:none;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec_self .field_supplier_date{width:100px!important;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec_self .col-md-12{padding:0;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec_self .form-group{margin-bottom:0;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec_self .form-group .remove{margin-top:10px;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec_self .input-group-prepend{display:none;} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							.has-many-spec_self .input-group>.form-control:not(:first-child){border-radius:.25rem;}'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						//0:旅游线路、1:酒店、2:景区、3:餐厅、4:车队、5:单项
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						$form->radio('tpl_type', '产品模板')->disable($form->isEditing())->default(0) | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							->options([0 => '旅游线路', 1 => '酒店', 2 => '景区', 3 => '餐厅', 4 => '车队', 5 => '单项']) | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							->when(0, function (Form $form) { //旅游线路
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								if ($form->isEditing() && $form->model()->tpl_type != 0) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									return; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_0_departure_place', '出发地'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->map('extends.field_0_departure_place_latitude', 'extends.field_0_departure_place_longitude', '出发地位置'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_0_destination', '目的地'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->map('extends.field_0_destination_latitude', 'extends.field_0_destination_longitude', '目的地位置'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->table('extends.field_0_project', '包含项目', function (NestedForm $table) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('name', '字段1'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('num', '字段2'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('price', '字段3'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								})->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->dateRange('extends.field_0_date.start', 'extends.field_0_date.end', '行程时间'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							})->when(1, function (Form $form) { //酒店
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								if ($form->isEditing() && $form->model()->tpl_type != 1) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									return; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$default = [ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									['tag' => '行李寄存'], ['tag' => '24小时前台'], ['tag' => '前台保险柜'], ['tag' => '唤醒服务'], | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									['tag' => '早餐'], ['tag' => '送餐服务'], ['tag' => '电梯'], ['tag' => '空调'], | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									['tag' => '新风系统'], ['tag' => '24小时热水'], ['tag' => '吹风机'], ['tag' => '加湿器'], | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									['tag' => '自动售货机'], ['tag' => '健身房'], ['tag' => '桌球室'], ['tag' => '洗衣服务'] | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								]; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->table('extends.field_1_tags', '酒店设施', function (NestedForm $table) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('tag', '包含项目')->placeholder('如:24小时热水、干洗服务等'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								})->default($default)->help('首次创建时,系统会默认填充基本服务,请根据本酒店情况进行删减或新增'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_1_name', '酒店名'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_1_address', '地址'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->map('extends.field_1_latitude', 'extends.field_1_longitude', '位置'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							})->when(2, function (Form $form) { //景区
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								if ($form->isEditing() && $form->model()->tpl_type != 2) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									return; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->table('extends.field_2_open_time', '开放时间', function (NestedForm $table) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('node', '字段1')->placeholder('如:周一至周五'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('summer', '字段2')->placeholder('如:08:00~19:00'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('winter', '字段3')->placeholder('如:08:00~18:00'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								})->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->table('extends.field_2_project', '包含项目', function (NestedForm $table) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('name', '字段1'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('num', '字段2'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('price', '字段3'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								})->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_2_name', '景区名'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_2_address', '地址'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->map('extends.field_2_latitude', 'extends.field_2_longitude', '位置'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							})->when(3, function (Form $form) { //餐厅
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								if ($form->isEditing() && $form->model()->tpl_type != 3) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									return; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->table('extends.field_3_open_time', '开放时间', function (NestedForm $table) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('week', '字段1')->placeholder('如:周一至周五'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('section', '字段2')->placeholder('如:上午/下午'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('time', '字段3')->placeholder('如:08:00~18:00'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								})->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->table('extends.field_3_package', '包含套餐', function (NestedForm $table) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('name', '字段1')->placeholder('如:清蒸鱿鱼'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('num', '字段2')->placeholder('如:1条'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									$table->text('price', '字段3')->placeholder('如:99元'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								})->help('第一行数据默认是表头,如:项目名称、数量、额外费用'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_3_name', '餐厅名'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_3_address', '地址'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->map('extends.field_3_latitude', 'extends.field_3_longitude', '位置'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							})->when(4, function (Form $form) { //车队
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								if ($form->isEditing() && $form->model()->tpl_type != 4) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									return; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_4_address', '地址'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->map('extends.field_4_latitude', 'extends.field_4_longitude', '位置'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							})->when(5, function (Form $form) { //单项
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								if ($form->isEditing() && $form->model()->tpl_type != 5) { | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
									return; | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								} | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->text('extends.field_5_address', '地址'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
								$form->map('extends.field_5_latitude', 'extends.field_5_longitude', '位置'); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
							}); | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					} | 
			
		
		
	
		
			
				 | 
				 | 
				} | 
				 | 
				 | 
				} |