diff --git a/public/static/admin/default/js/common.js b/public/static/admin/default/js/common.js index b721993c7..9f7d5bcf1 100644 --- a/public/static/admin/default/js/common.js +++ b/public/static/admin/default/js/common.js @@ -14,30 +14,33 @@ FromInit('form.form-validation-store-accounts'); */ function ParametersItemHtmlCreated(type, name, value) { + // 参数容器 + var $parameters_table = $('.parameters-table'); + + // 拼接html var index = parseInt(Math.random()*1000001); var html = ''; html += ''; - html += ''; + html += ''; + html += ''; + html += ''; html += ''; html += ''; html += ''; - html += ''; + html += ''; html += ''; html += ''; - html += ''; + html += ''; html += ''; html += ''; - html += '上移 '; - html += '下移 '; - html += '移除'; + html += ''+$parameters_table.data('move-top-name')+' '; + html += ''+$parameters_table.data('move-bottom-name')+' '; + html += ''+$parameters_table.data('remove-name')+''; html += ''; html += ''; // 数据添加 - var $parameters_table = $('.parameters-table'); $parameters_table.append(html); // select组件初始化 @@ -45,7 +48,7 @@ function ParametersItemHtmlCreated(type, name, value) inherit_select_classes: true, enable_split_word_search: true, search_contains: true, - no_results_text: '没有匹配到结果' + no_results_text: lang_chosen_select_no_results_text }); } @@ -237,14 +240,36 @@ $(function() StoreAccountsPopupOpen(); }); + // 商品规格和参数拖拽排序 + if($('table.specifications-table').length > 0) + { + $('table.specifications-table tbody').dragsort({ dragSelector: 'tr'}); + } + if($('table.parameters-table').length > 0) + { + var len = $('table.parameters-table tbody tr').length; + if(len == 0) + { + $('table.parameters-table tbody').html(''); + } + $('table.parameters-table tbody').dragsort({ dragSelector: 'tr'}); + if(len == 0) + { + $('table.parameters-table tbody').html(''); + } + } + // 商品规格和参数上下移动 $('.specifications-table,.parameters-table').on('click', '.line-move', function() { + // 父级table + var $table = $(this).parents('table'); + // 类型 var type = $(this).data('type') || null; if(type == null) { - Prompt('操作类型配置有误'); + Prompt($table.data('move-type-tips') || '操作类型配置有误'); return false; } @@ -258,7 +283,7 @@ $(function() case 'top' : if(index == 0) { - Prompt('已到最顶部'); + Prompt($table.data('move-top-tips') || '已到最顶部'); return false; } $parent.prev().insertAfter($parent); @@ -268,7 +293,7 @@ $(function() case 'bottom' : if(index >= count-1) { - Prompt('已到最底部'); + Prompt($table.data('move-bottom-tips') || '已到最底部'); return false; } $parent.next().insertBefore($parent); @@ -276,7 +301,7 @@ $(function() // 默认 default : - Prompt('操作类型配置有误'); + Prompt($table.data('move-type-tips') || '操作类型配置有误'); } }); @@ -295,7 +320,7 @@ $(function() }); // 商品参数配置信息复制 - var $parameters_copy_modal = $('#parameters-quick-copy-modal'); + var $quick_modal = $('#parameters-quick-copy-modal'); var clipboard = new ClipboardJS('.parameters-quick-copy', { text: function() @@ -311,24 +336,24 @@ $(function() }); }); data = JSON.stringify(data); - $parameters_copy_modal.find('textarea').val(data); + $quick_modal.find('textarea').val(data); return data; } }); clipboard.on('success', function(e) { - Prompt('复制成功', 'success'); + Prompt($parameters_table.data('copy-success-tips') || '复制成功', 'success'); }); clipboard.on('error', function(e) { // 复制失败则开启复制窗口,让用户自己复制 - $parameters_copy_modal.modal({ + $quick_modal.modal({ width: 200, height: 135 }); }); // 点击选中复制的值 - $parameters_copy_modal.find('textarea').on('click', function() + $quick_modal.find('textarea').on('click', function() { $(this).select(); }); @@ -341,7 +366,7 @@ $(function() var data = $parameters_quick_config.find('textarea').val() || null; if(data == null) { - Prompt('请先粘贴配置信息'); + Prompt($parameters_table.data('copy-no-tips') || '请先粘贴配置信息'); return false; } @@ -349,12 +374,12 @@ $(function() try { data = JSON.parse(data); } catch(e) { - Prompt('配置格式错误'); + Prompt($parameters_table.data('copy-error-tips') || '配置格式错误'); return false; } if(data.length <= 0) { - Prompt('配置为空'); + Prompt($parameters_table.data('copy-empty-tips') || '配置为空'); return false; } @@ -368,7 +393,7 @@ $(function() ParametersItemHtmlCreated(type, name, value); } $('#parameters-quick-container').dropdown('close'); - Prompt('生成成功', 'success'); + Prompt($parameters_table.data('created-success-tips') || '生成成功', 'success'); }); // 商品参数清空 diff --git a/public/static/admin/default/js/goods.js b/public/static/admin/default/js/goods.js index d649e2cf9..d1f15ccb4 100755 --- a/public/static/admin/default/js/goods.js +++ b/public/static/admin/default/js/goods.js @@ -1,3 +1,6 @@ +// 规格容器 +var $spec_table = $('table.specifications-table'); + /** * 笛卡尔积生成规格 * @author Devil @@ -88,10 +91,10 @@ $(function() // 规格列添加 $('.specifications-nav-title-add').on('click', function() { - var spec_max = $('#goods-nav-operations').data('spec-add-max-number') || 3; + var spec_max = $spec_table.data('spec-add-max-number') || 3; if($('.specifications-table th.table-title').length >= spec_max) { - Prompt('最多添加'+spec_max+'列规格,可在后台管理[系统设置-后台配置]中配置'); + Prompt($spec_table.data('spec-max-error')); return false; } @@ -99,13 +102,13 @@ $(function() var index = parseInt(Math.random()*1000001); html = ''; html += '×'; - html += ''; + html += ''; html += ''; $('.title-start').before(html); // value html = ''; - html += ''; + html += ''; html += ''; $('.value-start').before(html); }); @@ -122,7 +125,7 @@ $(function() // 防止用户操作删除了第一条数据、首行移除指定class ($('.specifications-table tr.line-not-first').length >= $('.specifications-table tr').length) { - $('.specifications-table').find('tbody tr:first').removeClass('line-not-first'); + $spec_table.find('tbody tr:first').removeClass('line-not-first'); } // 移除多余的规格行 @@ -135,18 +138,18 @@ $(function() { if($('.specifications-table th.table-title').length <= 0) { - Prompt('请先添加规格'); + Prompt($spec_table.data('spec-empty-data-tips') || '请先添加规格'); return false; } var index = parseInt(Math.random()*1000001); - var html = $('.specifications-table').find('tbody tr:last').prop('outerHTML'); - $('.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 html = $spec_table.find('tbody tr:last').prop('outerHTML'); + $spec_table.append(html); + $spec_table.find('tbody tr:last').attr('class', 'line-'+index+' line-not-first'); + $spec_table.find('tbody tr:last').attr('data-line-tag', '.line-'+index); // 值赋空 - $('.specifications-table').find('tbody tr:last').find('input').each(function(k, v) + $spec_table.find('tbody tr:last').find('input').each(function(k, v) { $(this).attr('value', ''); }); @@ -158,7 +161,7 @@ $(function() // 是否存在规格名称 if($('.specifications-table th.table-title').length <= 0) { - Prompt('请先添加规格'); + Prompt($spec_table.data('spec-empty-data-tips') || '请先添加规格'); return false; } @@ -170,8 +173,8 @@ $(function() $(this).attr('value', $(this).val()); }); $parent.after($parent.prop('outerHTML')); - $('.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); + $spec_table.find('tbody tr:last').attr('class', 'line-'+index+' line-not-first'); + $spec_table.find('tbody tr:last').attr('data-line-tag', '.line-'+index); }); // 规格行移除 @@ -180,7 +183,7 @@ $(function() // 不能全部移除,至少需要保留一行 if($('.specifications-table tbody tr').length <= 1) { - Prompt('至少需要保留一行规格值'); + Prompt($spec_table.data('spec-min-tips-message') || '至少需要保留一行规格值'); return false; } @@ -202,7 +205,7 @@ $(function() // 是否存在规格 if($('.specifications-table th.table-title').length <= 0) { - Prompt('请先添加规格'); + Prompt($spec_table.data('spec-empty-data-tips' || '请先添加规格')); return false; } @@ -210,15 +213,15 @@ $(function() var index = parseInt(Math.random()*1000001); var temp_class = 'spec-images-items-'+index; var html = '
  • '; - html += '' + html += '' html += ''; - html += '
    +上传图片
    '; + html += '
    +'+$spec_table.data('spec-images-name')+'
    '; html += '
  • '; $('.spec-images-list ul.spec-images-content').append(html); }); @@ -236,7 +239,7 @@ $(function() var spec_count = $('.specifications-table th.table-title').length || 0; if(spec_count <= 0) { - Prompt('请先添加规格'); + Prompt($spec_table.data('spec-empty-data-tips') || '请先添加规格'); return false; } @@ -262,7 +265,7 @@ $(function() }); if(data.length <= 0) { - Prompt('请先填写规格'); + Prompt($spec_table.data('spec-empty-fill-tips') || '请先填写规格'); return false; } @@ -289,15 +292,15 @@ $(function() var index = parseInt(Math.random()*1000001); var temp_class = 'spec-images-items-'+index; var html = '
  • '; - html += '' + html += '' html += ''; - html += '
    +上传图片
    '; + html += '
    +'+$spec_table.data('spec-images-name')+'
    '; html += '
  • '; $('.spec-images-list ul.spec-images-content').append(html); } @@ -383,7 +386,7 @@ $(function() }); if(title.length < $('.specifications-table th.table-title').length) { - Prompt('请填写规格名称'); + Prompt($spec_table.data('spec-type-message') || '请填写规格名称'); return false; } @@ -408,8 +411,8 @@ $(function() { html += '
    '; html += ''; - html += ''; + html += ''; for(var k in data[i]) { html += ''; @@ -431,7 +434,7 @@ $(function() inherit_select_classes: true, enable_split_word_search: true, search_contains: true, - no_results_text: '没有匹配到结果' + no_results_text: lang_chosen_select_no_results_text }); // 所有input赋空 @@ -486,40 +489,34 @@ $(function() // 手机详情添加 $(document).on('click', '.content-app-items-add-sub', function() { - var $content_tag = $('.content-app-items'); - - var i = (($(this).attr('index') || null) == null) ? parseInt($content_tag.find('li').length) : parseInt($(this).attr('index')); + var $app_content = $('#goods-nav-app .content-app-items'); + var i = (($(this).attr('index') || null) == null) ? parseInt($app_content.find('li').length) : parseInt($(this).attr('index')); var index = parseInt(Math.random()*1000001)+i; - - var images_name = $content_tag.data('images-name'); - var content_name = $content_tag.data('content-name'); - var images_text = $content_tag.data('images-text'); - var content_text = $content_tag.data('content-text'); - var delete_text = $content_tag.data('delete-text'); - var drag_sort_text = $content_tag.data('drag-sort-text'); - + var images_name = $app_content.data('images-name'); + var content_name = $app_content.data('content-name'); + // html拼接 var html = '
  • '; // 左侧 html += '
    '; - html += ''; + html += ''; html += '
      '; html += '
    '; - html += '
    +上传图片
    '; + html += '
    +'+$app_content.data('images-name')+'
    '; html += '
    '; // 右侧 html += '
    '; - html += ''; - html += ''; + html += ''; + html += ''; html += '
    '; html += '
    '; // 操作按钮 - html += '删除'; - html += ' 拖拽排序'; + html += ''+$app_content.data('delete-name')+''; + html += ' '+$app_content.data('drag-name')+''; html += '
  • '; - $content_tag.append(html); - $content_tag.attr('index', index); + $app_content.append(html); + $app_content.attr('index', index); $(this).attr('index', i+1); }); @@ -531,7 +528,7 @@ $(function() // 拖拽 $('ul.goods-photo-view').dragsort({ dragSelector: 'li', placeHolderTemplate: '
  • '}); - $('ul.content-app-items').dragsort({ dragSelector: 'i.drag-sort-submit', placeHolderTemplate: '
  • '}); + $('ul.content-app-items').dragsort({ dragSelector: 'a.drag-sort-submit', placeHolderTemplate: '
  • '}); // 规格扩展数据编辑 @@ -553,10 +550,10 @@ $(function() // 规格快捷操作 - 规格列添加 $('.quick-spec-title-add').on('click', function() { - var spec_max = $('#goods-nav-operations').data('spec-add-max-number') || 3; + var spec_max = $spec_table.data('spec-add-max-number') || 3; if($('.spec-quick table tbody tr').length >= spec_max) { - Prompt('最多添加'+spec_max+'列规格,可在后台管理[系统设置-后台配置]中配置'); + Prompt($spec_table.data('spec-max-error')); return false; } @@ -564,11 +561,11 @@ $(function() var html = ''; html += ''; html += '×'; - html += ''; + html += ''; html += ''; html += ''; html += '
    '; - html += '+ 添加规格值'; + html += '+ '+$spec_table.data('spec-add-value-message')+''; html += '
    '; html += ''; html += ''; @@ -581,7 +578,7 @@ $(function() { var index = $(this).data('index'); var html = '
    '; - html += ''; + html += ''; html += '×'; html += '
    '; $(this).parent().before(html); @@ -634,14 +631,14 @@ $(function() // 是否存在规格 if(spec.length <= 0) { - Prompt('快捷操作规格为空'); + Prompt($spec_table.data('spec-quick-error') || '快捷操作规格为空'); return false; } // 操作确认 AMUI.dialog.confirm({ - title: '温馨提示', - content: '生成规格将清空现有规格数据、是否继续?', + title: $spec_table.data('spec-quick-tips-title'), + content: $spec_table.data('spec-quick-tips-msg'), onConfirm: function(options) { // 移除所有规格列 @@ -654,13 +651,13 @@ $(function() // title html = ''; html += '×'; - html += ''; + html += ''; html += ''; $('.title-start').before(html); // value html = ''; - html += ''; + html += ''; html += ''; $('.value-start').before(html); } @@ -671,24 +668,24 @@ $(function() { // 添加规格值 var index = parseInt(Math.random()*1000001); - var html = $('.specifications-table').find('tbody tr:last').prop('outerHTML'); - $('.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 html = $spec_table.find('tbody tr:last').prop('outerHTML'); + $spec_table.append(html); + $spec_table.find('tbody tr:last').attr('class', 'line-'+index+' line-not-first'); + $spec_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]); + $spec_table.find('tbody tr:last').find('td:eq('+k+') input').val(temp_spec[k]); } } // 清空扩展数据 $('.specifications-table .line-extend-input').val(''); - Prompt('生成成功', 'success'); + Prompt($spec_table.data('spec-quick-success') || '生成成功', 'success'); }, onCancel: function(){} }); diff --git a/public/static/common/js/common.js b/public/static/common/js/common.js index 3f9136588..02852f294 100755 --- a/public/static/common/js/common.js +++ b/public/static/common/js/common.js @@ -2763,7 +2763,7 @@ $(function() inherit_select_classes: true, enable_split_word_search: true, search_contains: true, - no_results_text: '没有匹配到结果' + no_results_text: lang_chosen_select_no_results_text }); } // 多选插件 空内容失去焦点验证bug兼容处理