提交 74dae375 编写于 作者: D devil_gong

商品规格快捷操作

上级 89912973
......@@ -168,10 +168,14 @@
<!-- 规格 -->
<div id="goods-nav-operations" class="division-block" data-spec-add-max-number="{{:MyC('common_spec_add_max_number', 3, true)}}">
<label class="block nav-detail-title">商品规格</label>
<!-- 规格快捷操作 -->
<div class="spec-quick am-margin-bottom-lg">
<div class="am-alert am-alert-warning am-radius" data-am-alert>
快捷操作可以快速创建商品SKU,大量节省SKU编辑时间,快捷操作数据不影响SKU数据,仅生成的时候重新覆盖SKU。
</div>
<span class="business-operations-submit quick-spec-title-add">+快捷操作</span>
<span class="business-operations-submit am-margin-left-sm am-icon-gg quick-spec-created">生成规格</span>
<div class="goods-specifications" style="display: none;">
<div class="goods-specifications" {{if empty($data['spec_base'])}}style="display: none;"{{/if}}>
<table class="am-table am-table-bordered am-table-centered">
<thead>
<tr>
......@@ -179,11 +183,35 @@
<th class="spec-quick-th-value">规格值</th>
</tr>
</thead>
<tbody></tbody>
<tbody>
{{if !empty($data['spec_base'])}}
{{foreach $data.spec_base as $spec_base_key=>$spec_base}}
<tr>
<td class="am-text-middle">
<i class="am-close am-close-spin quick-title-remove">×</i>
<input type="text" value="{{$spec_base.title}}" name="spec_base_title_{{$spec_base_key}}" placeholder="规格名" />
</td>
<td class="spec-quick-td-value am-cf">
{{if !empty($spec_base['value'])}}
{{foreach $spec_base.value as $value}}
<div class="am-fl am-margin-xs value-item">
<input type="text" class="am-fl" name="spec_base_value_{{$spec_base_key}}[]" value="{{$value}}" placeholder="规格值" />
<i class="am-close am-close-spin quick-value-remove">×</i>
</div>
{{/foreach}}
{{/if}}
<div class="am-fl am-margin-xs value-item am-text-left"><span class="business-operations-submit quick-spec-value-add" data-index="{{$spec_base_key}}">+添加规格值</span>
</div>
</td>
</tr>
{{/foreach}}
{{/if}}
</tbody>
</table>
</div>
</div>
<!-- 规格常规操作 -->
<span class="business-operations-submit specifications-nav-title-add">+添加规格</span>
<div class="goods-specifications">
<!-- 规格批量操作弹层 -->
......
......@@ -396,6 +396,12 @@ class GoodsService
}
}
// 规格基础
if(isset($v['spec_base']))
{
$v['spec_base'] = empty($v['spec_base']) ? '' : json_decode($v['spec_base'], true);
}
// 获取规格
if($is_spec && !empty($v['id']))
{
......@@ -1064,7 +1070,14 @@ class GoodsService
return DataReturn($ret, -1);
}
// 规格
// 规格基础
$specifications_base = self::GetFormGoodsSpecificationsBaseParams($params);
if($specifications_base['code'] != 0)
{
return $specifications_base;
}
// 规格值
$specifications = self::GetFormGoodsSpecificationsParams($params);
if($specifications['code'] != 0)
{
......@@ -1120,6 +1133,7 @@ class GoodsService
'seo_keywords' => empty($params['seo_keywords']) ? '' : $params['seo_keywords'],
'seo_desc' => empty($params['seo_desc']) ? '' : $params['seo_desc'],
'is_exist_many_spec' => empty($specifications['data']['title']) ? 0 : 1,
'spec_base' => empty($specifications_base['data']) ? '' : json_encode($specifications_base['data']),
];
// 商品保存处理钩子
......@@ -1245,7 +1259,7 @@ class GoodsService
}
/**
* 获取规格参数
* 获取规格参数
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
......@@ -1416,6 +1430,32 @@ class GoodsService
return DataReturn('success', 0, ['data'=>$data, 'title'=>$title, 'images'=>$images]);
}
/**
* 获取规格基础参数
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-09-23
* @desc description
* @param [array] $params [输入参数]
*/
private static function GetFormGoodsSpecificationsBaseParams($params = [])
{
$result = [];
foreach($params as $k=>$v)
{
if(substr($k, 0, 16) == 'spec_base_title_')
{
$key = substr($k, 16);
$result[] = [
'title' => $v,
'value' => isset($params['spec_base_value_'.$key]) ? $params['spec_base_value_'.$key] : [],
];
}
}
return DataReturn('success', 0, $result);
}
/**
* 获取商品相册
* @author Devil
......
......@@ -19,7 +19,7 @@ return [
// 应用地址
'app_host' => '',
// 应用调试模式
'app_debug' => false,
'app_debug' => true,
// 应用Trace
'app_trace' => false,
// 是否支持多模块
......
此差异已折叠。
......@@ -307,14 +307,15 @@ $(function()
return false;
}
var index = parseInt(Math.random()*1000001);
var html = '<tr>';
html += '<td class="am-text-middle">';
html += '<i class="am-close am-close-spin quick-title-remove" data-index="168">×</i>';
html += '<input type="text" name="spec_quick_title_0" placeholder="规格名" />';
html += '<i class="am-close am-close-spin quick-title-remove">×</i>';
html += '<input type="text" name="spec_base_title_'+index+'" placeholder="规格名" />';
html += '</td>';
html += '<td class="spec-quick-td-value am-cf">';
html += '<div class="am-fl am-margin-xs value-item am-text-left">';
html += '<span class="business-operations-submit quick-spec-value-add">+添加规格值</span>';
html += '<span class="business-operations-submit quick-spec-value-add" data-index="'+index+'">+添加规格值</span>';
html += '</div>';
html += '</td>';
html += '</tr>';
......@@ -325,9 +326,10 @@ $(function()
// 添加规格值
$(document).on('click', '.spec-quick table .quick-spec-value-add', function()
{
var index = $(this).data('index');
var html = '<div class="am-fl am-margin-xs value-item">';
html += '<input type="text" class="am-fl" name="spec_quick_value_0" placeholder="规格值" />';
html += '<i class="am-close am-close-spin quick-value-remove" data-index="168">×</i>';
html += '<input type="text" class="am-fl" name="spec_base_value_'+index+'[]" placeholder="规格值" />';
html += '<i class="am-close am-close-spin quick-value-remove">×</i>';
html += '</div>';
$(this).parent().before(html);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册