网站
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

severDetail.js 6.7 KiB

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