college-picker.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <u-popup :show="localShow" mode="bottom" @close="localShow=false" top="0px">
  3. <mx-filter-page title="选择院校" :filter-parms="queryParams" :local-data="filter"
  4. requires-init-fill use-alias-mapping custom-nav-show custom-nav-back
  5. @search="handleSearch" @navBack="localShow=false">
  6. <view class="fx-row fx-cen-cen px12 bg-white bd-b-1" style="height: 44px">
  7. <u-search v-model="keyword" @search="handleNameSearch2" @custom="handleNameSearch2"/>
  8. </view>
  9. <mx-scroll-empty ref="mescroll" :auto-load="false" :mescroll-ignore-height="44" @query="handleQuery">
  10. <view v-if="categoryNode" class="h44 bg-white fx-row ai-cen pl20">
  11. <u-text type="warning" prefix-icon="bell" :icon-style="{color: $u.color.warning}" :text="`仅显示包含[${categoryNode.name}]专业的院校`" />
  12. </view>
  13. <view class="pt5 pl10 pr10 pb40">
  14. <university-item v-for="item in dataList" :key="item.id" :item="item" class="mt5" @click.native="handleConfirm(item)"/>
  15. </view>
  16. </mx-scroll-empty>
  17. </mx-filter-page>
  18. </u-popup>
  19. </template>
  20. <script>
  21. import CollegeLibrary from "@/pages/career/college-major/components/college-library.vue";
  22. import {findTreeNode} from "@/common/tools/tree-helper";
  23. export default {
  24. name: "college-picker",
  25. extends: CollegeLibrary,
  26. props: {
  27. show: {
  28. type: Boolean,
  29. default: false
  30. },
  31. excepts: {
  32. // 互拆选择的时候传入
  33. type: Array,
  34. default: () => []
  35. },
  36. majorCategory: {
  37. type: String | Number,
  38. default: ''
  39. }
  40. },
  41. data() {
  42. return {
  43. majorTree: [],
  44. localShow: this.show || false
  45. }
  46. },
  47. computed: {
  48. categoryNode() {
  49. if (!this.majorCategory) return null
  50. return findTreeNode(this.majorTree, n => n.code == this.majorCategory)
  51. },
  52. extraParams() {
  53. if (!this.majorCategory) return null
  54. return { majorCategory: this.majorCategory}
  55. }
  56. },
  57. watch: {
  58. show(val) {
  59. this.localShow = val
  60. },
  61. localShow(val) {
  62. this.$emit('update:show', val)
  63. }
  64. },
  65. mounted() {
  66. this.loadMajorTree()
  67. },
  68. methods: {
  69. async loadMajorTree() {
  70. this.majorTree = await this.$store.cache.dispatch('cachedData/GET_ALL_MAJORS')
  71. },
  72. handleNameSearch() {
  73. // override default action: watch keyword change.
  74. // do nothing here. break always searching mode.
  75. },
  76. handleNameSearch2() {
  77. // only do searching while `complete` or `search` button clicked
  78. this.$refs.mescroll.reset()
  79. },
  80. handleConfirm(item) {
  81. if (this.excepts.includes(item.code)) {
  82. this.$message.error('您已经选择过该院校了')
  83. return
  84. }
  85. // emit confirm event
  86. this.$emit('confirm', item)
  87. this.localShow = false
  88. }
  89. }
  90. }
  91. </script>
  92. <style scoped>
  93. </style>