attribute_add.htm 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. {include file="public/layout" /}
  2. <body class="bodystyle">
  3. <div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
  4. <div id="append_parent"></div>
  5. <div id="ajaxwaitid"></div>
  6. <div class="page">
  7. {include file="field/attribute_bar" /}
  8. <form class="form-horizontal" id="post_form" action="{:url('Field/attribute_add')}" method="post" onsubmit="return false;">
  9. <div class="ncap-form-default">
  10. <dl class="row">
  11. <dt class="tit">
  12. <label for="typeid"><em>*</em>所属栏目</label>
  13. </dt>
  14. <dd class="opt">
  15. {empty name="$typeid"}
  16. <select name="typeid" id="typeid" onchange="showlist(this)">
  17. <option value="0">请选择栏目…</option>
  18. {$select_html}
  19. </select>
  20. {else /}
  21. {$select_html}
  22. <input type="hidden" name="typeid" id="typeid" value="{$typeid|default=''}">
  23. {/empty}
  24. <span class="err" id="err_typeid" style="color:#F00; display:none;"></span>
  25. <p class="notic"></p>
  26. </dd>
  27. </dl>
  28. <dl class="row">
  29. <dt class="tit">
  30. <label for="ac_name"><em>*</em>属性名称</label>
  31. </dt>
  32. <dd class="opt">
  33. <input type="text" name="attr_name" value="" id="attr_name" class="input-txt">
  34. <span class="err" id="err_attr_name" style="color:#F00; display:none;"></span>
  35. <p class="notic"></p>
  36. </dd>
  37. </dl>
  38. <dl class="row">
  39. <dt class="tit">
  40. <label for="attr_input_type"><em>*</em>属性类型</label>
  41. </dt>
  42. <dd class="opt">
  43. {volist name='$attrInputTypeArr' id='vo'}
  44. <div style="width: 150px; float: left;">
  45. <label><input type="radio" name="attr_input_type" value="{$key}" {eq name='$i' value='1'} checked="checked" {/eq}>{$vo}</label>&nbsp;
  46. </div>
  47. {if condition="$i % 4 == 0"}<br/>{/if}
  48. {/volist}
  49. <span class="err" id="err_attr_input_type" style="color:#F00; display:none;"></span>
  50. <p class="notic"></p>
  51. <p class="none red" id="validate_type"><br/>前台表单输入框的格式验证标签调用,<a href="javascript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=8973','标签调用');">请点击这里查看教程</a></p>
  52. </dd>
  53. </dl>
  54. <dl class="row none attr_input_type2">
  55. <dt class="tit">
  56. <label for="attr_values"><em>*</em>可选值列表</label>
  57. </dt>
  58. <dd class="opt">
  59. <textarea rows="10" cols="30" name="attr_values" id="attr_values" class="input-txt" style="height:100px;" placeholder="一行代表一个可选值" onkeyup="this.value=this.value.replace(/[\|]/g,'');" onpaste="this.value=this.value.replace(/[\|]/g,'');"></textarea>
  60. <span id="err_attr_values" class="err" style="color:#F00; display:none;"></span>
  61. <p class="notic">一行代表一个可选值</p>
  62. </dd>
  63. </dl>
  64. <dl class="row none" id="show_list">
  65. <dt class="tit">
  66. <label>后台列表显示</label>
  67. </dt>
  68. <dd class="opt">
  69. <div class="onoff">
  70. <label for="is_showlist1" id="is_showlist1_label" class="cb-enable" data-is_showlist="1" onclick="ajax_attribute_show(this);">显示</label>
  71. <input id="is_showlist1" name="is_showlist" value="1" type="radio">
  72. <label for="is_showlist0" id="is_showlist0_label" class="cb-disable selected" data-is_showlist="0" onclick="ajax_attribute_show(this);">隐藏</label>
  73. <input id="is_showlist0" name="is_showlist" value="0" type="radio" checked="checked">
  74. </div>
  75. &nbsp;
  76. <span class="err"></span>
  77. <p class="notic">默认在列表显示前4个字段,全部字段可点击查看</p>
  78. </dd>
  79. </dl>
  80. <dl class="row">
  81. <dt class="tit">
  82. <label>前台必填</label>
  83. </dt>
  84. <dd class="opt">
  85. <div class="onoff">
  86. <label for="required1" class="cb-enable" >是</label>
  87. <input id="required1" name="required" value="1" type="radio">
  88. <label for="required0" class="cb-disable selected">否</label>
  89. <input id="required0" name="required" value="0" type="radio" checked="checked">
  90. </div>
  91. &nbsp;
  92. <span class="err"></span>
  93. <p class="notic">用于控制前台用户提交是否必填验证</p>
  94. </dd>
  95. </dl>
  96. <div class="bot">
  97. <a href="JavaScript:void(0);" onclick="check_submit('post_form');" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
  98. </div>
  99. </div>
  100. </form>
  101. </div>
  102. <script type="text/javascript">
  103. $(function(){
  104. $('input[name=attr_input_type]').click(function(){
  105. var val = parseInt($(this).val());
  106. $('#validate_type').hide();
  107. if (-1 < $.inArray(val, [1,3,4])) {
  108. $('.attr_input_type2').show();
  109. } else {
  110. $('.attr_input_type2').hide();
  111. if (-1 < $.inArray(val, [6,7])) {
  112. $('#validate_type').show();
  113. }
  114. }
  115. });
  116. });
  117. /**
  118. * ajax 提交属性 到后台去验证然后回到前台提示错误
  119. * 验证通过后,再通过 form 自动提交
  120. */
  121. function check_submit(form_id)
  122. {
  123. if ($('#typeid').val() == 0) {
  124. showErrorMsg('请选择栏目…!');
  125. $('#typeid').focus();
  126. return false;
  127. }
  128. if($.trim($('input[name=attr_name]').val()) == ''){
  129. showErrorMsg('属性名称不能为空!');
  130. $('input[name=attr_name]').focus();
  131. return false;
  132. }
  133. var attr_input_type = parseInt($('input[name=attr_input_type]:checked').val());
  134. if (-1 < $.inArray(attr_input_type, [1,3,4]) && $.trim($('#attr_values').val()) == '') {
  135. showErrorMsg('可选值列表不能为空!');
  136. $('#attr_values').focus();
  137. return false;
  138. }
  139. layer_loading('正在处理');
  140. $.ajax({
  141. type : "POST",
  142. url : "{:url('Field/attribute_add', ['_ajax'=>1])}",
  143. data : $('#'+form_id).serialize(),// 你的formid
  144. dataType: "JSON",
  145. error: function(request) {
  146. layer.closeAll();
  147. layer.alert(ey_unknown_error, {icon: 5, title:false});
  148. return false;
  149. },
  150. success: function(v) {
  151. layer.closeAll();
  152. if(v.status == 1)
  153. {
  154. if(v.hasOwnProperty('data')){
  155. if(v.data.hasOwnProperty('url')){
  156. location.href = v.data.url;
  157. }else{
  158. location.href = location.href;
  159. }
  160. }else{
  161. location.href = location.href;
  162. }
  163. return true;
  164. } else {
  165. showErrorMsg(v.msg);
  166. return false;
  167. }
  168. }
  169. });
  170. }
  171. function showlist(obj) {
  172. if ($(obj).val() == 0) {
  173. $("#show_list").hide();
  174. } else {
  175. $("#show_list").show();
  176. }
  177. }
  178. function ajax_attribute_show(obj) {
  179. var is_showlist = $(obj).attr('data-is_showlist');
  180. var typeid = $('#typeid').val();
  181. if (typeid == 0) {
  182. showErrorMsg('请选择栏目…!');
  183. $('#typeid').focus();
  184. return false;
  185. }
  186. $.ajax({
  187. type : 'post',
  188. url : "{:url('Field/ajax_attribute_show')}",
  189. data : {typeid:typeid,is_showlist:is_showlist, _ajax:1},
  190. dataType : 'json',
  191. success : function(res){
  192. if (res.code != 1) {
  193. $('#is_showlist1_label').removeClass('selected');
  194. $('#is_showlist0_label').addClass('selected');//添加一个class
  195. $("input:radio[name=is_showlist]").eq(0).attr("checked",false);
  196. $("input:radio[name=is_showlist]").eq(1).attr("checked",true);
  197. layer.alert(res.msg, {icon: 2, title:false});
  198. }
  199. },
  200. error:function(){
  201. layer.alert(ey_unknown_error, {icon: 2, title:false});
  202. }
  203. });
  204. }
  205. </script>
  206. {include file="public/footer" /}