majorChoice.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div class="major-page">
  3. <div class="breadcrumb">
  4. <el-breadcrumb separator="/">
  5. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  6. <el-breadcrumb-item :to="{ path: '/career/plan/index' }"
  7. >生涯·志愿</el-breadcrumb-item
  8. >
  9. <el-breadcrumb-item :to="{ path: '/career/subject/index' }"
  10. >选科查询</el-breadcrumb-item
  11. >
  12. <el-breadcrumb-item>由专业选科目</el-breadcrumb-item>
  13. </el-breadcrumb>
  14. </div>
  15. <div class="content-box">
  16. <div class="xkcx-input-box">
  17. <div>
  18. <el-select
  19. v-model="selected.selectNian"
  20. @change="onChangeYear"
  21. placeholder="全部年份"
  22. >
  23. <el-option
  24. v-for="(item, index) in selected.yearList"
  25. :key="index"
  26. :label="item"
  27. :value="item"
  28. >
  29. </el-option>
  30. </el-select>
  31. </div>
  32. <div class="button-school">
  33. <el-button plain @click="onChangeSchoolPopup">
  34. 学校
  35. <i class="el-icon-my-button"></i>
  36. </el-button>
  37. </div>
  38. <div class="button-major">
  39. <el-button plain @click="onChangeMajorPopup">
  40. 专业<i class="el-icon-my-button"></i
  41. ></el-button>
  42. </div>
  43. <div class="search_header">
  44. <input
  45. placeholder="搜索专业"
  46. v-model="keyword"
  47. @keyup.enter="httpGetXkcxList()"
  48. />
  49. <img
  50. src="@/assets/images/icon_search2.png"
  51. alt=""
  52. @click="httpGetXkcxList()"
  53. />
  54. </div>
  55. </div>
  56. <div class="popup-box major-box">
  57. <div class="popup-select">
  58. <div
  59. class="popup-select-item"
  60. :class="selected.marjorsType == '本科' ? 'active' : ''"
  61. @click="clickMarjorsType('本科')"
  62. >
  63. 本科
  64. </div>
  65. <div
  66. class="popup-select-item"
  67. :class="selected.marjorsType == '专科' ? 'active' : ''"
  68. @click="clickMarjorsType('专科')"
  69. >
  70. 专科
  71. </div>
  72. </div>
  73. <div class="choice-box">
  74. <div class="choice-item">
  75. <div
  76. class="choice-item-menv"
  77. v-for="(item, index) in selected.marjorsList.one"
  78. :key="index"
  79. :class="selected.curMarjors.one.code == item.code ? 'active' : ''"
  80. @click="changeMajor(item)"
  81. >
  82. {{ item.name }}
  83. </div>
  84. </div>
  85. <div class="choice-item">
  86. <div
  87. class="choice-item-menv"
  88. v-for="(item, index) in selected.marjorsList.two"
  89. :key="index"
  90. :class="selected.curMarjors.two.code == item.code ? 'active' : ''"
  91. @click="changeMajor(item)"
  92. >
  93. {{ item.name }}
  94. </div>
  95. </div>
  96. <div class="choice-item">
  97. <el-checkbox-group v-model="selected.curMarjors.three" @change="httpGetXkcxList">
  98. <el-checkbox
  99. class="choice-item-checkbox"
  100. label="全选"
  101. @change="onSelectMarjorsAll"
  102. ></el-checkbox>
  103. <el-checkbox
  104. class="choice-item-checkbox"
  105. :label="item.name"
  106. v-for="(item, index) in selected.marjorsList.three"
  107. :key="index"
  108. ></el-checkbox>
  109. </el-checkbox-group>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="concerned-college-container">
  114. <mx-table :rows="dataList" :propDefines="propDefines">
  115. <template #select="{ row }">
  116. <img
  117. class="college-icon"
  118. v-if="row.collect"
  119. @click="httpCollectRemove(row)"
  120. src="@/assets/images/subject/icon_shoucang_pre.png"
  121. />
  122. <img
  123. class="college-icon"
  124. v-else
  125. @click="httpCollectAdd(row)"
  126. src="@/assets/images/subject/icon_shoucang_n.png"
  127. />
  128. </template>
  129. </mx-table>
  130. <pagination
  131. v-show="total > 0"
  132. :total="total"
  133. :page.sync="pageNum"
  134. :limit.sync="pageSize"
  135. :page-size="20"
  136. @pagination="onChangePage"
  137. />
  138. </div>
  139. </div>
  140. </div>
  141. </template>
  142. <script>
  143. import {xkcxYears, collectAdd, collectRemove, marjorsList, xkcxlistByMarjors} from "@/api/webApi/webQue";
  144. export default {
  145. data() {
  146. return {
  147. selected: {
  148. yearList: [],
  149. selectNian: '',
  150. marjorsType: "本科",
  151. marjorsLevel: 1,
  152. marjorsCode: "",
  153. marjorsList: {
  154. one: [], two: [], three: []
  155. },
  156. curMarjors: {
  157. one: "", two: "", three: []
  158. }
  159. },
  160. dataList: [
  161. ],
  162. propDefines: {
  163. universityName: {
  164. label: "院校名称",
  165. },
  166. marjorName: {
  167. label: "专业(类)名称",
  168. },
  169. marjorBelongs: {
  170. label: "专业备注",
  171. align: "left",
  172. },
  173. level: {
  174. label: "专业层次",
  175. },
  176. courseRemark0: {
  177. label: "首选科目范围",
  178. align: "left",
  179. },
  180. courseRemark1: {
  181. label: "再选科目范围",
  182. align: "left",
  183. },
  184. year: {
  185. label: "年份",
  186. align: "left",
  187. },
  188. collect: {
  189. label: "选择",
  190. align: "left",
  191. slot: "select",
  192. width: "100px",
  193. },
  194. },
  195. selectIds: [],
  196. pageNum: 1,
  197. pageSize: 10,
  198. total: 0,
  199. keyword: ''
  200. };
  201. },
  202. created() {
  203. this.httpGetXkcxYears();
  204. this.httpGetMarjorsList();
  205. },
  206. methods: {
  207. httpGetXkcxYears() {
  208. xkcxYears().then((res) => {
  209. this.selected.yearList = res.data || [];
  210. this.selected.selectNian = this.selected.yearList[0]
  211. });
  212. },
  213. onChangeYear(res) {
  214. //切换学年时,取第1页
  215. this.pageNum = 1;
  216. this.httpGetMarjorsList();
  217. },
  218. onChangeSchoolPopup() {
  219. this.isShowSchoolPopup = !this.isShowSchoolPopup;
  220. },
  221. onChangeMajorPopup() {
  222. this.isShowMajorPopup = !this.isShowMajorPopup;
  223. },
  224. clickMarjorsType(type) {
  225. this.selected.marjorsType = type;
  226. this.selected.marjorsLevel = 1;
  227. this.selected.marjorsCode = "";
  228. this.httpGetMarjorsList();
  229. },
  230. onSelectMarjorsAll(res) {
  231. if (res) {
  232. let len = this.selected.marjorsList.three.length;
  233. for (let i = 0; i < len; i++) {
  234. let name = this.selected.marjorsList.three[i]["name"];
  235. let index = this.selected.curMarjors.three.indexOf(name);
  236. if (index < 0) {
  237. this.selected.curMarjors.three.push(name);
  238. }
  239. }
  240. } else {
  241. this.selected.curMarjors.three = [];
  242. }
  243. },
  244. changeMajor(res) {
  245. this.selected.curMarjors.three = [];
  246. switch (res.level) {
  247. case 1:
  248. this.selected.curMarjors.one = res;
  249. break;
  250. case 2:
  251. this.selected.curMarjors.two = res;
  252. break;
  253. }
  254. this.selected.marjorsCode = res.code;
  255. this.selected.marjorsLevel = res.level + 1;
  256. this.httpGetMarjorsList();
  257. },
  258. httpGetMarjorsList() {
  259. marjorsList({
  260. type: this.selected.marjorsType,
  261. level: this.selected.marjorsLevel,
  262. code: this.selected.marjorsCode,
  263. }).then((res) => {
  264. switch (this.selected.marjorsLevel) {
  265. case 2:
  266. this.selected.marjorsList.two = res.rows;
  267. this.changeMajor(res.rows[0]);
  268. break;
  269. case 3:
  270. this.selected.marjorsList.three = res.rows;
  271. this.httpGetXkcxList();
  272. break;
  273. default:
  274. this.selected.marjorsList.one = res.rows;
  275. this.changeMajor(res.rows[0]);
  276. break;
  277. }
  278. });
  279. },
  280. // 查询结果
  281. httpGetXkcxList() {
  282. if (this.selected.curMarjors.three.length<1) return;
  283. //console.log(this.selected);return;
  284. xkcxlistByMarjors({
  285. level:this.selected.marjorsType.toString(),
  286. keyword: this.keyword,
  287. year: this.selected.selectNian.toString(),
  288. marjors: this.selected.curMarjors.one.name + "," + this.selected.curMarjors.two.name + "," + this.selected.curMarjors.three.join(","),
  289. pageNum: this.pageNum,
  290. pageSize: this.pageSize,
  291. })
  292. .then((res) => {
  293. this.dataList = res.rows;
  294. this.total = res.total;
  295. this.isShowTable = true;
  296. })
  297. .catch((err) => {
  298. console.log("请求出错!");
  299. this.cleanSchoolSelect();
  300. });
  301. },
  302. onChangePage(page) {
  303. this.pageSize = page.limit;
  304. this.pageNum = page.page;
  305. this.httpGetXkcxList();
  306. },
  307. // 收藏
  308. httpCollectAdd(row) {
  309. row.collect = true;
  310. collectAdd({
  311. refId: row.id,
  312. });
  313. },
  314. // 取消收藏
  315. httpCollectRemove(row) {
  316. row.collect = false;
  317. collectRemove({
  318. refId: row.id,
  319. });
  320. },
  321. },
  322. };
  323. </script>
  324. <style scoped>
  325. .breadcrumb {
  326. padding: 15px 30px;
  327. margin: 15px 0;
  328. border-bottom: 1px solid #eee;
  329. border-radius: 2px;
  330. background-color: #fff;
  331. box-shadow: 0 1px 2px 0 rgb(0 0 0);
  332. }
  333. .content-box {
  334. padding: 10px 40px 10px 50px;
  335. }
  336. .major-list-title span {
  337. color: #d28140;
  338. }
  339. el-button {
  340. padding: 9px 20px;
  341. }
  342. .button-school {
  343. margin: 0 10px;
  344. }
  345. .el-icon-my-button {
  346. background: url(../../../assets/images/subject/icon_shaixuan.png) center no-repeat;
  347. background-size: cover;
  348. }
  349. .el-icon-my-button:before {
  350. content: "替";
  351. font-size: 16px;
  352. visibility: hidden;
  353. }
  354. .major-box {
  355. display: flex;
  356. margin-bottom: 30px;
  357. }
  358. .popup-select {
  359. border-right: 1px solid #d7d7d7;
  360. }
  361. .popup-select-item {
  362. cursor: pointer;
  363. line-height: 30px;
  364. width: 100px;
  365. padding: 0 20px 0 30px;
  366. }
  367. .popup-select-item.active {
  368. color: #47c6a2;
  369. border-right: 2px solid #47c6a2;
  370. }
  371. .choice-box {
  372. display: flex;
  373. }
  374. .choice-item {
  375. margin: 0 10px;
  376. min-width: 300px;
  377. border: 1px solid #d7d7d7;
  378. height: 300px;
  379. overflow-x: hidden;
  380. overflow-y: auto;
  381. }
  382. .choice-item-menv {
  383. margin: 15px 20px;
  384. cursor: pointer;
  385. }
  386. .choice-item-menv.active {
  387. color: #47c6a2;
  388. }
  389. .choice-item-checkbox {
  390. padding: 10px 20px;
  391. width: 100%;
  392. box-sizing: border-box;
  393. }
  394. .xkcx-input-box {
  395. padding: 20px 0 0;
  396. display: flex;
  397. margin-bottom: 20px;
  398. border-bottom: 2px solid #47c6a2;
  399. }
  400. .search_header {
  401. margin-left: auto;
  402. display: flex;
  403. flex-direction: row;
  404. align-items: center;
  405. justify-content: flex-end;
  406. position: relative;
  407. margin-right: 20px;
  408. }
  409. .search_header img {
  410. position: absolute;
  411. right: 20px;
  412. cursor: pointer;
  413. top: 6px;
  414. }
  415. .search_header input {
  416. background: #f7f7ff;
  417. border-radius: 20px;
  418. border: 1px solid #c6cbf5;
  419. outline: none;
  420. width: 340px;
  421. height: 32px;
  422. padding-left: 24px;
  423. }
  424. </style>