https://react-querybuilder.js.org/
在线案例 https://react-querybuilder.js.org/react-querybuilder
Github https://github.com/react-querybuilder/react-querybuilder
image.png

  1. yarn add react-querybuilder
  2. yarn add @react-querybuilder/antd @ant-design/icons antd

load from sql

image.png

  1. SELECT *
  2. FROM my_table
  3. WHERE (firstName like 'Stev%' and lastName in ('Vai', 'Vaughan') and age > '28' and (isMusician = TRUE or instrument = 'Guitar') and groupedField1 = groupedField4);

load from json

  1. {
  2. "and": [
  3. {
  4. "startsWith": [
  5. {
  6. "var": "firstName"
  7. },
  8. "Stev"
  9. ]
  10. },
  11. {
  12. "in": [
  13. {
  14. "var": "lastName"
  15. },
  16. [
  17. "Vai",
  18. "Vaughan"
  19. ]
  20. ]
  21. },
  22. {
  23. ">": [
  24. {
  25. "var": "age"
  26. },
  27. "28"
  28. ]
  29. },
  30. {
  31. "or": [
  32. {
  33. "==": [
  34. {
  35. "var": "isMusician"
  36. },
  37. true
  38. ]
  39. },
  40. {
  41. "==": [
  42. {
  43. "var": "instrument"
  44. },
  45. "Guitar"
  46. ]
  47. }
  48. ]
  49. },
  50. {
  51. "==": [
  52. {
  53. "var": "groupedField1"
  54. },
  55. {
  56. "var": "groupedField4"
  57. }
  58. ]
  59. }
  60. ]
  61. }

QueryBuild在线案例
https://codesandbox.io/s/ug9wk
https://codesandbox.io/s/fe9cc
https://codesandbox.io/examples/package/react-querybuilder

sql queryBuild

https://github.com/sqlkata/querybuilder

vue queryBuild

https://github.com/gloxing/treeRule
image.png