diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index ba07d42c9..65a1d345a 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -11,20 +11,7 @@ class HomeController < ApplicationController end # 目录分级 - repertoires = Repertoire.includes(sub_repertoires: :tag_repertoires).order("updated_at asc") - @rep_list = [] - repertoires.each do |rep| - - sub_rep_list = [] - rep.sub_repertoires.each do |sub_rep| - tag_rep_list = [] - sub_rep.tag_repertoires.each do |tag_rep| - tag_rep_list << {tag_id: tag_rep.id, tag_name: tag_rep.name} - end - sub_rep_list << {sub_rep_id: sub_rep.id, sub_rep_name: sub_rep.name, tag_rep_list: tag_rep_list} - end - @rep_list << {rep_id: rep.id, rep_name: rep.name, sub_rep_list: sub_rep_list} - end + @rep_list = current_laboratory.shixun_repertoires shixuns = current_laboratory.shixuns subjects = current_laboratory.subjects diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index c1676fbe9..15ee2a712 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -154,22 +154,7 @@ class ShixunsController < ApplicationController ## 获取顶部菜单 def menus - where_sql = ShixunTagRepertoire.where("shixun_tag_repertoires.tag_repertoire_id = tag_repertoires.id") - - # 云上实验室过滤 - unless current_laboratory.main_site? - where_sql = where_sql.joins('JOIN laboratory_shixuns ls ON ls.shixun_id = shixun_tag_repertoires.shixun_id') - end - where_sql = where_sql.select('1').to_sql - tags = TagRepertoire.where("EXISTS(#{where_sql})").distinct.includes(sub_repertoire: :repertoire) - - @tags_map = tags.group_by(&:sub_repertoire) - @sub_reps_map = @tags_map.keys.group_by(&:repertoire) - - # @repertoires = Repertoire.includes(sub_repertoires: [:tag_repertoires]).order("updated_at asc") - # respond_with @repertoires - - render_json + @repertoires = current_laboratory.shixun_repertoires end ## 实训详情 diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index b76db8a20..c1a8b15cd 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -11,7 +11,7 @@ class SubjectsController < ApplicationController include SubjectsHelper def index - @tech_system = Repertoire.where(nil).order("updated_at desc") + @tech_system = current_laboratory.subject_repertoires select = params[:select] # 路径导航类型 reorder = params[:order] || "publish_time" search = params[:search] diff --git a/app/models/laboratory.rb b/app/models/laboratory.rb index 672294b63..0c32114b0 100644 --- a/app/models/laboratory.rb +++ b/app/models/laboratory.rb @@ -47,6 +47,42 @@ class Laboratory < ApplicationRecord main_site? ? Subject.all : Subject.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: id }) end + def shixun_repertoires + where_sql = ShixunTagRepertoire.where("shixun_tag_repertoires.tag_repertoire_id = tag_repertoires.id") + + # 云上实验室过滤 + unless main_site? + where_sql = where_sql.joins("JOIN laboratory_shixuns ls ON ls.shixun_id = shixun_tag_repertoires.shixun_id "\ + "AND ls.laboratory_id = #{id}") + end + where_sql = where_sql.select('1').to_sql + tags = TagRepertoire.where("EXISTS(#{where_sql})").distinct.includes(sub_repertoire: :repertoire) + + tags_map = tags.group_by(&:sub_repertoire) + sub_reps_map = tags_map.keys.group_by(&:repertoire) + + sub_reps_map.keys.sort_by(&:updated_at).reverse.map do |repertoire| + repertoire_hash = repertoire.as_json(only: %i[id name]) + repertoire_hash[:sub_repertoires] = + sub_reps_map[repertoire].sort_by(&:updated_at).reverse.map do |sub_repertoire| + sub_repertoire_hash = sub_repertoire.as_json(only: %i[id name]) + sub_repertoire_hash[:tags] = tags_map[sub_repertoire].sort_by(&:updated_at).reverse.map { |tag| tag.as_json(only: %i[id name]) } + sub_repertoire_hash + end + repertoire_hash + end + end + + def subject_repertoires + exist_sql = Subject.where('subjects.repertoire_id = repertoires.id') + + unless main_site? + exist_sql = exist_sql.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: id }) + end + + Repertoire.where("EXISTS(#{exist_sql.select('1').to_sql})").order(updated_at: :desc).distinct + end + # 是否为主站 def main_site? id == 1 diff --git a/app/views/shixuns/menus.json.jbuilder b/app/views/shixuns/menus.json.jbuilder index 491ba5f05..5f107da3a 100644 --- a/app/views/shixuns/menus.json.jbuilder +++ b/app/views/shixuns/menus.json.jbuilder @@ -30,19 +30,5 @@ # end # end -json.array! @sub_reps_map.keys.sort_by(&:updated_at).reverse do |rep| - json.extract! rep, :id, :name - - json.sub_repertoires do - json.array! @sub_reps_map[rep].sort_by(&:updated_at).reverse do |sub_rep| - json.extract! sub_rep, :id, :name - - json.tags do - json.array! @tags_map[sub_rep].sort_by(&:updated_at).reverse do |tag| - json.extract! tag, :id, :name - end - end - end - end -end +json.array! @repertoires diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.css b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.css index d923c4a28..a21a02eba 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.css +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.css @@ -424,7 +424,7 @@ .competimgabsolute{ position: absolute; - left: 100px; + left: 86px; bottom: -10px; } .competimgabsolute .ant-badge-count{ @@ -433,6 +433,6 @@ .competimgabsoluteijmg{ position: absolute; - left: 14px; + left: 0px; bottom: 0px; } \ No newline at end of file diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsChart.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsChart.js index 4f13bf213..18128036b 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsChart.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsChart.js @@ -159,6 +159,9 @@ class CompetitionContents extends Component{ font-size: 20px; margin: 0 10px 0 0; } + .ant-badge{ + width:64px; + } ` } diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/Bankcardnumberverification.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/Bankcardnumberverification.js index a9ae5a4b0..d48ea8fe2 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/Bankcardnumberverification.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/Bankcardnumberverification.js @@ -30,7 +30,13 @@ class Bankcardnumberverification extends Component { window.document.title = '竞赛'; // console.log("3获取用户信息"); // console.log(this.props) - this.props.triggerRef(this); + try { + this.props.triggerRef(this); + }catch (e) { + + } + console.log(this.props.bank_account); + //初始化值 if (this.props.bank_account) { this.props.form.setFieldsValue({ @@ -38,6 +44,11 @@ class Bankcardnumberverification extends Component { subbranch: this.props.bank_account.second_bank, subbranchs: this.props.bank_account.card_no, }) + this.setState({ + openingbank: this.props.bank_account.bank, + subbranch: this.props.bank_account.second_bank, + subbranchs: this.props.bank_account.card_no, + }) } } @@ -50,6 +61,30 @@ class Bankcardnumberverification extends Component { }) } componentDidUpdate = (prevProps) => { + if (prevProps.bank_account != this.props.bank_account) { + console.log("componentDidUpdate"); + console.log(this.props);//是新数据 + console.log(prevProps);//是老数据 + ////console.log("Registration"); + ////console.log("componentDidUpdate"); + ////console.log(this.props.user.admin); + try { + if(this.props.bank_account){ + this.props.form.setFieldsValue({ + openingbank: this.props.bank_account.bank, + subbranch: this.props.bank_account.second_bank, + subbranchs: this.props.bank_account.card_no, + }) + } + this.setState({ + openingbank: this.props.bank_account.bank, + subbranch: this.props.bank_account.second_bank, + subbranchs: this.props.bank_account.card_no, + }) + }catch (e) { + + } + } } yhBankstrue = () => { @@ -64,13 +99,25 @@ class Bankcardnumberverification extends Component { }) .then((result) => { try { - if (result.data.status == 0) { - // console.log(JSON.stringify(result)); - this.props.form.setFieldsValue({ - openingbank: values.openingbank, - subbranch: values.subbranch, - subbranchs: values.subbranchs, - }) + if (result.data.status === 0) { + try { + // console.log(values.openingbank); + // console.log(values.subbranch); + // console.log(values.subbranchs); + this.props.form.setFieldsValue({ + openingbank: values.openingbank, + subbranch: values.subbranch, + subbranchs: values.subbranchs, + }); + this.setState({ + openingbank: values.openingbank, + subbranch: values.subbranch, + subbranchs: values.subbranchs, + }) + }catch (e) { + + } + try { this.props.showNotification(`提交成功,等待审核!`); @@ -103,24 +150,6 @@ class Bankcardnumberverification extends Component { render() { const {getFieldDecorator} = this.props.form; const {updating, seconds, secondsFlag, basicInfo, phonebool, emailbool, certification, formationdata, bank_account_editable, leader, bank_account} = this.state - var bank=""; - if(this.props.bank_account){ - if(this.props.bank_account.bank){ - bank=this.props.bank_account.bank; - } - } - var second_bank =""; - if(this.props.bank_account){ - if(this.props.bank_account.second_bank){ - second_bank=this.props.bank_account.second_bank; - } - } - var card_no=""; - if(this.props.bank_account){ - if(this.props.bank_account.card_no){ - card_no=this.props.bank_account.card_no; - } - } return (
签/领/开户行及银行卡号
-为保障奖金的及时发放,请队长如实填写你名下的银行卡信息
-开户行:
-{bank_account && bank_account.bank}
-支行:
-{bank_account && bank_account.second_bank}
-账号:
-{bank_account && bank_account.card_no}
-签/领/开户行及银行卡号
+为保障奖金的及时发放,请队长如实填写你名下的银行卡信息
开户行:
+{bank_account && bank_account.bank}
+支行:
+{bank_account && bank_account.second_bank}
+账号:
+{bank_account && bank_account.card_no}
+