Class: ReportsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/reports_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/reports_controller.rb', line 25

def create
  @report = Report.new(report_params)

  respond_to do |format|
    if @report.save
      format.html { redirect_to reports_url, notice: '添加成功' }
    else
      format.html { render :new }
    end
  end
end

#destroyObject



47
48
49
50
51
52
# File 'app/controllers/reports_controller.rb', line 47

def destroy
  @report.destroy
  respond_to do |format|
    format.html { redirect_to reports_url, notice: '删除成功' }
  end
end

#editObject



22
23
# File 'app/controllers/reports_controller.rb', line 22

def edit
end

#indexObject



4
5
6
# File 'app/controllers/reports_controller.rb', line 4

def index
  @reports = Report.all
end

#newObject



18
19
20
# File 'app/controllers/reports_controller.rb', line 18

def new
  @report = Report.new
end

#showObject



8
9
10
11
12
13
14
15
16
# File 'app/controllers/reports_controller.rb', line 8

def show
  @data = @report.report_date(params)
  #@result = @report.get_chart_date(params)
  if @report.template.blank?
    render text: "没有模板,请先添加report模板"
  else
    render @report.template
  end
end

#updateObject



37
38
39
40
41
42
43
44
45
# File 'app/controllers/reports_controller.rb', line 37

def update
  respond_to do |format|
    if @report.update(report_params)
      format.html { redirect_to reports_url, notice: '修改成功' }
    else
      format.html { render :edit }
    end
  end
end