commit
9b9503bbb1
@ -0,0 +1,98 @@
|
||||
*.gem
|
||||
*.rbc
|
||||
/.config
|
||||
/coverage/
|
||||
/InstalledFiles
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/spec/examples.txt
|
||||
/test/tmp/
|
||||
/test/version_tmp/
|
||||
/tmp/
|
||||
|
||||
|
||||
.idea/
|
||||
spec/examples.txt
|
||||
.vagrant
|
||||
.byebug_history
|
||||
.ruby-version
|
||||
|
||||
|
||||
# 配置
|
||||
/config/secrets.yml
|
||||
/config/redis.yml
|
||||
/config/elasticsearch.yml
|
||||
/config/aliyun_vod.yml
|
||||
/config/configuration.yml
|
||||
/config/environments/production.rb
|
||||
/config/initializers/gitlab_config.rb
|
||||
/config/master.key
|
||||
/config/database.yml
|
||||
|
||||
|
||||
# avatars
|
||||
/public/images/avatars
|
||||
/public/files
|
||||
/public/upload.html
|
||||
public/doc
|
||||
files
|
||||
|
||||
|
||||
Dockerfile
|
||||
dump.rdb
|
||||
|
||||
# Ignore all logfiles and tempfiles.
|
||||
/log/*
|
||||
!/log/.keep
|
||||
/tmp
|
||||
.DS_Store
|
||||
.swp
|
||||
|
||||
Dockerfile
|
||||
|
||||
# Ignore node_modules
|
||||
node_modules/
|
||||
|
||||
|
||||
# Used by dotenv library to load environment variables.
|
||||
# .env
|
||||
|
||||
# Ignore Byebug command history file.
|
||||
.byebug_history
|
||||
|
||||
|
||||
## Specific to RubyMotion (use of CocoaPods):
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# vendor/Pods/
|
||||
|
||||
## Documentation cache and generated files:
|
||||
/.yardoc/
|
||||
/_yardoc/
|
||||
/doc/
|
||||
/rdoc/
|
||||
|
||||
## Environment normalization:
|
||||
/.bundle/
|
||||
/vendor/bundle
|
||||
/lib/bundler/man/
|
||||
|
||||
# for a library or gem, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# Gemfile.lock
|
||||
# .ruby-version
|
||||
# .ruby-gemset
|
||||
|
||||
.vscode/
|
||||
|
||||
.generators
|
||||
.rakeTasks
|
||||
|
||||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||
.rvmrc
|
||||
|
||||
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
||||
# .rubocop-https?--*
|
@ -0,0 +1,131 @@
|
||||
source 'https://gems.ruby-china.com'
|
||||
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||
|
||||
ruby '2.3.7'
|
||||
|
||||
gem 'rails', '~> 5.2.0'
|
||||
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
|
||||
gem 'puma', '~> 3.11'
|
||||
gem 'sass-rails', '~> 5.0'
|
||||
gem 'uglifier', '>= 1.3.0'
|
||||
|
||||
# gem 'coffee-rails', '~> 4.2'
|
||||
gem 'turbolinks', '~> 5'
|
||||
gem 'jbuilder', '~> 2.5'
|
||||
|
||||
gem 'grape-entity', '~> 0.7.1'
|
||||
gem 'kaminari', '~> 1.1', '>= 1.1.1'
|
||||
|
||||
gem 'bootsnap', '>= 1.1.0', require: false
|
||||
|
||||
gem 'gitlab', path: 'lib/gitlab-cli'
|
||||
|
||||
gem 'chinese_pinyin'
|
||||
|
||||
gem 'rack-cors'
|
||||
gem 'redis-rails'
|
||||
gem 'roo-xls'
|
||||
gem 'simple_xlsx_reader'
|
||||
|
||||
gem 'rubyzip'
|
||||
|
||||
# gem 'quill-rails5', github: 'paul-at/quill-rails5'
|
||||
|
||||
gem 'spreadsheet'
|
||||
gem 'ruby-ole'
|
||||
# 导出为xlsx
|
||||
gem 'axlsx', '~> 3.0.0.pre'
|
||||
gem 'axlsx_rails', '~> 0.5.2'
|
||||
|
||||
gem 'oauth2'
|
||||
#导出为pdf
|
||||
gem 'pdfkit'
|
||||
gem 'wkhtmltopdf-binary'
|
||||
|
||||
#gem 'iconv'
|
||||
# markdown 转html
|
||||
gem 'redcarpet', '~> 3.4'
|
||||
|
||||
gem 'rqrcode', '~> 0.10.1'
|
||||
gem 'rqrcode_png'
|
||||
|
||||
gem 'acts-as-taggable-on', '~> 6.0'
|
||||
|
||||
gem 'omniauth-cas'
|
||||
|
||||
group :development, :test do
|
||||
gem 'rspec-rails', '~> 3.8'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'awesome_print'
|
||||
gem 'web-console', '>= 3.3.0'
|
||||
gem 'listen', '>= 3.0.5', '< 3.2'
|
||||
gem 'spring'
|
||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||
# 调试
|
||||
gem 'byebug', '~> 11.0', '>= 11.0.1'
|
||||
# 性能测试
|
||||
gem 'benchmark-ips'
|
||||
gem 'kalibera'
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'capybara', '~> 3.15', '>= 3.15.1'
|
||||
gem 'selenium-webdriver'
|
||||
gem 'chromedriver-helper'
|
||||
end
|
||||
|
||||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
||||
|
||||
#编码检测
|
||||
gem 'rchardet', '~> 1.8'
|
||||
|
||||
# http client
|
||||
gem 'faraday', '~> 0.15.4'
|
||||
|
||||
# view
|
||||
gem 'active_decorator'
|
||||
gem 'bootstrap', '~> 4.3.1'
|
||||
gem 'jquery-rails'
|
||||
gem 'simple_form'
|
||||
gem 'font-awesome-sass', '4.7.0'
|
||||
|
||||
# i18n
|
||||
gem 'rails-i18n', '~> 5.1'
|
||||
|
||||
# job
|
||||
gem 'sidekiq'
|
||||
gem 'sinatra'
|
||||
|
||||
# batch insert
|
||||
gem 'bulk_insert'
|
||||
|
||||
# elasticsearch
|
||||
gem 'searchkick'
|
||||
|
||||
gem 'aasm'
|
||||
gem 'enumerize'
|
||||
|
||||
gem 'diffy'
|
||||
|
||||
# oauth2
|
||||
gem 'omniauth', '~> 1.9.0'
|
||||
gem 'omniauth-oauth2', '~> 1.6.0'
|
||||
|
||||
# global var
|
||||
gem 'request_store'
|
||||
|
||||
# 敏感词汇
|
||||
gem 'harmonious_dictionary', '~> 0.0.1'
|
||||
|
||||
gem 'parallel', '~> 1.19', '>= 1.19.1'
|
||||
|
||||
# 图片压缩处理
|
||||
gem 'mini_magick'
|
||||
|
||||
# 列表排序
|
||||
gem 'acts_as_list', '0.9.19'
|
||||
|
||||
# 动作缓存
|
||||
gem 'actionpack-action_caching'
|
@ -0,0 +1,463 @@
|
||||
PATH
|
||||
remote: lib/gitlab-cli
|
||||
specs:
|
||||
gitlab (3.2.0)
|
||||
httparty
|
||||
terminal-table
|
||||
|
||||
GEM
|
||||
remote: https://gems.ruby-china.com/
|
||||
specs:
|
||||
aasm (5.0.8)
|
||||
concurrent-ruby (~> 1.0)
|
||||
actioncable (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
actionview (= 5.2.4.3)
|
||||
activejob (= 5.2.4.3)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.4.3)
|
||||
actionview (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionpack-action_caching (1.2.1)
|
||||
actionpack (>= 4.0.0)
|
||||
actionview (5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
active_decorator (1.3.2)
|
||||
activesupport
|
||||
activejob (5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
activerecord (5.2.4.3)
|
||||
activemodel (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
activerecord (= 5.2.4.3)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.4.3)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
acts-as-taggable-on (6.5.0)
|
||||
activerecord (>= 5.0, < 6.1)
|
||||
acts_as_list (0.9.19)
|
||||
activerecord (>= 3.0)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
archive-zip (0.12.0)
|
||||
io-like (~> 0.3.0)
|
||||
arel (9.0.0)
|
||||
autoprefixer-rails (9.7.6)
|
||||
execjs
|
||||
awesome_print (1.8.0)
|
||||
axlsx (3.0.0.pre)
|
||||
htmlentities (~> 4.3, >= 4.3.4)
|
||||
mimemagic (~> 0.3)
|
||||
nokogiri (~> 1.8, >= 1.8.2)
|
||||
rubyzip (~> 1.2, >= 1.2.1)
|
||||
axlsx_rails (0.5.2)
|
||||
actionpack (>= 3.1)
|
||||
axlsx (>= 2.0.1)
|
||||
benchmark-ips (2.8.2)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.4.6)
|
||||
msgpack (~> 1.0)
|
||||
bootstrap (4.3.1)
|
||||
autoprefixer-rails (>= 9.1.0)
|
||||
popper_js (>= 1.14.3, < 2)
|
||||
sassc-rails (>= 2.0.0)
|
||||
builder (3.2.4)
|
||||
bulk_insert (1.8.1)
|
||||
activerecord (>= 3.2.0)
|
||||
byebug (11.0.1)
|
||||
capybara (3.15.1)
|
||||
addressable
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (~> 1.8)
|
||||
rack (>= 1.6.0)
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (~> 1.2)
|
||||
xpath (~> 3.2)
|
||||
childprocess (3.0.0)
|
||||
chinese_pinyin (1.0.2)
|
||||
chromedriver-helper (2.1.1)
|
||||
archive-zip (~> 0.10)
|
||||
nokogiri (~> 1.8)
|
||||
chunky_png (1.3.11)
|
||||
concurrent-ruby (1.1.6)
|
||||
connection_pool (2.2.3)
|
||||
crass (1.0.6)
|
||||
diff-lcs (1.3)
|
||||
diffy (3.3.0)
|
||||
elasticsearch (7.5.0)
|
||||
elasticsearch-api (= 7.5.0)
|
||||
elasticsearch-transport (= 7.5.0)
|
||||
elasticsearch-api (7.5.0)
|
||||
multi_json
|
||||
elasticsearch-transport (7.5.0)
|
||||
faraday (>= 0.14, < 1)
|
||||
multi_json
|
||||
enumerize (2.3.1)
|
||||
activesupport (>= 3.2)
|
||||
erubi (1.9.0)
|
||||
execjs (2.7.0)
|
||||
faraday (0.15.4)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.13.0)
|
||||
font-awesome-sass (4.7.0)
|
||||
sass (>= 3.2)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
grape-entity (0.7.1)
|
||||
activesupport (>= 4.0)
|
||||
multi_json (>= 1.3.2)
|
||||
harmonious_dictionary (0.0.1)
|
||||
hashie (4.1.0)
|
||||
htmlentities (4.3.4)
|
||||
httparty (0.18.0)
|
||||
mime-types (~> 3.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (1.8.3)
|
||||
concurrent-ruby (~> 1.0)
|
||||
io-like (0.3.1)
|
||||
jbuilder (2.10.0)
|
||||
activesupport (>= 5.0.0)
|
||||
jquery-rails (4.3.5)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
jwt (2.2.1)
|
||||
kalibera (0.1)
|
||||
memoist (~> 0.11.0)
|
||||
rbzip2 (~> 0.2.0)
|
||||
kaminari (1.2.1)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.2.1)
|
||||
kaminari-activerecord (= 1.2.1)
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-actionview (1.2.1)
|
||||
actionview
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-activerecord (1.2.1)
|
||||
activerecord
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-core (1.2.1)
|
||||
listen (3.1.5)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
ruby_dep (~> 1.2)
|
||||
loofah (2.5.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
memoist (0.11.0)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2020.0512)
|
||||
mimemagic (0.3.5)
|
||||
mini_magick (4.10.1)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.1)
|
||||
msgpack (1.3.3)
|
||||
multi_json (1.14.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
mustermann (1.1.1)
|
||||
ruby2_keywords (~> 0.0.1)
|
||||
mysql2 (0.5.3)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.9)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.2)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.1)
|
||||
hashie (>= 3.4.6)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-cas (1.1.1)
|
||||
addressable (~> 2.3)
|
||||
nokogiri (~> 1.5)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-oauth2 (1.6.0)
|
||||
oauth2 (~> 1.1)
|
||||
omniauth (~> 1.9)
|
||||
parallel (1.19.1)
|
||||
pdfkit (0.8.4.1)
|
||||
popper_js (1.16.0)
|
||||
public_suffix (4.0.5)
|
||||
puma (3.12.6)
|
||||
rack (2.2.2)
|
||||
rack-cors (1.1.1)
|
||||
rack (>= 2.0.0)
|
||||
rack-protection (2.0.7)
|
||||
rack
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.4.3)
|
||||
actioncable (= 5.2.4.3)
|
||||
actionmailer (= 5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
actionview (= 5.2.4.3)
|
||||
activejob (= 5.2.4.3)
|
||||
activemodel (= 5.2.4.3)
|
||||
activerecord (= 5.2.4.3)
|
||||
activestorage (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.4.3)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
loofah (~> 2.3)
|
||||
rails-i18n (5.1.3)
|
||||
i18n (>= 0.7, < 2)
|
||||
railties (>= 5.0, < 6)
|
||||
railties (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rake (13.0.1)
|
||||
rb-fsevent (0.10.4)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rbzip2 (0.2.0)
|
||||
rchardet (1.8.0)
|
||||
redcarpet (3.5.0)
|
||||
redis (4.1.4)
|
||||
redis-actionpack (5.2.0)
|
||||
actionpack (>= 5, < 7)
|
||||
redis-rack (>= 2.1.0, < 3)
|
||||
redis-store (>= 1.1.0, < 2)
|
||||
redis-activesupport (5.2.0)
|
||||
activesupport (>= 3, < 7)
|
||||
redis-store (>= 1.3, < 2)
|
||||
redis-rack (2.1.2)
|
||||
rack (>= 2.0.8, < 3)
|
||||
redis-store (>= 1.2, < 2)
|
||||
redis-rails (5.0.2)
|
||||
redis-actionpack (>= 5.0, < 6)
|
||||
redis-activesupport (>= 5.0, < 6)
|
||||
redis-store (>= 1.2, < 2)
|
||||
redis-store (1.8.2)
|
||||
redis (>= 4, < 5)
|
||||
regexp_parser (1.7.0)
|
||||
request_store (1.5.0)
|
||||
rack (>= 1.4)
|
||||
roo (2.8.3)
|
||||
nokogiri (~> 1)
|
||||
rubyzip (>= 1.3.0, < 3.0.0)
|
||||
roo-xls (1.2.0)
|
||||
nokogiri
|
||||
roo (>= 2.0.0, < 3)
|
||||
spreadsheet (> 0.9.0)
|
||||
rqrcode (0.10.1)
|
||||
chunky_png (~> 1.0)
|
||||
rqrcode_png (0.1.5)
|
||||
chunky_png
|
||||
rqrcode
|
||||
rspec-core (3.9.2)
|
||||
rspec-support (~> 3.9.3)
|
||||
rspec-expectations (3.9.2)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-mocks (3.9.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-rails (3.9.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.9.0)
|
||||
rspec-expectations (~> 3.9.0)
|
||||
rspec-mocks (~> 3.9.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-support (3.9.3)
|
||||
ruby-ole (1.2.12.2)
|
||||
ruby2_keywords (0.0.2)
|
||||
ruby_dep (1.5.0)
|
||||
rubyzip (1.3.0)
|
||||
sass (3.7.4)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sass-rails (5.0.7)
|
||||
railties (>= 4.0.0, < 6)
|
||||
sass (~> 3.1)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
sassc (2.4.0)
|
||||
ffi (~> 1.9)
|
||||
sassc-rails (2.1.2)
|
||||
railties (>= 4.0.0)
|
||||
sassc (>= 2.0)
|
||||
sprockets (> 3.0)
|
||||
sprockets-rails
|
||||
tilt
|
||||
searchkick (3.1.3)
|
||||
activemodel (>= 4.2)
|
||||
elasticsearch (>= 5)
|
||||
hashie
|
||||
selenium-webdriver (3.142.7)
|
||||
childprocess (>= 0.5, < 4.0)
|
||||
rubyzip (>= 1.2.2)
|
||||
sidekiq (5.2.7)
|
||||
connection_pool (~> 2.2, >= 2.2.2)
|
||||
rack (>= 1.5.0)
|
||||
rack-protection (>= 1.5.0)
|
||||
redis (>= 3.3.5, < 5)
|
||||
simple_form (5.0.1)
|
||||
actionpack (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
simple_xlsx_reader (1.0.4)
|
||||
nokogiri
|
||||
rubyzip
|
||||
sinatra (2.0.7)
|
||||
mustermann (~> 1.0)
|
||||
rack (~> 2.0)
|
||||
rack-protection (= 2.0.7)
|
||||
tilt (~> 2.0)
|
||||
spreadsheet (1.2.5)
|
||||
ruby-ole (>= 1.0)
|
||||
spring (2.0.2)
|
||||
activesupport (>= 4.2)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 1.2, < 3.0)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.10)
|
||||
turbolinks (5.2.1)
|
||||
turbolinks-source (~> 5.2)
|
||||
turbolinks-source (5.2.0)
|
||||
tzinfo (1.2.7)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicode-display_width (1.7.0)
|
||||
web-console (3.7.0)
|
||||
actionview (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 5.0)
|
||||
websocket-driver (0.7.2)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
wkhtmltopdf-binary (0.12.5.1)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
aasm
|
||||
actionpack-action_caching
|
||||
active_decorator
|
||||
acts-as-taggable-on (~> 6.0)
|
||||
acts_as_list (= 0.9.19)
|
||||
awesome_print
|
||||
axlsx (~> 3.0.0.pre)
|
||||
axlsx_rails (~> 0.5.2)
|
||||
benchmark-ips
|
||||
bootsnap (>= 1.1.0)
|
||||
bootstrap (~> 4.3.1)
|
||||
bulk_insert
|
||||
byebug (~> 11.0, >= 11.0.1)
|
||||
capybara (~> 3.15, >= 3.15.1)
|
||||
chinese_pinyin
|
||||
chromedriver-helper
|
||||
diffy
|
||||
enumerize
|
||||
faraday (~> 0.15.4)
|
||||
font-awesome-sass (= 4.7.0)
|
||||
gitlab!
|
||||
grape-entity (~> 0.7.1)
|
||||
harmonious_dictionary (~> 0.0.1)
|
||||
jbuilder (~> 2.5)
|
||||
jquery-rails
|
||||
kalibera
|
||||
kaminari (~> 1.1, >= 1.1.1)
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
mini_magick
|
||||
mysql2 (>= 0.4.4, < 0.6.0)
|
||||
oauth2
|
||||
omniauth (~> 1.9.0)
|
||||
omniauth-cas
|
||||
omniauth-oauth2 (~> 1.6.0)
|
||||
parallel (~> 1.19, >= 1.19.1)
|
||||
pdfkit
|
||||
puma (~> 3.11)
|
||||
rack-cors
|
||||
rails (~> 5.2.0)
|
||||
rails-i18n (~> 5.1)
|
||||
rchardet (~> 1.8)
|
||||
redcarpet (~> 3.4)
|
||||
redis-rails
|
||||
request_store
|
||||
roo-xls
|
||||
rqrcode (~> 0.10.1)
|
||||
rqrcode_png
|
||||
rspec-rails (~> 3.8)
|
||||
ruby-ole
|
||||
rubyzip
|
||||
sass-rails (~> 5.0)
|
||||
searchkick
|
||||
selenium-webdriver
|
||||
sidekiq
|
||||
simple_form
|
||||
simple_xlsx_reader
|
||||
sinatra
|
||||
spreadsheet
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
turbolinks (~> 5)
|
||||
tzinfo-data
|
||||
uglifier (>= 1.3.0)
|
||||
web-console (>= 3.3.0)
|
||||
wkhtmltopdf-binary
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.3.7p456
|
||||
|
||||
BUNDLED WITH
|
||||
2.1.4
|
@ -0,0 +1,2 @@
|
||||
web: cd client && npm start
|
||||
api: bundle exec rails s -p 3001
|
@ -0,0 +1,6 @@
|
||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require_relative 'config/application'
|
||||
|
||||
Rails.application.load_tasks
|
@ -0,0 +1,3 @@
|
||||
//= link_tree ../images
|
||||
//= link_directory ../javascripts .js
|
||||
//= link_directory ../stylesheets .css
|
After Width: | Height: | Size: 2.8 KiB |
File diff suppressed because one or more lines are too long
@ -0,0 +1,101 @@
|
||||
//= require rails-ujs
|
||||
//= require activestorage
|
||||
//= require turbolinks
|
||||
//= require jquery3
|
||||
//= require popper
|
||||
//= require bootstrap-sprockets
|
||||
//= require jquery.validate.min
|
||||
//= require additional-methods.min
|
||||
//= require bootstrap-notify
|
||||
//= require jquery.cookie.min
|
||||
//= require select2
|
||||
//= require moment.min
|
||||
//= require jquery.cxselect
|
||||
//= require bootstrap-datepicker
|
||||
//= require bootstrap-datetimepicker
|
||||
//= require bootstrap.viewer
|
||||
//= require jquery.mloading
|
||||
//= require jquery-confirm.min
|
||||
//= require common
|
||||
|
||||
//= require echarts
|
||||
//= require codemirror/lib/codemirror
|
||||
//= require codemirror/mode/shell/shell
|
||||
//= require editormd/editormd
|
||||
//= require editormd/languages/zh-tw
|
||||
//= require dragula/dragula
|
||||
|
||||
//= require_tree ./i18n
|
||||
//= require_tree ./admins
|
||||
|
||||
|
||||
$.ajaxSetup({
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
|
||||
}
|
||||
});
|
||||
|
||||
// ******** select2 global config ********
|
||||
$.fn.select2.defaults.set('theme', 'bootstrap4');
|
||||
$.fn.select2.defaults.set('language', 'zh-CN');
|
||||
|
||||
Turbolinks.setProgressBarDelay(200);
|
||||
|
||||
$.notifyDefaults({
|
||||
type: 'success',
|
||||
z_index: 9999,
|
||||
delay: 2000
|
||||
});
|
||||
|
||||
function show_success_flash(){
|
||||
$.notify({
|
||||
message: '操作成功'
|
||||
},{
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('turbolinks:load', function(){
|
||||
$('[data-toggle="tooltip"]').tooltip({ trigger : 'hover' });
|
||||
$('[data-toggle="popover"]').popover();
|
||||
|
||||
// 图片查看大图
|
||||
$('img.preview-image').bootstrapViewer();
|
||||
|
||||
// flash alert提示框自动关闭
|
||||
if($('.admin-alert-container .alert').length > 0){
|
||||
setTimeout(function(){
|
||||
$('.admin-alert-container .alert:not(.alert-danger)').alert('close');
|
||||
}, 2000);
|
||||
setTimeout(function(){
|
||||
$('.admin-alert-container .alert.alert-danger').alert('close');
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("turbolinks:before-cache", function () {
|
||||
$('[data-toggle="tooltip"]').tooltip('hide');
|
||||
$('[data-toggle="popover"]').popover('hide');
|
||||
});
|
||||
// var progressBar = new Turbolinks.ProgressBar();
|
||||
|
||||
// $(document).on('ajax:send', function(event){
|
||||
// console.log('ajax send', event);
|
||||
// progressBar.setValue(0)
|
||||
// progressBar.show()
|
||||
// });
|
||||
//
|
||||
// $(document).on('ajax:complete', function(event){
|
||||
// console.log('ajax complete', event);
|
||||
// progressBar.setValue(1)
|
||||
// progressBar.hide() // 分页时不触发,奇怪
|
||||
// });
|
||||
// $(document).on('ajax:success', function(event){
|
||||
// console.log('ajax success', event);
|
||||
// });
|
||||
// $(document).on('ajax:error', function(event){
|
||||
// console.log('ajax error', event);
|
||||
// });
|
||||
|
||||
$(function () {
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-abouts-edit-page, body.admins-abouts-update-page').length > 0) {
|
||||
createMDEditor('about-us-editor', {});
|
||||
}
|
||||
})
|
@ -0,0 +1,5 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-agreements-edit-page, body.admins-agreements-update-page').length > 0) {
|
||||
createMDEditor('agreement-editor', {});
|
||||
}
|
||||
})
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
||||
|
||||
function show_add_manager(id) {
|
||||
$(".auth-schools-user-add").modal("show");
|
||||
|
||||
$(".auth-schools-user-add").find("#school_id_input").val(id)
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
$(document).on('turbolinks:load', function(){
|
||||
$(document).on('click', '.batch-all-check-box', function(){
|
||||
var $checkAll = $(this);
|
||||
|
||||
$('.batch-check-box').prop('checked', $checkAll.is(':checked'));
|
||||
})
|
||||
|
||||
$(document).on('click', '.batch-check-box', function(){
|
||||
var allChecked = $('.batch-check-box:checked').length === $('.batch-check-box').length
|
||||
$('.batch-all-check-box').prop('checked', allChecked);
|
||||
})
|
||||
});
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,132 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-carousels-index-page').length > 0) {
|
||||
var laboratoryId = $('#carousels-container').data('laboratoryId');
|
||||
var resetNo = function(){
|
||||
$('#carousels-container .custom-carousel-item-no').each(function(index, ele){
|
||||
$(ele).html(index + 1);
|
||||
})
|
||||
}
|
||||
// 删除后
|
||||
$(document).on('delete_success', resetNo);
|
||||
|
||||
// ------------ 保存链接 -----------
|
||||
$('.carousels-card').on('click', '.save-data-btn', function(){
|
||||
var $link = $(this);
|
||||
var id = $link.data('id');
|
||||
var link = $('.custom-carousel-item-' + id).find('.link-input').val();
|
||||
var name = $('.custom-carousel-item-' + id).find('.name-input').val();
|
||||
if(!name || name.length == 0){
|
||||
$.notify({ message: '名称不能为空' },{ type: 'danger' });
|
||||
return;
|
||||
}
|
||||
$link.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/laboratories/' + laboratoryId + '/carousels/' + id,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
data: { link: link, name: name },
|
||||
success: function(data){
|
||||
$.notify({ message: '操作成功' });
|
||||
},
|
||||
error: ajaxErrorNotifyHandler,
|
||||
complete: function(){
|
||||
$link.removeAttr('disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
// -------------- 是否在首页展示 --------------
|
||||
$('.carousels-card').on('change', '.online-check-box', function(){
|
||||
var $checkbox = $(this);
|
||||
var id = $checkbox.data('id');
|
||||
var checked = $checkbox.is(':checked');
|
||||
$checkbox.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/laboratories/' + laboratoryId + '/carousels/' + id,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
data: { status: checked },
|
||||
success: function(data){
|
||||
$.notify({ message: '保存成功' });
|
||||
var box = $('.custom-carousel-item-' + id).find('.drag');
|
||||
if(checked){
|
||||
box.removeClass('not_active');
|
||||
}else{
|
||||
box.addClass('not_active');
|
||||
}
|
||||
},
|
||||
error: ajaxErrorNotifyHandler,
|
||||
complete: function(){
|
||||
$checkbox.removeAttr('disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// ------------ 拖拽 -------------
|
||||
var onDropFunc = function(el, _target, _source, sibling){
|
||||
var moveId = $(el).data('id');
|
||||
var insertId = $(sibling).data('id') || '';
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/laboratories/' + laboratoryId + '/carousels/drag',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: { move_id: moveId, after_id: insertId },
|
||||
success: function(data){
|
||||
resetNo();
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$.notify({message: '移动失败,原因:' + data.message}, {type: 'danger'});
|
||||
}
|
||||
})
|
||||
};
|
||||
var ele1 = document.getElementById('carousels-container');
|
||||
dragula([ele1], { mirrorContainer: ele1 }).on('drop', onDropFunc);
|
||||
|
||||
|
||||
// ----------- 新增 --------------
|
||||
var $createModal = $('.modal.admin-add-carousel-modal');
|
||||
var $createForm = $createModal.find('form.admin-add-carousel-form');
|
||||
|
||||
$createForm.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"portal_image[image]": {
|
||||
required: true
|
||||
},
|
||||
"portal_image[name]": {
|
||||
required: true
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
$createModal.on('show.bs.modal', function(event){
|
||||
resetFileInputFunc($createModal.find('.img-file-input'));
|
||||
$createModal.find('.file-names').html('选择文件');
|
||||
});
|
||||
|
||||
$createModal.on('click', '.submit-btn', function() {
|
||||
$createForm.find('.error').html('');
|
||||
|
||||
if ($createForm.valid()) {
|
||||
$createForm.submit();
|
||||
} else {
|
||||
$createForm.find('.error').html('请选择图片');
|
||||
}
|
||||
});
|
||||
$createModal.on('change', '.img-file-input', function(){
|
||||
var file = $(this)[0].files[0];
|
||||
$createModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
})
|
||||
|
||||
// -------------- 重新上传图片 --------------
|
||||
//replace_image_url
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
var $carouselItem = $('.custom-carousel-item-' + data.source_id);
|
||||
$carouselItem.find('.custom-carousel-item-img img').attr('src', data.url);
|
||||
})
|
||||
}
|
||||
})
|
@ -0,0 +1,67 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $refuseModal = $('.admin-common-refuse-modal');
|
||||
if ($refuseModal.length > 0) {
|
||||
var $form = $refuseModal.find('form.admin-common-refuse-form');
|
||||
var $applyIdInput = $refuseModal.find('.modal-body input[name="apply_id"]');
|
||||
var $applyTitle = $refuseModal.find('.modal-title');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
reason: {
|
||||
required: true,
|
||||
maxlength: 200
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$refuseModal.on('show.bs.modal', function (event) {
|
||||
var $link = $(event.relatedTarget);
|
||||
|
||||
var applyId = $link.data('id');
|
||||
var url = $link.data('url');
|
||||
var title = $link.data('title');
|
||||
var type = $link.data('type');
|
||||
var form_method = "POST";
|
||||
if(typeof title !== 'undefined'){
|
||||
$applyTitle.html(title)
|
||||
}
|
||||
if(typeof type !== 'undefined'){
|
||||
form_method = type;
|
||||
}
|
||||
|
||||
$applyIdInput.val(applyId);
|
||||
$form.data('url', url);
|
||||
$form.data('type', form_method);
|
||||
});
|
||||
// modal visited fire
|
||||
$refuseModal.on('shown.bs.modal', function(){
|
||||
$refuseModal.find('.modal-body textarea[name="reason"]').focus();
|
||||
});
|
||||
$refuseModal.on('hide.bs.modal', function () {
|
||||
$applyIdInput.val('');
|
||||
$refuseModal.find('.modal-body textarea[name="reason"]').val('');
|
||||
$form.data('url', '');
|
||||
})
|
||||
|
||||
$refuseModal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
var form_method = $form.data('type');
|
||||
|
||||
$.ajax({
|
||||
method: form_method,
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
}).done(function(){
|
||||
$refuseModal.modal('hide');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,148 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-competitions-index-page').length > 0) {
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
var $imageElement = $('.competition-image-' + data.source_id);
|
||||
$imageElement.attr('src', data.url);
|
||||
$imageElement.show();
|
||||
$imageElement.next().html('重新上传');
|
||||
});
|
||||
}
|
||||
|
||||
$(".admin-competition-list-form").on("change", '.competitions-hot-select', function () {
|
||||
var s_value = $(this).get(0).checked ? 1 : 0;
|
||||
var json = {};
|
||||
json["hot"] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/competitions/hot_setting",
|
||||
type: "POST",
|
||||
dataType:'json',
|
||||
data: json,
|
||||
success: function(){
|
||||
$.notify({ message: '操作成功' });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ============== 新增竞赛 ===============
|
||||
var $modal = $('.modal.admin-create-competition-modal');
|
||||
var $form = $modal.find('form.admin-create-competition-form');
|
||||
var $competitionNameInput = $form.find('input[name="competition_name"]');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
competition_name: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function () {
|
||||
$competitionNameInput.val('');
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 导入学生
|
||||
var $importScoreModal = $('.modal.admin-import-competition-score-modal');
|
||||
var $importScoreForm = $importScoreModal.find('form.admin-import-competition-score-form');
|
||||
var $competitionIdInput = $importScoreForm.find('input[name="competition_id"]');
|
||||
|
||||
$importScoreModal.on('show.bs.modal', function(event){
|
||||
resetFileInputFunc($importScoreModal.find('.upload-file-input'));
|
||||
$importScoreModal.find('.file-names').html('选择文件');
|
||||
$importScoreModal.find('.upload-file-input').trigger('click');
|
||||
|
||||
var $link = $(event.relatedTarget);
|
||||
var competitionId = $link.data('competition-id');
|
||||
$competitionIdInput.val(competitionId);
|
||||
});
|
||||
|
||||
$importScoreModal.on('change', '.upload-file-input', function(e){
|
||||
var file = $(this)[0].files[0];
|
||||
$importScoreModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
});
|
||||
|
||||
var importUserFormValid = function(){
|
||||
if($importScoreForm.find('input[name="file"]').val() == undefined || $importScoreForm.find('input[name="file"]').val().length == 0){
|
||||
$importScoreForm.find('.error').html('请选择文件');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var buildResultMessage = function(data){
|
||||
var messageHtml = "<div>导入结果:成功" + data.success + "条,失败"+ data.fail.length + "条</div>";
|
||||
|
||||
if(data.fail.length > 0){
|
||||
messageHtml += '<table class="table"><thead class="thead-light"><tr><th>数据</th><th>失败原因</th></tr></thead><tbody>';
|
||||
|
||||
data.fail.forEach(function(item){
|
||||
messageHtml += '<tr><td>' + item.data + '</td><td>' + item.message + '</td></tr>';
|
||||
});
|
||||
|
||||
messageHtml += '</tbody></table>'
|
||||
}
|
||||
|
||||
return messageHtml;
|
||||
};
|
||||
|
||||
$importScoreModal.on('click', '.submit-btn', function(){
|
||||
$importScoreForm.find('.error').html('');
|
||||
|
||||
if (importUserFormValid()) {
|
||||
$('body').mLoading({ text: '正在导入...' });
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/import_competition_scores',
|
||||
data: new FormData($importScoreForm[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data){
|
||||
$('body').mLoading('destroy');
|
||||
$importScoreModal.modal('hide');
|
||||
|
||||
showMessageModal(buildResultMessage(data), function(){
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
error: function(res){
|
||||
$('body').mLoading('destroy');
|
||||
var data = res.responseJSON;
|
||||
$importScoreForm.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -0,0 +1,96 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-cooperatives-index-page').length > 0) {
|
||||
// ------------ 保存链接 -----------
|
||||
$('.coo-img-card').on('click', '.save-url-btn', function(){
|
||||
var $link = $(this);
|
||||
var cooId = $link.data('id');
|
||||
var url = $('.coo-img-item-' + cooId).find('.url-input').val();
|
||||
$link.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/cooperatives/' + cooId,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
data: { url: url },
|
||||
success: function(data){
|
||||
$.notify({ message: '保存成功' });
|
||||
},
|
||||
error: ajaxErrorNotifyHandler,
|
||||
complete: function(){
|
||||
$link.removeAttr('disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// ------------ 拖拽 -------------
|
||||
var onDropFunc = function(el, _target, _source, sibling){
|
||||
var moveId = $(el).data('id');
|
||||
var insertId = $(sibling).data('id') || '';
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/cooperatives/drag',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: { move_id: moveId, after_id: insertId },
|
||||
success: function(data){
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$.notify({message: '移动失败,原因:' + data.message}, {type: 'danger'});
|
||||
}
|
||||
})
|
||||
};
|
||||
var ele1 = document.getElementById('coo-img-container-alliance_coop');
|
||||
dragula([ele1], { mirrorContainer: ele1 }).on('drop', onDropFunc);
|
||||
var ele2 = document.getElementById('coo-img-container-com_coop');
|
||||
dragula([ele2], { mirrorContainer: ele2 }).on('drop', onDropFunc);
|
||||
var ele3 = document.getElementById('coo-img-container-edu_coop');
|
||||
dragula([ele3], { mirrorContainer: ele3 }).on('drop', onDropFunc);
|
||||
|
||||
|
||||
// ----------- 新增 --------------
|
||||
var $createModal = $('.modal.admin-add-cooperative-modal');
|
||||
var $createForm = $createModal.find('form.admin-add-cooperative-form');
|
||||
|
||||
$createForm.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"coo_img[image]": {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$createModal.on('show.bs.modal', function(event){
|
||||
resetFileInputFunc($createModal.find('.img-file-input'));
|
||||
$createModal.find('.file-names').html('选择文件');
|
||||
|
||||
var $link = $(event.relatedTarget);
|
||||
var imgType = $link.data('imgType');
|
||||
$createForm.find('input[name="coo_img[img_type]"]').val(imgType);
|
||||
});
|
||||
|
||||
$createModal.on('click', '.submit-btn', function() {
|
||||
$createForm.find('.error').html('');
|
||||
|
||||
if ($createForm.valid()) {
|
||||
$createForm.submit();
|
||||
} else {
|
||||
$createForm.find('.error').html('请选择图片');
|
||||
}
|
||||
});
|
||||
$createModal.on('change', '.img-file-input', function(){
|
||||
var file = $(this)[0].files[0];
|
||||
$createModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
})
|
||||
|
||||
// -------------- 重新上传图片 --------------
|
||||
//replace_image_url
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
var $cooImgItem = $('.coo-img-item-' + data.source_id);
|
||||
$.post('/admins/cooperatives/'+ data.source_id + '/replace_image_url');
|
||||
$cooImgItem.find('.coo-img-item-img img').attr('src', data.url);
|
||||
})
|
||||
}
|
||||
})
|
@ -0,0 +1,73 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-courses-index-page').length > 0) {
|
||||
let searchContainer = $(".course-list-form");
|
||||
let searchForm = $("form.search-form",searchContainer);
|
||||
|
||||
searchContainer.on('change', '.course-homepage-show', function(){
|
||||
searchForm.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
|
||||
//导出
|
||||
searchContainer.on('click', "#course-export", function () {
|
||||
window.location.href = "/admins/courses.xlsx?" + searchForm.serialize();
|
||||
});
|
||||
|
||||
|
||||
// 老师信息导出
|
||||
searchContainer.on('click', "#course-teacher-export", function () {
|
||||
window.location.href = "/admins/courses/export_teacher_info.xlsx?" + searchForm.serialize();
|
||||
});
|
||||
|
||||
|
||||
$(".course-list-container").on("change", '.course-setting-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/classrooms/" + s_id,
|
||||
type: "PUT",
|
||||
dataType:'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
|
||||
// 清空
|
||||
searchForm.on('click', '.clear-btn', function () {
|
||||
searchForm.find('select[name="status"]').val('');
|
||||
searchForm.find('.school-select').val('').trigger('change');
|
||||
searchForm.find('input[name="keyword"]').val('');
|
||||
searchForm.find('#homepage_show').attr('checked', false);
|
||||
searchForm.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
|
||||
// ************** 学校选择 *************
|
||||
searchForm.find('.school-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请选择单位',
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/api/schools/search.json',
|
||||
dataType: 'json',
|
||||
data: function (params) {
|
||||
return {keyword: params.term};
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {results: data.schools}
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if (!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
if (item.id) {
|
||||
}
|
||||
return item.name || item.text;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,12 @@
|
||||
$(document).on('turbolinks:load', function(){
|
||||
if ($('body.admins-daily-school-statistics-index-page').length > 0) {
|
||||
$('.export-action').on('click', function(){
|
||||
var form = $(".daily-school-statistic-list-form .search-form")
|
||||
var exportLink = $(this);
|
||||
var keyword = form.find("input[name='keyword']").val();
|
||||
|
||||
var url = exportLink.data("url").split('?')[0] + "?keyword=" + keyword;
|
||||
window.open(url);
|
||||
});
|
||||
}
|
||||
})
|
@ -0,0 +1,66 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-dashboards-index-page').length > 0) {
|
||||
// 月新增用户
|
||||
var monthChart = echarts.init(document.getElementById('month-active-user'));
|
||||
monthChart.setOption({
|
||||
tooltip: {
|
||||
show: "true",
|
||||
trigger: 'item',
|
||||
formatter: '{c0}',
|
||||
backgroundColor: 'rgba(0,0,0,0.7)', // 背景
|
||||
padding: [8, 10], //内边距
|
||||
extraCssText: 'box-shadow: 0 0 3px rgba(255, 255, 255, 0.4);', //添加阴影
|
||||
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||
}
|
||||
},
|
||||
series : [
|
||||
{
|
||||
name: '访问来源',
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
data: []
|
||||
}
|
||||
]
|
||||
});
|
||||
monthChart.showLoading();
|
||||
$.get('/admins/dashboards/month_active_user.json').done(function(data){
|
||||
monthChart.setOption({
|
||||
series: [
|
||||
{ data: data.data }
|
||||
]
|
||||
});
|
||||
|
||||
monthChart.hideLoading();
|
||||
});
|
||||
|
||||
|
||||
// 近七天评测次数
|
||||
// var evaluateChart = echarts.init(document.getElementById('evaluate-pie'));
|
||||
// evaluateChart.setOption({
|
||||
// tooltip: {
|
||||
// show: "true",
|
||||
// trigger: 'item',
|
||||
// formatter: '{c0}',
|
||||
// backgroundColor: 'rgba(0,0,0,0.7)', // 背景
|
||||
// padding: [8, 10], //内边距
|
||||
// extraCssText: 'box-shadow: 0 0 3px rgba(255, 255, 255, 0.4);', //添加阴影
|
||||
// axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||
// type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||
// }
|
||||
// },
|
||||
// xAxis: { type: 'category', boundaryGap: false, data: [] },
|
||||
// yAxis: { type: 'value' },
|
||||
// series: [{ data: [], type: 'line', areaStyle: {} }]
|
||||
// });
|
||||
// evaluateChart.showLoading();
|
||||
// $.get('/admins/dashboards/evaluate.json').done(function(data){
|
||||
// evaluateChart.setOption({
|
||||
// xAxis: { data: data.names },
|
||||
// series: [{ data: data.data }]
|
||||
// });
|
||||
//
|
||||
// evaluateChart.hideLoading();
|
||||
// });
|
||||
}
|
||||
});
|
@ -0,0 +1,173 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-departments-index-page').length > 0) {
|
||||
var $searchContainer = $('.department-list-form');
|
||||
var $searchForm = $searchContainer.find('form.search-form');
|
||||
var $list = $('.department-list-container');
|
||||
|
||||
$searchContainer.on('change', '.form-check-input', function(){
|
||||
$searchForm.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
|
||||
// ============== 新建部门 ===============
|
||||
var $modal = $('.modal.admin-create-department-modal');
|
||||
var $form = $modal.find('form.admin-create-department-form');
|
||||
var $departmentNameInput = $form.find('input[name="department_name"]');
|
||||
var $schoolSelect = $modal.find('.school-select');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
school_id: {
|
||||
required: true
|
||||
},
|
||||
department_name: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
school_id: {
|
||||
required: '请选择所属单位'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function () {
|
||||
$departmentNameInput.val('');
|
||||
$schoolSelect.select2('val', ' ');
|
||||
});
|
||||
|
||||
// ************** 学校选择 *************
|
||||
var matcherFunc = function(params, data){
|
||||
if ($.trim(params.term) === '') {
|
||||
return data;
|
||||
}
|
||||
if (typeof data.text === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.name && data.name.indexOf(params.term) > -1) {
|
||||
var modifiedData = $.extend({}, data, true);
|
||||
return modifiedData;
|
||||
}
|
||||
|
||||
// Return `null` if the term should not be displayed
|
||||
return null;
|
||||
};
|
||||
|
||||
var defineSchoolSelect = function(schools) {
|
||||
$schoolSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请选择所属单位',
|
||||
minimumInputLength: 1,
|
||||
data: schools,
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
$('#school_id').val(item.id);
|
||||
}
|
||||
return item.name || item.text;
|
||||
},
|
||||
matcher: matcherFunc
|
||||
});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '/api/schools/for_option.json',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
defineSchoolSelect(data.schools);
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// ============= 添加部门管理员 ==============
|
||||
var $addMemberModal = $('.admin-add-department-member-modal');
|
||||
var $addMemberForm = $addMemberModal.find('.admin-add-department-member-form');
|
||||
var $memberSelect = $addMemberModal.find('.department-member-select');
|
||||
var $departmentIdInput = $addMemberForm.find('input[name="department_id"]')
|
||||
|
||||
$addMemberModal.on('show.bs.modal', function(event){
|
||||
var $link = $(event.relatedTarget);
|
||||
var departmentId = $link.data('department-id');
|
||||
$departmentIdInput.val(departmentId);
|
||||
|
||||
$memberSelect.select2('val', ' ');
|
||||
});
|
||||
|
||||
$memberSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请输入要添加的管理员姓名',
|
||||
multiple: true,
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/admins/users',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { name: params.term };
|
||||
},
|
||||
processResults: function(data){
|
||||
return { results: data.users }
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.real_name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
}
|
||||
return item.real_name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
$addMemberModal.on('click', '.submit-btn', function(){
|
||||
$addMemberForm.find('.error').html('');
|
||||
|
||||
var departmentId = $departmentIdInput.val();
|
||||
var memberIds = $memberSelect.val();
|
||||
if (departmentId && memberIds && memberIds.length > 0) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'script',
|
||||
url: '/admins/departments/' + departmentId + '/department_member',
|
||||
data: { user_ids: memberIds }
|
||||
});
|
||||
} else {
|
||||
$addMemberModal.modal('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,138 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-disciplines-index-page').length > 0) {
|
||||
|
||||
// ============== 新建 ===============
|
||||
var $modal = $('.modal.admin-create-discipline-modal');
|
||||
var $form = $modal.find('form.admin-create-discipline-form');
|
||||
var $nameInput = $form.find('input[name="name"]');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function () {
|
||||
$nameInput.val('');
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".discipline-list-container").on("change", '.discipline-source-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/disciplines/" + s_id,
|
||||
type: "PUT",
|
||||
dataType:'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
|
||||
// 导入学生
|
||||
var $importDisciplineModal = $('.modal.admin-import-discipline-modal');
|
||||
var $importDisciplineForm = $importDisciplineModal.find('form.admin-import-discipline-form');
|
||||
|
||||
$importDisciplineModal.on('show.bs.modal', function(){
|
||||
resetFileInputFunc($importDisciplineModal.find('.upload-file-input'));
|
||||
$importDisciplineModal.find('.file-names').html('选择文件');
|
||||
$importDisciplineModal.find('.upload-file-input').trigger('click');
|
||||
});
|
||||
$importDisciplineModal.on('change', '.upload-file-input', function(e){
|
||||
var file = $(this)[0].files[0];
|
||||
$importDisciplineModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
});
|
||||
|
||||
var importDisciplineFormValid = function(){
|
||||
if($importDisciplineForm.find('input[name="file"]').val() == undefined || $importDisciplineForm.find('input[name="file"]').val().length == 0){
|
||||
$importDisciplineForm.find('.error').html('请选择文件');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var buildResultMessage = function(data){
|
||||
var messageHtml = "<div>导入结果:成功" + data.success + "条,失败"+ data.fail.length + "条</div>";
|
||||
|
||||
return messageHtml;
|
||||
};
|
||||
|
||||
$importDisciplineModal.on('click', '.submit-btn', function(){
|
||||
$importDisciplineForm.find('.error').html('');
|
||||
|
||||
if (importDisciplineFormValid()) {
|
||||
$('body').mLoading({ text: '正在导入...' });
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/import_disciplines',
|
||||
data: new FormData($importDisciplineForm[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data){
|
||||
$('body').mLoading('destroy');
|
||||
$importDisciplineModal.modal('hide');
|
||||
|
||||
showMessageModal(buildResultMessage(data), function(){
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
error: function(res){
|
||||
$('body').mLoading('destroy');
|
||||
var data = res.responseJSON;
|
||||
$importDisciplineForm.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// ------------ 上移/下移 -------------
|
||||
$('.discipline-list-container').on('click', ".move-action", function () {
|
||||
var $doAction = $(this);
|
||||
|
||||
var disciplineId = $doAction.data('id');
|
||||
var opr = $doAction.data('opr');
|
||||
$.ajax({
|
||||
url: '/admins/disciplines/' + disciplineId + '/adjust_position',
|
||||
method: 'POST',
|
||||
dataType: 'script',
|
||||
data: {opr: opr}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,70 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-ec-templates-index-page').length > 0) {
|
||||
var add_modal = $(".ec-templates-new-add");
|
||||
var template_file_name = add_modal.find(".template-file-upload");
|
||||
var attachment_id_input = add_modal.find(".template_attachment_id");
|
||||
var template_container = $(".ec-templates-list-container");
|
||||
|
||||
//编辑附件
|
||||
template_container.on("click", ".edit-template-content", function () {
|
||||
var t_id = $(this).attr("data-id");
|
||||
var t_name = $(this).attr("data-name");
|
||||
var template_name = $(this).attr("data-template-name");
|
||||
var t_msg = $(this).attr("data-msg");
|
||||
var template_id = $(this).attr("data-template-id");
|
||||
add_modal.modal("show");
|
||||
add_modal.find(".template_add_title").html(t_msg);
|
||||
attachment_id_input.val(template_id);
|
||||
add_modal.find(".template_show_id").val(t_id);
|
||||
add_modal.find("input[name='name']").val(t_name);
|
||||
add_modal.find("i.delete-template-icon").attr("data-id", template_id);
|
||||
if(template_id !== "-1"){
|
||||
template_file_name.find("span.template-file-input").hide();
|
||||
template_file_name.find("span.template_file_show").show();
|
||||
template_file_name.find("span.template_file_show_title").html(template_name);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//删除附件
|
||||
add_modal.on("click",".delete-template-icon",function () {
|
||||
var attachment_id = $(this).attr("data-id");
|
||||
$.ajax({
|
||||
url: "/api/attachments/" + attachment_id,
|
||||
type: "delete",
|
||||
contentType:"application/json",
|
||||
dataType:"json",
|
||||
success: function (data) {
|
||||
template_file_name.find("span.template-file-input").show();
|
||||
template_file_name.find("span.template_file_show").hide();
|
||||
attachment_id_input.attr("value","-1")
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
//上传附件
|
||||
add_modal.on("change", "#upload_template_file",function () {
|
||||
|
||||
var template = document.getElementById('upload_template_file').files[0];
|
||||
|
||||
var file_content = new FormData();
|
||||
|
||||
file_content.append("file", template);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/api/attachments",
|
||||
data:file_content,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
template_file_name.find("span.template-file-input").hide();
|
||||
template_file_name.find("span.template_file_show").show();
|
||||
template_file_name.find("span.template_file_show_title").html(template.name);
|
||||
template_file_name.find("i.delete-template-icon").attr("data-id",data.id);
|
||||
attachment_id_input.val(data.id)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
@ -0,0 +1,9 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if($('body.admins-enroll-lists-index-page').length > 0){
|
||||
var search_form = $(".search-form");
|
||||
//导出
|
||||
$(".competition-enroll-list-form").on("click","#enroll-lists-export",function () {
|
||||
window.location.href = "/admins/competitions/"+$(this).attr("data-competition-id")+"/enroll_lists/export.xlsx?" + search_form.serialize();
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,22 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-examination-authentications-index-page').length > 0) {
|
||||
var $searchFrom = $('.examination-authentication-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if($link.data('value') === 'processed'){
|
||||
$('.batch-action-container').hide();
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$('.batch-action-container').show();
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,13 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if($(".admins-graduation-standards-index-page").length > 0){
|
||||
$(".admin-body-container").on("click", ".standard-create-modal", function () {
|
||||
var content = $(this).attr("data-content");
|
||||
var g_id = $(this).attr("data-id");
|
||||
var g_msg = $(this).attr("data-msg");
|
||||
|
||||
$("#graduation-modal-type").html(g_msg);
|
||||
$("#graduation_standard_id").val(g_id);
|
||||
$("textarea[name='content']").val(content);
|
||||
})
|
||||
}
|
||||
});
|
@ -0,0 +1,74 @@
|
||||
$(document).on("turbolinks:load", function() {
|
||||
if ($("body.admins-hack-imports-index-page").length > 0) {
|
||||
// 导入题库
|
||||
var $import_hack_import = $(".modal.admin-import-hack-modal");
|
||||
var $importForm = $import_hack_import.find(
|
||||
"form.admin-import-hack-form"
|
||||
);
|
||||
|
||||
$import_hack_import.on("show.bs.modal", function() {
|
||||
resetFileInputFunc($import_hack_import.find(".upload-file-input"));
|
||||
$import_hack_import.find(".file-names").html("选择文件");
|
||||
$import_hack_import.find(".upload-file-input").trigger("click");
|
||||
});
|
||||
$import_hack_import.on("change", ".upload-file-input", function(e) {
|
||||
var file = $(this)[0].files[0];
|
||||
$import_hack_import
|
||||
.find(".file-names")
|
||||
.html(file ? file.name : "请选择文件");
|
||||
});
|
||||
|
||||
var importFormValid = function() {
|
||||
if (
|
||||
$importForm.find('input[name="file"]').val() == undefined ||
|
||||
$importForm.find('input[name="file"]').val().length == 0
|
||||
) {
|
||||
$importForm.find(".error").html("请选择文件");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var buildResultMessage = function(data) {
|
||||
var messageHtml =
|
||||
"<div>导入结果:成功" +
|
||||
data.success +
|
||||
"条,失败" +
|
||||
data.fail.length +
|
||||
"条</div>";
|
||||
|
||||
return messageHtml;
|
||||
};
|
||||
|
||||
$import_hack_import.on("click", ".submit-btn", function() {
|
||||
$importForm.find(".error").html("");
|
||||
|
||||
if (importFormValid()) {
|
||||
$("body").mLoading({ text: "正在导入..." });
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
url: "/admins/hack_imports",
|
||||
data: new FormData($importForm[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
$("body").mLoading("destroy");
|
||||
$import_hack_import.modal("hide");
|
||||
|
||||
showMessageModal(buildResultMessage(data), function() {
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
error: function(res) {
|
||||
$("body").mLoading("destroy");
|
||||
var data = res.responseJSON;
|
||||
$importForm.find(".error").html(data.message);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-help-centers-edit-page, body.admins-help-centers-update-page').length > 0) {
|
||||
createMDEditor('help-center-editor', {});
|
||||
}
|
||||
})
|
@ -0,0 +1,50 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-identity-authentications-index-page').length > 0) {
|
||||
var $searchFrom = $('.identity-authentication-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if($link.data('value') === 'processed'){
|
||||
$('.batch-action-container').hide();
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$('.batch-action-container').show();
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
|
||||
$('.batch-agree-btn').on('click', function(){
|
||||
if($('.batch-check-box:checked').length === 0){
|
||||
$.notify({ message: '请先选择数据' }, { type: 'info' });
|
||||
return;
|
||||
}
|
||||
|
||||
customConfirm({
|
||||
content: '确认审核通过?',
|
||||
ok: function(){
|
||||
var ids = $('.batch-check-box:checked').map(function(_, e){ return $(e).val() }).get();
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/identity_authentications/batch_agree',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: { ids: ids },
|
||||
success: function(data){
|
||||
$.notify({ message: '操作成功' });
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(res){
|
||||
$.notify({ message: res.responseJSON.message }, { type: 'danger' });
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
@ -0,0 +1,22 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-item-authentications-index-page').length > 0) {
|
||||
var $searchFrom = $('.item-authentication-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if($link.data('value') === 'processed'){
|
||||
$('.batch-action-container').hide();
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$('.batch-action-container').show();
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,64 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-item-banks-index-page').length > 0) {
|
||||
// 导入题库
|
||||
var $import_item_bank = $('.modal.admin-import-item_bank-modal');
|
||||
var $importForm = $import_item_bank.find('form.admin-import-item_bank-form');
|
||||
|
||||
$import_item_bank.on('show.bs.modal', function () {
|
||||
resetFileInputFunc($import_item_bank.find('.upload-file-input'));
|
||||
$import_item_bank.find('.file-names').html('选择文件');
|
||||
$import_item_bank.find('.upload-file-input').trigger('click');
|
||||
})
|
||||
$import_item_bank.on('change', '.upload-file-input', function (e) {
|
||||
var file = $(this)[0].files[0];
|
||||
$import_item_bank.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
})
|
||||
|
||||
var importFormValid = function () {
|
||||
if ($importForm.find('input[name="file"]').val() == undefined || $importForm.find('input[name="file"]').val().length == 0) {
|
||||
$importForm.find('.error').html('请选择文件');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var buildResultMessage = function (data) {
|
||||
var messageHtml = "<div>导入结果:成功" + data.success + "条,失败" + data.fail.length + "条</div>";
|
||||
|
||||
return messageHtml;
|
||||
}
|
||||
|
||||
$import_item_bank.on('click', '.submit-btn', function () {
|
||||
$importForm.find('.error').html('');
|
||||
|
||||
if (importFormValid()) {
|
||||
$('body').mLoading({
|
||||
text: '正在导入...'
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/item_banks',
|
||||
data: new FormData($importForm[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (data) {
|
||||
$('body').mLoading('destroy');
|
||||
$import_item_bank.modal('hide');
|
||||
|
||||
showMessageModal(buildResultMessage(data), function () {
|
||||
window.location.reload();
|
||||
})
|
||||
},
|
||||
error: function (res) {
|
||||
$('body').mLoading('destroy');
|
||||
var data = res.responseJSON;
|
||||
$importForm.find('.error').html(data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
@ -0,0 +1,51 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-job-authentications-index-page').length > 0) {
|
||||
$(".admins-job-authentications-index-page").on("click", ".reject", function() {
|
||||
var self = this;
|
||||
bootbox.prompt({
|
||||
title: "确认拒绝",
|
||||
required: true,
|
||||
placeholder: '请输入合适拒绝理由',
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: '确定',
|
||||
className: 'btn-success'
|
||||
},
|
||||
cancel: {
|
||||
label: '取消',
|
||||
className: 'btn-danger'
|
||||
}
|
||||
},
|
||||
callback: function(result) {
|
||||
if (result === null) {
|
||||
return true;
|
||||
}
|
||||
var id = $(self).attr("id");
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
dataType: 'script',
|
||||
data: { reason: result },
|
||||
url: "/admins/job_authentications/" + id + "/refuse?element=.job-authentication-" + id + "&=refresh_url=" + "/admins/job_authentications/" + id,
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
var $searchFrom = $('.job-authentication-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function() {
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if ($link.data('value') === 'processed') {
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,86 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-laboratory-settings-show-page, body.admins-laboratory-settings-update-page').length > 0) {
|
||||
var $container = $('.edit-laboratory-setting-container');
|
||||
var $form = $container.find('.edit_laboratory');
|
||||
|
||||
$('.logo-item-left, .banner-item-bottom').on("change", 'input[type="file"]', function () {
|
||||
var $fileInput = $(this);
|
||||
var file = this.files[0];
|
||||
var imageType = /image.*/;
|
||||
if (file && file.type.match(imageType)) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function () {
|
||||
var $box = $fileInput.parent();
|
||||
$box.find('img').attr('src', reader.result).css('display', 'block');
|
||||
$box.addClass('has-img');
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
}
|
||||
});
|
||||
|
||||
createMDEditor('laboratory-footer-editor', { height: 200, placeholder: '请输入备案信息' });
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
errorPlacement:function(error,element){
|
||||
if(element.parent().hasClass("input-group")){
|
||||
element.parent().after(error);
|
||||
}else{
|
||||
element.after(error)
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
identifier: {
|
||||
required: true,
|
||||
checkSite: true
|
||||
},
|
||||
name: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
$.validator.addMethod("checkSite",function(value,element,params){
|
||||
var checkSite = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
|
||||
return this.optional(element)||(checkSite.test(value + '.educoder.com'));
|
||||
},"域名不合法!");
|
||||
|
||||
$form.on('click', '.submit-btn', function(){
|
||||
$form.find('.submit-btn').attr('disabled', 'disabled');
|
||||
$form.find('.error').html('');
|
||||
var valid = $form.valid();
|
||||
|
||||
$('input[name="navbar[][name]"]').each(function(_, e){
|
||||
var $ele = $(e);
|
||||
if($ele.val() === undefined || $ele.val().length === 0){
|
||||
$ele.addClass('danger text-danger');
|
||||
valid = false;
|
||||
} else {
|
||||
$ele.removeClass('danger text-danger');
|
||||
}
|
||||
});
|
||||
|
||||
if(!valid) return;
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
url: $form.attr('action'),
|
||||
data: new FormData($form[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data){
|
||||
$.notify({ message: '保存成功' });
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
},
|
||||
complete: function(){
|
||||
$form.find('.submit-btn').attr('disabled', false);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
@ -0,0 +1,189 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-laboratories-index-page').length > 0) {
|
||||
var $searchContainer = $('.laboratory-list-form');
|
||||
var $searchForm = $searchContainer.find('form.search-form');
|
||||
var $list = $('.laboratory-list-container');
|
||||
|
||||
// ============== 新建 ===============
|
||||
var $modal = $('.modal.admin-create-laboratory-modal');
|
||||
var $form = $modal.find('form.admin-create-laboratory-form');
|
||||
var $schoolSelect = $modal.find('.school-select');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
school_id: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
school_id: {
|
||||
required: '请选择所属单位'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function () {
|
||||
$schoolSelect.select2('val', ' ');
|
||||
});
|
||||
|
||||
// ************** 学校选择 *************
|
||||
var matcherFunc = function(params, data){
|
||||
if ($.trim(params.term) === '') {
|
||||
return data;
|
||||
}
|
||||
if (typeof data.text === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.name && data.name.indexOf(params.term) > -1) {
|
||||
var modifiedData = $.extend({}, data, true);
|
||||
return modifiedData;
|
||||
}
|
||||
|
||||
// Return `null` if the term should not be displayed
|
||||
return null;
|
||||
};
|
||||
|
||||
var defineSchoolSelect = function(schools) {
|
||||
$schoolSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请选择单位',
|
||||
minimumInputLength: 1,
|
||||
data: schools,
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
$('#school_id').val(item.id);
|
||||
}
|
||||
return item.name || item.text;
|
||||
},
|
||||
matcher: matcherFunc
|
||||
});
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: '/api/schools/for_option.json',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
defineSchoolSelect(data.schools);
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// ============= 添加管理员 ==============
|
||||
var $addMemberModal = $('.admin-add-laboratory-user-modal');
|
||||
var $addMemberForm = $addMemberModal.find('.admin-add-laboratory-user-form');
|
||||
var $memberSelect = $addMemberModal.find('.laboratory-user-select');
|
||||
var $laboratoryIdInput = $addMemberForm.find('input[name="laboratory_id"]')
|
||||
|
||||
$addMemberModal.on('show.bs.modal', function(event){
|
||||
var $link = $(event.relatedTarget);
|
||||
var laboratoryId = $link.data('laboratory-id');
|
||||
$laboratoryIdInput.val(laboratoryId);
|
||||
|
||||
$memberSelect.select2('val', ' ');
|
||||
});
|
||||
|
||||
$memberSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请输入要添加的管理员姓名',
|
||||
multiple: true,
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/admins/users',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { name: params.term };
|
||||
},
|
||||
processResults: function(data){
|
||||
return { results: data.users }
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return $("<span>" + item.real_name + " <span class='font-12'>" + item.school_name + ' ' + item.hidden_phone + "</span></span>");
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
}
|
||||
return item.real_name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
$addMemberModal.on('click', '.submit-btn', function(){
|
||||
$addMemberForm.find('.error').html('');
|
||||
|
||||
var laboratoryId = $laboratoryIdInput.val();
|
||||
var memberIds = $memberSelect.val();
|
||||
if (laboratoryId && memberIds && memberIds.length > 0) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'script',
|
||||
url: '/admins/laboratories/' + laboratoryId + '/laboratory_user',
|
||||
data: { user_ids: memberIds }
|
||||
});
|
||||
} else {
|
||||
$addMemberModal.modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
$(".laboratory-list-container").on("change", '.laboratory-sync-course', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var json = {};
|
||||
$.ajax({
|
||||
url: "/admins/laboratories/" + s_id + "/update_sync_course",
|
||||
type: "POST",
|
||||
dataType:'script',
|
||||
data: json
|
||||
})
|
||||
});
|
||||
|
||||
$(".laboratory-list-container").on("change", '.laboratory-sync-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/laboratories/" + s_id,
|
||||
type: "PUT",
|
||||
dataType:'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,126 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-laboratory-shixuns-index-page').length > 0) {
|
||||
var $searchForm = $('.laboratory-shixun-list-form .search-form');
|
||||
var laboratoryId = $('.laboratory-shixun-list-container').data('id');
|
||||
|
||||
$searchForm.find('select#tag_id').select2({
|
||||
placeholder: "请选择",
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
// 定义状态切换监听事件
|
||||
var defineStatusChangeFunc = function (doElement, undoElement, url, callback) {
|
||||
$('.laboratory-shixun-list-container').on('click', doElement, function () {
|
||||
var $doAction = $(this);
|
||||
var $undoAction = $doAction.siblings(undoElement);
|
||||
|
||||
var laboratoryShixunId = $doAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认进行该操作吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/laboratories/' + laboratoryId + '/laboratory_shixuns/' + laboratoryShixunId + url,
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function () {
|
||||
show_success_flash();
|
||||
$doAction.hide();
|
||||
$undoAction.show();
|
||||
if (callback && typeof callback === "function") {
|
||||
callback(laboratoryShixunId, url);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 首页展示与取消首页展示
|
||||
var homepageShowCallback = function (laboratoryShixunId, url) {
|
||||
var $laboratoryShixunItem = $('.laboratory-shixun-list-container').find('.laboratory-shixun-item-' + laboratoryShixunId);
|
||||
|
||||
if (url === '/homepage') {
|
||||
$laboratoryShixunItem.find('.homepage-badge').show();
|
||||
} else {
|
||||
$laboratoryShixunItem.find('.homepage-badge').hide();
|
||||
}
|
||||
}
|
||||
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage', homepageShowCallback);
|
||||
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage', homepageShowCallback);
|
||||
|
||||
// 添加实训功能
|
||||
var $addModal = $('.modal.admin-add-laboratory-shixun-modal');
|
||||
var $addForm = $addModal.find('form.admin-add-laboratory-user-form');
|
||||
var $shixunSelect = $addForm.find('select.shixun-select');
|
||||
|
||||
$addModal.on('show.bs.modal', function(){
|
||||
$addModal.find('.error').html('');
|
||||
$shixunSelect.select2('val', ' ');
|
||||
});
|
||||
|
||||
$shixunSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请输入实训名称/创建者检索',
|
||||
multiple: true,
|
||||
closeOnSelect: false,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/admins/laboratories/' + laboratoryId + '/shixuns_for_select',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { keyword: params.term, page: params.page || 1, per_page: 20 };
|
||||
},
|
||||
processResults: function(data, params){
|
||||
params.page = params.page || 1;
|
||||
|
||||
return {
|
||||
results: data.shixuns,
|
||||
pagination: {
|
||||
more: (params.page * 20) < data.count
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
var ele = '<span>'
|
||||
ele += '<span>' + item.name + '</span>';
|
||||
ele += '<span class="font-12"> -- ' + item.creator_name + '</span>';
|
||||
ele += '<span class="font-12"> -- ' + item.status_text+ '</span>';
|
||||
ele += '</span>';
|
||||
|
||||
return $(ele);
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
}
|
||||
var ele = '<span>' + (item.name || item.text) + '<span class="font-12"> -- ' + item.creator_name + '</span></span>'
|
||||
return $(ele);
|
||||
}
|
||||
});
|
||||
|
||||
$addModal.on('click', '.submit-btn', function(){
|
||||
$addModal.find('.error').html('');
|
||||
|
||||
var shixunIds = $shixunSelect.val();
|
||||
if (shixunIds && shixunIds.length > 0) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/laboratories/' + laboratoryId + '/laboratory_shixuns',
|
||||
data: { shixun_ids: shixunIds },
|
||||
success: function(){
|
||||
show_success_flash();
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(res){
|
||||
$addModal.find('.error').html(res.responseJSON.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$addModal.find('.error').html('请选择实训');
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
@ -0,0 +1,148 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-laboratory-subjects-index-page').length > 0) {
|
||||
var $searchForm = $('.laboratory-subject-list-form .search-form');
|
||||
var laboratoryId = $('.laboratory-subject-list-container').data('id');
|
||||
|
||||
// ************** 学校选择 *************
|
||||
$searchForm.find('.school-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请选择创建者单位',
|
||||
allowClear: true,
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/api/schools/search.json',
|
||||
dataType: 'json',
|
||||
data: function (params) {
|
||||
return {keyword: params.term};
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {results: data.schools}
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if (!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
if (item.id) {
|
||||
}
|
||||
return item.name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
// 定义状态切换监听事件
|
||||
var defineStatusChangeFunc = function (doElement, undoElement, url, callback) {
|
||||
$('.laboratory-subject-list-container').on('click', doElement, function () {
|
||||
var $doAction = $(this);
|
||||
var $undoAction = $doAction.siblings(undoElement);
|
||||
|
||||
var laboratorySubjectId = $doAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认进行该操作吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/laboratories/' + laboratoryId + '/laboratory_subjects/' + laboratorySubjectId + url,
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function () {
|
||||
show_success_flash();
|
||||
$doAction.hide();
|
||||
$undoAction.show();
|
||||
if (callback && typeof callback === "function") {
|
||||
callback(laboratorySubjectId, url);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 首页展示与取消首页展示
|
||||
var homepageShowCallback = function (laboratoryShixunId, url) {
|
||||
var $laboratoryShixunItem = $('.laboratory-subject-list-container').find('.laboratory-subject-item-' + laboratoryShixunId);
|
||||
|
||||
if (url === '/homepage') {
|
||||
$laboratoryShixunItem.find('.homepage-badge').show();
|
||||
} else {
|
||||
$laboratoryShixunItem.find('.homepage-badge').hide();
|
||||
}
|
||||
}
|
||||
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage', homepageShowCallback);
|
||||
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage', homepageShowCallback);
|
||||
|
||||
// 添加实践课程功能
|
||||
var $addModal = $('.modal.admin-add-laboratory-subject-modal');
|
||||
var $addForm = $addModal.find('form.admin-add-laboratory-user-form');
|
||||
var $subjectSelect = $addForm.find('select.subject-select');
|
||||
|
||||
$addModal.on('show.bs.modal', function(){
|
||||
$addModal.find('.error').html('');
|
||||
$subjectSelect.select2('val', ' ');
|
||||
});
|
||||
|
||||
$subjectSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请输入课程名称/创建者检索',
|
||||
multiple: false,
|
||||
closeOnSelect: true,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/admins/laboratories/' + laboratoryId + '/subjects_for_select',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { keyword: params.term, page: params.page || 1, per_page: 20 }
|
||||
},
|
||||
processResults: function(data, params){
|
||||
params.page = params.page || 1;
|
||||
|
||||
return {
|
||||
results: data.subjects,
|
||||
pagination: {
|
||||
more: (params.page * 20) < data.count
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
var ele = '<span>';
|
||||
ele += '<span>' + item.name + '</span>';
|
||||
ele += '<span class="font-12"> -- ' + item.creator_name + '</span>';
|
||||
ele += '<span class="font-12"> -- ' + item.status_text+ '</span>';
|
||||
ele += '</span>';
|
||||
|
||||
return $(ele);
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
var ele = '<span>' + (item.name || item.text) + '<span class="font-12"> -- ' + item.creator_name + '</span></span>';
|
||||
return $(ele);
|
||||
}
|
||||
});
|
||||
|
||||
$addModal.on('click', '.submit-btn', function(){
|
||||
$addModal.find('.error').html('');
|
||||
|
||||
var subjectIds = $subjectSelect.val();
|
||||
if (subjectIds && subjectIds.length > 0) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/laboratories/' + laboratoryId + '/laboratory_subjects',
|
||||
data: { subject_id: subjectIds },
|
||||
success: function(){
|
||||
show_success_flash();
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(res){
|
||||
$addModal.find('.error').html(res.responseJSON.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$addModal.find('.error').html('请选择课程');
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
@ -0,0 +1,660 @@
|
||||
/*
|
||||
* jQuery treetable Plugin 3.1.0
|
||||
* http://ludo.cubicphuse.nl/jquery-treetable
|
||||
*
|
||||
* Copyright 2013, Ludo van den Boom
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*/
|
||||
(function() {
|
||||
var $, Node, Tree, methods;
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
Node = (function() {
|
||||
function Node(row, tree, settings) {
|
||||
var parentId;
|
||||
|
||||
this.row = row;
|
||||
this.tree = tree;
|
||||
this.settings = settings;
|
||||
|
||||
// TODO Ensure id/parentId is always a string (not int)
|
||||
this.id = this.row.data(this.settings.nodeIdAttr);
|
||||
|
||||
// TODO Move this to a setParentId function?
|
||||
parentId = this.row.data(this.settings.parentIdAttr);
|
||||
if (parentId != null && parentId !== "") {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
this.treeCell = $(this.row.children(this.settings.columnElType)[this.settings.column]);
|
||||
this.expander = $(this.settings.expanderTemplate);
|
||||
this.indenter = $(this.settings.indenterTemplate);
|
||||
this.children = [];
|
||||
this.initialized = false;
|
||||
this.treeCell.prepend(this.indenter);
|
||||
}
|
||||
|
||||
Node.prototype.addChild = function(child) {
|
||||
return this.children.push(child);
|
||||
};
|
||||
|
||||
Node.prototype.ancestors = function() {
|
||||
var ancestors, node;
|
||||
node = this;
|
||||
ancestors = [];
|
||||
while (node = node.parentNode()) {
|
||||
ancestors.push(node);
|
||||
}
|
||||
return ancestors;
|
||||
};
|
||||
|
||||
Node.prototype.collapse = function() {
|
||||
if (this.collapsed()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.row.removeClass("expanded").addClass("collapsed");
|
||||
|
||||
this._hideChildren();
|
||||
this.expander.attr("title", this.settings.stringExpand);
|
||||
|
||||
if (this.initialized && this.settings.onNodeCollapse != null) {
|
||||
this.settings.onNodeCollapse.apply(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.collapsed = function() {
|
||||
return this.row.hasClass("collapsed");
|
||||
};
|
||||
|
||||
// TODO destroy: remove event handlers, expander, indenter, etc.
|
||||
|
||||
Node.prototype.expand = function() {
|
||||
if (this.expanded()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.row.removeClass("collapsed").addClass("expanded");
|
||||
|
||||
if (this.initialized && this.settings.onNodeExpand != null) {
|
||||
this.settings.onNodeExpand.apply(this);
|
||||
}
|
||||
|
||||
if ($(this.row).is(":visible")) {
|
||||
this._showChildren();
|
||||
}
|
||||
|
||||
this.expander.attr("title", this.settings.stringCollapse);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.expanded = function() {
|
||||
return this.row.hasClass("expanded");
|
||||
};
|
||||
|
||||
Node.prototype.hide = function() {
|
||||
this._hideChildren();
|
||||
this.row.hide();
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.isBranchNode = function() {
|
||||
if(this.children.length > 0 || this.row.data(this.settings.branchAttr) === true) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Node.prototype.updateBranchLeafClass = function(){
|
||||
this.row.removeClass('branch');
|
||||
this.row.removeClass('leaf');
|
||||
this.row.addClass(this.isBranchNode() ? 'branch' : 'leaf');
|
||||
};
|
||||
|
||||
Node.prototype.level = function() {
|
||||
return this.ancestors().length;
|
||||
};
|
||||
|
||||
Node.prototype.parentNode = function() {
|
||||
if (this.parentId != null) {
|
||||
return this.tree[this.parentId];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Node.prototype.removeChild = function(child) {
|
||||
var i = $.inArray(child, this.children);
|
||||
return this.children.splice(i, 1)
|
||||
};
|
||||
|
||||
Node.prototype.render = function() {
|
||||
var handler,
|
||||
settings = this.settings,
|
||||
target;
|
||||
|
||||
if (settings.expandable === true && this.isBranchNode()) {
|
||||
handler = function(e) {
|
||||
$(this).parents("table").treetable("node", $(this).parents("tr").data(settings.nodeIdAttr)).toggle();
|
||||
return e.preventDefault();
|
||||
};
|
||||
|
||||
this.indenter.html(this.expander);
|
||||
target = settings.clickableNodeNames === true ? this.treeCell : this.expander;
|
||||
|
||||
target.off("click.treetable").on("click.treetable", handler);
|
||||
target.off("keydown.treetable").on("keydown.treetable", function(e) {
|
||||
if (e.keyCode == 13) {
|
||||
handler.apply(this, [e]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.indenter[0].style.paddingLeft = "" + (this.level() * settings.indent) + "px";
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.reveal = function() {
|
||||
if (this.parentId != null) {
|
||||
this.parentNode().reveal();
|
||||
}
|
||||
return this.expand();
|
||||
};
|
||||
|
||||
Node.prototype.setParent = function(node) {
|
||||
if (this.parentId != null) {
|
||||
this.tree[this.parentId].removeChild(this);
|
||||
}
|
||||
this.parentId = node.id;
|
||||
this.row.data(this.settings.parentIdAttr, node.id);
|
||||
return node.addChild(this);
|
||||
};
|
||||
|
||||
Node.prototype.show = function() {
|
||||
if (!this.initialized) {
|
||||
this._initialize();
|
||||
}
|
||||
this.row.show();
|
||||
if (this.expanded()) {
|
||||
this._showChildren();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.toggle = function() {
|
||||
if (this.expanded()) {
|
||||
this.collapse();
|
||||
} else {
|
||||
this.expand();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype._hideChildren = function() {
|
||||
var child, _i, _len, _ref, _results;
|
||||
_ref = this.children;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
child = _ref[_i];
|
||||
_results.push(child.hide());
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
Node.prototype._initialize = function() {
|
||||
var settings = this.settings;
|
||||
|
||||
this.render();
|
||||
|
||||
if (settings.expandable === true && settings.initialState === "collapsed") {
|
||||
this.collapse();
|
||||
} else {
|
||||
this.expand();
|
||||
}
|
||||
|
||||
if (settings.onNodeInitialized != null) {
|
||||
settings.onNodeInitialized.apply(this);
|
||||
}
|
||||
|
||||
return this.initialized = true;
|
||||
};
|
||||
|
||||
Node.prototype._showChildren = function() {
|
||||
var child, _i, _len, _ref, _results;
|
||||
_ref = this.children;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
child = _ref[_i];
|
||||
_results.push(child.show());
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
return Node;
|
||||
})();
|
||||
|
||||
Tree = (function() {
|
||||
function Tree(table, settings) {
|
||||
this.table = table;
|
||||
this.settings = settings;
|
||||
this.tree = {};
|
||||
|
||||
// Cache the nodes and roots in simple arrays for quick access/iteration
|
||||
this.nodes = [];
|
||||
this.roots = [];
|
||||
}
|
||||
|
||||
Tree.prototype.collapseAll = function() {
|
||||
var node, _i, _len, _ref, _results;
|
||||
_ref = this.nodes;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
node = _ref[_i];
|
||||
_results.push(node.collapse());
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
Tree.prototype.expandAll = function() {
|
||||
var node, _i, _len, _ref, _results;
|
||||
_ref = this.nodes;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
node = _ref[_i];
|
||||
_results.push(node.expand());
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
Tree.prototype.findLastNode = function (node) {
|
||||
if (node.children.length > 0) {
|
||||
return this.findLastNode(node.children[node.children.length - 1]);
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
};
|
||||
|
||||
Tree.prototype.loadRows = function(rows) {
|
||||
var node, row, i;
|
||||
|
||||
if (rows != null) {
|
||||
for (i = 0; i < rows.length; i++) {
|
||||
row = $(rows[i]);
|
||||
|
||||
if (row.data(this.settings.nodeIdAttr) != null) {
|
||||
node = new Node(row, this.tree, this.settings);
|
||||
this.nodes.push(node);
|
||||
this.tree[node.id] = node;
|
||||
|
||||
if (node.parentId != null) {
|
||||
this.tree[node.parentId].addChild(node);
|
||||
} else {
|
||||
this.roots.push(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < this.nodes.length; i++) {
|
||||
node = this.nodes[i].updateBranchLeafClass();
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Tree.prototype.move = function(node, destination) {
|
||||
// Conditions:
|
||||
// 1: +node+ should not be inserted as a child of +node+ itself.
|
||||
// 2: +destination+ should not be the same as +node+'s current parent (this
|
||||
// prevents +node+ from being moved to the same location where it already
|
||||
// is).
|
||||
// 3: +node+ should not be inserted in a location in a branch if this would
|
||||
// result in +node+ being an ancestor of itself.
|
||||
var nodeParent = node.parentNode();
|
||||
if (node !== destination && destination.id !== node.parentId && $.inArray(node, destination.ancestors()) === -1) {
|
||||
node.setParent(destination);
|
||||
this._moveRows(node, destination);
|
||||
|
||||
// Re-render parentNode if this is its first child node, and therefore
|
||||
// doesn't have the expander yet.
|
||||
if (node.parentNode().children.length === 1) {
|
||||
node.parentNode().render();
|
||||
}
|
||||
}
|
||||
|
||||
if(nodeParent){
|
||||
nodeParent.updateBranchLeafClass();
|
||||
}
|
||||
if(node.parentNode()){
|
||||
node.parentNode().updateBranchLeafClass();
|
||||
}
|
||||
node.updateBranchLeafClass();
|
||||
return this;
|
||||
};
|
||||
|
||||
Tree.prototype.move_node = function (node, destination, position) {
|
||||
// Conditions:
|
||||
// 1: +node+ should not be inserted as a child of +node+ itself.
|
||||
// 2: +destination+ should not be the same as +node+'s current parent (this
|
||||
// prevents +node+ from being moved to the same location where it already
|
||||
// is).
|
||||
// 3: +node+ should not be inserted in a location in a branch if this would
|
||||
// result in +node+ being an ancestor of itself.
|
||||
var nodeParent = node.parentNode();
|
||||
if (node !== destination && destination.id !== node.parentId && $.inArray(node, destination.ancestors()) === -1) {
|
||||
node.setParent(destination);
|
||||
this._moveRows(node, position);
|
||||
|
||||
// Re-render parentNode if this is its first child node, and therefore
|
||||
// doesn't have the expander yet.
|
||||
if (node.parentNode().children.length === 1) {
|
||||
node.parentNode().render();
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeParent) {
|
||||
nodeParent.updateBranchLeafClass();
|
||||
}
|
||||
if (node.parentNode()) {
|
||||
node.parentNode().updateBranchLeafClass();
|
||||
}
|
||||
node.updateBranchLeafClass();
|
||||
return this;
|
||||
};
|
||||
|
||||
Tree.prototype.removeNode = function(node) {
|
||||
// Recursively remove all descendants of +node+
|
||||
this.unloadBranch(node);
|
||||
|
||||
// Remove node from DOM (<tr>)
|
||||
node.row.remove();
|
||||
|
||||
// Clean up Tree object (so Node objects are GC-ed)
|
||||
delete this.tree[node.id];
|
||||
this.nodes.splice($.inArray(node, this.nodes), 1);
|
||||
}
|
||||
|
||||
Tree.prototype.render = function() {
|
||||
var root, _i, _len, _ref;
|
||||
_ref = this.roots;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
root = _ref[_i];
|
||||
|
||||
// Naming is confusing (show/render). I do not call render on node from
|
||||
// here.
|
||||
root.show();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Tree.prototype.sortBranch = function(node, sortFun) {
|
||||
// First sort internal array of children
|
||||
node.children.sort(sortFun);
|
||||
|
||||
// Next render rows in correct order on page
|
||||
this._sortChildRows(node);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Tree.prototype.unloadBranch = function(node) {
|
||||
var children, i;
|
||||
|
||||
for (i = 0; i < node.children.length; i++) {
|
||||
this.removeNode(node.children[i]);
|
||||
}
|
||||
|
||||
// Reset node's collection of children
|
||||
node.children = [];
|
||||
|
||||
node.updateBranchLeafClass();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Tree.prototype._moveRows = function(node, destination) {
|
||||
var children = node.children, i;
|
||||
|
||||
node.row.insertAfter(destination.row);
|
||||
node.render();
|
||||
|
||||
// Loop backwards through children to have them end up on UI in correct
|
||||
// order (see #112)
|
||||
for (i = children.length - 1; i >= 0; i--) {
|
||||
this._moveRows(children[i], node);
|
||||
}
|
||||
};
|
||||
|
||||
// Special _moveRows case, move children to itself to force sorting
|
||||
Tree.prototype._sortChildRows = function(parentNode) {
|
||||
return this._moveRows(parentNode, parentNode);
|
||||
};
|
||||
|
||||
return Tree;
|
||||
})();
|
||||
|
||||
// jQuery Plugin
|
||||
methods = {
|
||||
init: function(options, force) {
|
||||
var settings;
|
||||
|
||||
settings = $.extend({
|
||||
branchAttr: "ttBranch",
|
||||
clickableNodeNames: false,
|
||||
column: 0,
|
||||
columnElType: "td", // i.e. 'td', 'th' or 'td,th'
|
||||
expandable: false,
|
||||
expanderTemplate: "<a href='#'> </a>",
|
||||
indent: 19,
|
||||
indenterTemplate: "<span class='indenter'></span>",
|
||||
initialState: "collapsed",
|
||||
nodeIdAttr: "ttId", // maps to data-tt-id
|
||||
parentIdAttr: "ttParentId", // maps to data-tt-parent-id
|
||||
stringExpand: "Expand",
|
||||
stringCollapse: "Collapse",
|
||||
|
||||
// Events
|
||||
onInitialized: null,
|
||||
onNodeCollapse: null,
|
||||
onNodeExpand: null,
|
||||
onNodeInitialized: null
|
||||
}, options);
|
||||
|
||||
return this.each(function() {
|
||||
var el = $(this), tree;
|
||||
|
||||
if (force || el.data("treetable") === undefined) {
|
||||
tree = new Tree(this, settings);
|
||||
tree.loadRows(this.rows).render();
|
||||
|
||||
el.addClass("treetable").data("treetable", tree);
|
||||
|
||||
if (settings.onInitialized != null) {
|
||||
settings.onInitialized.apply(tree);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
});
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
return this.each(function() {
|
||||
return $(this).removeData("treetable").removeClass("treetable");
|
||||
});
|
||||
},
|
||||
|
||||
collapseAll: function() {
|
||||
this.data("treetable").collapseAll();
|
||||
return this;
|
||||
},
|
||||
|
||||
collapseNode: function(id) {
|
||||
var node = this.data("treetable").tree[id];
|
||||
|
||||
if (node) {
|
||||
node.collapse();
|
||||
} else {
|
||||
throw new Error("Unknown node '" + id + "'");
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
expandAll: function() {
|
||||
this.data("treetable").expandAll();
|
||||
return this;
|
||||
},
|
||||
|
||||
expandNode: function(id) {
|
||||
var node = this.data("treetable").tree[id];
|
||||
|
||||
if (node) {
|
||||
if (!node.initialized) {
|
||||
node._initialize();
|
||||
}
|
||||
|
||||
node.expand();
|
||||
} else {
|
||||
throw new Error("Unknown node '" + id + "'");
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
loadBranch: function(node, rows) {
|
||||
var settings = this.data("treetable").settings,
|
||||
tree = this.data("treetable").tree;
|
||||
|
||||
// TODO Switch to $.parseHTML
|
||||
rows = $(rows);
|
||||
|
||||
if (node == null) { // Inserting new root nodes
|
||||
this.append(rows);
|
||||
} else {
|
||||
var lastNode = this.data("treetable").findLastNode(node);
|
||||
rows.insertAfter(lastNode.row);
|
||||
}
|
||||
|
||||
this.data("treetable").loadRows(rows);
|
||||
|
||||
// Make sure nodes are properly initialized
|
||||
rows.filter("tr").each(function() {
|
||||
tree[$(this).data(settings.nodeIdAttr)].show();
|
||||
});
|
||||
|
||||
if (node != null) {
|
||||
// Re-render parent to ensure expander icon is shown (#79)
|
||||
node.render().expand();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
move: function(nodeId, destinationId) {
|
||||
var destination, node;
|
||||
|
||||
node = this.data("treetable").tree[nodeId];
|
||||
destination = this.data("treetable").tree[destinationId];
|
||||
this.data("treetable").move(node, destination);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
move_node: function (nodeId, destinationId, position) {
|
||||
var destination, node;
|
||||
|
||||
node = this.data("treetable").tree[nodeId];
|
||||
destination = this.data("treetable").tree[destinationId];
|
||||
this.data("treetable").move_node(node, destination, position);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
node: function(id) {
|
||||
return this.data("treetable").tree[id];
|
||||
},
|
||||
|
||||
removeNode: function(id) {
|
||||
var node = this.data("treetable").tree[id];
|
||||
|
||||
if (node) {
|
||||
this.data("treetable").removeNode(node);
|
||||
} else {
|
||||
throw new Error("Unknown node '" + id + "'");
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
reveal: function(id) {
|
||||
var node = this.data("treetable").tree[id];
|
||||
|
||||
if (node) {
|
||||
node.reveal();
|
||||
} else {
|
||||
throw new Error("Unknown node '" + id + "'");
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
sortBranch: function(node, columnOrFunction) {
|
||||
var settings = this.data("treetable").settings,
|
||||
prepValue,
|
||||
sortFun;
|
||||
|
||||
columnOrFunction = columnOrFunction || settings.column;
|
||||
sortFun = columnOrFunction;
|
||||
|
||||
if ($.isNumeric(columnOrFunction)) {
|
||||
sortFun = function(a, b) {
|
||||
var extractValue, valA, valB;
|
||||
|
||||
extractValue = function(node) {
|
||||
var val = node.row.find("td:eq(" + columnOrFunction + ")").text();
|
||||
// Ignore trailing/leading whitespace and use uppercase values for
|
||||
// case insensitive ordering
|
||||
return $.trim(val).toUpperCase();
|
||||
}
|
||||
|
||||
valA = extractValue(a);
|
||||
valB = extractValue(b);
|
||||
|
||||
if (valA < valB) return -1;
|
||||
if (valA > valB) return 1;
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
this.data("treetable").sortBranch(node, sortFun);
|
||||
return this;
|
||||
},
|
||||
|
||||
unloadBranch: function(node) {
|
||||
this.data("treetable").unloadBranch(node);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.treetable = function(method) {
|
||||
if (methods[method]) {
|
||||
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
} else if (typeof method === 'object' || !method) {
|
||||
return methods.init.apply(this, arguments);
|
||||
} else {
|
||||
return $.error("Method " + method + " does not exist on jQuery.treetable");
|
||||
}
|
||||
};
|
||||
|
||||
// Expose classes to world
|
||||
this.TreeTable || (this.TreeTable = {});
|
||||
this.TreeTable.Node = Node;
|
||||
this.TreeTable.Tree = Tree;
|
||||
}).call(this);
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-library-applies-index-page').length > 0) {
|
||||
var $searchFrom = $('.library-applies-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if($link.data('value') === 'processed'){
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
@ -0,0 +1,13 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-major-informations-index-page').length > 0) {
|
||||
var box_contain = $(".major-informations-list-container");
|
||||
box_contain.on("click",".collapse-item",function () {
|
||||
var a_fa = $(this).find("i");
|
||||
if(a_fa.hasClass("fa-caret-right")){
|
||||
a_fa.removeClass("fa-caret-right").addClass("fa-caret-down");
|
||||
}else{
|
||||
a_fa.removeClass("fa-caret-down").addClass("fa-caret-right");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,22 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $modal = $('.modal.admin-message-modal');
|
||||
var $submitBtn = $modal.find('.submit-btn');
|
||||
if ($modal.length > 0) {
|
||||
$modal.on('hide.bs.modal', function(){
|
||||
$modal.find('.modal-body').html('');
|
||||
$submitBtn.unbind();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function showMessageModal(html, callback) {
|
||||
var $modal = $('.modal.admin-message-modal');
|
||||
var $submitBtn = $modal.find('.submit-btn');
|
||||
$submitBtn.unbind();
|
||||
if(callback !== undefined && typeof callback === 'function'){
|
||||
$submitBtn.on('click', callback);
|
||||
}
|
||||
|
||||
$modal.find('.modal-body').html(html);
|
||||
$modal.modal('show');
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-mirror-repositories-edit-page, body.admins-mirror-repositories-update-page').length > 0) {
|
||||
var $form = $('form.edit-mirror');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"mirror_repository[type_name]": {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$form.submit(function(e){
|
||||
if(!$form.valid()){ e.preventDefault(); }
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,4 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-mirror-repositories-index-page').length > 0) {
|
||||
}
|
||||
});
|
@ -0,0 +1,33 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-mirror-scripts-edit-page, body.admins-mirror-scripts-update-page, body.admins-mirror-scripts-new-page, body.admins-mirror-scripts-create-page').length > 0) {
|
||||
var $form = $('form.script-form');
|
||||
|
||||
// codemirror编辑器
|
||||
var scriptEditor = CodeMirror.fromTextArea(document.getElementById('mirror_script_script'), {
|
||||
lineNumbers: true,
|
||||
mode: 'shell',
|
||||
theme: "default",
|
||||
indentUnit: 4, //代码缩进为一个tab的距离
|
||||
matchBrackets: true,
|
||||
autoRefresh: true,
|
||||
smartIndent: true,//智能换行
|
||||
styleActiveLine: true,
|
||||
lint: true
|
||||
});
|
||||
scriptEditor.setSize('auto', '600px');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"mirror_script[script_type]": {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$form.submit(function(e){
|
||||
if(!$form.valid()){ e.preventDefault(); }
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,32 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-choose-mirror-modal', function(){
|
||||
var $modal = $('.modal.admin-choose-mirror-modal');
|
||||
var $form = $modal.find('form.admin-choose-mirror-form');
|
||||
|
||||
var validateForm = function(){
|
||||
var checkedValue = $form.find('input[name="mirror_number"]:checked').val();
|
||||
|
||||
if(checkedValue == undefined){
|
||||
$modal.find('.error').html('必须选择一种镜像保存!');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
if (validateForm()) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
}).done(function(){
|
||||
$modal.modal('hide');
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
@ -0,0 +1,34 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-department-modal', function(){
|
||||
var $modal = $('.modal.admin-edit-department-modal');
|
||||
var $form = $modal.find('form.admin-edit-department-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
'department[name]': {
|
||||
required: true,
|
||||
maxlength: 20
|
||||
},
|
||||
'department[host_count]': {
|
||||
digits: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
if ($form.valid()) {
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize()
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
@ -0,0 +1,42 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-discipline-modal', function () {
|
||||
var $modal = $('.modal.admin-edit-discipline-modal');
|
||||
var $form = $modal.find('form.admin-edit-discipline-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
'discipline[name]': {
|
||||
required: true,
|
||||
maxlength: 20
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', submit_edit_form);
|
||||
|
||||
$form.find("#discipline_name").keydown(function (e) {
|
||||
var ev = e || event;
|
||||
var keycode = ev.which || ev.keyCode;
|
||||
if (keycode == 13) {
|
||||
submit_edit_form();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
function submit_edit_form() {
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
if ($form.valid()) {
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,31 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-repertoire-modal', function(){
|
||||
var $modal = $('.modal.admin-edit-repertoire-modal');
|
||||
var $form = $modal.find('form.admin-edit-repertoire-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
'repertoire[name]': {
|
||||
required: true,
|
||||
maxlength: 20
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
if ($form.valid()) {
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize()
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,43 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-sub-discipline-modal', function () {
|
||||
var $modal = $('.modal.admin-edit-sub-discipline-modal');
|
||||
var $form = $modal.find('form.admin-edit-sub-discipline-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
'sub_discipline[name]': {
|
||||
required: true,
|
||||
maxlength: 20
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', submit_edit_form);
|
||||
|
||||
$form.find("#sub_discipline_name").keydown(function (e) {
|
||||
var ev = e || event;
|
||||
var keycode = ev.which || ev.keyCode;
|
||||
if (keycode == 13) {
|
||||
submit_edit_form();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
function submit_edit_form() {
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
if ($form.valid()) {
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
@ -0,0 +1,31 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-sub-repertoire-modal', function(){
|
||||
var $modal = $('.modal.admin-edit-sub-repertoire-modal');
|
||||
var $form = $modal.find('form.admin-edit-sub-repertoire-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
'sub_repertoire[name]': {
|
||||
required: true,
|
||||
maxlength: 20
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
if ($form.valid()) {
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize()
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-subject-modal', function () {
|
||||
var $modal = $('.modal.admin-edit-subject-modal');
|
||||
var $form = $modal.find('form.admin-edit-subject-form');
|
||||
|
||||
$modal.on('click', '.submit-btn', function () {
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize()
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
@ -0,0 +1,42 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-tag-discipline-modal', function () {
|
||||
var $modal = $('.modal.admin-edit-tag-discipline-modal');
|
||||
var $form = $modal.find('form.admin-edit-tag-discipline-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
'tag_discipline[name]': {
|
||||
required: true,
|
||||
maxlength: 20
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', submit_edit_form);
|
||||
|
||||
$form.find("#tag_discipline_name").keydown(function (e) {
|
||||
var ev = e || event;
|
||||
var keycode = ev.which || ev.keyCode;
|
||||
if (keycode == 13) {
|
||||
submit_edit_form();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
function submit_edit_form() {
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
if ($form.valid()) {
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,31 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-tag-repertoire-modal', function(){
|
||||
var $modal = $('.modal.admin-edit-tag-repertoire-modal');
|
||||
var $form = $modal.find('form.admin-edit-tag-repertoire-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
'tag_repertoire[name]': {
|
||||
required: true,
|
||||
maxlength: 20
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
if ($form.valid()) {
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize()
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,78 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $modal = $('.modal.admin-import-course-member-modal');
|
||||
if ($modal.length > 0) {
|
||||
var $form = $modal.find('form.admin-import-course-member-form');
|
||||
|
||||
var resetFileInputFunc = function(file){
|
||||
file.after(file.clone().val(""));
|
||||
file.remove();
|
||||
}
|
||||
|
||||
$modal.on('show.bs.modal', function(){
|
||||
$modal.find('.file-names').html('选择文件');
|
||||
$modal.find('.upload-file-input').trigger('click');
|
||||
});
|
||||
$modal.on('hide.bs.modal', function(){
|
||||
resetFileInputFunc($modal.find('.upload-file-input'));
|
||||
});
|
||||
$modal.on('change', '.upload-file-input', function(e){
|
||||
var file = $(this)[0].files[0];
|
||||
$modal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
})
|
||||
|
||||
var importFormValid = function(){
|
||||
if($form.find('input[name="file"]').val() == undefined || $form.find('input[name="file"]').val().length == 0){
|
||||
$form.find('.error').html('请选择文件');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var buildResultMessage = function(data){
|
||||
var messageHtml = "<div>导入结果:成功" + data.success + "条,失败"+ data.fail.length + "条</div>";
|
||||
|
||||
if(data.fail.length > 0){
|
||||
messageHtml += '<table class="table"><thead class="thead-light"><tr><th>数据</th><th>失败原因</th></tr></thead><tbody>';
|
||||
|
||||
data.fail.forEach(function(item){
|
||||
messageHtml += '<tr><td>' + item.data + '</td><td>' + item.message + '</td></tr>';
|
||||
});
|
||||
|
||||
messageHtml += '</tbody></table>'
|
||||
}
|
||||
|
||||
return messageHtml;
|
||||
}
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if (importFormValid()) {
|
||||
$('body').mLoading({ text: '正在导入...' });
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/import_course_members',
|
||||
data: new FormData($form[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data){
|
||||
$('body').mLoading('destroy');
|
||||
$modal.modal('hide');
|
||||
|
||||
showMessageModal(buildResultMessage(data), function(){
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
error: function(res){
|
||||
$('body').mLoading('destroy');
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,60 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $modal = $('.modal.admin-merge-course-list-modal');
|
||||
if ($modal.length > 0) {
|
||||
var $form = $modal.find('form.admin-merge-course-list-form');
|
||||
var $originCourseListIdInput = $form.find('input[name="origin_course_list_id"]');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
course_list_name: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
course_list_name: {
|
||||
required: '请输入课程名称'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function (event) {
|
||||
var $link = $(event.relatedTarget);
|
||||
|
||||
var couresListId = $link.data('courseListId');
|
||||
var url = $link.data('url');
|
||||
|
||||
$originCourseListIdInput.val(couresListId);
|
||||
$form.data('url', url);
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '操作成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,111 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $modal = $('.modal.admin-merge-department-modal');
|
||||
if ($modal.length > 0) {
|
||||
var $form = $modal.find('form.admin-merge-department-form');
|
||||
var $schoolIdInput = $form.find('input[name="school_id"]');
|
||||
var $originDepartmentIdInput = $form.find('input[name="origin_department_id"]');
|
||||
var $departmentSelect = $modal.find('.department-select');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
department_id: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
department_id: {
|
||||
required: '请选择部门'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ************** 学校选择 *************
|
||||
var matcherFunc = function(params, data){
|
||||
if ($.trim(params.term) === '') {
|
||||
return data;
|
||||
}
|
||||
if (typeof data.text === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.name && data.name.indexOf(params.term) > -1) {
|
||||
var modifiedData = $.extend({}, data, true);
|
||||
return modifiedData;
|
||||
}
|
||||
|
||||
// Return `null` if the term should not be displayed
|
||||
return null;
|
||||
};
|
||||
|
||||
var defineDepartmentSelect = function(departments) {
|
||||
$departmentSelect.empty();
|
||||
|
||||
$departmentSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请选择所属部门',
|
||||
data: departments,
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
$form.find('#department_id').val(item.id);
|
||||
}
|
||||
return item.name || item.text;
|
||||
},
|
||||
matcher: matcherFunc
|
||||
});
|
||||
$departmentSelect.select2('val', ' ');
|
||||
};
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function (event) {
|
||||
var $link = $(event.relatedTarget);
|
||||
|
||||
var schoolId = $link.data('schoolId');
|
||||
var url = $link.data('url');
|
||||
|
||||
$schoolIdInput.val(schoolId);
|
||||
$originDepartmentIdInput.val($link.data('departmentId'));
|
||||
$form.data('url', url);
|
||||
$.ajax({
|
||||
url: '/api/schools/' + schoolId + '/departments/for_option.json',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
defineDepartmentSelect(data.departments);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '操作成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,89 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $modal = $('.modal.admin-replace-mirror-modal');
|
||||
if ($modal.length > 0) {
|
||||
var $form = $modal.find('form.admin-replace-mirror-form');
|
||||
var $mirrorIdInput = $modal.find('.modal-body input[name="mirror_id"]');
|
||||
var $mirrorSelect = $modal.find('.new-mirror-select');
|
||||
|
||||
var setMirror = function(id, name){
|
||||
$mirrorIdInput.val(id);
|
||||
$form.find('.mirror-id-container').html(id);
|
||||
$form.find('.mirror-name-container').html(name);
|
||||
}
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
new_mirror_id: {
|
||||
required: true
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
new_mirror_id: {
|
||||
required: '请选择新镜像'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function (event) {
|
||||
var $link = $(event.relatedTarget);
|
||||
|
||||
var mirrorId = $link.data('id');
|
||||
var mirrorName = $link.data('name');
|
||||
|
||||
setMirror(mirrorId, mirrorName);
|
||||
$mirrorSelect.select2('val', ' ');
|
||||
});
|
||||
$modal.on('hide.bs.modal', function () {
|
||||
setMirror('', '');
|
||||
$mirrorSelect.select2('val', ' ');
|
||||
$('#new_mirror_id-error').remove();
|
||||
});
|
||||
|
||||
$mirrorSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '输入要合并的镜像名',
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
url: '/admins/mirror_repositories/for_select',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { keyword: params.term };
|
||||
},
|
||||
processResults: function(data){
|
||||
return { results: data.mirrors }
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
$('#new_mirror_id-error').remove();
|
||||
$('#new_mirror_id').val(item.id);
|
||||
}
|
||||
return item.name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
}).done(function(){
|
||||
$modal.modal('hide');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,46 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.admin-save-competition-prize-modal', function(event){
|
||||
var $modal = $('.modal.admin-save-competition-prize-modal');
|
||||
var $form = $modal.find('form.admin-save-competition-prize-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
'competition_prize[name]': {
|
||||
required: true,
|
||||
maxlength: 10
|
||||
},
|
||||
'competition_prize[num]': {
|
||||
required: true,
|
||||
digits: true,
|
||||
min: 1
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
var formMethod = $form.data('form-method')
|
||||
|
||||
if ($form.valid()) {
|
||||
$.ajax({
|
||||
method: formMethod,
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(data){
|
||||
if(data && data.status === 0) {
|
||||
show_success_flash();
|
||||
$(document).trigger('prize.save.success');
|
||||
$modal.modal('hide');
|
||||
} else {
|
||||
$modal.find('.error').html(data.message)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
@ -0,0 +1,90 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $modal = $('.modal.admin-select-school-modal');
|
||||
if ($modal.length > 0) {
|
||||
var $link = null;
|
||||
var $form = $modal.find('form.admin-select-school-form');
|
||||
var multiple = $form.data('multiple');
|
||||
|
||||
$form.find('.school-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请选择',
|
||||
multiple: multiple,
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/api/schools/search.json',
|
||||
dataType: 'json',
|
||||
data: function (params) {
|
||||
return {keyword: params.term};
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {results: data.schools}
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if (!item.id || item.id === '') return item.text;
|
||||
var html = "<span>" + item.name + "<span class='ml-4 font-12'>";
|
||||
if(item.province){ html += item.province }
|
||||
html += "</span></span>";
|
||||
return $(html);
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
if (item.id) {
|
||||
}
|
||||
return item.name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
school_ids: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
school_ids: {
|
||||
required: '请选择'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('show.bs.modal', function(event){
|
||||
$link = $(event.relatedTarget);
|
||||
});
|
||||
|
||||
$modal.on('hide.bs.modal', function(){
|
||||
$form.find('.error').html('');
|
||||
$form.find('.school-select').select2('val', ' ');
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if($form.valid()){
|
||||
var url = $form.data('url');
|
||||
var schoolIds = $form.find('#school_ids').val();
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: { school_ids: schoolIds },
|
||||
success: function(){
|
||||
$.notify({ message: '操作成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,66 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $modal = $('.modal.admin-upload-file-modal');
|
||||
if ($modal.length > 0) {
|
||||
var $form = $modal.find('form.admin-upload-file-form')
|
||||
var $sourceIdInput = $modal.find('input[name="source_id"]');
|
||||
var $sourceTypeInput = $modal.find('input[name="source_type"]');
|
||||
var $suffixInput = $modal.find('input[name="suffix"]');
|
||||
|
||||
$modal.on('show.bs.modal', function(event){
|
||||
var $link = $(event.relatedTarget);
|
||||
var sourceId = $link.data('sourceId');
|
||||
var sourceType = $link.data('sourceType');
|
||||
var suffix = $link.data('suffix');
|
||||
|
||||
$sourceIdInput.val(sourceId);
|
||||
$sourceTypeInput.val(sourceType);
|
||||
if(suffix != undefined){ $suffixInput.val(suffix); }
|
||||
|
||||
$modal.find('.upload-file-input').trigger('click');
|
||||
});
|
||||
|
||||
$modal.find('.upload-file-input').on('change', function(e){
|
||||
var file = $(this)[0].files[0];
|
||||
|
||||
if(file){
|
||||
$modal.find('.file-names').html(file.name);
|
||||
$modal.find('.submit-btn').trigger('click');
|
||||
}
|
||||
})
|
||||
|
||||
var formValid = function(){
|
||||
if($form.find('input[name="file"]').val() == undefined || $form.find('input[name="file"]').val().length == 0){
|
||||
$form.find('.error').html('请选择文件');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if (formValid()) {
|
||||
var formDataString = $form.serialize();
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/files?' + formDataString,
|
||||
data: new FormData($form[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data){
|
||||
$.notify({ message: '上传成功' });
|
||||
$modal.find('.file-names').html('');
|
||||
$modal.trigger('upload:success', data);
|
||||
$modal.modal('hide');
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,68 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-multiple-school-reports-index-page').length > 0) {
|
||||
var baseOptions = {
|
||||
autoclose: true,
|
||||
language: 'zh-CN',
|
||||
format: 'yyyy-mm-dd',
|
||||
startDate: '2017-04-01',
|
||||
endDate: '-1d'
|
||||
}
|
||||
|
||||
var defineDateRangeSelect = function (element) {
|
||||
$(element).datepicker(baseOptions);
|
||||
};
|
||||
|
||||
defineDateRangeSelect("#begin_at");
|
||||
defineDateRangeSelect("#end_at");
|
||||
|
||||
$('.export-action').on('click', function () {
|
||||
var form = $(".multiple-school-report-list-form .search-form")
|
||||
var exportLink = $(this);
|
||||
var school = form.find("[name='school']").val();
|
||||
var begin_at = form.find("input[name='begin_at']").val();
|
||||
var end_at = form.find("input[name='end_at']").val();
|
||||
var search_type = form.find("[name='search_type']").val();
|
||||
|
||||
var url = exportLink.data("url").split('?')[0] + "?school=" + school + "&begin_at=" + begin_at + "&end_at=" + end_at + "&search_type=" + search_type;
|
||||
window.open(url);
|
||||
});
|
||||
|
||||
|
||||
$("#school").select2({
|
||||
placeholder: '请选择学校',
|
||||
allowClear: true,
|
||||
ajax: {
|
||||
url: "/admins/multiple_school_reports/school",
|
||||
dataType: 'json',
|
||||
delay: 500,
|
||||
data: function (params) {
|
||||
return {
|
||||
q: params.term, // search term
|
||||
page: params.page
|
||||
};
|
||||
},
|
||||
processResults: function (data, params) {
|
||||
params.page = params.page || 1;
|
||||
|
||||
return {
|
||||
results: data.items,
|
||||
pagination: {
|
||||
more: (params.page * 10) < data.total_count
|
||||
}
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
escapeMarkup: function (markup) {
|
||||
return markup;
|
||||
},
|
||||
minimumInputLength: 1,
|
||||
templateResult: formatRepoProvince,
|
||||
templateSelection: formatRepoProvince
|
||||
});
|
||||
|
||||
function formatRepoProvince(repo) {
|
||||
return repo.name || repo.text;
|
||||
}
|
||||
}
|
||||
})
|
@ -0,0 +1,50 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-professional-authentications-index-page').length > 0) {
|
||||
var $searchFrom = $('.professional-authentication-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if($link.data('value') === 'processed'){
|
||||
$('.batch-action-container').hide();
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$('.batch-action-container').show();
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
|
||||
$('.batch-agree-btn').on('click', function(){
|
||||
if($('.batch-check-box:checked').length === 0){
|
||||
$.notify({ message: '请先选择数据' }, { type: 'info' });
|
||||
return;
|
||||
}
|
||||
|
||||
customConfirm({
|
||||
content: '确认审核通过?',
|
||||
ok: function(){
|
||||
var ids = $('.batch-check-box:checked').map(function(_, e){ return $(e).val() }).get();
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/professional_authentications/batch_agree',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: { ids: ids },
|
||||
success: function(data){
|
||||
$.notify({ message: '操作成功' });
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(res){
|
||||
$.notify({ message: res.responseJSON.message }, { type: 'danger' });
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
@ -0,0 +1,20 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-project-package-applies-index-page').length > 0) {
|
||||
var $searchFrom = $('.project-package-applies-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('all');
|
||||
|
||||
if($link.data('value') === 'all'){
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
@ -0,0 +1,11 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-projects-index-page').length > 0) {
|
||||
var $form = $('.search-form');
|
||||
|
||||
// 清空
|
||||
$form.on('click', '.clear-btn', function () {
|
||||
$form.find('input[name="search"]').val('');
|
||||
$form.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,65 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-repertoires-index-page').length > 0) {
|
||||
|
||||
// ============== 新建 ===============
|
||||
var $modal = $('.modal.admin-create-repertoire-modal');
|
||||
var $form = $modal.find('form.admin-create-repertoire-form');
|
||||
var $nameInput = $form.find('input[name="name"]');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function () {
|
||||
$nameInput.val('');
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".repertoire-list-container").on("change", '.repertoire-source-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/repertoires/" + s_id,
|
||||
type: "PUT",
|
||||
dataType:'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,119 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-salesman-channels-index-page').length > 0) {
|
||||
|
||||
// ============= 添加销售人员 ==============
|
||||
var $addMemberModal = $('.admin-add-salesman-channel-user-modal');
|
||||
var $addMemberForm = $addMemberModal.find('.admin-add-salesman-channel-user-form');
|
||||
var $memberSelect = $addMemberModal.find('.salesman-channel-user-select');
|
||||
var $form = $addMemberModal.find('form.admin-add-salesman-user-form');
|
||||
|
||||
// 搜索
|
||||
var searchscForm = $(".saleman-channel-list-form .search-form");
|
||||
|
||||
|
||||
$addMemberModal.on('show.bs.modal', function(event){
|
||||
$memberSelect.select2('val', ' ');
|
||||
});
|
||||
|
||||
$memberSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请输入要添加的单位',
|
||||
multiple: true,
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/admins/schools',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { keyword: params.term };
|
||||
},
|
||||
processResults: function(data){
|
||||
return { results: data.schools }
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return '';
|
||||
return $("<span>" + item.name + "</span>");
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
}
|
||||
return item.name || '';
|
||||
}
|
||||
});
|
||||
|
||||
$addMemberModal.on('click', '.submit-btn', function(){
|
||||
$addMemberForm.find('.error').html('');
|
||||
|
||||
// var salesmanId = $salesmanIdInput.val();
|
||||
var memberIds = $memberSelect.val();
|
||||
if (memberIds && memberIds.length > 0) {
|
||||
var url = $form.data('url');
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$addMemberModal.modal('hide');
|
||||
searchscForm.find('input[name="keyword"]').val('');
|
||||
|
||||
setTimeout(function(){
|
||||
submitForm();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$addMemberForm.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$addMemberModal.modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 清空
|
||||
searchscForm.on('click', '.clear-btn', function () {
|
||||
searchscForm.find('.start_date').val('');
|
||||
searchscForm.find('.end_date').val('').trigger('change');
|
||||
searchscForm.find('input[name="keyword"]').val('');
|
||||
});
|
||||
|
||||
// 时间跨度
|
||||
var baseOptions = {
|
||||
autoclose: true,
|
||||
language: 'zh-CN',
|
||||
format: 'yyyy-mm-dd',
|
||||
startDate: '2017-04-01'
|
||||
};
|
||||
|
||||
var defineDateRangeSelect = function(element){
|
||||
var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, baseOptions);
|
||||
$(element).datepicker(options);
|
||||
|
||||
$(element).find('.start-date').datepicker().on('changeDate', function(e){
|
||||
$(element).find('.end-date').datepicker('setStartDate', e.date);
|
||||
});
|
||||
};
|
||||
|
||||
defineDateRangeSelect('.grow-date-input-daterange');
|
||||
|
||||
|
||||
// 区间搜索
|
||||
searchscForm.on('click', ".search-btn", function(){
|
||||
submitForm();
|
||||
});
|
||||
|
||||
var submitForm = function(){
|
||||
var url = searchscForm.data('search-form-url');
|
||||
var form = searchscForm;
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: form.serialize(),
|
||||
dataType: "script"
|
||||
})
|
||||
};
|
||||
}
|
||||
});
|
@ -0,0 +1,82 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-salesman-customers-index-page').length > 0) {
|
||||
|
||||
// ============= 添加销售人员 ==============
|
||||
var $addMemberModal = $('.admin-add-salesman-customer-user-modal');
|
||||
var $addMemberForm = $addMemberModal.find('.admin-add-salesman-customer-user-form');
|
||||
var $memberSelect = $addMemberModal.find('.salesman-customer-user-select');
|
||||
var $salesmanIdInput = $('.salesman-customer-list-form').find(".btn-primary");
|
||||
|
||||
$addMemberModal.on('show.bs.modal', function(event){
|
||||
var $link = $(event.relatedTarget);
|
||||
// var salesmanId = $link.data('salesman_id');
|
||||
// $salesmanIdInput.val(salesmanId);
|
||||
|
||||
$memberSelect.select2('val', ' ');
|
||||
});
|
||||
|
||||
$memberSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请输入要添加的销售姓名',
|
||||
multiple: true,
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/admins/users',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { name: params.term };
|
||||
},
|
||||
processResults: function(data){
|
||||
return { results: data.users }
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return $("<span>" + item.real_name + " <span class='font-12'>" + item.school_name + ' ' + item.hidden_phone + "</span></span>");
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
}
|
||||
return item.real_name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
$addMemberModal.on('click', '.submit-btn', function(){
|
||||
$addMemberForm.find('.error').html('');
|
||||
|
||||
// var salesmanId = $salesmanIdInput.val();
|
||||
var memberIds = $memberSelect.val();
|
||||
if (memberIds && memberIds.length > 0) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/salesman_customers/batch_add',
|
||||
data: { salesman_id: $salesmanIdInput.data("salesman-id"), user_ids: memberIds },
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$addMemberModal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
listForm();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$addMemberModal.modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var listForm = function(){
|
||||
$.ajax({
|
||||
url: '/admins/salesman_customers?salesman_id='+ $salesmanIdInput.data("salesman-id"),
|
||||
dataType: "script"
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
@ -0,0 +1,99 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-salesmans-index-page').length > 0) {
|
||||
|
||||
// ============= 添加销售人员 ==============
|
||||
var $addMemberModal = $('.admin-add-salesman-user-modal');
|
||||
var $addMemberForm = $addMemberModal.find('.admin-add-salesman-user-form');
|
||||
var $memberSelect = $addMemberModal.find('.salesman-user-select');
|
||||
// var $salesmanIdInput = $addMemberForm.find('input[name="salesman_id"]')
|
||||
|
||||
$addMemberModal.on('show.bs.modal', function(event){
|
||||
var $link = $(event.relatedTarget);
|
||||
// var salesmanId = $link.data('salesman-id');
|
||||
// $salesmanIdInput.val(salesmanId);
|
||||
|
||||
$memberSelect.select2('val', ' ');
|
||||
});
|
||||
|
||||
$memberSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请输入要添加的销售姓名',
|
||||
multiple: true,
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/admins/users',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { name: params.term };
|
||||
},
|
||||
processResults: function(data){
|
||||
return { results: data.users }
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return $("<span>" + item.real_name + " <span class='font-12'>" + item.school_name + ' ' + item.hidden_phone + "</span></span>");
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
}
|
||||
return item.real_name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
$addMemberModal.on('click', '.submit-btn', function(){
|
||||
$addMemberForm.find('.error').html('');
|
||||
|
||||
// var salesmanId = $salesmanIdInput.val();
|
||||
var memberIds = $memberSelect.val();
|
||||
if (memberIds && memberIds.length > 0) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/salesmans/batch_add',
|
||||
data: { user_ids: memberIds },
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$addMemberModal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$addMemberModal.modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
$(".salesman-list-container").on("change", '.salesman-sync-course', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var json = {};
|
||||
$.ajax({
|
||||
url: "/admins/salesmans/" + s_id + "/update_sync_course",
|
||||
type: "POST",
|
||||
dataType:'script',
|
||||
data: json
|
||||
})
|
||||
});
|
||||
|
||||
$(".salesman-list-container").on("change", '.salesman-sync-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/salesmans/" + s_id,
|
||||
type: "PUT",
|
||||
dataType:'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,135 @@
|
||||
$(document).on('turbolinks:load', function(){
|
||||
if ($('body.admins-school-statistics-index-page').length > 0) {
|
||||
var searchForm = $(".school-statistic-list-form .search-form");
|
||||
var growFormUrl = searchForm.data('grow-form-url');
|
||||
var contrastFormUrl = searchForm.data('contrast-form-url');
|
||||
|
||||
var dataTypeInput = searchForm.find("input[name='data_type']");
|
||||
var keywordInput = searchForm.find("input[name='keyword']");
|
||||
var contrastBtn = searchForm.find(".contrast-btn");
|
||||
var growBtn = searchForm.find(".grow-btn");
|
||||
var contrastDateContainer = searchForm.find('.contrast-date-container');
|
||||
var growDateContainer = searchForm.find('.grow-date-container');
|
||||
|
||||
// 数据对比日期输入框
|
||||
var beginDateInput = searchForm.find("input[name='begin_date']");
|
||||
var endDateInput = searchForm.find("input[name='end_date']");
|
||||
var otherBeginDateInput = searchForm.find("input[name='other_begin_date']");
|
||||
var otherEndDateInput = searchForm.find("input[name='other_end_date']");
|
||||
|
||||
// 新增数据日期输入框
|
||||
var growBeginDateInput = searchForm.find("input[name='grow_begin_date']");
|
||||
var growEndDateInput = searchForm.find("input[name='grow_end_date']");
|
||||
|
||||
// 数据展示切换: 数据对比、新增数据
|
||||
searchForm.on('click', ".contrast-btn", function(){
|
||||
if(contrastBtn.hasClass("active")) { return }
|
||||
changeDataType("contrast");
|
||||
submitForm();
|
||||
});
|
||||
searchForm.on('click', ".grow-btn", function(){
|
||||
if(growBtn.hasClass("active")) { return }
|
||||
changeDataType("grow");
|
||||
submitForm();
|
||||
});
|
||||
|
||||
// 搜索按钮
|
||||
searchForm.on('click', ".search-btn", function(){
|
||||
console.log('submit');
|
||||
submitForm();
|
||||
});
|
||||
|
||||
$('.school-statistic-list-container').on('change', '.contrast-column-select', function() {
|
||||
searchForm.find("input[name='contrast_column']").val($('.contrast-column-select').val());
|
||||
submitForm();
|
||||
});
|
||||
|
||||
var submitForm = function(){
|
||||
if(!validateFrom()) { return }
|
||||
|
||||
var form = searchForm;
|
||||
var url = dataTypeInput.val() == "contrast" ? contrastFormUrl : growFormUrl;
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: form.serialize(),
|
||||
dataType: "script"
|
||||
})
|
||||
};
|
||||
|
||||
var validateFrom = function(){
|
||||
if (dataTypeInput.val() != "contrast") { return true; }
|
||||
|
||||
// 全部为空时,需要展示空数据页
|
||||
if (beginDateInput.val() == "" && endDateInput.val() == "" &&
|
||||
otherBeginDateInput.val() == "" && otherBeginDateInput.val() == "") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (beginDateInput.val() != "" && endDateInput.val() != "" &&
|
||||
otherBeginDateInput.val() != "" && otherBeginDateInput.val() != "") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
var changeDataType = function(dataType){
|
||||
if (dataTypeInput.val() == dataType) { return }
|
||||
|
||||
if (dataType == "contrast") {
|
||||
contrastBtn.addClass("active");
|
||||
growBtn.removeClass("active");
|
||||
dataTypeInput.val('contrast');
|
||||
growDateContainer.hide();
|
||||
contrastDateContainer.show();
|
||||
|
||||
clearGrowDateInput();
|
||||
} else {
|
||||
contrastBtn.removeClass("active");
|
||||
growBtn.addClass("active");
|
||||
dataTypeInput.val('grow');
|
||||
growDateContainer.show();
|
||||
contrastDateContainer.hide();
|
||||
|
||||
clearContrastDateInput();
|
||||
}
|
||||
};
|
||||
|
||||
var clearGrowDateInput = function() {
|
||||
searchForm.find("input[name='grow_begin_date']").val('');
|
||||
searchForm.find("input[name='grow_end_date']").val('');
|
||||
searchForm.find("input[name='grow_date_input']").val('');
|
||||
};
|
||||
|
||||
var clearContrastDateInput = function(){
|
||||
searchForm.find("input[name='begin_date']").val('');
|
||||
searchForm.find("input[name='end_date']").val('');
|
||||
searchForm.find("input[name='other_begin_date']").val('');
|
||||
searchForm.find("input[name='other_end_date']").val('');
|
||||
searchForm.find("input[name='date_input']").val('');
|
||||
searchForm.find("input[name='other_date_input']").val('');
|
||||
};
|
||||
|
||||
var baseOptions = {
|
||||
autoclose: true,
|
||||
language: 'zh-CN',
|
||||
format: 'yyyy-mm-dd',
|
||||
startDate: '2017-04-01',
|
||||
endDate: '-1d'
|
||||
}
|
||||
|
||||
var defineDateRangeSelect = function(element){
|
||||
var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, baseOptions);
|
||||
$(element).datepicker(options);
|
||||
|
||||
$(element).find('.start-date').datepicker().on('changeDate', function(e){
|
||||
$(element).find('.end-date').datepicker('setStartDate', e.date);
|
||||
})
|
||||
};
|
||||
|
||||
defineDateRangeSelect('.grow-date-input-daterange');
|
||||
defineDateRangeSelect('.date-input-daterange');
|
||||
defineDateRangeSelect('.other-date-input-daterange');
|
||||
}
|
||||
})
|
@ -0,0 +1,4 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-schools-index-page').length > 0) {
|
||||
}
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $tabs = $('.search-form-container .search-form-tabs');
|
||||
if ($tabs.length > 0) {
|
||||
$tabs.on('click', '.search-form-tab', function(){
|
||||
var $activeTab = $(this);
|
||||
$tabs.find('.search-form-tab').removeClass('active');
|
||||
$activeTab.addClass('active');
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-shixun-authorizations-index-page').length > 0) {
|
||||
var $searchFrom = $('.shixun-authorization-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if($link.data('value') === 'processed'){
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
@ -0,0 +1,24 @@
|
||||
$(document).on('turbolinks:load', function(){
|
||||
if ($('body.admins-shixun-feedback-messages-index-page').length > 0) {
|
||||
|
||||
$(".content-img img").addClass("w-20").addClass("preview-image");
|
||||
|
||||
var baseOptions = {
|
||||
autoclose: true,
|
||||
language: 'zh-CN',
|
||||
format: 'yyyy-mm-dd 00:00:00',
|
||||
startDate: '2017-04-01'
|
||||
};
|
||||
|
||||
var defineDateRangeSelect = function(element){
|
||||
var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, baseOptions);
|
||||
$(element).datepicker(options);
|
||||
|
||||
$(element).find('.start-date').datepicker().on('changeDate', function(e){
|
||||
$(element).find('.end-date').datepicker('setStartDate', e.date);
|
||||
});
|
||||
};
|
||||
|
||||
defineDateRangeSelect('.grow-date-input-daterange');
|
||||
}
|
||||
});
|
@ -0,0 +1,12 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-shixun-modify-records-index-page').length > 0) {
|
||||
var $form = $('.search-form');
|
||||
|
||||
// 清空
|
||||
$form.on('click', '.clear-btn', function () {
|
||||
$form.find('select[name="date"]').val('weekly');
|
||||
$form.find('input[name="user_name"]').val('');
|
||||
$form.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,70 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-shixun-settings-index-page').length > 0) {
|
||||
let searchContainer = $(".shixun-settings-list-form");
|
||||
let searchForm = $("form.search-form",searchContainer);
|
||||
|
||||
searchContainer.on('change', '.shixun-settings-select', function(){
|
||||
searchForm.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
|
||||
//导出
|
||||
searchContainer.on('click',"#shixun-settings-export",function () {
|
||||
window.location.href = "/admins/shixun_settings.xls?" + searchForm.serialize();
|
||||
});
|
||||
|
||||
// 基础数据导出
|
||||
searchContainer.on('click', "#shixun-settings-base-export", function () {
|
||||
window.location.href = "/admins/shixun_settings.xls?base_data=1" + searchForm.serialize();
|
||||
});
|
||||
|
||||
$(".shixun-settings-list-container").on("change", '.shixun-setting-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
var s_index = $(this).parent("td").siblings(".shixun-line-no").text();
|
||||
json[s_name] = s_value;
|
||||
json["page_no"] = s_index;
|
||||
$.ajax({
|
||||
url: "/admins/shixun_settings/" + s_id,
|
||||
type: "PUT",
|
||||
dataType:'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
|
||||
$(".shixun-settings-list-container").on("change", '.repertoire-setting-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/shixun_settings/" + s_id + "/update_tag_repertoires",
|
||||
type: "POST",
|
||||
dataType:'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
|
||||
$("select#settings-tag-choosed").select2({
|
||||
placeholder: "请选择分类",
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
if(data.suffix == '_weapp'){
|
||||
var $imageElement = $('.shixun-weapp-image-' + data.source_id);
|
||||
$imageElement.attr('src', data.url);
|
||||
$imageElement.show();
|
||||
$imageElement.next().html('重新上传');
|
||||
} else {
|
||||
var $imageElement = $('.shixun-image-' + data.source_id);
|
||||
$imageElement.attr('src', data.url);
|
||||
$imageElement.show();
|
||||
$imageElement.next().html('重新上传');
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,14 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if($('body.admins-shixuns-index-page').length > 0){
|
||||
$('select#tag-choosed').select2({
|
||||
placeholder: "请选择分类",
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
var search_form = $(".search-form");
|
||||
//导出
|
||||
$(".shixuns-list-form").on("click","#shixuns-export",function () {
|
||||
window.location.href = "/admins/shixuns.xls?" + search_form.serialize();
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,16 @@
|
||||
$(document).on('turbolinks:load', function(){
|
||||
$('#sidebarCollapse').on('click', function () {
|
||||
$(this).toggleClass('active');
|
||||
$('#sidebar').toggleClass('active');
|
||||
$.cookie('admin_sidebar_collapse', $(this).hasClass('active'), {path: '/admins'});
|
||||
});
|
||||
|
||||
var sidebarController = $('#sidebar').data('current-controller');
|
||||
if (sidebarController.length > 0) {
|
||||
$('#sidebar a.active').removeClass('active');
|
||||
$('#sidebar ul.collapse.show').removeClass('show');
|
||||
var activeLi = $('#sidebar a[data-controller="' + sidebarController + '"]');
|
||||
activeLi.addClass('active');
|
||||
activeLi.parent().parent('ul.collapse').addClass('show');
|
||||
}
|
||||
});
|
@ -0,0 +1,89 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-sub-disciplines-index-page').length > 0) {
|
||||
|
||||
// ============== 新建 ===============
|
||||
var $modal = $('.modal.admin-create-sub-discipline-modal');
|
||||
var $form = $modal.find('form.admin-create-sub-discipline-form');
|
||||
var $nameInput = $form.find('input[name="name"]');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function () {
|
||||
$nameInput.val('');
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', submit_create_form);
|
||||
|
||||
$nameInput.keydown(function (e) {
|
||||
var ev = e || event;
|
||||
var keycode = ev.which || ev.keyCode;
|
||||
if (keycode == 13) {
|
||||
submit_create_form();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
function submit_create_form() {
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function () {
|
||||
$.notify({message: '创建成功'});
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function () {
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function (res) {
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(".sub-discipline-list-container").on("change", '.sub-discipline-source-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/sub_disciplines/" + s_id,
|
||||
type: "PUT",
|
||||
dataType: 'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
// ------------ 上移/下移 -------------
|
||||
$('.sub-discipline-list-container').on('click', ".move-action", function () {
|
||||
var $doAction = $(this);
|
||||
|
||||
var objectId = $doAction.data('id');
|
||||
var opr = $doAction.data('opr');
|
||||
$.ajax({
|
||||
url: '/admins/sub_disciplines/' + objectId + '/adjust_position',
|
||||
method: 'POST',
|
||||
dataType: 'script',
|
||||
data: {opr: opr}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,65 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-sub-repertoires-index-page').length > 0) {
|
||||
|
||||
// ============== 新建 ===============
|
||||
var $modal = $('.modal.admin-create-sub-repertoire-modal');
|
||||
var $form = $modal.find('form.admin-create-sub-repertoire-form');
|
||||
var $nameInput = $form.find('input[name="name"]');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function () {
|
||||
$nameInput.val('');
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".sub-repertoire-list-container").on("change", '.sub-repertoire-source-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/sub_repertoires/" + s_id,
|
||||
type: "PUT",
|
||||
dataType:'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-subject-authorizations-index-page').length > 0) {
|
||||
var $searchFrom = $('.subject-authorization-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if($link.data('value') === 'processed'){
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
@ -0,0 +1,72 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-subject-settings-index-page').length > 0) {
|
||||
var $form = $('.subject-setting-list-form');
|
||||
|
||||
// ************** 学校选择 *************
|
||||
$form.find('.school-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请选择创建者单位',
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/api/schools/search.json',
|
||||
dataType: 'json',
|
||||
data: function (params) {
|
||||
return {keyword: params.term};
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {results: data.schools}
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if (!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
if (item.id) {
|
||||
}
|
||||
return item.name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(".subject-setting-list-container").on("change", '.subject-setting-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/subject_settings/" + s_id,
|
||||
type: "PUT",
|
||||
dataType:'script',
|
||||
data: json
|
||||
})
|
||||
});
|
||||
|
||||
// 清空
|
||||
$form.on('click', '.clear-btn', function () {
|
||||
$form.find('select[name="status"]').val('');
|
||||
$form.find('.school-select').val('').trigger('change');
|
||||
$form.find('input[name="keyword"]').val('');
|
||||
$form.find('#homepage_show').attr('checked', false);
|
||||
$form.find('#excellent').attr('checked', false);
|
||||
$form.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
|
||||
// 上传图片
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function (e, data) {
|
||||
if(data.suffix == '_qrcode'){
|
||||
var $imageElement = $('.subject-weapp-image-' + data.source_id);
|
||||
$imageElement.attr('src', data.url);
|
||||
$imageElement.show();
|
||||
$imageElement.next().html('重新上传');
|
||||
} else {
|
||||
var $imageElement = $('.subject-image-' + data.source_id);
|
||||
$imageElement.attr('src', data.url);
|
||||
$imageElement.show();
|
||||
$imageElement.next().html('重新上传');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,99 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-subjects-index-page').length > 0) {
|
||||
var $form = $('.subject-list-form');
|
||||
|
||||
// ************** 学校选择 *************
|
||||
$form.find('.school-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请选择创建者单位',
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/api/schools/search.json',
|
||||
dataType: 'json',
|
||||
data: function (params) {
|
||||
return {keyword: params.term};
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {results: data.schools}
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if (!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
if (item.id) {
|
||||
}
|
||||
return item.name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
// 清空
|
||||
$form.on('click', '.clear-btn', function () {
|
||||
$form.find('select[name="status"]').val('');
|
||||
$form.find('.school-select').val('').trigger('change');
|
||||
$form.find('input[name="keyword"]').val('');
|
||||
$form.find('#homepage_show').attr('checked', false);
|
||||
$form.find('#excellent').attr('checked', false);
|
||||
$form.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
|
||||
// 定义状态切换监听事件
|
||||
var defineStatusChangeFunc = function (doElement, undoElement, url, callback) {
|
||||
$('.subject-list-container').on('click', doElement, function () {
|
||||
var $doAction = $(this);
|
||||
var $undoAction = $doAction.siblings(undoElement);
|
||||
|
||||
var subjectId = $doAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认进行该操作吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/subjects/' + subjectId + url,
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function () {
|
||||
show_success_flash();
|
||||
$doAction.hide();
|
||||
$undoAction.show();
|
||||
if (callback && typeof callback === "function") {
|
||||
callback(subjectId, url);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// 隐藏与取消隐藏
|
||||
defineStatusChangeFunc('.hide-action', '.active-action', '/hide');
|
||||
defineStatusChangeFunc('.active-action', '.hide-action', '/cancel_hide');
|
||||
|
||||
// 首页展示与取消首页展示
|
||||
var homepageShowCallback = function (subjectId, url) {
|
||||
var $subjectItem = $('.subject-list-container').find('.subject-item-' + subjectId);
|
||||
|
||||
if (url === '/homepage_show') {
|
||||
$subjectItem.find('.homepage-show-badge').show();
|
||||
} else {
|
||||
$subjectItem.find('.homepage-show-badge').hide();
|
||||
}
|
||||
}
|
||||
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage_show', homepageShowCallback);
|
||||
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage_show', homepageShowCallback);
|
||||
|
||||
// 设为金课与取消金课
|
||||
var excellentCallback = function (subjectId, url) {
|
||||
var $subjectItem = $('.subject-list-container').find('.subject-item-' + subjectId);
|
||||
|
||||
if (url === '/excellent') {
|
||||
$subjectItem.find('.excellent-badge').show();
|
||||
} else {
|
||||
$subjectItem.find('.excellent-badge').hide();
|
||||
}
|
||||
}
|
||||
defineStatusChangeFunc('.excellent-action', '.cancel-excellent-action', '/excellent', excellentCallback);
|
||||
defineStatusChangeFunc('.cancel-excellent-action', '.excellent-action', '/cancel_excellent', excellentCallback);
|
||||
}
|
||||
});
|
@ -0,0 +1,90 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-tag-disciplines-index-page').length > 0) {
|
||||
|
||||
// ============== 新建 ===============
|
||||
var $modal = $('.modal.admin-create-tag-discipline-modal');
|
||||
var $form = $modal.find('form.admin-create-tag-discipline-form');
|
||||
var $nameInput = $form.find('input[name="name"]');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function () {
|
||||
$nameInput.val('');
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', submit_create_form);
|
||||
|
||||
$nameInput.keydown(function (e) {
|
||||
var ev = e || event;
|
||||
var keycode = ev.which || ev.keyCode;
|
||||
if (keycode == 13) {
|
||||
submit_create_form();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
function submit_create_form() {
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function () {
|
||||
$.notify({message: '创建成功'});
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function () {
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function (res) {
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(".tag-discipline-list-container").on("change", '.tag-discipline-source-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/tag_disciplines/" + s_id,
|
||||
type: "PUT",
|
||||
dataType: 'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
|
||||
// ------------ 上移/下移 -------------
|
||||
$('.tag-discipline-list-container').on('click', ".move-action", function () {
|
||||
var $doAction = $(this);
|
||||
|
||||
var objectId = $doAction.data('id');
|
||||
var opr = $doAction.data('opr');
|
||||
$.ajax({
|
||||
url: '/admins/tag_disciplines/' + objectId + '/adjust_position',
|
||||
method: 'POST',
|
||||
dataType: 'script',
|
||||
data: {opr: opr}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,65 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-tag-repertoires-index-page').length > 0) {
|
||||
|
||||
// ============== 新建 ===============
|
||||
var $modal = $('.modal.admin-create-tag-repertoire-modal');
|
||||
var $form = $modal.find('form.admin-create-tag-repertoire-form');
|
||||
var $nameInput = $form.find('input[name="name"]');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function () {
|
||||
$nameInput.val('');
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function(){
|
||||
$.notify({ message: '创建成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".tag-repertoire-list-container").on("change", '.tag-repertoire-source-form', function () {
|
||||
var s_id = $(this).attr("data-id");
|
||||
var s_value = $(this).val();
|
||||
var s_name = $(this).attr("name");
|
||||
var json = {};
|
||||
json[s_name] = s_value;
|
||||
$.ajax({
|
||||
url: "/admins/tag_repertoires/" + s_id,
|
||||
type: "PUT",
|
||||
dataType:'script',
|
||||
data: json
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,82 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-upgrade-notices-index-page').length > 0) {
|
||||
window.upgradeNoticeForm = function(clazz) {
|
||||
var $modal = $('.modal.admin-' + clazz + '-upgrade-notice-modal');
|
||||
var $form = $modal.find('form.admin-' + clazz + '-upgrade-notice-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
'upgrade_notice[title]': {
|
||||
required: true
|
||||
},
|
||||
'upgrade_notice[content]': {
|
||||
required: true
|
||||
},
|
||||
'upgrade_notice[start_at]': {
|
||||
required: true
|
||||
},
|
||||
'upgrade_notice[end_at]': {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function() {
|
||||
$form.find('.error').html('');
|
||||
console.log('url', $form.data('url'), $form)
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.attr('action');
|
||||
var newDate = new Date();
|
||||
var begin_time = Date.parse($('.' + clazz +'_start_at').val());
|
||||
var end_time = Date.parse($('.' + clazz +'_end_at').val());
|
||||
if (begin_time < newDate) {
|
||||
$('.' + clazz +'_end_at').addClass('danger text-danger');
|
||||
$form.find('.error').html('开始时间应大于当前时间');
|
||||
return false
|
||||
} else if (end_time < newDate) {
|
||||
$form.find('.error').html('结束时间应大于当前时间');
|
||||
$('.' + clazz +'_end_at').addClass('danger text-danger');
|
||||
return false
|
||||
} else if (end_time < begin_time) {
|
||||
$form.find('.error').html('结束时间应大于开始时间');
|
||||
$('.' + clazz +'_end_at').addClass('danger text-danger');
|
||||
return false
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: clazz == 'create' ? 'POST' : 'PUT',
|
||||
dataType: 'json',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
success: function() {
|
||||
$.notify({ message: '创建成功' });
|
||||
$modal.modal('hide');
|
||||
|
||||
setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
},
|
||||
error: function(res) {
|
||||
var data = res.responseJSON;
|
||||
$form.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var timeOptions = {
|
||||
autoclose: 1,
|
||||
language: 'zh-CN',
|
||||
format: 'yyyy-mm-dd hh:ii',
|
||||
minuteStep: 10
|
||||
};
|
||||
|
||||
$(".create_start_at").datetimepicker(timeOptions)
|
||||
$(".create_end_at").datetimepicker(timeOptions)
|
||||
upgradeNoticeForm("create");
|
||||
}
|
||||
});
|
@ -0,0 +1,81 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-user-schools-statistics-index-page').length > 0) {
|
||||
var $form = $('.user-schools-statistic-list-form');
|
||||
|
||||
// ************** 学校选择 *************
|
||||
var matcherFunc = function(params, data){
|
||||
if ($.trim(params.term) === '') {
|
||||
return data;
|
||||
}
|
||||
if (typeof data.text === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.name && data.name.indexOf(params.term) > -1) {
|
||||
var modifiedData = $.extend({}, data, true);
|
||||
return modifiedData;
|
||||
}
|
||||
|
||||
// Return `null` if the term should not be displayed
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
var defineSchoolSelect = function (schools) {
|
||||
$form.find('.school-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '选择学校/单位',
|
||||
minimumInputLength: 1,
|
||||
data: schools,
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
$form.find('#school_id').val(item.id);
|
||||
}
|
||||
return item.name || item.text;
|
||||
},
|
||||
matcher: matcherFunc
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// 初始化学校选择器
|
||||
$.ajax({
|
||||
url: '/api/schools/for_option.json',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
defineSchoolSelect(data.schools);
|
||||
}
|
||||
});
|
||||
|
||||
// 清空
|
||||
$form.on('click', '.clear-btn', function(){
|
||||
$form.find('select[name="date"]').val('');
|
||||
$form.find('select[name="province"]').val('');
|
||||
$form.find('.school-select').val('').trigger('change');
|
||||
$form.find('input[type="submit"]').trigger('click');
|
||||
})
|
||||
|
||||
|
||||
// 导出
|
||||
$('.export-action').on('click', function(){
|
||||
var form = $(".user-schools-statistic-list-form")
|
||||
var exportLink = $(this);
|
||||
var date = form.find("select[name='date']").val();
|
||||
var schoolId = form.find('input[name="school_id"]').val();
|
||||
var province = form.find('input[name="province"]').val();
|
||||
console.log(province)
|
||||
if(province == "" || province == null){
|
||||
alert("只能按省份导出");
|
||||
return;
|
||||
}
|
||||
|
||||
var url = exportLink.data("url").split('?')[0] + "?date=" + date + "&school_id=" + schoolId + "&province=" + province;
|
||||
window.open(url);
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,73 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-user-statistics-index-page').length > 0) {
|
||||
var $form = $('.user-statistic-list-form');
|
||||
|
||||
// ************** 学校选择 *************
|
||||
var matcherFunc = function(params, data){
|
||||
if ($.trim(params.term) === '') {
|
||||
return data;
|
||||
}
|
||||
if (typeof data.text === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.name && data.name.indexOf(params.term) > -1) {
|
||||
var modifiedData = $.extend({}, data, true);
|
||||
return modifiedData;
|
||||
}
|
||||
|
||||
// Return `null` if the term should not be displayed
|
||||
return null;
|
||||
}
|
||||
|
||||
var defineSchoolSelect = function (schools) {
|
||||
$form.find('.school-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '选择学校/单位',
|
||||
minimumInputLength: 1,
|
||||
data: schools,
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
$form.find('#school_id').val(item.id);
|
||||
}
|
||||
return item.name || item.text;
|
||||
},
|
||||
matcher: matcherFunc
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// 初始化学校选择器
|
||||
$.ajax({
|
||||
url: '/api/schools/for_option.json',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
defineSchoolSelect(data.schools);
|
||||
}
|
||||
});
|
||||
|
||||
// 清空
|
||||
$form.on('click', '.clear-btn', function(){
|
||||
$form.find('select[name="date"]').val('');
|
||||
$form.find('.school-select').val('').trigger('change');
|
||||
$form.find('input[type="submit"]').trigger('click');
|
||||
})
|
||||
|
||||
|
||||
// 导出
|
||||
$('.export-action').on('click', function(){
|
||||
var form = $(".user-statistic-list-form .search-form")
|
||||
var exportLink = $(this);
|
||||
var date = form.find("select[name='date']").val();
|
||||
var schoolId = form.find('input[name="school_id"]').val();
|
||||
|
||||
var url = exportLink.data("url").split('?')[0] + "?date=" + date + "&school_id=" + schoolId;
|
||||
window.open(url);
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,156 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-users-edit-page, body.admins-users-update-page').length > 0) {
|
||||
var initDepartmentSelect = true;
|
||||
|
||||
// ************** 学校选择 *************
|
||||
var matcherFunc = function(params, data){
|
||||
if ($.trim(params.term) === '') {
|
||||
return data;
|
||||
}
|
||||
if (typeof data.text === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.name && data.name.indexOf(params.term) > -1) {
|
||||
var modifiedData = $.extend({}, data, true);
|
||||
return modifiedData;
|
||||
}
|
||||
|
||||
// Return `null` if the term should not be displayed
|
||||
return null;
|
||||
}
|
||||
|
||||
var defineSchoolSelect = function (schools) {
|
||||
$('.school-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '查询学校/单位',
|
||||
minimumInputLength: 1,
|
||||
data: schools,
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
$('#user_school_id').val(item.id);
|
||||
getDepartmentsData(item.id, defineDepartmentSelect2);
|
||||
}
|
||||
return item.name || item.text;
|
||||
},
|
||||
matcher: matcherFunc
|
||||
});
|
||||
};
|
||||
|
||||
var defineDepartmentSelect2 = function(departments){
|
||||
departments.unshift({ id: '-1', name: '未选择' }); // 可不选
|
||||
|
||||
if (!initDepartmentSelect) { $('.department-select').empty(); } // 为了能够回填部门
|
||||
initDepartmentSelect = false;
|
||||
|
||||
$('.department-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '查询学院/部门',
|
||||
minimumInputLength: 0,
|
||||
data: departments,
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
$('#user_department_id').val(item.id);
|
||||
}
|
||||
return item.name || item.text;
|
||||
},
|
||||
matcher: matcherFunc
|
||||
});
|
||||
};
|
||||
|
||||
var getDepartmentsData = function(school_id, callback){
|
||||
$.ajax({
|
||||
url: '/api/schools/' + school_id + '/departments/for_option.json',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
callback(data.departments);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 初始化学校选择器
|
||||
$.ajax({
|
||||
url: '/api/schools/for_option.json',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
defineSchoolSelect(data.schools);
|
||||
}
|
||||
});
|
||||
|
||||
// **************** 地区选择 ****************
|
||||
$('.province-city-select').cxSelect({
|
||||
url: '/javascripts/educoder/province-data.json',
|
||||
selects: ['province-select', 'city-select']
|
||||
});
|
||||
|
||||
// *********** 职业选择 ************
|
||||
var identityData = [
|
||||
{
|
||||
"v": "teacher",
|
||||
"n": "教师",
|
||||
"s": [{"n": "教授", "v": "教授"},{"n": "副教授", "v": "副教授"},{"n": "讲师", "v": "讲师"},{"n": "助教", "v": "助教"}]
|
||||
},
|
||||
{
|
||||
"v": "student",
|
||||
"n": "学生",
|
||||
"s": []
|
||||
},
|
||||
{
|
||||
"v": "professional",
|
||||
"n": "专业人士",
|
||||
"s": [{"n": "企业管理者", "v": "企业管理者"},{"n": "部门管理者", "v": "部门管理者"},{"n": "高级工程师", "v": "高级工程师"},{"n": "工程师", "v": "工程师"},{"n": "助理工程师", "v": "助理工程师"}]
|
||||
}
|
||||
];
|
||||
$('.user-identity-select').cxSelect({
|
||||
data: identityData,
|
||||
jsonValue: 'v',
|
||||
selects: ['identity-select', 'technical-title-select']
|
||||
});
|
||||
$('.identity-select').on('change', function(){
|
||||
if($(this).val() === 'student'){
|
||||
$('.technical-title-select-wrapper').hide();
|
||||
$('.form-group.user_student_id').show();
|
||||
} else {
|
||||
$('.technical-title-select-wrapper').show();
|
||||
$('.form-group.user_student_id').hide();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
var $form = $('form.edit_user')
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"user[password]": {
|
||||
required: false,
|
||||
minlength: 5
|
||||
},
|
||||
"user[password_confirmation]": {
|
||||
required: false,
|
||||
minlength: 5,
|
||||
equalTo: "#user_password"
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
"user[password_confirmation]": {
|
||||
equalTo: "两次密码输入不一致"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$form.submit(function(e){
|
||||
if(!$form.valid()){ e.preventDefault(); }
|
||||
})
|
||||
}
|
||||
});
|
@ -0,0 +1,218 @@
|
||||
$(document).on('turbolinks:load', function(){
|
||||
if ($('body.admins-users-index-page').length > 0) {
|
||||
|
||||
var showSuccessNotify = function() {
|
||||
$.notify({
|
||||
message: '操作成功'
|
||||
},{
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
|
||||
// lock user
|
||||
$('.users-list-container').on('click', '.lock-action', function(){
|
||||
var $lockAction = $(this);
|
||||
var $unlockAction = $lockAction.siblings('.unlock-action');
|
||||
|
||||
var userId = $lockAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认加锁吗?',
|
||||
ok: function(){
|
||||
$.ajax({
|
||||
url: '/admins/users/' + userId + '/lock',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$lockAction.hide();
|
||||
$unlockAction.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// unlock user
|
||||
$('.users-list-container').on('click', '.unlock-action', function(){
|
||||
var $unlockAction = $(this);
|
||||
var $lockAction = $unlockAction.siblings('.lock-action');
|
||||
|
||||
var userId = $unlockAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认解锁吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/users/' + userId + '/unlock',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$lockAction.show();
|
||||
$unlockAction.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// active user
|
||||
$('.users-list-container').on('click', '.active-action', function(){
|
||||
var $activeAction = $(this);
|
||||
var $unlockAction = $activeAction.siblings('.unlock-action');
|
||||
var $lockAction = $activeAction.siblings('.lock-action');
|
||||
|
||||
var userId = $activeAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认激活吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/users/' + userId + '/unlock',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$activeAction.hide();
|
||||
$lockAction.show();
|
||||
$unlockAction.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// reset user login times
|
||||
$('.users-list-container').on('click', '.reset-login-times-action', function(){
|
||||
var $action = $(this);
|
||||
|
||||
var userId = $action.data('id');
|
||||
$.ajax({
|
||||
url: '/admins/users/' + userId + '/reset_login_times',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ***************** reward grade modal *****************
|
||||
var $rewardGradeModal = $('.admin-users-reward-grade-modal');
|
||||
var $form = $rewardGradeModal.find('form.admin-users-reward-grade-form');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
grade: {
|
||||
required: true,
|
||||
digits: true
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$rewardGradeModal.on('show.bs.modal', function (event) {
|
||||
var $link = $(event.relatedTarget);
|
||||
|
||||
var userId = $link.data('id');
|
||||
$rewardGradeModal.find('.modal-body input[name="user_id"]').val(userId);
|
||||
});
|
||||
// modal visited fire
|
||||
$rewardGradeModal.on('shown.bs.modal', function(){
|
||||
$rewardGradeModal.find('.modal-body input[name="grade"]').focus();
|
||||
});
|
||||
|
||||
$('.admin-users-reward-grade-modal .submit-btn').on('click', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var userId = $form.find('input[name="user_id"]').val();
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: "/admins/users/" + userId + "/reward_grade",
|
||||
data: $form.serialize(),
|
||||
success: function(data) {
|
||||
showSuccessNotify();
|
||||
$('.users-list-container .user-item-' + userId + ' td.grade-content').html(data.grade);
|
||||
$rewardGradeModal.modal('hide');
|
||||
},
|
||||
error: function(res) {
|
||||
$rewardGradeModal.find('.error').html(res.responseJSON.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 导入学生
|
||||
var $importUserModal = $('.modal.admin-import-user-modal');
|
||||
var $importUserForm = $importUserModal.find('form.admin-import-user-form')
|
||||
|
||||
$importUserModal.on('show.bs.modal', function(){
|
||||
resetFileInputFunc($importUserModal.find('.upload-file-input'));
|
||||
$importUserModal.find('.file-names').html('选择文件');
|
||||
$importUserModal.find('.upload-file-input').trigger('click');
|
||||
});
|
||||
$importUserModal.on('change', '.upload-file-input', function(e){
|
||||
var file = $(this)[0].files[0];
|
||||
$importUserModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
})
|
||||
|
||||
var importUserFormValid = function(){
|
||||
if($importUserForm.find('input[name="file"]').val() == undefined || $importUserForm.find('input[name="file"]').val().length == 0){
|
||||
$importUserForm.find('.error').html('请选择文件');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var buildResultMessage = function(data){
|
||||
var messageHtml = "<div>导入结果:成功" + data.success + "条,失败"+ data.fail.length + "条</div>";
|
||||
|
||||
if(data.fail.length > 0){
|
||||
messageHtml += '<table class="table"><thead class="thead-light"><tr><th>数据</th><th>失败原因</th></tr></thead><tbody>';
|
||||
|
||||
data.fail.forEach(function(item){
|
||||
messageHtml += '<tr><td>' + item.data + '</td><td>' + item.message + '</td></tr>';
|
||||
});
|
||||
|
||||
messageHtml += '</tbody></table>'
|
||||
}
|
||||
|
||||
return messageHtml;
|
||||
}
|
||||
|
||||
$importUserModal.on('click', '.submit-btn', function(){
|
||||
$importUserForm.find('.error').html('');
|
||||
|
||||
if (importUserFormValid()) {
|
||||
$('body').mLoading({ text: '正在导入...' });
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: '/admins/import_users',
|
||||
data: new FormData($importUserForm[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data){
|
||||
$('body').mLoading('destroy');
|
||||
$importUserModal.modal('hide');
|
||||
|
||||
showMessageModal(buildResultMessage(data), function(){
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
error: function(res){
|
||||
$('body').mLoading('destroy');
|
||||
var data = res.responseJSON;
|
||||
$importUserForm.find('.error').html(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-video-applies-index-page').length > 0) {
|
||||
var $searchFrom = $('.video-applies-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('all');
|
||||
|
||||
if($link.data('value') === 'all'){
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
@ -0,0 +1,124 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-weapp-adverts-index-page').length > 0) {
|
||||
var resetNo = function(){
|
||||
$('#adverts-container .advert-item-no').each(function(index, ele){
|
||||
$(ele).html(index + 1);
|
||||
})
|
||||
}
|
||||
|
||||
// ------------ 保存链接 -----------
|
||||
$('.adverts-card').on('click', '.save-data-btn', function(){
|
||||
var $link = $(this);
|
||||
var id = $link.data('id');
|
||||
var link = $('.advert-item-' + id).find('.link-input').val();
|
||||
$link.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/weapp_adverts/' + id,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
data: { link: link },
|
||||
success: function(data){
|
||||
$.notify({ message: '操作成功' });
|
||||
},
|
||||
error: ajaxErrorNotifyHandler,
|
||||
complete: function(){
|
||||
$link.removeAttr('disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
// -------------- 是否在首页展示 --------------
|
||||
$('.adverts-card').on('change', '.online-check-box', function(){
|
||||
var $checkbox = $(this);
|
||||
var id = $checkbox.data('id');
|
||||
var checked = $checkbox.is(':checked');
|
||||
$checkbox.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/weapp_adverts/' + id,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
data: { online: checked },
|
||||
success: function(data){
|
||||
$.notify({ message: '保存成功' });
|
||||
var box = $('.advert-item-' + id).find('.drag');
|
||||
if(checked){
|
||||
box.removeClass('not_active');
|
||||
}else{
|
||||
box.addClass('not_active');
|
||||
}
|
||||
},
|
||||
error: ajaxErrorNotifyHandler,
|
||||
complete: function(){
|
||||
$checkbox.removeAttr('disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// ------------ 拖拽 -------------
|
||||
var onDropFunc = function(el, _target, _source, sibling){
|
||||
var moveId = $(el).data('id');
|
||||
var insertId = $(sibling).data('id') || '';
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/weapp_adverts/drag',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: { move_id: moveId, after_id: insertId },
|
||||
success: function(data){
|
||||
resetNo();
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$.notify({message: '移动失败,原因:' + data.message}, {type: 'danger'});
|
||||
}
|
||||
})
|
||||
};
|
||||
var ele1 = document.getElementById('adverts-container');
|
||||
dragula([ele1], { mirrorContainer: ele1 }).on('drop', onDropFunc);
|
||||
|
||||
|
||||
// ----------- 新增 --------------
|
||||
var $createModal = $('.modal.admin-add-weapp-advert-modal');
|
||||
var $createForm = $createModal.find('form.admin-add-weapp-advert-form');
|
||||
|
||||
$createForm.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"weapp_settings_advert[image]": {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$createModal.on('show.bs.modal', function(event){
|
||||
resetFileInputFunc($createModal.find('.img-file-input'));
|
||||
$createModal.find('.file-names').html('选择文件');
|
||||
});
|
||||
|
||||
$createModal.on('click', '.submit-btn', function() {
|
||||
$createForm.find('.error').html('');
|
||||
|
||||
if ($createForm.valid()) {
|
||||
$createForm.submit();
|
||||
} else {
|
||||
$createForm.find('.error').html('请选择图片');
|
||||
}
|
||||
});
|
||||
$createModal.on('change', '.img-file-input', function(){
|
||||
var file = $(this)[0].files[0];
|
||||
$createModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
})
|
||||
|
||||
// -------------- 重新上传图片 --------------
|
||||
//replace_image_url
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
var $advertItem = $('.advert-item-' + data.source_id);
|
||||
$advertItem.find('.advert-item-img img').attr('src', data.url);
|
||||
})
|
||||
|
||||
// 删除后
|
||||
$(document).on('delete_success', resetNo)
|
||||
}
|
||||
})
|
@ -0,0 +1,123 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-weapp-carousels-index-page').length > 0) {
|
||||
var resetNo = function(){
|
||||
$('#carousels-container .custom-carousel-item-no').each(function(index, ele){
|
||||
$(ele).html(index + 1);
|
||||
})
|
||||
}
|
||||
// ------------ 保存链接 -----------
|
||||
$('.carousels-card').on('click', '.save-data-btn', function(){
|
||||
var $link = $(this);
|
||||
var id = $link.data('id');
|
||||
var link = $('.custom-carousel-item-' + id).find('.link-input').val();
|
||||
$link.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/weapp_carousels/' + id,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
data: { link: link },
|
||||
success: function(data){
|
||||
$.notify({ message: '操作成功' });
|
||||
},
|
||||
error: ajaxErrorNotifyHandler,
|
||||
complete: function(){
|
||||
$link.removeAttr('disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
// -------------- 是否在首页展示 --------------
|
||||
$('.carousels-card').on('change', '.online-check-box', function(){
|
||||
var $checkbox = $(this);
|
||||
var id = $checkbox.data('id');
|
||||
var checked = $checkbox.is(':checked');
|
||||
$checkbox.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/weapp_carousels/' + id,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
data: { online: checked },
|
||||
success: function(data){
|
||||
$.notify({ message: '保存成功' });
|
||||
var box = $('.custom-carousel-item-' + id).find('.drag');
|
||||
if(checked){
|
||||
box.removeClass('not_active');
|
||||
}else{
|
||||
box.addClass('not_active');
|
||||
}
|
||||
},
|
||||
error: ajaxErrorNotifyHandler,
|
||||
complete: function(){
|
||||
$checkbox.removeAttr('disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// ------------ 拖拽 -------------
|
||||
var onDropFunc = function(el, _target, _source, sibling){
|
||||
var moveId = $(el).data('id');
|
||||
var insertId = $(sibling).data('id') || '';
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/weapp_carousels/drag',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: { move_id: moveId, after_id: insertId },
|
||||
success: function(data){
|
||||
resetNo();
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$.notify({message: '移动失败,原因:' + data.message}, {type: 'danger'});
|
||||
}
|
||||
})
|
||||
};
|
||||
var ele1 = document.getElementById('carousels-container');
|
||||
dragula([ele1], { mirrorContainer: ele1 }).on('drop', onDropFunc);
|
||||
|
||||
|
||||
// ----------- 新增 --------------
|
||||
var $createModal = $('.modal.admin-add-weapp-carousel-modal');
|
||||
var $createForm = $createModal.find('form.admin-add-weapp-carousel-form');
|
||||
|
||||
$createForm.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"weapp_settings_carousel[image]": {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$createModal.on('show.bs.modal', function(event){
|
||||
resetFileInputFunc($createModal.find('.img-file-input'));
|
||||
$createModal.find('.file-names').html('选择文件');
|
||||
});
|
||||
|
||||
$createModal.on('click', '.submit-btn', function() {
|
||||
$createForm.find('.error').html('');
|
||||
|
||||
if ($createForm.valid()) {
|
||||
$createForm.submit();
|
||||
} else {
|
||||
$createForm.find('.error').html('请选择图片');
|
||||
}
|
||||
});
|
||||
$createModal.on('change', '.img-file-input', function(){
|
||||
var file = $(this)[0].files[0];
|
||||
$createModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
})
|
||||
|
||||
// -------------- 重新上传图片 --------------
|
||||
//replace_image_url
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
var $carouselItem = $('.custom-carousel-item-' + data.source_id);
|
||||
$carouselItem.find('.custom-carousel-item-img img').attr('src', data.url);
|
||||
})
|
||||
|
||||
// 删除后
|
||||
$(document).on('delete_success', resetNo)
|
||||
}
|
||||
})
|
@ -0,0 +1,25 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('.weapp-banner-setting-container').length > 0) {
|
||||
var $form = $('#course_form');
|
||||
|
||||
$('.course.banner-item-bottom').on("change", 'input[type="file"]', function() {
|
||||
var $fileInput = $(this);
|
||||
var file = this.files[0];
|
||||
var imageType = /image.*/;
|
||||
if (file && file.type.match(imageType)) {
|
||||
$form.ajaxSubmit()
|
||||
}
|
||||
});
|
||||
|
||||
var $shixunform = $('#shixun_form');
|
||||
|
||||
$('.shixun.banner-item-bottom').on("change", 'input[type="file"]', function() {
|
||||
var $fileInput = $(this);
|
||||
var file = this.files[0];
|
||||
var imageType = /image.*/;
|
||||
if (file && file.type.match(imageType)) {
|
||||
$shixunform.ajaxSubmit()
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
@ -0,0 +1,18 @@
|
||||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
|
||||
// vendor/assets/javascripts directory can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
||||
//
|
||||
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||
// about supported directives.
|
||||
//
|
||||
//= require rails-ujs
|
||||
//= require activestorage
|
||||
//= require turbolinks
|
||||
//= require jquery3
|
||||
//= require popper
|
||||
//= require bootstrap-sprockets
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue