Sha256: 619d130bf61663e7cc8b5a5ad1c839d0b221dd69df92b7a1642b40e7f5e7f461
Contents?: true
Size: 1.89 KB
Versions: 19
Compression:
Stored size: 1.89 KB
Contents
require_dependency "educode_sales/application_controller" module EducodeSales class PlacesController < ApplicationController def index respond_to do |format| authorize! :read, Place format.html do end format.json do @places = Place.page(params[:page]).per(params[:limit]) @x = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id @stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id) end end end def new # gon.area_ids = @place.area_ids gon.areas = Common.where(clazz: 'area').map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'}) render layout: false end def edit @place = Place.find(params[:id]) gon.area_ids = @place.area_ids gon.areas = Common.where(clazz: 'area').map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'}) render layout: false end def create place = @current_admin.places.new(name: params[:name]) commons = [] params[:area_ids].each do |d| commons << Common.find(d) end place.areas = commons if place.save render_success else render_failure place end end def update place = Place.find(params[:id]) place.assign_attributes(name: params[:name]) commons = [] params[:area_ids].each do |d| commons << Common.find(d) end place.areas = commons if place.save render_success else render_failure place end end def destroy place = Place.find(params[:id]) place.destroy render_success rescue ActiveRecord::DeleteRestrictionError => e render_failure '渠道下已有关联数据产生,暂不能删除' end end end
Version data entries
19 entries across 19 versions & 1 rubygems