No Description
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.

channel_edit.htm 22KB

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_edit')}" 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. {$channeltype_list[$info.channel_id]['title']}
  17. </dd>
  18. </dl>
  19. {/if}
  20. <dl class="row">
  21. <dt class="tit">
  22. <label for="title"><em>*</em>字段名称</label>
  23. </dt>
  24. <dd class="opt">
  25. <input type="text" value="{$info.title|default=''}" name="title" id="title" class="input-txt">
  26. <p class="notic"></p>
  27. </dd>
  28. </dl>
  29. <dl class="row">
  30. <dt class="tit">
  31. <label for="name"><em>*</em>字段标识</label>
  32. </dt>
  33. <dd class="opt">
  34. <input type="text" value="{$info.name|default=''}" 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,''));">
  35. <p class="notic">保持唯一性</p>
  36. </dd>
  37. </dl>
  38. <dl class="row">
  39. <dt class="tit">
  40. <label for="dtype"><em>*</em>数据类型</label>
  41. </dt>
  42. <dd class="opt">
  43. {volist name='$fieldtype_list' id='vo'}
  44. <div style="width: 150px; float: left;">
  45. <label><input type="radio" name="dtype" value="{$vo.name}" data-ifoption="{$vo.ifoption|default=0}" {eq name="$info.dtype" value="$vo.name"} checked="checked" {/eq} data-text="{$vo.title}">{$vo.title}</label>&nbsp;
  46. </div>
  47. {if condition="$i % 4 == 0"}<br/>{/if}
  48. {/volist}
  49. <input type="hidden" name="old_dtype" value="{$info.dtype}">
  50. <span class="err"></span>
  51. <p class="notic"></p>
  52. </dd>
  53. </dl>
  54. <div id='region_div' style="display: none;">
  55. <dl class="row">
  56. <dt class="tit">
  57. <label for="region"><em>*</em>区域选择</label>
  58. </dt>
  59. <dd class="opt">
  60. <select id="province" onchange="GetRegionData(this,'province');">
  61. <option value="-1">请选择</option>
  62. {volist name='$Province' id='P_V'}
  63. <option {if condition="$P_V.id == $region.parent_id"} selected {/if} value="{$P_V.id}">{$P_V.name}</option>
  64. {/volist}
  65. </select>
  66. <span id='CityId'>
  67. <select id="city" onchange="GetRegionData(this,'city');">
  68. <option value="{$region.parent_id}">请选择</option>
  69. {notempty name="$City"}
  70. {volist name='$City' id='C_V'}
  71. <option {if condition="$C_V.id == $region.region_id"} selected {/if} value="{$C_V.id}">{$C_V.name}</option>
  72. {/volist}
  73. {/notempty}
  74. </select>
  75. </span>
  76. <span class="err"></span>
  77. <p class="notic"></p>
  78. </dd>
  79. <input type="hidden" id="GetRegionDataUrl" value="{:url('Field/ajax_get_region_data')}">
  80. <input type="hidden" name="region_data[region_id]" id="RegionId" value="{$region.region_id}">
  81. </dl>
  82. <dl class="row">
  83. <dt class="tit">
  84. <label><em>*</em>默认值</label>
  85. </dt>
  86. <dd class="opt">
  87. <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>
  88. <span class="err"></span>
  89. <p class="notic">这里会自动区域选择之后的下级区域列表</p>
  90. </dd>
  91. <input type="hidden" name="region_data[region_ids]" id='region_ids' value='{$region.region_ids}' style="width: 100%;">
  92. </dl>
  93. <dl class="row">
  94. <dt class="tit">
  95. <label>三级区域联动</label>
  96. </dt>
  97. <dd class="opt">
  98. <div class="onoff">
  99. <label for="SetType_1" class="cb-enable {eq name='$info.set_type' value='1'}selected{/eq}">是</label>
  100. <input id="SetType_1" name="set_type" value="1" type="radio" onclick="change_set_type(this);">
  101. <label for="SetType_0" class="cb-disable {empty name='$info.set_type'}selected{/empty}">否</label>
  102. <input id="SetType_0" name="set_type" value="0" type="radio" onclick="change_set_type(this);">
  103. </div>
  104. &nbsp;
  105. <span class="err"></span>
  106. <p class="notic">是否开启三级联动</p>
  107. </dd>
  108. </dl>
  109. </div>
  110. <dl class="row" id="dl_dfvalue">
  111. <dt class="tit">
  112. <label id="label_dfvalue">默认值</label>
  113. </dt>
  114. <dd class="opt">
  115. <textarea rows="5" cols="60" id="dfvalue" name="dfvalue" placeholder="如果定义字段类型为下拉框、单选项、多选项时,此处填写被选择的项目(用“,”分开,如“男,女,人妖”)。" style="height:60px;">{$info.dfvalue|default=''}</textarea>
  116. <textarea rows="5" cols="60" name="old_dfvalue" style="display: none;">{$info.dfvalue|default=''}</textarea>
  117. <span class="err"></span>
  118. <p class="notic">1、如果定义字段类型为下拉框、单选项、多选项时,默认值为必填项,不支持反斜杠 \ ,可以用斜杠 / 代替。<br/>2、特殊符号会被过滤掉,比如:&、=、?等<br/>3、定义字段类型为多选项时,默认值最多为64项,超出则截取前64项</p>
  119. </dd>
  120. </dl>
  121. <dl class="row" id="dl_dfvalue_unit">
  122. <dt class="tit">
  123. <label for="dfvalue_unit">数值单位</label>
  124. </dt>
  125. <dd class="opt">
  126. <input type="text" value="{$info.dfvalue_unit|default=''}" name="dfvalue_unit" id="dfvalue_unit" placeholder="比如:元、个、件等等" class="input-txt">
  127. <p class="notic"></p>
  128. </dd>
  129. </dl>
  130. <dl class="row" id='IsRelease' {eq name='$userConfig.users_open_release' value='0'} style="display: none;" {/eq}>
  131. <dt class="tit">
  132. <label>支持投稿</label>
  133. </dt>
  134. <dd class="opt">
  135. <label class="curpoin"><input id="IsRelease_1" name="is_release" value="1" type="radio" {if condition="$info.is_release == 1"}checked="checked"{/if}>是</label>
  136. &nbsp;
  137. <label class="curpoin"><input id="IsRelease_0" name="is_release" value="0" type="radio" {if condition="!isset($info.is_release) || empty($info.is_release)"}checked="checked"{/if}>否</label>
  138. &nbsp;
  139. <span class="err"></span>
  140. <p class="notic">是否应用于会员投稿中</p>
  141. </dd>
  142. </dl>
  143. <dl class="row" id='IsScreening' style="display: none;">
  144. <dt class="tit">
  145. <label>支持筛选</label>
  146. </dt>
  147. <dd class="opt">
  148. <label class="curpoin"><input id="IsScreening_1" name="is_screening" value="1" type="radio" {if condition="$info.is_screening == 1"}checked="checked"{/if}>是</label>
  149. &nbsp;
  150. <label class="curpoin"><input id="IsScreening_0" name="is_screening" value="0" type="radio" {if condition="!isset($info.is_screening) || empty($info.is_screening)"}checked="checked"{/if}>否</label>
  151. <input type="hidden" name="IsScreening_status" value="0">
  152. &nbsp;
  153. <span class="err"></span>
  154. <p class="notic">是否应用于列表的条件筛选中</p>
  155. <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="{if condition='!isset($info.is_screening) || empty($info.is_screening)'}none{/if}">查看标签调用</a>
  156. </dd>
  157. </dl>
  158. <dl class="row">
  159. <dt class="tit">
  160. <label>提示文字</label>
  161. </dt>
  162. <dd class="opt">
  163. <textarea rows="5" cols="60" id="remark" name="remark" placeholder="问号提示文字" style="height:60px;">{$info.remark|default=''}</textarea>
  164. <span class="err"></span>
  165. <p class="notic">问号提示文字</p>
  166. </dd>
  167. </dl>
  168. <dl class="row">
  169. <dt class="tit">
  170. <label for="title" id="select_title">指定栏目</label>
  171. </dt>
  172. <dd class="opt">
  173. <select name="typeids[]" id="typeid" style="width: 300px;" size="15" multiple="true">
  174. <option value="0" {if condition="in_array(0, $typeids) OR empty($typeids)"}selected="true"{/if}>
  175. —指定所有栏目—
  176. </option>
  177. {$select_html}
  178. </select>
  179. <span class="err"></span>
  180. <p class="red">(按 Ctrl 可以进行多选)</p>
  181. </dd>
  182. </dl>
  183. <!-- <dl class="row">
  184. <dt class="tit">
  185. <label for="sort_order">排序</label>
  186. </dt>
  187. <dd class="opt">
  188. <input type="text" value="{$info.sort_order|default=100}" name="sort_order" id="sort_order" class="input-txt">
  189. <p class="notic">越小越靠前</p>
  190. </dd>
  191. </dl> -->
  192. </div>
  193. <!-- 常规选项 -->
  194. <div class="ncap-form-default">
  195. <div class="bot">
  196. <input type="hidden" name="channel_id" id="channel_id" value="{$info.channel_id|default=''}">
  197. <input type="hidden" name="id" id="id" value="{$info.id|default=''}">
  198. <input type="hidden" name="old_name" id="old_name" value="{$info.name|default=''}">
  199. <a href="JavaScript:void(0);" onclick="check_submit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
  200. </div>
  201. </div>
  202. </form>
  203. </div>
  204. <script type="text/javascript">
  205. function change_set_type(obj) {
  206. var val = $(obj).val();
  207. if (1 == val) {
  208. // $("#IsScreening_1").prop('checked', false);
  209. // $("#IsScreening_0").prop('checked', true);
  210. // $("#IsScreening").find('label').eq(1).removeClass('selected');
  211. // $("#IsScreening").find('label').eq(2).addClass('selected');
  212. // $("#IsScreening").hide();
  213. $("#call_tags_help").hide();
  214. } else {
  215. // $("#IsScreening").show();
  216. }
  217. }
  218. $(function(){
  219. // 判断是否隐藏第二级地区选择栏
  220. var parent_array = {$parent_array};
  221. if (parent_array) {
  222. var region_id = $('#RegionId').val();
  223. if (0 <= $.inArray(region_id, parent_array)) {
  224. $('#CityId').hide();
  225. }
  226. }
  227. var screening_value = $('input:radio[name="is_screening"]:checked').val();
  228. $('#IsScreening_'+screening_value).click();
  229. dtype_change($('input[name=dtype]:checked'));
  230. $('input[name=dtype]').click(function(){
  231. /*多选项不能切换为指定的字段类型*/
  232. var dtype = $(this).val();
  233. var old_dtype = $('input[name=old_dtype]').val();
  234. if (('checkbox' == old_dtype && 0 <= $.inArray(dtype, ['radio','select'])) || 'media' == old_dtype) {
  235. $("input[name=dtype][value="+old_dtype+"]").attr("checked",'checked');
  236. var old_dtype_text = $("input[name=dtype][value="+old_dtype+"]").data('text');
  237. var dtype_text = $("input[name=dtype][value="+dtype+"]").data('text');
  238. showErrorMsg(old_dtype_text+"不能更改为"+dtype_text+"!");
  239. $(this).focus();
  240. return false;
  241. }
  242. /*end*/
  243. dtype_change(this);
  244. });
  245. function dtype_change(obj) {
  246. var dtype = $(obj).val();
  247. var ifoption = $(obj).data('ifoption');
  248. if (0 <= $.inArray(dtype, ['datetime','switch','img','imgs','file','media'])) {
  249. $('#dl_dfvalue').hide();
  250. ClearAreaData();
  251. } else if ('region' == dtype) {
  252. $('#region_div').show();
  253. $('#dl_dfvalue').hide();
  254. } else {
  255. $('#dl_dfvalue').show();
  256. ClearAreaData();
  257. }
  258. if (1 == ifoption) {
  259. $('#label_dfvalue').html('<em>*</em>默认值');
  260. } else {
  261. $('#label_dfvalue').html('默认值');
  262. }
  263. if (0 <= $.inArray(dtype, ['text','multitext'])) {
  264. $('#dfvalue').attr('placeholder', '前端将默认显示输入的默认值');
  265. } else if (0 <= $.inArray(dtype, ['checkbox','radio','select'])) {
  266. $('#dfvalue').attr('placeholder', '此处填写被选择的项目(用“,”分开,如“男,女”)。');
  267. } else {
  268. $('#dfvalue').attr('placeholder', '前端将默认显示输入的默认值');
  269. }
  270. if (0 <= $.inArray(dtype, ['region','checkbox','radio','select'])) {
  271. $('#IsScreening').show();
  272. $('input[name=IsScreening_status]').val(1);
  273. } else {
  274. $('#IsScreening').hide();
  275. $('input[name=IsScreening_status]').val(0);
  276. $('#select_title').html('指定栏目');
  277. }
  278. if (0 <= $.inArray(dtype, ['text','int','float','decimal'])) {
  279. $('#dl_dfvalue_unit').show();
  280. } else {
  281. $('#dl_dfvalue_unit').hide();
  282. }
  283. //如果开启了区域三级联动 隐藏用于筛选
  284. var set_type = "{$info.set_type|default=0}";
  285. if (1 == set_type && 'region' == dtype ) {
  286. // $("#IsScreening").hide();
  287. }
  288. }
  289. });
  290. // 当切换其他类型时清空所有关于区域选择的数据
  291. function ClearAreaData(){
  292. $('#region_div').hide();
  293. $('#RegionId').val('');
  294. $('#region_names').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_edit', ['_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" /}