mirror of https://gitee.com/xiaonuobase/snowy
【新增】前端tool工具类新增iss提议树形字典翻译方法
parent
98fa499b8c
commit
7b4fdc4bff
|
@ -3,7 +3,7 @@
|
|||
<a-button type="primary" :href="props.src" target="_blank">
|
||||
<template #icon><download-outlined /></template>
|
||||
</a-button>
|
||||
<a-button type="primary" @click="emit('goBack')" >
|
||||
<a-button type="primary" @click="emit('goBack')">
|
||||
<template #icon><rollback-outlined /></template>
|
||||
返回
|
||||
</a-button>
|
||||
|
|
|
@ -126,6 +126,27 @@ tool.dictList = (dictValue) => {
|
|||
return []
|
||||
}
|
||||
|
||||
// 树形翻译 需要指定最顶级的 parentValue 和当级的value
|
||||
tool.translateTree = (parentValue, value) => {
|
||||
const tree = tool.dictDataAll().find((item) => item.dictValue === parentValue)
|
||||
const targetNode = findNodeByValue(tree, value)
|
||||
return targetNode ? targetNode.dictLabel : ''
|
||||
}
|
||||
const findNodeByValue = (node, value) => {
|
||||
if (node.dictValue === value) {
|
||||
return node
|
||||
}
|
||||
if (node.children) {
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
const result = findNodeByValue(node.children[i], value)
|
||||
if (result) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// 生成UUID
|
||||
tool.snowyUuid = () => {
|
||||
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
||||
|
|
Loading…
Reference in New Issue