model-outline.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. export const getModels = (list, group = '') => {
  2. let currentNode = []
  3. for (let i = 0; i < list.length; i++) {
  4. if (list[i].type === 'grid') {
  5. list[i].columns.forEach(item => {
  6. currentNode = currentNode.concat(getModels(item.list, group))
  7. })
  8. } else if (list[i].type === 'tabs') {
  9. list[i].tabs.forEach(item => {
  10. currentNode = currentNode.concat(getModels(item.list, group))
  11. })
  12. } else if (list[i].type === 'collapse') {
  13. list[i].tabs.forEach(item => {
  14. currentNode = currentNode.concat(getModels(item.list, group))
  15. })
  16. } else if (list[i].type === 'report') {
  17. list[i].rows.forEach(row => {
  18. row.columns.forEach(column => {
  19. currentNode = currentNode.concat(getModels(column.list, group))
  20. })
  21. })
  22. } else if (list[i].type === 'inline') {
  23. currentNode = currentNode.concat(getModels(list[i].list, group))
  24. } else if (list[i].type === 'card') {
  25. currentNode = currentNode.concat(getModels(list[i].list, group))
  26. } else {
  27. if (list[i].options.dataBind) {
  28. let children = []
  29. let curGroup = group ? group + '.' + list[i].model : list[i].model
  30. if (list[i].type === 'table') {
  31. children = getModels(list[i].tableColumns, curGroup)
  32. }
  33. if (list[i].type === 'subform') {
  34. children = getModels(list[i].list, curGroup)
  35. }
  36. if (list[i].type === 'dialog') {
  37. children = getModels(list[i].list, curGroup)
  38. }
  39. if (list[i].type === 'group') {
  40. children = getModels(list[i].list, curGroup)
  41. }
  42. currentNode.push({
  43. id: group ? group + '.' + list[i].model : list[i].model,
  44. name: list[i].name,
  45. type: list[i].type,
  46. icon: list[i].icon,
  47. children: children
  48. })
  49. }
  50. }
  51. }
  52. return currentNode
  53. }
  54. export default getModels