Brak opisu
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 15KB

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