subjectChoice.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <div >
  3. <div class="content-box">
  4. <div>
  5. <el-row class="radioInput">
  6. <div>
  7. <span class="radiaTitle">年份:</span>
  8. </div>
  9. <el-radio-group v-model="selected.years" @change="yearChange">
  10. <el-radio-button
  11. v-for="item in form.years"
  12. :key="item"
  13. :label="item"
  14. style="margin-bottom: 10px"
  15. ></el-radio-button>
  16. </el-radio-group>
  17. </el-row>
  18. <el-row class="radioInput radioScience">
  19. <div v-if="selectCourse.course0 ? selectCourse.course0.length : selectCourse.course0" class="fx-row">
  20. <span class="radiaTitle">首选科目:</span>
  21. <el-checkbox-group v-model="selected.sciences[0]" @change="onScienceChanged" size="mini" :max="1">
  22. <el-checkbox-button v-for="item in selectCourse.course0" :key="item" :label="item">
  23. {{item}}
  24. </el-checkbox-button>
  25. </el-checkbox-group>
  26. </div>
  27. <div class="fx-row">
  28. <span class="radiaTitle">{{ gkType == 1 ? '再选科目' : '选科科目' }}:</span>
  29. <el-checkbox-group v-model="selected.sciences[1]" @change="onScienceChanged" size="mini" :max="gkType == 1 ? 2 : 3">
  30. <el-checkbox-button v-for="item in selectCourse.course1" :key="item" :label="item">
  31. {{item}}
  32. </el-checkbox-button>
  33. </el-checkbox-group>
  34. </div>
  35. </el-row>
  36. <filter-form :filter="filter_form"></filter-form>
  37. </div>
  38. <div class="content">
  39. <mx-search-group class="mb10" justify="end" :span="12" v-model="keyword" placeholder="请输入内容" @search="httpGetXkcxList"
  40. ></mx-search-group>
  41. <div class="concerned-college-container" v-loading="loading">
  42. <mx-table :rows="dataList" :propDefines="propDefines">
  43. <template #collect="{ row }">
  44. <img
  45. class="college-icon"
  46. v-if="row.collect"
  47. @click="httpCollectRemove(row)"
  48. src="@/assets/images/subject/icon_shoucang_pre.png"
  49. />
  50. <img
  51. class="college-icon"
  52. v-else
  53. @click="httpCollectAdd(row)"
  54. src="@/assets/images/subject/icon_shoucang_n.png"
  55. />
  56. </template>
  57. <template #select="{ row }">
  58. <div @click="saveCourseCollect(row)">
  59. <i class="el-icon el-icon-success" style="color: #42b983" v-if="row.isSelectCourse"></i>
  60. <i class="el-icon el-icon-success" v-else></i>
  61. </div>
  62. </template>
  63. </mx-table>
  64. <pagination
  65. v-show="total > 0"
  66. :total="total"
  67. :page.sync="pageNum"
  68. :limit.sync="pageSize"
  69. :page-size="20"
  70. @pagination="onChangePage"
  71. />
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </template>
  77. <script>
  78. import {collectAdd, collectRemove, xkcxlist, xkcxYears,saveSelectCourse,getSelectCourse} from "@/api/webApi/webQue";
  79. import MxSearchGroup from "@/components/MxSearch/mx-search-group";
  80. import FilterForm from '@/views/career/components/FilterForm';
  81. export default {
  82. props: {
  83. course0:{
  84. type: String,
  85. default: ''
  86. },
  87. course1:{
  88. type: String,
  89. default: ''
  90. },
  91. readonly: {
  92. type: Boolean,
  93. default: false
  94. }
  95. },
  96. components : {
  97. MxSearchGroup,
  98. FilterForm
  99. },
  100. data() {
  101. return {
  102. // 初始条件
  103. form: {
  104. years: [],
  105. },
  106. selectCourse:{},
  107. gkType: 1, // 1 4选2 2 6选3
  108. filter_form:{
  109. location:'',
  110. natureTypeCN:'',
  111. type:'',
  112. level:'',
  113. features:'',
  114. },
  115. // 选中条件
  116. selected: { years:'', sciences:[[],[]]},
  117. pageNum: 1,
  118. pageSize: 20,
  119. total: 0,
  120. loading: false,
  121. keyword: "",
  122. // 查询结果
  123. dataList: [],
  124. isShowTabl: true,
  125. propDefines: {
  126. universityName: {
  127. label: "院校名称",
  128. },
  129. marjorName: {
  130. label: "专业(类)名称",
  131. },
  132. marjorBelongs: {
  133. label: "专业备注",
  134. align: "left",
  135. },
  136. level: {
  137. label: "专业层次",
  138. },
  139. courseRemark0: {
  140. label: "首选科目范围",
  141. align: "left",
  142. },
  143. courseRemark1: {
  144. label: "再选科目范围",
  145. align: "left",
  146. },
  147. year: {
  148. label: "年份",
  149. align: "left",
  150. },
  151. collect: {
  152. hidden: this.readonly,
  153. label: "收藏",
  154. align: "left",
  155. slot: "collect",
  156. width: "100px",
  157. },
  158. subjectCollect: {
  159. hidden: this.readonly,
  160. label: "选科收藏",
  161. align: "left",
  162. slot: "select",
  163. width: "100px",
  164. },
  165. },
  166. };
  167. },
  168. watch:{
  169. filter_form:{
  170. deep:true,
  171. handler(val) {
  172. this.httpGetXkcxList()
  173. }
  174. },
  175. },
  176. created() {
  177. this.selected.sciences[0] = this.course0 ? [this.course0] : []
  178. this.selected.sciences[1] = this.course1? this.course1.split(',') :[]
  179. if(this.course0 && this.course1) this.httpGetXkcxList()
  180. this.getYears();
  181. this.getSelectCourse()
  182. },
  183. methods: {
  184. getSelectCourse(){
  185. getSelectCourse().then(res => {
  186. this.selectCourse = res.data
  187. if(!res.data.course0.length) {
  188. this.gkType = 2
  189. }else {
  190. this.gkType = 1
  191. }
  192. })
  193. },
  194. // 有效年份
  195. getYears() {
  196. xkcxYears().then((res) => {
  197. this.form.years = res.data || [];
  198. this.selected.years = this.form.years[0]
  199. });
  200. },
  201. yearChange(value) {
  202. this.httpGetXkcxList();
  203. },
  204. onScienceChanged(value) {
  205. this.httpGetXkcxList();
  206. },
  207. httpGetXkcxList() {
  208. const course = [...this.selected.sciences[0],...this.selected.sciences[1]]
  209. if (course.length<3) return;
  210. //console.log(this.selected);return;
  211. this.loading = true
  212. xkcxlist({
  213. keyword: this.keyword,
  214. course0: this.selected.sciences[0].toString(),
  215. course1: this.selected.sciences[1].toString(),
  216. year: this.selected.years.toString(),
  217. ...this.filter_form,
  218. pageNum: this.pageNum,
  219. marjors: [],
  220. pageSize: this.pageSize,
  221. })
  222. .then((res) => {
  223. this.dataList = res.rows;
  224. this.total = res.total;
  225. this.isShowTable = true;
  226. })
  227. .catch((err) => {
  228. console.log("请求出错!");
  229. this.cleanSchoolSelect();
  230. }).finally(() => {
  231. this.loading = false
  232. })
  233. },
  234. onChangePage(page) {
  235. this.pageSize = page.limit;
  236. this.pageNum = page.page;
  237. this.httpGetXkcxList();
  238. },
  239. // 收藏
  240. httpCollectAdd(row) {
  241. row.collect = true;
  242. collectAdd({
  243. refId: row.id,
  244. });
  245. },
  246. // 选科收藏 取消和收藏
  247. saveCourseCollect(row) {
  248. saveSelectCourse({
  249. refId:row.id,
  250. isSelectCourse: !row.isSelectCourse
  251. }).then(res =>{
  252. if(res.code== 200){
  253. row.isSelectCourse = !row.isSelectCourse
  254. this.$message.success(res.msg)
  255. }
  256. })
  257. },
  258. // 取消收藏
  259. httpCollectRemove(row) {
  260. row.collect = false;
  261. collectRemove({
  262. refId: row.id,
  263. });
  264. },
  265. },
  266. };
  267. </script>
  268. <style scoped>
  269. .el-icon-success{
  270. cursor: pointer;
  271. }
  272. .college-icon {
  273. cursor: pointer;
  274. }
  275. .search_header {
  276. margin-left: auto;
  277. display: flex;
  278. flex-direction: row;
  279. align-items: center;
  280. justify-content: flex-end;
  281. position: relative;
  282. margin-right: 20px;
  283. }
  284. .search_header img {
  285. position: absolute;
  286. right: 20px;
  287. cursor: pointer;
  288. top: 6px;
  289. }
  290. .search_header input {
  291. background: #f7f7ff;
  292. border-radius: 20px;
  293. border: 1px solid #c6cbf5;
  294. outline: none;
  295. width: 340px;
  296. height: 32px;
  297. padding-left: 24px;
  298. }
  299. .popup-item-title span {
  300. font-size: 14px;
  301. font-weight: 500;
  302. }
  303. </style>
  304. <style lang="scss" scoped>
  305. .layui-bg-orange {
  306. background-color: var(--themeColor);
  307. margin-left: 0;
  308. }
  309. </style>
  310. <style lang="scss">
  311. .el-checkbox-button {
  312. margin-bottom: 10px;
  313. .el-checkbox-button__inner {
  314. font-size: 14px;
  315. }
  316. }
  317. .radioInput {
  318. background-color: #ffffff;font-size: 14px;padding:5px;
  319. .el-radio {
  320. .el-radio__input {
  321. display: none;
  322. }
  323. }
  324. }
  325. .radioInput.radioScience {
  326. .el-radio-button {
  327. border: 1px solid #47C6A2;
  328. border-radius: 3px;
  329. margin-right: 10px;
  330. }
  331. }
  332. .radioInput {
  333. display: flex;
  334. .el-radio-button .el-radio-button__inner {
  335. border-radius: 4px !important;
  336. border: none;
  337. padding: 5px 10px !important;
  338. font-weight: 400;
  339. font-family: PingFangSC-Regular, PingFang SC;
  340. }
  341. .el-radio-button__orig-radio:checked + .el-radio-button__inner {
  342. box-shadow: none;
  343. }
  344. .radiaTitle {
  345. display: inline-block;
  346. width: 80px;
  347. font-size: 14px;
  348. text-align: right;
  349. margin-top: 2px;
  350. margin-right: 10px;
  351. }
  352. }
  353. //.radioInput02 {
  354. // display: flex;
  355. // align-items: center;
  356. // .radiaTitle {
  357. // display: inline-block;
  358. // width: 130px;
  359. // font-size: 14px;
  360. // text-align: right;
  361. // margin-top: 2px;
  362. // }
  363. // .el-input--medium .el-input__inner {
  364. // border-radius: 50px;
  365. // }
  366. //}
  367. </style>