字典国际化
This commit is contained in:
@@ -2,6 +2,7 @@ import Vue from 'vue'
|
||||
import store from '@/store'
|
||||
import DataDict from '@/utils/dict'
|
||||
import { getDicts as getDicts } from '@/api/system/dict/data'
|
||||
import i18n from "@/lang";
|
||||
|
||||
function searchDictByKey(dict, key) {
|
||||
if (key == null && key == "") {
|
||||
@@ -31,8 +32,14 @@ function install() {
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
getDicts(dictMeta.type).then(res => {
|
||||
store.dispatch('dict/setDict', { key: dictMeta.type, value: res.data })
|
||||
resolve(res.data)
|
||||
//console.log(res.data)
|
||||
const translatedData = res.data.map(item => ({
|
||||
...item,
|
||||
dictLabel: i18n.t(item.dictLabel) || item.dictLabel
|
||||
}))
|
||||
//console.log(translatedData)
|
||||
store.dispatch('dict/setDict', { key: dictMeta.type, value: translatedData })
|
||||
resolve(translatedData)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
@@ -46,4 +53,4 @@ function install() {
|
||||
|
||||
export default {
|
||||
install,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3898,5 +3898,12 @@ export default {
|
||||
callConfirm: '呼叫确认',
|
||||
shelfCalledSuccess: '料架 {containerCode} 已从 {sourcePortName} 呼叫到 {currentPortName}',
|
||||
callCancelled: '已取消呼叫'
|
||||
},
|
||||
dict:{
|
||||
is_available:{
|
||||
n:'否',
|
||||
y:'是'
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@
|
||||
<script>
|
||||
import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data"
|
||||
import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type"
|
||||
import i18n from "@/lang";
|
||||
|
||||
export default {
|
||||
name: "Data",
|
||||
@@ -334,6 +335,10 @@ export default {
|
||||
getList() {
|
||||
this.loading = true
|
||||
listData(this.queryParams).then(response => {
|
||||
response.rows = response.rows.map(item => ({
|
||||
...item,
|
||||
dictLabel: i18n.t(item.dictLabel) || item.dictLabel
|
||||
}))
|
||||
this.dataList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
|
||||
Reference in New Issue
Block a user