Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. {include file="public/layout" /}
  2. <body style="background-color: #FFF; overflow: auto;">
  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" style="box-shadow:none;">
  7. <form class="form-horizontal" id="post_form" action="{:url('Guestbook/attribute_add')}" method="post" onsubmit="return false;">
  8. <div class="ncap-form-default">
  9. <dl class="row">
  10. <dt class="tit">
  11. <label for="typeid"><em>*</em>所属栏目</label>
  12. </dt>
  13. <dd class="opt">
  14. {empty name="$typeid"}
  15. <select name="typeid" id="typeid" onchange="showlist(this)">
  16. <option value="0">请选择栏目…</option>
  17. {$select_html}
  18. </select>
  19. {else /}
  20. {$select_html}
  21. <input type="hidden" name="typeid" id="typeid" value="{$typeid|default=''}">
  22. {/empty}
  23. <span class="err" id="err_typeid" style="color:#F00; display:none;"></span>
  24. <p class="notic"></p>
  25. </dd>
  26. </dl>
  27. <dl class="row">
  28. <dt class="tit">
  29. <label for="ac_name"><em>*</em>字段名称</label>
  30. </dt>
  31. <dd class="opt">
  32. <input type="text" name="attr_name" value="" id="attr_name" class="input-txt" autocomplete="off">
  33. <span class="err" id="err_attr_name" style="color:#F00; display:none;"></span>
  34. <p class="notic"></p>
  35. </dd>
  36. </dl>
  37. <dl class="row">
  38. <dt class="tit">
  39. <label for="attr_input_type"><em>*</em>字段类型</label>
  40. </dt>
  41. <dd class="opt">
  42. {volist name='$attrInputTypeArr' id='vo'}
  43. <div style="width: 150px; float: left;">
  44. <label><input type="radio" name="attr_input_type" value="{$key}" {eq name='$i' value='1'} checked="checked" {/eq}>{$vo}</label>&nbsp;
  45. </div>
  46. {if condition="$i % 4 == 0"}<br/>{/if}
  47. {/volist}
  48. <span class="err" id="err_attr_input_type" style="color:#F00; display:none;"></span>
  49. <p class="notic"></p>
  50. <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&origin_eycms=1','标签调用');">请点击这里查看教程</a></p>
  51. </dd>
  52. </dl>
  53. <dl class="row none attr_input_type2">
  54. <dt class="tit">
  55. <label for="attr_values"><em>*</em>可选值列表</label>
  56. </dt>
  57. <dd class="opt">
  58. <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>
  59. <span id="err_attr_values" class="err" style="color:#F00; display:none;"></span>
  60. <p class="notic">一行代表一个可选值</p>
  61. </dd>
  62. </dl>
  63. <dl class="row none" id="show_list">
  64. <dt class="tit">
  65. <label>后台列表显示</label>
  66. </dt>
  67. <dd class="opt">
  68. <div class="onoff">
  69. <label for="is_showlist1" id="is_showlist1_label" class="cb-enable" data-is_showlist="1" onclick="ajax_attribute_show(this);">显示</label>
  70. <input id="is_showlist1" name="is_showlist" value="1" type="radio">
  71. <label for="is_showlist0" id="is_showlist0_label" class="cb-disable selected" data-is_showlist="0" onclick="ajax_attribute_show(this);">隐藏</label>
  72. <input id="is_showlist0" name="is_showlist" value="0" type="radio" checked="checked">
  73. </div>
  74. &nbsp;
  75. <span class="err"></span>
  76. <p class="notic">默认在列表显示前4个字段,全部字段可点击查看</p>
  77. </dd>
  78. </dl>
  79. <div id='region_div' style="display: none;">
  80. <dl class="row">
  81. <dt class="tit">
  82. <label for="region"><em>*</em>区域选择</label>
  83. </dt>
  84. <dd class="opt">
  85. <select id="province" onchange="GetRegionData(this,'province');">
  86. <option value="-1">请选择</option>
  87. {volist name='$Province' id='P_V'}
  88. <option value="{$P_V.id}">{$P_V.name}</option>
  89. {/volist}
  90. </select>
  91. <span id='CityId'>
  92. <select id="city" onchange="GetRegionData(this,'city');">
  93. <option value="">请选择</option>
  94. </select>
  95. </span>
  96. <span class="err"></span>
  97. <p class="notic"></p>
  98. </dd>
  99. <input type="hidden" id="GetRegionDataUrl" value="{:url('Field/ajax_get_region_data')}">
  100. <input type="hidden" name="region_data[region_id]" id="RegionId" value="-1">
  101. </dl>
  102. <dl class="row">
  103. <dt class="tit">
  104. <label><em>*</em>默认值</label>
  105. </dt>
  106. <dd class="opt">
  107. <textarea rows="5" cols="60" name="region_data[region_names]" id="region_names" readonly='readonly' placeholder="这里会自动区域选择之后的下级区域列表" style="height:110px; background-color: #f5f5f5;">{$region.region_names}</textarea>
  108. <span class="err"></span>
  109. <p class="notic">这里会自动区域选择之后的下级区域列表</p>
  110. </dd>
  111. <input type="hidden" name="region_data[region_ids]" id='region_ids' value='{$region.region_ids}' style="width: 100%;">
  112. </dl>
  113. </div>
  114. <dl class="row">
  115. <dt class="tit">
  116. <label>前台必填</label>
  117. </dt>
  118. <dd class="opt">
  119. <div class="onoff">
  120. <label for="required1" class="cb-enable" >是</label>
  121. <input id="required1" name="required" value="1" type="radio">
  122. <label for="required0" class="cb-disable selected">否</label>
  123. <input id="required0" name="required" value="0" type="radio" checked="checked">
  124. </div>
  125. &nbsp;
  126. <span class="err"></span>
  127. <p class="notic">用于控制前台用户提交是否必填验证</p>
  128. </dd>
  129. </dl>
  130. <dl class="row" id="realValidate" style="display: none;">
  131. <dt class="tit"> <label>真实验证</label> </dt>
  132. <dd class="opt">
  133. <div class="onoff">
  134. <label for="real_validate1" class="cb-enable" >是</label>
  135. <input id="real_validate1" name="real_validate" value="1" type="radio">
  136. <label for="real_validate0" class="cb-disable selected">否</label>
  137. <input id="real_validate0" name="real_validate" value="0" type="radio" checked="checked">
  138. </div>
  139. &nbsp;
  140. <span class="err"></span>
  141. <p class="notic">用于控制前台用户提交的内容是否进行真实验证</p>
  142. <p style="line-height: 1;" class="red {if condition="!in_array($field.attr_input_type, [6,7])"} none {/if}" id="real_validate_type"><br/>前台表单手机验证码调用标签,<a href="javascript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=28608&origin_eycms=1','标签调用');">请点击这里查看教程</a></p>
  143. </dd>
  144. </dl>
  145. <div class="bot">
  146. <a href="JavaScript:void(0);" onclick="check_submit('post_form');" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
  147. </div>
  148. </div>
  149. </form>
  150. </div>
  151. <script type="text/javascript">
  152. $(function(){
  153. if (0 == $('#RegionId').val() || -1 == $('#RegionId').val()) {
  154. $('#CityId').hide();
  155. }
  156. $('input[name=attr_input_type]').click(function(){
  157. var val = parseInt($(this).val());
  158. $('#validate_type').hide();
  159. $('#real_validate_type').hide();
  160. $('#realValidate').hide();
  161. if (-1 < $.inArray(val, [1,3,4])) {
  162. $('.attr_input_type2').show();
  163. } else {
  164. $('.attr_input_type2').hide();
  165. if (-1 < $.inArray(val, [6,7])) {
  166. $('#validate_type').show();
  167. $('#real_validate_type').show();
  168. // 如果点击的是手机号码字段则执行
  169. if (val == 6) $('#realValidate').show();
  170. }
  171. }
  172. if (9 == val) {
  173. $('#region_div').show();
  174. $('#dl_dfvalue').hide();
  175. } else {
  176. $('#dl_dfvalue').show();
  177. ClearAreaData();
  178. }
  179. });
  180. });
  181. // 当切换其他类型时清空所有关于区域选择的数据
  182. function ClearAreaData(){
  183. $('#region_div').hide();
  184. $('#RegionId').val('');
  185. $('#region_dfvalue').empty();
  186. }
  187. // 获取联动地址
  188. function GetRegionData(t,type){
  189. var parent_id = $(t).val();
  190. if(!parent_id){
  191. return false;
  192. }
  193. var url = $('#GetRegionDataUrl').val();
  194. $.ajax({
  195. url: url,
  196. data: {parent_id:parent_id,_ajax:1},
  197. type:'post',
  198. dataType:'json',
  199. success:function(res){
  200. // 判断是否隐藏第二级地区选择栏
  201. if (0 <= $.inArray(parent_id, res.parent_array)) {
  202. $('#CityId').hide();
  203. }else{
  204. $('#CityId').show();
  205. }
  206. // 加载城市名称数据到textarea
  207. $('#region_names').empty().html(res.region_names);
  208. // 加载城市ID数据到input
  209. $('#region_ids').val(res.region_ids);
  210. // 加载ID到input
  211. $('#RegionId').val(parent_id);
  212. // 输出下一级城市选项
  213. if ('province' == type) {
  214. res = '<option value='+parent_id+'>请选择</option>'+ res.region_html;
  215. $('#city').empty().html(res);
  216. }
  217. },
  218. error : function(e) {
  219. layer.closeAll();
  220. showErrorAlert(e.responseText);
  221. }
  222. });
  223. }
  224. var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  225. /**
  226. * ajax 提交字段 到后台去验证然后回到前台提示错误
  227. * 验证通过后,再通过 form 自动提交
  228. */
  229. function check_submit(form_id)
  230. {
  231. if ($('#typeid').val() == 0) {
  232. showErrorMsg('请选择栏目…!');
  233. $('#typeid').focus();
  234. return false;
  235. }
  236. if($.trim($('input[name=attr_name]').val()) == ''){
  237. showErrorMsg('字段名称不能为空!');
  238. $('input[name=attr_name]').focus();
  239. return false;
  240. }
  241. var attr_input_type = parseInt($('input[name=attr_input_type]:checked').val());
  242. if (-1 < $.inArray(attr_input_type, [1,3,4]) && $.trim($('#attr_values').val()) == '') {
  243. showErrorMsg('可选值列表不能为空!');
  244. $('#attr_values').focus();
  245. return false;
  246. }
  247. layer_loading('正在处理');
  248. $.ajax({
  249. type : "POST",
  250. url : "{:url('Guestbook/attribute_add', ['_ajax'=>1])}",
  251. data : $('#'+form_id).serialize(),// 你的formid
  252. dataType: "JSON",
  253. success: function(res) {
  254. layer.closeAll();
  255. if(res.status == 1)
  256. {
  257. var _parent = parent;
  258. _parent.layer.close(parentObj);
  259. if(res.hasOwnProperty('data')){
  260. if(res.data.hasOwnProperty('url')){
  261. _parent.layer.msg(res.msg, {shade: layer_shade, time: 1000}, function(){
  262. _parent.gourl(res.data.url);
  263. });
  264. }else{
  265. _parent.layer.msg(res.msg, {shade: layer_shade, time: 1000}, function(){
  266. _parent.window.location.reload();
  267. });
  268. }
  269. }else{
  270. _parent.layer.msg(res.msg, {shade: layer_shade, time: 1000}, function(){
  271. _parent.window.location.reload();
  272. });
  273. }
  274. return true;
  275. } else {
  276. showErrorMsg(res.msg);
  277. return false;
  278. }
  279. },
  280. error: function(e) {
  281. layer.closeAll();
  282. showErrorAlert(e.responseText);
  283. return false;
  284. }
  285. });
  286. }
  287. function showlist(obj) {
  288. if ($(obj).val() == 0) {
  289. $("#show_list").hide();
  290. } else {
  291. $("#show_list").show();
  292. }
  293. }
  294. function ajax_attribute_show(obj) {
  295. var is_showlist = $(obj).attr('data-is_showlist');
  296. var typeid = $('#typeid').val();
  297. if (typeid == 0) {
  298. showErrorMsg('请选择栏目…!');
  299. $('#typeid').focus();
  300. return false;
  301. }
  302. $.ajax({
  303. type : 'post',
  304. url : "{:url('Field/ajax_attribute_show')}",
  305. data : {typeid:typeid,is_showlist:is_showlist, _ajax:1},
  306. dataType : 'json',
  307. success : function(res){
  308. if (res.code != 1) {
  309. $('#is_showlist1_label').removeClass('selected');
  310. $('#is_showlist0_label').addClass('selected');//添加一个class
  311. $("input:radio[name=is_showlist]").eq(0).attr("checked",false);
  312. $("input:radio[name=is_showlist]").eq(1).attr("checked",true);
  313. showErrorAlert(res.msg);
  314. }
  315. },
  316. error:function(e){
  317. showErrorAlert(e.responseText);
  318. }
  319. });
  320. }
  321. </script>
  322. {include file="public/footer" /}