PrevEnrollPlan.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div v-loading="loading" class="fx-column">
  3. <div class="fx-row fx-bet-cen mt15 mb10">
  4. <div class="fx-row">
  5. <el-select v-if="pureMode&&!isPrePlanAsYzy" v-model="query.category" class="mr10" @change="initProcess">
  6. <el-option v-for="item in queryData.categories" :key="item.label" :label="item.label" :value="item.value" />
  7. </el-select>
  8. <el-select v-model="query.year" placeholder="请选择年份" @change="handleYearChange">
  9. <el-option v-for="item in queryData.years" :key="item.label" :label="item.label" :value="item.value" />
  10. </el-select>
  11. <el-select v-model="query.type" placeholder="请选择科目" class="ml10" @change="handleTypeChange">
  12. <el-option v-for="item in queryData.types" :key="item.label" :label="item.label" :value="item.value" />
  13. </el-select>
  14. <el-cascader
  15. ref="cascader"
  16. v-model="query.tagCode"
  17. placeholder="计划类别不限"
  18. :options="preTree"
  19. :props="{emitPath:false,checkStrictly:true}"
  20. :show-all-levels="false"
  21. clearable
  22. filterable
  23. class="ml10"
  24. @change="handleTagChange"
  25. />
  26. </div>
  27. <div>
  28. <el-input
  29. v-model="query.keyword"
  30. placeholder="请输入院校/专业名称"
  31. suffix-icon="el-icon-search"
  32. style="width: 250px"
  33. clearable
  34. @keyup.enter.native="handleSearch"
  35. />
  36. <el-button type="primary" class="ml10" @click="handleSearch">搜索</el-button>
  37. </div>
  38. </div>
  39. <dynamic-table :rows="rows" :columns="columns" border>
  40. <template #university="{row, display}">
  41. <div class="pointer hover-primary" @click="toDetail(row)">{{ display }}</div>
  42. </template>
  43. <template #groupsName="{row, display}">
  44. <div v-if="display">{{ display }}</div>
  45. <div>{{ row.premark }}</div>
  46. </template>
  47. <template #marjorBelongs="{row, display}">
  48. <div>[{{ display }}]{{ row['marjorName'] }}</div>
  49. <div class="f12 f-999">{{ row.marjorDirection }}</div>
  50. </template>
  51. <template #tag="{display}">
  52. <enroll-plan-tags :value="display" />
  53. </template>
  54. </dynamic-table>
  55. <vip-guide-more v-if="total>1&&!isBind" />
  56. <pagination :total="total" :page.sync="query.pageNum" :limit.sync="query.pageSize" @pagination="getList" />
  57. </div>
  58. </template>
  59. <script>
  60. import { getPreRecruitPlan, getPreRecruitPlanTypes, getPreRecruitPlanYears } from '@/api/webApi/prev-batch'
  61. import DynamicTable from '@/components/dynamic-table/index.vue'
  62. import transferMixin from '@/components/TransferMixin'
  63. import { mapActions, mapGetters, mapState } from 'vuex'
  64. import EnrollPlanTags from '@/views/career/PrevBatch/components/EnrollPlanTags.vue'
  65. import MxConst from '@/common/MxConst'
  66. import VipGuideMore from '@/components/VipGuideMore/index.vue'
  67. export default {
  68. name: 'PrevEnrollPlan',
  69. components: { VipGuideMore, EnrollPlanTags, DynamicTable },
  70. mixins: [transferMixin],
  71. props: {
  72. category: {
  73. type: String | Number,
  74. default: ''
  75. },
  76. universityCode: {
  77. type: String | Number,
  78. default: ''
  79. }
  80. },
  81. data() {
  82. return {
  83. loading: false,
  84. query: {
  85. pageNum: 1,
  86. pageSize: 10,
  87. category: this.category || this.$route.meta.category,
  88. year: '',
  89. type: '',
  90. tagCode: '',
  91. keyword: '',
  92. universityCode: this.universityCode
  93. },
  94. queryData: {
  95. years: [],
  96. types: [],
  97. categories: []
  98. },
  99. total: 0,
  100. rows: [],
  101. columns: [{
  102. label: '院校名称',
  103. prop: 'universityName',
  104. slotBody: 'university',
  105. width: '120px'
  106. }, {
  107. label: '专业组',
  108. prop: 'groupsName',
  109. width: '120px',
  110. slotBody: 'groupsName'
  111. }, {
  112. label: '招生代码',
  113. prop: 'collegeCode',
  114. width: '90px'
  115. }, {
  116. label: '年份',
  117. prop: 'year',
  118. width: '60px'
  119. }, {
  120. label: '招生专业',
  121. prop: 'marjorBelongs',
  122. slotBody: 'marjorBelongs'
  123. }, {
  124. label: '计划类别',
  125. prop: 'tag',
  126. align: 'left',
  127. slotBody: 'tag'
  128. }, {
  129. label: '选考科目',
  130. prop: 'course',
  131. width: '90px'
  132. }, {
  133. label: '计划数',
  134. prop: 'planCount',
  135. width: '60px'
  136. }, {
  137. label: '学制',
  138. prop: 'xuezhi',
  139. width: '60px'
  140. }, {
  141. label: '学费',
  142. prop: 'xuefei',
  143. width: '60px'
  144. }]
  145. }
  146. },
  147. computed: {
  148. ...mapGetters(['isBind', 'isPrePlanAsYzy']),
  149. ...mapState({ preTree: state => state.cachedData.preTree }),
  150. pureMode() {
  151. return !!this.universityCode // now work in university detail page.
  152. }
  153. },
  154. watch: {
  155. 'query.year': function() {
  156. // refresh cached data `preTree`
  157. if (!this.query.category) return
  158. this.query.tagCode = ''
  159. this.loadPreTree({ category: this.query.category, year: this.query.year })
  160. }
  161. },
  162. created() {
  163. const categoryKeys = MxConst.enum.recruitPlanCategory.visibleKeys
  164. this.queryData.categories = categoryKeys.map(key => {
  165. const val = MxConst.enum.recruitPlanCategory[key]
  166. return {
  167. label: MxConst.enum.recruitPlanCategory.names[val],
  168. value: val
  169. }
  170. })
  171. },
  172. async mounted() {
  173. await this.initProcess()
  174. },
  175. methods: {
  176. ...mapActions({ 'loadPreTree': 'cachedData/ensurePreTree' }),
  177. _makeOptions(rows, all) {
  178. const options = rows.map(item => ({
  179. label: item,
  180. value: item
  181. }))
  182. if (all) options.unshift({ label: all, value: '' })
  183. return options
  184. },
  185. async initProcess() {
  186. await this.initQueryYear()
  187. await this.initQueryType()
  188. await this.getList()
  189. },
  190. async initQueryYear() {
  191. const res = await getPreRecruitPlanYears({ category: this.query.category })
  192. this.queryData.years = this._makeOptions(res['rows'])
  193. this.query.year = this.queryData.years.first().value
  194. },
  195. async initQueryType() {
  196. if (!this.query.year) {
  197. this.queryData.types = [{ label: '科目不限', value: '' }]
  198. this.query.type = ''
  199. return
  200. }
  201. const res = await getPreRecruitPlanTypes({ category: this.query.category, year: this.query.year })
  202. this.queryData.types = this._makeOptions(res['rows'], '科目不限')
  203. this.query.type = this.queryData.types.first().value
  204. },
  205. async handleYearChange() {
  206. await this.initQueryType()
  207. this.query.pageNum = 1
  208. await this.getList()
  209. },
  210. async handleTypeChange() {
  211. this.query.pageNum = 1
  212. await this.getList()
  213. },
  214. handleTagChange() {
  215. this.$refs.cascader.toggleDropDownVisible(false)
  216. this.query.pageNum = 1
  217. this.getList()
  218. },
  219. handleSearch() {
  220. this.query.pageNum = 1
  221. this.getList()
  222. },
  223. async getList() {
  224. this.loading = true
  225. try {
  226. const res = await getPreRecruitPlan(this.query)
  227. this.rows = res.rows
  228. this.total = res.total
  229. } finally {
  230. this.loading = false
  231. }
  232. },
  233. toDetail(row) {
  234. this.transferTo('/career/plan/UniversityDetail', { code: row.universityCode })
  235. }
  236. }
  237. }
  238. </script>