<?php /*a:3:{s:74:"/data/web/mall.valimart.net/app/admin/view/goodsclass/goods_class_add.html";i:1657785096;s:61:"/data/web/mall.valimart.net/app/admin/view/public/header.html";i:1657785098;s:66:"/data/web/mall.valimart.net/app/admin/view/public/admin_items.html";i:1657785098;}*/ ?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title><?php echo htmlentities((isset($html_title) && ($html_title !== '')?$html_title:config('ds_config.site_name'))); ?><?php echo htmlentities(lang('system_backend')); ?></title>
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
        <link rel="stylesheet" href="<?php echo htmlentities(ADMIN_SITE_ROOT); ?>/css/admin.css">
        <link rel="stylesheet" href="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui/jquery-ui.min.css">
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery-2.1.4.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery.validate.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery.cookie.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/common.js"></script>
        <script src="<?php echo htmlentities(ADMIN_SITE_ROOT); ?>/js/admin.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui/jquery-ui.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui/jquery.ui.datepicker-zh-CN.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/perfect-scrollbar.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/layer/layer.js"></script>
        <script type="text/javascript">
            var BASESITEROOT = "<?php echo htmlentities(BASE_SITE_ROOT); ?>";
            var ADMINSITEROOT = "<?php echo htmlentities(ADMIN_SITE_ROOT); ?>";
            var BASESITEURL = "<?php echo htmlentities(BASE_SITE_URL); ?>";
            var HOMESITEURL = "<?php echo htmlentities(HOME_SITE_URL); ?>";
            var ADMINSITEURL = "<?php echo htmlentities(ADMIN_SITE_URL); ?>";
        </script>
    </head>
    <body>
        <div id="append_parent"></div>
        <div id="ajaxwaitid"></div>










<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3><?php echo htmlentities(lang('goods_class_index_class')); ?></h3>
            </div>
            <?php if($admin_item): ?>
<ul class="tab-base ds-row">
    <?php if(is_array($admin_item) || $admin_item instanceof \think\Collection || $admin_item instanceof \think\Paginator): if( count($admin_item)==0 ) : echo "" ;else: foreach($admin_item as $key=>$item): ?>
    <li><a href="<?php echo htmlentities($item['url']); ?>" <?php if($item['name'] == $curitem): ?>class="current"<?php endif; ?>><span><?php echo htmlentities($item['text']); ?></span></a></li>
    <?php endforeach; endif; else: echo "" ;endif; ?>
