From 93274f78f2f8d54fb888b308661be70eb545411e Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 13 Jul 2019 14:29:22 +0800 Subject: [PATCH] modify project package --- app/api/mobile/apis/project_packages.rb | 4 ++-- app/models/project_package.rb | 4 ++-- app/views/users/_project_package.html.erb | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/api/mobile/apis/project_packages.rb b/app/api/mobile/apis/project_packages.rb index 1ddd4ebb..d17a154b 100644 --- a/app/api/mobile/apis/project_packages.rb +++ b/app/api/mobile/apis/project_packages.rb @@ -101,7 +101,7 @@ module Mobile requires :content, type: String, desc: '描述' optional :attachment_ids, type: Array[Integer], desc: '附件ID数组' requires :deadline_at, type: DateTime, desc: '截止日期' - requires :min_price, type: Float, desc: '最小费用' + optional :min_price, type: Float, desc: '最小费用' optional :max_price, type: Float, desc: '最大费用' requires :contact_name, type: String, desc: '联系人姓名' requires :contact_phone, type: String, desc: '联系人手机号' @@ -129,7 +129,7 @@ module Mobile requires :content, type: String, desc: '描述' optional :attachment_ids, type: Array[Integer], desc: '附件ID数组' requires :deadline_at, type: DateTime, desc: '截止日期' - requires :min_price, type: Float, desc: '最小费用' + optional :min_price, type: Float, desc: '最小费用' optional :max_price, type: Float, desc: '最大费用' requires :contact_name, type: String, desc: '联系人姓名' requires :contact_phone, type: String, desc: '联系人手机号' diff --git a/app/models/project_package.rb b/app/models/project_package.rb index bc40bfe9..9ed28882 100644 --- a/app/models/project_package.rb +++ b/app/models/project_package.rb @@ -22,8 +22,8 @@ class ProjectPackage < ActiveRecord::Base validates :deadline_at, presence: true validates :contact_name, presence: true, length: { maximum: 20 } validates :contact_phone, presence: true, format: { with: /1\d{10}/ } - validates :min_price, numericality: { greater_than: 0 } - validates :max_price, numericality: { greater_than: ->(obj){ obj.min_price } }, allow_blank: true + validates :min_price, numericality: { greater_than: 0 }, allow_blank: true + validates :max_price, numericality: { greater_than: ->(obj){ obj.min_price.to_f } }, allow_blank: true aasm(:status) do state :pending, initiali: true diff --git a/app/views/users/_project_package.html.erb b/app/views/users/_project_package.html.erb index 66f256c6..43abda92 100644 --- a/app/views/users/_project_package.html.erb +++ b/app/views/users/_project_package.html.erb @@ -46,7 +46,9 @@
- <% if object.max_price && object.max_price != object.min_price %> + <% if object.min_price.blank? && object.max_price.blank? %> + 可议价 + <% elsif object.max_price && object.max_price != object.min_price %> <%= object.min_price %>~<%= object.max_price %> <% else %> <%= object.min_price %>