sh_real_name_system_web/src/utils/getCommonData.js

33 lines
1.0 KiB
JavaScript
Raw Normal View History

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 []
}