diff --git a/application/admin/view/default/goods/save_info.html b/application/admin/view/default/goods/save_info.html
index 6a4d5fa81..fadb8aab7 100755
--- a/application/admin/view/default/goods/save_info.html
+++ b/application/admin/view/default/goods/save_info.html
@@ -355,10 +355,11 @@
+添加一行
- +添加规格图片
规格名称与规格值保持一致,相同规格名称添加一次即可,重复添加则后面覆盖前面,顺序不影响前端展示效果。
+ +添加规格图片
+ +第列规格自动生成
{{if !empty($specifications['type'])}}
{{foreach $specifications.type as $type}}
diff --git a/public/static/admin/default/css/goods.css b/public/static/admin/default/css/goods.css
index 0e951a599..cea7b5446 100755
--- a/public/static/admin/default/css/goods.css
+++ b/public/static/admin/default/css/goods.css
@@ -98,13 +98,8 @@
background: #eaeaea;
cursor: pointer;
}
-.goods-nav-retract {
- /*right: -110px;*/
-}
.goods-nav-retract .nav-shrink-submit {
position: absolute;
- /*left: -50px;*/
- /*width: 50px;*/
}
/**
@@ -167,6 +162,10 @@
.specifications-table thead th i {
cursor: pointer;
}
+.specifications-line-images-auto-add input {
+ width: 30px !important;
+ padding: 1px !important;
+}
/**
diff --git a/public/static/admin/default/js/goods.js b/public/static/admin/default/js/goods.js
index 61239f8ad..cca761e5f 100755
--- a/public/static/admin/default/js/goods.js
+++ b/public/static/admin/default/js/goods.js
@@ -175,6 +175,7 @@ $(function()
// 添加规格图片
$('.specifications-line-images-add').on('click', function()
{
+ // 是否存在规格
if($('.specifications-table th.table-title').length <= 0)
{
Prompt('请先添加规格');
@@ -204,6 +205,115 @@ $(function()
$(this).parents('li.spec-images-items').remove();
});
+ // 规格图片自动添加
+ $('.specifications-line-images-auto-add').on('click', function()
+ {
+ // 是否存在规格
+ var spec_count = $('.specifications-table th.table-title').length || 0;
+ if(spec_count <= 0)
+ {
+ Prompt('请先添加规格');
+ return false;
+ }
+
+ // 获取第一列规格名称
+ var data = [];
+ var index = parseInt($(this).find('input').val()) || 1;
+ if(index <= 0)
+ {
+ index = 1;
+ }
+ if(index > spec_count)
+ {
+ index = spec_count;
+ }
+ index -= 1;
+ $('.specifications-table tbody tr').each(function(k, v)
+ {
+ var value = $(this).find('td').eq(index).find('input').val() || null;
+ if(value != null && data.indexOf(value) == -1)
+ {
+ data.push(value);
+ }
+ });
+
+ // 创建图片规格
+ if(data.length > 0)
+ {
+ // 获取已存在规格图片
+ var data_old = [];
+ $('ul.spec-images-list li.spec-images-items').each(function(k, v)
+ {
+ var value = $(this).find('input').val() || null;
+ if(value != null && data_old.indexOf(value) == -1)
+ {
+ data_old.push(value);
+ }
+ });
+
+ // 循环添加
+ for(var i in data)
+ {
+ // 开始添加,不存在则不添加
+ if(data_old.indexOf(data[i]) == -1)
+ {
+ var index = parseInt(Math.random()*1000001);
+ var temp_class = 'spec-images-items-'+index;
+ var html = '- ';
+ html += ''
+ html += '';
+ html += '
+上传图片
';
+ html += ' ';
+ $('ul.spec-images-list').append(html);
+ }
+ }
+
+ // 原始图片规格不存在指定规格列中则移除
+ for(var i in data_old)
+ {
+ if(data.indexOf(data_old[i]) == -1)
+ {
+ $('ul.spec-images-list li.spec-images-items').each(function(k, v)
+ {
+ var value = $(this).find('input').val() || null;
+ if(value == data_old[i])
+ {
+ $(this).remove();
+ }
+ });
+ }
+ }
+ }
+ });
+
+ // 自动添加图片规格input输入值处理
+ $('.specifications-line-images-auto-add input').on('blur', function()
+ {
+ var value = parseInt($(this).val()) || 1;
+ if(value <= 0)
+ {
+ value = 1;
+ }
+ var spec_count = $('.specifications-table th.table-title').length || 0;
+ if(value > spec_count)
+ {
+ value = spec_count;
+ }
+ $(this).val(value);
+ });
+
+ // 自动添加图片规格input禁止冒泡
+ $('.specifications-line-images-auto-add input').on('click', function()
+ {
+ return false;
+ });
+
// 规格批量操作-开启
var $spec_modal = $('#spec-modal-all-operation');
$('.specifications-table thead th i').on('click', function()
@@ -377,48 +487,57 @@ $(function()
return false;
}
- // 移除所有规格列
- $('.specifications-table .title-nav-remove').trigger('click');
-
- // 添加规格列
- for(var i in spec)
- {
- var index = parseInt(Math.random()*1000001);
- // title
- html = '';
- html += '×';
- html += '';
- html += ' | ';
- $('.title-start').before(html);
-
- // value
- html = '';
- html += '';
- html += ' | ';
- $('.value-start').before(html);
- }
-
- // 自动生成规格
- var data = SpecCartesian(spec);
- for(var i=1; i') >= 0)
+ // 操作确认
+ AMUI.dialog.confirm({
+ title: '温馨提示',
+ content: '生成规格将清空现有规格数据、是否继续?',
+ onConfirm: function(options)
{
- html = html.replace(//ig, '复制 移除');
- }
- $('.specifications-table').append(html);
- $('.specifications-table').find('tbody tr:last').attr('class', 'line-'+index+' line-not-first');
- $('.specifications-table').find('tbody tr:last').attr('data-line-tag', '.line-'+index);
+ // 移除所有规格列
+ $('.specifications-table .title-nav-remove').trigger('click');
+
+ // 添加规格列
+ for(var i in spec)
+ {
+ var index = parseInt(Math.random()*1000001);
+ // title
+ html = '';
+ html += '×';
+ html += '';
+ html += ' | ';
+ $('.title-start').before(html);
- // 规格值
- var temp_spec = data[i].split(',');
- for(var k in temp_spec)
- {
- // 规格值赋值
- $('.specifications-table').find('tbody tr:last').find('td:eq('+k+') input').val(temp_spec[k]);
- }
- }
+ // value
+ html = '';
+ html += '';
+ html += ' | ';
+ $('.value-start').before(html);
+ }
+
+ // 自动生成规格
+ var data = SpecCartesian(spec);
+ for(var i=1; i') >= 0)
+ {
+ html = html.replace(//ig, '复制 移除');
+ }
+ $('.specifications-table').append(html);
+ $('.specifications-table').find('tbody tr:last').attr('class', 'line-'+index+' line-not-first');
+ $('.specifications-table').find('tbody tr:last').attr('data-line-tag', '.line-'+index);
+
+ // 规格值
+ var temp_spec = data[i].split(',');
+ for(var k in temp_spec)
+ {
+ // 规格值赋值
+ $('.specifications-table').find('tbody tr:last').find('td:eq('+k+') input').val(temp_spec[k]);
+ }
+ }
+ },
+ onCancel: function(){}
+ });
});
});
\ No newline at end of file