ExplanatoryNoteDialog.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <el-dialog
  3. :title="titleText === '气泡' ? titleText : '编辑' + titleText"
  4. :visible.sync="visible"
  5. width="680px"
  6. :close-on-click-modal="false"
  7. @close="dialogClose()"
  8. >
  9. <RichText
  10. v-model="richData.dataStr"
  11. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright image media link"
  12. :wordlimit-num="false"
  13. :height="240"
  14. placeholder="输入内容"
  15. page-from="audit"
  16. />
  17. <template slot="footer">
  18. <el-button size="medium" @click="deleteNote">删除</el-button>
  19. <el-button type="primary" size="medium" @click="confirm">确定</el-button>
  20. </template>
  21. </el-dialog>
  22. </template>
  23. <script>
  24. import RichText from './RichText';
  25. export default {
  26. name: 'ExplanatoryNoteDialog',
  27. components: {
  28. RichText,
  29. },
  30. props: {
  31. open: {
  32. type: Boolean,
  33. default: false,
  34. required: true,
  35. },
  36. initData: {
  37. type: Object,
  38. default: () => ({}),
  39. },
  40. titleText: {
  41. type: String,
  42. default: '气泡',
  43. },
  44. },
  45. data() {
  46. return {
  47. visible: false,
  48. richData: this.initData,
  49. };
  50. },
  51. watch: {
  52. open(newVal) {
  53. this.visible = newVal;
  54. this.richData = this.initData;
  55. },
  56. visible(newVal) {
  57. if (!newVal) {
  58. this.$emit('update:open', false);
  59. this.richData = {};
  60. }
  61. },
  62. },
  63. methods: {
  64. // 关闭弹窗,调用富文本组件中的
  65. dialogClose() {
  66. this.visible = false;
  67. },
  68. deleteNote() {
  69. this.$confirm(`确定要删除此条${this.titleText}吗?`, '提示', {
  70. confirmButtonText: '确定',
  71. cancelButtonText: '取消',
  72. type: 'warning',
  73. })
  74. .then(() => {
  75. this.visible = false;
  76. this.$emit('cancel');
  77. })
  78. .catch(() => {});
  79. },
  80. confirm() {
  81. this.$emit('confirm', this.richData);
  82. },
  83. },
  84. };
  85. </script>
  86. <style lang="scss" scoped>
  87. .el-dialog {
  88. :deep &__body {
  89. display: flex;
  90. flex-direction: column;
  91. row-gap: 8px;
  92. padding: 8px 8px 0;
  93. .el-textarea__inner {
  94. height: 108px;
  95. }
  96. }
  97. :deep &__footer {
  98. display: flex;
  99. padding: 8px;
  100. .el-button {
  101. flex: 1;
  102. }
  103. }
  104. }
  105. </style>