107 lines
3.1 KiB
JavaScript
107 lines
3.1 KiB
JavaScript
import store from '@/store'
|
|
import {
|
|
getCompanySelectListAPI,
|
|
getMainProjectListAllAPI,
|
|
getSubCompanySelectListAPI,
|
|
getLotProjectSelectListAPI,
|
|
getSubSelectListAPI,
|
|
getTeamSelectListAPI,
|
|
getPostTypeSelectListAPI,
|
|
} 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
|
|
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 []
|
|
}
|
|
|
|
// 获取分公司下拉列表
|
|
export async function getSubCompanySelectListCommonFun() {
|
|
const { subCompanySelectList } = store.state.common
|
|
if (subCompanySelectList.length > 0) {
|
|
return subCompanySelectList
|
|
}
|
|
const res = await getSubCompanySelectListAPI()
|
|
if (res.code === 200) {
|
|
store.commit('SET_SUB_COMPANY_SELECT_LIST', res.rows)
|
|
return res.rows
|
|
}
|
|
return []
|
|
}
|
|
|
|
// 获取标段工程下拉列表
|
|
export async function getLotProjectSelectListCommonFun(data) {
|
|
const { lotProjectSelectList } = store.state.common
|
|
if (lotProjectSelectList.length > 0) {
|
|
return lotProjectSelectList
|
|
}
|
|
const res = await getLotProjectSelectListAPI(data)
|
|
if (res.code === 200) {
|
|
store.commit('SET_LOT_PROJECT_SELECT_LIST', res.rows)
|
|
return res.rows
|
|
}
|
|
return []
|
|
}
|
|
// 获取分包下拉列表
|
|
export async function getSubSelectListCommonFun() {
|
|
const { subSelectList } = store.state.common
|
|
if (subSelectList.length > 0) {
|
|
return subSelectList
|
|
}
|
|
const res = await getSubSelectListAPI()
|
|
if (res.code === 200) {
|
|
store.commit('SET_SUB_SELECT_LIST', res.rows)
|
|
return res.rows
|
|
}
|
|
return []
|
|
}
|
|
// 获取班组下拉列表
|
|
export async function getTeamSelectListCommonFun(data) {
|
|
const { teamSelectList } = store.state.common
|
|
if (teamSelectList.length > 0) {
|
|
return teamSelectList
|
|
}
|
|
const res = await getTeamSelectListAPI(data)
|
|
if (res.code === 200) {
|
|
store.commit('SET_TEAM_SELECT_LIST', res.rows)
|
|
return res.rows
|
|
}
|
|
return []
|
|
}
|
|
// 获取工种下拉列表
|
|
export async function getPostTypeSelectListCommonFun() {
|
|
const { postTypeSelectList } = store.state.common
|
|
if (postTypeSelectList.length > 0) {
|
|
return postTypeSelectList
|
|
}
|
|
const res = await getPostTypeSelectListAPI()
|
|
if (res.code === 200) {
|
|
store.commit('SET_POST_TYPE_SELECT_LIST', res.rows)
|
|
return res.rows
|
|
}
|
|
return []
|
|
}
|