post.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. {template '_header'}
  2. <div class="page-header">
  3. 当前位置:
  4. <span class="text-primary">
  5. <?php if( !empty($item['id'])){ ?>编辑<?php }else{ ?>添加<?php } ?>专题 <small><?php if( !empty($item['id'])){ ?>修改【{$item['name']}】<?php } ?></small>
  6. </span>
  7. </div>
  8. <div class="page-content">
  9. <div class="page-sub-toolbar">
  10. <span class='pull-right'>
  11. <a class="btn btn-primary btn-sm" href="{:U('config/special.add')}">添加专题</a>
  12. </span>
  13. </div>
  14. <form class="form-horizontal form-validate" enctype="multipart/form-data">
  15. <input type="hidden" name="id" value="{$item['id']}" />
  16. <div class="form-group">
  17. <label class="col-sm-2 control-label must">专题名称</label>
  18. <div class="col-sm-9 col-xs-12">
  19. <input type="text" id='name' name="name" class="form-control" value="{$item['name']}" data-rule-required='true' />
  20. </div>
  21. </div>
  22. <div class="form-group">
  23. <label class="col-sm-2 control-label must">专题描述</label>
  24. <div class="col-sm-9 col-xs-12">
  25. <input type="text" id='description' name="description" class="form-control" value="{$item['description']}" required style="width: 300px;"/>
  26. </div>
  27. </div>
  28. <div class="form-group">
  29. <label class="col-sm-2 control-label">封面图</label>
  30. <div class="col-sm-9 col-xs-12">
  31. {:tpl_form_field_image2('cover', $item['cover'])}
  32. </div>
  33. </div>
  34. <div class="form-group">
  35. <label class="col-sm-2 control-label ">是否启用</label>
  36. <div class="col-sm-9 col-xs-12">
  37. <label class='radio-inline'>
  38. <input type='radio' name='enabled' id="isdefault1" value='1' <?php if( $item['enabled']==1){ ?>checked<?php } ?> /> 是
  39. </label>
  40. <label class='radio-inline'>
  41. <input type='radio' name='enabled' id="isdefault0" value='0' <?php if( $item['enabled']==0){ ?>checked<?php } ?> /> 否
  42. </label>
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <label class="col-sm-2 control-label">专题商品</label>
  47. <div class="col-sm-9">
  48. <div class="form-group" style="height: auto; display: block;">
  49. <div class="col-sm-12 col-xs-12">
  50. <div class="input-group">
  51. <input type="text" id="goodsid_text" name="goodsid_text" value="" class="form-control text" readonly="">
  52. <div class="input-group-btn">
  53. <button class="btn btn-primary select_goods" type="button">选择商品</button>
  54. </div>
  55. </div>
  56. <div class="input-group multi-img-details container ui-sortable goods_show">
  57. <?php if( !empty($goods)){ ?>
  58. <?php foreach( $goods as $g ){ ?>
  59. <div class="multi-item" data-id="{$g['id']}" data-name="goodsid" id="{$g['id']}">
  60. <img class="img-responsive img-thumbnail" src="{:tomedia($g['thumb'])}" onerror="this.src='/static/images/nopic.png'" style="width:100px;height:100px;">
  61. <div class="img-nickname">{$g['goodsname']}</div>
  62. <input type="hidden" value="{$g['id']}" name="goodsids[]">
  63. <em onclick="remove({$g['id']})" class="close">×</em>
  64. <div style="clear:both;"></div>
  65. </div>
  66. <?php } ?>
  67. <?php } ?>
  68. </div>
  69. <script>
  70. $(function(){
  71. var title = '';
  72. $('.img-nickname').each(function(){
  73. title += $(this).html()+';';
  74. });
  75. $('#goodsid_text').val(title);
  76. })
  77. myrequire(['web/goods_selector'],function (Gselector) {
  78. $('.select_goods').click(function () {
  79. var ids = select_goods_ids();
  80. Gselector.open('goods_show','',0,true,'',ids);
  81. });
  82. })
  83. function goods_show(data) {
  84. if(data.act == 1){
  85. var html = '<div class="multi-item" data-id="'+data.id+'" data-name="goodsid" id="'+data.id+'">'
  86. +'<img class="img-responsive img-thumbnail" src="'+data.thumb+'" onerror="this.src=\'/static/images/nopic.png\'" style="width:100px;height:100px;">'
  87. +'<div class="img-nickname">'+data.goodsname+'</div>'
  88. +'<input type="hidden" value="'+data.id+'" name="goodsids[]">'
  89. +'<em onclick="removeHtml('+data.id+')" class="close">×</em>'
  90. +'</div>';
  91. $('.goods_show').append(html);
  92. var title = '';
  93. $('.img-nickname').each(function(){
  94. title += $(this).html()+';';
  95. });
  96. $('#goodsid_text').val(title);
  97. }else if(data.act == 0){
  98. remove(data.id);
  99. }
  100. }
  101. function remove(id){
  102. $("[id='"+id+"']").remove();
  103. var title = '';
  104. $('.img-nickname').each(function(){
  105. title += $(this).html()+';';
  106. });
  107. $('#goodsid_text').val(title);
  108. }
  109. function select_goods_ids(){
  110. var goodsids = [];
  111. $(".multi-item").each(function(){
  112. goodsids.push($(this).attr('data-id'));
  113. });
  114. return goodsids;
  115. }
  116. </script>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="form-group">
  122. <label class="col-sm-2 control-label "></label>
  123. <div class="col-sm-9 col-xs-12">
  124. <input type="submit" value="提交" class="btn btn-primary" />
  125. <input type="button" name="back" onclick="javascript:window.location.href='{:U('config/special.index')}'" value="返回列表" class="btn btn-default" />
  126. </div>
  127. </div>
  128. </form>
  129. </div>
  130. <script language='javascript'>
  131. require(['jquery.ui'],function(){
  132. $('.multi-img-details').sortable();
  133. })
  134. function formcheck() {
  135. if ($("#name").isEmpty()) {
  136. Tip.focus("name", "请填写专题名称!", "top");
  137. return false;
  138. }
  139. if ($("#description").isEmpty()) {
  140. Tip.focus("description", "请填写专题描述!", "top");
  141. return false;
  142. }
  143. return true;
  144. }
  145. </script>
  146. {template '_footer'}