123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 |
- {include file="public/layout" /}
-
- <body class="bodystyle">
- <div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
- <div id="append_parent"></div>
- <div id="ajaxwaitid"></div>
- <div class="page min-hg-c-i">
- <form class="form-horizontal" id="post_form" action="{:url('Field/channel_add')}" method="post">
- <!-- 常规选项 -->
- <div class="ncap-form-default tab_div_1">
- {if condition="!empty($type) && 'all' == $type"}
- <dl class="row">
- <dt class="tit">
- <label><em>*</em>所属模型</label>
- </dt>
- <dd class="opt">
- <select name="channel_id" id="channel_id" onchange="channelSelect(this);">
- <option value="0">请选择模型</option>
- {volist name="$channeltype_list" id="vo"}
- <option value="{$vo.id}">{$vo.title}</option>
- {/volist}
- </select>
- </dd>
- </dl>
- <script type="text/javascript">
- function channelSelect(obj) {
- var channel_id = $(obj).val();
- var resData = '<option value="0" selected="false">—指定所有栏目—</option>';
- if (channel_id && channel_id > 0) {
- $.ajax({
- type: 'post',
- url : "{:url('Field/channel_select')}",
- data: {'_ajax': 1, channel_id: channel_id},
- dataType: 'json',
- success: function(res){
- if (res.code == 1) {
- resData = resData + res.data;
- $('#typeid').empty().html(resData);
- } else {
- showErrorMsg(res.msg);
- }
- },
- error: function(e){
- layer.alert(e.responseText, {icon: 5, title: false, closeBtn: false});
- }
- });
- } else {
- $('#typeid').empty().html(resData);
- }
- }
- </script>
- {/if}
- <dl class="row">
- <dt class="tit">
- <label for="title"><em>*</em>字段名称</label>
- </dt>
- <dd class="opt">
- <input type="text" value="" name="title" id="title" class="input-txt">
- <p class="notic"></p>
- </dd>
- </dl>
- <dl class="row">
- <dt class="tit">
- <label for="name"><em>*</em>字段标识</label>
- </dt>
- <dd class="opt">
- <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,''));">
- <p class="notic">保持唯一性</p>
- </dd>
- </dl>
- <dl class="row">
- <dt class="tit">
- <label for="dtype"><em>*</em>数据类型</label>
- </dt>
- <dd class="opt">
- {volist name='$fieldtype_list' id='vo'}
- <div style="width: 150px; float: left;">
- <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>
- </div>
- {if condition="$i % 4 == 0"}<br/>{/if}
- {/volist}
- <span class="err"></span>
- <p class="notic"></p>
- </dd>
- </dl>
-
- <div id='region_div' style="display: none;">
- <dl class="row">
- <dt class="tit">
- <label for="region"><em>*</em>区域选择</label>
- </dt>
- <dd class="opt">
- <select id="province" onchange="GetRegionData(this,'province');">
- <option value="-1">请选择</option>
- {volist name='$Province' id='P_V'}
- <option value="{$P_V.id}">{$P_V.name}</option>
- {/volist}
- </select>
-
- <span id='CityId'>
- <select id="city" onchange="GetRegionData(this,'city');">
- <option value="">请选择</option>
- </select>
- </span>
- <span class="err"></span>
- <p class="notic"></p>
- </dd>
- <input type="hidden" id="GetRegionDataUrl" value="{:url('Field/ajax_get_region_data')}">
- <input type="hidden" name="region_data[region_id]" id="RegionId" value="-1">
- </dl>
-
- <dl class="row">
- <dt class="tit">
- <label><em>*</em>默认值</label>
- </dt>
- <dd class="opt">
- <textarea rows="5" cols="60" name="region_data[region_names]" id="region_names" readonly='readonly' placeholder="这里会自动区域选择之后的下级区域列表" style="height:110px; background-color: #f5f5f5;"></textarea>
- <span class="err"></span>
- <p class="notic">这里会自动区域选择之后的下级区域列表</p>
- </dd>
- <input type="hidden" name="region_data[region_ids]" id='region_ids' value='' style="width: 100%;">
- </dl>
-
- <dl class="row">
- <dt class="tit">
- <label>三级区域联动</label>
- </dt>
- <dd class="opt">
- <div class="onoff">
- <label for="SetType_1" class="cb-enable">是</label>
- <input id="SetType_1" name="set_type" value="1" type="radio" onclick="change_set_type(this);">
-
- <label for="SetType_0" class="cb-disable selected">否</label>
- <input id="SetType_0" name="set_type" value="0" type="radio" onclick="change_set_type(this);">
- </div>
-
- <span class="err"></span>
- <p class="notic">是否开启三级联动</p>
- </dd>
- </dl>
- </div>
-
- <dl class="row" id="dl_dfvalue">
- <dt class="tit">
- <label id="label_dfvalue">默认值</label>
- </dt>
- <dd class="opt">
- <textarea rows="5" cols="60" id="dfvalue" name="dfvalue" placeholder="前端将默认显示输入的默认值" style="height:60px;"></textarea>
- <span class="err"></span>
- <p class="notic">1、如果定义字段类型为下拉框、单选项、多选项时,默认值为必填项,不支持反斜杠 \ ,可以用斜杠 / 代替。<br/>2、特殊符号会被过滤掉,比如:&、=、?等<br/>3、定义字段类型为多选项时,默认值最多为64项,超出则截取前64项</p>
- </dd>
- </dl>
- <dl class="row" id="dl_dfvalue_unit">
- <dt class="tit">
- <label for="dfvalue_unit">数值单位</label>
- </dt>
- <dd class="opt">
- <input type="text" value="" name="dfvalue_unit" id="dfvalue_unit" placeholder="比如:元、个、件等等" class="input-txt">
- <p class="notic">比如:元、个、件等等</p>
- </dd>
- </dl>
- <dl class="row" id='IsRelease' {eq name='$userConfig.users_open_release' value='0'} style="display: none;" {/eq}>
- <dt class="tit">
- <label>支持投稿</label>
- </dt>
- <dd class="opt">
- <label class="curpoin"><input id="IsRelease_1" name="is_release" value="1" type="radio" >是</label>
-
- <label class="curpoin"><input id="IsRelease_0" name="is_release" value="0" type="radio" checked="checked">否</label>
-
- <span class="err"></span>
- <p class="notic">是否应用于会员投稿中</p>
- </dd>
- </dl>
- <dl class="row" id='IsScreening' style="display: none;">
- <dt class="tit">
- <label>支持筛选</label>
- </dt>
- <dd class="opt">
- <label class="curpoin"><input id="IsScreening_1" name="is_screening" value="1" type="radio" >是</label>
-
- <label class="curpoin"><input id="IsScreening_0" name="is_screening" value="0" type="radio" checked="checked">否</label>
- <input type="hidden" name="IsScreening_status" value="0">
-
- <span class="err"></span>
- <p class="notic">是否应用于列表的条件筛选中</p>
- <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>
- </dd>
- </dl>
-
- <dl class="row">
- <dt class="tit">
- <label>提示文字</label>
- </dt>
- <dd class="opt">
- <textarea rows="5" cols="60" id="remark" name="remark" placeholder="问号提示文字" style="height:60px;"></textarea>
- <span class="err"></span>
- <p class="notic"></p>
- </dd>
- </dl>
- <dl class="row">
- <dt class="tit">
- <label for="title" id="select_title">指定栏目</label>
- </dt>
- <dd class="opt">
- <select name="typeids[]" id="typeid" style="width: 300px;" size="15" multiple="true">
- <option value="0" selected="false">—指定所有栏目—</option>
- {$select_html}
- </select>
- <span class="err"></span>
- <p class="red">(按 Ctrl 可以进行多选)</p>
- </dd>
- </dl>
- <!-- <dl class="row">
- <dt class="tit">
- <label for="sort_order">排序</label>
- </dt>
- <dd class="opt">
- <input type="text" value="100" name="sort_order" id="sort_order" class="input-txt">
- <p class="notic">越小越靠前</p>
- </dd>
- </dl> -->
- </div>
- <!-- 常规选项 -->
- <div class="ncap-form-default">
- <div class="bot">
- {if condition="empty($type)"}
- <input type="hidden" name="channel_id" id="channel_id" value="{$channel_id|default=''}">
- {/if}
- <a href="JavaScript:void(0);" onclick="check_submit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
- </div>
- </div>
- </form>
- </div>
- <script type="text/javascript">
- function change_set_type(obj) {
- var val = $(obj).val();
- if (1 == val) {
- // $("#IsScreening_1").prop('checked',false);
- // $("#IsScreening_0").prop('checked',true);
- // $("#IsScreening").find('label').eq(1).removeClass('selected');
- // $("#IsScreening").find('label').eq(2).addClass('selected');
- // $("#IsScreening").hide();
- $("#call_tags_help").hide();
- }else{
- // $("#IsScreening").show();
- }
- }
-
- $(function(){
- if (0 == $('#RegionId').val() || -1 == $('#RegionId').val()) {
- $('#CityId').hide();
- }
-
- var screening_value = $('input:radio[name="is_screening"]:checked').val();
- $('#IsScreening_'+screening_value).click();
-
- $('input[name=dtype]').click(function(){
- dtype_change(this);
- });
-
- function dtype_change(obj) {
- var dtype = $(obj).val();
- var ifoption = $(obj).data('ifoption');
- if (0 <= $.inArray(dtype, ['datetime','switch','img','imgs','file','media'])) {
- $('#dl_dfvalue').hide();
- ClearAreaData();
- } else if ('region' == dtype) {
- $('#region_div').show();
- $('#dl_dfvalue').hide();
- } else {
- $('#dl_dfvalue').show();
- ClearAreaData();
- }
- if (1 == ifoption) {
- $('#label_dfvalue').html('<em>*</em>默认值');
- } else {
- $('#label_dfvalue').html('默认值');
- }
- if (0 <= $.inArray(dtype, ['text','multitext'])) {
- $('#dfvalue').attr('placeholder', '前端将默认显示输入的默认值');
- } else if (0 <= $.inArray(dtype, ['checkbox','radio','select'])) {
- $('#dfvalue').attr('placeholder', '此处填写被选择的项目(用“,”分开,如“男,女”)。');
- } else {
- $('#dfvalue').attr('placeholder', '前端将默认显示输入的默认值');
- }
- if (0 <= $.inArray(dtype, ['region','checkbox','radio','select'])) {
- $('#IsScreening').show();
- $('input[name=IsScreening_status]').val(1);
- } else {
- $('#IsScreening').hide();
- $('input[name=IsScreening_status]').val(0);
- $('#select_title').html('指定栏目');
- }
- if (0 <= $.inArray(dtype, ['text','int','float','decimal'])) {
- $('#dl_dfvalue_unit').show();
- } else {
- $('#dl_dfvalue_unit').hide();
- }
- }
- });
-
- // 当切换其他类型时清空所有关于区域选择的数据
- function ClearAreaData(){
- $('#region_div').hide();
- $('#RegionId').val('');
- $('#region_dfvalue').empty();
- }
-
- // 获取联动地址
- function GetRegionData(t,type){
- var parent_id = $(t).val();
- if(!parent_id){
- return false;
- }
-
- var url = $('#GetRegionDataUrl').val();
- $.ajax({
- url: url,
- data: {parent_id:parent_id,_ajax:1},
- type:'post',
- dataType:'json',
- success:function(res){
- // 判断是否隐藏第二级地区选择栏
- if (0 <= $.inArray(parent_id, res.parent_array)) {
- $('#CityId').hide();
- }else{
- $('#CityId').show();
- }
- // 加载城市名称数据到textarea
- $('#region_names').empty().html(res.region_names);
- // 加载城市ID数据到input
- $('#region_ids').val(res.region_ids);
- // 加载ID到input
- $('#RegionId').val(parent_id);
- // 输出下一级栏目选项
- if ('province' == type) {
- res = '<option value='+parent_id+'>请选择</option>'+ res.region_html;
- $('#city').empty().html(res);
- }
- },
- error : function(e) {
- layer.closeAll();
- layer.alert(e.responseText, {icon: 5});
- }
- });
- }
-
- $('#IsScreening_1').click(function(){
- $('#select_title').html('<em>*</em>指定栏目');
- $('#typeid').find('option:first').attr('disabled', true).css('display', 'none');
- $('#call_tags_help').show();
- });
-
- $('#IsScreening_0').click(function(){
- $('#select_title').html('指定栏目');
- $('#typeid').find('option:first').attr('disabled', false).css('display', '');
- $('#call_tags_help').hide();
- });
-
- var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
- function check_submit(){
- if($('input[name="title"]').val() == ''){
- showErrorMsg('字段标题不能为空!');
- $('input[name=title]').focus();
- return false;
- }
- var name = $('input[name="name"]').val();
- var ret1 = /^[_]+$/;
- var ret2 = /^[\w]+$/;
- var ret3 = /^[0-9]+$/;
- if (ret1.test(name) || !ret2.test(name)) {
- showErrorMsg('字段名称格式不正确!');
- $('input[name=name]').focus();
- return false;
- } else if (ret3.test(name)) {
- showErrorMsg('字段名称不能纯数字!');
- $('input[name=name]').focus();
- return false;
- }
- if($('input[name=dtype]:checked').val() == ''){
- showErrorMsg('请选择字段类型!');
- $('input[name=dtype]').focus();
- return false;
- } else if ('region' == $('input[name=dtype]:checked').val()){
- if (-1 == $('#RegionId').val()) {
- showErrorMsg('请选择区域范围!');
- $('#province').focus();
- return false;
- }
- } else {
- var ifoption = $('input[name=dtype]:checked').data('ifoption');
- if (1 == ifoption) {
- if ($.trim($('#dfvalue').val()) == '') {
- showErrorMsg('默认值不能为空!');
- $('#dfvalue').focus();
- return false;
- }
- var tag = '|';
- if($('#dfvalue').val().indexOf(tag) != -1){
- showErrorMsg('默认值不能输入 | 符号!');
- $('#dfvalue').focus();
- return false;
- }
- }
-
- if (0 <= $.inArray($('input[name=dtype]:checked').val(), ['radio','checkbox','select'])) {
- var dfvalue = $.trim($('#dfvalue').val());
- if(dfvalue.indexOf('\\') != -1){
- showErrorMsg('默认值不支持反斜杠 \\ ,可用斜杠 / 代替');
- $('#dfvalue').focus();
- return false;
- }
- data = dfvalue.split(',');
- for(var i = 0;i < data.length ;i++) {
- for(var j = i+1;j < data.length;j++) {
- if ($.trim(data[i]) == $.trim(data [j])){
- showErrorMsg('默认值不能含有相同的值!');
- $('#dfvalue').focus();
- return false;
- }
- }
- }
- if (0 <= $.inArray($('input[name=dtype]:checked').val(), ['checkbox'])) {
- if (64 < data.length) {
- showErrorMsg('默认值最多填写64项!');
- $('#dfvalue').focus();
- return false;
- }
- }
- }
- }
- if (0 >= parseInt($('#typeid').find('option:selected').length)) {
- showErrorMsg('请选择指定栏目!');
- $('#typeid').focus();
- return false;
- }
-
- // 字段支持筛选时,指定栏目必须指定一个或多个栏目
- if (1 == parseInt($('input:radio[name="is_screening"]:checked').val())) {
- if (0 == parseInt($('#typeid').find('option:selected').val())) {
- if (1 >= $('#typeid').val().length) {
- showErrorMsg('字段支持筛选时,栏目必须指定一个或多个!');
- $('#typeid').focus();
- return false;
- }
- }
- }
-
- layer_loading('正在处理');
- $.ajax({
- type : 'post',
- url : "{:url('Field/channel_add', ['_ajax'=>1])}",
- data : $('#post_form').serialize(),
- dataType : 'json',
- success : function(res){
- layer.closeAll();
- if(res.code == 1){
- var _parent = parent;
- _parent.layer.close(parentObj);
- _parent.layer.msg(res.msg, {shade: layer_shade, time: 1000}, function(){
- _parent.window.location.reload();
- });
- }else{
- showErrorMsg(res.msg);
- }
- },
- error: function(e){
- layer.closeAll();
- layer.alert(e.responseText, {icon: 5, title:false});
- }
- });
- }
- </script>
-
- {include file="public/footer" /}
|