import Vue from 'vue';
import Vuex from 'vuex';
import _ from 'lodash';
Vue.use(Vuex);
const api = {
  list: `/api/jobs/posts`,
  fetch: id => `/api/jobs/posts/${id}`,
};
export const state = () => ({});
export const mutations = {};
export const actions = {
  //在线招聘
  async getPosts({ state }, { type, data }) {
    let { skip = 0, limit } = data;
    let result;
    if (type === 'list') {
      let { schid, corpid, is_practice, is_publish, ...searchInfo } = data;
      result = await this.$axios.$get(api.list, {
        schid: schid,
        corpid: corpid,
        is_practice: is_practice,
        skip: skip,
        limit: limit,
        is_publish: is_publish,
        ...searchInfo,
      });
    }
    if (type === 'fetch') {
      let { id } = data;
      result = await this.$axios.$get(api.fetch(id));
    }
    return result;
  },
};
