Blame view

src/utils/dictionary.js 918 Bytes
1
/*
yuanbo committed
2
 * @Description:
3
 * @Autor: renchao
yangwei committed
4
 * @LastEditTime: 2023-08-16 11:30:45
5 6
 */
import store from '@/store'
yuanbo committed
7 8 9 10 11 12

/**
 * @description: getSjlx
 * @param {*} level
 * @author: renchao
 */
13 14 15 16 17 18 19
export function getSjlx (level) {
  const resultMap = {
    1: '系统数据',
    2: '存量数据',
    3: '补录数据',
  }
  return resultMap[level] || resultMap.default;
20 21
}

yuanbo committed
22 23 24 25 26 27
/**
 * @description: getDictLeabel
 * @param {*} level
 * @param {*} code
 * @author: renchao
 */
28 29
export function getDictLeabel (level, code) {
  const resultMap = store.getters.dictData[code]
yangwei committed
30 31 32 33 34 35 36 37 38
  function findNode(tree, func) {
    for (const node of tree) {
        if (func(node)) return node
        if (node.children) {
            const res = findNode(node.children, func)
            if (res) return res
        }
    }
    return {dname:""}
39
  }
yangwei committed
40 41 42 43
  let data = findNode(resultMap, (node) => {
    return node.dcode === level
  })
  return data.dname
xiaomiao committed
44
}