list.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div id="jobfair">
  3. <list-layout searchPlaceHolder="请输入招聘会标题" @search="search" @searchBar="searchBar" :hasMore="hasMore" :searchName="`title`">
  4. <template v-slot:content>
  5. <span v-if="list.length > 0">
  6. <el-row class="jobfair_list" v-for="(item, index) in list" :key="index" @click.native="link(item.id)">
  7. <el-row>
  8. <span class="time_off" v-if="item.is_over === '0'">过</span>
  9. <el-col :span="6" class="jobfair_icon">
  10. 招聘
  11. </el-col>
  12. <el-col :span="18" class="jobfair_info">
  13. <div style="float:left">
  14. <el-tag effect="plain" v-if="item.schid === $site" class="jobfair_tags">校内</el-tag>
  15. <el-tag type="warning" effect="plain" v-else>校外</el-tag>
  16. </div>
  17. <div class="info_word">
  18. {{ item.title }}
  19. </div>
  20. </el-col>
  21. </el-row>
  22. <el-row type="flex" align="top" :gutter="10" class="jobfair_under_info">
  23. <el-col :span="1">
  24. <div class="el-icon-s-flag info_icon"></div>
  25. </el-col>
  26. <el-col :span="15" :offset="1"> 主办方:{{ item.organizer }} </el-col>
  27. <el-col :span="6" class="info_date">
  28. {{ item.meet_day }}
  29. </el-col>
  30. </el-row>
  31. <el-row type="flex" align="top" :gutter="10" class="jobfair_under_info">
  32. <el-col :span="1">
  33. <div class="el-icon-position info_icon"></div>
  34. </el-col>
  35. <el-col :span="15" :offset="1">
  36. {{ item.address }}
  37. </el-col>
  38. <el-col :span="6" class="info_time">
  39. {{ item.meet_time }}
  40. </el-col>
  41. </el-row>
  42. <el-row type="flex" align="middle" :gutter="10" class="jobfair_under_info">
  43. <el-col :span="1">
  44. <div class="el-icon-user-solid info_icon"></div>
  45. </el-col>
  46. <el-col :span="15" :offset="1"> 时间:{{ item.time }} </el-col>
  47. <!-- <el-col :span="6" class="el-icon-view info_icon info_date view_icon">
  48. {{ item.fact_c_count }}
  49. </el-col> -->
  50. </el-row>
  51. </el-row>
  52. </span>
  53. <nodata v-else></nodata>
  54. </template>
  55. </list-layout>
  56. </div>
  57. </template>
  58. <script>
  59. import listLayout from '@/layout/list-layout.vue';
  60. import nodata from '@/components/nodata.vue';
  61. import { mapActions, mapState } from 'vuex';
  62. export default {
  63. metaInfo() {
  64. return {
  65. title: '校园招聘会',
  66. };
  67. },
  68. name: 'jobfair',
  69. props: {
  70. searchVal: { type: String, default: '' },
  71. },
  72. components: {
  73. listLayout,
  74. nodata,
  75. },
  76. data: () => ({
  77. list: {},
  78. totalRow: 20,
  79. hasMore: true,
  80. searchInfo: {},
  81. }),
  82. created() {
  83. this.changeState(this.$route.query.type);
  84. this.search();
  85. },
  86. computed: {
  87. ...mapState({
  88. user: state => state.user.user,
  89. }),
  90. },
  91. methods: {
  92. ...mapActions(['fairsOperation']),
  93. async search(type) {
  94. let skip = 0;
  95. //判断下type,如果type存在.当前页加一
  96. if (type && type === 'nextPage') {
  97. this.currentPage++; //当前页加一
  98. skip = (this.currentPage - 1) * this.$limit; //重新计算skip:即计算数据库开始查询的位置
  99. }
  100. if (!this.hasMore) return false; //判断的是:如果我列表的数据条数大于等于数据库返回给我的总数时=>我就不查了.没数据了
  101. this.$set(this, `hasMore`, false); //控制无限加载瞬间加载N次的情况
  102. let result = await this.fairsOperation({ type: 'list', data: { skip: skip, limit: this.$limit, ...this.searchInfo } }); //查询,添加skip和limit参数
  103. if (`${result.errcode}` === '0') {
  104. if (type && type === 'nextPage') {
  105. this.$set(this, `list`, this.list.concat(result.data)); //将现有的列表和请求来的数据列表合并到一起,自动追加在下面import '@/plugins/var';
  106. } else {
  107. this.$set(this, `list`, result.data);
  108. }
  109. this.$set(this, `totalRow`, result.total); //将数据库返回的总数放到页面的totalRow变量中,用来判断
  110. this.$set(this, `hasMore`, this.list.length < this.totalRow); //此处是根据数据库总数的结果和当前列表的总条数比较,看看是否可以继续请求数据
  111. }
  112. },
  113. searchBar({ type, value }) {
  114. this.$set(this, `searchInfo`, value);
  115. if (type === 'search') {
  116. this.hasMore = true;
  117. this.search();
  118. }
  119. },
  120. changeState(type) {
  121. if (typeof this.user !== 'object') {
  122. this.$message.error('请先登录');
  123. return false;
  124. }
  125. if (type === 'in') {
  126. this.searchInfo.schid = this.user.schid;
  127. this.schIn = 'in';
  128. } else {
  129. this.searchInfo.schid = undefined;
  130. this.schIn = 'out';
  131. }
  132. },
  133. link(id) {
  134. window.location.href = `jobfair.html#/?id=${id}`;
  135. },
  136. },
  137. };
  138. </script>
  139. <style lang="less" scoped>
  140. .jobfair_list {
  141. padding: 1rem;
  142. background: #fff;
  143. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  144. border-bottom: 1px dashed;
  145. }
  146. .jobfair_icon {
  147. background-color: #25b6ed;
  148. border-radius: 50% 0 50% 50%;
  149. color: #fff;
  150. width: 3rem;
  151. height: 3rem;
  152. padding-top: 0.8rem;
  153. padding-left: 0.5rem;
  154. }
  155. .jobfair_info {
  156. margin-left: 1rem;
  157. }
  158. .info_word {
  159. text-indent: 0.8rem;
  160. line-height: 2rem;
  161. color: #000;
  162. font-size: 1rem;
  163. word-wrap: break-word;
  164. }
  165. .recommend_tag {
  166. position: relative;
  167. top: 0;
  168. }
  169. .recommed_mark {
  170. border-radius: 0% 0 0 100%;
  171. background-color: #f40;
  172. color: #fff;
  173. font-size: 1rem;
  174. position: absolute;
  175. top: -1rem;
  176. right: -1rem;
  177. height: 1.5rem;
  178. width: 1.8rem;
  179. padding-top: 0.1rem;
  180. text-align: center;
  181. }
  182. .time_off {
  183. @extend .recommed_mark;
  184. background-color: #ccc;
  185. }
  186. .jobfair_under_info {
  187. font-size: 14px;
  188. color: #666;
  189. }
  190. .info_icon {
  191. color: #ccc;
  192. zoom: 1.5;
  193. }
  194. .info_date {
  195. text-align: right;
  196. font-size: 12px;
  197. }
  198. .info_time {
  199. @extend .info_date;
  200. color: #ff4400;
  201. }
  202. .view_icon {
  203. zoom: 1;
  204. color: #999999;
  205. }
  206. </style>