Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

attribute_edit.htm 16KB

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