Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

attribute_add.htm 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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" style="min-width: auto;box-shadow:none;">
  7. <form class="form-horizontal" id="post_form" action="{:url('Field/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">
  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" id="dl_dfvalue" style="display: none;">
  115. <dt class="tit">
  116. <label id="label_dfvalue">默认值</label>
  117. </dt>
  118. <dd class="opt">
  119. <textarea rows="5" cols="60" id="dfvalue" name="dfvalue" placeholder="如果定义字段类型为下拉框、单选项、多选项时,此处填写被选择的项目(用“,”分开,如“男,女,人妖”)。" style="height:60px;"></textarea>
  120. <span class="err"></span>
  121. <p class="notic">1、如果定义字段类型为下拉框、单选项、多选项时,此处填写被选择的项目(用“,”分开,如“男,女,人妖”)。<br/>2、特殊符号会被过滤掉,比如:&、=、?等</p>
  122. </dd>
  123. </dl>
  124. <dl class="row">
  125. <dt class="tit">
  126. <label>前台必填</label>
  127. </dt>
  128. <dd class="opt">
  129. <div class="onoff">
  130. <label for="required1" class="cb-enable" >是</label>
  131. <input id="required1" name="required" value="1" type="radio">
  132. <label for="required0" class="cb-disable selected">否</label>
  133. <input id="required0" name="required" value="0" type="radio" checked="checked">
  134. </div>
  135. &nbsp;
  136. <span class="err"></span>
  137. <p class="notic">用于控制前台用户提交是否必填验证</p>
  138. </dd>
  139. </dl>
  140. <dl class="row" id="realValidate" style="display: none;">
  141. <dt class="tit"> <label>真实验证</label> </dt>
  142. <dd class="opt">
  143. <div class="onoff">
  144. <label for="real_validate1" class="cb-enable" >是</label>
  145. <input id="real_validate1" name="real_validate" value="1" type="radio">
  146. <label for="real_validate0" class="cb-disable selected">否</label>
  147. <input id="real_validate0" name="real_validate" value="0" type="radio" checked="checked">
  148. </div>
  149. &nbsp;
  150. <span class="err"></span>
  151. <p class="notic">用于控制前台用户提交的内容是否进行真实验证</p>
  152. <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>
  153. </dd>
  154. </dl>
  155. <div class="bot" style="padding-bottom: 0px;">
  156. <a href="JavaScript:void(0);" onclick="check_submit('post_form');" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
  157. </div>
  158. </div>
  159. </form>
  160. </div>
  161. <script type="text/javascript">
  162. var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  163. $(function(){
  164. if (0 == $('#RegionId').val() || -1 == $('#RegionId').val()) {
  165. $('#CityId').hide();
  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. layer.alert(e.responseText, {icon: 5});
  232. }
  233. });
  234. }
  235. /**
  236. * ajax 提交字段 到后台去验证然后回到前台提示错误
  237. * 验证通过后,再通过 form 自动提交
  238. */
  239. function check_submit(form_id)
  240. {
  241. if ($('#typeid').val() == 0) {
  242. showErrorMsg('请选择栏目…!');
  243. $('#typeid').focus();
  244. return false;
  245. }
  246. if($.trim($('input[name=attr_name]').val()) == ''){
  247. showErrorMsg('字段名称不能为空!');
  248. $('input[name=attr_name]').focus();
  249. return false;
  250. }
  251. var attr_input_type = parseInt($('input[name=attr_input_type]:checked').val());
  252. if (-1 < $.inArray(attr_input_type, [1,3,4]) && $.trim($('#attr_values').val()) == '') {
  253. showErrorMsg('可选值列表不能为空!');
  254. $('#attr_values').focus();
  255. return false;
  256. }
  257. layer_loading('正在处理');
  258. $.ajax({
  259. type : "POST",
  260. url : "{:url('Field/attribute_add', ['_ajax'=>1])}",
  261. data : $('#'+form_id).serialize(),// 你的formid
  262. dataType: "JSON",
  263. error: function(e) {
  264. layer.closeAll();
  265. layer.alert(e.responseText, {icon: 5, title:false});
  266. return false;
  267. },
  268. success: function(res) {
  269. layer.closeAll();
  270. if(res.code == 1)
  271. {
  272. if(!res.data.url){
  273. layer.msg(res.msg, {shade: layer_shade, time: 1000}, function(){
  274. window.location.reload();
  275. });
  276. }else{
  277. var _parent = parent;
  278. _parent.layer.close(parentObj);
  279. _parent.layer.msg(res.msg, {shade: layer_shade, time: 1000}, function(){
  280. _parent.gourl(res.data.url);
  281. });
  282. }
  283. return true;
  284. } else {
  285. showErrorMsg(res.msg);
  286. return false;
  287. }
  288. }
  289. });
  290. }
  291. function showlist(obj) {
  292. if ($(obj).val() == 0) {
  293. $("#show_list").hide();
  294. } else {
  295. $("#show_list").show();
  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. layer.alert(res.msg, {icon: 2, title:false});
  318. }
  319. },
  320. error:function(e){
  321. layer.alert(e.responseText, {icon: 2, title:false});
  322. }
  323. });
  324. }
  325. </script>
  326. {include file="public/footer" /}