# encoding: utf-8
class StoreRecord < ActiveRecord::Base
  self.table_name = "store_records"
  belongs_to :product, :foreign_key => :product_id
  TYPE_ENUM = [["入库",0],["报损",1],["赠品",2],["线下零售",3],["盘盈（亏）",4],["其他",5]]
  validates :date_time,:product_id,presence: true

  rails_admin do
    navigation_label '仓储物流管理'
    weight -300
    list do
      filters [:order_type,:no,:product_id]
      field :id
      field :date_time
      field :no do
        visible true
        label "单据号"
      end
      field :product
      field :product_id do
        visible false
        filterable true
      end
      field :order_type, :enum do
        filterable true
        enum do
          TYPE_ENUM
        end
      end
      field :nums
      field :operator
      field :remark
      field :created_at
      # field :updated_at
    end
    show do
      field :id
      field :date_time
      field :no do
        visible true
        label "单据号"
      end
      field :product
      field :order_type, :enum do
        filterable true
        enum do
          TYPE_ENUM
        end
      end
      field :nums
      field :operator
      field :remark
      field :created_at
      field :created_at
      field :updated_at
    end
    edit do
      field :date_time
      field :no do
        visible true
        label "单据号"
      end
      field :product_id
      field :order_type, :enum do
        filterable true
        enum do
          TYPE_ENUM
        end
      end
      field :nums
      field :operator
      field :remark
        # field :created_at
    end
  end
end
