kboss/f/web-kboss/src/store/modules/operationAnalysis.js
2025-07-16 14:27:17 +08:00

146 lines
3.8 KiB
JavaScript

import {reqGetIncome, reqGetOperation, reqGetOperationProfit, reqGetTime} from '@/api/operation/analyze'
const state = {
timeObj: {},
//header主题设置是否存在的状态
themeStates: false,
//图表配置数据
gridObj: {},
//运营KPI分析
operationCustom: {},
//收入统计分析
operationIncome: {},
//点击某个柱状图隐藏其他的柱状图状态
yunyingConutShow: true,
yunyingSaleShow: true,
yunyingProfitShow: true,
yunyingDistributorShow: true,
yunyingSuppilerShow: true,
//扇形图展示的状态
pieShow: false,
//扇形展示的数据
pieData: [],
//利润分析相关数据
operationProfitData: {},
//算力中心导航
navList: []
}
const mutations = {
setNavList(state, navList) {
console.log("mutation执行了")
state.navList = navList
},
//计算右侧饼图展示的数据
setPieData(state, pieData) {
state.pieData = pieData
},
//展示扇形图的状态
changePieShow() {
state.pieShow = Object.assign({}, state.pieShow, true);
},
//消除扇形图的状态
detroyPieShow() {
state.pieShow = false
state.yunyingConutShow = true,
state.yunyingSaleShow = true,
state.yunyingProfitShow = true,
state.yunyingDistributorShow = true,
state.yunyingSuppilerShow = true
},
//改变header头部设置状态
changeThemeStates(state, data) {
state.themeStates = data
},
//配置图表数据
setGridObj(state, gridObj) {
state.gridObj = gridObj
},
//运营配置状态
setYunyinState(payload) {
state.yunyingSaleShow = false
state.yunyingProfitShow = false
state.yunyingDistributorShow = false
state.yunyingSuppilerShow = false
},
//只显示销售
setYunyinSaleShow(payload) {
state.yunyingConutShow = false
state.yunyingSaleShow = true
state.yunyingProfitShow = false
state.yunyingDistributorShow = false
state.yunyingSuppilerShow = false
},
//只显示利润
setYunyingProfit() {
state.yunyingConutShow = false
state.yunyingSaleShow = false
state.yunyingProfitShow = true
state.yunyingDistributorShow = false
state.yunyingSuppilerShow = false
},
//只显示分销商
setYunYingDistributor() {
state.yunyingConutShow = false
state.yunyingSaleShow = false
state.yunyingProfitShow = false
state.yunyingDistributorShow = true
state.yunyingSuppilerShow = false
},
//只显示供销商
setYunYingSuppiler() {
state.yunyingConutShow = false
state.yunyingSaleShow = false
state.yunyingProfitShow = false
state.yunyingDistributorShow = false
state.yunyingSuppilerShow = true
},
//运营KPI分析
GETOPERATION(state, operationCustom) {
state.operationCustom = operationCustom
},
//收入统计分析
GETOPERATIONINCOME(state, operationIncome) {
state.operationIncome = operationIncome
},
//利润统计分析
GETOPERATIONPROFIT(state, operationProfitData) {
state.operationProfitData = operationProfitData
}
}
const actions = {
//获取运营KPI相关的数据
async getOperation({commit}, payload) {
const {userid, type} = payload
let result = await reqGetOperation({type})
// console.log("请求接口拿回来的数据是:", result)
if (result.status == true) {
commit('GETOPERATION', result.data)
}
},
//获取收入统计分析相关数据
async getOperationIncome({commit}, time) {
let result = await reqGetIncome(time)
if (result.status == true) {
commit('GETOPERATIONINCOME', result.data)
}
},
//获取利润统计分析相关数据
async getOperationProfit({commit}, time) {
let result = await reqGetOperationProfit(time)
if (result.status == true) {
commit('GETOPERATIONPROFIT', result.data)
}
}
}
export default {
namespaced: true,
state,
mutations,
actions
};