人民医院前端

dataTreating.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. export function filterTreeDatas(tree) {
  2. const accessedRouters = []
  3. let j = -1
  4. for (const i in tree) {
  5. j++
  6. accessedRouters.push({
  7. value: tree[i].id, //tree[i].id
  8. text: tree[i].text,
  9. id: tree[i].id ,//treeValue
  10. })
  11. if (tree[i].children) {
  12. accessedRouters[j].children = filterTreeDatas(tree[i].children)
  13. }
  14. }
  15. return accessedRouters
  16. }
  17. export function filterGongDanTreeDatas(tree,zIndex,position) {
  18. const accessedRouters = []
  19. let j = -1
  20. zIndex++
  21. for (const i in tree) {
  22. j++
  23. accessedRouters.push({
  24. value: tree[i].id, //tree[i].id
  25. text: tree[i].text,
  26. id: tree[i].id ,//treeValue
  27. zIndex:zIndex,
  28. sort:j,
  29. position:position+i+'-'
  30. })
  31. if (tree[i].children) {
  32. accessedRouters[j].children = filterGongDanTreeDatas(tree[i].children,zIndex,accessedRouters[j].position)
  33. }
  34. }
  35. return accessedRouters
  36. }
  37. export function filterTreeDatasNew(tree) {
  38. const accessedRouters = []
  39. let j = -1
  40. for (const i in tree) {
  41. j++
  42. accessedRouters.push({
  43. value: tree[i].id, //tree[i].id
  44. text: tree[i].text,
  45. })
  46. if (tree[i].children) {
  47. accessedRouters[j].children = filterTreeDatasNew(tree[i].children)
  48. }
  49. }
  50. return accessedRouters
  51. }
  52. export function filterDepartTreeDatas(tree,tid,zIndex,position) {
  53. const accessedRouters = []
  54. let j = -1
  55. tid++
  56. zIndex++
  57. for (const i in tree) {
  58. j++
  59. accessedRouters.push({
  60. value: tid+ '_' +tree[i].id,
  61. text: tree[i].text,
  62. id: tree[i].id,
  63. zIndex:zIndex,
  64. sort:j,
  65. position:position+i+'-'
  66. })
  67. if (tree[i].children) {
  68. accessedRouters[j].children = filterDepartTreeDatas(tree[i].children, tid,zIndex,accessedRouters[j].position)
  69. }
  70. }
  71. return accessedRouters
  72. }
  73. export function filterMuterDatas(tree){
  74. const accessedRouters = []
  75. let j = -1
  76. for (const i in tree) {
  77. j++
  78. accessedRouters.push({
  79. value: tree[i].id, //tree[i].id
  80. text: tree[i].text,
  81. id: tree[i].id //treeValue
  82. })
  83. if (tree[i].children) {
  84. accessedRouters[j].children = filterMuterDatas(tree[i].children)
  85. }
  86. }
  87. return accessedRouters
  88. }
  89. export function filterTreatData(data){
  90. const treatData = []
  91. for (const i in data) {
  92. treatData.push({
  93. cityCode:data[i].F_UserId,
  94. cityName:data[i].F_UserName
  95. })
  96. }
  97. return treatData
  98. }
  99. export function filterSelectData(data,keyValue1,keyValue2){
  100. const treatData = []
  101. for (let data of data) {
  102. treatData.push({
  103. text:data[keyValue1],
  104. value:data[keyValue2]
  105. })
  106. }
  107. return treatData
  108. }
  109. export function filterSelectDataSX(data,keyValue1,keyValue2){
  110. const treatData = []
  111. for (let data of data) {
  112. treatData.push({
  113. text:data[keyValue1],
  114. value:data[keyValue2]
  115. })
  116. }
  117. return treatData
  118. }