From 23c9d5381e34fc46a73e7f66aa5af5edd0b6216a Mon Sep 17 00:00:00 2001 From: linhk <304431313@.com> Date: Wed, 6 Aug 2014 14:41:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=95=8C=E9=9D=A2=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=A1=AB=E5=86=99=E4=BF=A1=E6=81=AF=E7=BB=A7=E7=BB=AD?= =?UTF-8?q?=E4=BF=9D=E7=95=99=20=E4=BF=AE=E6=94=B9=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E8=A7=81=E9=9D=A2=E4=BC=81=E4=B8=9A=E6=8F=90=E4=BA=A4=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=A7=93=E3=80=81=E5=90=8D=E5=86=85=E5=AE=B9=E9=94=99?= =?UTF-8?q?=E8=AF=AFBug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 13 ++++++-- app/views/account/register.html.erb | 44 +++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 085ee0c60..c05d1172c 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -102,7 +102,14 @@ class AccountController < ApplicationController # User self-registration def register # @root_path="/home/pdl/redmine-2.3.2-0/apache2/" -# +# + @cache_identityy = params[:identity]||"" #身份 + @cache_no = params[:no]||"" #学号 + @cache_technical_title = params[:technical_title]||"" #教师职称 + @cache_province = params[:province]||"" #省份 + @cache_city = params[:city]||"" #城市 + @cache_enterprise_name = params[:enterprise_name]||"" #企业 + (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration] if request.get? session[:auth_source_registration] = nil @@ -112,8 +119,8 @@ class AccountController < ApplicationController @user = User.new @user.safe_attributes = user_params if params[:identity] == "2" # 2 企业 - @user.firstname = params[:enterprise_name] - @user.lastname = l(:field_enterprise) + #@user.firstname = params[:enterprise_name] + #@user.lastname = l(:field_enterprise) end @user.admin = false @user.register diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb index 260d53744..21c8c11b9 100644 --- a/app/views/account/register.html.erb +++ b/app/views/account/register.html.erb @@ -193,7 +193,40 @@ </script> <script type="text/javascript" language="javascript"> + + window.onload = function(){ + var identity = "<%= @cache_identityy %>"; + var no = "<%= @cache_no %>"; + var technical_title = "<%= @cache_technical_title %>"; + var province = "<%= @cache_province %>"; + var city = "<%= @cache_city %>"; + var enterprise_name = "<%= @cache_enterprise_name %>"; + //还原身份 + if(identity!=null&&identity!=""){ + $('#userIdentity').children("option[value='"+identity+"']").attr("selected","selected"); + showtechnical_title(identity, document.getElementById('userTechnical_title')); + if(identity=="0"){ + //还原教师职称 + $('#userTechnical_title').children("option[value='"+technical_title+"']").attr("selected","selected"); + }else if(identity=="1"){ + //还原学号 + $("input[id='no']").attr("value",no); + } + } + //还原地区 + if(province!=null&&province!=""){ + $("#userProvince").children("option[value='"+province+"']").attr("selected","selected"); + showcity(province, document.getElementById('userCity')); + $("select[id='userCity']").children("option[value='"+city+"']").attr("selected","selected"); + } + //还原企业名 + if(enterprise_name!=null&&enterprise_name!=""){ + $("input[id='enterprise_name']").attr("value",enterprise_name); + } + } + function showtechnical_title(identity, technical_titleField) { + var technical_titleOptions = null; switch (identity) { case '0' : @@ -202,7 +235,7 @@ $('#name').show() $('#enterprise').hide() $('#gender').show() - var technical_titleOptions = new Array( + technical_titleOptions = new Array( "<%= l(:label_technicl_title_professor) %>", "<%= l(:label_technicl_title_associate_professor) %>", "<%= l(:label_technicl_title_lecturer) %>", "<%= l(:label_technicl_title_teaching_assistant) %>"); break; @@ -234,15 +267,20 @@ break; } + technical_titleField.options.length = 0; + if(technical_titleOptions == null){ + return; + } for (var i = 0; i < technical_titleOptions.length; i++) { technical_titleField.options[i] = new Option(technical_titleOptions[i], technical_titleOptions[i]); - /* + /* if (cityField.options[i].value==city) { //alert("here put City ok!"); document.oblogform["city"].selectedIndex = i; - }*/ + } + */ } } </script>