crud.code-snippets 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. {
  2. "cl-crud": {
  3. "prefix": "cl-crud",
  4. "scope": "vue",
  5. "body": [
  6. "<template>",
  7. " <cl-crud ref=\"Crud\">",
  8. " <cl-row>",
  9. " <!-- 刷新按钮 -->",
  10. " <cl-refresh-btn />",
  11. " <!-- 新增按钮 -->",
  12. " <cl-add-btn />",
  13. " <!-- 删除按钮 -->",
  14. " <cl-multi-delete-btn />",
  15. " <cl-flex1 />",
  16. " <!-- 关键字搜索 -->",
  17. " <cl-search-key />",
  18. " </cl-row>",
  19. "",
  20. " <cl-row>",
  21. " <!-- 数据表格 -->",
  22. " <cl-table ref=\"Table\" />",
  23. " </cl-row>",
  24. "",
  25. " <cl-row>",
  26. " <cl-flex1 />",
  27. " <!-- 分页控件 -->",
  28. " <cl-pagination />",
  29. " </cl-row>",
  30. "",
  31. " <!-- 新增、编辑 -->",
  32. " <cl-upsert ref=\"Upsert\" />",
  33. " </cl-crud>",
  34. "</template>",
  35. "",
  36. "<script lang=\"ts\" name=\"菜单名称\" setup>",
  37. "import { useCrud, useTable, useUpsert } from \"@cool-vue/crud\";",
  38. "import { useCool } from \"/@/cool\";",
  39. "",
  40. "const { service } = useCool();",
  41. "",
  42. "// cl-upsert",
  43. "const Upsert = useUpsert({",
  44. " items: []",
  45. "});",
  46. "",
  47. "// cl-table",
  48. "const Table = useTable({",
  49. " columns: []",
  50. "});",
  51. "",
  52. "// cl-crud",
  53. "const Crud = useCrud(",
  54. " {",
  55. " service: service.demo.goods",
  56. " },",
  57. " (app) => {",
  58. " app.refresh();",
  59. " }",
  60. ");",
  61. "",
  62. "// 刷新",
  63. "function refresh(params?: any) {",
  64. " Crud.value?.refresh(params);",
  65. "}",
  66. "</script>",
  67. ""
  68. ],
  69. "description": "cl-crud snippets"
  70. }
  71. }