|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- define(['jquery', "template", "Tools",'swiper',], function ($, template, Tools, swiper) {
- //数据存储
- var module = {
- data: {
- //服务器地址
- serverApi: '',
- trainStudentsList:[{
- name:'',
- phone:'',
- sex: '',
- trainId:''
- }]
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
- //新闻管理列表techniqueType
- tools.doGet(dictType + '/technique_type', {}, module.dictType , true);
- tools.doGet(dictType + '/apply_state', {}, function(data){module.data.studentsTypeOptions = data.data;} , true);
- };
-
- module.dictType = function (data) {
- module.data.trainingTypeOptions = data.data;
- tools.doPost(technologyConsultingDetails + '/' + getQueryVariable('id'), {}, module.technologyTrainingDetails, true);
- }
-
- //获取地址栏参数
- function getQueryVariable(variable){
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i=0;i<vars.length;i++) {
- var pair = vars[i].split("=");
- if(pair[0] == variable){return pair[1];}
- }
- return(false);
- }
-
- //焦点图滚动
- module.swiperBanner = function (type) {
- var viewSwiper = new Swiper('.view .swiper-container', {
- onSlideChangeStart: function() {
- updateNavPosition()
- }
- })
-
- $('.view .arrow-left,.preview .arrow-left').on('click', function(e) {
- e.preventDefault()
- if (viewSwiper.activeIndex == 0) {
- viewSwiper.swipeTo(viewSwiper.slides.length - 1, 1000);
- return
- }
- viewSwiper.swipePrev()
- })
- $('.view .arrow-right,.preview .arrow-right').on('click', function(e) {
- e.preventDefault()
- if (viewSwiper.activeIndex == viewSwiper.slides.length - 1) {
- viewSwiper.swipeTo(0, 1000);
- return
- }
- viewSwiper.swipeNext()
- })
-
- var previewSwiper = new Swiper('.preview .swiper-container', {
- visibilityFullFit: true,
- slidesPerView: 'auto',
- onlyExternal: true,
- onSlideClick: function() {
- viewSwiper.swipeTo(previewSwiper.clickedSlideIndex)
- }
- })
-
- function updateNavPosition() {
- $('.preview .active-nav').removeClass('active-nav')
- var activeNav = $('.preview .swiper-slide').eq(viewSwiper.activeIndex).addClass('active-nav')
- if (!activeNav.hasClass('swiper-slide-visible')) {
- if (activeNav.index() > previewSwiper.activeIndex) {
- var thumbsPerNav = Math.floor(previewSwiper.width / activeNav.width()) - 1
- previewSwiper.swipeTo(activeNav.index() - thumbsPerNav)
- } else {
- previewSwiper.swipeTo(activeNav.index())
- }
- }
- }
- }
-
- //专家列表
- module.technologyTrainingDetails = function (data) {
- if (data.code == 200) {
- var content = data.data;
- // content.trainingType = module.selectDictLabel(module.data.trainingTypeOptions,content.trainingType);
- //
- // for (var i = 0 ; i < content.tEntityTrainStudentsList.length ; i++){
- // content.tEntityTrainStudentsList[i].applyState = module.selectDictLabel(module.data.studentsTypeOptions,content.tEntityTrainStudentsList[i].applyState);
- // }
- //
- // const masterMapList = content.masterMap.split(",");
- // for (var i = 0 ; i < masterMapList.length ; i++){
- // masterMapList[i] = serverApi + masterMapList[i];
- // }
- // console.log(masterMapList)
- // content.masterMap = masterMapList;
-
- module.data.technologyDetail = content;
- var technologyData = template('technologyData', module.data);
- $("#technologyContent").html(technologyData);
- // $('#detailBox').html(content.briefIntroduction)
- // module.swiperBanner();
- }
- }
-
- module.selectDictLabel = function (datas, value) {
- var actions = [];
- Object.keys(datas).some((key) => {
- if (datas[key].dictValue == ('' + value)) {
- actions.push(datas[key].dictLabel);
- return true;
- }
- })
- return actions.join('');
- }
-
- goDelete = function(index){
- tools.doPost(technologyTrainingStudentsRemove+'/'+module.data.technologyDetail.tEntityTrainStudentsList[index].id, {}, module.updateList , true);
- module.data.technologyDetail.tEntityTrainStudentsList.splice(index, 1);
- var technologyData = template('technologyData', module.data);
- $("#technologyContent").html(technologyData);
- }
-
- goStudentsDelete = function(index){
- module.data.trainStudentsList.splice(index, 1);
- var technologyData = template('technologyData', module.data);
- $("#technologyContent").html(technologyData);
- }
-
- goSubmit = function(index){
- tools.doPost(technologyTrainingStudents, module.data.trainStudentsList[index], module.updateList , true);
- var technologyData = template('technologyData', module.data);
- $("#technologyContent").html(technologyData);
- }
-
- module.updateList = function(data){
- if (data.code == 200){
- tools.doPost(technologyTrainingDetails + '/' + getQueryVariable('id'), {}, module.technologyTrainingDetails, true);
- var technologyData = template('technologyData', module.data);
- $("#technologyContent").html(technologyData);
- }
- }
-
- inputNameChange = function(index){
- module.data.trainStudentsList[index].name = $('#name'+index+'').val();
- }
-
- inputPhoneChange = function(index){
- module.data.trainStudentsList[index].phone = $('#phone'+index+'').val();
- }
-
- inputSexChange = function(index){
- module.data.trainStudentsList[index].sex = $('#sex'+index+'').val();
- }
-
- goAdd = function(){
- for (var i = 0 ; i < module.data.trainStudentsList.length ; i++){
- if (module.data.trainStudentsList[i].name == '' || module.data.trainStudentsList[i].phone == '' || module.data.trainStudentsList[i].sex == ''){
- return;
- }
- }
- module.data.trainStudentsList.push({
- name:'',
- phone:'',
- sex:'',
- trainId:getQueryVariable('id')
- });
- var technologyData = template('technologyData', module.data);
- $("#technologyContent").html(technologyData);
- }
-
- return module;
- })
|