123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- {include file="public/layout" /}
-
- <body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;min-width: auto;">
- <div id="append_parent"></div>
- <div id="ajaxwaitid"></div>
- <div class="page" style="min-width: auto;box-shadow:none;">
- <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); padding-right: 0px; height: 100%;">
- <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
- <h4 title="提示相关设置操作时应注意的要点">提示</h4>
- <span title="收起提示" id="explanationZoom" style="display: block;"></span>
- </div>
- <ul>
- <li>1、新增规格模板,方便管理员快捷选择商品规格复制到商品发布页里</li>
- <li>2、在规格库里编辑,修改,删除商品规格模板并<i style="color: red;">不影响</i>已发布的商品里的规格值</li>
- <li>3、如果编辑商品规格时需要和规格库里规格模板一致,可以点击规格值右侧的刷新按钮 <i class="fa fa-refresh"></i> 同步</li>
- </ul>
- </div>
- <div class="flexigrid">
- <div class="hDiv">
- <div class="hDivBox">
- <table cellspacing="0" cellpadding="0" style="width: 100%">
- <thead>
- <tr>
- <th class="sign w10" axis="col0">
- <div class="tc"></div>
- </th>
- <th abbr="article_time" axis="col4" class="w180">
- <div class="text-l10">规格名称</div>
- </th>
- <th abbr="ac_id" axis="col4">
- <div class="text-l10">规格值</div>
- </th>
- <th abbr="article_time" axis="col6" class="w100">
- <div class="tc">是否同步</div>
- </th>
- <th abbr="article_time" axis="col6" class="w60">
- <div class="tc">排序</div>
- </th>
- </tr>
- </thead>
- </table>
- </div>
- </div>
- <div class="bDiv" style="height: auto;">
- <form id="PostForm">
- <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
- <table style="width: 100%">
- <input type="hidden" name="mark_preset_ids" id='mark_preset_ids'>
- <input type="hidden" name="mark_mark_ids" id='mark_mark_ids'>
- <tbody id='Template'>
- {volist name="info" id="vo"}
- <tr class="tr" id="tr_{$vo.preset_mark_id}">
- <td class="sign">
- <div class="w10 tc">
- <input type="hidden" name="preset_old[]" value="{$vo.preset_mark_id}">
- </div>
- </td>
-
- <td class="">
- <div class="w180 tc preset-bt3" style="text-align: left;">
- <span>
- <input type="text" name="preset_name_old_{$vo.preset_mark_id}[]" placeholder="请输入规格名称" onchange="MarkMarkId('{$vo.preset_mark_id}');" value="{$vo.preset_name}">
- <em data-id="tr_{$vo.preset_mark_id}" onclick="DelSpecTpl(this, '{$vo.preset_mark_id}')"><i style="position: absolute;right: 4px;" class="fa fa-times-circle" title="关闭"></i></em>
- </span>
- </div>
- </td>
-
- <td style="width: 100%">
- <div class="preset-bt3" style="text-align: left;" id="tr_td_input_old_{$vo.preset_mark_id}">
- {volist name="vo.preset_value" id="value"}
- <span>
- <input type="hidden" name="preset_id_old_{$vo.preset_mark_id}[]" value="{$value.preset_id}">
- <input type="text" name="preset_value_old_{$vo.preset_mark_id}[]" placeholder="请输入规格值" onchange="MarkPresetId('{$value.preset_id}');" value="{$value.preset_value}"><em onclick="DelSpecTplValue(this, '{$value.preset_id}', '{$vo.preset_mark_id}')"><i class="fa fa-times-circle" title="关闭"></i></em>
- </span>
- {/volist}
- <span style="background:#4fc0e8; float: right; color: #fff; border-radius: 4px; padding:0px 6px 0px 20px; position: relative;" class="red" data-id="tr_td_input_old_{$vo.preset_mark_id}" onclick="AddSpecTplValue(this,'{$vo.preset_mark_id}','old');">
- <i class="layui-icon layui-icon-addition" style="position:absolute; left: 0; top:0px; margin: 0 3px; color: #fff"></i>添加规格值
- </span>
- </div>
- </td>
- <td class="sort">
- <div class="w100 tc">
- <label class="label">
- <input class="check" type="checkbox" {eq name="$vo.spec_sync" value="1"} checked {/eq} value="1" name="spec_sync_{$vo.preset_mark_id}" onmouseover="layer_tips = layer.tips('勾选后,修改规格名称或规格值,会自动同步更新已发布的商品规格', this, {time:100000});" onmouseout="layer.close(layer_tips);">
- </label>
- </div>
- </td>
- <td class="sort">
- <div class="w60 tc">
- <input type="text" size="4" name="sort_order_{$vo.preset_mark_id}" value="{$vo.sort_order}">
- </div>
- </td>
- </tr>
- {/volist}
- </tbody>
- </table>
- </div>
- </form>
- <div class="iDiv" style="display: none;"></div>
- </div>
- <div style="border-left:1px solid #f6f6f6;height:60px;line-height:60px;padding-left:10px;font-size:14px;">
- <a href="JavaScript:void(0);" onclick="AddSpecTpl(this);">
- <input type="hidden" id="PresetMarkId" value="{$PresetMarkId}">
- <span style="color:#0ba4da">+ 新增商品规格</span>
- </a>
- </div>
- <div class="tDiv">
- <div class="tDiv2">
- <div class="fbutton">
- <a href="JavaScript:void(0);" onclick="SaveSpecTpl(this);">
- <div class="add" title="保存更改">
- <span class="red"><i class="fa fa-save"></i>保存更改</span>
- </div>
- </a>
- </div>
- </div>
- <div style="clear:both"></div>
- </div>
- </div>
- </div>
-
- <script type="text/javascript">
- $(document).ready(function(){
- // 表格行点击选中切换
- $('#flexigrid > table>tbody >tr').click(function(){
- $(this).toggleClass('trSelected');
- });
-
- // 点击刷新数据
- $('.fa-refresh').click(function(){
- location.href = location.href;
- });
- });
-
- // 追加规格模板
- function AddSpecTpl(obj){
- var PresetMarkId = $('#PresetMarkId').val();
- // 预设值标记ID,规格名称唯一标识
- if (!PresetMarkId || 0 == PresetMarkId) {
- // 标记ID出错则提示
- layer.alert('数据出错,请刷新重试~', {icon: 2, title:false});
- }
- // 拼装html
- var AddHtml =
- [
- '<tr class="tr" id="tr_'+PresetMarkId+'">'+
- '<td class="sign">'+
- '<div class="w10 tc">'+
- '<input type="hidden" name="preset_new[]" value="'+PresetMarkId+'">'+
- '<input type="hidden" name="preset_id_'+PresetMarkId+'[]">'+
- '</div>'+
- '</td>'+
-
- '<td class="">'+
- '<div class="w180 tc preset-bt3" style="text-align: left;">'+
- '<span>'+
- '<input type="text" name="preset_name_'+PresetMarkId+'[]" placeholder="请输入规格名称"><em data-id="tr_'+PresetMarkId+'" onclick="DelSpecTpl(this);"><i style="position: absolute;right: 4px;" class="fa fa-times-circle" title="关闭"></i></em>'+
- '</span>'+
- '</div>'+
- '</td>'+
-
- '<td style="width: 100%">'+
- '<div class="preset-bt3" id="tr_td_input_'+PresetMarkId+'">'+
- '<span>'+
- '<input type="text" name="preset_value_'+PresetMarkId+'[]" placeholder="请输入规格值">'+
- '<em onclick="DelSpecTplValue(this)"><i class="fa fa-times-circle" title="关闭"></i></em>'+
- '</span>'+
-
- '<span style="background:#4fc0e8; float:right; color: #fff; border-radius: 4px; padding:0px 6px 0px 20px; position: relative;" class="red" data-id="tr_td_input_'+PresetMarkId+'" onclick="AddSpecTplValue(this, '+PresetMarkId+');"><i class="layui-icon layui-icon-addition" style="position:absolute;left: 0; top:0px;margin: 0 3px; color: #fff"></i>添加规格值'+
- '</span>'+
- '</div>'+
- '</td>'+
-
- '<td class="sort">'+
- '<div class="w100 tc">'+
- '<label class="label">'+
- '<input class="check" type="checkbox" value="0" disabled>'+
- '</label>'+
- '</div>'+
- '</td>'+
-
- '<td class="sort">'+
- '<div class="w60 tc">'+
- '<input type="text" name="sort_order_'+PresetMarkId+'" size="4" value="100">'+
- '</div>'+
- '</td>'+
- '</tr>'
- ];
-
- // 追加规格名称规格值框架
- $('#Template').append(AddHtml);
- // 更新标记ID数
- PresetMarkId++;
- $('#PresetMarkId').val(PresetMarkId);
- }
-
- // 追加规格值
- function AddSpecTplValue(obj, PresetMarkId, type){
- var tr_td_input_id = $(obj).attr('data-id');
- var AddValue = [
- '<span>'
- ];
- if ('old' == type) {
- AddValue += [
- '<input type="hidden" name="preset_id_old_'+PresetMarkId+'[]">'+
- '<input type="text" name="preset_value_old_'+PresetMarkId+'[]" placeholder="请输入规格值">'+
- '<em onclick="DelSpecTplValue(this)"><i class="fa fa-times-circle" title="关闭"></i></em>'
- ];
- }else{
- AddValue += [
- '<input type="text" name="preset_value_'+PresetMarkId+'[]" placeholder="请输入规格值">'+
- '<em onclick="DelSpecTplValue(this)"><i class="fa fa-times-circle" title="关闭"></i></em>'
-
- ];
- }
- AddValue += [
- '</span>'
- ];
- $('#'+tr_td_input_id).append(AddValue);
- }
-
- // 删除规格模板
- function DelSpecTpl(obj, preset_mark_id){
- layer.confirm('<font color="red">此操作将和规格值一起删除</font>,确认删除规格名称?', {
- shade: layer_shade,
- area: ['480px', '190px'],
- move: false,
- title: '提示',
- btnAlign:'r',
- closeBtn: 3,
- btn: ['确定', '取消'] ,//按钮
- success: function () {
- $(".layui-layer-content").css('text-align', 'left');
- }
- }, function () {
- layer_loading('正在处理');
- if (preset_mark_id) {
- var url = "{:url('Shop/spec_delete')}";
- $.ajax({
- type : 'post',
- url : url,
- data : {preset_mark_id:preset_mark_id,_ajax:1},
- dataType : 'json',
- success : function(data){
- layer.closeAll();
- if(0 == data.code){
- layer.alert(data.msg, {icon: 2, title:false});
- }
- }
- });
- }
- // 确定
- $('#'+$(obj).attr('data-id')).remove();
- layer.closeAll();
- layer.msg('操作成功!', {icon: 1, time:1500});
- if (preset_mark_id) {
- // 调用父级方法,更新预设规格下拉框的信息
- parent.UpPresetSpecData(preset_mark_id);
- }
- }, function (index) {
- // 取消
- layer.closeAll(index);
- });
- }
-
- // 删除指定规格值
- function DelSpecTplValue(obj, preset_id, preset_mark_id){
- layer_loading('正在处理');
- if (preset_id) {
- var url = "{:url('Shop/spec_delete')}";
- $.ajax({
- type : 'post',
- url : url,
- data : {preset_id:preset_id,_ajax:1},
- dataType : 'json',
- success : function(data){
- layer.closeAll();
- if(0 == data.code){
- layer.alert(data.msg, {icon: 2, title:false});
- }else{
- layer.msg(data.msg, {icon: 1, time:1000});
- $(obj).parent().remove();
- parent.RefreshPresetValue(preset_id, preset_mark_id);
- }
- }
- });
- }else{
- layer.closeAll();
- layer.msg('删除成功!', {icon: 1, time:1000});
- $(obj).parent().remove();
- }
- }
-
- // 保存规格信息
- function SaveSpecTpl(obj){
- layer_loading('正在处理');
- var mark_preset_ids = $('#mark_preset_ids').val();
- var mark_mark_ids = $('#mark_mark_ids').val();
- var url = "{:url('Shop/spec_template', ['_ajax'=>1])}";
- $.ajax({
- type : 'post',
- url : url,
- data : $('#PostForm').serialize(),
- dataType : 'json',
- success : function(data){
- layer.closeAll();
- if(data.code == 1){
- // 关闭自身
- parent.UpPresetSpecData(null, mark_preset_ids, mark_mark_ids);
- parent.layer.closeAll();
- parent.layer.msg(data.msg, {icon: 1, time:1500});
- // 调用父级方法,更新预设规格下拉框的信息
- }else{
- layer.alert(data.msg, {icon: 2, title:false});
- }
- }
- });
- }
-
- // 标记预设规格值ID
- function MarkPresetId(preset_id) {
- var mark_preset_ids = $('#mark_preset_ids').val();
- if (mark_preset_ids) {
- var mark_preset = mark_preset_ids.split(',');
- var is_mark = mark_preset.indexOf(preset_id);
- if (-1 == is_mark) {
- $('#mark_preset_ids').val(mark_preset_ids+','+preset_id);
- }
- }else{
- $('#mark_preset_ids').val(preset_id);
- }
- }
-
- // 标记预设规格名称ID
- function MarkMarkId(mark_id) {
- var mark_mark_ids = $('#mark_mark_ids').val();
- if (mark_mark_ids) {
- var mark_mark = mark_mark_ids.split(',');
- var is_mark = mark_mark.indexOf(mark_id);
- if (-1 == is_mark) {
- $('#mark_mark_ids').val(mark_mark_ids+','+mark_id);
- }
- }else{
- $('#mark_mark_ids').val(mark_id);
- }
- }
- </script>
- {include file="public/footer" /}
|