- 新增活动管理相关功能,包括活动创建、编辑、删除和状态管理 - 新增 PublishStatus 枚举定义活动发布状态 - 优化字典组件,支持字符串和数字类型的字典值 - 重构业务数据存储逻辑,简化字典数据获取流程 - 新增活动详情页面,支持分组管理和队伍配置 - 集成富文本编辑器用于活动规则编辑 - 优化图片上传组件,支持小图上传模式 - 修复模板管理中的区域选择和分页问题 - 更新 TypeScript 类型定义,完善 API 接口 - 调整主题配置,新增活动状态相关颜色
37 lines
959 B
TypeScript
37 lines
959 B
TypeScript
import { computed, onMounted } from 'vue'
|
|
import { useBusinessStore } from '@/store/modules/business'
|
|
|
|
/**
|
|
* 字典项 hook
|
|
* @param key 字典项 key
|
|
* @param valueType 字典项 value 类型,默认 number
|
|
*/
|
|
export function useDict(key: string, valueType: 'string' | 'number' = 'number') {
|
|
const store = useBusinessStore()
|
|
|
|
const data = computed(() => store.dictData[key] || [])
|
|
const loading = computed(() => store.loadingMap[key] || false)
|
|
const options = computed(() => {
|
|
if (data.value && data.value.length > 0) {
|
|
return data.value.map((item: any) => {
|
|
const rawValue = item.uI_Value || item.UI_Value || item.DicValue
|
|
return {
|
|
label: item.uI_Key || item.UI_Key || item.DicKey,
|
|
value: valueType === 'number' ? Number(rawValue) : String(rawValue),
|
|
}
|
|
})
|
|
}
|
|
return []
|
|
})
|
|
|
|
onMounted(() => {
|
|
store.getDict(key)
|
|
})
|
|
|
|
return {
|
|
data,
|
|
options,
|
|
loading,
|
|
}
|
|
}
|