doc.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!-- -->
  2. <template>
  3. <div class="num-box">
  4. <span>第</span>
  5. <div class="input-box">{{ pageIndex + 1 }}</div>
  6. <span style="margin-right: 30px">页</span> <span>共</span>
  7. <div class="input-box">{{ page }}</div>
  8. <span>页</span>
  9. </div>
  10. <div class="write-box" id="view-container">
  11. <div class="content" :style="`height:${inputHeight}px;`" @click="goWrite">
  12. <!-- <div contenteditable v-html="text" :style="`height:${lineCount * 40}px;`" @keydown="hanlderWrite($event)" id="view-info"></div> -->
  13. <div :style="`transform:translateY(${pageIndex == 1 ? -400 : -400 - (pageIndex - 1) * inputHeight}px);`" id="view-info" v-html="text"></div>
  14. <div class="msg-box">{{ text }}</div>
  15. <div class="item" :style="`top:${index * 40}px;`" v-for="(i, index) in lineCount"></div>
  16. </div>
  17. </div>
  18. <div class="bottom-name">
  19. <span v-if="type == '1'">被询问人:</span>
  20. <span v-else>被讯问人:</span>
  21. <div style="flex: 1" contenteditable></div>
  22. </div>
  23. </template>
  24. <script setup>
  25. import { reactive, ref, toRefs, onBeforeMount, onMounted, nextTick, defineProps, defineEmits } from 'vue';
  26. import { router } from '@/router';
  27. const props = defineProps({
  28. text: {
  29. type: String,
  30. default: '',
  31. },
  32. page: {
  33. type: Number,
  34. default: 1,
  35. },
  36. pageIndex: {
  37. type: Number,
  38. default: 1,
  39. },
  40. });
  41. const emits = defineEmits(['goWrite']);
  42. const type = ref(router.currentRoute.value.query.type);
  43. const lineCount = ref(1);
  44. const inputHeight = ref(0);
  45. const getLineCount = () => {
  46. let containerH = document.getElementById('view-container').clientHeight;
  47. let count = Math.floor(containerH / 40);
  48. lineCount.value = count;
  49. inputHeight.value = count * 40;
  50. // textAreaHeight.value = lineCount.value * 40;
  51. };
  52. const goWrite = () => {
  53. let text = window.getSelection();
  54. let textIndex = text.anchorOffset;
  55. emits('goWrite', { textIndex });
  56. };
  57. onMounted(async () => {
  58. await nextTick();
  59. getLineCount();
  60. });
  61. </script>
  62. <style lang="scss" scoped>
  63. div[contenteditable] {
  64. outline: none;
  65. }
  66. .bottom-name {
  67. width: 100%;
  68. height: 40px;
  69. line-height: 40px;
  70. margin: 28px auto 0;
  71. display: flex;
  72. font-size: 24px;
  73. }
  74. .num-box {
  75. display: flex;
  76. align-items: center;
  77. justify-content: flex-end;
  78. margin-bottom: 10px;
  79. .input-box {
  80. width: 64px;
  81. height: 30px;
  82. line-height: 30px;
  83. border-bottom: 1px solid #000;
  84. text-align: center;
  85. margin: 0 5px;
  86. }
  87. }
  88. .write-box {
  89. width: 100%;
  90. // height: calc(100vh - 100px);
  91. height: 1080px;
  92. overflow: hidden;
  93. .content {
  94. overflow: hidden;
  95. padding-bottom: 5px;
  96. position: relative;
  97. font-size: 24px;
  98. .item {
  99. width: 100%;
  100. height: 40px;
  101. border-bottom: 1px solid #000;
  102. box-sizing: border-box;
  103. position: absolute;
  104. left: 0;
  105. }
  106. #view-info {
  107. position: absolute;
  108. top: 0;
  109. left: 0;
  110. width: 100%;
  111. // height: 100%;
  112. line-height: 40px;
  113. outline: none;
  114. resize: none;
  115. z-index: 2;
  116. overflow: hidden;
  117. white-space: pre-wrap;
  118. }
  119. .msg-box {
  120. min-height: 40px;
  121. white-space: pre-wrap;
  122. opacity: 0;
  123. position: absolute;
  124. width: 100%;
  125. line-height: 40px;
  126. z-index: 1;
  127. }
  128. }
  129. }
  130. </style>