123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- <template>
- <div id="request">
- <el-row>
- <!-- v-if="user !== 'master'" -->
- <pages-one
- v-if="!loading"
- :topInfo="site"
- :notice="notice"
- :news="news"
- :enterList="self1List"
- :danweiList="self2List"
- :talksList="talksList"
- :talksoutList="talksOutList"
- :fairsList="jobfairList"
- :infoList="jobinfoList"
- :linkImgList="linkList"
- :lunboList="coopList"
- :floating="floating"
- >
- <template #native>
- <top-menu></top-menu>
- </template>
- <template #calendar>
- <self-calendar></self-calendar>
- </template>
- </pages-one>
- </el-row>
- <!-- <el-row v-else>
- <master
- v-if="!loading"
- :topinfo="site"
- :menulist="menu"
- :bannerinfo="master.bannerinfo"
- :newsList="news.infoList"
- :noticeinfo="master.noticeinfo"
- :noticelist="notice.infoList"
- :huodonginfo="master.jobsinfo"
- :fairsList="jobfairList"
- :talksList="talksOutList"
- :infoList="jobinfoList"
- :recruitList="self1List"
- :otherList="self2List"
- :fasttop="master.fasttop"
- :fastlist="master.fastlist"
- :contactinfo="master.contactinfo"
- :content="site.content"
- :companytop="master.companytop"
- :companylist="corpList"
- :unittop="master.unittop"
- :unitlist="coopList"
- :footinfo="site"
- :floating="floating"
- :rilitop="master.rilitop"
- :rightInfo="master.rightInfo"
- >
- <template #rili>
- <self-calendars></self-calendars>
- </template>
- </master>
- </el-row> -->
- </div>
- </template>
- <script>
- import _ from 'lodash';
- import { jobMenu } from '@/config/jobs-menu';
- import master from '@publics/src/views/master/index/index.vue';
- import topMenu from '@/layout/layout-part/top-menu.vue';
- import selfCalendar from '@/components/self-calendar.vue';
- import selfCalendars from '@/components/self-calendars.vue';
- import pagesOne from '@publics/src/views/index.vue';
- //master部分
- import { masterInfo } from '@/config/master-info';
- import { mapActions, mapState } from 'vuex';
- export default {
- name: 'request',
- props: {},
- components: {
- pagesOne,
- topMenu,
- selfCalendar,
- // selfCalendars,
- // master,
- },
- data: () => ({
- user: 'master',
- //menu部分
- activeIndex: '1',
- menu: [],
- jobs: jobMenu,
- loading: true,
- limit: 4,
- newList: [],
- talksList: [],
- jobfairList: [],
- talksOutList: [],
- jobinfoList: [],
- site: {},
- floating: {},
- news: [],
- notice: [],
- self1List: [],
- self2List: [],
- coopList: [],
- linkList: [],
- //master数据
- master: { ...masterInfo },
- corpList: [],
- siteTitle: '',
- }),
- metaInfo: {
- title: this.siteTitle,
- },
- async created() {
- await this.checkUser();
- await this.getSite();
- this.search();
- this.getModule();
- this.getLink();
- if (this.user === 'master') this.masterData();
- await this.getMenu();
- this.$set(this, `loading`, false);
- },
- computed: {},
- methods: {
- ...mapActions([
- 'jobfairOperation',
- 'postTalksInfo',
- 'jobinfoOperation',
- 'newsOperation',
- 'siteOperation',
- 'moduleOperation',
- 'columnOperation',
- 'linkOperation',
- 'menuOperation',
- 'corpListOperation',
- ]),
- //检查用户身份
- checkUser() {
- let schId = sessionStorage.getItem('schId');
- if (schId !== 'master') {
- this.$set(this, `user`, schId);
- }
- },
- //获取站点信息
- async getSite() {
- let site = sessionStorage.getItem('site');
- if (!site) {
- let result = await this.siteOperation({ type: 'search', data: { site: this.$site } });
- if (`${result.errcode}` === `0`) {
- sessionStorage.setItem('site', JSON.stringify(result.data));
- if (result.data.custom) {
- let item = result.data.custom;
- this.getfloating(item);
- }
- this.$set(this, `site`, result.data);
- this.$set(this, `siteTitle`, this.site.name);
- }
- } else {
- // console.log(JSON.parse(site));
- this.$set(this, `site`, JSON.parse(site));
- this.$set(this, `siteTitle`, this.site.name);
- let arr = this.site;
- if (arr.custom) {
- let item = arr.custom;
- this.getfloating(item);
- }
- }
- },
- getfloating(item) {
- let arr = JSON.parse(item);
- arr.forEach(val => {
- if (val.item == '浮窗') {
- this.$set(this, `floating`, val);
- }
- });
- },
- //查询招聘类信息
- async search() {
- // 1直接拿着参数发送请求
- let result = await this.postTalksInfo({ type: 'list', data: { schid: this.user === 'master' ? null : this.$site } });
- if (`${result.errcode}` === '0') {
- //给this=>vue的实例下在中的list属性,赋予result。data的值
- this.$set(this, `talksList`, result.data);
- } else {
- this.$message.error(result.errmsg ? result.errmsg : 'error');
- }
- result = await this.jobfairOperation({ type: 'list', data: { schid: this.user === 'master' ? null : this.$site } });
- if (`${result.errcode}` === '0') {
- //给this=>vue的实例下在中的list属性,赋予result。data的值
- this.$set(this, `jobfairList`, result.data);
- } else {
- this.$message.error(result.errmsg ? result.errmsg : 'error');
- }
- result = await this.postTalksInfo({ type: 'list', data: {} });
- if (`${result.errcode}` === '0') {
- //给this=>vue的实例下在中的list属性,赋予result。data的值
- this.$set(this, `talksOutList`, result.data);
- } else {
- this.$message.error(result.errmsg ? result.errmsg : 'error');
- }
- result = await this.jobinfoOperation({ type: 'list', data: { limit: this.limit } });
- if (`${result.errcode}` === '0') {
- //给this=>vue的实例下在中的list属性,赋予result。data的值
- this.$set(this, 'jobinfoList', result.data);
- } else {
- this.$message.error(result.errmsg ? result.errmsg : 'error');
- }
- },
- //获取固定的4个模块
- async getModule() {
- //获取分站所有模块 TODO:site=>_tenant
- let result = await this.moduleOperation({ type: 'list' });
- if (`${result.errcode}` === '0') {
- let moduleList = result.data;
- for (let item of moduleList) {
- //item为模块信息,拿着模块信息去查该模块下有什么栏目
- if (`${item.is_use}` === '0') {
- item = await this.getColumn(item);
- await this.makeList(item);
- } // console.log(item);
- }
- }
- },
- //根据条件获取栏目
- async getColumn(item) {
- let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id } });
- //查詢模块下所有的栏目(因为修改关联方是:抓取栏目和正常栏目关联,栏目类型(type)为bugList.所以bugList需要用content_id再去查下面关联的信息
- if (`${res.errcode}` === '0') {
- for (const col of res.data) {
- if (col.type === 'bugList') {
- col.path = `/info/list/${col.content_id}`;
- col.children = await this.getNewsList(col, '0');
- } else if (col.type === 'column') {
- col.path = `/info/list/${col.id}`;
- col.children = await this.getNewsList(col, '1');
- } else if (col.type === 'content') {
- col.path = `/info/detail?id=${col.content_id}`;
- }
- }
- item.children = res.data;
- }
- return item;
- },
- //根据条件获取信息
- async getNewsList(item, news_type) {
- let data = { skip: 0, limit: 4, news_type: news_type };
- data.parent_id = news_type === '1' ? item.id : item.content_id;
- let res = await this.newsOperation({ type: 'list', data: data });
- if (`${res.errcode}` === '0') {
- for (const val of res.data) {
- let result = await this.newsOperation({ type: 'search', data: { id: val.id } });
- if (`${result.errcode}` === '0') {
- val.content = result.data.content;
- } else {
- this.$message.error(result.errmsg ? result.errmsg : 'error');
- }
- }
- return res.data;
- } else {
- this.$message.error(res.errmsg ? res.errmsg : 'error');
- }
- },
- //组合数据
- makeList(item) {
- if (!item) return;
- if (item.category === 'news') {
- let arr = [];
- let colObject = {};
- for (const col of item.children) {
- if (!colObject.id) colObject = col;
- for (const news of col.children) {
- arr.push(news);
- }
- }
- let object = { ...JSON.parse(JSON.stringify(item)), infoList: arr, column: colObject };
- this.$set(this, `news`, object);
- } else if (item.category === 'notice') {
- let arr = [];
- let colObject = {};
- for (const col of item.children) {
- if (!colObject.id) colObject = col;
- for (const news of col.children) {
- arr.push(news);
- }
- }
- let object = { ...JSON.parse(JSON.stringify(item)), infoList: arr, column: colObject };
- // console.log(object);
- this.$set(this, `notice`, object);
- } else if (item.category === 'self1') {
- this.$set(this, `self1List`, item.children);
- } else if (item.category === 'self2') {
- this.$set(this, `self2List`, item.children);
- }
- },
- //友情链接/合作单位
- async getLink() {
- //合作单位
- let coop = await this.linkOperation({ type: 'list', data: { site: this.$site, type: 'cooperation' } });
- if (`${coop.errcode}` === '0') {
- this.$set(this, `coopList`, coop.data);
- }
- //友情链接
- let link = await this.linkOperation({ type: 'list', data: { site: this.$site, type: 'link' } });
- if (`${coop.errcode}` === '0') {
- this.$set(this, `linkList`, link.data);
- }
- },
- //检查+读取菜单
- async loadMenu() {
- let menu = sessionStorage.getItem('menu');
- if (menu) {
- this.$set(this, `menu`, JSON.parse(menu));
- return;
- } else this.getMenu();
- },
- //获取菜单
- async getMenu() {
- //获取菜单
- let result = await this.menuOperation({ type: 'list', data: { site: this.$site } });
- if (`${result.errcode}` === '0') {
- //获取菜单的栏目
- let allMenu = result.data;
- for (let item of allMenu) {
- if (item.type === 'content') {
- if (this.user === 'master') item.path = `/master/detail/news/${item.content_id}`;
- else item.path = `/info/detail?id=${item.content_id}`;
- } else if (item.type !== 'url') {
- let res = await this.completeMenu(item);
- item.children = res;
- }
- }
- sessionStorage.setItem('menu', JSON.stringify(allMenu));
- this.$set(this, `menu`, allMenu);
- }
- },
- //将菜单完善至栏目级别
- async completeMenu(item) {
- let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id, site: item.site } });
- if (`${res.errcode}` === '0') {
- //组合path:res.data内容都为栏目.所以,点击这些栏目显示的列表应该是信息列表,需要用栏目的id作为查询信息的parten_id查出不同栏目的信息
- for (const col of res.data) {
- if (col.type === 'content') {
- if (this.user === 'master') {
- col.path = `/master/notice/${col.content_id}`;
- } else col.path = `/info/detail?id=${col.content_id}`;
- } else if (col.type !== 'url') {
- if (this.user === 'master') {
- col.path = `/master/detail/news/${col.id}`;
- } else col.path = `/info/list/${col.id}`;
- }
- }
- return res.data;
- }
- },
- //主站信息组合
- async masterData() {
- this.$set(this.master, `bannerinfo`, { banner: this.site.banner });
- //获取入驻企业
- let result = await this.corpListOperation();
- // console.log(result);
- if (`${result.errcode}` === '0') {
- this.$set(this, `corpList`, result.data);
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped></style>
|