select-industry.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. (function() {
  2. Vue.component('select-industry', {
  3. template: `<div class="modal fade" id="selindustry" tabindex="-1" role="dialog" aria-labelledby="selindustryLabel">
  4. <div class="modal-dialog" role="document">
  5. <div class="modal-content">
  6. <div class="modal-header bgc-f9f9f9">
  7. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  8. <h4 class="modal-title" id="selindustryLabel">请选择行业</h4>
  9. </div>
  10. <div class="modal-body">
  11. <div class="p15 bgc-fff">
  12. <ul class="nav nav-tabs" role="tablist" id="industrylist">
  13. <li role="presentation" class="active">
  14. <a href="#home" aria-controls="home" role="tab" data-toggle="tab" id="_home">{{industryname}}</a>
  15. </li>
  16. <li role="presentation">
  17. <a href="#direction" aria-controls="direction" role="tab" data-toggle="tab" id="_direction">{{directionname}}</a>
  18. </li>
  19. </ul>
  20. <div class="tab-content industrybox">
  21. <div role="tabpanel" class="tab-pane active w3-row-padding industry" id="home">
  22. <div :id="'industry_'+industry.id" class="w3-quarter mb20" v-for="industry in industrys" @click="selectindustry(industry.id,industry.name)">
  23. <div class="industryname">{{industry.name}}</div>
  24. </div>
  25. </div>
  26. <div role="tabpanel" class="tab-pane w3-row-padding industry" id="direction">
  27. <div :id="'direction_'+direction.id" class="w3-quarter mb20" v-for="direction in directions" @click="selectdirection(direction.id,direction.name)">
  28. <div class="industryname">{{direction.name}}</div>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="c-t-center">
  33. <button type="button" class="btn btn-default c-f16 mt20" style="width:144px;" @click="back">取 消</button>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>`,
  40. props: ["industryid", "directionid"],
  41. data: function() {
  42. return {
  43. industrys: [{
  44. id: 0,
  45. name: "政府科研NGO"
  46. }, {
  47. id: 1,
  48. name: "IT互联网",
  49. direction: [{
  50. id: 0,
  51. name: "开发"
  52. }, {
  53. id: 1,
  54. name: "测试"
  55. }, {
  56. id: 2,
  57. name: "运维/安全"
  58. }, {
  59. id: 3,
  60. name: "硬件"
  61. }, {
  62. id: 4,
  63. name: "产品"
  64. }, {
  65. id: 5,
  66. name: "运营"
  67. }, {
  68. id: 6,
  69. name: "设计"
  70. }, {
  71. id: 7,
  72. name: "编辑/文档"
  73. }, ]
  74. }, {
  75. id: 2,
  76. name: "文化传媒"
  77. }, {
  78. id: 3,
  79. name: "医疗生物"
  80. }, {
  81. id: 4,
  82. name: "通信"
  83. }, {
  84. id: 5,
  85. name: "金融"
  86. }, {
  87. id: 6,
  88. name: "学生"
  89. }, {
  90. id: 7,
  91. name: "教育培训"
  92. }, {
  93. id: 8,
  94. name: "司法法律"
  95. }, {
  96. id: 9,
  97. name: "房产建筑"
  98. }, {
  99. id: 10,
  100. name: "服务业"
  101. }, {
  102. id: 7,
  103. name: "教育培训"
  104. }, {
  105. id: 8,
  106. name: "司法法律"
  107. }, {
  108. id: 9,
  109. name: "房产建筑"
  110. }, {
  111. id: 10,
  112. name: "服务业"
  113. }, {
  114. id: 7,
  115. name: "教育培训"
  116. }, {
  117. id: 8,
  118. name: "司法法律"
  119. }, {
  120. id: 9,
  121. name: "房产建筑"
  122. }, {
  123. id: 10,
  124. name: "服务业"
  125. }],
  126. directions: [],
  127. industryname:"请选择行业",
  128. directionname:"请选择方向",
  129. }
  130. },
  131. mounted: function() {
  132. this.initindustry()
  133. },
  134. methods: {
  135. initindustry: function() {
  136. var vm = this
  137. // getAllIndustry() //获取所有行业
  138. $("#industry_" + vm.industryid).addClass("selected")
  139. if(vm.industryid == -1) {
  140. $('#_direction').parent("li").addClass("hidden")
  141. } else {
  142. vm.getDirection(vm.industryid)
  143. }
  144. },
  145. selectindustry: function(id, name) {
  146. var vm = this
  147. if(vm.industryid != -1) {
  148. $("#industry_" + vm.industryid).removeClass("selected")
  149. }
  150. $("#industry_" + id).addClass("selected")
  151. vm.industryid = id
  152. vm.industryname = name
  153. if($('#_direction').parent("li").hasClass("hidden")) {
  154. $('#_direction').parent("li").removeClass("hidden")
  155. }
  156. $('#industrylist a[href="#direction"]').tab('show') //转到方向页面
  157. vm.getDirection(id) //通过id获取方向
  158. },
  159. getDirection: function(id) {
  160. // getAllDirection() //获取该行业所有方向
  161. var vm = this
  162. vm.directions = vm.industrys[id].direction
  163. },
  164. selectdirection: function(id, name) {
  165. var vm = this
  166. if(vm.directionid != -1) {
  167. $("#direction_" + vm.directionid).removeClass("selected")
  168. }
  169. $("#direction_" + id).addClass("selected")
  170. vm.directionid = id
  171. vm.directionname = name
  172. },
  173. back: function() {
  174. // var index = top.layer.getFrameIndex(window.name);
  175. // top.layer.close(index);
  176. $('#selindustry').modal('hide')
  177. },
  178. },
  179. })
  180. })()