reuse-methods.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. export const updateClassName = (genList, fields, className, updateType) => {
  2. for (let i = 0; i < genList.length; i++) {
  3. if (genList[i].type === 'grid') {
  4. genList[i].columns.forEach(item => {
  5. updateClassName(item.list, fields, className, updateType)
  6. })
  7. } else if (genList[i].type === 'tabs') {
  8. genList[i].tabs.forEach(item => {
  9. updateClassName(item.list, fields, className, updateType)
  10. })
  11. } else if (genList[i].type === 'collapse') {
  12. genList[i].tabs.forEach(item => {
  13. updateClassName(item.list, fields, className, updateType)
  14. })
  15. } else if (genList[i].type === 'report') {
  16. genList[i].rows.forEach(row => {
  17. row.columns.forEach(column => {
  18. updateClassName(column.list, fields, className, updateType)
  19. })
  20. })
  21. } else if (genList[i].type === 'inline') {
  22. updateClassName(genList[i].list, fields, className, updateType)
  23. } else if (genList[i].type === 'card') {
  24. updateClassName(genList[i].list, fields, className, updateType)
  25. } else {
  26. if (fields.length === 1) {
  27. if (genList[i].model === fields[0]) {
  28. if (updateType == 'add' && !genList[i].options.customClass.split(' ').includes(className)) {
  29. genList[i].options.customClass = [...genList[i].options.customClass.split(' '), className].join(' ')
  30. }
  31. if (updateType == 'remove' && genList[i].options.customClass.split(' ').includes(className)) {
  32. let originArray = genList[i].options.customClass.split(' ')
  33. originArray.splice(originArray.findIndex(item => item == className), 1)
  34. genList[i].options.customClass = originArray.join(' ')
  35. }
  36. }
  37. } else {
  38. if (genList[i].model === fields[0]) {
  39. let newFields = [...fields]
  40. newFields.splice(0, 1)
  41. if (genList[i].type === 'table') {
  42. updateClassName(genList[i].tableColumns, newFields, className, updateType)
  43. }
  44. if (genList[i].type === 'subform') {
  45. updateClassName(genList[i].list, newFields, className, updateType)
  46. }
  47. if (genList[i].type === 'group') {
  48. updateClassName(genList[i].list, newFields, className, updateType)
  49. }
  50. if (genList[i].type === 'dialog') {
  51. updateClassName(genList[i].list, newFields, className, updateType)
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }