HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.xxlht.com/application/admin/template/shop_product/attribute_add.htm
{include file="public/layout" /}
<body style="overflow: auto; cursor: default; -moz-user-select: inherit;background-color:#F4F4F4; padding: 20px; ">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <form class="form-horizontal" id="post_form" action="{:U('ShopProduct/attribute_add')}" method="post">
        <input type="hidden" name="list_id" value="{$list.list_id}">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label for="typeid"><em>*</em>所属参数</label>
                </dt>
                <dd class="opt"> 
                    {$list.list_name}
                    <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">表单类型</label>
                </dt>
                <dd class="opt">
                    <label><input type="radio" value="0" name="attr_input_type" checked="checked" />手工录入(单行文本框)</label>
                    <label><input type="radio" value="1" name="attr_input_type" />从下面的默认值中选择</label>
                    <!-- <label><input type="radio" value="2" name="attr_input_type" />多行文本</label> -->
                    <span class="err" id="err_attr_input_type" style="color:#F00; display:none;"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl class="row attr_input_type2">
                <dt class="tit">
                    <label for="attr_values">默认值</label>
                </dt>
                <dd class="opt">
                    <textarea rows="10" cols="30" disabled='true' name="attr_values" id="attr_values" class="input-txt" style="height:100px;" placeholder="一行代表一个可选值"></textarea>
                    <span id="err_attr_values" class="err" style="color:#F00; display:none;"></span>
                    <p class="notic">一行代表一个默认值</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>排序</label>
                </dt>
                <dd class="opt">    
                    <input type="text" value="100" name="sort_order" id="sort_order" class="input-txt">
                    <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 = $(this).val();
            if (val == 1) {
                $('#attr_values').attr('disabled', false).focus();
                // $('.attr_input_type2').show();
            } else {
                $('#attr_values').attr('disabled', true);
                // $('.attr_input_type2').hide();
            }
        });

        var dftypeid = {$Request.param.typeid|default='0'};
        $('#typeid').change(function(){
            var current_channel = $(this).find('option:selected').data('current_channel');
            if (0 < $(this).val() && {$channeltype} != current_channel) {
                showErrorMsg('请选择对应模型的栏目!');
                $(this).val(dftypeid);
            } else if ({$channeltype} == current_channel) {
                layer.closeAll();
            }
        });
    });

    /**
    * ajax 提交表单 到后台去验证然后回到前台提示错误
    * 验证通过后,再通过 form 自动提交
    */
    function check_submit(form_id)
    {
        if($.trim($('input[name=attr_name]').val()) == ''){
            showErrorMsg('参数名称不能为空!');
            $('input[name=attr_name]').focus();
            return false;
        }
        if ($('input[name=attr_input_type]').is(':checked') == false) {
            showErrorMsg('请选择表单类型!');
            $($('input[name=attr_input_type]')[0]).focus();
            return false;
        }
        if ($('input[name=attr_input_type]:checked').val() == 1 && $.trim($('#attr_values').val()) == '') {
            showErrorMsg('可选值列表不能为空!');
            $('#attr_values').focus();
            return false;
        }

        layer_loading('正在处理');
        $.ajax({
            type : 'post',
            url  : "{:url('ShopProduct/attribute_add', ['_ajax'=>1])}",
            data : $('#'+form_id).serialize(),
            dataType : 'json',
            success : function(data){
                layer.closeAll();
                if(data.code == 1){
                    layer.msg(data.msg, {icon: 1, time:1000}, function(){
                        parent.window.location.reload();
                    });
                }else{
                    layer.alert(data.msg, {icon: 2, title:false});
                }
            }
        });
    }
</script>
{include file="public/footer" /}