fetch inviting data when select case_no
This commit is contained in:
parent
c9157e9132
commit
128bc5c158
|
@ -9,7 +9,17 @@ class Admin::VenueManagementContractsController < Admin::VenueAdminController
|
||||||
super
|
super
|
||||||
@app_title = 'venue_management'
|
@app_title = 'venue_management'
|
||||||
end
|
end
|
||||||
|
def fetch_inviting
|
||||||
|
invitings = VenueManagementInviting.where(id: params[:id])
|
||||||
|
data = {}
|
||||||
|
if !invitings.first.nil?
|
||||||
|
key = [:early_rent,:operation_rent,:royalty,:house_tax_payer,:land_tax_payer]
|
||||||
|
invitings.pluck(*key)[0].each_with_index do |v,i|
|
||||||
|
data[key[i]] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
render :json => data
|
||||||
|
end
|
||||||
def index
|
def index
|
||||||
@table_fields = [
|
@table_fields = [
|
||||||
'venue_management.title',
|
'venue_management.title',
|
||||||
|
|
|
@ -54,9 +54,7 @@ class VenueManagementContract
|
||||||
belongs_to :venue_management_main
|
belongs_to :venue_management_main
|
||||||
belongs_to :venue_management_inviting
|
belongs_to :venue_management_inviting
|
||||||
include VenueLinkFile
|
include VenueLinkFile
|
||||||
before_save do
|
def update_inviting(inviting,check_inviting,org_contract=nil,save_flag=true)
|
||||||
org_contract = VenueManagementContract.find(self.id) rescue nil
|
|
||||||
inviting = VenueManagementInviting.find(self.venue_management_inviting_id) rescue nil
|
|
||||||
if !inviting.nil?
|
if !inviting.nil?
|
||||||
%i(case_no publish_times start_date end_date close_date bid_date evaluation_date contractor_manager bid_result details).each do |attr_|
|
%i(case_no publish_times start_date end_date close_date bid_date evaluation_date contractor_manager bid_result details).each do |attr_|
|
||||||
self[attr_] = inviting.send(attr_) rescue nil
|
self[attr_] = inviting.send(attr_) rescue nil
|
||||||
|
@ -67,7 +65,7 @@ class VenueManagementContract
|
||||||
update_flag = true
|
update_flag = true
|
||||||
if !org_contract.nil? && org_contract.venue_management_inviting_id == self.venue_management_inviting_id
|
if !org_contract.nil? && org_contract.venue_management_inviting_id == self.venue_management_inviting_id
|
||||||
%i(early_rent operation_rent royalty house_tax_payer land_tax_payer).each do |attr_|
|
%i(early_rent operation_rent royalty house_tax_payer land_tax_payer).each do |attr_|
|
||||||
if self[attr_] != (inviting.send(attr_) rescue nil)
|
if self[attr_] != (check_inviting.send(attr_) rescue nil)
|
||||||
update_flag = false
|
update_flag = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -77,5 +75,13 @@ class VenueManagementContract
|
||||||
self[attr_] = (inviting.send(attr_) rescue nil)
|
self[attr_] = (inviting.send(attr_) rescue nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if save_flag
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
before_save do
|
||||||
|
org_contract = VenueManagementContract.find(self.id) rescue nil
|
||||||
|
inviting = VenueManagementInviting.find(self.venue_management_inviting_id) rescue nil
|
||||||
|
update_inviting(inviting,inviting,org_contract,false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,8 +32,9 @@ class VenueManagementInviting
|
||||||
include VenueLinkFile
|
include VenueLinkFile
|
||||||
before_save do
|
before_save do
|
||||||
contracts = self.venue_management_contracts
|
contracts = self.venue_management_contracts
|
||||||
|
org_inviting = VenueManagementInviting.find(self.id) rescue nil
|
||||||
contracts.each do |contract|
|
contracts.each do |contract|
|
||||||
contract.save
|
contract.update_inviting(self,org_inviting,contract)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -228,5 +228,18 @@
|
||||||
$('#renewal_deadline').hide()
|
$('#renewal_deadline').hide()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
$('#venue_management_contract_venue_management_inviting_id').change(function(){
|
||||||
|
$.ajax({
|
||||||
|
url : "/admin/venue_management_contracts/fetch_inviting",
|
||||||
|
data : {"id" : $(this).val()},
|
||||||
|
dataType : "json",
|
||||||
|
type : "post",
|
||||||
|
success : function(data){
|
||||||
|
$.each(data,function(k,v){
|
||||||
|
$('*[name="venue_management_contract['+k+']"]').val(v)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
|
@ -27,7 +27,11 @@ Rails.application.routes.draw do
|
||||||
resources :venue_management_item_contents
|
resources :venue_management_item_contents
|
||||||
resources :venue_management_invitings
|
resources :venue_management_invitings
|
||||||
resources :venue_management_memorabilias
|
resources :venue_management_memorabilias
|
||||||
resources :venue_management_contracts
|
resources :venue_management_contracts do
|
||||||
|
collection do
|
||||||
|
post 'fetch_inviting'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :venue_managements do
|
resources :venue_managements do
|
||||||
|
|
Loading…
Reference in New Issue