人民医院前端

dataTreating.js 3.1KB

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