ChooseTemplateDialog.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <el-dialog
  3. :title="hasCreate ? '新建' : '模板'"
  4. :visible.sync="dialogVisible"
  5. width="50%"
  6. class="bs-dialog-wrap bs-el-dialog"
  7. :before-close="handleClose"
  8. >
  9. <TemplateList
  10. ref="templateList"
  11. :has-create="hasCreate"
  12. :page-info="pageInfo"
  13. :loading="loading"
  14. @addNew="addNew"
  15. @useIt="useIt"
  16. @replaceItByTemplate="replaceItByTemplate"
  17. />
  18. </el-dialog>
  19. </template>
  20. <script>
  21. import TemplateList from 'data-room-ui/TemplateList'
  22. export default {
  23. name: 'ChooseTemplistDialog',
  24. components: {
  25. TemplateList
  26. },
  27. props: {
  28. loading: {
  29. type: Boolean,
  30. default: false
  31. },
  32. hasCreate: {
  33. type: Boolean,
  34. default: false
  35. },
  36. pageInfo: {
  37. type: Object,
  38. default: () => {}
  39. }
  40. },
  41. data () {
  42. return {
  43. dialogVisible: false,
  44. parentNode: null,
  45. type: null
  46. }
  47. },
  48. mounted () {
  49. },
  50. methods: {
  51. init (parentNode, type) {
  52. this.parentNode = parentNode
  53. this.type = type
  54. this.dialogVisible = true
  55. this.$nextTick(() => {
  56. this.$refs.templateList.getTemplateList(type)
  57. })
  58. },
  59. handleClose () {
  60. this.dialogVisible = false
  61. },
  62. addNew () {
  63. this.$emit('addNew', this.parentNode, this.type)
  64. },
  65. useIt (id) {
  66. this.$emit('useIt', id, this.parentNode, this.type)
  67. },
  68. replaceItByTemplate (config) {
  69. this.$emit('replaceItByTemplate', config)
  70. this.dialogVisible = false
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. </style>