init: 管理会计OS初始代码
包含前后端完整代码: - 前端:Vue3+Vite+ElementPlus - 后端:FastAPI+SQLAlchemy - 模块:驾驶舱/KPI/战略地图/预警/预算/成本/预测/改善行动 - 当前版本:v1.0.0
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: '/api/cma',
|
||||
timeout: 15000,
|
||||
})
|
||||
|
||||
api.interceptors.request.use((config) => {
|
||||
const token = localStorage.getItem('cma_token')
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`
|
||||
return config
|
||||
})
|
||||
|
||||
api.interceptors.response.use(
|
||||
(response) => response.data,
|
||||
(error) => {
|
||||
if (error.response?.status === 401) {
|
||||
localStorage.removeItem('cma_token')
|
||||
localStorage.removeItem('cma_user')
|
||||
window.location.href = '/login'
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
export const authApi = {
|
||||
login: (data: any) => api.post('/auth/login', data),
|
||||
register: (data: any) => api.post('/auth/register', data),
|
||||
}
|
||||
|
||||
export const kpiApi = {
|
||||
list: (params?: any) => api.get('/kpis', { params }),
|
||||
get: (id: number) => api.get(`/kpis/${id}`),
|
||||
create: (data: any) => api.post('/kpis', data),
|
||||
update: (id: number, data: any) => api.put(`/kpis/${id}`, data),
|
||||
delete: (id: number) => api.delete(`/kpis/${id}`),
|
||||
listCategories: () => api.get('/kpis/categories'),
|
||||
}
|
||||
|
||||
export const mapApi = {
|
||||
list: () => api.get('/maps'),
|
||||
create: (data: any) => api.post('/maps', data),
|
||||
update: (id: number, data: any) => api.put(`/maps/${id}`, data),
|
||||
createWithTemplate: (data: any) => api.post('/maps/create-with-template', data),
|
||||
}
|
||||
|
||||
export const dashboardApi = {
|
||||
summary: (role: string) => api.get('/dashboard/summary', { params: { role } }),
|
||||
kpis: (params: any) => api.get('/dashboard/kpis', { params }),
|
||||
myKpis: (params?: any) => api.get('/dashboard/my-kpis', { params }),
|
||||
financeAnalysis: (params?: any) => api.get('/dashboard/finance-analysis', { params }),
|
||||
predict: (params?: any) => api.get('/dashboard/predict', { params }),
|
||||
}
|
||||
|
||||
export const dataApi = {
|
||||
importExcel: (file: File) => {
|
||||
const form = new FormData()
|
||||
form.append('file', file)
|
||||
return api.post('/data/import-excel', form)
|
||||
},
|
||||
listSources: () => api.get('/data/sources'),
|
||||
createSource: (data: any) => api.post('/data/sources', data),
|
||||
updateSource: (id: number, data: any) => api.put(`/data/sources/${id}`, data),
|
||||
deleteSource: (id: number) => api.delete(`/data/sources/${id}`),
|
||||
}
|
||||
|
||||
export const alertApi = {
|
||||
list: (params?: any) => api.get('/alerts', { params }),
|
||||
resolve: (id: number, data: any) => api.post(`/alerts/${id}/resolve`, data),
|
||||
}
|
||||
|
||||
export const userApi = {
|
||||
list: () => api.get('/users'),
|
||||
create: (data: any) => api.post('/users', data),
|
||||
update: (id: number, data: any) => api.put(`/users/${id}`, data),
|
||||
delete: (id: number) => api.delete(`/users/${id}`),
|
||||
}
|
||||
|
||||
export const notificationApi = {
|
||||
list: () => api.get('/notifications/channels'),
|
||||
create: (data: any) => api.post('/notifications/channels', data),
|
||||
update: (id: number, data: any) => api.put(`/notifications/channels/${id}`, data),
|
||||
delete: (id: number) => api.delete(`/notifications/channels/${id}`),
|
||||
test: (id: number) => api.post(`/notifications/channels/${id}/test`),
|
||||
logs: (params?: any) => api.get('/notifications/logs', { params }),
|
||||
}
|
||||
|
||||
export const actionPlanApi = {
|
||||
list: (params?: any) => api.get('/action-plans', { params }),
|
||||
create: (data: any) => api.post('/action-plans', data),
|
||||
update: (id: number, data: any) => api.put(`/action-plans/${id}`, data),
|
||||
delete: (id: number) => api.delete(`/action-plans/${id}`),
|
||||
}
|
||||
|
||||
export const budgetApi = {
|
||||
list: (params?: any) => api.get('/budget/plans', { params }),
|
||||
create: (data: any) => api.post('/budget/plans', data),
|
||||
update: (id: number, data: any) => api.put(`/budget/plans/${id}`, data),
|
||||
delete: (id: number) => api.delete(`/budget/plans/${id}`),
|
||||
autoDecompose: (data: any) => api.post('/budget/auto-decompose', data),
|
||||
deviationReport: (params?: any) => api.get('/budget/deviation-report', { params }),
|
||||
}
|
||||
|
||||
export const costApi = {
|
||||
dashboard: (params?: any) => api.get('/cost/dashboard', { params }),
|
||||
overview: (params?: any) => api.get('/cost/overview', { params }),
|
||||
variance: (params?: any) => api.get('/cost/variance', { params }),
|
||||
breakdown: (params?: any) => api.get('/cost/breakdown', { params }),
|
||||
listStandardCosts: (params?: any) => api.get('/cost/standard-costs', { params }),
|
||||
createStandardCost: (data: any) => api.post('/cost/standard-costs', data),
|
||||
updateStandardCost: (id: number, data: any) => api.put(`/cost/standard-costs/${id}`, data),
|
||||
deleteStandardCost: (id: number) => api.delete(`/cost/standard-costs/${id}`),
|
||||
listActualCosts: (params?: any) => api.get('/cost/actual-costs', { params }),
|
||||
createActualCost: (data: any) => api.post('/cost/actual-costs', data),
|
||||
listAbcActivities: () => api.get('/cost/abc/activities'),
|
||||
createAbcActivity: (data: any) => api.post('/cost/abc/activities', data),
|
||||
doAbcAllocate: (data: any) => api.post('/cost/abc/allocate', data),
|
||||
listAbcAllocations: (params?: any) => api.get('/cost/abc/allocations', { params }),
|
||||
}
|
||||
|
||||
export const predictApi = {
|
||||
cvp: (data: any) => api.post('/predict/cvp', data),
|
||||
investment: (data: any) => api.post('/predict/investment', data),
|
||||
sensitivity: (data: any) => api.post('/predict/sensitivity', data),
|
||||
scenario: (data: any) => api.post('/predict/scenario', data),
|
||||
}
|
||||
|
||||
export default api
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
import api from "./index"
|
||||
export const orgApi = {
|
||||
tree: () => api.get("/org/tree"),
|
||||
list: () => api.get("/org/nodes"),
|
||||
create: (data: any) => api.post("/org/nodes", data),
|
||||
update: (id: number, data: any) => api.put(`/org/nodes/${id}`, data),
|
||||
delete: (id: number) => api.delete(`/org/nodes/${id}`),
|
||||
toggle: (id: number) => api.put(`/org/nodes/${id}/toggle`),
|
||||
}
|
||||
Reference in New Issue
Block a user