diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index c92ae34d..20e40fc6 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1193,6 +1193,53 @@ end end + # 添加客户 + def customers_list + @search = params[:search] + @province = params[:province] + partner_id = params[:partner] + @partner = Partner.find partner_id + @customers = @partner.customers + customer_id = @customers.present? ? @customers.map(&:id).join(",") : -1 + @schools = School.where("partner_id != ? and customer_id not in(#{customer_id})", @partner.id) + + if params[:search] + @schools = @schools.where("name like ?", "%#{@search}%") + end + + if params[:province] + @schools = @schools.where("province like ?", "%#{@province}%") + end + + @limit = 10 + @page = params[:page] || 1 + @schools_count = @schools.count + + @total_pages = (@schools_count / 10.0).ceil + @schools = paginateHelper @schools, @limit + respond_to do |format| + format.js + format.json { + render json: @schools + } + end + end + + def add_customers + school_ids = params[:school_ids] + if school_ids.length > 0 + school_ids.each do |s| + school = School.where("id = ?",s).first + if school.present? + customer = Customer.new(partner_id: params[:partner_id]) + customer.save! + school.update_attributes(:customer_id => customer.id) + end + end + render :json => {status: 1, message: "创建成功!"} + end + end + def all_partners @search = params[:search] @province = params[:province] @@ -1238,6 +1285,8 @@ end + + # 删除部门管理员 def delete_depart_member DepartmentMember.where(:department_id => params[:depart], :user_id => params[:user_id]).destroy_all diff --git a/app/views/managements/_customer_addUnit.html.erb b/app/views/managements/_customer_addUnit.html.erb new file mode 100644 index 00000000..17f31b47 --- /dev/null +++ b/app/views/managements/_customer_addUnit.html.erb @@ -0,0 +1,100 @@ +