index.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <c-dialog
  3. ref="dialog"
  4. :size="sizeClassName"
  5. v-bind="$attrs"
  6. >
  7. <schema-table
  8. ref="table"
  9. :schema="schema"
  10. v-on="schema.listeners"
  11. >
  12. <template
  13. v-if="hasHeader"
  14. #header="scope"
  15. >
  16. <slot
  17. name="header"
  18. v-bind="scope"
  19. />
  20. </template>
  21. </schema-table>
  22. <slot />
  23. </c-dialog>
  24. </template>
  25. <script>
  26. export default {
  27. name: 'TableDialog',
  28. inheritAttrs: false,
  29. props: {
  30. schema: {
  31. type: Object,
  32. required: true
  33. },
  34. size: {
  35. type: String,
  36. default: 'medium'
  37. }
  38. },
  39. computed: {
  40. hasHeader () {
  41. return !!this.$scopedSlots.header
  42. },
  43. sizeClassName () {
  44. return `table ${this.size} fixed`
  45. }
  46. },
  47. methods: {
  48. show (condition) {
  49. if (condition) {
  50. this.schema.condition = { ...this.schema.condition, ...condition }
  51. }
  52. this.$refs.dialog.show()
  53. },
  54. getTable () {
  55. return this.$refs.table
  56. }
  57. }
  58. }
  59. </script>