From 96d6d9f1736bbc5f77750ba6cc3306a15b52352f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 6 Dec 2019 11:05:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BF=AE=E6=94=B9=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/admins/diff.scss | 14 +++++++ .../shixun_modify_records_controller.rb | 9 +++++ .../admins/shixun_modify_record_query.rb | 33 ++++++++++++++++ app/views/admins/shared/_sidebar.html.erb | 5 ++- .../shixun_modify_records/index.html.erb | 25 ++++++++++++ .../admins/shixun_modify_records/index.js.erb | 1 + .../shared/_list.html.erb | 38 +++++++++++++++++++ config/routes.rb | 1 + 8 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 app/assets/stylesheets/admins/diff.scss create mode 100644 app/controllers/admins/shixun_modify_records_controller.rb create mode 100644 app/queries/admins/shixun_modify_record_query.rb create mode 100644 app/views/admins/shixun_modify_records/index.html.erb create mode 100644 app/views/admins/shixun_modify_records/index.js.erb create mode 100644 app/views/admins/shixun_modify_records/shared/_list.html.erb diff --git a/app/assets/stylesheets/admins/diff.scss b/app/assets/stylesheets/admins/diff.scss new file mode 100644 index 000000000..13957570c --- /dev/null +++ b/app/assets/stylesheets/admins/diff.scss @@ -0,0 +1,14 @@ +.diff{overflow:auto;} +.diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;} +.diff del, .diff ins{display:block;text-decoration:none;} +.diff li{padding:0; display:table-row;margin: 0;height:1em;} +.diff li.ins{background:#dfd; color:#080} +.diff li.del{background:#fee; color:#b00} +.diff li:hover{background:#ffc} + +/* try 'whitespace:pre;' if you don't want lines to wrap */ +.diff del, .diff ins, .diff span{white-space:pre-wrap;font-family:courier;} +.diff del strong{font-weight:normal;background:#fcc;} +.diff ins strong{font-weight:normal;background:#9f9;} +.diff li.diff-comment { display: none; } +.diff li.diff-block-info { background: none repeat scroll 0 0 gray; } \ No newline at end of file diff --git a/app/controllers/admins/shixun_modify_records_controller.rb b/app/controllers/admins/shixun_modify_records_controller.rb new file mode 100644 index 000000000..43d9a4a16 --- /dev/null +++ b/app/controllers/admins/shixun_modify_records_controller.rb @@ -0,0 +1,9 @@ +class Admins::ShixunModifyRecordsController < Admins::BaseController + + def index + records = Admins::ShixunModifyRecordQuery.call(params) + + @records = paginate records.includes(:diff_record_content) + end + +end diff --git a/app/queries/admins/shixun_modify_record_query.rb b/app/queries/admins/shixun_modify_record_query.rb new file mode 100644 index 000000000..227e2f4c2 --- /dev/null +++ b/app/queries/admins/shixun_modify_record_query.rb @@ -0,0 +1,33 @@ +class Admins::ShixunModifyRecordQuery < ApplicationQuery + attr_reader :params + + def initialize(params) + @params = params + end + + def call + if params[:user_name].blank? || params[:date].blank? + records = DiffRecord.none + else + records = DiffRecord.joins(:user).where("concat(users.lastname, users.firstname) like ?", "%#{params[:user_name].strip}%") + if time_range.present? + records = records.where(created_at: time_range) + end + end + records.order("diff_records.created_at desc") + end + + private + + def time_range + @_time_range ||= begin + case params[:date] + when 'weekly' then 1.weeks.ago..Time.now + when 'monthly' then 1.months.ago..Time.now + when 'quarterly' then 3.months.ago..Time.now + when 'yearly' then 1.years.ago..Time.now + else '' + end + end + end +end diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index df344fd1a..4b84068e7 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -27,8 +27,9 @@