filters.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <u-popup :show="value" @close="close()" round="15" :closeable="true" :mask-close-able="true">
  3. <view class="ppopup">
  4. <u-divider text="条件筛选" style="margin-top: 25px; margin-bottom: -5px"></u-divider>
  5. <scroll-view scroll-y="true" style="height: 450px">
  6. <view class="item">
  7. <view class="title" @click="go('/pages/job/position/classification')">
  8. <text>职位分类</text>
  9. <text class="icon">&#xe631;</text>
  10. </view>
  11. <view class="tags">
  12. <view class="out" @click="go('/pages/job/position/classification')">
  13. <view class="int" :class="{ active: positionName != '不限' }">{{ positionName }}</view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="item">
  18. <view class="title">薪资待遇</view>
  19. <view class="tags" v-for="(item, index) in salary" :key="item.name" @click="select('salary', item, index)">
  20. <view class="out">
  21. <view class="int" :class="{ active: item.check }">{{ item.name }}</view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="item">
  26. <view class="title">经验要求</view>
  27. <view class="tags" v-for="(item, index) in experience" :key="item.name" @click="select('experience', item, index)">
  28. <view class="out">
  29. <view class="int" :class="{ active: item.check }">{{ item.name }}</view>
  30. </view>
  31. </view>
  32. </view>
  33. </scroll-view>
  34. <view class="flex">
  35. <view class="f">
  36. <button class="btn ex" @click="clear()">重置</button>
  37. </view>
  38. <view class="f">
  39. <button class="btn" @click="confirm()">确认</button>
  40. </view>
  41. </view>
  42. </view>
  43. </u-popup>
  44. </template>
  45. <script>
  46. export default {
  47. name: 'filters',
  48. props: {
  49. value: {
  50. type: Boolean,
  51. default: true
  52. }
  53. },
  54. data() {
  55. return {
  56. type: 0,
  57. positionName: '不限',
  58. positionId: '',
  59. experience: [{ name: '不限' }, { name: '1年以内' }, { name: '1-3年' }, { name: '3-5年' }, { name: '5-10年' }, { name: '10年以上' }],
  60. salary: [{ name: '不限' }, { name: '1-3k' }, { name: '3-5k' }, { name: '5-10k' }, { name: '10-20k' }, { name: '20-50k' }, { name: '50k以上' }]
  61. };
  62. },
  63. mounted() {
  64. uni.$on('select_position', (res) => {
  65. this.positionName = res.title;
  66. this.positionId = res.id;
  67. this.$forceUpdate();
  68. });
  69. },
  70. methods: {
  71. select(tag, item, index) {
  72. if (tag == 'salary') {
  73. this.salary.forEach((i) => (i.check = false));
  74. item.check = true;
  75. } else {
  76. if (index == 0) {
  77. this[tag].forEach((i) => (i.check = false));
  78. item.check = true;
  79. } else {
  80. this[tag][0].check = false;
  81. item.check = !item.check;
  82. }
  83. }
  84. this.$forceUpdate();
  85. },
  86. confirm(item) {
  87. this.$emit('input', false);
  88. this.$emit('confirm', {
  89. experience:
  90. this.experience
  91. .filter((item) => item.check && item.name != '不限')
  92. .map((item) => item.name)
  93. .toString() || '',
  94. salary:
  95. this.salary
  96. .filter((item) => item.check)
  97. .map((item) => item.name)
  98. .toString() || '',
  99. positionId: this.positionId || ''
  100. });
  101. },
  102. go(url) {
  103. uni.navigateTo({ url: url });
  104. },
  105. clear() {
  106. this.salary.forEach((i) => (i.check = false));
  107. this.experience.forEach((i) => (i.check = false));
  108. this.positionName = '不限';
  109. this.positionId = '';
  110. this.$forceUpdate();
  111. this.$emit('confirm', { experience: '', salary: '', positionId: '' });
  112. this.$emit('input', false);
  113. },
  114. close() {
  115. this.$emit('input', false);
  116. }
  117. }
  118. };
  119. </script>
  120. <style lang="scss">
  121. .ppopup {
  122. padding: 10px;
  123. .title {
  124. font-size: 17px;
  125. margin-top: 12px;
  126. margin-bottom: 12px;
  127. font-weight: bold;
  128. padding-left: 5px;
  129. .icon {
  130. float: right;
  131. font-size: 20px;
  132. }
  133. }
  134. .item {
  135. overflow: hidden;
  136. .tags {
  137. width: 33.33%;
  138. .int {
  139. &.active {
  140. background-color: $main-color;
  141. color: white;
  142. }
  143. }
  144. }
  145. }
  146. .f {
  147. margin: 7px;
  148. .btn {
  149. margin-top: 10px;
  150. padding: 0px;
  151. }
  152. .ex {
  153. background-color: #f3f3f3;
  154. color: #6b6b6b;
  155. }
  156. }
  157. }
  158. </style>