【新增】前端tool工具类新增iss提议树形字典翻译方法

pull/138/head
小诺 2023-07-22 13:05:54 +08:00 committed by 俞宝山
parent 98fa499b8c
commit 7b4fdc4bff
2 changed files with 22 additions and 1 deletions

View File

@ -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>

View File

@ -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) => {