</ul>
<?php endif; ?>
        </div>
    </div>

    <form id="goods_class_form" enctype="multipart/form-data" method="post">
        <table class="ds-default-table">
            <tbody>
                <tr class="noborder">
                    <td colspan="2" class="required"><label class="validation" for="gc_name"><?php echo htmlentities(lang('goods_class_index_name')); ?>:</label></td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input type="text" value="" name="gc_name" id="gc_name" maxlength="20" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr>
                    <td colspan="2" class="required"><label for="parent_id"><?php echo htmlentities(lang('goods_class_add_sup_class')); ?>:</label></td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><select name="gc_parent_id" id="gc_parent_id">
                            <option value="0"><?php echo htmlentities(lang('ds_please_choose')); ?>...</option>
                            <?php if(!(empty($parent_list) || (($parent_list instanceof \think\Collection || $parent_list instanceof \think\Paginator ) && $parent_list->isEmpty()))): if(is_array($parent_list) || $parent_list instanceof \think\Collection || $parent_list instanceof \think\Paginator): if( count($parent_list)==0 ) : echo "" ;else: foreach($parent_list as $k=>$v): ?>
                            <option <?php if($gc_parent_id == $v['gc_id']): ?>selected='selected'<?php endif; ?> value="<?php echo htmlentities($v['gc_id']); ?>"><?php echo $v['gc_name']; ?></option>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                            <?php endif; ?>
                        </select></td>
                    <td class="vatop tips"><?php echo htmlentities(lang('goods_class_add_sup_class_notice')); ?></td>
                </tr>
                <tr>
                    <td colspan="2" class="required"><label for="pic"><?php echo htmlentities(lang('goods_class_pic')); ?>:</label></td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform">
                        <span class="type-file-box">
                            <input type='text' name='textfield' id='textfield1' class='type-file-text' />
                            <input type='button' name='button' id='button1' value='上传' class='type-file-button' />
                            <input name="pic" type="file" class="type-file-file" id="pic" size="30" hidefocus="true" ds_type="change_pic">
                        </span>
                    </td>
                    <td class="vatop tips"><?php echo htmlentities(lang('goods_class_pic_tips')); ?></td>
                </tr>
                <tr>
                    <td colspan="2" class="required"><label><?php echo htmlentities(lang('gc_virtual')); ?>:</label></td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><label><input type="checkbox" name="gc_virtual" id="gc_virtual" value="1"><?php echo htmlentities(lang('ds_allow')); ?></label></td>
                    <td class="vatop tips"><?php echo htmlentities(lang('gc_virtual_tips')); ?></td>
                </tr>
                <tr>
                    <td colspan="2" class="required"><label class="validation"><?php echo htmlentities(lang('commis_rate')); ?>:</label></td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input id="commis_rate" class="w60" type="text" value="5" name="commis_rate">%</td>
                    <td class="vatop tips"><?php echo htmlentities(lang('commis_rate_tips')); ?></td>
                </tr>
                
                <tr>
                    <td colspan="2" class="required"><label for="gc_name"><?php echo htmlentities(lang('goods_class_add_type')); ?>:</label></td>
                </tr>
                <tr class="noborder">
                    <td colspan="2" id="gcategory"><select class="class-select">
                            <option value="0"><?php echo htmlentities(lang('ds_please_choose')); ?>...</option>
                            <?php if(!(empty($gc_list) || (($gc_list instanceof \think\Collection || $gc_list instanceof \think\Paginator ) && $gc_list->isEmpty()))): if(is_array($gc_list) || $gc_list instanceof \think\Collection || $gc_list instanceof \think\Paginator): if( count($gc_list)==0 ) : echo "" ;else: foreach($gc_list as $k=>$v): if($v['gc_parent_id'] == 0): ?>
                            <option value="<?php echo htmlentities($v['gc_id']); ?>"><?php echo htmlentities($v['gc_name']); ?></option>
                            <?php endif; ?>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                            <?php endif; ?>
                        </select>
                        <?php echo htmlentities(lang('ds_quickly_targeted')); ?>
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input type="hidden" name="t_name" id="t_name" value="" />
                        <div id="type_div" class="goods-sort-type">
                            <div class="container">
                                <dl>
                                    <dd>
                                        <input type="radio" name="t_id" value="0" checked="checked" /><?php echo htmlentities(lang('goods_class_null_type')); ?> </dd>
                                </dl>
                                <?php if(!(empty($type_list) || (($type_list instanceof \think\Collection || $type_list instanceof \think\Paginator ) && $type_list->isEmpty()))): if(is_array($type_list) || $type_list instanceof \think\Collection || $type_list instanceof \think\Paginator): if( count($type_list)==0 ) : echo "" ;else: foreach($type_list as $k=>$val): if(!(empty($val['type']) || (($val['type'] instanceof \think\Collection || $val['type'] instanceof \think\Paginator ) && $val['type']->isEmpty()))): ?>
                                <dl>
                                    <dt id="type_dt_<?php echo htmlentities($k); ?>"><?php echo htmlentities($val['name']); ?></dt>
                                    <?php if(is_array($val['type']) || $val['type'] instanceof \think\Collection || $val['type'] instanceof \think\Paginator): if( count($val['type'])==0 ) : echo "" ;else: foreach($val['type'] as $key=>$v): ?>
                                    <dd>
                                        <input type="radio" name="t_id" value="<?php echo htmlentities($v['type_id']); ?>" />
                                        <span><?php echo htmlentities($v['type_name']); ?></span></dd>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </dl>
                                <?php endif; ?>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                                <?php endif; ?>
                            </div>
                        </div></td>
                    <td class="vatop tips"><?php echo htmlentities(lang('goods_class_add_type_desc_one')); ?><a onclick="window.parent.openItem('index,type,goods')" href="JavaScript:void(0);"><?php echo htmlentities(lang('ds_type')); ?></a><?php echo htmlentities(lang('goods_class_add_type_desc_two')); ?></td>
                </tr>
                <tr>
                    <td colspan="2" class="required"><label><?php echo htmlentities(lang('ds_sort')); ?>:</label></td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input type="text" value="255" name="gc_sort" id="gc_sort" class="txt"></td>
                    <td class="vatop tips"><?php echo htmlentities(lang('goods_class_add_update_sort')); ?></td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="2"><input class="btn" type="submit" value="<?php echo htmlentities(lang('ds_submit')); ?>"/></td>
                </tr>
            </tfoot>
        </table>
    </form>
