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.

attribute_edit.htm 17KB

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