【fix ESLint】src/components/dict
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api'
|
||||
import { getAction } from '@/api/manage'
|
||||
// import { getAction } from '@/api/manage'
|
||||
|
||||
/**
|
||||
* 获取字典数组
|
||||
@@ -24,8 +24,7 @@ export async function initDictOptions (dictCode) {
|
||||
return res
|
||||
}
|
||||
// 获取字典数组
|
||||
const res = await ajaxGetDictItems(dictCode)
|
||||
return res
|
||||
return (await ajaxGetDictItems(dictCode))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,14 +71,14 @@ export function filterMultiDictText (dictOptions, text) {
|
||||
if (text === 0 || text === '0') {
|
||||
if (dictOptions) {
|
||||
for (const dictItem of dictOptions) {
|
||||
if (text == dictItem.value) {
|
||||
if ((text + '') === (dictItem.value + '')) {
|
||||
return dictItem.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!text || text == 'null' || !dictOptions || dictOptions.length == 0) {
|
||||
if (!text || text === 'null' || !dictOptions || dictOptions.length === 0) {
|
||||
return ''
|
||||
}
|
||||
let re = ''
|
||||
@@ -95,7 +94,7 @@ export function filterMultiDictText (dictOptions, text) {
|
||||
}
|
||||
}
|
||||
})
|
||||
if (re == '') {
|
||||
if (re === '') {
|
||||
return text
|
||||
}
|
||||
return re.substring(0, re.length - 1)
|
||||
@@ -103,11 +102,12 @@ export function filterMultiDictText (dictOptions, text) {
|
||||
|
||||
/**
|
||||
* 翻译字段值对应的文本
|
||||
* @param children
|
||||
* @returns string
|
||||
* @param dictCode
|
||||
* @param key
|
||||
*/
|
||||
export function filterDictTextByCache (dictCode, key) {
|
||||
if (key == null || key.length == 0) {
|
||||
if (key === null || key === undefined || key.length === 0) {
|
||||
return
|
||||
}
|
||||
if (!dictCode) {
|
||||
@@ -115,7 +115,7 @@ export function filterDictTextByCache (dictCode, key) {
|
||||
}
|
||||
// 优先从缓存中读取字典配置
|
||||
if (getDictItemsFromCache(dictCode)) {
|
||||
const item = getDictItemsFromCache(dictCode).filter(t => t.value == key)
|
||||
const item = getDictItemsFromCache(dictCode).filter(t => t.value + '' === key + '')
|
||||
if (item && item.length > 0) {
|
||||
return item[0].text
|
||||
}
|
||||
@@ -126,8 +126,7 @@ export function filterDictTextByCache (dictCode, key) {
|
||||
export async function getDictItems (dictCode, params) {
|
||||
// 优先从缓存中读取字典配置
|
||||
if (getDictItemsFromCache(dictCode)) {
|
||||
const desformDictItems = getDictItemsFromCache(dictCode).map(item => ({ ...item, label: item.text }))
|
||||
return desformDictItems
|
||||
return getDictItemsFromCache(dictCode).map(item => ({ ...item, label: item.text }))
|
||||
}
|
||||
|
||||
// 缓存中没有,就请求后台
|
||||
@@ -137,7 +136,7 @@ export async function getDictItems (dictCode, params) {
|
||||
console.log('------- 从DB中获取到了字典-------dictCode : ', dictCode, res)
|
||||
return Promise.resolve(res)
|
||||
} else {
|
||||
console.error('getDictItems error: : ', res)
|
||||
console.error('getDictItems error: : ', result)
|
||||
return Promise.resolve([])
|
||||
}
|
||||
}).catch((res) => {
|
||||
|
||||
Reference in New Issue
Block a user