Files
im-uniapp/store/modules/cache.js
砂糖 307b46b213 feat: 新增客户管理、项目进度和财务中心功能模块
新增客户管理、项目进度和财务中心相关页面及API接口
添加项目明细页面和启动图资源
重构请求基础URL和更新逻辑
引入uni-badge和uni-list组件
优化工作台首页功能入口布局
更新版本号至5.0.0并修改启动图配置
2025-11-06 16:56:35 +08:00

78 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { listProject } from '@/api/oa/project.js'
import { listUser } from '@/api/oa/user.js'
import { getDicts } from '@/api/oa/dict.js'
const state = {
projectList: [],
userList: [],
projectMap: {},
userMap: {}, // 修正:添加逗号
dicts: {}
}
const mutations = {
SET_DICT(state, data) {
state.dicts[data.type] = data.value
},
SET_USER(state, list) {
state.userList = list;
let o = {};
for (let i = 0; i < list.length; i++) {
o[list[i].userId] = list[i];
}
state.userMap = o;
},
SET_PROJECT(state, list) {
state.projectList = list;
let o = {};
for (let i = 0; i < list.length; i++) {
o[list[i].projectId] = list[i];
}
state.projectMap = o;
}
}
const actions = {
setDict({ commit, state }, dictType) {
// 查找state中是否已经有dictType如果已存在则不处理否则请求数据并添加
if (!state.dicts[dictType]) {
// 调用获取字典的接口,传入字典类型
getDicts(dictType).then(res => {
// 假设接口返回的数据结构为 { data: [...] },根据实际接口调整
commit('SET_DICT', {
type: dictType,
value: res.data
})
}).catch(error => {
console.error('获取字典数据失败:', error)
})
}
},
setUser({ commit, state }, { refresh }) {
if (!refresh && state.userList.length > 0) {
return;
}
listUser({ pageSize: 999, pageNum: 1 }).then(res => {
commit('SET_USER', res.rows)
}).catch(error => {
console.error('获取用户列表失败:', error)
})
},
setProject({ commit, state }, { refresh }) {
if (!refresh && state.projectList.length > 0) {
return;
}
// 与setUser逻辑类似调用项目列表接口并提交mutation
listProject({ pageSize: 999, pageNum: 1 }).then(res => {
commit('SET_PROJECT', res.rows)
}).catch(error => {
console.error('获取项目列表失败:', error)
})
}
}
export default {
state,
mutations,
actions
}