【fix ESLint】src/components/dict
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-radio-group v-if="tagType=='radio'" @change="handleInput" :value="getValueSting" :disabled="disabled">
|
<a-radio-group v-if="tagType==='radio'" @change="handleInput" :value="getValueSting" :disabled="disabled">
|
||||||
<a-radio v-for="(item, key) in dictOptions" :key="key" :value="item.value">{{ item.text }}</a-radio>
|
<a-radio v-for="(item, key) in dictOptions" :key="key" :value="item.value">{{ item.text }}</a-radio>
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
|
|
||||||
<a-radio-group v-else-if="tagType=='radioButton'" buttonStyle="solid" @change="handleInput" :value="getValueSting" :disabled="disabled">
|
<a-radio-group v-else-if="tagType==='radioButton'" buttonStyle="solid" @change="handleInput" :value="getValueSting" :disabled="disabled">
|
||||||
<a-radio-button v-for="(item, key) in dictOptions" :key="key" :value="item.value">{{ item.text }}</a-radio-button>
|
<a-radio-button v-for="(item, key) in dictOptions" :key="key" :value="item.value">{{ item.text }}</a-radio-button>
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
|
|
||||||
<a-select v-else-if="tagType=='select'" :getPopupContainer = "getPopupContainer" :placeholder="placeholder" :disabled="disabled" :value="getValueSting" @change="handleInput">
|
<a-select v-else-if="tagType==='select'" :getPopupContainer = "getPopupContainer" :placeholder="placeholder" :disabled="disabled" :value="getValueSting" @change="handleInput">
|
||||||
<a-select-option :value="undefined">请选择</a-select-option>
|
<a-select-option :value="undefined">请选择</a-select-option>
|
||||||
<a-select-option v-for="(item, key) in dictOptions" :key="key" :value="item.value">
|
<a-select-option v-for="(item, key) in dictOptions" :key="key" :value="item.value">
|
||||||
<span style="display: inline-block;width: 100%" :title=" item.text || item.label ">
|
<span style="display: inline-block;width: 100%" :title=" item.text || item.label ">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api'
|
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
|
return res
|
||||||
}
|
}
|
||||||
// 获取字典数组
|
// 获取字典数组
|
||||||
const res = await ajaxGetDictItems(dictCode)
|
return (await ajaxGetDictItems(dictCode))
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,14 +71,14 @@ export function filterMultiDictText (dictOptions, text) {
|
|||||||
if (text === 0 || text === '0') {
|
if (text === 0 || text === '0') {
|
||||||
if (dictOptions) {
|
if (dictOptions) {
|
||||||
for (const dictItem of dictOptions) {
|
for (const dictItem of dictOptions) {
|
||||||
if (text == dictItem.value) {
|
if ((text + '') === (dictItem.value + '')) {
|
||||||
return dictItem.text
|
return dictItem.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!text || text == 'null' || !dictOptions || dictOptions.length == 0) {
|
if (!text || text === 'null' || !dictOptions || dictOptions.length === 0) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
let re = ''
|
let re = ''
|
||||||
@@ -95,7 +94,7 @@ export function filterMultiDictText (dictOptions, text) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (re == '') {
|
if (re === '') {
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
return re.substring(0, re.length - 1)
|
return re.substring(0, re.length - 1)
|
||||||
@@ -103,11 +102,12 @@ export function filterMultiDictText (dictOptions, text) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 翻译字段值对应的文本
|
* 翻译字段值对应的文本
|
||||||
* @param children
|
|
||||||
* @returns string
|
* @returns string
|
||||||
|
* @param dictCode
|
||||||
|
* @param key
|
||||||
*/
|
*/
|
||||||
export function filterDictTextByCache (dictCode, key) {
|
export function filterDictTextByCache (dictCode, key) {
|
||||||
if (key == null || key.length == 0) {
|
if (key === null || key === undefined || key.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!dictCode) {
|
if (!dictCode) {
|
||||||
@@ -115,7 +115,7 @@ export function filterDictTextByCache (dictCode, key) {
|
|||||||
}
|
}
|
||||||
// 优先从缓存中读取字典配置
|
// 优先从缓存中读取字典配置
|
||||||
if (getDictItemsFromCache(dictCode)) {
|
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) {
|
if (item && item.length > 0) {
|
||||||
return item[0].text
|
return item[0].text
|
||||||
}
|
}
|
||||||
@@ -126,8 +126,7 @@ export function filterDictTextByCache (dictCode, key) {
|
|||||||
export async function getDictItems (dictCode, params) {
|
export async function getDictItems (dictCode, params) {
|
||||||
// 优先从缓存中读取字典配置
|
// 优先从缓存中读取字典配置
|
||||||
if (getDictItemsFromCache(dictCode)) {
|
if (getDictItemsFromCache(dictCode)) {
|
||||||
const desformDictItems = getDictItemsFromCache(dictCode).map(item => ({ ...item, label: item.text }))
|
return getDictItemsFromCache(dictCode).map(item => ({ ...item, label: item.text }))
|
||||||
return desformDictItems
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 缓存中没有,就请求后台
|
// 缓存中没有,就请求后台
|
||||||
@@ -137,7 +136,7 @@ export async function getDictItems (dictCode, params) {
|
|||||||
console.log('------- 从DB中获取到了字典-------dictCode : ', dictCode, res)
|
console.log('------- 从DB中获取到了字典-------dictCode : ', dictCode, res)
|
||||||
return Promise.resolve(res)
|
return Promise.resolve(res)
|
||||||
} else {
|
} else {
|
||||||
console.error('getDictItems error: : ', res)
|
console.error('getDictItems error: : ', result)
|
||||||
return Promise.resolve([])
|
return Promise.resolve([])
|
||||||
}
|
}
|
||||||
}).catch((res) => {
|
}).catch((res) => {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-checkbox-group v-if="tagType=='checkbox'" @change="onChange" :value="arrayValue" :disabled="disabled">
|
<a-checkbox-group v-if="tagType==='checkbox'" @change="onChange" :value="arrayValue" :disabled="disabled">
|
||||||
<a-checkbox v-for="(item, key) in dictOptions" :key="key" :value="item.value">{{ item.text || item.label }}</a-checkbox>
|
<a-checkbox v-for="(item, key) in dictOptions" :key="key" :value="item.value">{{ item.text || item.label }}</a-checkbox>
|
||||||
</a-checkbox-group>
|
</a-checkbox-group>
|
||||||
|
|
||||||
<a-select
|
<a-select
|
||||||
v-else-if="tagType=='select'"
|
v-else-if="tagType==='select'"
|
||||||
:value="arrayValue"
|
:value="arrayValue"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api'
|
import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api'
|
||||||
import debounce from 'lodash/debounce'
|
import debounce from 'lodash/debounce'
|
||||||
import { getAction } from '../../api/manage'
|
import { getAction } from '@api/manage'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'JSearchSelectTag',
|
name: 'JSearchSelectTag',
|
||||||
@@ -89,7 +89,7 @@ export default {
|
|||||||
immediate: true,
|
immediate: true,
|
||||||
handler (val) {
|
handler (val) {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
if (val == 0) {
|
if (val === 0) {
|
||||||
this.initSelectValue()
|
this.initSelectValue()
|
||||||
} else {
|
} else {
|
||||||
this.selectedValue = []
|
this.selectedValue = []
|
||||||
@@ -117,7 +117,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
initSelectValue () {
|
initSelectValue () {
|
||||||
if (this.async) {
|
if (this.async) {
|
||||||
if (!this.selectedAsyncValue || !this.selectedAsyncValue.key || this.selectedAsyncValue.key != this.value) {
|
if (!this.selectedAsyncValue || !this.selectedAsyncValue.key || (this.selectedAsyncValue.key + '') !== (this.value + '')) {
|
||||||
console.log('这才请求后台')
|
console.log('这才请求后台')
|
||||||
getAction(`/sys/dict/loadDictItem/${this.dict}`, { key: this.value }).then(res => {
|
getAction(`/sys/dict/loadDictItem/${this.dict}`, { key: this.value }).then(res => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
@@ -143,7 +143,7 @@ export default {
|
|||||||
getAction(`/sys/dict/loadDict/${this.dict}`, { keyword: value, pageSize: this.pageSize }).then(res => {
|
getAction(`/sys/dict/loadDict/${this.dict}`, { keyword: value, pageSize: this.pageSize }).then(res => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
if (currentLoad != this.lastLoad) {
|
if (currentLoad !== this.lastLoad) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.options = res.result
|
this.options = res.result
|
||||||
@@ -169,7 +169,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
dictStr = this.dict
|
dictStr = this.dict
|
||||||
}
|
}
|
||||||
if (this.dict.indexOf(',') == -1) {
|
if (this.dict.indexOf(',') === -1) {
|
||||||
// 优先从缓存中读取字典配置
|
// 优先从缓存中读取字典配置
|
||||||
if (getDictItemsFromCache(this.dictCode)) {
|
if (getDictItemsFromCache(this.dictCode)) {
|
||||||
this.options = getDictItemsFromCache(this.dictCode)
|
this.options = getDictItemsFromCache(this.dictCode)
|
||||||
|
|||||||
Reference in New Issue
Block a user