Преглед на файлове

增加商品属性定义

abiao преди 5 години
родител
ревизия
41e9d6c718
променени са 1 файла, в които са добавени 32 реда и са изтрити 9 реда
  1. 32 9
      app/models/product_attr_config.rb

+ 32 - 9
app/models/product_attr_config.rb

@@ -9,13 +9,13 @@ class ProductAttrConfig < ActiveRecord::Base
         showProducts=[]
         @products = Product.where("show_flag=1").order("created_at desc")
         @products.each do |pd|
-            a=[pd.id,pd.name]
+            a=[pd.name,pd.id]
             showProducts.push(a)
         end
         showProducts.each {|v| puts v}
         return showProducts
     end
-
+    TYPE_ENUM = [["颜色","color"],["尺码","size"]]
     rails_admin do
         navigation_label '商品管理'
         weight -250
@@ -28,23 +28,46 @@ class ProductAttrConfig < ActiveRecord::Base
         list do 
             filters [:product_id,:product_attr_key]
             field :id
-            field :product_id
-            field :show_products
+            field :product_id, :enum do
+                enum do
+                    show_products
+                end
+            end
             field :product_attr_key
-            field :size_type
+            field :size_type, :enum do
+                enum do
+                    TYPE_ENUM
+                end
+            end
         end
 
         show do
             field :id
-            field :product_id
+            field :product_id, :enum do
+                enum do
+                    show_products
+                end
+            end
             field :product_attr_key
-            field :size_type
+            field :size_type, :enum do
+                enum do
+                    TYPE_ENUM
+                end
+            end
         end
 
         edit do
-            field :product_id
+            field :product_id, :enum do
+                enum do
+                    show_products
+                end
+            end
             field :product_attr_key
-            field :size_type
+            field :size_type, :enum do
+                enum do
+                    TYPE_ENUM
+                end
+            end
         end
     end