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.

channel_add.htm 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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 min-hg-c-i">
  7. <form class="form-horizontal" id="post_form" action="{:url('Field/channel_add')}" method="post">
  8. <!-- 常规选项 -->
  9. <div class="ncap-form-default tab_div_1">
  10. {if condition="!empty($type) && 'all' == $type"}
  11. <dl class="row">
  12. <dt class="tit">
  13. <label><em>*</em>所属模型</label>
  14. </dt>
  15. <dd class="opt">
  16. <select name="channel_id" id="channel_id" onchange="channelSelect(this);">
  17. <option value="0">请选择模型</option>
  18. {volist name="$channeltype_list" id="vo"}
  19. <option value="{$vo.id}">{$vo.title}</option>
  20. {/volist}
  21. </select>
  22. </dd>
  23. </dl>
  24. <script type="text/javascript">
  25. function channelSelect(obj) {
  26. var channel_id = $(obj).val();
  27. var resData = '<option value="0" selected="false">—指定所有栏目—</option>';
  28. if (channel_id && channel_id > 0) {
  29. $.ajax({
  30. type: 'post',
  31. url : "{:url('Field/channel_select')}",
  32. data: {'_ajax': 1, channel_id: channel_id},
  33. dataType: 'json',
  34. success: function(res){
  35. if (res.code == 1) {
  36. resData = resData + res.data;
  37. $('#typeid').empty().html(resData);
  38. } else {
  39. showErrorMsg(res.msg);
  40. }
  41. },
  42. error: function(e){
  43. layer.alert(e.responseText, {icon: 5, title: false, closeBtn: false});
  44. }
  45. });
  46. } else {
  47. $('#typeid').empty().html(resData);
  48. }
  49. }
  50. </script>
  51. {/if}
  52. <dl class="row">
  53. <dt class="tit">
  54. <label for="title"><em>*</em>字段名称</label>
  55. </dt>
  56. <dd class="opt">
  57. <input type="text" value="" name="title" id="title" class="input-txt">
  58. <p class="notic"></p>
  59. </dd>
  60. </dl>
  61. <dl class="row">
  62. <dt class="tit">
  63. <label for="name"><em>*</em>字段标识</label>
  64. </dt>
  65. <dd class="opt">
  66. <input type="text" value="" name="name" id="name" placeholder="支持字母、数字和下划线,不能和别的标识值相同" class="input-txt" onkeyup="this.value=this.value.replace(/[^0-9a-zA-Z_]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^0-9a-zA-Z_]/g,''));">
  67. <p class="notic">保持唯一性</p>
  68. </dd>
  69. </dl>
  70. <dl class="row">
  71. <dt class="tit">
  72. <label for="dtype"><em>*</em>数据类型</label>
  73. </dt>
  74. <dd class="opt">
  75. {volist name='$fieldtype_list' id='vo'}
  76. <div style="width: 150px; float: left;">
  77. <label><input type="radio" name="dtype" value="{$vo.name}" data-ifoption="{$vo.ifoption|default=0}" {eq name='$i' value='1'} checked="checked" {/eq} data-text="{$vo.title}">{$vo.title}</label>&nbsp;
  78. </div>
  79. {if condition="$i % 4 == 0"}<br/>{/if}
  80. {/volist}
  81. <span class="err"></span>
  82. <p class="notic"></p>
  83. </dd>
  84. </dl>
  85. <div id='region_div' style="display: none;">
  86. <dl class="row">
  87. <dt class="tit">
  88. <label for="region"><em>*</em>区域选择</label>
  89. </dt>
  90. <dd class="opt">
  91. <select id="province" onchange="GetRegionData(this,'province');">
  92. <option value="-1">请选择</option>
  93. {volist name='$Province' id='P_V'}
  94. <option value="{$P_V.id}">{$P_V.name}</option>
  95. {/volist}
  96. </select>
  97. <span id='CityId'>
  98. <select id="city" onchange="GetRegionData(this,'city');">
  99. <option value="">请选择</option>
  100. </select>
  101. </span>
  102. <span class="err"></span>
  103. <p class="notic"></p>
  104. </dd>
  105. <input type="hidden" id="GetRegionDataUrl" value="{:url('Field/ajax_get_region_data')}">
  106. <input type="hidden" name="region_data[region_id]" id="RegionId" value="-1">
  107. </dl>
  108. <dl class="row">
  109. <dt class="tit">
  110. <label><em>*</em>默认值</label>
  111. </dt>
  112. <dd class="opt">
  113. <textarea rows="5" cols="60" name="region_data[region_names]" id="region_names" readonly='readonly' placeholder="这里会自动区域选择之后的下级区域列表" style="height:110px; background-color: #f5f5f5;"></textarea>
  114. <span class="err"></span>
  115. <p class="notic">这里会自动区域选择之后的下级区域列表</p>
  116. </dd>
  117. <input type="hidden" name="region_data[region_ids]" id='region_ids' value='' style="width: 100%;">
  118. </dl>
  119. <dl class="row">
  120. <dt class="tit">
  121. <label>三级区域联动</label>
  122. </dt>
  123. <dd class="opt">
  124. <div class="onoff">
  125. <label for="SetType_1" class="cb-enable">是</label>
  126. <input id="SetType_1" name="set_type" value="1" type="radio" onclick="change_set_type(this);">
  127. <label for="SetType_0" class="cb-disable selected">否</label>
  128. <input id="SetType_0" name="set_type" value="0" type="radio" onclick="change_set_type(this);">
  129. </div>
  130. &nbsp;
  131. <span class="err"></span>
  132. <p class="notic">是否开启三级联动</p>
  133. </dd>
  134. </dl>
  135. </div>
  136. <dl class="row" id="dl_dfvalue">
  137. <dt class="tit">
  138. <label id="label_dfvalue">默认值</label>
  139. </dt>
  140. <dd class="opt">
  141. <textarea rows="5" cols="60" id="dfvalue" name="dfvalue" placeholder="前端将默认显示输入的默认值" style="height:60px;"></textarea>
  142. <span class="err"></span>
  143. <p class="notic">1、如果定义字段类型为下拉框、单选项、多选项时,默认值为必填项,不支持反斜杠 \ ,可以用斜杠 / 代替。<br/>2、特殊符号会被过滤掉,比如:&、=、?等<br/>3、定义字段类型为多选项时,默认值最多为64项,超出则截取前64项</p>
  144. </dd>
  145. </dl>
  146. <dl class="row" id="dl_dfvalue_unit">
  147. <dt class="tit">
  148. <label for="dfvalue_unit">数值单位</label>
  149. </dt>
  150. <dd class="opt">
  151. <input type="text" value="" name="dfvalue_unit" id="dfvalue_unit" placeholder="比如:元、个、件等等" class="input-txt">
  152. <p class="notic">比如:元、个、件等等</p>
  153. </dd>
  154. </dl>
  155. <dl class="row" id='IsRelease' {eq name='$userConfig.users_open_release' value='0'} style="display: none;" {/eq}>
  156. <dt class="tit">
  157. <label>支持投稿</label>
  158. </dt>
  159. <dd class="opt">
  160. <label class="curpoin"><input id="IsRelease_1" name="is_release" value="1" type="radio" >是</label>
  161. &nbsp;
  162. <label class="curpoin"><input id="IsRelease_0" name="is_release" value="0" type="radio" checked="checked">否</label>
  163. &nbsp;
  164. <span class="err"></span>
  165. <p class="notic">是否应用于会员投稿中</p>
  166. </dd>
  167. </dl>
  168. <dl class="row" id='IsScreening' style="display: none;">
  169. <dt class="tit">
  170. <label>支持筛选</label>
  171. </dt>
  172. <dd class="opt">
  173. <label class="curpoin"><input id="IsScreening_1" name="is_screening" value="1" type="radio" >是</label>
  174. &nbsp;
  175. <label class="curpoin"><input id="IsScreening_0" name="is_screening" value="0" type="radio" checked="checked">否</label>
  176. <input type="hidden" name="IsScreening_status" value="0">
  177. &nbsp;
  178. <span class="err"></span>
  179. <p class="notic">是否应用于列表的条件筛选中</p>
  180. <a id="call_tags_help" href="JavaScript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=7881&origin_eycms=1','筛选标签调用')" class="none">查看标签调用</a>
  181. </dd>
  182. </dl>
  183. <dl class="row">
  184. <dt class="tit">
  185. <label>提示文字</label>
  186. </dt>
  187. <dd class="opt">
  188. <textarea rows="5" cols="60" id="remark" name="remark" placeholder="问号提示文字" style="height:60px;"></textarea>
  189. <span class="err"></span>
  190. <p class="notic"></p>
  191. </dd>
  192. </dl>
  193. <dl class="row">
  194. <dt class="tit">
  195. <label for="title" id="select_title">指定栏目</label>
  196. </dt>
  197. <dd class="opt">
  198. <select name="typeids[]" id="typeid" style="width: 300px;" size="15" multiple="true">
  199. <option value="0" selected="false">—指定所有栏目—</option>
  200. {$select_html}
  201. </select>
  202. <span class="err"></span>
  203. <p class="red">(按 Ctrl 可以进行多选)</p>
  204. </dd>
  205. </dl>
  206. <!-- <dl class="row">
  207. <dt class="tit">
  208. <label for="sort_order">排序</label>
  209. </dt>
  210. <dd class="opt">
  211. <input type="text" value="100" name="sort_order" id="sort_order" class="input-txt">
  212. <p class="notic">越小越靠前</p>
  213. </dd>
  214. </dl> -->
  215. </div>
  216. <!-- 常规选项 -->
  217. <div class="ncap-form-default">
  218. <div class="bot">
  219. {if condition="empty($type)"}
  220. <input type="hidden" name="channel_id" id="channel_id" value="{$channel_id|default=''}">
  221. {/if}
  222. <a href="JavaScript:void(0);" onclick="check_submit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
  223. </div>
  224. </div>
  225. </form>
  226. </div>
  227. <script type="text/javascript">
  228. function change_set_type(obj) {
  229. var val = $(obj).val();
  230. if (1 == val) {
  231. // $("#IsScreening_1").prop('checked',false);
  232. // $("#IsScreening_0").prop('checked',true);
  233. // $("#IsScreening").find('label').eq(1).removeClass('selected');
  234. // $("#IsScreening").find('label').eq(2).addClass('selected');
  235. // $("#IsScreening").hide();
  236. $("#call_tags_help").hide();
  237. }else{
  238. // $("#IsScreening").show();
  239. }
  240. }
  241. $(function(){
  242. if (0 == $('#RegionId').val() || -1 == $('#RegionId').val()) {
  243. $('#CityId').hide();
  244. }
  245. var screening_value = $('input:radio[name="is_screening"]:checked').val();
  246. $('#IsScreening_'+screening_value).click();
  247. $('input[name=dtype]').click(function(){
  248. dtype_change(this);
  249. });
  250. function dtype_change(obj) {
  251. var dtype = $(obj).val();
  252. var ifoption = $(obj).data('ifoption');
  253. if (0 <= $.inArray(dtype, ['datetime','switch','img','imgs','file','media'])) {
  254. $('#dl_dfvalue').hide();
  255. ClearAreaData();
  256. } else if ('region' == dtype) {
  257. $('#region_div').show();
  258. $('#dl_dfvalue').hide();
  259. } else {
  260. $('#dl_dfvalue').show();
  261. ClearAreaData();
  262. }
  263. if (1 == ifoption) {
  264. $('#label_dfvalue').html('<em>*</em>默认值');
  265. } else {
  266. $('#label_dfvalue').html('默认值');
  267. }
  268. if (0 <= $.inArray(dtype, ['text','multitext'])) {
  269. $('#dfvalue').attr('placeholder', '前端将默认显示输入的默认值');
  270. } else if (0 <= $.inArray(dtype, ['checkbox','radio','select'])) {
  271. $('#dfvalue').attr('placeholder', '此处填写被选择的项目(用“,”分开,如“男,女”)。');
  272. } else {
  273. $('#dfvalue').attr('placeholder', '前端将默认显示输入的默认值');
  274. }
  275. if (0 <= $.inArray(dtype, ['region','checkbox','radio','select'])) {
  276. $('#IsScreening').show();
  277. $('input[name=IsScreening_status]').val(1);
  278. } else {
  279. $('#IsScreening').hide();
  280. $('input[name=IsScreening_status]').val(0);
  281. $('#select_title').html('指定栏目');
  282. }
  283. if (0 <= $.inArray(dtype, ['text','int','float','decimal'])) {
  284. $('#dl_dfvalue_unit').show();
  285. } else {
  286. $('#dl_dfvalue_unit').hide();
  287. }
  288. }
  289. });
  290. // 当切换其他类型时清空所有关于区域选择的数据
  291. function ClearAreaData(){
  292. $('#region_div').hide();
  293. $('#RegionId').val('');
  294. $('#region_dfvalue').empty();
  295. }
  296. // 获取联动地址
  297. function GetRegionData(t,type){
  298. var parent_id = $(t).val();
  299. if(!parent_id){
  300. return false;
  301. }
  302. var url = $('#GetRegionDataUrl').val();
  303. $.ajax({
  304. url: url,
  305. data: {parent_id:parent_id,_ajax:1},
  306. type:'post',
  307. dataType:'json',
  308. success:function(res){
  309. // 判断是否隐藏第二级地区选择栏
  310. if (0 <= $.inArray(parent_id, res.parent_array)) {
  311. $('#CityId').hide();
  312. }else{
  313. $('#CityId').show();
  314. }
  315. // 加载城市名称数据到textarea
  316. $('#region_names').empty().html(res.region_names);
  317. // 加载城市ID数据到input
  318. $('#region_ids').val(res.region_ids);
  319. // 加载ID到input
  320. $('#RegionId').val(parent_id);
  321. // 输出下一级栏目选项
  322. if ('province' == type) {
  323. res = '<option value='+parent_id+'>请选择</option>'+ res.region_html;
  324. $('#city').empty().html(res);
  325. }
  326. },
  327. error : function(e) {
  328. layer.closeAll();
  329. layer.alert(e.responseText, {icon: 5});
  330. }
  331. });
  332. }
  333. $('#IsScreening_1').click(function(){
  334. $('#select_title').html('<em>*</em>指定栏目');
  335. $('#typeid').find('option:first').attr('disabled', true).css('display', 'none');
  336. $('#call_tags_help').show();
  337. });
  338. $('#IsScreening_0').click(function(){
  339. $('#select_title').html('指定栏目');
  340. $('#typeid').find('option:first').attr('disabled', false).css('display', '');
  341. $('#call_tags_help').hide();
  342. });
  343. var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  344. function check_submit(){
  345. if($('input[name="title"]').val() == ''){
  346. showErrorMsg('字段标题不能为空!');
  347. $('input[name=title]').focus();
  348. return false;
  349. }
  350. var name = $('input[name="name"]').val();
  351. var ret1 = /^[_]+$/;
  352. var ret2 = /^[\w]+$/;
  353. var ret3 = /^[0-9]+$/;
  354. if (ret1.test(name) || !ret2.test(name)) {
  355. showErrorMsg('字段名称格式不正确!');
  356. $('input[name=name]').focus();
  357. return false;
  358. } else if (ret3.test(name)) {
  359. showErrorMsg('字段名称不能纯数字!');
  360. $('input[name=name]').focus();
  361. return false;
  362. }
  363. if($('input[name=dtype]:checked').val() == ''){
  364. showErrorMsg('请选择字段类型!');
  365. $('input[name=dtype]').focus();
  366. return false;
  367. } else if ('region' == $('input[name=dtype]:checked').val()){
  368. if (-1 == $('#RegionId').val()) {
  369. showErrorMsg('请选择区域范围!');
  370. $('#province').focus();
  371. return false;
  372. }
  373. } else {
  374. var ifoption = $('input[name=dtype]:checked').data('ifoption');
  375. if (1 == ifoption) {
  376. if ($.trim($('#dfvalue').val()) == '') {
  377. showErrorMsg('默认值不能为空!');
  378. $('#dfvalue').focus();
  379. return false;
  380. }
  381. var tag = '|';
  382. if($('#dfvalue').val().indexOf(tag) != -1){
  383. showErrorMsg('默认值不能输入 | 符号!');
  384. $('#dfvalue').focus();
  385. return false;
  386.   }
  387. }
  388. if (0 <= $.inArray($('input[name=dtype]:checked').val(), ['radio','checkbox','select'])) {
  389. var dfvalue = $.trim($('#dfvalue').val());
  390. if(dfvalue.indexOf('\\') != -1){
  391.    showErrorMsg('默认值不支持反斜杠 \\ ,可用斜杠 / 代替');
  392. $('#dfvalue').focus();
  393. return false;
  394.   }
  395. data = dfvalue.split(',');
  396. for(var i = 0;i < data.length ;i++) {
  397. for(var j = i+1;j < data.length;j++) {
  398. if ($.trim(data[i]) == $.trim(data [j])){
  399. showErrorMsg('默认值不能含有相同的值!');
  400. $('#dfvalue').focus();
  401. return false;
  402. }
  403. }
  404. }
  405. if (0 <= $.inArray($('input[name=dtype]:checked').val(), ['checkbox'])) {
  406. if (64 < data.length) {
  407. showErrorMsg('默认值最多填写64项!');
  408. $('#dfvalue').focus();
  409. return false;
  410. }
  411. }
  412. }
  413. }
  414. if (0 >= parseInt($('#typeid').find('option:selected').length)) {
  415. showErrorMsg('请选择指定栏目!');
  416. $('#typeid').focus();
  417. return false;
  418. }
  419. // 字段支持筛选时,指定栏目必须指定一个或多个栏目
  420. if (1 == parseInt($('input:radio[name="is_screening"]:checked').val())) {
  421. if (0 == parseInt($('#typeid').find('option:selected').val())) {
  422. if (1 >= $('#typeid').val().length) {
  423. showErrorMsg('字段支持筛选时,栏目必须指定一个或多个!');
  424. $('#typeid').focus();
  425. return false;
  426. }
  427. }
  428. }
  429. layer_loading('正在处理');
  430. $.ajax({
  431. type : 'post',
  432. url : "{:url('Field/channel_add', ['_ajax'=>1])}",
  433. data : $('#post_form').serialize(),
  434. dataType : 'json',
  435. success : function(res){
  436. layer.closeAll();
  437. if(res.code == 1){
  438. var _parent = parent;
  439. _parent.layer.close(parentObj);
  440. _parent.layer.msg(res.msg, {shade: layer_shade, time: 1000}, function(){
  441. _parent.window.location.reload();
  442. });
  443. }else{
  444. showErrorMsg(res.msg);
  445. }
  446. },
  447. error: function(e){
  448. layer.closeAll();
  449. layer.alert(e.responseText, {icon: 5, title:false});
  450. }
  451. });
  452. }
  453. </script>
  454. {include file="public/footer" /}