Browse Source

fix:分类名称

super-yimizi 1 week ago
parent
commit
069b92a043

+ 5 - 1
application/admin/view/shop/category/add.html

@@ -9,7 +9,11 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="">
+            <div class="input-group">
+                <input id="c-name" maxlength="8" data-rule="required" class="form-control" name="row[name]" type="text" placeholder="请输入分类名称,最多8个字符" value="">
+                <span class="input-group-addon text-muted" id="category-name-count">0/8</span>
+            </div>
+            <span class="help-block">分类名称最多8个字符</span>
         </div>
     </div>
     <div class="form-group">

+ 5 - 1
application/admin/view/shop/category/edit.html

@@ -9,7 +9,11 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
+            <div class="input-group">
+                <input id="c-name" maxlength="8" data-rule="required" class="form-control" name="row[name]" type="text" placeholder="请输入分类名称,最多8个字符" value="{$row.name|htmlentities}">
+                <span class="input-group-addon text-muted" id="category-name-count">0/8</span>
+            </div>
+            <span class="help-block">分类名称最多8个字符</span>
         </div>
     </div>
     <div class="form-group">

+ 12 - 0
public/assets/js/backend/shop/category.js

@@ -91,6 +91,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     });
                 };
                 Form.api.bindevent($("form[role=form]"));
+                
+                // 分类名称字数统计
+                $('#c-name').on('input', function(){
+                    var len = $(this).val().length;
+                    $('#category-name-count').text(len + '/8');
+                });
+                
+                // 编辑页面初始化字数统计
+                if ($('#c-name').val()) {
+                    var len = $('#c-name').val().length;
+                    $('#category-name-count').text(len + '/8');
+                }
                 $(document).on('click', ".btn-search-icon", function () {
                     if (iconlist.length == 0) {
                         $.getJSON(Config.site.cdnurl + "/assets/addons/shop/shopicon/iconfont.json", function (ret) {