TopicSelectDialog.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <el-dialog
  3. class="topic-select-dialog"
  4. :visible.sync="modalIsShow"
  5. title="试题选择"
  6. top="10vh"
  7. width="500px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="visibleChange"
  12. >
  13. <div class="text-center">
  14. <el-button
  15. v-for="(item, index) in topics"
  16. :key="index"
  17. :type="curTopic.type === item.type ? 'primary' : ''"
  18. @click="selectTopic(item)"
  19. ><i class="el-icon-plus"></i>{{ item.name }}</el-button
  20. >
  21. </div>
  22. <div slot="footer">
  23. <el-button type="danger" @click="cancel" plain>取消</el-button>
  24. <el-button type="primary" @click="submit">确认</el-button>
  25. </div>
  26. </el-dialog>
  27. </template>
  28. <script>
  29. export default {
  30. name: "TopicSelectDialog",
  31. props: {
  32. topics: {
  33. type: Array,
  34. default() {
  35. return [];
  36. }
  37. }
  38. },
  39. data() {
  40. return {
  41. modalIsShow: false,
  42. curTopic: {}
  43. };
  44. },
  45. methods: {
  46. visibleChange() {
  47. this.curTopic = {};
  48. },
  49. cancel() {
  50. this.modalIsShow = false;
  51. },
  52. open() {
  53. this.modalIsShow = true;
  54. },
  55. selectTopic(topic) {
  56. this.curTopic = topic;
  57. },
  58. submit() {
  59. this.$emit("confirm", this.curTopic);
  60. this.cancel();
  61. }
  62. }
  63. };
  64. </script>