|
@@ -0,0 +1,255 @@
|
|
|
+<template>
|
|
|
+ <el-row style="height: 100%;padding: 0" v-loading="isLoading">
|
|
|
+
|
|
|
+ <el-col :span="4" style="background-color: white">
|
|
|
+ <el-col>
|
|
|
+ <emr-sidebar @nodeClick="handleNodeClick" @typeChange="typeChange"/>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="20">
|
|
|
+ <el-col>
|
|
|
+ <div style="height: 40px">
|
|
|
+ <emr-selection style="width: 120px" v-model="editorModify.editorTitle"
|
|
|
+ execute="defaultStyleId"
|
|
|
+ @change="selectionChange"
|
|
|
+ :data="editorTitle" styles="styles"/>
|
|
|
+ <emr-selection v-model="editorModify.availableFonts" :data="editorData.availableFonts"
|
|
|
+ @change="selectionChange"
|
|
|
+ code="font"
|
|
|
+ execute="fontFamily"
|
|
|
+ styles="styles"
|
|
|
+ name="text"/>
|
|
|
+ <emr-selection style="width: 120px"
|
|
|
+ v-model="editorModify.fontSizes"
|
|
|
+ execute="fontSize"
|
|
|
+ @change="selectionChange" :data="editorData.fontSizes"/>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col style="width: 100%;height: calc(100% - 50px);overflow-y: clip">
|
|
|
+ <el-row style="height: 100%">
|
|
|
+ <el-col :span="2">
|
|
|
+ as范德贝克哈设计好的呢
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="17">
|
|
|
+ <iframe style="width: 100%;height: 100%" :src="iframeSrc" ref="iframeRef"/>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="5">
|
|
|
+ 这里是存放数据源的
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {getTemplate} from "@/api/zhu-yuan-yi-sheng/emr-api";
|
|
|
+import store from "@/store";
|
|
|
+import {huanZheXinXi} from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
|
|
|
+import {ref} from 'vue'
|
|
|
+import EmrSidebar from "@/components/zhu-yuan-yi-sheng/emr/EmrSidebar.vue";
|
|
|
+import EmrSelection from "@/components/zhu-yuan-yi-sheng/emr/EmrSelection.vue";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'EmrEditor',
|
|
|
+ components: {EmrSelection, EmrSidebar},
|
|
|
+ setup() {
|
|
|
+ const iframeSrc = '/emr/runtime/#/editor'
|
|
|
+ const templateType = ref(0)
|
|
|
+
|
|
|
+ let emrInit = null
|
|
|
+ const iframeRef = ref(null)
|
|
|
+ const isLoading = ref(true)
|
|
|
+ const editorData = ref({})
|
|
|
+ const editorTitle = [
|
|
|
+ {
|
|
|
+ code: "global_style_text",
|
|
|
+ name: "正文",
|
|
|
+ styles: "font-family: "Microsoft YaHei"; font-size: 12pt; font-weight: normal;"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: "global_style_title",
|
|
|
+ name: "标题",
|
|
|
+ styles: "font-family: "Microsoft YaHei"; font-size: 22pt; font-weight: normal;"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: "global_style_subtitle",
|
|
|
+ name: "副标题",
|
|
|
+ styles: "font-family: "Microsoft YaHei"; font-size: 20pt; font-weight: normal;"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: "global_style_title_1",
|
|
|
+ name: "标题1",
|
|
|
+ styles: "font-family: "Microsoft YaHei"; font-size: 18pt; font-weight: normal;"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: "global_style_title_2",
|
|
|
+ name: "标题2",
|
|
|
+ styles: "font-family: "Microsoft YaHei"; font-size: 16pt; font-weight: normal;"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: "global_style_title_3",
|
|
|
+ name: "标题3",
|
|
|
+ styles: "font-family: "Microsoft YaHei" font-size: 14pt; font-weight: normal;"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: "global_style_title_4",
|
|
|
+ name: "标题4",
|
|
|
+ styles: "font-family: "Microsoft YaHei"; font-size: 12pt; font-weight: normal;"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: "global_style_title_5",
|
|
|
+ name: "标题5",
|
|
|
+ styles: "font-family: "Microsoft YaHei"; font-size: 11pt; font-weight: normal;"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ const editorModify = ref({
|
|
|
+ editorTitle: 'global_style_text',
|
|
|
+ availableFonts: 'SimSun',
|
|
|
+ fontSizes: '12pt'
|
|
|
+ })
|
|
|
+
|
|
|
+ const typeChange = (val) => {
|
|
|
+ console.log(val)
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleNodeClick = (val) => {
|
|
|
+ getTemplate(val.code).then((res) => {
|
|
|
+ emrInit.editor.setDocument(res, true, true)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ const getEditorData = () => {
|
|
|
+ let availableFonts = emrInit.editor.getAvailableFonts()
|
|
|
+ for (let i = 0, len = availableFonts.length; i < len; i++) {
|
|
|
+ availableFonts[i]['styles'] = `font-family:${availableFonts[i]['font']}`
|
|
|
+ }
|
|
|
+ dataAssignment('availableFonts', availableFonts)
|
|
|
+ dataAssignment('fontSizes', emrInit.editor.getFontSizes(), 'code')
|
|
|
+ console.log(editorData.value);
|
|
|
+ }
|
|
|
+
|
|
|
+ const dataAssignment = (name, data, code) => {
|
|
|
+ if (code) {
|
|
|
+ let keys = {}
|
|
|
+ let deduplication = []
|
|
|
+ for (let i = 0, len = data.length; i < len; i++) {
|
|
|
+ let item = data[i]
|
|
|
+ if (!keys[item[code]]) {
|
|
|
+ deduplication.push(item)
|
|
|
+ keys[item[code]] = item
|
|
|
+ }
|
|
|
+ }
|
|
|
+ editorData.value[name] = deduplication;
|
|
|
+ } else {
|
|
|
+ editorData.value[name] = data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const selectionChange = (name, val, data) => {
|
|
|
+ console.log(name, val, data)
|
|
|
+ emrInit.editor.execute(name, {value: val})
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ nextTick(() => {
|
|
|
+ emrInit = new EMRInteractive()
|
|
|
+ iframeRef.value.parentElement.emr = emrInit
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ return {
|
|
|
+ iframeSrc,
|
|
|
+ templateType,
|
|
|
+ handleNodeClick,
|
|
|
+ iframeRef,
|
|
|
+ isLoading,
|
|
|
+ editorModify,
|
|
|
+ typeChange,
|
|
|
+ editorData,
|
|
|
+ editorTitle,
|
|
|
+ selectionChange
|
|
|
+ }
|
|
|
+
|
|
|
+ function EMRInteractive(data) {
|
|
|
+ this.setEditor = (editor, runtime) => {
|
|
|
+ this.editor = editor;
|
|
|
+ this.runtime = runtime;
|
|
|
+
|
|
|
+ editor.on('loaded', function (event) {
|
|
|
+ getEditorData()
|
|
|
+ isLoading.value = false
|
|
|
+ })
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ this.getAppContext = () => {
|
|
|
+ return {
|
|
|
+ endpoints: {
|
|
|
+ app: "/bdp/dataservice/api",
|
|
|
+ },
|
|
|
+ input: {
|
|
|
+ user: store.state.user.info.code,
|
|
|
+ name: store.state.user.info.name
|
|
|
+ },
|
|
|
+ login: {
|
|
|
+ token: store.state.user.info.token
|
|
|
+ },
|
|
|
+ data
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ this.loadDocument = (result) => {
|
|
|
+ this.runtime.loadDocument(
|
|
|
+ result => {
|
|
|
+ console.log(result)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ this.saveDocument = (cb) => {
|
|
|
+ let data = this.editor.getDocument();
|
|
|
+ data.properties.patientId = huanZheXinXi.value.inpatientNo;
|
|
|
+ data.properties.creator = store.state.user.info.code;
|
|
|
+ data.properties.createTime = new Date()
|
|
|
+ data.properties.modifier = store.state.user.info.code;
|
|
|
+ data.properties.modifyTime = new Date()
|
|
|
+ this.runtime.saveDocument(
|
|
|
+ data,
|
|
|
+ (res) => {
|
|
|
+ console.log("emr保存成功", res);
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log("emr保存失败", err);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ };
|
|
|
+ this.deleteDocument = (cb) => {
|
|
|
+ this.runtime.delDocument(documentId, (res) => {
|
|
|
+ console.log(res)
|
|
|
+ });
|
|
|
+ };
|
|
|
+ this.printDocument = (showPreview, docs = null) => {
|
|
|
+ console.log(showPreview, docs)
|
|
|
+ console.log('print document.')
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|