人民医院前端

dataTreating.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 filterDepartTreeDatas(tree,tid) {
  18. const accessedRouters = []
  19. let j = -1
  20. tid++
  21. console.log()
  22. for (const i in tree) {
  23. j++
  24. accessedRouters.push({
  25. value: tid+ '_' +tree[i].id,
  26. text: tree[i].text,
  27. id: tree[i].id
  28. })
  29. if (tree[i].children) {
  30. accessedRouters[j].children = filterDepartTreeDatas(tree[i].children, tid)
  31. }
  32. }
  33. return accessedRouters
  34. }
  35. export function filterTreatData(data){
  36. const treatData = []
  37. for (const i in data) {
  38. treatData.push({
  39. cityCode:data[i].F_UserId,
  40. cityName:data[i].F_UserName
  41. })
  42. }
  43. return treatData
  44. }
  45. export function filterSelectData(data,keyValue1,keyValue2){
  46. const treatData = []
  47. console.log(keyValue1);
  48. console.log(keyValue2);
  49. for (let data of data) {
  50. treatData.push({
  51. text:data[keyValue1],
  52. value:data[keyValue2]
  53. })
  54. }
  55. return treatData
  56. }
  57. export function filterSelectDataSX(data,keyValue1,keyValue2){
  58. const treatData = []
  59. console.log(keyValue1);
  60. console.log(keyValue2);
  61. for (let data of data) {
  62. treatData.push({
  63. text:data[keyValue1],
  64. value:data[keyValue2]
  65. })
  66. }
  67. return treatData
  68. }