Parcourir la source

增加商品属性定义

abiao il y a 5 ans
Parent
commit
f1a8183e68

+ 12 - 0
app/models/product.rb

@@ -95,6 +95,10 @@ class Product < ActiveRecord::Base
             end
             field :is_only_new
             field :video_state
+            field :size_id
+            field :color_id
+            field :relate_product_id
+            field :show_flag
             field :created_at
             field :updated_at
         end
@@ -150,6 +154,10 @@ class Product < ActiveRecord::Base
             field :no_delivery_area
             field :video_state
             field :video_url
+            field :size_id
+            field :color_id
+            field :relate_product_id
+            field :show_flag
             field :created_at
             field :updated_at
         end
@@ -191,6 +199,10 @@ class Product < ActiveRecord::Base
             field :no_delivery_area
             field :video_state
             field :video_url
+            field :size_id
+            field :color_id
+            field :relate_product_id
+            field :show_flag
         end
 
     end

+ 39 - 0
app/models/product_attr.rb

@@ -0,0 +1,39 @@
+class ProductAttr < ActiveRecord::Base
+    has_paper_trail
+    self.table_name = 'product_attrs'
+    has_ancestry
+    has_many :product_attr_keys, :foreign_key => :attr_key_id
+    validates :name,presence:true
+    
+    rails_admin do
+        navigation_label '商品管理'
+        weight -240
+        nestable_tree({
+            position_field: :position,
+            max_depth: 2
+        })
+
+        list do 
+            filters [:name,:ancestry,:position]
+            field :id
+            field :product_attr_key
+            field :name 
+            field :recommend
+        end
+
+        show do
+            field :id
+            field :product_attr_key
+            field :name
+            field :recommend
+        end
+
+        edit do 
+            field :product_attr_key
+            field :name
+            field :recommend
+        end 
+
+    end
+
+end

+ 38 - 0
app/models/product_attr_config.rb

@@ -0,0 +1,38 @@
+class ProductAttrConfig < ActiveRecord::Base
+    has_paper_trail
+    self.table_name = 'product_attr_configs'
+    has_ancestry
+    has_many :products, :foreign_key => :category_id
+    validates :name,presence:true
+    
+    rails_admin do
+        navigation_label '商品管理'
+        weight -240
+        nestable_tree({
+            position_field: :position,
+            max_depth: 2
+        })
+
+        list do 
+            filters [:name,:ancestry,:position]
+            field :id
+            field :product_id
+            field :attr_key_id
+            field :type
+        end
+
+        show do
+            field :id
+            field :product_id
+            field :attr_key_id
+            field :type
+        end
+
+        edit do
+            field :product_id
+            field :attr_key_id
+            field :type
+        end
+    end
+
+end

+ 35 - 0
app/models/product_attr_key.rb

@@ -0,0 +1,35 @@
+class ProductAttrKey < ActiveRecord::Base
+    has_paper_trail
+    self.table_name = 'product_attr_keys'
+    has_ancestry
+    validates :name,presence:true
+    
+    rails_admin do
+        navigation_label '商品管理'
+        weight -240
+        nestable_tree({
+            position_field: :position,
+            max_depth: 2
+        })
+
+        list do 
+            filters [:name,:status]
+            field :id
+            field :name
+            field :status
+        end
+
+        show do
+            field :id
+            field :name
+            field :status
+        end
+
+        edit do 
+            field :name 
+            field :status
+        end 
+
+    end
+
+end

+ 7 - 1
config/locales/models/product.yml

@@ -41,4 +41,10 @@ zh-CN:
         specification: 规格
         no_delivery_area: 不发货地区
         video_state: 显示视频
-        video_url: 视频地址
+        video_url: 视频地址
+        size_id: 尺码
+        color_id: 颜色
+        size: 尺码
+        color: 颜色
+        relate_product_id: 关联主商品
+        show_flag: 主商品标记

+ 13 - 0
config/locales/models/product_attr.yml

@@ -0,0 +1,13 @@
+zh-CN:
+  activerecord:
+    models:
+      product_attr: 规格明细
+    attributes:
+      product_attr:
+        id: ID 
+        name: 名称
+        attr_key_id: 规格ID
+        product_attr_key: 规格
+        recommend: 推荐程度
+
+    

+ 11 - 0
config/locales/models/product_attr_config.yml

@@ -0,0 +1,11 @@
+zh-CN:
+  activerecord:
+    models:
+      product_attr_config: 主商品规格配置
+    attributes:
+      product_attr_config:
+        id: ID 
+        product: 商品
+        product_id: 商品Id
+        attr_key_id: 规格ID
+        type: 类型

+ 9 - 0
config/locales/models/product_attr_key.yml

@@ -0,0 +1,9 @@
+zh-CN:
+  activerecord:
+    models:
+      product_attr_key: 商品规格定义
+    attributes:
+      product_attr_key:
+        id: ID 
+        name: 规格名称
+        status: 状态

+ 2 - 0
db/migrate/20200808124641_create_product_attrs.rb

@@ -16,6 +16,8 @@ class CreateProductAttrs < ActiveRecord::Migration
       t.column :attr_key_id, :integer, :limit => 8, :default => 0
       # 规格名称
       t.column :name, :string,:limit => 500
+      # 排序
+      t.column :recommend, :integer, :limit => 8, :default => 0
       t.timestamps
     end
     add_index :product_attrs, :attr_key_id