EmrEditorTool.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div class="emr_editor_tool">
  3. <el-select v-model="emrStyle.fontFamily"
  4. ref="fontFamilyRef"
  5. @change="styleFunc('fontFamily',emrStyle.fontFamily)"
  6. style="width: 150px;">
  7. <el-option v-for="item in availableFonts" :value="item.font" :label="item.text"/>
  8. </el-select>
  9. <el-select v-model="emrStyle.fontSize">
  10. </el-select>
  11. </div>
  12. </template>
  13. <script setup name='EmrEditorTool' lang="ts">
  14. import {availableFonts} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
  15. import {defineProps, ref} from 'vue'
  16. const props = defineProps({
  17. editor: {
  18. type: Object
  19. },
  20. getEdit: {
  21. type: Function
  22. }
  23. })
  24. let emrStyle = $ref({
  25. // 字体样式
  26. fontFamily: '"Microsoft YaHei"',
  27. // 字体大小
  28. fontSize: '10.5pt',
  29. // 字体加粗
  30. fontWeight: 'normal',
  31. // 斜体
  32. fontStyle: 'normal',
  33. // 设置字体下划线、删除线
  34. underline: 'none'
  35. })
  36. const fontFamilyRef = ref(null)
  37. const blur = () => {
  38. fontFamilyRef.value.blur()
  39. }
  40. const styleFunc = (name, value) => {
  41. emrStyle[name] = value
  42. console.log(props.getEdit())
  43. props.getEdit().execute(name, {value: value})
  44. // props.editor.execute(name, {value: value})
  45. }
  46. const styleFuncNormal = (name, style) => {
  47. let value = emrStyle[name]
  48. styleFunc(name, value === 'normal' ? style : 'normal')
  49. }
  50. const updateStyleValue = (context) => {
  51. emrStyle.fontSize = context.fontSize
  52. emrStyle.fontFamily = context.fontFamily
  53. emrStyle.fontStyle = context.italic ? 'oblique' : 'normal'
  54. emrStyle.fontWeight = context.bold ? 'bold' : 'normal'
  55. }
  56. const emrContextUpdate = (value) => {
  57. blur()
  58. updateStyleValue(value)
  59. }
  60. defineExpose({
  61. emrContextUpdate
  62. })
  63. </script>
  64. <style scoped lang="scss">
  65. .emr_editor_tool {
  66. width: 100%;
  67. height: 30px;
  68. background-color: #f0f0f0
  69. }
  70. </style>