index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <div id="request">
  3. <el-row>
  4. <!-- v-if="user !== 'master'" -->
  5. <pages-one
  6. v-if="!loading"
  7. :topInfo="site"
  8. :notice="notice"
  9. :news="news"
  10. :enterList="self1List"
  11. :danweiList="self2List"
  12. :talksList="talksList"
  13. :talksoutList="talksOutList"
  14. :fairsList="jobfairList"
  15. :infoList="jobinfoList"
  16. :linkImgList="linkList"
  17. :lunboList="coopList"
  18. :floating="floating"
  19. >
  20. <template #native>
  21. <top-menu></top-menu>
  22. </template>
  23. <template #calendar>
  24. <self-calendar></self-calendar>
  25. </template>
  26. </pages-one>
  27. </el-row>
  28. <!-- <el-row v-else>
  29. <master
  30. v-if="!loading"
  31. :topinfo="site"
  32. :menulist="menu"
  33. :bannerinfo="master.bannerinfo"
  34. :newsList="news.infoList"
  35. :noticeinfo="master.noticeinfo"
  36. :noticelist="notice.infoList"
  37. :huodonginfo="master.jobsinfo"
  38. :fairsList="jobfairList"
  39. :talksList="talksOutList"
  40. :infoList="jobinfoList"
  41. :recruitList="self1List"
  42. :otherList="self2List"
  43. :fasttop="master.fasttop"
  44. :fastlist="master.fastlist"
  45. :contactinfo="master.contactinfo"
  46. :content="site.content"
  47. :companytop="master.companytop"
  48. :companylist="corpList"
  49. :unittop="master.unittop"
  50. :unitlist="coopList"
  51. :footinfo="site"
  52. :floating="floating"
  53. :rilitop="master.rilitop"
  54. :rightInfo="master.rightInfo"
  55. >
  56. <template #rili>
  57. <self-calendars></self-calendars>
  58. </template>
  59. </master>
  60. </el-row> -->
  61. </div>
  62. </template>
  63. <script>
  64. import _ from 'lodash';
  65. import { jobMenu } from '@/config/jobs-menu';
  66. import master from '@publics/src/views/master/index/index.vue';
  67. import topMenu from '@/layout/layout-part/top-menu.vue';
  68. import selfCalendar from '@/components/self-calendar.vue';
  69. import selfCalendars from '@/components/self-calendars.vue';
  70. import pagesOne from '@publics/src/views/index.vue';
  71. //master部分
  72. import { masterInfo } from '@/config/master-info';
  73. import { mapActions, mapState } from 'vuex';
  74. export default {
  75. name: 'request',
  76. props: {},
  77. components: {
  78. pagesOne,
  79. topMenu,
  80. selfCalendar,
  81. // selfCalendars,
  82. // master,
  83. },
  84. data: () => ({
  85. user: 'master',
  86. //menu部分
  87. activeIndex: '1',
  88. menu: [],
  89. jobs: jobMenu,
  90. loading: true,
  91. limit: 4,
  92. newList: [],
  93. talksList: [],
  94. jobfairList: [],
  95. talksOutList: [],
  96. jobinfoList: [],
  97. site: {},
  98. floating: {},
  99. news: [],
  100. notice: [],
  101. self1List: [],
  102. self2List: [],
  103. coopList: [],
  104. linkList: [],
  105. //master数据
  106. master: { ...masterInfo },
  107. corpList: [],
  108. siteTitle: '',
  109. }),
  110. metaInfo: {
  111. title: this.siteTitle,
  112. },
  113. async created() {
  114. await this.checkUser();
  115. await this.getSite();
  116. this.search();
  117. this.getModule();
  118. this.getLink();
  119. if (this.user === 'master') this.masterData();
  120. await this.getMenu();
  121. this.$set(this, `loading`, false);
  122. },
  123. computed: {},
  124. methods: {
  125. ...mapActions([
  126. 'jobfairOperation',
  127. 'postTalksInfo',
  128. 'jobinfoOperation',
  129. 'newsOperation',
  130. 'siteOperation',
  131. 'moduleOperation',
  132. 'columnOperation',
  133. 'linkOperation',
  134. 'menuOperation',
  135. 'corpListOperation',
  136. ]),
  137. //检查用户身份
  138. checkUser() {
  139. let schId = sessionStorage.getItem('schId');
  140. if (schId !== 'master') {
  141. this.$set(this, `user`, schId);
  142. }
  143. },
  144. //获取站点信息
  145. async getSite() {
  146. let site = sessionStorage.getItem('site');
  147. if (!site) {
  148. let result = await this.siteOperation({ type: 'search', data: { site: this.$site } });
  149. if (`${result.errcode}` === `0`) {
  150. sessionStorage.setItem('site', JSON.stringify(result.data));
  151. if (result.data.custom) {
  152. let item = result.data.custom;
  153. this.getfloating(item);
  154. }
  155. this.$set(this, `site`, result.data);
  156. this.$set(this, `siteTitle`, this.site.name);
  157. }
  158. } else {
  159. // console.log(JSON.parse(site));
  160. this.$set(this, `site`, JSON.parse(site));
  161. this.$set(this, `siteTitle`, this.site.name);
  162. let arr = this.site;
  163. if (arr.custom) {
  164. let item = arr.custom;
  165. this.getfloating(item);
  166. }
  167. }
  168. },
  169. getfloating(item) {
  170. let arr = JSON.parse(item);
  171. arr.forEach(val => {
  172. if (val.item == '浮窗') {
  173. this.$set(this, `floating`, val);
  174. }
  175. });
  176. },
  177. //查询招聘类信息
  178. async search() {
  179. // 1直接拿着参数发送请求
  180. let result = await this.postTalksInfo({ type: 'list', data: { schid: this.user === 'master' ? null : this.$site } });
  181. if (`${result.errcode}` === '0') {
  182. //给this=>vue的实例下在中的list属性,赋予result。data的值
  183. this.$set(this, `talksList`, result.data);
  184. } else {
  185. this.$message.error(result.errmsg ? result.errmsg : 'error');
  186. }
  187. result = await this.jobfairOperation({ type: 'list', data: { schid: this.user === 'master' ? null : this.$site } });
  188. if (`${result.errcode}` === '0') {
  189. //给this=>vue的实例下在中的list属性,赋予result。data的值
  190. this.$set(this, `jobfairList`, result.data);
  191. } else {
  192. this.$message.error(result.errmsg ? result.errmsg : 'error');
  193. }
  194. result = await this.postTalksInfo({ type: 'list', data: {} });
  195. if (`${result.errcode}` === '0') {
  196. //给this=>vue的实例下在中的list属性,赋予result。data的值
  197. this.$set(this, `talksOutList`, result.data);
  198. } else {
  199. this.$message.error(result.errmsg ? result.errmsg : 'error');
  200. }
  201. result = await this.jobinfoOperation({ type: 'list', data: { limit: this.limit } });
  202. if (`${result.errcode}` === '0') {
  203. //给this=>vue的实例下在中的list属性,赋予result。data的值
  204. this.$set(this, 'jobinfoList', result.data);
  205. } else {
  206. this.$message.error(result.errmsg ? result.errmsg : 'error');
  207. }
  208. },
  209. //获取固定的4个模块
  210. async getModule() {
  211. //获取分站所有模块 TODO:site=>_tenant
  212. let result = await this.moduleOperation({ type: 'list' });
  213. if (`${result.errcode}` === '0') {
  214. let moduleList = result.data;
  215. for (let item of moduleList) {
  216. //item为模块信息,拿着模块信息去查该模块下有什么栏目
  217. if (`${item.is_use}` === '0') {
  218. item = await this.getColumn(item);
  219. await this.makeList(item);
  220. } // console.log(item);
  221. }
  222. }
  223. },
  224. //根据条件获取栏目
  225. async getColumn(item) {
  226. let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id } });
  227. //查詢模块下所有的栏目(因为修改关联方是:抓取栏目和正常栏目关联,栏目类型(type)为bugList.所以bugList需要用content_id再去查下面关联的信息
  228. if (`${res.errcode}` === '0') {
  229. for (const col of res.data) {
  230. if (col.type === 'bugList') {
  231. col.path = `/info/list/${col.content_id}`;
  232. col.children = await this.getNewsList(col, '0');
  233. } else if (col.type === 'column') {
  234. col.path = `/info/list/${col.id}`;
  235. col.children = await this.getNewsList(col, '1');
  236. } else if (col.type === 'content') {
  237. col.path = `/info/detail?id=${col.content_id}`;
  238. }
  239. }
  240. item.children = res.data;
  241. }
  242. return item;
  243. },
  244. //根据条件获取信息
  245. async getNewsList(item, news_type) {
  246. let data = { skip: 0, limit: 4, news_type: news_type };
  247. data.parent_id = news_type === '1' ? item.id : item.content_id;
  248. let res = await this.newsOperation({ type: 'list', data: data });
  249. if (`${res.errcode}` === '0') {
  250. for (const val of res.data) {
  251. let result = await this.newsOperation({ type: 'search', data: { id: val.id } });
  252. if (`${result.errcode}` === '0') {
  253. val.content = result.data.content;
  254. } else {
  255. this.$message.error(result.errmsg ? result.errmsg : 'error');
  256. }
  257. }
  258. return res.data;
  259. } else {
  260. this.$message.error(res.errmsg ? res.errmsg : 'error');
  261. }
  262. },
  263. //组合数据
  264. makeList(item) {
  265. if (!item) return;
  266. if (item.category === 'news') {
  267. let arr = [];
  268. let colObject = {};
  269. for (const col of item.children) {
  270. if (!colObject.id) colObject = col;
  271. for (const news of col.children) {
  272. arr.push(news);
  273. }
  274. }
  275. let object = { ...JSON.parse(JSON.stringify(item)), infoList: arr, column: colObject };
  276. this.$set(this, `news`, object);
  277. } else if (item.category === 'notice') {
  278. let arr = [];
  279. let colObject = {};
  280. for (const col of item.children) {
  281. if (!colObject.id) colObject = col;
  282. for (const news of col.children) {
  283. arr.push(news);
  284. }
  285. }
  286. let object = { ...JSON.parse(JSON.stringify(item)), infoList: arr, column: colObject };
  287. // console.log(object);
  288. this.$set(this, `notice`, object);
  289. } else if (item.category === 'self1') {
  290. this.$set(this, `self1List`, item.children);
  291. } else if (item.category === 'self2') {
  292. this.$set(this, `self2List`, item.children);
  293. }
  294. },
  295. //友情链接/合作单位
  296. async getLink() {
  297. //合作单位
  298. let coop = await this.linkOperation({ type: 'list', data: { site: this.$site, type: 'cooperation' } });
  299. if (`${coop.errcode}` === '0') {
  300. this.$set(this, `coopList`, coop.data);
  301. }
  302. //友情链接
  303. let link = await this.linkOperation({ type: 'list', data: { site: this.$site, type: 'link' } });
  304. if (`${coop.errcode}` === '0') {
  305. this.$set(this, `linkList`, link.data);
  306. }
  307. },
  308. //检查+读取菜单
  309. async loadMenu() {
  310. let menu = sessionStorage.getItem('menu');
  311. if (menu) {
  312. this.$set(this, `menu`, JSON.parse(menu));
  313. return;
  314. } else this.getMenu();
  315. },
  316. //获取菜单
  317. async getMenu() {
  318. //获取菜单
  319. let result = await this.menuOperation({ type: 'list', data: { site: this.$site } });
  320. if (`${result.errcode}` === '0') {
  321. //获取菜单的栏目
  322. let allMenu = result.data;
  323. for (let item of allMenu) {
  324. if (item.type === 'content') {
  325. if (this.user === 'master') item.path = `/master/detail/news/${item.content_id}`;
  326. else item.path = `/info/detail?id=${item.content_id}`;
  327. } else if (item.type !== 'url') {
  328. let res = await this.completeMenu(item);
  329. item.children = res;
  330. }
  331. }
  332. sessionStorage.setItem('menu', JSON.stringify(allMenu));
  333. this.$set(this, `menu`, allMenu);
  334. }
  335. },
  336. //将菜单完善至栏目级别
  337. async completeMenu(item) {
  338. let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id, site: item.site } });
  339. if (`${res.errcode}` === '0') {
  340. //组合path:res.data内容都为栏目.所以,点击这些栏目显示的列表应该是信息列表,需要用栏目的id作为查询信息的parten_id查出不同栏目的信息
  341. for (const col of res.data) {
  342. if (col.type === 'content') {
  343. if (this.user === 'master') {
  344. col.path = `/master/notice/${col.content_id}`;
  345. } else col.path = `/info/detail?id=${col.content_id}`;
  346. } else if (col.type !== 'url') {
  347. if (this.user === 'master') {
  348. col.path = `/master/detail/news/${col.id}`;
  349. } else col.path = `/info/list/${col.id}`;
  350. }
  351. }
  352. return res.data;
  353. }
  354. },
  355. //主站信息组合
  356. async masterData() {
  357. this.$set(this.master, `bannerinfo`, { banner: this.site.banner });
  358. //获取入驻企业
  359. let result = await this.corpListOperation();
  360. // console.log(result);
  361. if (`${result.errcode}` === '0') {
  362. this.$set(this, `corpList`, result.data);
  363. }
  364. },
  365. },
  366. };
  367. </script>
  368. <style lang="scss" scoped></style>