123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- {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">
- {include file="field/attribute_bar" /}
- <form class="form-horizontal" id="post_form" action="{:url('Field/attribute_add')}" method="post" onsubmit="return false;">
- <div class="ncap-form-default">
- <dl class="row">
- <dt class="tit">
- <label for="typeid"><em>*</em>所属栏目</label>
- </dt>
- <dd class="opt">
- {empty name="$typeid"}
- <select name="typeid" id="typeid" onchange="showlist(this)">
- <option value="0">请选择栏目…</option>
- {$select_html}
- </select>
- {else /}
- {$select_html}
- <input type="hidden" name="typeid" id="typeid" value="{$typeid|default=''}">
- {/empty}
- <span class="err" id="err_typeid" style="color:#F00; display:none;"></span>
- <p class="notic"></p>
- </dd>
- </dl>
- <dl class="row">
- <dt class="tit">
- <label for="ac_name"><em>*</em>属性名称</label>
- </dt>
- <dd class="opt">
- <input type="text" name="attr_name" value="" id="attr_name" class="input-txt">
- <span class="err" id="err_attr_name" style="color:#F00; display:none;"></span>
- <p class="notic"></p>
- </dd>
- </dl>
- <dl class="row">
- <dt class="tit">
- <label for="attr_input_type"><em>*</em>属性类型</label>
- </dt>
- <dd class="opt">
- {volist name='$attrInputTypeArr' id='vo'}
- <div style="width: 150px; float: left;">
- <label><input type="radio" name="attr_input_type" value="{$key}" {eq name='$i' value='1'} checked="checked" {/eq}>{$vo}</label>
- </div>
- {if condition="$i % 4 == 0"}<br/>{/if}
- {/volist}
- <span class="err" id="err_attr_input_type" style="color:#F00; display:none;"></span>
- <p class="notic"></p>
- <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','标签调用');">请点击这里查看教程</a></p>
- </dd>
- </dl>
- <dl class="row none attr_input_type2">
- <dt class="tit">
- <label for="attr_values"><em>*</em>可选值列表</label>
- </dt>
- <dd class="opt">
- <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>
- <span id="err_attr_values" class="err" style="color:#F00; display:none;"></span>
- <p class="notic">一行代表一个可选值</p>
- </dd>
- </dl>
- <dl class="row none" id="show_list">
- <dt class="tit">
- <label>后台列表显示</label>
- </dt>
- <dd class="opt">
- <div class="onoff">
- <label for="is_showlist1" id="is_showlist1_label" class="cb-enable" data-is_showlist="1" onclick="ajax_attribute_show(this);">显示</label>
- <input id="is_showlist1" name="is_showlist" value="1" type="radio">
- <label for="is_showlist0" id="is_showlist0_label" class="cb-disable selected" data-is_showlist="0" onclick="ajax_attribute_show(this);">隐藏</label>
- <input id="is_showlist0" name="is_showlist" value="0" type="radio" checked="checked">
- </div>
-
- <span class="err"></span>
- <p class="notic">默认在列表显示前4个字段,全部字段可点击查看</p>
- </dd>
- </dl>
- <dl class="row">
- <dt class="tit">
- <label>前台必填</label>
- </dt>
- <dd class="opt">
- <div class="onoff">
- <label for="required1" class="cb-enable" >是</label>
- <input id="required1" name="required" value="1" type="radio">
- <label for="required0" class="cb-disable selected">否</label>
- <input id="required0" name="required" value="0" type="radio" checked="checked">
- </div>
-
- <span class="err"></span>
- <p class="notic">用于控制前台用户提交是否必填验证</p>
- </dd>
- </dl>
- <div class="bot">
- <a href="JavaScript:void(0);" onclick="check_submit('post_form');" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
- </div>
- </div>
- </form>
- </div>
- <script type="text/javascript">
- $(function(){
- $('input[name=attr_input_type]').click(function(){
- var val = parseInt($(this).val());
- $('#validate_type').hide();
- if (-1 < $.inArray(val, [1,3,4])) {
- $('.attr_input_type2').show();
- } else {
- $('.attr_input_type2').hide();
- if (-1 < $.inArray(val, [6,7])) {
- $('#validate_type').show();
- }
- }
- });
- });
- /**
- * ajax 提交属性 到后台去验证然后回到前台提示错误
- * 验证通过后,再通过 form 自动提交
- */
- function check_submit(form_id)
- {
- if ($('#typeid').val() == 0) {
- showErrorMsg('请选择栏目…!');
- $('#typeid').focus();
- return false;
- }
- if($.trim($('input[name=attr_name]').val()) == ''){
- showErrorMsg('属性名称不能为空!');
- $('input[name=attr_name]').focus();
- return false;
- }
- var attr_input_type = parseInt($('input[name=attr_input_type]:checked').val());
- if (-1 < $.inArray(attr_input_type, [1,3,4]) && $.trim($('#attr_values').val()) == '') {
- showErrorMsg('可选值列表不能为空!');
- $('#attr_values').focus();
- return false;
- }
- layer_loading('正在处理');
- $.ajax({
- type : "POST",
- url : "{:url('Field/attribute_add', ['_ajax'=>1])}",
- data : $('#'+form_id).serialize(),// 你的formid
- dataType: "JSON",
- error: function(request) {
- layer.closeAll();
- layer.alert(ey_unknown_error, {icon: 5, title:false});
- return false;
- },
- success: function(v) {
- layer.closeAll();
- if(v.status == 1)
- {
- if(v.hasOwnProperty('data')){
- if(v.data.hasOwnProperty('url')){
- location.href = v.data.url;
- }else{
- location.href = location.href;
- }
- }else{
- location.href = location.href;
- }
- return true;
- } else {
- showErrorMsg(v.msg);
- return false;
- }
- }
- });
- }
- function showlist(obj) {
- if ($(obj).val() == 0) {
- $("#show_list").hide();
- } else {
- $("#show_list").show();
- }
- }
- function ajax_attribute_show(obj) {
- var is_showlist = $(obj).attr('data-is_showlist');
- var typeid = $('#typeid').val();
- if (typeid == 0) {
- showErrorMsg('请选择栏目…!');
- $('#typeid').focus();
- return false;
- }
- $.ajax({
- type : 'post',
- url : "{:url('Field/ajax_attribute_show')}",
- data : {typeid:typeid,is_showlist:is_showlist, _ajax:1},
- dataType : 'json',
- success : function(res){
- if (res.code != 1) {
- $('#is_showlist1_label').removeClass('selected');
- $('#is_showlist0_label').addClass('selected');//添加一个class
- $("input:radio[name=is_showlist]").eq(0).attr("checked",false);
- $("input:radio[name=is_showlist]").eq(1).attr("checked",true);
- layer.alert(res.msg, {icon: 2, title:false});
- }
- },
- error:function(){
- layer.alert(ey_unknown_error, {icon: 2, title:false});
- }
- });
- }
- </script>
- {include file="public/footer" /}
|