filters.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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">
  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 experiences" :key="item.name" @click="select('experiences', 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. list: {
  54. type: Array
  55. }
  56. },
  57. data() {
  58. return {
  59. type: 0,
  60. positionName: '不限',
  61. positionId: '',
  62. experiences: [{ name: '不限' }, { name: '1年以内' }, { name: '1-3年' }, { name: '3-5年' }, { name: '5-10年' }, { name: '10年以上' }],
  63. salary: [{ name: '不限' }, { name: '1-3k' }, { name: '3-5k' }, { name: '5-10k' }, { name: '10-20k' }, { name: '20-50k' }, { name: '50k以上' }]
  64. };
  65. },
  66. mounted() {
  67. uni.$on('select_position', (res) => {
  68. this.positionName = res.title;
  69. this.positionId = res.id;
  70. this.$forceUpdate();
  71. });
  72. },
  73. methods: {
  74. select(tag, item, index) {
  75. if (tag == 'salary') {
  76. this.salary.forEach((i) => (i.check = false));
  77. item.check = true;
  78. } else {
  79. if (index == 0) {
  80. this[tag].forEach((i) => (i.check = false));
  81. item.check = true;
  82. } else {
  83. this[tag][0].check = false;
  84. item.check = !item.check;
  85. }
  86. }
  87. this.$forceUpdate();
  88. },
  89. confirm(item) {
  90. this.$emit('input', false);
  91. this.$emit('confirm', {
  92. experiences: this.experiences.filter((item) => item.check && item.name != '不限'),
  93. salary: this.salary.filter((item) => item.check),
  94. positionId: this.positionId
  95. });
  96. },
  97. go(url) {
  98. uni.navigateTo({ url: url });
  99. },
  100. clear() {
  101. this.salary.forEach((i) => (i.check = false));
  102. this.experiences.forEach((i) => (i.check = false));
  103. this.positionName = '不限';
  104. this.positionId = '';
  105. this.$forceUpdate();
  106. this.$emit('confirm', { experiences: [], salary: '', positionId: '' });
  107. this.$emit('input', false);
  108. },
  109. close() {
  110. this.$emit('input', false);
  111. }
  112. }
  113. };
  114. </script>
  115. <style lang="scss">
  116. .ppopup {
  117. padding: 10px;
  118. .title {
  119. font-size: 17px;
  120. margin-top: 12px;
  121. margin-bottom: 12px;
  122. font-weight: bold;
  123. padding-left: 5px;
  124. .icon {
  125. float: right;
  126. }
  127. }
  128. .item {
  129. overflow: hidden;
  130. .tags {
  131. width: 33.33%;
  132. .int {
  133. &.active {
  134. background-color: $main-color;
  135. color: white;
  136. }
  137. }
  138. }
  139. }
  140. .f {
  141. margin: 7px;
  142. .btn {
  143. margin-top: 10px;
  144. padding: 0px;
  145. }
  146. .ex {
  147. background-color: #f3f3f3;
  148. color: #6b6b6b;
  149. }
  150. }
  151. }
  152. </style>