</div>
<script type="text/javascript" src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/mlselection.js" charset="utf-8"></script>
<script type="text/javascript" src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery.mousewheel.js"></script> 
<script>
//按钮先执行验证再提交表单
              $(function() {
                  $("#pic").change(function() {
                      $("#textfield1").val($(this).val());
                  });
                  $('input[type="radio"][name="t_id"]').click(function() {
                      if ($(this).val() == '0') {
                          $('#t_name').val('');
                      } else {
                          $('#t_name').val($(this).next('span').html());
                      }
                  });

                  $('#goods_class_form').validate({
                      errorPlacement: function(error, element) {
                          error.appendTo(element.parent().parent().prev().find('td:first'));
                      },
                      rules: {
                          gc_name: {
                              required: true,
                              remote: {
                                  url: "<?php echo url('Goodsclass/ajax',['branch'=>'check_class_name']); ?>",
                                  type: 'get',
                                  data: {
                                      gc_name: function() {
                                          return $('#gc_name').val();
                                      },
                                      gc_parent_id: function() {
                                          return $('#gc_parent_id').val();
                                      },
                                      gc_id: ''
                                  }
                              }
                          },
                          commis_rate: {
                              required: true,
                              max: 100,
                              min: 0,
                              digits: true
                          },
                          gc_sort: {
                              number: true
                          }
                      },
                      messages: {
                          gc_name: {
                              required: '<?php echo htmlentities(lang('goods_class_add_name_null')); ?>',
                              remote: '<?php echo htmlentities(lang('goods_class_add_name_exists')); ?>'
                          },
                          commis_rate: {
                              required: '<?php echo htmlentities(lang('goods_class_add_commis_rate_error')); ?>',
                              max: '<?php echo htmlentities(lang('goods_class_add_commis_rate_error')); ?>',
                              min: '<?php echo htmlentities(lang('goods_class_add_commis_rate_error')); ?>',
                              digits: '<?php echo htmlentities(lang('goods_class_add_commis_rate_error')); ?>'
                          },
                          gc_sort: {
                              number: '<?php echo htmlentities(lang('goods_class_add_sort_int')); ?>'
                          }
                      }
                  });

                  // 所属分类
                  $(document).off('change',"#gc_parent_id").on("change","#gc_parent_id", function() {
                      type_scroll($(this));
                  });
                  // 类型搜索
                  $(document).off('change',"#gcategory > select").on("change","#gcategory > select", function() {
                      type_scroll($(this));
                  });
              });
              var typeScroll = 0;
              function type_scroll(o) {
                  var id = o.val();
                  if (!$('#type_dt_' + id).is('dt')) {
                      return false;
                  }
                  $('#type_div').scrollTop(-typeScroll);
                  var sp_top = $('#type_dt_' + id).offset().top;
                  var div_top = $('#type_div').offset().top;
                  $('#type_div').scrollTop(sp_top - div_top);
                  typeScroll = sp_top - div_top;
              }
              gcategoryInit('gcategory');
</script> 
