网站
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. define(['jquery', "template", "Tools",'swiper',], function ($, template, Tools, swiper) {
  2. //数据存储
  3. var module = {
  4. data: {
  5. //服务器地址
  6. serverApi: '',
  7. trainStudentsList:[{
  8. name:'',
  9. phone:'',
  10. sex: '',
  11. trainId:''
  12. }]
  13. },
  14. };
  15. var tools = new Tools();
  16. module.init = function (page) {
  17. //新闻管理列表
  18. tools.doGet(dictType + '/training_type', {}, module.dictType , true);
  19. tools.doGet(dictType + '/apply_state', {}, function(data){module.data.studentsTypeOptions = data.data;} , true);
  20. module.data.trainStudentsList[0].trainId = getQueryVariable('id');
  21. };
  22. module.dictType = function (data) {
  23. module.data.trainingTypeOptions = data.data;
  24. tools.doPost(technologyTrainingDetails + '/' + getQueryVariable('id'), {}, module.technologyTrainingDetails, true);
  25. }
  26. //获取地址栏参数
  27. function getQueryVariable(variable){
  28. var query = window.location.search.substring(1);
  29. var vars = query.split("&");
  30. for (var i=0;i<vars.length;i++) {
  31. var pair = vars[i].split("=");
  32. if(pair[0] == variable){return pair[1];}
  33. }
  34. return(false);
  35. }
  36. //焦点图滚动
  37. module.swiperBanner = function (type) {
  38. var viewSwiper = new Swiper('.view .swiper-container', {
  39. onSlideChangeStart: function() {
  40. updateNavPosition()
  41. }
  42. })
  43. $('.view .arrow-left,.preview .arrow-left').on('click', function(e) {
  44. e.preventDefault()
  45. if (viewSwiper.activeIndex == 0) {
  46. viewSwiper.swipeTo(viewSwiper.slides.length - 1, 1000);
  47. return
  48. }
  49. viewSwiper.swipePrev()
  50. })
  51. $('.view .arrow-right,.preview .arrow-right').on('click', function(e) {
  52. e.preventDefault()
  53. if (viewSwiper.activeIndex == viewSwiper.slides.length - 1) {
  54. viewSwiper.swipeTo(0, 1000);
  55. return
  56. }
  57. viewSwiper.swipeNext()
  58. })
  59. var previewSwiper = new Swiper('.preview .swiper-container', {
  60. visibilityFullFit: true,
  61. slidesPerView: 'auto',
  62. onlyExternal: true,
  63. onSlideClick: function() {
  64. viewSwiper.swipeTo(previewSwiper.clickedSlideIndex)
  65. }
  66. })
  67. function updateNavPosition() {
  68. $('.preview .active-nav').removeClass('active-nav')
  69. var activeNav = $('.preview .swiper-slide').eq(viewSwiper.activeIndex).addClass('active-nav')
  70. if (!activeNav.hasClass('swiper-slide-visible')) {
  71. if (activeNav.index() > previewSwiper.activeIndex) {
  72. var thumbsPerNav = Math.floor(previewSwiper.width / activeNav.width()) - 1
  73. previewSwiper.swipeTo(activeNav.index() - thumbsPerNav)
  74. } else {
  75. previewSwiper.swipeTo(activeNav.index())
  76. }
  77. }
  78. }
  79. }
  80. //专家列表
  81. module.technologyTrainingDetails = function (data) {
  82. if (data.code == 200) {
  83. var content = data.data;
  84. content.trainingType = module.selectDictLabel(module.data.trainingTypeOptions,content.trainingType);
  85. for (var i = 0 ; i < content.tEntityTrainStudentsList.length ; i++){
  86. content.tEntityTrainStudentsList[i].applyState = module.selectDictLabel(module.data.studentsTypeOptions,content.tEntityTrainStudentsList[i].applyState);
  87. }
  88. const masterMapList = content.masterMap.split(",");
  89. for (var i = 0 ; i < masterMapList.length ; i++){
  90. masterMapList[i] = serverApi + masterMapList[i];
  91. }
  92. console.log(masterMapList)
  93. content.masterMap = masterMapList;
  94. module.data.technologyDetail = content;
  95. var technologyData = template('technologyData', module.data);
  96. $("#technologyContent").html(technologyData);
  97. $('#detailBox').html(content.briefIntroduction)
  98. module.swiperBanner();
  99. }
  100. }
  101. module.selectDictLabel = function (datas, value) {
  102. var actions = [];
  103. Object.keys(datas).some((key) => {
  104. if (datas[key].dictValue == ('' + value)) {
  105. actions.push(datas[key].dictLabel);
  106. return true;
  107. }
  108. })
  109. return actions.join('');
  110. }
  111. goDelete = function(index){
  112. tools.doPost(technologyTrainingStudentsRemove+'/'+module.data.technologyDetail.tEntityTrainStudentsList[index].id, {}, module.updateList , true);
  113. module.data.technologyDetail.tEntityTrainStudentsList.splice(index, 1);
  114. var technologyData = template('technologyData', module.data);
  115. $("#technologyContent").html(technologyData);
  116. }
  117. goStudentsDelete = function(index){
  118. module.data.trainStudentsList.splice(index, 1);
  119. var technologyData = template('technologyData', module.data);
  120. $("#technologyContent").html(technologyData);
  121. }
  122. goSubmit = function(index){
  123. tools.doPost(technologyTrainingStudents, module.data.trainStudentsList[index], module.updateList , true);
  124. var technologyData = template('technologyData', module.data);
  125. $("#technologyContent").html(technologyData);
  126. }
  127. module.updateList = function(data){
  128. if (data.code == 200){
  129. tools.doPost(technologyTrainingDetails + '/' + getQueryVariable('id'), {}, module.technologyTrainingDetails, true);
  130. var technologyData = template('technologyData', module.data);
  131. $("#technologyContent").html(technologyData);
  132. }
  133. }
  134. inputNameChange = function(index){
  135. module.data.trainStudentsList[index].name = $('#name'+index+'').val();
  136. }
  137. inputPhoneChange = function(index){
  138. module.data.trainStudentsList[index].phone = $('#phone'+index+'').val();
  139. }
  140. inputSexChange = function(index){
  141. module.data.trainStudentsList[index].sex = $('#sex'+index+'').val();
  142. }
  143. goAdd = function(){
  144. for (var i = 0 ; i < module.data.trainStudentsList.length ; i++){
  145. if (module.data.trainStudentsList[i].name == '' || module.data.trainStudentsList[i].phone == '' || module.data.trainStudentsList[i].sex == ''){
  146. return;
  147. }
  148. }
  149. module.data.trainStudentsList.push({
  150. name:'',
  151. phone:'',
  152. sex:'',
  153. trainId:getQueryVariable('id')
  154. });
  155. var technologyData = template('technologyData', module.data);
  156. $("#technologyContent").html(technologyData);
  157. }
  158. return module;
  159. })