filterStatus.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view class="">
  3. <u-popup v-model="filterStatus" mode="bottom" border-radius="14" height="800" safe-area-inset-bottom
  4. :mask-close-able="false">
  5. <view class="header">
  6. <view> </view>
  7. <view style="font-size: 32rpx;">筛选课程</view>
  8. <u-icon name="close" @click="filterStatus = false"></u-icon>
  9. </view>
  10. <view class="li_s" @click="openSearch(1)">
  11. <view class="left">
  12. 教育类型:
  13. </view>
  14. <view class="right">
  15. {{filterEdu(educationType).find(i => i.id == activeData.educationId) && filterEdu(educationType).find(i => i.id == activeData.educationId)['educationName']}}
  16. </view>
  17. <u-icon class="icon" name="arrow-right"></u-icon>
  18. </view>
  19. <view class="li_s" @click="openSearch(2)">
  20. <view class="left">
  21. 培训项目:
  22. </view>
  23. <view class="right">
  24. {{filterBus(businessLevel).find(i => i.id == activeData.businessId) && filterBus(businessLevel).find(i => i.id == activeData.businessId)['aliasName']}}
  25. </view>
  26. <u-icon class="icon" name="arrow-right"></u-icon>
  27. </view>
  28. <view class="li_s" @click="openSearch(3)">
  29. <view class="left">
  30. 科目:
  31. </view>
  32. <view class="right">
  33. {{filterSuj(sujectType).find(i => i.id == activeData.subjectId) && filterSuj(sujectType).find(i => i.id == activeData.subjectId)['subjectName']}}
  34. </view>
  35. <u-icon class="icon" name="arrow-right"></u-icon>
  36. </view>
  37. <view class="li_s" @click="openSearch(4)">
  38. <view class="left">
  39. 排序:
  40. </view>
  41. <view class="right">
  42. {{sortTypeList.find(i => i.value == activeData.sortType)['label']}}
  43. </view>
  44. <u-icon class="icon" name="arrow-right"></u-icon>
  45. </view>
  46. <view class="footer">
  47. <view class="custom-style-l" @click="initData">重置</view>
  48. <view class="custom-style-r" @click="submit">确定</view>
  49. </view>
  50. <u-select :mask-close-able="false" v-model="showEdu" :list="filterEdu(educationType)"
  51. label-name="educationName" value-name="id" @confirm="confirmA"
  52. :default-value="[filterEdu(educationType).findIndex(i => i.id == activeData.educationId)]"></u-select>
  53. <u-select :mask-close-able="false" v-model="showBus" :list="filterBus(businessLevel)" label-name="aliasName"
  54. value-name="id" @confirm="confirmB"
  55. :default-value="[filterBus(businessLevel).findIndex(i => i.id == activeData.businessId)]"></u-select>
  56. <u-select :mask-close-able="false" v-model="showSuj" :list="filterSuj(sujectType)" label-name="subjectName"
  57. value-name="id" @confirm="confirmC"
  58. :default-value="[filterSuj(sujectType).findIndex(i => i.id == activeData.subjectId)]"></u-select>
  59. <u-select :mask-close-able="false" v-model="showSort" :list="sortTypeList" @confirm="confirmD"
  60. :default-value="[sortTypeList.findIndex(i => i.value == activeData.sortType)]"></u-select>
  61. </u-popup>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. mapGetters
  67. } from "vuex";
  68. export default {
  69. data() {
  70. return {
  71. filterStatus: false,
  72. showEdu: false,
  73. showBus: false,
  74. showSuj: false,
  75. showSort: false,
  76. activeData: {
  77. educationId: "",
  78. projectId: "",
  79. businessId: "",
  80. subjectId: "",
  81. sortType: 1
  82. },
  83. sortTypeList: [{
  84. label: "综合",
  85. value: 1
  86. }, {
  87. label: "低价",
  88. value: 2
  89. }, {
  90. label: "高价",
  91. value: 3
  92. }]
  93. };
  94. },
  95. computed: {
  96. ...mapGetters(["educationType", "businessLevel", "sujectType"]),
  97. filterEdu: function() {
  98. return function(list) {
  99. if (list && list.length > 0) {
  100. let array = JSON.parse((JSON.stringify(list)))
  101. array.unshift({
  102. id: "",
  103. educationName: "全部",
  104. })
  105. return array
  106. } else {
  107. return []
  108. }
  109. }
  110. },
  111. filterBus: function() {
  112. return function(list) {
  113. if (list && list.length > 0) {
  114. let array = JSON.parse((JSON.stringify(list)))
  115. array.unshift({
  116. id: "",
  117. aliasName: "全部",
  118. projectId: ""
  119. })
  120. return array.filter(i => {
  121. return i.educationId == this.activeData.educationId || i.id == ""
  122. })
  123. } else {
  124. return []
  125. }
  126. }
  127. },
  128. filterSuj: function() {
  129. return function(list) {
  130. if (list && list.length > 0) {
  131. let array = JSON.parse((JSON.stringify(list)))
  132. array.unshift({
  133. id: "",
  134. subjectName: "全部",
  135. projectList: []
  136. })
  137. return array.filter(i => {
  138. return i.projectList.includes(this.activeData.projectId) || i.id == ""
  139. })
  140. } else {
  141. return []
  142. }
  143. }
  144. },
  145. },
  146. onLoad(option) {},
  147. methods: {
  148. initData() {
  149. this.activeData = {
  150. educationId: "",
  151. projectId: "",
  152. businessId: "",
  153. subjectId: "",
  154. sortType: 1
  155. }
  156. },
  157. submit() {
  158. this.$emit("backFunc", this.activeData)
  159. this.filterStatus = false
  160. },
  161. confirmA(i) {
  162. this.activeData.educationId = i[0].value
  163. this.activeData.projectId = ""
  164. this.activeData.businessId = ""
  165. this.activeData.subjectId = ""
  166. },
  167. confirmB(i) {
  168. this.activeData.projectId = this.filterBus(this.businessLevel).find(k => k.id == i[0].value)['projectId']
  169. this.activeData.businessId = i[0].value
  170. this.activeData.subjectId = ""
  171. },
  172. confirmC(i) {
  173. this.activeData.subjectId = i[0].value
  174. },
  175. confirmD(i) {
  176. this.activeData.sortType = i[0].value
  177. },
  178. openSearch(i) {
  179. let ary = ["showEdu", "showBus", "showSuj", "showSort"]
  180. this[ary[i - 1]] = true
  181. },
  182. openBoxs(item) {
  183. this.activeData = Object.assign({}, item)
  184. this.filterStatus = true
  185. },
  186. }
  187. };
  188. </script>
  189. <style scoped lang="scss">
  190. .header {
  191. height: 100rpx;
  192. font-size: 34rpx;
  193. border-bottom: 1rpx solid #eee;
  194. display: flex;
  195. padding: 0rpx 40rpx;
  196. justify-content: space-between;
  197. align-items: center;
  198. }
  199. .li_s {
  200. display: flex;
  201. align-items: center;
  202. height: 100rpx;
  203. border-bottom: 1rpx solid #eee;
  204. padding: 0rpx 20rpx 0rpx 40rpx;
  205. &>.left {
  206. width: 140rpx;
  207. margin-right: 40rpx;
  208. flex-shrink: 0;
  209. text-align: end;
  210. }
  211. &>.right {
  212. flex: 1;
  213. width: 1rpx;
  214. text-align: end;
  215. margin-right: 20rpx;
  216. text-overflow: ellipsis;
  217. white-space: nowrap;
  218. overflow: hidden;
  219. }
  220. }
  221. .footer {
  222. margin-top: 160rpx;
  223. display: flex;
  224. align-items: center;
  225. justify-content: space-between;
  226. padding: 0rpx 40rpx;
  227. font-size:28rpx;
  228. .custom-style-l {
  229. margin-right: 20rpx;
  230. flex: 1;
  231. background-color: #f3f3f3;
  232. color: #7f7f7f;
  233. text-align: center;
  234. padding: 20rpx 0rpx;
  235. border-radius: 8rpx;
  236. }
  237. .custom-style-r {
  238. border-radius: 8rpx;
  239. padding: 20rpx 0rpx;
  240. background-color: #007aff;
  241. color: #ffffff;
  242. width: 70%;
  243. text-align: center;
  244. }
  245. }
  246. </style>