detail.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div id="detail">
  3. <login-Detail :topinfo="site" :menulist="menu" :bannerinfo="master.bannerinfo" :noticedetail="info" :footinfo="site"></login-Detail>
  4. </div>
  5. </template>
  6. <script>
  7. import loginDetail from '@publics/src/views/master/news/detail.vue';
  8. import { mapActions, mapState } from 'vuex';
  9. import { masterInfo } from '@/config/master-info';
  10. import _ from 'lodash';
  11. export default {
  12. name: 'detail',
  13. props: {},
  14. components: {
  15. loginDetail,
  16. },
  17. async created() {
  18. await this.getSite();
  19. await this.getMenu();
  20. this.masterData();
  21. await this.search();
  22. },
  23. data: () => ({
  24. site: {},
  25. master: { ...masterInfo },
  26. info: {},
  27. menu: [],
  28. jobList: [],
  29. }),
  30. computed: {
  31. type() {
  32. return this.$route.params.type;
  33. },
  34. id() {
  35. return this.$route.params.id;
  36. },
  37. },
  38. methods: {
  39. ...mapActions([
  40. 'siteOperation',
  41. 'columnOperation ',
  42. 'newsOperation',
  43. 'menuOperation',
  44. 'jobfairOperation',
  45. 'jobinfoOperation',
  46. 'postTalksInfo',
  47. 'postOperation',
  48. ]),
  49. //获取站点信息
  50. async getSite() {
  51. let site = sessionStorage.getItem('site');
  52. if (!site) {
  53. let result = await this.siteOperation({ type: 'search', data: { site: this.$site } });
  54. if (`${result.errcode}` === `0`) {
  55. sessionStorage.setItem('site', JSON.stringify(result.data));
  56. this.$set(this, `site`, result.data);
  57. }
  58. } else {
  59. this.$set(this, `site`, JSON.parse(site));
  60. }
  61. },
  62. //获取菜单
  63. async getMenu() {
  64. if (sessionStorage.getItem('menu')) {
  65. this.$set(this, `menu`, JSON.parse(sessionStorage.getItem('menu')));
  66. return;
  67. }
  68. //获取菜单
  69. let result = await this.menuOperation({ type: 'list', data: { site: this.site } });
  70. if (`${result.errcode}` === '0') {
  71. //获取菜单的栏目
  72. let allMenu = result.data;
  73. for (let item of allMenu) {
  74. if (item.type === 'content') {
  75. item.path = `/info/detail?id=${item.content_id}`;
  76. } else if (item.type !== 'url') {
  77. let res = await this.completeMenu(item);
  78. item.children = res;
  79. }
  80. }
  81. sessionStorage.setItem('menu', JSON.stringify(allMenu));
  82. this.$set(this, `menu`, allMenu);
  83. }
  84. },
  85. //将菜单完善至栏目级别
  86. async completeMenu(item) {
  87. let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id, site: item.site } });
  88. if (`${res.errcode}` === '0') {
  89. //组合path:res.data内容都为栏目.所以,点击这些栏目显示的列表应该是信息列表,需要用栏目的id作为查询信息的parten_id查出不同栏目的信息
  90. for (const col of res.data) {
  91. if (col.type === 'content') col.path = `/info/detail?id=${col.content_id}`;
  92. else if (col.type !== 'url') col.path = `/info/list/${col.id}`;
  93. }
  94. return res.data;
  95. }
  96. },
  97. //主站信息组合
  98. masterData() {
  99. this.$set(this.master, `bannerinfo`, { banner: this.site.banner });
  100. },
  101. async search() {
  102. if (this.type === 'jobinfo') this.getJobInfo();
  103. },
  104. //jobinfo部分
  105. async getJobInfo() {
  106. //1直接拿着参数发送请求
  107. let result = await this.jobinfoOperation({ type: 'search', data: { id: this.id } });
  108. if (`${result.errcode}` === '0') {
  109. //给this=>vue的实例下在中的list属性,赋予result.data的值
  110. this.$set(this, `info`, result.data);
  111. // this.searchCorpInfo();
  112. this.searchJobs();
  113. } else {
  114. this.$message.error(result.errmsg ? result.errmsg : 'error');
  115. }
  116. },
  117. async searchJobs() {
  118. let result;
  119. let jobIds = this.info.jobs.length > 0 ? this.info.jobs : [];
  120. let jobList = [];
  121. for (const item of jobIds) {
  122. result = await this.postOperation({ type: 'search', data: { id: item } });
  123. if (`${result.errcode}` === '0') {
  124. jobList.push(result.data);
  125. }
  126. }
  127. this.$set(this, `jobList`, jobList);
  128. },
  129. },
  130. };
  131. </script>
  132. <style lang="less" scoped></style>