- 新增活动管理相关功能,包括活动创建、编辑、删除和状态管理 - 新增 PublishStatus 枚举定义活动发布状态 - 优化字典组件,支持字符串和数字类型的字典值 - 重构业务数据存储逻辑,简化字典数据获取流程 - 新增活动详情页面,支持分组管理和队伍配置 - 集成富文本编辑器用于活动规则编辑 - 优化图片上传组件,支持小图上传模式 - 修复模板管理中的区域选择和分页问题 - 更新 TypeScript 类型定义,完善 API 接口 - 调整主题配置,新增活动状态相关颜色
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
import { getDictionaryItemListByDicID, getDictionaryList } from '@/service/api/dictionary'
|
|
|
|
export const useBusinessStore = defineStore('business-store', () => {
|
|
const dictList = ref<Api.Dictionary.DictionaryItem[]>([])
|
|
const dictData = ref<Record<string, Api.Dictionary.DictionaryUIItem[]>>({})
|
|
const isInitialized = ref(false)
|
|
const loadingMap = ref<Record<string, boolean>>({})
|
|
|
|
/** 初始化字典 */
|
|
async function initDict() {
|
|
if (isInitialized.value)
|
|
return
|
|
const { data: res, error } = await getDictionaryList()
|
|
if (!error && res) {
|
|
dictList.value = res.data || []
|
|
isInitialized.value = true
|
|
}
|
|
}
|
|
|
|
/** 获取字典数据 */
|
|
async function getDict(key: string) {
|
|
// 已经加载过,直接返回
|
|
if (dictData.value[key] && dictData.value[key].length > 0)
|
|
return dictData.value[key]
|
|
|
|
if (loadingMap.value[key]) {
|
|
return []
|
|
}
|
|
|
|
loadingMap.value[key] = true
|
|
try {
|
|
const { data: res, error } = await getDictionaryItemListByDicID(key)
|
|
if (!error && res) {
|
|
const list = res.data || []
|
|
// 使用新对象赋值,确保触发响应式更新
|
|
dictData.value = {
|
|
...dictData.value,
|
|
[key]: list,
|
|
}
|
|
}
|
|
}
|
|
finally {
|
|
loadingMap.value[key] = false
|
|
}
|
|
// eslint-disable-next-line no-console
|
|
console.log(`获取字典数据 ${key}`, dictData.value[key])
|
|
return dictData.value[key]
|
|
}
|
|
|
|
return {
|
|
dictList,
|
|
dictData,
|
|
loadingMap,
|
|
initDict,
|
|
getDict,
|
|
}
|
|
})
|