Sha256: a841e2f5097b9f034617dcfb06a653a8d9f5fe725004ab9b8ad8201d5c7ec02a

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

class Requirement < ActiveRecord::Base
  belongs_to :report
  has_many :dictionaries, dependent: :destroy, as: :resource

  #搜索类型
  FormType = {
      form_select: 1,   #下拉
      form_datetime: 2, #时间
      form_text: 3      #输入
  }
  # enum form_type: FormType

  #下拉数据来源类型
  SqlType = {
      sql_dict: 1,          #字典
      sql_query: 2          #sql查询所得
  }
  # enum sql_type: SqlType

  def form_type_name
    return "下拉" if self.form_type == FormType[:form_select]
    return "时间" if self.form_type == FormType[:form_datetime]
    return "输入" if self.form_type == FormType[:form_text]
  end

  def sql_type_name
    return "字典" if self.sql_type == SqlType[:sql_dict]
    return "sql查询所得" if self.sql_type == SqlType[:sql_query]
  end

  def self.sql_type_options
    [["", 0],["字典", SqlType[:sql_dict]],["sql查询所得", SqlType[:sql_query]]]
  end

  def self.form_type_options
    [["下拉", FormType[:form_select]],["时间", FormType[:form_datetime]],["输入", FormType[:form_text]]]
  end

  def dict_options
    self.dictionaries.collect{|s|[s.key, s.value]}
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
treport-0.2.0 app/models/requirement.rb
treport-0.1.0 app/models/requirement.rb
admin-sys-1.0.2 plugins/report/app/models/requirement.rb
admin-sys-1.0.1 plugins/report/app/models/requirement.rb
admin-sys-1.0.0 plugins/report/app/models/requirement.rb