暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

spec_index.htm 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. {include file="public/layout" /}
  2. <body class="bodystyle" style="cursor: default; -moz-user-select: inherit;min-width:auto;">
  3. <div id="append_parent"></div>
  4. <div id="ajaxwaitid"></div>
  5. {include file="shop/left" /}
  6. <div class="page min-hg-c-10">
  7. <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); padding-right: 0px; height: 100%;">
  8. <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
  9. <h4 title="提示相关设置操作时应注意的要点">提示</h4>
  10. <span title="收起提示" id="explanationZoom" style="display: block;"></span>
  11. </div>
  12. <ul>
  13. <li>1、新增规格模板,方便管理员快捷选择商品规格复制到商品发布页里</li>
  14. <li>2、在规格库里编辑,修改,删除商品规格模板并<i style="color: red;">不影响</i>已发布的商品里的规格值</li>
  15. <li>3、如果编辑商品规格时需要和规格库里规格模板一致,可以点击规格值右侧的刷新按钮 <i class="fa fa-refresh"></i> 同步</li>
  16. </ul>
  17. </div>
  18. <div class="flexigrid">
  19. <div class="hDiv">
  20. <div class="hDivBox">
  21. <table cellspacing="0" cellpadding="0" style="width: 100%">
  22. <thead>
  23. <tr>
  24. <th class="sign w10" axis="col0">
  25. <div class="tc"></div>
  26. </th>
  27. <th abbr="article_time" axis="col4" class="w180">
  28. <div class="text-l10">规格名称</div>
  29. </th>
  30. <th abbr="ac_id" axis="col4">
  31. <div class="text-l10">规格值</div>
  32. </th>
  33. <th abbr="article_time" axis="col6" class="w100">
  34. <div class="tc">是否同步</div>
  35. </th>
  36. <th abbr="article_time" axis="col6" class="w60">
  37. <div class="tc">排序</div>
  38. </th>
  39. </tr>
  40. </thead>
  41. </table>
  42. </div>
  43. </div>
  44. <div class="bDiv" style="height: auto;">
  45. <form id="PostForm">
  46. <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
  47. <table style="width: 100%">
  48. <input type="hidden" name="mark_preset_ids" id='mark_preset_ids'>
  49. <input type="hidden" name="mark_mark_ids" id='mark_mark_ids'>
  50. <tbody id='Template'>
  51. {volist name="info" id="vo"}
  52. <tr class="tr" id="tr_{$vo.preset_mark_id}">
  53. <td class="sign">
  54. <div class="w10 tc">
  55. <input type="hidden" name="preset_old[]" value="{$vo.preset_mark_id}">
  56. </div>
  57. </td>
  58. <td class="">
  59. <div class="w180 tc preset-bt3" style="text-align: left;">
  60. <span>
  61. <input type="text" name="preset_name_old_{$vo.preset_mark_id}[]" placeholder="请输入规格名称" onchange="MarkMarkId('{$vo.preset_mark_id}');" value="{$vo.preset_name}">
  62. <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>
  63. </span>
  64. </div>
  65. </td>
  66. <td style="width: 100%">
  67. <div class="preset-bt3" style="text-align: left;" id="tr_td_input_old_{$vo.preset_mark_id}">
  68. {volist name="vo.preset_value" id="value"}
  69. <span>
  70. <input type="hidden" name="preset_id_old_{$vo.preset_mark_id}[]" value="{$value.preset_id}">
  71. <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>
  72. </span>
  73. {/volist}
  74. <span style="background:#4fc0e8; float: right; color: #fff; border-radius: 4px; padding:0px 6px 0px 20px; position: relative; cursor: pointer;" class="red" data-id="tr_td_input_old_{$vo.preset_mark_id}" onclick="AddSpecTplValue(this,'{$vo.preset_mark_id}','old');">
  75. <i class="layui-icon layui-icon-addition" style="position:absolute; left: 0; top:0px; margin: 0 3px; color: #fff"></i>添加规格值
  76. </span>
  77. </div>
  78. </td>
  79. <td class="sort">
  80. <div class="w100 tc">
  81. <label class="label">
  82. <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);">
  83. </label>
  84. </div>
  85. </td>
  86. <td class="sort">
  87. <div class="w60 tc">
  88. <input type="text" size="4" name="sort_order_{$vo.preset_mark_id}" value="{$vo.sort_order}">
  89. </div>
  90. </td>
  91. </tr>
  92. {/volist}
  93. </tbody>
  94. </table>
  95. </div>
  96. </form>
  97. <div class="iDiv" style="display: none;"></div>
  98. </div>
  99. <div class="tDiv">
  100. <div class="tDiv2">
  101. <div class="fbutton">
  102. <a href="JavaScript:void(0);" onclick="SaveSpecTpl(this);" class="layui-btn layui-btn-primary">
  103. <span>保存</span>
  104. </a>
  105. </div>
  106. <div class="fbutton">
  107. <a href="JavaScript:void(0);" onclick="AddSpecTpl(this);" class="layui-btn layui-btn-primary">
  108. <input type="hidden" id="PresetMarkId" value="{$PresetMarkId}">
  109. <span class="red">新增规格</span>
  110. </a>
  111. </div>
  112. </div>
  113. <div style="clear:both"></div>
  114. </div>
  115. </div>
  116. </div>
  117. <script type="text/javascript">
  118. try{
  119. if (typeof(eval('is_conceal_1649209614'))=="function" && is_conceal_1649209614()){
  120. $(".page").css("margin-left","");
  121. $(".page").css("min-width","");
  122. }else{
  123. $(".page").css("margin-left","100px");
  124. $(".page").css("min-width","auto");
  125. }
  126. }catch(e){}
  127. $(document).ready(function(){
  128. // 表格行点击选中切换
  129. $('#flexigrid > table>tbody >tr').click(function(){
  130. $(this).toggleClass('trSelected');
  131. });
  132. // 点击刷新数据
  133. $('.fa-refresh').click(function(){
  134. location.href = location.href;
  135. });
  136. });
  137. // 追加规格模板
  138. function AddSpecTpl(obj){
  139. var PresetMarkId = $('#PresetMarkId').val();
  140. // 预设值标记ID,规格名称唯一标识
  141. if (!PresetMarkId || 0 == PresetMarkId) {
  142. // 标记ID出错则提示
  143. layer.alert('数据出错,请刷新重试~', {icon: 2, title:false});
  144. }
  145. // 拼装html
  146. var AddHtml =
  147. [
  148. '<tr class="tr" id="tr_'+PresetMarkId+'">'+
  149. '<td class="sign">'+
  150. '<div class="w10 tc">'+
  151. '<input type="hidden" name="preset_new[]" value="'+PresetMarkId+'">'+
  152. '<input type="hidden" name="preset_id_'+PresetMarkId+'[]">'+
  153. '</div>'+
  154. '</td>'+
  155. '<td class="">'+
  156. '<div class="w180 tc preset-bt3" style="text-align: left;">'+
  157. '<span>'+
  158. '<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>'+
  159. '</span>'+
  160. '</div>'+
  161. '</td>'+
  162. '<td style="width: 100%">'+
  163. '<div class="preset-bt3" id="tr_td_input_'+PresetMarkId+'">'+
  164. '<span>'+
  165. '<input type="text" name="preset_value_'+PresetMarkId+'[]" placeholder="请输入规格值">'+
  166. '<em onclick="DelSpecTplValue(this)"><i class="fa fa-times-circle" title="关闭"></i></em>'+
  167. '</span>'+
  168. '<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>添加规格值'+
  169. '</span>'+
  170. '</div>'+
  171. '</td>'+
  172. '<td class="sort">'+
  173. '<div class="w100 tc">'+
  174. '<label class="label">'+
  175. '<input class="check" type="checkbox" value="0" disabled>'+
  176. '</label>'+
  177. '</div>'+
  178. '</td>'+
  179. '<td class="sort">'+
  180. '<div class="w60 tc">'+
  181. '<input type="text" name="sort_order_'+PresetMarkId+'" size="4" value="100">'+
  182. '</div>'+
  183. '</td>'+
  184. '</tr>'
  185. ];
  186. // 追加规格名称规格值框架
  187. $('#Template').append(AddHtml);
  188. // 更新标记ID数
  189. PresetMarkId++;
  190. $('#PresetMarkId').val(PresetMarkId);
  191. }
  192. // 追加规格值
  193. function AddSpecTplValue(obj, PresetMarkId, type){
  194. var tr_td_input_id = $(obj).attr('data-id');
  195. var AddValue = [
  196. '<span>'
  197. ];
  198. if ('old' == type) {
  199. AddValue += [
  200. '<input type="hidden" name="preset_id_old_'+PresetMarkId+'[]">'+
  201. '<input type="text" name="preset_value_old_'+PresetMarkId+'[]" placeholder="请输入规格值">'+
  202. '<em onclick="DelSpecTplValue(this)"><i class="fa fa-times-circle" title="关闭"></i></em>'
  203. ];
  204. }else{
  205. AddValue += [
  206. '<input type="text" name="preset_value_'+PresetMarkId+'[]" placeholder="请输入规格值">'+
  207. '<em onclick="DelSpecTplValue(this)"><i class="fa fa-times-circle" title="关闭"></i></em>'
  208. ];
  209. }
  210. AddValue += [
  211. '</span>'
  212. ];
  213. $('#'+tr_td_input_id).append(AddValue);
  214. }
  215. // 删除规格模板
  216. function DelSpecTpl(obj, preset_mark_id){
  217. layer.confirm('确认删除规格名称?规格值将会一起删除', {
  218. shade: layer_shade,
  219. area: ['480px', '190px'],
  220. move: false,
  221. title: '提示',
  222. btnAlign:'r',
  223. closeBtn: 3,
  224. btn: ['确定', '取消'] ,//按钮
  225. success: function () {
  226. $(".layui-layer-content").css('text-align', 'left');
  227. }
  228. }, function () {
  229. layer_loading('正在处理');
  230. if (preset_mark_id) {
  231. var url = "{:url('Shop/spec_delete')}";
  232. $.ajax({
  233. type : 'post',
  234. url : url,
  235. data : {preset_mark_id:preset_mark_id,_ajax:1},
  236. dataType : 'json',
  237. success : function(data){
  238. layer.closeAll();
  239. if(0 == data.code){
  240. layer.alert(data.msg, {icon: 2, title:false});
  241. }
  242. }
  243. });
  244. }
  245. // 确定
  246. $('#'+$(obj).attr('data-id')).remove();
  247. layer.closeAll();
  248. layer.msg('操作成功!', {icon: 1, time: 1500});
  249. // 调用父级方法,更新预设规格下拉框的信息
  250. // if (preset_mark_id) parent.UpPresetSpecData(preset_mark_id);
  251. }, function (index) {
  252. // 取消
  253. layer.closeAll(index);
  254. });
  255. }
  256. // 删除指定规格值
  257. function DelSpecTplValue(obj, preset_id, preset_mark_id){
  258. layer_loading('正在处理');
  259. if (preset_id) {
  260. var url = "{:url('Shop/spec_delete')}";
  261. $.ajax({
  262. type : 'post',
  263. url : url,
  264. data : {preset_id:preset_id,_ajax:1},
  265. dataType : 'json',
  266. success : function(data){
  267. layer.closeAll();
  268. if(0 == data.code){
  269. layer.alert(data.msg, {icon: 2, title:false});
  270. } else {
  271. layer.msg(data.msg, {icon: 1, time:1000});
  272. $(obj).parent().remove();
  273. // parent.RefreshPresetValue(preset_id, preset_mark_id);
  274. }
  275. }
  276. });
  277. } else {
  278. layer.closeAll();
  279. layer.msg('删除成功!', {icon: 1, time:1000});
  280. $(obj).parent().remove();
  281. }
  282. }
  283. // 保存规格信息
  284. function SaveSpecTpl(obj){
  285. layer_loading('正在处理');
  286. var mark_preset_ids = $('#mark_preset_ids').val();
  287. var mark_mark_ids = $('#mark_mark_ids').val();
  288. var url = "{:url('Shop/spec_template', ['_ajax'=>1])}";
  289. $.ajax({
  290. type : 'post',
  291. url : url,
  292. data : $('#PostForm').serialize(),
  293. dataType : 'json',
  294. success : function(data){
  295. layer.closeAll();
  296. if (data.code == 1) {
  297. // 关闭自身
  298. // parent.UpPresetSpecData(null, mark_preset_ids, mark_mark_ids);
  299. layer.closeAll();
  300. layer.msg(data.msg, {icon: 1, time: 1500}, function() {
  301. window.location.reload();
  302. });
  303. // 调用父级方法,更新预设规格下拉框的信息
  304. } else {
  305. layer.alert(data.msg, {icon: 2, title: false});
  306. }
  307. }
  308. });
  309. }
  310. // 标记预设规格值ID
  311. function MarkPresetId(preset_id) {
  312. var mark_preset_ids = $('#mark_preset_ids').val();
  313. if (mark_preset_ids) {
  314. var mark_preset = mark_preset_ids.split(',');
  315. var is_mark = mark_preset.indexOf(preset_id);
  316. if (-1 == is_mark) {
  317. $('#mark_preset_ids').val(mark_preset_ids+','+preset_id);
  318. }
  319. }else{
  320. $('#mark_preset_ids').val(preset_id);
  321. }
  322. }
  323. // 标记预设规格名称ID
  324. function MarkMarkId(mark_id) {
  325. var mark_mark_ids = $('#mark_mark_ids').val();
  326. if (mark_mark_ids) {
  327. var mark_mark = mark_mark_ids.split(',');
  328. var is_mark = mark_mark.indexOf(mark_id);
  329. if (-1 == is_mark) {
  330. $('#mark_mark_ids').val(mark_mark_ids+','+mark_id);
  331. }
  332. }else{
  333. $('#mark_mark_ids').val(mark_id);
  334. }
  335. }
  336. </script>
  337. {include file="public/footer" /}