Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

spec_template.htm 16KB

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