|
@@ -0,0 +1,317 @@
|
|
|
+@extends('admin.public.base')
|
|
|
+@section('body_class')
|
|
|
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
|
|
|
+@endsection
|
|
|
+@section('content')
|
|
|
+<form class="post-form" action="" method="post">
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">产品图片</label>
|
|
|
+ <div id="thumb">
|
|
|
+ <a id="thumb-image" href="#" data-toggle="image" class="img-thumb">
|
|
|
+ <img src="{{path_compat($oldData['thumb'])}}" height="100" />
|
|
|
+ </a>
|
|
|
+ <input type="hidden" name="thumb" value="{{$oldData['thumb']}}" id="input-image" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">产品海报</label>
|
|
|
+ <div id="poster">
|
|
|
+ <a id="poster-image" href="#" data-toggle="image" class="img-thumbnail">
|
|
|
+ <img src="{{path_compat($oldData['poster'])}}" height="100" />
|
|
|
+ </a>
|
|
|
+ <input type="hidden" name="poster" value="{{$oldData['poster']}}" id="input-poster" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">产品名称</label>
|
|
|
+ <input class="form-control" required="required" type="text" placeholder="产品名称" maxlength="50" name="name" value="{{$oldData['name']}}" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">折扣价格</label>
|
|
|
+ <input class="form-control" required="required" type="text" placeholder="折扣价格" min="0" max="9999.99" name="price" value="{{$oldData['price']}}" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">产品原价</label>
|
|
|
+ <input class="form-control" required="required" type="text" placeholder="产品原价" min="0" max="9999.99" name="market_price" value="{{$oldData['market_price']}}" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">产品规格</label>
|
|
|
+ <input class="form-control" required="required" type="text" placeholder="产品规格" maxlength="25" name="spec" value="{{$oldData['spec']}}" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">产品库存</label>
|
|
|
+ <input class="form-control" required="required" type="number" placeholder="产品库存" name="stock" value="{{$oldData['stock']}}" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">限购数量</label>
|
|
|
+ <input class="form-control" required="required" type="number" placeholder="限购数量,设置为0表示不限购" name="quota" value="{{$oldData['quota']}}" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">限购开始</label>
|
|
|
+ <input class="form-control" type="datetime-local" placeholder="限购开始时间" name="quota_start" value="{{date('Y-m-d H:i',$oldData['quota_start'])}}" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">限购结束</label>
|
|
|
+ <input class="form-control" type="datetime-local" placeholder="限购结束时间" name="quota_end" value="{{date('Y-m-d H:i',$oldData['quota_end'])}}" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">服务城市</label>
|
|
|
+ <select name="city_ids[]" class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索城市" data-none-results-text="未搜索到 {0}" title="选择城市" multiple>
|
|
|
+ @foreach ($cityList as $group)
|
|
|
+ <optgroup label="{{$group['name']}}">
|
|
|
+ @foreach ($group['city'] as $city)
|
|
|
+ <option value="{{$city['id']}}" @if(in_array($city['id'],$oldData['city_ids'])) selected @endif >{{$city['name']}}</option>
|
|
|
+ @endforeach
|
|
|
+ </optgroup>
|
|
|
+ @endforeach
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">商品类型</label>
|
|
|
+ <select name="type_id" class="form-control" id="typeId">
|
|
|
+ @foreach ($typeList as $value)
|
|
|
+ <option value="{{$value['id']}}" >{{$value['name']}}</option>
|
|
|
+ @endforeach
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">生产厂家</label>
|
|
|
+ <select name="producer_id" required class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索生产厂家" data-none-results-text="未搜索到 {0}" title="选择厂家">
|
|
|
+ @foreach ($producerList as $value)
|
|
|
+ <option value="{{$value['id']}}" @if( $value['id'] == $oldData['producer_id']) selected @endif >{{$value['name']}}</option>
|
|
|
+ @endforeach
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-2">
|
|
|
+ <label class="control-label">商业公司</label>
|
|
|
+ <select name="business_id" required class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索商业公司" data-none-results-text="未搜索到 {0}" title="选择商业公司">
|
|
|
+ @foreach ($businessList as $value)
|
|
|
+ <option value="{{$value['id']}}" @if( $value['id'] == $oldData['business_id']) selected @endif >{{$value['name']}}</option>
|
|
|
+ @endforeach
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-12" id="add_spec">
|
|
|
+ @foreach ($specList as $spec)
|
|
|
+ <div class="form-group col-sm-12">
|
|
|
+ <label class="control-label">{{$spec['name']}}</label>
|
|
|
+ <div class="form-group col-sm-12">
|
|
|
+ @if( empty($spec['attr_list']))
|
|
|
+ <div class="form-group col-sm-3 attr_div">
|
|
|
+ <div class="form-group form-inline">
|
|
|
+ <div class="input-group col-sm-4">
|
|
|
+ <!-- @if ($spec['has_img'])
|
|
|
+ <span class="input-group-addon btn-primary" data-toggle="image" style="cursor:pointer;" title="上传图片">
|
|
|
+ <i class="fa fa-file-photo-o"></i>
|
|
|
+ <input type="hidden" name="attr[{{$spec['id']}}][thumb][]" placeholder="图片路径">
|
|
|
+ </span>
|
|
|
+ @endif -->
|
|
|
+ <input type="{{$spec['input_type']}}" name="attr[{{$spec['id']}}][name][]" class="form-control attr_name" required="required" placeholder="属性" />
|
|
|
+ </div>
|
|
|
+ <div class="input-group col-sm-4">
|
|
|
+ <input type="text" class="form-control" name="attr[{{$spec['id']}}][remark][]" placeholder="备注" />
|
|
|
+ <span class="input-group-addon btn-danger remove_attr" style="cursor:pointer;">
|
|
|
+ <i class="fa fa-trash-o"></i>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ @else
|
|
|
+ @foreach ($spec['attr_list'] as $attr)
|
|
|
+ <div class="form-group col-sm-3 attr_div">
|
|
|
+ <div class="form-group form-inline">
|
|
|
+ <div class="input-group col-sm-4">
|
|
|
+ <!-- @if ($spec['has_img'])
|
|
|
+ <span class="input-group-addon btn-primary" data-toggle="image" style="cursor:pointer;" title="上传图片">
|
|
|
+ <i class="fa fa-file-photo-o"></i>
|
|
|
+ <input type="hidden" name="attr[{{$spec['id']}}][thumb][]" placeholder="图片路径" vlalue="value="{{$attr['thumb']}}" ">
|
|
|
+ </span>
|
|
|
+ @endif -->
|
|
|
+ <input type="{{$spec['input_type']}}" name="attr[{{$spec['id']}}][name][]" class="form-control attr_name" required="required" placeholder="属性" value="{{$attr['name']}}" />
|
|
|
+ </div>
|
|
|
+ <div class="input-group col-sm-4">
|
|
|
+ <input type="text" class="form-control" name="attr[{{$spec['id']}}][remark][]" placeholder="备注" value="{{$attr['remark']}}" />
|
|
|
+ <span class="input-group-addon btn-danger remove_attr" style="cursor:pointer;">
|
|
|
+ <i class="fa fa-trash-o"></i>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ @endforeach
|
|
|
+ @endif
|
|
|
+ <div class="form-group col-sm-3 add_attr_div">
|
|
|
+ <div class="form-group form-inline">
|
|
|
+ <div class="input-group">
|
|
|
+ <button type="button" class="form-control add_attr"><i class="ace-icon fa glyphicon-plus"></i>添加属性</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ @endforeach
|
|
|
+ @if( !$specList )
|
|
|
+ <script type="text/javascript">
|
|
|
+ $(function(){
|
|
|
+ // 获取
|
|
|
+ var type_id = $('#typeId').val();
|
|
|
+ // 获取对应的规格
|
|
|
+ getSpecHtml(type_id);
|
|
|
+ })
|
|
|
+ </script>
|
|
|
+ @endif
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-12" id="add_sku">
|
|
|
+ <div class="form-group col-sm-12">
|
|
|
+ <div class="table-responsive">
|
|
|
+ <table class="table table-striped table-bordered table-hover">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ @foreach ($specList as $value)
|
|
|
+ <th>{{$value['name']}}</th>
|
|
|
+ @endforeach
|
|
|
+ <th>价格</th>
|
|
|
+ <th>库存</th>
|
|
|
+ <th>是否上架</th>
|
|
|
+ <th>操作</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ @foreach ($skuList as $value)
|
|
|
+ <tr>
|
|
|
+ @foreach (explode(',',$value['attr_ids']) as $v)
|
|
|
+ <td>{{$v}}</td>
|
|
|
+ @endforeach
|
|
|
+ <td><input type="text" name="sku[{{$value['attr_ids']}}][price]" placeholder="价格" value="{{$value['price']}}"></td>
|
|
|
+ <td><input type="number" name="sku[{{$value['attr_ids']}}][stock]" placeholder="库存" value="{{$value['stock']}}"></td>
|
|
|
+ <td>
|
|
|
+ <select name="sku[{{$value['attr_ids']}}][status]" >
|
|
|
+ <option value="0" @if( $value['status'] == 0 ) selected @endif>上架</option>
|
|
|
+ <option value="1" @if( $value['status'] == 1 ) selected @endif>下架</option>
|
|
|
+ </select>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <button type="button" class="btn btn-xs btn-danger remove_sku">删除 </button>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ @endforeach
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <script type="text/javascript">
|
|
|
+ $(function(){
|
|
|
+ // 删除属性
|
|
|
+ $('#add_sku').on('click','.remove_sku',function(){
|
|
|
+ // 只有一个节点时(没有同级节点)。不允许删除
|
|
|
+ if( $(this).parents('tr').siblings('tr').length < 1 ) return false;
|
|
|
+ $(this).parents('tr').remove();
|
|
|
+ return false;
|
|
|
+ })
|
|
|
+ })
|
|
|
+ </script>
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-12">
|
|
|
+ <label class="control-label">产品简介</label>
|
|
|
+ <textarea required="required" name="description" id="container" placeholder="产品简介" maxlength="1500">{{$oldData['description']}}</textarea>
|
|
|
+ </div>
|
|
|
+ <div class="form-group col-sm-12">
|
|
|
+ @csrf
|
|
|
+ <input id="send" type="submit" value="提交" class="btn btn-primary btn-block" />
|
|
|
+ </div>
|
|
|
+</form>
|
|
|
+@endsection
|
|
|
+@section('javascript')
|
|
|
+<script src="/static/ueditor/ueditor.config.js"></script>
|
|
|
+<script src="/static/ueditor/ueditor.all.js"></script>
|
|
|
+<script type="text/javascript">
|
|
|
+ var editor = new UE.ui.Editor();
|
|
|
+ editor.render("container");
|
|
|
+</script>
|
|
|
+<script type="text/javascript">
|
|
|
+// 获取类型的规格
|
|
|
+function getSpecHtml(type_id){
|
|
|
+ $.ajax({
|
|
|
+ type: 'get',
|
|
|
+ url: "{{url('admin/product/get_spec_html')}}",
|
|
|
+ data: {type_id:type_id},
|
|
|
+ success: function(data) {
|
|
|
+ $('#add_spec').html(data);
|
|
|
+ },
|
|
|
+ error: function(data) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 获取节点
|
|
|
+$(function(){
|
|
|
+ $('#typeId').change(function(){
|
|
|
+ // 获取
|
|
|
+ var type_id = $('#typeId').val();
|
|
|
+ // 获取对应的规格
|
|
|
+ getSpecHtml(type_id);
|
|
|
+ })
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
+<script type="text/javascript">
|
|
|
+ $(function(){
|
|
|
+ // 添加属性
|
|
|
+ $('#add_spec').on('click','.add_attr',function(){
|
|
|
+ // 克隆
|
|
|
+ var copy = $(this).parents('.add_attr_div').prev().clone();
|
|
|
+ $(this).parents('.add_attr_div').before(copy);
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ // 删除属性
|
|
|
+ $('#add_spec').on('click','.remove_attr',function(){
|
|
|
+ // 只有一个节点时(没有同级节点)。不允许删除
|
|
|
+ // if( $(this).parents('.attr_div').siblings('.attr_div').length < 1 ) return false;
|
|
|
+ $(this).parents('.attr_div').remove();
|
|
|
+ var formData = $('#add_spec input,select').serialize();
|
|
|
+ $.ajax({
|
|
|
+ type: 'get',
|
|
|
+ url: "{{url('admin/product/get_sku_html?product_id='.$oldData['id'])}}",
|
|
|
+ data: formData,
|
|
|
+ success: function(data) {
|
|
|
+ $('#add_sku').html(data);
|
|
|
+ },
|
|
|
+ error: function(data) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ })
|
|
|
+ // 属性名称变更
|
|
|
+ $('#add_spec').on('change','.attr_name',function(){
|
|
|
+ // 获取当前的名称
|
|
|
+ var name = $(this).val();
|
|
|
+ var formData = $('#add_spec input,select').serialize();
|
|
|
+ $.ajax({
|
|
|
+ type: 'get',
|
|
|
+ url: "{{url('admin/product/get_sku_html?product_id='.$oldData['id'])}}",
|
|
|
+ data: formData,
|
|
|
+ success: function(data) {
|
|
|
+ $('#add_sku').html(data);
|
|
|
+ },
|
|
|
+ error: function(data) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ })
|
|
|
+ })
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/javascript">
|
|
|
+ $(function(){
|
|
|
+ // 删除规格
|
|
|
+ $('#add_sku').on('click','.remove_sku',function(){
|
|
|
+ // 只有一个节点时(没有同级节点)。不允许删除
|
|
|
+ // if( $(this).parents('tr').siblings('tr').length < 1 ) return false;
|
|
|
+ $(this).parents('tr').remove();
|
|
|
+ return false;
|
|
|
+ })
|
|
|
+ })
|
|
|
+</script>
|
|
|
+@endsection
|