forked from Gitlink/forgeplus
update
This commit is contained in:
parent
1d7878f575
commit
0b22a03d96
|
@ -0,0 +1,89 @@
|
|||
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
||||
#
|
||||
# If you find yourself ignoring temporary files generated by your text editor
|
||||
# or operating system, you probably want to add a global ignore instead:
|
||||
# git config --global core.excludesfile '~/.gitignore_global'
|
||||
|
||||
# Ignore bundler config.
|
||||
/.bundle
|
||||
/bundle
|
||||
|
||||
# Ignore lock config file
|
||||
*.log
|
||||
|
||||
# mac
|
||||
*.DS_Store
|
||||
.bashrc
|
||||
# Ignore all logfiles and tempfiles.
|
||||
/log/*
|
||||
/tmp/*
|
||||
!/log/.keep
|
||||
!/tmp/.keep
|
||||
|
||||
# Ignore uploaded files in development
|
||||
/storage/*
|
||||
|
||||
/node_modules
|
||||
/yarn-error.log
|
||||
public/react/yarn.lock
|
||||
|
||||
# /public/assets
|
||||
.byebug_history
|
||||
|
||||
# Ignore master key for decrypting credentials and more.
|
||||
/config/master.key
|
||||
/config/database.yml
|
||||
/.idea/*
|
||||
|
||||
# Ignore react node_modules
|
||||
public/system/*
|
||||
public/react/*
|
||||
/public/react/.cache
|
||||
/public/react/node_modules/
|
||||
/public/react/config/stats.json
|
||||
/public/react/stats.json
|
||||
/public/react/.idea/*
|
||||
/public/react/build/*
|
||||
/public/h5build
|
||||
/public/npm-debug.log
|
||||
|
||||
# avatars
|
||||
/public/images/avatars
|
||||
|
||||
/config/secrets.yml
|
||||
/config/redis.yml
|
||||
/config/elasticsearch.yml
|
||||
/config/aliyun_vod.yml
|
||||
|
||||
public/upload.html
|
||||
/config/configuration.yml
|
||||
/config/environments/production.rb
|
||||
/config/initializers/gitlab_config.rb
|
||||
/db/schema.rb
|
||||
.vscode/
|
||||
vendor/bundle/
|
||||
.ruby-version
|
||||
.ruby-gemset
|
||||
|
||||
/Users
|
||||
/files
|
||||
/public/images/avatars
|
||||
/public/cache_repository
|
||||
/public/files
|
||||
/workspace
|
||||
/log
|
||||
/public/admin
|
||||
/mysql_data
|
||||
/public/repo/
|
||||
|
||||
|
||||
.generators
|
||||
.rakeTasks
|
||||
db/bak/
|
||||
docker/
|
||||
educoder.sql
|
||||
redis_data/
|
||||
Dockerfile
|
||||
dump.rdb
|
||||
.tags*
|
||||
ceshi_user.xlsx
|
|
@ -0,0 +1,22 @@
|
|||
kind: pipeline
|
||||
name: default
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: install
|
||||
image: ruby:2.4.5
|
||||
commands:
|
||||
- gem install bundler
|
||||
- bundle -v
|
||||
- bundle install --jobs=1 --retry=1
|
||||
|
||||
- name: test
|
||||
image: ruby:2.4.5
|
||||
volumes:
|
||||
- name: bundle
|
||||
path: /usr/local/bundle
|
||||
commands:
|
||||
- rake
|
|
@ -0,0 +1,129 @@
|
|||
# Changelog
|
||||
## [v3.2.0](https://forgeplus.trustie.net/projects/jasder/forgeplus/releases) - 2021-06-09
|
||||
|
||||
### ENHANCEMENTS
|
||||
* ADD 集成邮件和平台站内信等通知系统
|
||||
* Fix 代码库二级页面-优化文件子目录浏览功能(#50388)
|
||||
* Fix 代码库二级页面-优化commit提交详情页页面排版及数据显示(#50372)
|
||||
* Fix 代码库二级页面-优化commit提交信息列表页加载方式和数据排序功能(#50348)
|
||||
* Fix 代码库二级页面-优化创建发行版功能(#50346)
|
||||
* Fix 代码库二级页面-优化标签列表页功能(#50344)
|
||||
* Fix 代码库二级页面-优化发行版本列表页功能(#50345)
|
||||
* Fix 代码库二级页面-优化分支列表页功能(#50343)
|
||||
* Fix 其他问题优化(#51581) (#51343) (#51108)
|
||||
|
||||
---
|
||||
|
||||
### BUGFIXES
|
||||
* Fix 发行版—标签跳转链接错误(#51666)
|
||||
* Fix 文件预览报错(#51660)
|
||||
* Fix 标签创建时间显示错误(#51658)
|
||||
* Fix 分支列表中头像显示问题(#51656)
|
||||
* Fix 文本信息过长(#51630) (#51626)
|
||||
* Fix 版本库中附件下载400(#51625)
|
||||
* Fix loading页面优化(#51588)
|
||||
* Fix 提交详情页面优化(#51577)
|
||||
* Fix 修复易修复制功能(#51569)
|
||||
* Fix 修复新建发行版用户信息显示错误的问题(#51665)
|
||||
* Fix 修复查看文件详细信息报错的问题(#51561)
|
||||
* Fix 修复提交记录中时间显示格式问题(#51526)
|
||||
* Fix 组织下项目更加更新时间倒序排序(#50833)
|
||||
|
||||
|
||||
## [v3.1.0](https://forgeplus.trustie.net/projects/jasder/forgeplus/releases) - 2021-06-09
|
||||
|
||||
* ENHANCEMENTS
|
||||
* ADD 用户活动统计图表功能
|
||||
* ADD 用户精选项目功能
|
||||
* ADD 用户贡献度统计图表功能
|
||||
* ADD 用户开发能力数据统计工
|
||||
* ADD 用户角色定位展示功能
|
||||
* ADD 用户专业定位标签展示功能
|
||||
* ADD 修改用户基本资料功能
|
||||
* ADD 更改密码功能
|
||||
* ADD 用户个人主页基本现在展示可配置功能
|
||||
|
||||
* BUGFIXES
|
||||
* Fix 解决一些bug
|
||||
* Fix 优化美化页面
|
||||
|
||||
|
||||
* BUGFIXES
|
||||
* Fix 在线修改文件,页面文件显不及时的问题(46049)
|
||||
* Fix Fork项目,接口多次调用问题(45052)
|
||||
* FIX 页面置顶功能区域排版问题(45825)
|
||||
* Fix 其他样式显示问题
|
||||
|
||||
* ENHANCEMENTS
|
||||
* ADD 合并请求页面显示有冲突文件状态(46016)
|
||||
* ADD 创建组织各属性添加规则匹配功能(45707)
|
||||
* ADD 微信分享功能(45707)
|
||||
|
||||
## [v3.0.3](https://forgeplus.trustie.net/projects/jasder/forgeplus/releases) - 2021-05-08
|
||||
|
||||
* BUGFIXES
|
||||
* Fix 解决易修标题过长导致的排版问题(45469)
|
||||
* Fix 解决合并请求详情页面排版错误的问题(45457)
|
||||
* FIX 解决转移仓库界面专有名词描述错误的问题(45455)
|
||||
* Fix 解决markdown格式文件自动生成数字排序的问题(45454)
|
||||
* Fix 解决镜像项目源地址不显示的问题(45403)
|
||||
* Fix 解决镜像项目导航显示错误问题(45398)
|
||||
* Fix 解决其他相关bug
|
||||
|
||||
* ENHANCEMENTS
|
||||
* UPDATE 用户注册时,账号和密码正则匹配调整(45336) (45318) (45290)
|
||||
* ADD 创建组织各属性添加规则匹配功能(45313) (45289)
|
||||
* ADD 创建团建各属性添加规则匹配功能(45334) (45325) (45287)
|
||||
* ADD 仓库转移功能(45017) (45015)
|
||||
|
||||
## [v3.0.2](https://forgeplus.trustie.net/projects/jasder/forgeplus/releases) - 2021-04-23
|
||||
|
||||
* BUGFIXES
|
||||
* Fix 解决部分用户头像不显示问题
|
||||
* Fix 解决代码库模块中最左侧目录中的文件定位加载不准确的问题
|
||||
* FIX 解决团队管理页面中项目链接错误问题
|
||||
* Fix 解决markdown格式文件显示问题
|
||||
* Fix 解决组织名下创建项目报错的问题
|
||||
* Fix 解决组织名下的项目,创建issue报错的问题
|
||||
* Fix 解决组织名下创建团队提示信息信息显示错误问题
|
||||
* Fix 解决点击组织图片时,链接加载错误问题
|
||||
* Fix 修复查询版本库信息安全漏洞
|
||||
* Fix 解决修复团队成员操作访问组织仓库报403错误的问题
|
||||
* Fix 解决owners团队成员对仓库添加成功失败的问题
|
||||
|
||||
* ENHANCEMENTS
|
||||
* ADD 自动生产用户头像功能
|
||||
* ADD 创建组织支持中文名称
|
||||
* ADD 创建团建支持中文名称
|
||||
* ADD 组织名称统一显示中文名
|
||||
* ADD 团队名称统一显示中文名
|
||||
* ADD 用户头像悬浮时展示相关信息
|
||||
* ADD 项目详情页添加实践课程链接入口
|
||||
* ADD README文件页面添加添加目录导航功能
|
||||
* UPDATE 升级改版底部footer信息
|
||||
* UPDATE 升级用户操作版本库权限
|
||||
|
||||
## [v3.0.1](https://forgeplus.trustie.net/projects/jasder/forgeplus/releases) - 2021-03-19
|
||||
|
||||
* BUGFIXES
|
||||
* Fix pull reqeust模块中用户头像显示问题
|
||||
* Fix 解决issue模块中,指派用户的问题
|
||||
* Fix 解决合并请求失败的后显示message信息不正确
|
||||
* Fix 代码目录页面,readme文件提供单独的api
|
||||
|
||||
* ENHANCEMENTS
|
||||
* 重构项目详情页面
|
||||
|
||||
## [v3.0.0](https://forgeplus.trustie.net/projects/jasder/forgeplus/releases) - 2020-12-29
|
||||
|
||||
* BUGFIXES
|
||||
* Fix pull reqeust的访问权限问题 (#14156) (#14171)
|
||||
* Fix 部分页面访问403的问题
|
||||
* Fix 合并请求失败的问题
|
||||
* Fix 代码目录页面,文件夹和文件图片不显示的问题
|
||||
* Fix Issue列表中按‘负责人’过滤筛选时,部分项目成员不在搜索范围没的问题
|
||||
* Fix 项目更新时间不同步的问题, 添加了定时任务
|
||||
* ENHANCEMENTS
|
||||
* 提升获取版本库目录代码查询速度 (#43296)
|
||||
* tag 列表慢查询速度问题 (#43332)
|
||||
* API builder 模版中 render partial builder的性能问题
|
|
@ -0,0 +1,130 @@
|
|||
source 'https://gems.ruby-china.com'
|
||||
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||
|
||||
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 'groupdate', '~> 4.1.0'
|
||||
gem 'chartkick'
|
||||
gem 'grape-entity', '~> 0.7.1'
|
||||
gem 'kaminari', '~> 1.1', '>= 1.1.1'
|
||||
|
||||
gem 'bootsnap', '>= 1.1.0', require: false
|
||||
|
||||
gem 'chinese_pinyin'
|
||||
|
||||
gem 'rack-cors'
|
||||
gem 'redis-rails'
|
||||
gem 'roo-xls'
|
||||
gem 'simple_xlsx_reader'
|
||||
|
||||
gem 'rubyzip'
|
||||
|
||||
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 'request_store'
|
||||
#gem 'iconv'
|
||||
# markdown 转html
|
||||
gem 'redcarpet', '~> 3.4'
|
||||
|
||||
gem 'rqrcode', '~> 0.10.1'
|
||||
gem 'rqrcode_png'
|
||||
|
||||
gem 'acts-as-taggable-on', '~> 6.0'
|
||||
|
||||
# a tree structure
|
||||
gem 'ancestry'
|
||||
gem 'acts_as_list'
|
||||
gem 'omniauth-cas'
|
||||
|
||||
# profiler Middleware
|
||||
gem 'rack-mini-profiler'
|
||||
|
||||
# object-based searching
|
||||
gem 'ransack'
|
||||
|
||||
group :development, :test do
|
||||
gem 'rspec-rails', '~> 3.8'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'prettier'
|
||||
gem 'rubocop', '~> 0.52.0'
|
||||
gem 'solargraph', '~> 0.38.0'
|
||||
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 "annotate", "~> 2.6.0"
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'capybara', '>= 2.15', '< 4.0'
|
||||
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'
|
||||
gem "sidekiq-cron", "~> 1.1"
|
||||
|
||||
# batch insert
|
||||
gem 'bulk_insert'
|
||||
|
||||
# elasticsearch
|
||||
gem 'searchkick'
|
||||
|
||||
gem 'aasm'
|
||||
gem 'enumerize'
|
||||
|
||||
gem 'diffy'
|
||||
|
||||
gem 'deep_cloneable', '~> 3.0.0'
|
||||
|
||||
# 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 'letter_avatar'
|
|
@ -0,0 +1,508 @@
|
|||
GEM
|
||||
remote: https://gems.ruby-china.com/
|
||||
specs:
|
||||
aasm (5.0.6)
|
||||
concurrent-ruby (~> 1.0)
|
||||
actioncable (5.2.4.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.4.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
actionview (= 5.2.4.1)
|
||||
activejob (= 5.2.4.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.4.1)
|
||||
actionview (= 5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
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.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
activerecord (5.2.4.1)
|
||||
activemodel (= 5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.4.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
activerecord (= 5.2.4.1)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.4.1)
|
||||
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)
|
||||
ancestry (3.0.7)
|
||||
activerecord (>= 3.2.0)
|
||||
annotate (2.6.5)
|
||||
activerecord (>= 2.3.0)
|
||||
rake (>= 0.8.7)
|
||||
archive-zip (0.12.0)
|
||||
io-like (~> 0.3.0)
|
||||
arel (9.0.0)
|
||||
ast (2.4.0)
|
||||
autoprefixer-rails (9.7.4)
|
||||
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)
|
||||
backport (1.1.2)
|
||||
benchmark (0.1.0)
|
||||
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.7.0)
|
||||
activerecord (>= 3.2.0)
|
||||
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)
|
||||
chartkick (3.3.1)
|
||||
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.2)
|
||||
crass (1.0.6)
|
||||
deep_cloneable (3.0.0)
|
||||
activerecord (>= 3.1.0, < 7)
|
||||
diff-lcs (1.3)
|
||||
diffy (3.3.0)
|
||||
e2mmap (0.1.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)
|
||||
et-orbi (1.2.4)
|
||||
tzinfo
|
||||
execjs (2.7.0)
|
||||
faraday (0.15.4)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.12.2)
|
||||
font-awesome-sass (4.7.0)
|
||||
sass (>= 3.2)
|
||||
fugit (1.4.1)
|
||||
et-orbi (~> 1.1, >= 1.1.8)
|
||||
raabro (~> 1.4)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
grape-entity (0.7.1)
|
||||
activesupport (>= 4.0)
|
||||
multi_json (>= 1.3.2)
|
||||
groupdate (4.1.2)
|
||||
activesupport (>= 4.2)
|
||||
harmonious_dictionary (0.0.1)
|
||||
hashie (3.6.0)
|
||||
htmlentities (4.3.4)
|
||||
i18n (1.8.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
io-like (0.3.1)
|
||||
jaro_winkler (1.5.4)
|
||||
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)
|
||||
kaminari (1.2.0)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.2.0)
|
||||
kaminari-activerecord (= 1.2.0)
|
||||
kaminari-core (= 1.2.0)
|
||||
kaminari-actionview (1.2.0)
|
||||
actionview
|
||||
kaminari-core (= 1.2.0)
|
||||
kaminari-activerecord (1.2.0)
|
||||
activerecord
|
||||
kaminari-core (= 1.2.0)
|
||||
kaminari-core (1.2.0)
|
||||
letter_avatar (0.3.8)
|
||||
listen (3.1.5)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
ruby_dep (~> 1.2)
|
||||
loofah (2.4.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)
|
||||
maruku (0.7.3)
|
||||
method_source (0.9.2)
|
||||
mimemagic (0.3.10)
|
||||
nokogiri (~> 1)
|
||||
rake
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.0)
|
||||
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.8)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.4)
|
||||
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.0)
|
||||
hashie (>= 3.4.6, < 3.7.0)
|
||||
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)
|
||||
parser (2.7.1.1)
|
||||
ast (~> 2.4.0)
|
||||
pdfkit (0.8.4.1)
|
||||
polyamorous (2.3.2)
|
||||
activerecord (>= 5.2.1)
|
||||
popper_js (1.16.0)
|
||||
powerpack (0.1.2)
|
||||
prettier (0.18.2)
|
||||
public_suffix (4.0.3)
|
||||
puma (3.12.2)
|
||||
raabro (1.4.0)
|
||||
rack (2.0.9)
|
||||
rack-cors (1.1.1)
|
||||
rack (>= 2.0.0)
|
||||
rack-mini-profiler (2.0.1)
|
||||
rack (>= 1.2.0)
|
||||
rack-protection (2.0.8.1)
|
||||
rack
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.4.1)
|
||||
actioncable (= 5.2.4.1)
|
||||
actionmailer (= 5.2.4.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
actionview (= 5.2.4.1)
|
||||
activejob (= 5.2.4.1)
|
||||
activemodel (= 5.2.4.1)
|
||||
activerecord (= 5.2.4.1)
|
||||
activestorage (= 5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.4.1)
|
||||
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.1)
|
||||
actionpack (= 5.2.4.1)
|
||||
activesupport (= 5.2.4.1)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rainbow (3.0.0)
|
||||
rake (13.0.1)
|
||||
ransack (2.3.2)
|
||||
activerecord (>= 5.2.1)
|
||||
activesupport (>= 5.2.1)
|
||||
i18n
|
||||
polyamorous (= 2.3.2)
|
||||
rb-fsevent (0.10.3)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rchardet (1.8.0)
|
||||
redcarpet (3.5.0)
|
||||
redis (4.1.3)
|
||||
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)
|
||||
reverse_markdown (1.4.0)
|
||||
nokogiri
|
||||
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.1)
|
||||
rspec-support (~> 3.9.1)
|
||||
rspec-expectations (3.9.0)
|
||||
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.2)
|
||||
rubocop (0.52.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.4.0.2, < 3.0)
|
||||
powerpack (~> 0.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
ruby-ole (1.2.12.2)
|
||||
ruby-progressbar (1.10.1)
|
||||
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.2.1)
|
||||
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.8)
|
||||
connection_pool (~> 2.2, >= 2.2.2)
|
||||
rack (< 2.1.0)
|
||||
rack-protection (>= 1.5.0)
|
||||
redis (>= 3.3.5, < 5)
|
||||
sidekiq-cron (1.2.0)
|
||||
fugit (~> 1.1)
|
||||
sidekiq (>= 4.2.1)
|
||||
simple_form (5.0.2)
|
||||
actionpack (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
simple_xlsx_reader (1.0.4)
|
||||
nokogiri
|
||||
rubyzip
|
||||
sinatra (2.0.8.1)
|
||||
mustermann (~> 1.0)
|
||||
rack (~> 2.0)
|
||||
rack-protection (= 2.0.8.1)
|
||||
tilt (~> 2.0)
|
||||
solargraph (0.38.6)
|
||||
backport (~> 1.1)
|
||||
benchmark
|
||||
bundler (>= 1.17.2)
|
||||
e2mmap
|
||||
jaro_winkler (~> 1.5)
|
||||
maruku (~> 0.7, >= 0.7.3)
|
||||
nokogiri (~> 1.9, >= 1.9.1)
|
||||
parser (~> 2.3)
|
||||
reverse_markdown (~> 1.0, >= 1.0.5)
|
||||
rubocop (~> 0.52)
|
||||
thor (~> 1.0)
|
||||
tilt (~> 2.0)
|
||||
yard (~> 0.9)
|
||||
spreadsheet (1.2.6)
|
||||
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)
|
||||
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.6)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicode-display_width (1.6.1)
|
||||
web-console (3.7.0)
|
||||
actionview (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 5.0)
|
||||
websocket-driver (0.7.1)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.4)
|
||||
wkhtmltopdf-binary (0.12.5.4)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
yard (0.9.24)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
aasm
|
||||
active_decorator
|
||||
acts-as-taggable-on (~> 6.0)
|
||||
acts_as_list
|
||||
ancestry
|
||||
annotate (~> 2.6.0)
|
||||
awesome_print
|
||||
axlsx (~> 3.0.0.pre)
|
||||
axlsx_rails (~> 0.5.2)
|
||||
bootsnap (>= 1.1.0)
|
||||
bootstrap (~> 4.3.1)
|
||||
bulk_insert
|
||||
capybara (>= 2.15, < 4.0)
|
||||
chartkick
|
||||
chinese_pinyin
|
||||
chromedriver-helper
|
||||
deep_cloneable (~> 3.0.0)
|
||||
diffy
|
||||
enumerize
|
||||
faraday (~> 0.15.4)
|
||||
font-awesome-sass (= 4.7.0)
|
||||
grape-entity (~> 0.7.1)
|
||||
groupdate (~> 4.1.0)
|
||||
harmonious_dictionary (~> 0.0.1)
|
||||
jbuilder (~> 2.5)
|
||||
jquery-rails
|
||||
kaminari (~> 1.1, >= 1.1.1)
|
||||
letter_avatar
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
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
|
||||
prettier
|
||||
puma (~> 3.11)
|
||||
rack-cors
|
||||
rack-mini-profiler
|
||||
rails (~> 5.2.0)
|
||||
rails-i18n (~> 5.1)
|
||||
ransack
|
||||
rchardet (~> 1.8)
|
||||
redcarpet (~> 3.4)
|
||||
redis-rails
|
||||
request_store
|
||||
roo-xls
|
||||
rqrcode (~> 0.10.1)
|
||||
rqrcode_png
|
||||
rspec-rails (~> 3.8)
|
||||
rubocop (~> 0.52.0)
|
||||
ruby-ole
|
||||
rubyzip
|
||||
sass-rails (~> 5.0)
|
||||
searchkick
|
||||
selenium-webdriver
|
||||
sidekiq
|
||||
sidekiq-cron (~> 1.1)
|
||||
simple_form
|
||||
simple_xlsx_reader
|
||||
sinatra
|
||||
solargraph (~> 0.38.0)
|
||||
spreadsheet
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
turbolinks (~> 5)
|
||||
tzinfo-data
|
||||
uglifier (>= 1.3.0)
|
||||
web-console (>= 3.3.0)
|
||||
wkhtmltopdf-binary
|
||||
|
||||
BUNDLED WITH
|
||||
2.1.4
|
|
@ -0,0 +1,124 @@
|
|||
木兰宽松许可证, 第2版
|
||||
|
||||
2020年1月 http://license.coscl.org.cn/MulanPSL2
|
||||
|
||||
您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
|
||||
|
||||
0. 定义
|
||||
|
||||
“软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
|
||||
|
||||
“贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
|
||||
|
||||
“贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
|
||||
|
||||
“法人实体” 是指提交贡献的机构及其“关联实体”。
|
||||
|
||||
“关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
|
||||
|
||||
1. 授予版权许可
|
||||
|
||||
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
|
||||
|
||||
2. 授予专利许可
|
||||
|
||||
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
|
||||
|
||||
3. 无商标许可
|
||||
|
||||
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
|
||||
|
||||
4. 分发限制
|
||||
|
||||
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
|
||||
|
||||
5. 免责声明与责任限制
|
||||
|
||||
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
|
||||
|
||||
6. 语言
|
||||
|
||||
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
|
||||
|
||||
条款结束
|
||||
|
||||
如何将木兰宽松许可证,第2版,应用到您的软件
|
||||
|
||||
如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
|
||||
|
||||
1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
|
||||
|
||||
2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
|
||||
|
||||
3, 请将如下声明文本放入每个源文件的头部注释中。
|
||||
|
||||
Copyright (c) [Year] [name of copyright holder]
|
||||
[Software Name] is licensed under Mulan PSL v2.
|
||||
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
You may obtain a copy of Mulan PSL v2 at:
|
||||
http://license.coscl.org.cn/MulanPSL2
|
||||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
See the Mulan PSL v2 for more details.
|
||||
Mulan Permissive Software License,Version 2
|
||||
Mulan Permissive Software License,Version 2 (Mulan PSL v2)
|
||||
|
||||
January 2020 http://license.coscl.org.cn/MulanPSL2
|
||||
|
||||
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
|
||||
|
||||
0. Definition
|
||||
|
||||
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
|
||||
|
||||
Contribution means the copyrightable work licensed by a particular Contributor under this License.
|
||||
|
||||
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
|
||||
|
||||
Legal Entity means the entity making a Contribution and all its Affiliates.
|
||||
|
||||
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
|
||||
|
||||
1. Grant of Copyright License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
|
||||
|
||||
2. Grant of Patent License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
|
||||
|
||||
3. No Trademark License
|
||||
|
||||
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4.
|
||||
|
||||
4. Distribution Restriction
|
||||
|
||||
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
|
||||
|
||||
5. Disclaimer of Warranty and Limitation of Liability
|
||||
|
||||
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
6. Language
|
||||
|
||||
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
|
||||
|
||||
END OF THE TERMS AND CONDITIONS
|
||||
|
||||
How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
|
||||
|
||||
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
|
||||
|
||||
Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
|
||||
Create a file named "LICENSE" which contains the whole context of this License in the first directory of your software package;
|
||||
Attach the statement to the appropriate annotated syntax at the beginning of each source file.
|
||||
Copyright (c) [Year] [name of copyright holder]
|
||||
[Software Name] is licensed under Mulan PSL v2.
|
||||
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
You may obtain a copy of Mulan PSL v2 at:
|
||||
http://license.coscl.org.cn/MulanPSL2
|
||||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
See the Mulan PSL v2 for more details.
|
|
@ -0,0 +1,178 @@
|
|||
Trustie (确实)是一个以大众化协同开发、开放式资源共享、持续性可信评估为核心机理,面向高校创新实践的在线协作平台。
|
||||
|
||||
## 特性
|
||||
|
||||
- 软件创作与生产深度融合的软件开发环境体系结构 软件自由创作和工程生产的高效衔接,适于软件开发中群体智慧的有效汇聚。
|
||||
|
||||
- 构件化协同开发环境的可扩展运行框架多样化工具的集成和联动,形成了强动态扩展能力的平台框架。
|
||||
|
||||
- “互联网即资源库”的全新软件复用模式 成长式软件资源管理系统,实现了分散资源的知识融合、资源的可持续增长和有效复用。
|
||||
|
||||
## 部署
|
||||
|
||||
|
||||
### Depends Versions
|
||||
|
||||
* Ruby 2.4.5
|
||||
|
||||
* Rails ~> 5.2
|
||||
|
||||
* MySql ~> 5.6
|
||||
|
||||
* Redis 5+
|
||||
|
||||
* imagemagick
|
||||
|
||||
### Steps
|
||||
|
||||
#### 1. 克隆稳定版本
|
||||
```
|
||||
git clone -b standalone https://git.trustie.net/jasder/forgeplus.git
|
||||
```
|
||||
|
||||
#### 2. 安装依赖包
|
||||
|
||||
```bash
|
||||
cd forgeplus && bundle install
|
||||
```
|
||||
|
||||
#### 3. 配置初始化文件
|
||||
进入项目根目录执行一下命令:
|
||||
|
||||
```bash
|
||||
cp config/configuration.yml.example config/configuration.yml
|
||||
cp config/database.yml.example config/database.yml
|
||||
touch config/redis.yml
|
||||
touch config/elasticsearch.yml
|
||||
```
|
||||
|
||||
#### 4. 配置数据库
|
||||
数据库配置信息请查看/config/database.yml文件,
|
||||
项目默认采用mysql数据库, 如需更改,请自行修改配置信息,
|
||||
默认配置如下:
|
||||
|
||||
```bash
|
||||
default: &default
|
||||
adapter: mysql2
|
||||
host: 127.0.0.1
|
||||
encoding: utf8
|
||||
username: root
|
||||
password: 123456
|
||||
```
|
||||
|
||||
#### 5. 配置gitea服务(可选)
|
||||
**如需要部署自己的gitea平台,请参考gitea官方平台:https://docs.gitea.io/zh-cn/install-from-binary/**
|
||||
|
||||
**因目前gitea平台api受限,暂时推荐从forge平台获取gitea部署文件进行部署:https://forgeplus.trustie.net/projects/Trustie/gitea-binary**
|
||||
|
||||
**配置gitea服务步骤**
|
||||
1. 部署gitea服务,并注册root账户
|
||||
2. 修改forge平台的 config/configuration.yml中的gitea服务指向地址,如:
|
||||
|
||||
```ruby
|
||||
gitea:
|
||||
access_key_id: 'root'
|
||||
access_key_secret: 'password'
|
||||
domain: 'http://www.gitea.example.com'
|
||||
base_url: '/api/v1'
|
||||
```
|
||||
|
||||
#### 6. 安装redis环境
|
||||
**请自行搜索各平台如何安装部署redis环境**
|
||||
|
||||
#### 7. 安装imagemagick插件
|
||||
- Mac OS X
|
||||
```bash
|
||||
brew install imagemagick ghostscript
|
||||
```
|
||||
|
||||
- Linux
|
||||
```bash
|
||||
sudo apt-get install -y imagemagick
|
||||
```
|
||||
|
||||
#### 8. 创建数据库
|
||||
**开发环境为development, 生成环境为production**
|
||||
```bash
|
||||
rails db:create RAILS_ENV=development
|
||||
```
|
||||
|
||||
#### 9. 导入数据表结构
|
||||
|
||||
```bash
|
||||
bundle exec rake sync_table_structure:import_csv
|
||||
```
|
||||
|
||||
#### 10. 执行migrate迁移文件
|
||||
**开发环境为development, 生成环境为production**
|
||||
```bash
|
||||
rails db:migrate RAILS_ENV=development
|
||||
```
|
||||
|
||||
#### 11. clone前端代码
|
||||
**将前端代码克隆到public/react目录下,目录结构应该是: public/react/build**
|
||||
```bash
|
||||
git clone -b standalone https://git.trustie.net/jasder/build.git
|
||||
```
|
||||
|
||||
#### 12. 启动redis(此处已mac系统为例)
|
||||
```bash
|
||||
redis-server&
|
||||
```
|
||||
|
||||
#### 13. 启动sidekiq
|
||||
**开发环境为development, 生成环境为production**
|
||||
```bash
|
||||
bundle exec sidekiq -C config/sidekiq.yml -e production -d
|
||||
```
|
||||
|
||||
#### 14. 启动rails服务
|
||||
```bash
|
||||
rails s
|
||||
```
|
||||
|
||||
#### 15. 浏览器访问
|
||||
在浏览器中输入如下地址访问:
|
||||
```bash
|
||||
http://localhost:3000/
|
||||
```
|
||||
|
||||
#### 16. 其他说明
|
||||
通过页面注册都第一个用户为平台管理员用户
|
||||
|
||||
## 页面展示
|
||||
|
||||
- 代码库
|
||||
|
||||

|
||||
|
||||
|
||||
- 任务管理
|
||||

|
||||
|
||||
- 任务查看
|
||||
|
||||

|
||||
|
||||
- 任务指派
|
||||
|
||||

|
||||
|
||||
- 里程碑
|
||||
|
||||

|
||||
|
||||
### API
|
||||
- [API文档](https://forgeplus.trustie.net/docs/api)
|
||||
- [API](showdoc.com.cn)
|
||||
账号:forgeplus@admin.com 密码:forge123
|
||||
|
||||
## 贡献代码
|
||||
|
||||
1. Fork 项目
|
||||
2. 创建本地分支(git checkout -b my-new-feature)
|
||||
3. 提交更改 (git commit -am 'Add some feature')
|
||||
4. 推送到分支 (git push origin my-new-feature)
|
||||
5. 向源项目的 **develop** 分支发起 Pull Request
|
||||
|
||||
## License
|
|
@ -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
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,3 @@
|
|||
//= link_tree ../images
|
||||
//= link_directory ../javascripts .js
|
||||
//= link_directory ../stylesheets .css
|
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,136 @@
|
|||
//= 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 () {
|
||||
});
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
|
||||
$('.logo-item-left').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 {
|
||||
}
|
||||
});
|
||||
|
||||
$('.attachment-item-left').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 {
|
||||
}
|
||||
});
|
||||
})
|
|
@ -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', {});
|
||||
}
|
||||
})
|
|
@ -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);
|
||||
})
|
||||
});
|
|
@ -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,803 @@
|
|||
$(document).on('turbolinks:load', function(){
|
||||
if ($('body.admins-competition-settings-index-page').length > 0) {
|
||||
|
||||
var dateOptions = {
|
||||
autoclose: true,
|
||||
language: 'zh-CN',
|
||||
format: 'yyyy-mm-dd',
|
||||
startDate: '2017-04-01'
|
||||
};
|
||||
|
||||
var timeOptions = {
|
||||
autoclose: 1,
|
||||
language: 'zh-CN',
|
||||
format: 'yyyy-mm-dd hh:ii',
|
||||
minuteStep: 30
|
||||
};
|
||||
|
||||
var defineDateRangeSelect = function (element) {
|
||||
var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, dateOptions);
|
||||
$(element).datepicker(options);
|
||||
|
||||
$(element).find('.start-date').datepicker().on('changeDate', function (e) {
|
||||
$(element).find('.end-date').datepicker('setStartDate', e.date);
|
||||
});
|
||||
};
|
||||
$(".competition-start-end-date .start-date").datetimepicker(timeOptions);
|
||||
|
||||
$(".competition-start-end-date .end-date").datetimepicker(timeOptions);
|
||||
|
||||
$(".nav-setting-form .enroll_end_time").datetimepicker(timeOptions);
|
||||
|
||||
$(".stage-update-form .section-start-time").datetimepicker(timeOptions);
|
||||
$(".stage-update-form .section-end-time").datetimepicker(timeOptions);
|
||||
|
||||
defineDateRangeSelect('.teaching-mode-date');
|
||||
// defineTimeRangeSelect('.competition-start-end-date');
|
||||
|
||||
var $basicForm = $('form.basic-setting-form');
|
||||
|
||||
$basicForm.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
name: "required",
|
||||
subTitle: "required",
|
||||
startTime: "required",
|
||||
endTime: "required",
|
||||
mode: "required",
|
||||
identifier: "required"
|
||||
}
|
||||
});
|
||||
|
||||
// 保存按钮
|
||||
$basicForm.on('click', ".submit-btn", function () {
|
||||
$basicForm.find('.submit-btn').attr('disabled', 'disabled');
|
||||
$basicForm.find('.error').html('');
|
||||
var valid = $basicForm.valid();
|
||||
|
||||
if ($("input[name='mode']:checked").val() == 2) {
|
||||
var $courseId = $("input[name='course_id']");
|
||||
if ($courseId.val() === undefined || $courseId.val().length === 0) {
|
||||
$courseId.addClass('danger text-danger');
|
||||
valid = false;
|
||||
} else {
|
||||
$courseId.removeClass('danger text-danger');
|
||||
}
|
||||
} else if ($("input[name='mode']:checked").val() == 3) {
|
||||
var $techStartTime = $("input[name='teach_start_time']");
|
||||
var $techEndTime = $("input[name='teach_end_time']");
|
||||
if ($techStartTime.val() === undefined || $techStartTime.val().length === 0) {
|
||||
$techStartTime.addClass('danger text-danger');
|
||||
valid = false;
|
||||
} else {
|
||||
$techStartTime.removeClass('danger text-danger');
|
||||
}
|
||||
|
||||
if ($techEndTime.val() === undefined || $techEndTime.val().length === 0) {
|
||||
$techEndTime.addClass('danger text-danger');
|
||||
valid = false;
|
||||
} else {
|
||||
$techEndTime.removeClass('danger text-danger');
|
||||
}
|
||||
} else {
|
||||
$("input[name='course_id']").removeClass('danger text-danger');
|
||||
$("input[name='teach_start_time']").removeClass('danger text-danger');
|
||||
$("input[name='teach_end_time']").removeClass('danger text-danger');
|
||||
}
|
||||
|
||||
if (!valid) return;
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: $basicForm.attr('action'),
|
||||
data: new FormData($basicForm[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (data) {
|
||||
$.notify({message: '保存成功'});
|
||||
// window.location.reload();
|
||||
},
|
||||
error: function (res) {
|
||||
var data = res.responseJSON;
|
||||
$basicForm.find('.error').html(data.message);
|
||||
},
|
||||
complete: function () {
|
||||
$basicForm.find('.submit-btn').attr('disabled', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var selectOptions = {
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请输入要添加的单位名称',
|
||||
multiple: 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 || item.text;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
return item.name || item.text;
|
||||
}
|
||||
};
|
||||
|
||||
$('.sponsor-select').select2(selectOptions);
|
||||
$('.allow-school-select').select2(selectOptions);
|
||||
|
||||
$('.manager-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请输入要添加的管理员姓名',
|
||||
multiple: true,
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/admins/users',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { keyword: params.term };
|
||||
},
|
||||
processResults: function(data){
|
||||
return { results: data.users }
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return $("<div class='row px-0'><span class='col-3'>" + item.real_name + "</span><span class='col-5 font-12'>" + item.school_name + "</span><span class='col-4 font-12'>" + item.hidden_phone + "</span></div>");
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
}
|
||||
return item.real_name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 排行榜
|
||||
//链接
|
||||
$(".nav-setting-form").on("click",".add_linkBtn",function () {
|
||||
var length=$(".nav-setting-form").find(".linkFormItem").length + 1;
|
||||
var html='<div class="row mt-2 align-items-center linkFormItem">\n' +
|
||||
' <div class="col-1 text-right">\n' +
|
||||
' <label class="checkbox checkbox-primary mt-1">\n' +
|
||||
' <input type="checkbox" name="navbar[][hidden]" value="0" hidden class="font-16" checked="checked">\n' +
|
||||
' <input type="checkbox" value="0" class="font-16 module_hidden" checked="checked">\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="col-md-label mt-1"><input type="hidden" value="md" name="navbar[][module_type]">\n' +
|
||||
' <input type="text" name="navbar[][name]" value="" class="form-control" placeholder="模块名称"></div>\n' +
|
||||
' <div class="col-md-1 mt-1"><input type="text" name="navbar[][position]" value="" class="form-control" placeholder="位置"></div>\n' +
|
||||
' <div class="col-md-3 mt-1"><input type="text" name="navbar[][url]" value="" class="form-control" placeholder="请输入资料下载地址"></div>\n' +
|
||||
' <a class="mt-1 btn btn-primary waves-effect waves-light btn-xs setBtn_s add_linkBtn" href="javascript:void(0)">+</a>\n' +
|
||||
' <a class="mt-1 btn btn-icon waves-effect btn-default waves-light setBtn_s ml10 del_linkBtn" href="javascript:void(0)">×</a>\n' +
|
||||
' </div>';
|
||||
$(this).parents(".linkFormItem").after(html);
|
||||
});
|
||||
|
||||
$(".nav-setting-form").on("click", ".del_linkBtn", function () {
|
||||
$(this).parents(".linkFormItem").remove();
|
||||
});
|
||||
|
||||
//有关报名要求
|
||||
$(".addRequireBtn").on("click",function () {
|
||||
var length=$("#requireForm").find(".requireForm_item").length + 1;
|
||||
var html='<div class="row mt-2 mb-4 requireForm_item">\n' +
|
||||
' <div class="col-1 text-right"> </div>\n' +
|
||||
' <div class="col-1 text-left mt-1">\n' +
|
||||
' <input type="text" class="form-control" name="competition_staffs[][minimum]" value="0">\n' +
|
||||
' </div>\n' +
|
||||
' <span class="mt-2">~</span>\n' +
|
||||
' <div class="col-1 mt-1">\n' +
|
||||
' <input type="text" class="form-control" name="competition_staffs[][maximum]" value="1">\n' +
|
||||
' </div>\n' +
|
||||
' <span class="mt-2">人</span>\n' +
|
||||
' <div class="col-2 mt-1">\n' +
|
||||
' <select class="form-control" name="competition_staffs[][category]">\n' +
|
||||
' <option value="student">学生</option>\n' +
|
||||
' <option value="teacher">教师</option>\n' +
|
||||
' </select>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="col-2 mt-1">\n' +
|
||||
' <label class="radio checkbox-primary mt-1" value="require_'+length+'_1">\n' +
|
||||
' <input id="require_'+length+'_1" class="mutiple-limited-radio" value="false" checked name="competition_staffs[][mutiple_limited]" type="checkbox">\n' +
|
||||
' <label for="require_'+length+'_1">可多次报名</label>\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="col-2 mt-1">\n' +
|
||||
' <label class="radio checkbox-primary mt-1" value="require_'+length+'_2">\n' +
|
||||
' <input id="require_'+length+'_2" class="mutiple-limited-radio" value="true" name="competition_staffs[][mutiple_limited]" type="checkbox">\n' +
|
||||
' <label for="require_'+length+'_2">不可多次报名</label>\n' +
|
||||
' </label>\n' +
|
||||
' <a href="javascript:void(0)" class="ml20 delRequrieBtn">\n' +
|
||||
' <i class="fa fa-times-circle font-20 color-grey-c"></i>\n' +
|
||||
' </a>\n' +
|
||||
' </div>\n' +
|
||||
' </div>';
|
||||
$("#requireForm").append(html);
|
||||
});
|
||||
|
||||
$("#requireForm").on("click",".delRequrieBtn",function () {
|
||||
$(this).parents(".requireForm_item").remove();
|
||||
});
|
||||
|
||||
$('.nav-setting-form').on('click', '.module_hidden', function(){
|
||||
var checkEle = $(this);
|
||||
if (checkEle.is(':checked')) {
|
||||
checkEle.prev().val(0);
|
||||
} else {
|
||||
checkEle.prev().val(1);
|
||||
}
|
||||
});
|
||||
|
||||
$('.competition-staff-settings').on('click', '.mutiple-limited-radio', function(){
|
||||
var radio = $(this);
|
||||
if (radio.is(':checked')) {
|
||||
radio.parent().parent().siblings().find('.mutiple-limited-radio').attr('checked', false)
|
||||
} else {
|
||||
radio.parent().parent().siblings().find('.mutiple-limited-radio').attr('checked', true)
|
||||
}
|
||||
});
|
||||
|
||||
var $navForm = $('form.nav-setting-form');
|
||||
$navForm.on('click', ".submit-btn", function () {
|
||||
$navForm.find('.submit-btn').attr('disabled', 'disabled');
|
||||
$navForm.find('.error').html('');
|
||||
var valid = $navForm.valid();
|
||||
|
||||
if (!valid) return;
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: $navForm.attr('action'),
|
||||
data: new FormData($navForm[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (data) {
|
||||
$.notify({message: '保存成功'});
|
||||
// window.location.reload();
|
||||
},
|
||||
error: function (res) {
|
||||
var data = res.responseJSON;
|
||||
$navForm.find('.error').html(data.message);
|
||||
},
|
||||
complete: function () {
|
||||
$navForm.find('.submit-btn').attr('disabled', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 排行榜设置
|
||||
//删除小阶段
|
||||
$("#large_panel").on("click",".small_panel_item_del",function () {
|
||||
var list = $(this).parents(".small_panel");
|
||||
$(this).parents(".small_panel_item").remove();
|
||||
|
||||
for(var i=0;i < $(list).find(".subName").length;i++){
|
||||
console.log(i);
|
||||
$(list).find(".subName").eq(i).html("第"+parseInt(i+1)+"阶段");
|
||||
}
|
||||
});
|
||||
|
||||
// $('form.stage-update-form').validate({
|
||||
// errorElement: 'span',
|
||||
// errorClass: 'danger text-danger',
|
||||
// rules: {
|
||||
// stage_name: "required",
|
||||
// "stage[][start_time]": "required",
|
||||
// "stage[][end_time]": "required",
|
||||
// "stage[][mission_count]": {
|
||||
// required: true,
|
||||
// min: 1
|
||||
// },
|
||||
// "stage[][entry]": {
|
||||
// required: true,
|
||||
// min: 1
|
||||
// },
|
||||
// score_rate: {
|
||||
// required: true,
|
||||
// range: [0, 100]
|
||||
// }
|
||||
// },
|
||||
// messages: {
|
||||
// "stage[][mission_count]": {
|
||||
// min: ">=1"
|
||||
// },
|
||||
// "stage[][entry]": {
|
||||
// min: ">=1"
|
||||
// },
|
||||
// }
|
||||
// });
|
||||
|
||||
$('.competition-chart-setting').on('click', ".update-stage", function () {
|
||||
var updateForm = $(this).parents("form");
|
||||
$(this).attr('disabled', 'disabled');
|
||||
updateForm.find('.error').html('');
|
||||
// var valid = updateForm.valid();
|
||||
var valid = true;
|
||||
|
||||
var $stageName = updateForm.find('input[name="stage_name"]');
|
||||
if($stageName.val() === undefined || $stageName.val().length === 0){
|
||||
$stageName.addClass('danger text-danger');
|
||||
valid = false;
|
||||
} else {
|
||||
$stageName.removeClass('danger text-danger');
|
||||
}
|
||||
|
||||
var $scoreRate = updateForm.find('input[name="score_rate"]');
|
||||
if($scoreRate.val() === undefined || $scoreRate.val().length === 0){
|
||||
$scoreRate.addClass('danger text-danger');
|
||||
valid = false;
|
||||
} else if (parseInt($scoreRate.val()) > 100 || parseInt($scoreRate.val()) < 0) {
|
||||
$scoreRate.addClass('danger text-danger');
|
||||
$scoreRate.after('<span class="danger text-danger">0-100之间的数值</span>');
|
||||
valid = false;
|
||||
} else {
|
||||
$scoreRate.removeClass('danger text-danger');
|
||||
$scoreRate.siblings().remove();
|
||||
}
|
||||
|
||||
updateForm.find('input[name="stage[][start_time]"]').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');
|
||||
}
|
||||
});
|
||||
|
||||
updateForm.find('input[name="stage[][end_time]"]').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');
|
||||
}
|
||||
});
|
||||
|
||||
updateForm.find('input[name="stage[][mission_count]"]').each(function(i, e){
|
||||
var $ele = $(e);
|
||||
var $entry = updateForm.find('input[name="stage[][entry]"]').eq(i);
|
||||
if($ele.val() === undefined || $ele.val().length === 0){
|
||||
$ele.addClass('danger text-danger');
|
||||
valid = false;
|
||||
} else if (parseInt($ele.val()) < 1) {
|
||||
$ele.addClass('danger text-danger');
|
||||
$ele.after('<span class="danger text-danger">大于等于1</span>');
|
||||
valid = false;
|
||||
} else if (parseInt($ele.val()) > parseInt($entry.val())) {
|
||||
$ele.addClass('danger text-danger');
|
||||
$ele.after('<span class="danger text-danger">不能大于总任务数</span>');
|
||||
valid = false;
|
||||
} else {
|
||||
$ele.removeClass('danger text-danger');
|
||||
$ele.siblings().remove();
|
||||
}
|
||||
});
|
||||
|
||||
updateForm.find('input[name="stage[][entry]"]').each(function(_, e){
|
||||
var $ele = $(e);
|
||||
if($ele.val() === undefined || $ele.val().length === 0){
|
||||
$ele.addClass('danger text-danger');
|
||||
valid = false;
|
||||
} else if (parseInt($ele.val()) < 1) {
|
||||
$ele.addClass('danger text-danger');
|
||||
$ele.after('<span class="danger text-danger">大于等于1</span>');
|
||||
valid = false;
|
||||
} else {
|
||||
$ele.removeClass('danger text-danger');
|
||||
$ele.siblings().remove();
|
||||
}
|
||||
});
|
||||
|
||||
updateForm.find('input[name="stage[][identifiers][]"]').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;
|
||||
|
||||
updateForm.find('input[name="stage[][mission_count]"]').each(function(_, e){
|
||||
var $missionCount = $(e);
|
||||
var $entryCount = $(e).parents("div.row").find('input[name="stage[][mission_count]"]');
|
||||
if(parseInt($missionCount.val()) > parseInt($entryCount.val()) ){
|
||||
$missionCount.addClass('danger text-danger');
|
||||
$missionCount.after('<span class="danger text-danger">不能大于总任务数</span>');
|
||||
valid = false;
|
||||
} else {
|
||||
$missionCount.removeClass('danger text-danger');
|
||||
$missionCount.siblings().remove();
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
url: updateForm.attr('action'),
|
||||
data: new FormData(updateForm[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (data) {
|
||||
$.notify({message: '保存成功'});
|
||||
window.location.reload();
|
||||
},
|
||||
error: function (res) {
|
||||
var data = res.responseJSON;
|
||||
$navForm.find('.error').html(data.message);
|
||||
},
|
||||
complete: function () {
|
||||
$navForm.find('.submit-btn').attr('disabled', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".competition-chart-stages").on("click", ".add-new-tab", function () {
|
||||
if($(".new-stage-form").length > 0){
|
||||
alert("请先保存上一个tab");
|
||||
} else {
|
||||
var count = parseInt($("#large_panel").find(".large_panel_part").length)+1;
|
||||
var html = '<form class="stage-update-form new-stage-form flex-1" action="/admins/competitions/'+$(this).attr("data-competition-id")+'/competition_stages" accept-charset="UTF-8" data-remote="true" method="post">' +
|
||||
'<div class="large_panel_part" attr_line="'+count+'"><div class="row d-flex mt-3">\n' +
|
||||
' <span class="col-1 mt-2">tab标题</span>\n' +
|
||||
' <div class="col-2 no_padding">\n' +
|
||||
' <input type="text" class="form-control" name="stage_name"/>\n' +
|
||||
' </div>\n' +
|
||||
' <span class="col-1 text-right mt-2 no_padding">总排行榜占比:</span>\n' +
|
||||
' <div class="col-1 no_padding">\n' +
|
||||
' <input type="number" class="form-control" name="score_rate" value="100"/>\n' +
|
||||
' </div><span class=" mt-2">%</span>\n' +
|
||||
' <div class="flex-1">\n' +
|
||||
' <a href="javascript:void(0)"class="btn btn-outline-primary export-action ml20 add-task-sub">新增子阶段</a>\n' +
|
||||
' </div>\n' +
|
||||
' <a href="javascript:void(0)" class="btn btn-default ml20" onclick="Del_tab(this)">删除</a>\n' +
|
||||
' <a href="javascript:void(0)" class="btn btn-outline-primary update-stage export-action ml20">保存</a>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="small_panel_'+count+'" class="small_panel">\n' +
|
||||
' <div class="row d-flex small_panel_item" attr_line="sub_new_new" count="1">\n' +
|
||||
' <span class="mt-2 subName mr10">第1阶段</span>\n' +
|
||||
' <div class="flex-1">\n' +
|
||||
' <div class="row">\n' +
|
||||
' <div class="row col-6"><span class="mt-2 ml20">有效时间:</span>\n' +
|
||||
' <div class="col-4 no_padding">\n' +
|
||||
' <input type="text" name="stage[][start_time]" id="stage__start_time" value="" autocomplete="off" class="section-start-time form-control" placeholder="有效开始时间">\n' +
|
||||
' </div>\n' +
|
||||
' <span class="mt-2">~</span>\n' +
|
||||
' <div class="col-4 no_padding ">\n' +
|
||||
' <input type="text" name="stage[][end_time]" id="stage__end_time" value="" autocomplete="off" class="section-end-time form-control" placeholder="有效结束时间">\n' +
|
||||
' </div></div>\n' +
|
||||
' <div class="row col-3"><span class="col-4 text-right mt-2 no_padding">总任务数:</span>\n' +
|
||||
' <div class="col-6 no_padding ">\n' +
|
||||
' <input type="number" class="form-control" onchange="change_total(this)" value="3" name="stage[][entry]">\n' +
|
||||
' </div></div>\n' +
|
||||
' <div class="row col-3"><span class="col-4 text-right mt-2 no_padding">成绩来源:</span>\n' +
|
||||
' <div class="col-6 no_padding ">\n' +
|
||||
' <select class="form-control" name="stage[][score_source]">\n' +
|
||||
' <option value="0">经验值</option>\n' +
|
||||
' <option value="1">预测准确率</option>\n' +
|
||||
' </select>\n' +
|
||||
' </div></div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="row mt-2" id="task_Input_sub_new_new">\n' +
|
||||
' <div class="col-4 row task_Input_div">\n' +
|
||||
' <span class="col-4 text-right mt-3 no_padding mr10">任务1</span>\n' +
|
||||
' <div class="col-6 no_padding">\n' +
|
||||
' <input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="col-4 row task_Input_div">\n' +
|
||||
' <span class="col-4 text-right mt-3 no_padding mr10">任务2</span>\n' +
|
||||
' <div class="col-6 no_padding">\n' +
|
||||
' <input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="col-4 row task_Input_div">\n' +
|
||||
' <span class="col-4 text-right mt-3 no_padding mr10">任务3</span>\n' +
|
||||
' <div class="col-6 no_padding">\n' +
|
||||
' <input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' <span>\n' +
|
||||
' <a href="javascript:void(0)" class="btn btn-default ml20 small_panel_item_del">删除</a>\n' +
|
||||
' </span>\n' +
|
||||
' </div>\n' +
|
||||
'</div></div></form>';
|
||||
$("#large_panel").append(html);
|
||||
|
||||
$(".stage-update-form .section-start-time").datetimepicker(timeOptions);
|
||||
$(".stage-update-form .section-end-time").datetimepicker(timeOptions);
|
||||
}
|
||||
});
|
||||
|
||||
//新增子阶段
|
||||
$(".competition-chart-stages").on("click", ".add-task-sub", function () {
|
||||
var index = $(this).parents(".large_panel_part").attr("attr_line");
|
||||
var count= 0;
|
||||
|
||||
console.log("sdfsf");
|
||||
console.log($("#small_panel_"+index).find(".small_panel_item").length > 0);
|
||||
|
||||
if($("#small_panel_"+index).find(".small_panel_item").length > 0){
|
||||
count = parseInt($("#small_panel_"+index).find(".small_panel_item").last().attr("count")) + 1;
|
||||
|
||||
console.log($("#small_panel_"+index).find(".small_panel_item").last().attr("count"));
|
||||
}else{
|
||||
count = 1;
|
||||
}
|
||||
|
||||
var showCount=parseInt($("#small_panel_"+index).find(".small_panel_item").length) + 1;
|
||||
|
||||
|
||||
var html='<div class="row d-flex small_panel_item" attr_line="sub_'+index+'_'+count+'" count="'+count+'">\n' +
|
||||
' <span class="mr10 mt-2 subName">第'+showCount+'阶段</span>\n' +
|
||||
' <div class="flex-1">\n' +
|
||||
' <div class="row">\n' +
|
||||
' <div class="row col-6"><span class="mt-2 ml20 mr10">有效时间:</span>\n' +
|
||||
' <div class="col-4 no_padding ">\n' +
|
||||
' <input type="text" name="stage[][start_time]" id="stage__start_time" value="" autocomplete="off" class="section-start-time form-control" placeholder="有效开始时间">\n' +
|
||||
' </div>\n' +
|
||||
' <span class="mt-2">~</span>\n' +
|
||||
' <div class="col-4 no_padding ">\n' +
|
||||
' <input type="text" name="stage[][end_time]" id="stage__end_time" value="" autocomplete="off" class="section-end-time form-control" placeholder="有效结束时间">\n' +
|
||||
' </div></div>\n' +
|
||||
' <div class="row col-3"><span class="col-4 text-right mt-2 no_padding mr10">总任务数:</span>\n' +
|
||||
' <div class="col-6 no_padding ">\n' +
|
||||
' <input type="number" class="form-control" onchange="change_total(this)" value="3" name="stage[][entry]">\n' +
|
||||
' </div></div>\n' +
|
||||
' <div class="row col-3"><span class="col-4 mr10 text-right mt-2 no_padding">成绩来源:</span>\n' +
|
||||
' <div class="col-6 no_padding ">\n' +
|
||||
' <select class="form-control" name="stage[][score_source]">\n' +
|
||||
' <option value="0">经验值</option>\n' +
|
||||
' <option value="1">预测准确率</option>\n' +
|
||||
' </select>\n' +
|
||||
' </div></div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="row mt-2" id="task_Input_sub_'+index+'_'+count+'">\n'+
|
||||
' <div class="col-4 row task_Input_div">\n' +
|
||||
' <span class="col-4 text-right mt-3 no_padding mr10">任务1</span>\n' +
|
||||
' <div class="col-6 no_padding">\n' +
|
||||
' <input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="col-4 row task_Input_div">\n' +
|
||||
' <span class="col-4 text-right mt-3 no_padding mr10">任务2</span>\n' +
|
||||
' <div class="col-6 no_padding">\n' +
|
||||
' <input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="col-4 row task_Input_div">\n' +
|
||||
' <span class="col-4 text-right mt-3 no_padding mr10">任务3</span>\n' +
|
||||
' <div class="col-6 no_padding">\n' +
|
||||
' <input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' <span>\n' +
|
||||
' <a href="javascript:void(0)" class="btn btn-default ml20 small_panel_item_del">删除</a>\n' +
|
||||
' </span>\n' +
|
||||
' </div>';
|
||||
$("#small_panel_"+index).append(html);
|
||||
|
||||
$(".stage-update-form .section-start-time").datetimepicker(timeOptions);
|
||||
$(".stage-update-form .section-end-time").datetimepicker(timeOptions);
|
||||
});
|
||||
|
||||
// 奖项设置
|
||||
var $prizeContainer = $('#competition-prize-card');
|
||||
var competitionId = $prizeContainer.data('id');
|
||||
$(document).on('prize.save.success', function(){
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: '/admins/competitions/' + competitionId + '/competition_prizes',
|
||||
dataType: 'script'
|
||||
})
|
||||
});
|
||||
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
var $imageElement;
|
||||
if(data.suffix === '_member'){
|
||||
$imageElement = $('.prize-member-image-' + data.source_id);
|
||||
} else if(data.suffix === '_team'){
|
||||
$imageElement = $('.prize-team-image-' + data.source_id);
|
||||
} else {
|
||||
$imageElement = $('.prize-teacher-image-' + data.source_id);
|
||||
}
|
||||
$imageElement.attr('src', data.url);
|
||||
$imageElement.show();
|
||||
$imageElement.next().html('重新上传');
|
||||
})
|
||||
|
||||
// 生成获奖记录
|
||||
$prizeContainer.on('click', '.generate-prize-user-action', function(){
|
||||
var $link = $(this);
|
||||
|
||||
var generateRequest = function(){
|
||||
return $.ajax({
|
||||
method: 'POST',
|
||||
url: '/admins/competitions/' + competitionId + '/competition_prize_users',
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
if(data && data.status === 0){
|
||||
show_success_flash();
|
||||
$link.remove();
|
||||
} else {
|
||||
showErrorNotify(data.message);
|
||||
}
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
showErrorNotify(data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
customConfirm({
|
||||
content: '确认生成吗?',
|
||||
ok: function () {
|
||||
customLoading({
|
||||
ajax: generateRequest
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
$(document).unbind('prize.save.success');
|
||||
}
|
||||
});
|
||||
|
||||
//添加主办方或者开放范围
|
||||
function addSponsor(item){
|
||||
var html='<div class="sponsor_label">\n' +
|
||||
' <input type="hidden" value="school_id" />\n' +
|
||||
' <span>caicai</span>\n' +
|
||||
' <a href="javascript:void(0)" onclick="del_sponsor(this)">×</a>\n' +
|
||||
' </div>';
|
||||
$(item).parents(".sponsorPanel").append(html);
|
||||
}
|
||||
//删除
|
||||
function del_sponsor(item){
|
||||
$(item).parents(".sponsor_label").remove();
|
||||
}
|
||||
|
||||
// 小阶段修改总任务数
|
||||
function change_total(item) {
|
||||
var count=parseInt($(item).val());
|
||||
|
||||
|
||||
var index = $(item).parents(".small_panel_item").attr("attr_line");
|
||||
var indexLarge = $(item).parents(".large_panel_part").attr("attr_line");
|
||||
console.log(indexLarge);
|
||||
console.log(index);
|
||||
|
||||
var divCount=parseInt($("#task_Input_"+index).find(".task_Input_div").length);
|
||||
|
||||
|
||||
var html = "";
|
||||
if(count > divCount){
|
||||
for(var i=0;i < count-divCount ;i++){
|
||||
html+='<div class="col-4 row task_Input_div"><span class="col-4 text-right mt-3 no_padding mr10">任务'+(divCount+i+1)+'</span>\n' +
|
||||
'<div class="col-6 no_padding">\n' +
|
||||
'<input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
'</div>\n' +
|
||||
'</div>';
|
||||
}
|
||||
$("#task_Input_"+index).append(html);
|
||||
}else{
|
||||
var delCount = divCount - count ;
|
||||
console.log(divCount);
|
||||
console.log(count);
|
||||
var _max=parseInt($("#task_Input_"+index).find(".task_Input_div:last").index());
|
||||
|
||||
console.log(_max);
|
||||
var _get= _max - delCount;
|
||||
|
||||
console.log(_get);
|
||||
if(count == 0){
|
||||
$("#task_Input_"+index).empty();
|
||||
}else{
|
||||
$("#task_Input_"+index).find(".task_Input_div:gt("+_get+")").remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//删除tab
|
||||
function Del_tab(item) {
|
||||
$(item).parents(".large_panel_part").remove();
|
||||
}
|
||||
//新增tab
|
||||
function addNewTab(competition_id) {
|
||||
if($(".new-stage-form").length > 0){
|
||||
alert("请先保存上一个tab");
|
||||
} else {
|
||||
var count = parseInt($("#large_panel").find(".large_panel_part").length)+1;
|
||||
var html = '<form class="stage-update-form new-stage-form flex-1" action="/admins/competitions/'+competition_id+'/competition_stages" accept-charset="UTF-8" data-remote="true" method="post">' +
|
||||
'<div class="large_panel_part" attr_line="'+count+'"><div class="row d-flex mt-3">\n' +
|
||||
' <span class="col-1 mt-2">tab标题</span>\n' +
|
||||
' <div class="col-2 no_padding">\n' +
|
||||
' <input type="text" class="form-control" name="stage_name"/>\n' +
|
||||
' </div>\n' +
|
||||
' <span class="col-1 text-right mt-2 no_padding">总排行榜占比:</span>\n' +
|
||||
' <div class="col-1 no_padding">\n' +
|
||||
' <input type="number" class="form-control" name="score_rate" value="100"/>\n' +
|
||||
' </div><span class=" mt-2">%</span>\n' +
|
||||
' <div class="flex-1">\n' +
|
||||
' <a href="javascript:void(0)"class="btn btn-outline-primary export-action ml20 add-task-sub">新增子阶段</a>\n' +
|
||||
' </div>\n' +
|
||||
' <a href="javascript:void(0)" class="btn btn-default ml20" onclick="Del_tab(this)">删除</a>\n' +
|
||||
' <a href="javascript:void(0)" class="btn btn-outline-primary update-stage export-action ml20">保存</a>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="small_panel_'+count+'" class="small_panel">\n' +
|
||||
' <div class="row d-flex small_panel_item" attr_line="sub_new_new" count="1">\n' +
|
||||
' <span class="mt-2 subName mr10">第1阶段</span>\n' +
|
||||
' <div class="flex-1">\n' +
|
||||
' <div class="row">\n' +
|
||||
' <div class="row col-6"><span class="mt-2 ml20 mr10">有效时间:</span>\n' +
|
||||
' <div class="col-4 no_padding ">\n' +
|
||||
' <input type="text" name="stage[][start_time]" id="stage__start_time" value="" autocomplete="off" class="section-start-time form-control" placeholder="有效开始时间">\n' +
|
||||
' </div>\n' +
|
||||
' <span class="mt-2">~</span>\n' +
|
||||
' <div class="col-4 no_padding input_middle">\n' +
|
||||
' <input type="text" name="stage[][end_time]" id="stage__end_time" value="" autocomplete="off" class="section-end-time form-control" placeholder="有效结束时间">\n' +
|
||||
' </div></div>\n' +
|
||||
' <div class="row col-3"><span class="col-4 text-right mt-2 no_padding mr10">总任务数:</span>\n' +
|
||||
' <div class="col-6 no_padding ">\n' +
|
||||
' <input type="number" class="form-control" onchange="change_total(this)" value="3" name="stage[][entry]">\n' +
|
||||
' </div></div>\n' +
|
||||
' <div class="row col-3"><span class="col-4 text-right mt-2 no_padding mr10">成绩来源:</span>\n' +
|
||||
' <div class="col-6 no_padding ">\n' +
|
||||
' <select class="form-control" name="stage[][score_source]">\n' +
|
||||
' <option value="0">经验值</option>\n' +
|
||||
' <option value="1">预测准确率</option>\n' +
|
||||
' </select>\n' +
|
||||
' </div></div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="row mt-2" id="task_Input_sub_new_new">\n' +
|
||||
' <div class="col-4 row task_Input_div">\n' +
|
||||
' <span class="col-3 text-right mt-3 no_padding mr10">任务1</span>\n' +
|
||||
' <div class="col-8 no_padding">\n' +
|
||||
' <input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="col-4 row task_Input_div">\n' +
|
||||
' <span class="col-3 text-right mt-3 no_padding mr10">任务2</span>\n' +
|
||||
' <div class="col-8 no_padding">\n' +
|
||||
' <input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' <div class="col-4 row task_Input_div">\n' +
|
||||
' <span class="col-3 text-right no_padding mr10 mt-3">任务3</span>\n' +
|
||||
' <div class="col-8 no_padding">\n' +
|
||||
' <input type="text" class="form-control mt-2" name="stage[][identifiers][]" placeholder="请填写实训ID">\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' <span>\n' +
|
||||
' <a href="javascript:void(0)" class="btn btn-default ml20 small_panel_item_del">删除</a>\n' +
|
||||
' </span>\n' +
|
||||
' </div>\n' +
|
||||
'</div></div></form>';
|
||||
$("#large_panel").append(html);
|
||||
}
|
||||
}
|
|
@ -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,66 @@
|
|||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-courses-index-page').length > 0) {
|
||||
var searchContainer = $(".course-list-form");
|
||||
var 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();
|
||||
});
|
||||
|
||||
$(".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/courses/" + 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,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -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,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,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,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,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,141 @@
|
|||
/*
|
||||
* @Description: Do not edit
|
||||
* @Date: 2021-08-31 11:16:45
|
||||
* @LastEditors: viletyy
|
||||
* @Author: viletyy
|
||||
* @LastEditTime: 2021-08-31 14:19:46
|
||||
* @FilePath: /forgeplus/app/assets/javascripts/admins/system_notifications/index.js
|
||||
*/
|
||||
$(document).on('turbolinks:load', function(){
|
||||
|
||||
var showSuccessNotify = function() {
|
||||
$.notify({
|
||||
message: '操作成功'
|
||||
},{
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
|
||||
// close user
|
||||
$('.project-list-container').on('click', '.recommend-action', function(){
|
||||
var $closeAction = $(this);
|
||||
var $uncloseAction = $closeAction.siblings('.unrecommend-action');
|
||||
var $editAction = $closeAction.siblings('.edit-recommend-action');
|
||||
|
||||
var keywordID = $closeAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认将该项目设置为推荐项目吗?',
|
||||
ok: function(){
|
||||
$.ajax({
|
||||
url: '/admins/projects/' + keywordID,
|
||||
method: 'PUT',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
project: {
|
||||
recommend: true,
|
||||
recommend_index: 1
|
||||
}
|
||||
},
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$closeAction.hide();
|
||||
$uncloseAction.show();
|
||||
$editAction.show();
|
||||
$(".project-item-"+keywordID).children('td').eq(5).text("√")
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// unclose user
|
||||
$('.project-list-container').on('click', '.unrecommend-action', function(){
|
||||
var $uncloseAction = $(this);
|
||||
var $closeAction = $uncloseAction.siblings('.recommend-action');
|
||||
var $editAction = $closeAction.siblings('.edit-recommend-action');
|
||||
|
||||
var keywordID = $uncloseAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认取消该推荐项目吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/projects/' + keywordID,
|
||||
method: 'PUT',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
project: {
|
||||
recommend: false,
|
||||
recommend_index: 0
|
||||
}
|
||||
},
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$closeAction.show();
|
||||
$uncloseAction.hide();
|
||||
$editAction.hide();
|
||||
$(".project-item-"+keywordID).children('td').eq(5).text("")
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
// close user
|
||||
$('.project-list-container').on('click', '.pinned-action', function(){
|
||||
var $closeAction = $(this);
|
||||
var $uncloseAction = $closeAction.siblings('.unpinned-action');
|
||||
|
||||
var keywordID = $closeAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认将该项目设置为精选项目吗?',
|
||||
ok: function(){
|
||||
$.ajax({
|
||||
url: '/admins/projects/' + keywordID,
|
||||
method: 'PUT',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
project: {
|
||||
is_pinned: true,
|
||||
}
|
||||
},
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$closeAction.hide();
|
||||
$uncloseAction.show();
|
||||
$(".project-item-"+keywordID).children('td').eq(4).text("√")
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// unclose user
|
||||
$('.project-list-container').on('click', '.unpinned-action', function(){
|
||||
var $uncloseAction = $(this);
|
||||
var $closeAction = $uncloseAction.siblings('.pinned-action');
|
||||
|
||||
var keywordID = $uncloseAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认取消该精选项目吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/projects/' + keywordID,
|
||||
method: 'PUT',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
project: {
|
||||
is_pinned: false,
|
||||
}
|
||||
},
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$closeAction.show();
|
||||
$uncloseAction.hide();
|
||||
$(".project-item-"+keywordID).children('td').eq(4).text("")
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
})
|
|
@ -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,76 @@
|
|||
/*
|
||||
* @Description: Do not edit
|
||||
* @Date: 2021-08-31 11:16:45
|
||||
* @LastEditors: viletyy
|
||||
* @Author: viletyy
|
||||
* @LastEditTime: 2021-08-31 14:19:46
|
||||
* @FilePath: /forgeplus/app/assets/javascripts/admins/reversed_keywords/index.js
|
||||
*/
|
||||
$(document).on('turbolinks:load', function(){
|
||||
|
||||
var showSuccessNotify = function() {
|
||||
$.notify({
|
||||
message: '操作成功'
|
||||
},{
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
|
||||
// close user
|
||||
$('.reversed-keyword-list-container').on('click', '.close-action', function(){
|
||||
var $closeAction = $(this);
|
||||
var $uncloseAction = $closeAction.siblings('.unclose-action');
|
||||
|
||||
var keywordID = $closeAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认关闭限制吗?',
|
||||
ok: function(){
|
||||
$.ajax({
|
||||
url: '/admins/reversed_keywords/' + keywordID,
|
||||
method: 'PUT',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
reversed_keyword: {
|
||||
closed: true
|
||||
}
|
||||
},
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$closeAction.hide();
|
||||
$uncloseAction.show();
|
||||
$(".reversed-keyword-item-"+keywordID).children('td').eq(3).text("")
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// unclose user
|
||||
$('.reversed-keyword-list-container').on('click', '.unclose-action', function(){
|
||||
var $uncloseAction = $(this);
|
||||
var $closeAction = $uncloseAction.siblings('.close-action');
|
||||
|
||||
var keywordID = $uncloseAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认开启限制吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/reversed_keywords/' + keywordID,
|
||||
method: 'PUT',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
reversed_keyword: {
|
||||
closed: false
|
||||
}
|
||||
},
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$closeAction.show();
|
||||
$uncloseAction.hide();
|
||||
$(".reversed-keyword-item-"+keywordID).children('td').eq(3).text("√")
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
})
|
|
@ -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,78 @@
|
|||
/*
|
||||
* @Description: Do not edit
|
||||
* @Date: 2021-07-16 11:58:16
|
||||
* @LastEditors: viletyy
|
||||
* @Author: viletyy
|
||||
* @LastEditTime: 2021-08-31 14:48:59
|
||||
* @FilePath: /forgeplus/app/assets/javascripts/admins/shixun_settings/index.js
|
||||
*/
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-shixun-settings-index-page').length > 0) {
|
||||
var searchContainer = $(".shixun-settings-list-form");
|
||||
var 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,76 @@
|
|||
/*
|
||||
* @Description: Do not edit
|
||||
* @Date: 2021-08-31 11:16:45
|
||||
* @LastEditors: viletyy
|
||||
* @Author: viletyy
|
||||
* @LastEditTime: 2021-08-31 14:19:46
|
||||
* @FilePath: /forgeplus/app/assets/javascripts/admins/system_notifications/index.js
|
||||
*/
|
||||
$(document).on('turbolinks:load', function(){
|
||||
|
||||
var showSuccessNotify = function() {
|
||||
$.notify({
|
||||
message: '操作成功'
|
||||
},{
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
|
||||
// close user
|
||||
$('.system-notification-list-container').on('click', '.close-action', function(){
|
||||
var $closeAction = $(this);
|
||||
var $uncloseAction = $closeAction.siblings('.unclose-action');
|
||||
|
||||
var keywordID = $closeAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认取消置顶吗?',
|
||||
ok: function(){
|
||||
$.ajax({
|
||||
url: '/admins/system_notifications/' + keywordID,
|
||||
method: 'PUT',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
system_notification: {
|
||||
is_top: false
|
||||
}
|
||||
},
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$closeAction.hide();
|
||||
$uncloseAction.show();
|
||||
$(".system-notification-item-"+keywordID).children('td').eq(3).text("")
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// unclose user
|
||||
$('.system-notification-list-container').on('click', '.unclose-action', function(){
|
||||
var $uncloseAction = $(this);
|
||||
var $closeAction = $uncloseAction.siblings('.close-action');
|
||||
|
||||
var keywordID = $uncloseAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认置顶吗?',
|
||||
ok: function () {
|
||||
$.ajax({
|
||||
url: '/admins/system_notifications/' + keywordID,
|
||||
method: 'PUT',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
system_notification: {
|
||||
is_top: true
|
||||
}
|
||||
},
|
||||
success: function() {
|
||||
showSuccessNotify();
|
||||
$closeAction.show();
|
||||
$uncloseAction.hide();
|
||||
$(".system-notification-item-"+keywordID).children('td').eq(3).text("√")
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
})
|
|
@ -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,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,20 @@
|
|||
// 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
|
||||
//= require chartkick
|
||||
//= require Chart.bundle
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,350 @@
|
|||
/*
|
||||
* Project: Bootstrap Notify = v3.1.3
|
||||
* Description: Turns standard Bootstrap alerts into "Growl-like" notifications.
|
||||
* Author: Mouse0270 aka Robert McIntosh
|
||||
* License: MIT License
|
||||
* Website: https://github.com/mouse0270/bootstrap-growl
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
// Create the defaults once
|
||||
var defaults = {
|
||||
element: 'body',
|
||||
position: null,
|
||||
type: "info",
|
||||
allow_dismiss: true,
|
||||
newest_on_top: false,
|
||||
showProgressbar: false,
|
||||
placement: {
|
||||
from: "top",
|
||||
align: "right"
|
||||
},
|
||||
offset: 20,
|
||||
spacing: 10,
|
||||
z_index: 1031,
|
||||
delay: 1000,
|
||||
timer: 1000,
|
||||
url_target: '_blank',
|
||||
mouse_over: null,
|
||||
animate: {
|
||||
enter: 'animated fadeInDown',
|
||||
exit: 'animated fadeOutUp'
|
||||
},
|
||||
onShow: null,
|
||||
onShown: null,
|
||||
onClose: null,
|
||||
onClosed: null,
|
||||
icon_type: 'class',
|
||||
template: '<div data-notify="container" class="col-xs-4 col-sm-2 alert alert-{0}" role="alert"><button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button><span data-notify="icon"></span> <span data-notify="title">{1}</span> <span data-notify="message">{2}</span><div class="progress" data-notify="progressbar"><div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div></div><a href="{3}" target="{4}" data-notify="url"></a></div>'
|
||||
};
|
||||
|
||||
String.format = function() {
|
||||
var str = arguments[0];
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
str = str.replace(RegExp("\\{" + (i - 1) + "\\}", "gm"), arguments[i]);
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
function Notify ( element, content, options ) {
|
||||
// Setup Content of Notify
|
||||
var content = {
|
||||
content: {
|
||||
message: typeof content == 'object' ? content.message : content,
|
||||
title: content.title ? content.title : '',
|
||||
icon: content.icon ? content.icon : '',
|
||||
url: content.url ? content.url : '#',
|
||||
target: content.target ? content.target : '-'
|
||||
}
|
||||
};
|
||||
|
||||
options = $.extend(true, {}, content, options);
|
||||
this.settings = $.extend(true, {}, defaults, options);
|
||||
this._defaults = defaults;
|
||||
if (this.settings.content.target == "-") {
|
||||
this.settings.content.target = this.settings.url_target;
|
||||
}
|
||||
this.animations = {
|
||||
start: 'webkitAnimationStart oanimationstart MSAnimationStart animationstart',
|
||||
end: 'webkitAnimationEnd oanimationend MSAnimationEnd animationend'
|
||||
}
|
||||
|
||||
if (typeof this.settings.offset == 'number') {
|
||||
this.settings.offset = {
|
||||
x: this.settings.offset,
|
||||
y: this.settings.offset
|
||||
};
|
||||
}
|
||||
|
||||
this.init();
|
||||
};
|
||||
|
||||
$.extend(Notify.prototype, {
|
||||
init: function () {
|
||||
var self = this;
|
||||
|
||||
this.buildNotify();
|
||||
if (this.settings.content.icon) {
|
||||
this.setIcon();
|
||||
}
|
||||
if (this.settings.content.url != "#") {
|
||||
this.styleURL();
|
||||
}
|
||||
this.placement();
|
||||
this.bind();
|
||||
|
||||
this.notify = {
|
||||
$ele: this.$ele,
|
||||
update: function(command, update) {
|
||||
var commands = {};
|
||||
if (typeof command == "string") {
|
||||
commands[command] = update;
|
||||
}else{
|
||||
commands = command;
|
||||
}
|
||||
for (var command in commands) {
|
||||
switch (command) {
|
||||
case "type":
|
||||
this.$ele.removeClass('alert-' + self.settings.type);
|
||||
this.$ele.find('[data-notify="progressbar"] > .progress-bar').removeClass('progress-bar-' + self.settings.type);
|
||||
self.settings.type = commands[command];
|
||||
this.$ele.addClass('alert-' + commands[command]).find('[data-notify="progressbar"] > .progress-bar').addClass('progress-bar-' + commands[command]);
|
||||
break;
|
||||
case "icon":
|
||||
var $icon = this.$ele.find('[data-notify="icon"]');
|
||||
if (self.settings.icon_type.toLowerCase() == 'class') {
|
||||
$icon.removeClass(self.settings.content.icon).addClass(commands[command]);
|
||||
}else{
|
||||
if (!$icon.is('img')) {
|
||||
$icon.find('img');
|
||||
}
|
||||
$icon.attr('src', commands[command]);
|
||||
}
|
||||
break;
|
||||
case "progress":
|
||||
var newDelay = self.settings.delay - (self.settings.delay * (commands[command] / 100));
|
||||
this.$ele.data('notify-delay', newDelay);
|
||||
this.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', commands[command]).css('width', commands[command] + '%');
|
||||
break;
|
||||
case "url":
|
||||
this.$ele.find('[data-notify="url"]').attr('href', commands[command]);
|
||||
break;
|
||||
case "target":
|
||||
this.$ele.find('[data-notify="url"]').attr('target', commands[command]);
|
||||
break;
|
||||
default:
|
||||
this.$ele.find('[data-notify="' + command +'"]').html(commands[command]);
|
||||
};
|
||||
}
|
||||
var posX = this.$ele.outerHeight() + parseInt(self.settings.spacing) + parseInt(self.settings.offset.y);
|
||||
self.reposition(posX);
|
||||
},
|
||||
close: function() {
|
||||
self.close();
|
||||
}
|
||||
};
|
||||
},
|
||||
buildNotify: function () {
|
||||
var content = this.settings.content;
|
||||
this.$ele = $(String.format(this.settings.template, this.settings.type, content.title, content.message, content.url, content.target));
|
||||
this.$ele.attr('data-notify-position', this.settings.placement.from + '-' + this.settings.placement.align);
|
||||
if (!this.settings.allow_dismiss) {
|
||||
this.$ele.find('[data-notify="dismiss"]').css('display', 'none');
|
||||
}
|
||||
if ((this.settings.delay <= 0 && !this.settings.showProgressbar) || !this.settings.showProgressbar) {
|
||||
this.$ele.find('[data-notify="progressbar"]').remove();
|
||||
}
|
||||
},
|
||||
setIcon: function() {
|
||||
if (this.settings.icon_type.toLowerCase() == 'class') {
|
||||
this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon);
|
||||
}else{
|
||||
if (this.$ele.find('[data-notify="icon"]').is('img')) {
|
||||
this.$ele.find('[data-notify="icon"]').attr('src', this.settings.content.icon);
|
||||
}else{
|
||||
this.$ele.find('[data-notify="icon"]').append('<img src="'+this.settings.content.icon+'" alt="Notify Icon" />');
|
||||
}
|
||||
}
|
||||
},
|
||||
styleURL: function() {
|
||||
this.$ele.find('[data-notify="url"]').css({
|
||||
backgroundImage: 'url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)',
|
||||
height: '100%',
|
||||
left: '0px',
|
||||
position: 'absolute',
|
||||
top: '0px',
|
||||
width: '100%',
|
||||
zIndex: this.settings.z_index + 1
|
||||
});
|
||||
this.$ele.find('[data-notify="dismiss"]').css({
|
||||
position: 'absolute',
|
||||
right: '10px',
|
||||
top: '5px',
|
||||
zIndex: this.settings.z_index + 2
|
||||
});
|
||||
},
|
||||
placement: function() {
|
||||
var self = this,
|
||||
offsetAmt = this.settings.offset.y,
|
||||
css = {
|
||||
display: 'inline-block',
|
||||
margin: '0px auto',
|
||||
position: this.settings.position ? this.settings.position : (this.settings.element === 'body' ? 'fixed' : 'absolute'),
|
||||
transition: 'all .5s ease-in-out',
|
||||
zIndex: this.settings.z_index
|
||||
},
|
||||
hasAnimation = false,
|
||||
settings = this.settings;
|
||||
|
||||
$('[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])').each(function() {
|
||||
return offsetAmt = Math.max(offsetAmt, parseInt($(this).css(settings.placement.from)) + parseInt($(this).outerHeight()) + parseInt(settings.spacing));
|
||||
});
|
||||
if (this.settings.newest_on_top == true) {
|
||||
offsetAmt = this.settings.offset.y;
|
||||
}
|
||||
css[this.settings.placement.from] = offsetAmt+'px';
|
||||
|
||||
switch (this.settings.placement.align) {
|
||||
case "left":
|
||||
case "right":
|
||||
css[this.settings.placement.align] = this.settings.offset.x+'px';
|
||||
break;
|
||||
case "center":
|
||||
css.left = 0;
|
||||
css.right = 0;
|
||||
break;
|
||||
}
|
||||
this.$ele.css(css).addClass(this.settings.animate.enter);
|
||||
$.each(Array('webkit', 'moz', 'o', 'ms', ''), function(index, prefix) {
|
||||
self.$ele[0].style[prefix+'AnimationIterationCount'] = 1;
|
||||
});
|
||||
|
||||
$(this.settings.element).append(this.$ele);
|
||||
|
||||
if (this.settings.newest_on_top == true) {
|
||||
offsetAmt = (parseInt(offsetAmt)+parseInt(this.settings.spacing)) + this.$ele.outerHeight();
|
||||
this.reposition(offsetAmt);
|
||||
}
|
||||
|
||||
if ($.isFunction(self.settings.onShow)) {
|
||||
self.settings.onShow.call(this.$ele);
|
||||
}
|
||||
|
||||
this.$ele.one(this.animations.start, function(event) {
|
||||
hasAnimation = true;
|
||||
}).one(this.animations.end, function(event) {
|
||||
if ($.isFunction(self.settings.onShown)) {
|
||||
self.settings.onShown.call(this);
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
if (!hasAnimation) {
|
||||
if ($.isFunction(self.settings.onShown)) {
|
||||
self.settings.onShown.call(this);
|
||||
}
|
||||
}
|
||||
}, 600);
|
||||
},
|
||||
bind: function() {
|
||||
var self = this;
|
||||
|
||||
this.$ele.find('[data-notify="dismiss"]').on('click', function() {
|
||||
self.close();
|
||||
})
|
||||
|
||||
this.$ele.mouseover(function(e) {
|
||||
$(this).data('data-hover', "true");
|
||||
}).mouseout(function(e) {
|
||||
$(this).data('data-hover', "false");
|
||||
});
|
||||
this.$ele.data('data-hover', "false");
|
||||
|
||||
if (this.settings.delay > 0) {
|
||||
self.$ele.data('notify-delay', self.settings.delay);
|
||||
var timer = setInterval(function() {
|
||||
var delay = parseInt(self.$ele.data('notify-delay')) - self.settings.timer;
|
||||
if ((self.$ele.data('data-hover') === 'false' && self.settings.mouse_over == "pause") || self.settings.mouse_over != "pause") {
|
||||
var percent = ((self.settings.delay - delay) / self.settings.delay) * 100;
|
||||
self.$ele.data('notify-delay', delay);
|
||||
self.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', percent).css('width', percent + '%');
|
||||
}
|
||||
if (delay <= -(self.settings.timer)) {
|
||||
clearInterval(timer);
|
||||
self.close();
|
||||
}
|
||||
}, self.settings.timer);
|
||||
}
|
||||
},
|
||||
close: function() {
|
||||
var self = this,
|
||||
$successors = null,
|
||||
posX = parseInt(this.$ele.css(this.settings.placement.from)),
|
||||
hasAnimation = false;
|
||||
|
||||
this.$ele.data('closing', 'true').addClass(this.settings.animate.exit);
|
||||
self.reposition(posX);
|
||||
|
||||
if ($.isFunction(self.settings.onClose)) {
|
||||
self.settings.onClose.call(this.$ele);
|
||||
}
|
||||
|
||||
this.$ele.one(this.animations.start, function(event) {
|
||||
hasAnimation = true;
|
||||
}).one(this.animations.end, function(event) {
|
||||
$(this).remove();
|
||||
if ($.isFunction(self.settings.onClosed)) {
|
||||
self.settings.onClosed.call(this);
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
if (!hasAnimation) {
|
||||
self.$ele.remove();
|
||||
if (self.settings.onClosed) {
|
||||
self.settings.onClosed(self.$ele);
|
||||
}
|
||||
}
|
||||
}, 600);
|
||||
},
|
||||
reposition: function(posX) {
|
||||
var self = this,
|
||||
notifies = '[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])',
|
||||
$elements = this.$ele.nextAll(notifies);
|
||||
if (this.settings.newest_on_top == true) {
|
||||
$elements = this.$ele.prevAll(notifies);
|
||||
}
|
||||
$elements.each(function() {
|
||||
$(this).css(self.settings.placement.from, posX);
|
||||
posX = (parseInt(posX)+parseInt(self.settings.spacing)) + $(this).outerHeight();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$.notify = function ( content, options ) {
|
||||
var plugin = new Notify( this, content, options );
|
||||
return plugin.notify;
|
||||
};
|
||||
$.notifyDefaults = function( options ) {
|
||||
defaults = $.extend(true, {}, defaults, options);
|
||||
return defaults;
|
||||
};
|
||||
$.notifyClose = function( command ) {
|
||||
if (typeof command === "undefined" || command == "all") {
|
||||
$('[data-notify]').find('[data-notify="dismiss"]').trigger('click');
|
||||
}else{
|
||||
$('[data-notify-position="'+command+'"]').find('[data-notify="dismiss"]').trigger('click');
|
||||
}
|
||||
};
|
||||
|
||||
}));
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright 2018-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* WebSite: http://bootstrap-viewer.leftso.com
|
||||
*/
|
||||
$.fn.bootstrapViewer = function (options) {
|
||||
$(this).on('click', function () {
|
||||
var opts = $.extend({}, $.fn.bootstrapViewer.defaults, options);
|
||||
var viewer = $('<div class="modal fade bs-example-modal-lg text-center" id="bootstrapViewer" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" >\n' +
|
||||
' <div class="modal-dialog modal-lg" style="display: inline-block; width: auto;">\n' +
|
||||
' <div class="modal-content">\n' +
|
||||
' <img' +
|
||||
'\t\t\t class="carousel-inner img-responsive img-rounded img-viewer" draggable="false"\n' +
|
||||
'\t\t\t onclick="/*$(\'#bootstrapViewer\').modal(\'hide\');setTimeout(function(){$(\'#bootstrapViewer\').remove();},200);*/"\n' +
|
||||
'\t\t\t onmouseover="this.style.cursor=\'move\';" \n' +
|
||||
'\t\t\t onmouseout="this.style.cursor=\'default\'" \n' +
|
||||
'\t\t\t />\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>');
|
||||
$('body').append(viewer);
|
||||
if ($(this).attr(opts.src)) {
|
||||
$("#bootstrapViewer").find(".img-viewer").attr("src", $(this).attr(opts.src));
|
||||
$("#bootstrapViewer").modal();
|
||||
} else {
|
||||
throw "图片不存在"
|
||||
}
|
||||
$('#bootstrapViewer').on('hidden.bs.modal', function(){
|
||||
$('#bootstrapViewer').remove();
|
||||
});
|
||||
|
||||
var $moveDiv = $('#bootstrapViewer .modal-dialog');
|
||||
var isMove = false;
|
||||
var div_x = $moveDiv.offset().left;
|
||||
var div_y = $moveDiv.offset().top;
|
||||
|
||||
var mousedownFunc = function (e) {
|
||||
if (isMove) {
|
||||
var left = e.pageX - div_x;
|
||||
var top = e.pageY - div_y;
|
||||
if(left < 0){ left = 0}
|
||||
if(top < 0){ top = 0}
|
||||
$moveDiv.css({"left": left, "top":top});
|
||||
}
|
||||
}
|
||||
|
||||
$moveDiv.mousedown(function (e) {
|
||||
$moveDiv.css({ left: $moveDiv[0].offsetLeft, top: $moveDiv[0].offsetTop, marginTop: 0, position: 'absolute' });
|
||||
|
||||
isMove = true;
|
||||
div_x = e.pageX - $moveDiv.offset().left;
|
||||
div_y = e.pageY - $moveDiv.offset().top;
|
||||
$(document).mousemove(mousedownFunc);
|
||||
}).mouseup(function () {
|
||||
isMove = false;
|
||||
$(document).unbind('mousemove', mousedownFunc);
|
||||
});
|
||||
})
|
||||
|
||||
$(this).on('mouseover', function () {
|
||||
$(this).css('cursor', 'zoom-in');
|
||||
})
|
||||
}
|
||||
$.fn.bootstrapViewer.defaults = {
|
||||
src: 'src'
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// Action Cable provides the framework to deal with WebSockets in Rails.
|
||||
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
||||
//
|
||||
//= require action_cable
|
||||
//= require_self
|
||||
//= require_tree ./channels
|
||||
|
||||
(function() {
|
||||
this.App || (this.App = {});
|
||||
|
||||
App.cable = ActionCable.createConsumer();
|
||||
|
||||
}).call(this);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue