goods_class_add.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. {include file="public/header" /}
  2. <div class="page">
  3. <div class="fixed-bar">
  4. <div class="item-title">
  5. <div class="subject">
  6. <h3>{$Think.lang.goods_class_index_class}</h3>
  7. </div>
  8. {include file="public/admin_items" /}
  9. </div>
  10. </div>
  11. <form id="goods_class_form" enctype="multipart/form-data" method="post">
  12. <table class="ds-default-table">
  13. <tbody>
  14. <tr class="noborder">
  15. <td colspan="2" class="required"><label class="validation" for="gc_name">{$Think.lang.goods_class_index_name}:</label></td>
  16. </tr>
  17. <tr class="noborder">
  18. <td class="vatop rowform"><input type="text" value="" name="gc_name" id="gc_name" maxlength="20" class="txt"></td>
  19. <td class="vatop tips"></td>
  20. </tr>
  21. <tr>
  22. <td colspan="2" class="required"><label for="parent_id">{$Think.lang.goods_class_add_sup_class}:</label></td>
  23. </tr>
  24. <tr class="noborder">
  25. <td class="vatop rowform"><select name="gc_parent_id" id="gc_parent_id">
  26. <option value="0">{$Think.lang.ds_please_choose}...</option>
  27. {notempty name="parent_list"}
  28. {foreach name="parent_list" item="v" key="k" }
  29. <option {if $gc_parent_id == $v.gc_id}selected='selected'{/if} value="{$v.gc_id}">{$v.gc_name|raw}</option>
  30. {/foreach}
  31. {/notempty}
  32. </select></td>
  33. <td class="vatop tips">{$Think.lang.goods_class_add_sup_class_notice}</td>
  34. </tr>
  35. <tr>
  36. <td colspan="2" class="required"><label for="pic">{$Think.lang.goods_class_pic}:</label></td>
  37. </tr>
  38. <tr class="noborder">
  39. <td class="vatop rowform">
  40. <span class="type-file-box">
  41. <input type='text' name='textfield' id='textfield1' class='type-file-text' />
  42. <input type='button' name='button' id='button1' value='上传' class='type-file-button' />
  43. <input name="pic" type="file" class="type-file-file" id="pic" size="30" hidefocus="true" ds_type="change_pic">
  44. </span>
  45. </td>
  46. <td class="vatop tips">{$Think.lang.goods_class_pic_tips}</td>
  47. </tr>
  48. <tr>
  49. <td colspan="2" class="required"><label>{$Think.lang.gc_virtual}:</label></td>
  50. </tr>
  51. <tr class="noborder">
  52. <td class="vatop rowform"><label><input type="checkbox" name="gc_virtual" id="gc_virtual" value="1">{$Think.lang.ds_allow}</label></td>
  53. <td class="vatop tips">{$Think.lang.gc_virtual_tips}</td>
  54. </tr>
  55. <tr>
  56. <td colspan="2" class="required"><label class="validation">{$Think.lang.commis_rate}:</label></td>
  57. </tr>
  58. <tr class="noborder">
  59. <td class="vatop rowform"><input id="commis_rate" class="w60" type="text" value="5" name="commis_rate">%</td>
  60. <td class="vatop tips">{$Think.lang.commis_rate_tips}</td>
  61. </tr>
  62. <tr>
  63. <td colspan="2" class="required"><label for="gc_name">{$Think.lang.goods_class_add_type}:</label></td>
  64. </tr>
  65. <tr class="noborder">
  66. <td colspan="2" id="gcategory"><select class="class-select">
  67. <option value="0">{$Think.lang.ds_please_choose}...</option>
  68. {notempty name="gc_list"}
  69. {foreach name="gc_list" item="v" key="k" }
  70. {if $v.gc_parent_id == 0}
  71. <option value="{$v.gc_id}">{$v.gc_name}</option>
  72. {/if}
  73. {/foreach}
  74. {/notempty}
  75. </select>
  76. {$Think.lang.ds_quickly_targeted}
  77. </td>
  78. </tr>
  79. <tr class="noborder">
  80. <td class="vatop rowform"><input type="hidden" name="t_name" id="t_name" value="" />
  81. <div id="type_div" class="goods-sort-type">
  82. <div class="container">
  83. <dl>
  84. <dd>
  85. <input type="radio" name="t_id" value="0" checked="checked" />{$Think.lang.goods_class_null_type} </dd>
  86. </dl>
  87. {notempty name="type_list"}
  88. {foreach name="type_list" item="val" key="k" }
  89. {notempty name="$val.type"}
  90. <dl>
  91. <dt id="type_dt_{$k}">{$val.name}</dt>
  92. {foreach name="$val.type" item="v"}
  93. <dd>
  94. <input type="radio" name="t_id" value="{$v.type_id}" />
  95. <span>{$v.type_name}</span></dd>
  96. {/foreach}
  97. </dl>
  98. {/notempty}
  99. {/foreach}
  100. {/notempty}
  101. </div>
  102. </div></td>
  103. <td class="vatop tips">{$Think.lang.goods_class_add_type_desc_one}<a onclick="window.parent.openItem('index,type,goods')" href="JavaScript:void(0);">{$Think.lang.ds_type}</a>{$Think.lang.goods_class_add_type_desc_two}</td>
  104. </tr>
  105. <tr>
  106. <td colspan="2" class="required"><label>{$Think.lang.ds_sort}:</label></td>
  107. </tr>
  108. <tr class="noborder">
  109. <td class="vatop rowform"><input type="text" value="255" name="gc_sort" id="gc_sort" class="txt"></td>
  110. <td class="vatop tips">{$Think.lang.goods_class_add_update_sort}</td>
  111. </tr>
  112. </tbody>
  113. <tfoot>
  114. <tr>
  115. <td colspan="2"><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
  116. </tr>
  117. </tfoot>
  118. </table>
  119. </form>
  120. </div>
  121. <script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js" charset="utf-8"></script>
  122. <script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.mousewheel.js"></script>
  123. <script>
  124. //按钮先执行验证再提交表单
  125. $(function() {
  126. $("#pic").change(function() {
  127. $("#textfield1").val($(this).val());
  128. });
  129. $('input[type="radio"][name="t_id"]').click(function() {
  130. if ($(this).val() == '0') {
  131. $('#t_name').val('');
  132. } else {
  133. $('#t_name').val($(this).next('span').html());
  134. }
  135. });
  136. $('#goods_class_form').validate({
  137. errorPlacement: function(error, element) {
  138. error.appendTo(element.parent().parent().prev().find('td:first'));
  139. },
  140. rules: {
  141. gc_name: {
  142. required: true,
  143. remote: {
  144. url: "{:url('Goodsclass/ajax',['branch'=>'check_class_name'])}",
  145. type: 'get',
  146. data: {
  147. gc_name: function() {
  148. return $('#gc_name').val();
  149. },
  150. gc_parent_id: function() {
  151. return $('#gc_parent_id').val();
  152. },
  153. gc_id: ''
  154. }
  155. }
  156. },
  157. commis_rate: {
  158. required: true,
  159. max: 100,
  160. min: 0,
  161. digits: true
  162. },
  163. gc_sort: {
  164. number: true
  165. }
  166. },
  167. messages: {
  168. gc_name: {
  169. required: '{$Think.lang.goods_class_add_name_null}',
  170. remote: '{$Think.lang.goods_class_add_name_exists}'
  171. },
  172. commis_rate: {
  173. required: '{$Think.lang.goods_class_add_commis_rate_error}',
  174. max: '{$Think.lang.goods_class_add_commis_rate_error}',
  175. min: '{$Think.lang.goods_class_add_commis_rate_error}',
  176. digits: '{$Think.lang.goods_class_add_commis_rate_error}'
  177. },
  178. gc_sort: {
  179. number: '{$Think.lang.goods_class_add_sort_int}'
  180. }
  181. }
  182. });
  183. // 所属分类
  184. $(document).off('change',"#gc_parent_id").on("change","#gc_parent_id", function() {
  185. type_scroll($(this));
  186. });
  187. // 类型搜索
  188. $(document).off('change',"#gcategory > select").on("change","#gcategory > select", function() {
  189. type_scroll($(this));
  190. });
  191. });
  192. var typeScroll = 0;
  193. function type_scroll(o) {
  194. var id = o.val();
  195. if (!$('#type_dt_' + id).is('dt')) {
  196. return false;
  197. }
  198. $('#type_div').scrollTop(-typeScroll);
  199. var sp_top = $('#type_dt_' + id).offset().top;
  200. var div_top = $('#type_div').offset().top;
  201. $('#type_div').scrollTop(sp_top - div_top);
  202. typeScroll = sp_top - div_top;
  203. }
  204. gcategoryInit('gcategory');
  205. </script>