import store from '@/store' import { getCompanySelectListAPI, getMainProjectListAllAPI } from '@/api/common' // 获取公司下拉列表 export async function getCompanySelectListCommonFun() { const { companySelectList } = store.state.common // 先判断store中有没有 如果没有则直接调接口 如果有则取store中的数据 if (companySelectList.length > 0) { return companySelectList } const res = await getCompanySelectListAPI() if (res.code === 200) { store.commit('SET_COMPANY_SELECT_LIST', res.rows) return res.rows } return [] } // 获取总包工程列表 export async function getMainProjectListCommonFun() { const { mainProjectList } = store.state.common console.log(mainProjectList, 'mainProjectList') if (mainProjectList.length > 0) { return mainProjectList } const res = await getMainProjectListAllAPI() if (res.code === 200) { store.commit('SET_MAIN_PROJECT_LIST', res.rows) return res.rows } return [] }