dialog.code-snippets 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. {
  2. "mldong-art-design-dialog": {
  3. "prefix": "dialog",
  4. "body": [
  5. "<template>",
  6. " <Dialog> 我是弹窗内容 </Dialog>",
  7. "</template>",
  8. "<script setup lang=\"tsx\">",
  9. " import { useDialog } from '@/components/dialog'",
  10. " import { CrudMethods } from '@/components/crud'",
  11. " const record = ref<any>({})",
  12. " const crudApi = ref<CrudMethods>()",
  13. " const [Dialog, dialogApi] = useDialog({",
  14. " title: '我是标题',",
  15. " width: '50%'",
  16. " })",
  17. " defineExpose({",
  18. " show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {",
  19. " record.value = data",
  20. " crudApi.value = getCrudApi()",
  21. " dialogApi.open()",
  22. " }",
  23. " })",
  24. "</script>",
  25. "<style lang=\"scss\" scoped></style>",
  26. ""
  27. ],
  28. "description": "生成mldong-art-design dialog模板"
  29. },
  30. "mldong-art-design-dialog-drawer": {
  31. "prefix": "drawer",
  32. "body": [
  33. "<template>",
  34. " <Dialog> 我是弹窗内容 </Dialog>",
  35. "</template>",
  36. "<script setup lang=\"tsx\">",
  37. " import { useDialog } from '@/components/dialog'",
  38. " import { CrudMethods } from '@/components/crud'",
  39. " const record = ref<any>({})",
  40. " const crudApi = ref<CrudMethods>()",
  41. " const [Dialog, dialogApi] = useDialog({",
  42. " title: '我是标题',",
  43. " width: '50%',",
  44. " dialogType: 'drawer'",
  45. " })",
  46. " defineExpose({",
  47. " show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {",
  48. " record.value = data",
  49. " crudApi.value = getCrudApi()",
  50. " dialogApi.open()",
  51. " }",
  52. " })",
  53. "</script>",
  54. "<style lang=\"scss\" scoped></style>",
  55. ""
  56. ],
  57. "description": "生成mldong-art-design dialog-drawer模板"
  58. },
  59. "mldong-art-design-dialog-form": {
  60. "prefix": "dialog-form",
  61. "body": [
  62. "<template>",
  63. " <Dialog>",
  64. " <BasicForm />",
  65. " </Dialog>",
  66. "</template>",
  67. "<script setup lang=\"tsx\">",
  68. " import { useDialog } from '@/components/dialog'",
  69. " import { CrudMethods } from '@/components/crud'",
  70. " import { useForm } from '@/components/form'",
  71. " const record = ref<any>({})",
  72. " const crudApi = ref<CrudMethods>()",
  73. " const [Dialog, dialogApi] = useDialog({",
  74. " title: '我是标题',",
  75. " width: '50%',",
  76. " onConfirm() {",
  77. " formApi.validate().then(async () => {",
  78. " const values = await formApi.getValues()",
  79. " console.log(values)",
  80. " })",
  81. " }",
  82. " })",
  83. " const [BasicForm, formApi] = useForm({",
  84. " labelWidth: '120px',",
  85. " schema: [{ prop: 'name', label: '姓名', component: 'Input', rules: [{ required: true, message: '请输入姓名' }] }]",
  86. " })",
  87. " defineExpose({",
  88. " show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {",
  89. " record.value = data",
  90. " crudApi.value = getCrudApi()",
  91. " dialogApi.open()",
  92. " nextTick(() => {",
  93. " formApi.setValues(record.value)",
  94. " })",
  95. " }",
  96. " })",
  97. "</script>",
  98. "<style lang=\"scss\" scoped></style>"
  99. ],
  100. "description": "生成mldong-art-design dialog-form模板"
  101. },
  102. "mldong-art-design-drawer-form": {
  103. "prefix": "drawer-form",
  104. "body": [
  105. "<template>",
  106. " <Dialog>",
  107. " <BasicForm />",
  108. " </Dialog>",
  109. "</template>",
  110. "<script setup lang=\"tsx\">",
  111. " import { useDialog } from '@/components/dialog'",
  112. " import { CrudMethods } from '@/components/crud'",
  113. " import { useForm } from '@/components/form'",
  114. " const record = ref<any>({})",
  115. " const crudApi = ref<CrudMethods>()",
  116. " const [Dialog, dialogApi] = useDialog({",
  117. " title: '我是标题',",
  118. " width: '50%',",
  119. " dialogType: 'drawer',",
  120. " onConfirm() {",
  121. " formApi.validate().then(async () => {",
  122. " const values = await formApi.getValues()",
  123. " console.log(values)",
  124. " })",
  125. " }",
  126. " })",
  127. " const [BasicForm, formApi] = useForm({",
  128. " labelWidth: '120px',",
  129. " schema: [{ prop: 'name', label: '姓名', component: 'Input', rules: [{ required: true, message: '请输入姓名' }] }]",
  130. " })",
  131. " defineExpose({",
  132. " show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {",
  133. " record.value = data",
  134. " crudApi.value = getCrudApi()",
  135. " dialogApi.open()",
  136. " nextTick(() => {",
  137. " formApi.setValues(record.value)",
  138. " })",
  139. " }",
  140. " })",
  141. "</script>",
  142. "<style lang=\"scss\" scoped></style>"
  143. ],
  144. "description": "生成mldong-art-design drawer-form模板"
  145. }
  146. }