引入
import { ajaxGetDictItems } from '@/api/api'
方法
//获取年度季度月度的字典值
async initDictData() {
//根据字典Code, 初始化字典数组
let dictCode = 'period'
let res = await ajaxGetDictItems(dictCode, null)
if (res.success) {
let arr = []
res.result.forEach((v) => {
if (v.title == '月') {
arr[0] = v
}
if (v.title == '季度') {
arr[1] = v
}
if (v.title == '年') {
arr[2] = v
}
})
this.dictOptions = arr //需要对排序更改下 为月季度年
// console.log('读取的字典值', res.result, this.dictOptions)
}
},