vue2-client 1.16.24 → 1.16.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +112 -112
- package/src/assets/img/paymentMethod/icon1.png +0 -0
- package/src/assets/img/paymentMethod/icon2.png +0 -0
- package/src/assets/img/paymentMethod/icon3.png +0 -0
- package/src/assets/img/paymentMethod/icon4.png +0 -0
- package/src/assets/img/paymentMethod/icon5.png +0 -0
- package/src/assets/img/paymentMethod/icon6.png +0 -0
- package/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm.vue +478 -478
- package/src/base-client/components/common/HIS/HAddNativeForm/index.js +3 -3
- package/src/base-client/components/common/HIS/HButtons/HButtons.vue +365 -365
- package/src/base-client/components/common/HIS/HForm/HForm.vue +133 -0
- package/src/base-client/components/common/HIS/HForm/index.js +3 -0
- package/src/base-client/components/common/HIS/HFormTable/HFormTable.vue +219 -219
- package/src/base-client/components/common/HIS/HTab/HTab.vue +293 -293
- package/src/base-client/components/common/HIS/demo.vue +54 -54
- package/src/base-client/components/common/XReport/XReportHospitalizationDemo.vue +45 -0
- package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +816 -813
- package/src/base-client/components/his/XCharge/XCharge.vue +610 -610
- package/src/base-client/components/his/XCharge/testConfig.js +149 -0
- package/src/base-client/components/his/XSidebar/XSidebar.vue +283 -283
- package/src/base-client/components/his/XSimpleTable/XSimpleTable.vue +119 -119
- package/src/base-client/components/his/XTimeSelect/XTimeSelect.vue +200 -200
- package/src/base-client/components/his/threeTestOrders/threeTestOrders.vue +482 -482
- package/src/router/async/router.map.js +131 -129
- package/src/services/api/common.js +1 -0
@@ -1,482 +1,482 @@
|
|
1
|
-
<template>
|
2
|
-
<!-- <Source src="/code/VitalSigns.vue"></Source>-->
|
3
|
-
<div>
|
4
|
-
<a-row class="box">
|
5
|
-
<!-- 病历号输入框已隐藏,通过setMedicalRecordId方法设置vitalSignsId -->
|
6
|
-
<!-- 病历号 <a-input v-model="vitalSignsId" style="width: 160px"></a-input> -->
|
7
|
-
<a-button-group style="margin-left: 20px;">
|
8
|
-
<a-button
|
9
|
-
v-if="showCreateButton"
|
10
|
-
plain
|
11
|
-
type="primary"
|
12
|
-
@click="showVitalSignsModal('create')"
|
13
|
-
:loading="loading"
|
14
|
-
:disabled="!editorReady">创建体温单</a-button>
|
15
|
-
<a-button
|
16
|
-
v-if="showUpdateButton"
|
17
|
-
plain
|
18
|
-
type="primary"
|
19
|
-
@click="showVitalSignsModal('update')"
|
20
|
-
:loading="loading"
|
21
|
-
:disabled="!editorReady">更新体温单</a-button>
|
22
|
-
</a-button-group>
|
23
|
-
<a-button-group v-if="showClearButton" style="margin: 0 20px;">
|
24
|
-
<a-button plain type="primary" @click="execCommand('print')" :loading="loading" :disabled="!editorReady">打印</a-button>
|
25
|
-
</a-button-group>
|
26
|
-
<!-- 修改清空体温单按钮样式,使其更加醒目 -->
|
27
|
-
<a-button
|
28
|
-
type="primary"
|
29
|
-
danger
|
30
|
-
v-if="showClearButton"
|
31
|
-
@click="clearVitalSigns"
|
32
|
-
:loading="loading"
|
33
|
-
:disabled="!editorReady"
|
34
|
-
style="margin-left: 10px;">
|
35
|
-
<a-icon type="delete" /> 清空体温单
|
36
|
-
</a-button>
|
37
|
-
</a-row>
|
38
|
-
<div v-if="!editorReady" style="margin: 10px 0; padding: 10px; background-color: #fffbe6; border: 1px solid #ffe58f;">
|
39
|
-
<a-icon type="loading" /> 体温单编辑器加载中...
|
40
|
-
</div>
|
41
|
-
|
42
|
-
<!-- 添加体温单生成加载遮罩 -->
|
43
|
-
<div v-if="generating" class="generating-mask">
|
44
|
-
<div class="generating-content">
|
45
|
-
<a-spin size="large" />
|
46
|
-
<div class="generating-text">体温单生成中,请稍候...</div>
|
47
|
-
</div>
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<Editor @editor-ready="onEditorReady" style="margin: 10px 0;" ref="editorComponent"></Editor>
|
51
|
-
|
52
|
-
<!-- 使用TextBox组件替代原有弹窗 -->
|
53
|
-
<TextBox
|
54
|
-
:visible="modalVisible"
|
55
|
-
:modalType="modalType"
|
56
|
-
:editorReady="editorReady"
|
57
|
-
:id="Number(vitalSignsId) || 180"
|
58
|
-
@submit="handleSubmit"
|
59
|
-
@cancel="closeModal"
|
60
|
-
/>
|
61
|
-
</div>
|
62
|
-
</template>
|
63
|
-
|
64
|
-
<script setup>
|
65
|
-
import { ref, onMounted } from 'vue'
|
66
|
-
import Editor from './editor.vue'
|
67
|
-
import TextBox from './textBox.vue'
|
68
|
-
import { message } from 'ant-design-vue'
|
69
|
-
|
70
|
-
// 响应式状态
|
71
|
-
const vitalSignsId = ref(null)
|
72
|
-
const loading = ref(false)
|
73
|
-
const editorReady = ref(false)
|
74
|
-
const editorComponent = ref(null)
|
75
|
-
const modalVisible = ref(false)
|
76
|
-
const modalType = ref('create')
|
77
|
-
const generating = ref(false) // 添加体温单生成中状态
|
78
|
-
let editor = null
|
79
|
-
// 定义组件事件
|
80
|
-
const emit = defineEmits(['submit'])
|
81
|
-
// 常量
|
82
|
-
const modalTitles = {
|
83
|
-
create: '创建体温单',
|
84
|
-
update: '更新体温单'
|
85
|
-
}
|
86
|
-
|
87
|
-
// 接受父组件传递的属性
|
88
|
-
defineProps({
|
89
|
-
showCreateButton: {
|
90
|
-
type: Boolean,
|
91
|
-
default: false
|
92
|
-
},
|
93
|
-
showUpdateButton: {
|
94
|
-
type: Boolean,
|
95
|
-
default: false
|
96
|
-
},
|
97
|
-
// 添加打印按钮是否显示属性
|
98
|
-
showPrintButton: {
|
99
|
-
type: Boolean,
|
100
|
-
default: false
|
101
|
-
},
|
102
|
-
showClearButton: {
|
103
|
-
type: Boolean,
|
104
|
-
default: false
|
105
|
-
},
|
106
|
-
// 时间模式 -2 ~ 2
|
107
|
-
adjustHour: {
|
108
|
-
type: Number,
|
109
|
-
default: 0
|
110
|
-
}
|
111
|
-
})
|
112
|
-
|
113
|
-
// 显示弹窗
|
114
|
-
function showVitalSignsModal (type) {
|
115
|
-
modalType.value = type
|
116
|
-
modalVisible.value = true
|
117
|
-
}
|
118
|
-
|
119
|
-
// 关闭弹窗
|
120
|
-
function closeModal () {
|
121
|
-
modalVisible.value = false
|
122
|
-
}
|
123
|
-
|
124
|
-
// 编辑器初始化
|
125
|
-
function onEditorReady (editorObj) {
|
126
|
-
try {
|
127
|
-
if (!editorObj) {
|
128
|
-
throw new Error('传入的editor对象为null或undefined')
|
129
|
-
}
|
130
|
-
|
131
|
-
// 尝试获取编辑器对象
|
132
|
-
if (typeof editorObj.createVitalSigns === 'function') {
|
133
|
-
editor = editorObj
|
134
|
-
} else if (editorObj.getEditor && typeof editorObj.getEditor === 'function') {
|
135
|
-
const editorFromComponent = editorObj.getEditor()
|
136
|
-
editor = editorFromComponent && typeof editorFromComponent.createVitalSigns === 'function'
|
137
|
-
? editorFromComponent
|
138
|
-
: (typeof editorObj.createVitalSigns === 'function' ? editorObj : null)
|
139
|
-
}
|
140
|
-
if (!editor) {
|
141
|
-
throw new Error('无法获取有效的editor对象')
|
142
|
-
}
|
143
|
-
editorReady.value = true
|
144
|
-
} catch (err) {
|
145
|
-
console.error('设置editor对象失败:', err)
|
146
|
-
message.error('体温单编辑器初始化失败,请刷新页面重试')
|
147
|
-
}
|
148
|
-
}
|
149
|
-
|
150
|
-
// 执行命令
|
151
|
-
function execCommand (cmd) {
|
152
|
-
if (!editorReady.value || !editor) return
|
153
|
-
loading.value = true
|
154
|
-
try {
|
155
|
-
editor.execCommand(cmd)
|
156
|
-
} catch (err) {
|
157
|
-
console.error('执行命令出错:', err)
|
158
|
-
message.error(`执行${cmd}命令失败`)
|
159
|
-
} finally {
|
160
|
-
loading.value = false
|
161
|
-
}
|
162
|
-
}
|
163
|
-
|
164
|
-
// 清空体温单
|
165
|
-
async function clearVitalSigns () {
|
166
|
-
if (!editorReady.value || !editor) {
|
167
|
-
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
168
|
-
return
|
169
|
-
}
|
170
|
-
loading.value = true
|
171
|
-
generating.value = true
|
172
|
-
try {
|
173
|
-
// 重新加载editor.html页面来完全重置编辑器
|
174
|
-
try {
|
175
|
-
const iframe = editorComponent.value.$refs.editorIframe
|
176
|
-
if (iframe) {
|
177
|
-
// 保存当前src
|
178
|
-
const currentSrc = iframe.src
|
179
|
-
// 确认提示
|
180
|
-
message.loading('正在清空体温单...', 1)
|
181
|
-
// 重新加载iframe
|
182
|
-
iframe.onload = async () => {
|
183
|
-
try {
|
184
|
-
// 等待iframe重新加载完成
|
185
|
-
await new Promise(resolve => setTimeout(resolve, 500))
|
186
|
-
// 获取新的editor对象
|
187
|
-
const newEditorObj = iframe.contentWindow.editor
|
188
|
-
if (newEditorObj) {
|
189
|
-
// 等待editor初始化
|
190
|
-
if (typeof newEditorObj.init === 'function') {
|
191
|
-
await new Promise((resolve) => {
|
192
|
-
const checkInterval = setInterval(() => {
|
193
|
-
if (newEditorObj.isReady) {
|
194
|
-
clearInterval(checkInterval)
|
195
|
-
resolve()
|
196
|
-
}
|
197
|
-
}, 100)
|
198
|
-
// 最多等待5秒
|
199
|
-
setTimeout(() => {
|
200
|
-
clearInterval(checkInterval)
|
201
|
-
resolve()
|
202
|
-
}, 5000)
|
203
|
-
})
|
204
|
-
}
|
205
|
-
// 更新全局editor引用
|
206
|
-
editor = newEditorObj
|
207
|
-
window.iframeEditor = newEditorObj
|
208
|
-
} else {
|
209
|
-
throw new Error('重新加载后无法获取editor对象')
|
210
|
-
}
|
211
|
-
} catch (err) {
|
212
|
-
console.error('重新加载iframe后清空体温单出错:', err)
|
213
|
-
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
214
|
-
} finally {
|
215
|
-
loading.value = false
|
216
|
-
generating.value = false
|
217
|
-
// 移除临时onload处理器
|
218
|
-
iframe.onload = null
|
219
|
-
}
|
220
|
-
}
|
221
|
-
// 重新加载iframe
|
222
|
-
iframe.src = currentSrc + '?t=' + new Date().getTime()
|
223
|
-
return
|
224
|
-
}
|
225
|
-
} catch (reloadErr) {
|
226
|
-
console.warn('重新加载iframe失败,将尝试其他方法清空体温单:', reloadErr)
|
227
|
-
}
|
228
|
-
// 备用清空方法
|
229
|
-
try {
|
230
|
-
const iframe = editorComponent.value.$refs.editorIframe
|
231
|
-
if (iframe?.contentWindow) {
|
232
|
-
iframe.contentWindow.eval(`
|
233
|
-
try {
|
234
|
-
// 尝试使用编辑器提供的各种可能的清空方法
|
235
|
-
if (editor) {
|
236
|
-
if (typeof editor.loadUrl === 'function') {
|
237
|
-
editor.loadUrl('');
|
238
|
-
} else if (typeof editor.resetDocument === 'function') {
|
239
|
-
editor.resetDocument();
|
240
|
-
} else if (typeof editor.clearContent === 'function') {
|
241
|
-
editor.clearContent();
|
242
|
-
} else if (typeof editor.clear === 'function') {
|
243
|
-
editor.clear();
|
244
|
-
} else if (typeof editor.setEditorContent === 'function') {
|
245
|
-
editor.setEditorContent('');
|
246
|
-
} else if (editor.document) {
|
247
|
-
try {
|
248
|
-
editor.document.body.innerHTML = '';
|
249
|
-
} catch(clearErr) {
|
250
|
-
console.warn('清空编辑器内容失败');
|
251
|
-
}
|
252
|
-
}
|
253
|
-
}
|
254
|
-
} catch(e) {
|
255
|
-
console.error('清空体温单失败:', e);
|
256
|
-
}
|
257
|
-
`)
|
258
|
-
} else if (window.iframeEditor) {
|
259
|
-
const editorObj = window.iframeEditor
|
260
|
-
if (typeof editorObj.loadUrl === 'function') {
|
261
|
-
editorObj.loadUrl('')
|
262
|
-
} else if (typeof editorObj.resetDocument === 'function') {
|
263
|
-
editorObj.resetDocument()
|
264
|
-
} else if (typeof editorObj.clearContent === 'function') {
|
265
|
-
editorObj.clearContent()
|
266
|
-
} else if (typeof editorObj.clear === 'function') {
|
267
|
-
editorObj.clear()
|
268
|
-
} else if (typeof editorObj.setEditorContent === 'function') {
|
269
|
-
editorObj.setEditorContent('')
|
270
|
-
}
|
271
|
-
} else if (editor) {
|
272
|
-
if (typeof editor.loadUrl === 'function') {
|
273
|
-
editor.loadUrl('')
|
274
|
-
} else if (typeof editor.resetDocument === 'function') {
|
275
|
-
editor.resetDocument()
|
276
|
-
} else if (typeof editor.clearContent === 'function') {
|
277
|
-
editor.clearContent()
|
278
|
-
} else if (typeof editor.clear === 'function') {
|
279
|
-
editor.clear()
|
280
|
-
} else if (typeof editor.setEditorContent === 'function') {
|
281
|
-
editor.setEditorContent('')
|
282
|
-
}
|
283
|
-
} else {
|
284
|
-
throw new Error('无法获取编辑器对象')
|
285
|
-
}
|
286
|
-
} catch (err) {
|
287
|
-
console.error('清空体温单出错:', err)
|
288
|
-
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
289
|
-
}
|
290
|
-
} finally {
|
291
|
-
loading.value = false
|
292
|
-
generating.value = false
|
293
|
-
}
|
294
|
-
}
|
295
|
-
|
296
|
-
// 处理表单提交
|
297
|
-
async function handleSubmit (formData) {
|
298
|
-
console.log('表单数据:', formData)
|
299
|
-
if (!editorReady.value || !editor) {
|
300
|
-
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
301
|
-
return
|
302
|
-
}
|
303
|
-
loading.value = true
|
304
|
-
generating.value = true // 开始生成,显示加载遮罩
|
305
|
-
try {
|
306
|
-
let result
|
307
|
-
try {
|
308
|
-
const iframe = editorComponent.value.$refs.editorIframe
|
309
|
-
if (iframe?.contentWindow) {
|
310
|
-
// 直接传递数据对象,避免使用eval
|
311
|
-
if (iframe.contentWindow.editor && typeof iframe.contentWindow.editor.createVitalSigns === 'function') {
|
312
|
-
result = iframe.contentWindow.editor.createVitalSigns(formData)
|
313
|
-
} else {
|
314
|
-
throw new Error('编辑器对象无效')
|
315
|
-
}
|
316
|
-
} else if (window.iframeEditor) {
|
317
|
-
result = window.iframeEditor.createVitalSigns(formData)
|
318
|
-
} else {
|
319
|
-
throw new Error('无法访问iframe')
|
320
|
-
}
|
321
|
-
} catch (err) {
|
322
|
-
// 备用方案
|
323
|
-
if (editor && typeof editor.createVitalSigns === 'function') {
|
324
|
-
editor.createVitalSigns(formData)
|
325
|
-
} else {
|
326
|
-
throw new Error('无法调用createVitalSigns方法')
|
327
|
-
}
|
328
|
-
}
|
329
|
-
|
330
|
-
vitalSignsId.value = result || formData.id
|
331
|
-
modalVisible.value = false
|
332
|
-
message.success(`${modalTitles[modalType.value]}成功`)
|
333
|
-
emit('submit', formData)
|
334
|
-
} catch (err) {
|
335
|
-
console.error('创建体温单出错:', err)
|
336
|
-
message.error(`创建体温单失败: ${err.message || '未知错误'}`)
|
337
|
-
} finally {
|
338
|
-
loading.value = false
|
339
|
-
generating.value = false // 无论成功失败,都结束加载遮罩
|
340
|
-
}
|
341
|
-
}
|
342
|
-
|
343
|
-
// 处理表单数据
|
344
|
-
function mergeAndTransformData (records, patientInfo, id, date, operateDate) {
|
345
|
-
// 提取records中的数据
|
346
|
-
const temperatureList = records.map(record => record.temperature).join(',')
|
347
|
-
const sphygmusList = records.map(record => record.sphygmus).join(',')
|
348
|
-
const breathList = records.map(record => record.breath).join(',')
|
349
|
-
const heartList = records.map(record => record.heart).join(',')
|
350
|
-
const notesList = records.map(record => record.notes).join(',')
|
351
|
-
const painList = records.map(record => record.pain).join(',')
|
352
|
-
const data1List = records.map(record => {
|
353
|
-
const [systolic, diastolic] = record.data1.split('|')
|
354
|
-
return `${systolic}/${diastolic}`
|
355
|
-
}).join(',')
|
356
|
-
const data2List = records.map(record => record.data2).join(',')
|
357
|
-
const data3List = records.map(record => record.data3).join(',')
|
358
|
-
const data4List = records.map(record => record.data4).join(',')
|
359
|
-
const data5List = records.map(record => record.data5).join(',')
|
360
|
-
const data6List = records.map(record => record.data6).join(',')
|
361
|
-
const data7List = records.map(record => record.data7).join(',')
|
362
|
-
const tempTypeList = records.map(record => record.temptype).join(',')
|
363
|
-
|
364
|
-
// 提取patientInfo中的数据
|
365
|
-
const name = patientInfo.name || ''
|
366
|
-
const dept = patientInfo.dept || ''
|
367
|
-
const bed = patientInfo.bed || ''
|
368
|
-
const inDate = patientInfo.indate || ''
|
369
|
-
const diag = patientInfo.diag || ''
|
370
|
-
|
371
|
-
// 生成合并后的对象
|
372
|
-
const mergedData = {
|
373
|
-
bed: bed.toString(),
|
374
|
-
sphygmus: sphygmusList,
|
375
|
-
notes: notesList,
|
376
|
-
medicalNo: id, // 示例中的固定值
|
377
|
-
diag: diag,
|
378
|
-
type: 'normal', // 示例中的固定值
|
379
|
-
breath: breathList,
|
380
|
-
temperature: temperatureList,
|
381
|
-
id: id, // 示例中的固定值
|
382
|
-
tempType: tempTypeList,
|
383
|
-
data7: data7List,
|
384
|
-
pain: painList,
|
385
|
-
data6: data6List,
|
386
|
-
data5: data5List,
|
387
|
-
data4: data4List,
|
388
|
-
data3: data3List,
|
389
|
-
data2: data2List,
|
390
|
-
inDate: inDate.split(' ')[0], // 只取日期部分
|
391
|
-
data1: data1List,
|
392
|
-
dept: dept,
|
393
|
-
heart: heartList,
|
394
|
-
labels: '血压(mmHg)|入水量(ml)|出水量(ml)|大便(次)|小便(次)|身高(cm)|体重(kg)', // 示例中的固定值
|
395
|
-
name: name,
|
396
|
-
begin: date, // 只取日期部分
|
397
|
-
operateDate: operateDate // 只取日期部分
|
398
|
-
}
|
399
|
-
return mergedData
|
400
|
-
}
|
401
|
-
// 设置病历号的方法
|
402
|
-
function setMedicalRecordId (id) {
|
403
|
-
vitalSignsId.value = id
|
404
|
-
// console.log('病历号已设置为:', vitalSignsId.value)
|
405
|
-
}
|
406
|
-
// 生命周期钩子
|
407
|
-
onMounted(() => {
|
408
|
-
window.addEventListener('message', (event) => {
|
409
|
-
if (event.data?.type === 'editorReady' && !editorReady.value && editorComponent.value?.getEditor) {
|
410
|
-
try {
|
411
|
-
const editorFromComponent = editorComponent.value.getEditor()
|
412
|
-
if (editorFromComponent && typeof editorFromComponent.createVitalSigns === 'function') {
|
413
|
-
editor = editorFromComponent
|
414
|
-
editorReady.value = true
|
415
|
-
}
|
416
|
-
} catch (err) {
|
417
|
-
console.error('从组件获取editor对象错误:', err)
|
418
|
-
}
|
419
|
-
}
|
420
|
-
})
|
421
|
-
})
|
422
|
-
|
423
|
-
// 暴露方法和属性给父组件,使父组件可以通过ref访问
|
424
|
-
defineExpose({
|
425
|
-
// 属性
|
426
|
-
vitalSignsId,
|
427
|
-
// 清空体温单方法
|
428
|
-
clearVitalSigns,
|
429
|
-
// 展示更新和创建弹框 创建参数:(String) create, 更新参数:(String) update
|
430
|
-
showVitalSignsModal,
|
431
|
-
// 触发打印函数 参数:(String) print
|
432
|
-
execCommand,
|
433
|
-
// 获取当前体温单ID的方法
|
434
|
-
getVitalSignsId: () => vitalSignsId.value,
|
435
|
-
// 设置体温单ID的方法
|
436
|
-
setVitalSignsId: (id) => {
|
437
|
-
vitalSignsId.value = id
|
438
|
-
},
|
439
|
-
// 创建体温单 参数:(Object) data
|
440
|
-
handleSubmit,
|
441
|
-
// 设置病历号
|
442
|
-
setMedicalRecordId,
|
443
|
-
// 获取表单数据
|
444
|
-
mergeAndTransformData
|
445
|
-
})
|
446
|
-
</script>
|
447
|
-
|
448
|
-
<style scoped>
|
449
|
-
.box {
|
450
|
-
display: flex;
|
451
|
-
align-items: center;
|
452
|
-
padding: 1%;
|
453
|
-
}
|
454
|
-
|
455
|
-
/* 体温单生成加载遮罩样式 */
|
456
|
-
.generating-mask {
|
457
|
-
position: fixed;
|
458
|
-
top: 0;
|
459
|
-
left: 0;
|
460
|
-
right: 0;
|
461
|
-
bottom: 0;
|
462
|
-
background-color: rgba(0, 0, 0, 0.5);
|
463
|
-
display: flex;
|
464
|
-
justify-content: center;
|
465
|
-
align-items: center;
|
466
|
-
z-index: 9999;
|
467
|
-
}
|
468
|
-
|
469
|
-
.generating-content {
|
470
|
-
background-color: white;
|
471
|
-
padding: 20px 40px;
|
472
|
-
border-radius: 4px;
|
473
|
-
text-align: center;
|
474
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
475
|
-
}
|
476
|
-
|
477
|
-
.generating-text {
|
478
|
-
margin-top: 16px;
|
479
|
-
color: rgba(0, 0, 0, 0.85);
|
480
|
-
font-size: 16px;
|
481
|
-
}
|
482
|
-
</style>
|
1
|
+
<template>
|
2
|
+
<!-- <Source src="/code/VitalSigns.vue"></Source>-->
|
3
|
+
<div>
|
4
|
+
<a-row class="box">
|
5
|
+
<!-- 病历号输入框已隐藏,通过setMedicalRecordId方法设置vitalSignsId -->
|
6
|
+
<!-- 病历号 <a-input v-model="vitalSignsId" style="width: 160px"></a-input> -->
|
7
|
+
<a-button-group style="margin-left: 20px;">
|
8
|
+
<a-button
|
9
|
+
v-if="showCreateButton"
|
10
|
+
plain
|
11
|
+
type="primary"
|
12
|
+
@click="showVitalSignsModal('create')"
|
13
|
+
:loading="loading"
|
14
|
+
:disabled="!editorReady">创建体温单</a-button>
|
15
|
+
<a-button
|
16
|
+
v-if="showUpdateButton"
|
17
|
+
plain
|
18
|
+
type="primary"
|
19
|
+
@click="showVitalSignsModal('update')"
|
20
|
+
:loading="loading"
|
21
|
+
:disabled="!editorReady">更新体温单</a-button>
|
22
|
+
</a-button-group>
|
23
|
+
<a-button-group v-if="showClearButton" style="margin: 0 20px;">
|
24
|
+
<a-button plain type="primary" @click="execCommand('print')" :loading="loading" :disabled="!editorReady">打印</a-button>
|
25
|
+
</a-button-group>
|
26
|
+
<!-- 修改清空体温单按钮样式,使其更加醒目 -->
|
27
|
+
<a-button
|
28
|
+
type="primary"
|
29
|
+
danger
|
30
|
+
v-if="showClearButton"
|
31
|
+
@click="clearVitalSigns"
|
32
|
+
:loading="loading"
|
33
|
+
:disabled="!editorReady"
|
34
|
+
style="margin-left: 10px;">
|
35
|
+
<a-icon type="delete" /> 清空体温单
|
36
|
+
</a-button>
|
37
|
+
</a-row>
|
38
|
+
<div v-if="!editorReady" style="margin: 10px 0; padding: 10px; background-color: #fffbe6; border: 1px solid #ffe58f;">
|
39
|
+
<a-icon type="loading" /> 体温单编辑器加载中...
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<!-- 添加体温单生成加载遮罩 -->
|
43
|
+
<div v-if="generating" class="generating-mask">
|
44
|
+
<div class="generating-content">
|
45
|
+
<a-spin size="large" />
|
46
|
+
<div class="generating-text">体温单生成中,请稍候...</div>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<Editor @editor-ready="onEditorReady" style="margin: 10px 0;" ref="editorComponent"></Editor>
|
51
|
+
|
52
|
+
<!-- 使用TextBox组件替代原有弹窗 -->
|
53
|
+
<TextBox
|
54
|
+
:visible="modalVisible"
|
55
|
+
:modalType="modalType"
|
56
|
+
:editorReady="editorReady"
|
57
|
+
:id="Number(vitalSignsId) || 180"
|
58
|
+
@submit="handleSubmit"
|
59
|
+
@cancel="closeModal"
|
60
|
+
/>
|
61
|
+
</div>
|
62
|
+
</template>
|
63
|
+
|
64
|
+
<script setup>
|
65
|
+
import { ref, onMounted } from 'vue'
|
66
|
+
import Editor from './editor.vue'
|
67
|
+
import TextBox from './textBox.vue'
|
68
|
+
import { message } from 'ant-design-vue'
|
69
|
+
|
70
|
+
// 响应式状态
|
71
|
+
const vitalSignsId = ref(null)
|
72
|
+
const loading = ref(false)
|
73
|
+
const editorReady = ref(false)
|
74
|
+
const editorComponent = ref(null)
|
75
|
+
const modalVisible = ref(false)
|
76
|
+
const modalType = ref('create')
|
77
|
+
const generating = ref(false) // 添加体温单生成中状态
|
78
|
+
let editor = null
|
79
|
+
// 定义组件事件
|
80
|
+
const emit = defineEmits(['submit'])
|
81
|
+
// 常量
|
82
|
+
const modalTitles = {
|
83
|
+
create: '创建体温单',
|
84
|
+
update: '更新体温单'
|
85
|
+
}
|
86
|
+
|
87
|
+
// 接受父组件传递的属性
|
88
|
+
defineProps({
|
89
|
+
showCreateButton: {
|
90
|
+
type: Boolean,
|
91
|
+
default: false
|
92
|
+
},
|
93
|
+
showUpdateButton: {
|
94
|
+
type: Boolean,
|
95
|
+
default: false
|
96
|
+
},
|
97
|
+
// 添加打印按钮是否显示属性
|
98
|
+
showPrintButton: {
|
99
|
+
type: Boolean,
|
100
|
+
default: false
|
101
|
+
},
|
102
|
+
showClearButton: {
|
103
|
+
type: Boolean,
|
104
|
+
default: false
|
105
|
+
},
|
106
|
+
// 时间模式 -2 ~ 2
|
107
|
+
adjustHour: {
|
108
|
+
type: Number,
|
109
|
+
default: 0
|
110
|
+
}
|
111
|
+
})
|
112
|
+
|
113
|
+
// 显示弹窗
|
114
|
+
function showVitalSignsModal (type) {
|
115
|
+
modalType.value = type
|
116
|
+
modalVisible.value = true
|
117
|
+
}
|
118
|
+
|
119
|
+
// 关闭弹窗
|
120
|
+
function closeModal () {
|
121
|
+
modalVisible.value = false
|
122
|
+
}
|
123
|
+
|
124
|
+
// 编辑器初始化
|
125
|
+
function onEditorReady (editorObj) {
|
126
|
+
try {
|
127
|
+
if (!editorObj) {
|
128
|
+
throw new Error('传入的editor对象为null或undefined')
|
129
|
+
}
|
130
|
+
|
131
|
+
// 尝试获取编辑器对象
|
132
|
+
if (typeof editorObj.createVitalSigns === 'function') {
|
133
|
+
editor = editorObj
|
134
|
+
} else if (editorObj.getEditor && typeof editorObj.getEditor === 'function') {
|
135
|
+
const editorFromComponent = editorObj.getEditor()
|
136
|
+
editor = editorFromComponent && typeof editorFromComponent.createVitalSigns === 'function'
|
137
|
+
? editorFromComponent
|
138
|
+
: (typeof editorObj.createVitalSigns === 'function' ? editorObj : null)
|
139
|
+
}
|
140
|
+
if (!editor) {
|
141
|
+
throw new Error('无法获取有效的editor对象')
|
142
|
+
}
|
143
|
+
editorReady.value = true
|
144
|
+
} catch (err) {
|
145
|
+
console.error('设置editor对象失败:', err)
|
146
|
+
message.error('体温单编辑器初始化失败,请刷新页面重试')
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
// 执行命令
|
151
|
+
function execCommand (cmd) {
|
152
|
+
if (!editorReady.value || !editor) return
|
153
|
+
loading.value = true
|
154
|
+
try {
|
155
|
+
editor.execCommand(cmd)
|
156
|
+
} catch (err) {
|
157
|
+
console.error('执行命令出错:', err)
|
158
|
+
message.error(`执行${cmd}命令失败`)
|
159
|
+
} finally {
|
160
|
+
loading.value = false
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
// 清空体温单
|
165
|
+
async function clearVitalSigns () {
|
166
|
+
if (!editorReady.value || !editor) {
|
167
|
+
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
168
|
+
return
|
169
|
+
}
|
170
|
+
loading.value = true
|
171
|
+
generating.value = true
|
172
|
+
try {
|
173
|
+
// 重新加载editor.html页面来完全重置编辑器
|
174
|
+
try {
|
175
|
+
const iframe = editorComponent.value.$refs.editorIframe
|
176
|
+
if (iframe) {
|
177
|
+
// 保存当前src
|
178
|
+
const currentSrc = iframe.src
|
179
|
+
// 确认提示
|
180
|
+
message.loading('正在清空体温单...', 1)
|
181
|
+
// 重新加载iframe
|
182
|
+
iframe.onload = async () => {
|
183
|
+
try {
|
184
|
+
// 等待iframe重新加载完成
|
185
|
+
await new Promise(resolve => setTimeout(resolve, 500))
|
186
|
+
// 获取新的editor对象
|
187
|
+
const newEditorObj = iframe.contentWindow.editor
|
188
|
+
if (newEditorObj) {
|
189
|
+
// 等待editor初始化
|
190
|
+
if (typeof newEditorObj.init === 'function') {
|
191
|
+
await new Promise((resolve) => {
|
192
|
+
const checkInterval = setInterval(() => {
|
193
|
+
if (newEditorObj.isReady) {
|
194
|
+
clearInterval(checkInterval)
|
195
|
+
resolve()
|
196
|
+
}
|
197
|
+
}, 100)
|
198
|
+
// 最多等待5秒
|
199
|
+
setTimeout(() => {
|
200
|
+
clearInterval(checkInterval)
|
201
|
+
resolve()
|
202
|
+
}, 5000)
|
203
|
+
})
|
204
|
+
}
|
205
|
+
// 更新全局editor引用
|
206
|
+
editor = newEditorObj
|
207
|
+
window.iframeEditor = newEditorObj
|
208
|
+
} else {
|
209
|
+
throw new Error('重新加载后无法获取editor对象')
|
210
|
+
}
|
211
|
+
} catch (err) {
|
212
|
+
console.error('重新加载iframe后清空体温单出错:', err)
|
213
|
+
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
214
|
+
} finally {
|
215
|
+
loading.value = false
|
216
|
+
generating.value = false
|
217
|
+
// 移除临时onload处理器
|
218
|
+
iframe.onload = null
|
219
|
+
}
|
220
|
+
}
|
221
|
+
// 重新加载iframe
|
222
|
+
iframe.src = currentSrc + '?t=' + new Date().getTime()
|
223
|
+
return
|
224
|
+
}
|
225
|
+
} catch (reloadErr) {
|
226
|
+
console.warn('重新加载iframe失败,将尝试其他方法清空体温单:', reloadErr)
|
227
|
+
}
|
228
|
+
// 备用清空方法
|
229
|
+
try {
|
230
|
+
const iframe = editorComponent.value.$refs.editorIframe
|
231
|
+
if (iframe?.contentWindow) {
|
232
|
+
iframe.contentWindow.eval(`
|
233
|
+
try {
|
234
|
+
// 尝试使用编辑器提供的各种可能的清空方法
|
235
|
+
if (editor) {
|
236
|
+
if (typeof editor.loadUrl === 'function') {
|
237
|
+
editor.loadUrl('');
|
238
|
+
} else if (typeof editor.resetDocument === 'function') {
|
239
|
+
editor.resetDocument();
|
240
|
+
} else if (typeof editor.clearContent === 'function') {
|
241
|
+
editor.clearContent();
|
242
|
+
} else if (typeof editor.clear === 'function') {
|
243
|
+
editor.clear();
|
244
|
+
} else if (typeof editor.setEditorContent === 'function') {
|
245
|
+
editor.setEditorContent('');
|
246
|
+
} else if (editor.document) {
|
247
|
+
try {
|
248
|
+
editor.document.body.innerHTML = '';
|
249
|
+
} catch(clearErr) {
|
250
|
+
console.warn('清空编辑器内容失败');
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
} catch(e) {
|
255
|
+
console.error('清空体温单失败:', e);
|
256
|
+
}
|
257
|
+
`)
|
258
|
+
} else if (window.iframeEditor) {
|
259
|
+
const editorObj = window.iframeEditor
|
260
|
+
if (typeof editorObj.loadUrl === 'function') {
|
261
|
+
editorObj.loadUrl('')
|
262
|
+
} else if (typeof editorObj.resetDocument === 'function') {
|
263
|
+
editorObj.resetDocument()
|
264
|
+
} else if (typeof editorObj.clearContent === 'function') {
|
265
|
+
editorObj.clearContent()
|
266
|
+
} else if (typeof editorObj.clear === 'function') {
|
267
|
+
editorObj.clear()
|
268
|
+
} else if (typeof editorObj.setEditorContent === 'function') {
|
269
|
+
editorObj.setEditorContent('')
|
270
|
+
}
|
271
|
+
} else if (editor) {
|
272
|
+
if (typeof editor.loadUrl === 'function') {
|
273
|
+
editor.loadUrl('')
|
274
|
+
} else if (typeof editor.resetDocument === 'function') {
|
275
|
+
editor.resetDocument()
|
276
|
+
} else if (typeof editor.clearContent === 'function') {
|
277
|
+
editor.clearContent()
|
278
|
+
} else if (typeof editor.clear === 'function') {
|
279
|
+
editor.clear()
|
280
|
+
} else if (typeof editor.setEditorContent === 'function') {
|
281
|
+
editor.setEditorContent('')
|
282
|
+
}
|
283
|
+
} else {
|
284
|
+
throw new Error('无法获取编辑器对象')
|
285
|
+
}
|
286
|
+
} catch (err) {
|
287
|
+
console.error('清空体温单出错:', err)
|
288
|
+
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
289
|
+
}
|
290
|
+
} finally {
|
291
|
+
loading.value = false
|
292
|
+
generating.value = false
|
293
|
+
}
|
294
|
+
}
|
295
|
+
|
296
|
+
// 处理表单提交
|
297
|
+
async function handleSubmit (formData) {
|
298
|
+
console.log('表单数据:', formData)
|
299
|
+
if (!editorReady.value || !editor) {
|
300
|
+
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
301
|
+
return
|
302
|
+
}
|
303
|
+
loading.value = true
|
304
|
+
generating.value = true // 开始生成,显示加载遮罩
|
305
|
+
try {
|
306
|
+
let result
|
307
|
+
try {
|
308
|
+
const iframe = editorComponent.value.$refs.editorIframe
|
309
|
+
if (iframe?.contentWindow) {
|
310
|
+
// 直接传递数据对象,避免使用eval
|
311
|
+
if (iframe.contentWindow.editor && typeof iframe.contentWindow.editor.createVitalSigns === 'function') {
|
312
|
+
result = iframe.contentWindow.editor.createVitalSigns(formData)
|
313
|
+
} else {
|
314
|
+
throw new Error('编辑器对象无效')
|
315
|
+
}
|
316
|
+
} else if (window.iframeEditor) {
|
317
|
+
result = window.iframeEditor.createVitalSigns(formData)
|
318
|
+
} else {
|
319
|
+
throw new Error('无法访问iframe')
|
320
|
+
}
|
321
|
+
} catch (err) {
|
322
|
+
// 备用方案
|
323
|
+
if (editor && typeof editor.createVitalSigns === 'function') {
|
324
|
+
editor.createVitalSigns(formData)
|
325
|
+
} else {
|
326
|
+
throw new Error('无法调用createVitalSigns方法')
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
vitalSignsId.value = result || formData.id
|
331
|
+
modalVisible.value = false
|
332
|
+
message.success(`${modalTitles[modalType.value]}成功`)
|
333
|
+
emit('submit', formData)
|
334
|
+
} catch (err) {
|
335
|
+
console.error('创建体温单出错:', err)
|
336
|
+
message.error(`创建体温单失败: ${err.message || '未知错误'}`)
|
337
|
+
} finally {
|
338
|
+
loading.value = false
|
339
|
+
generating.value = false // 无论成功失败,都结束加载遮罩
|
340
|
+
}
|
341
|
+
}
|
342
|
+
|
343
|
+
// 处理表单数据
|
344
|
+
function mergeAndTransformData (records, patientInfo, id, date, operateDate) {
|
345
|
+
// 提取records中的数据
|
346
|
+
const temperatureList = records.map(record => record.temperature).join(',')
|
347
|
+
const sphygmusList = records.map(record => record.sphygmus).join(',')
|
348
|
+
const breathList = records.map(record => record.breath).join(',')
|
349
|
+
const heartList = records.map(record => record.heart).join(',')
|
350
|
+
const notesList = records.map(record => record.notes).join(',')
|
351
|
+
const painList = records.map(record => record.pain).join(',')
|
352
|
+
const data1List = records.map(record => {
|
353
|
+
const [systolic, diastolic] = record.data1.split('|')
|
354
|
+
return `${systolic}/${diastolic}`
|
355
|
+
}).join(',')
|
356
|
+
const data2List = records.map(record => record.data2).join(',')
|
357
|
+
const data3List = records.map(record => record.data3).join(',')
|
358
|
+
const data4List = records.map(record => record.data4).join(',')
|
359
|
+
const data5List = records.map(record => record.data5).join(',')
|
360
|
+
const data6List = records.map(record => record.data6).join(',')
|
361
|
+
const data7List = records.map(record => record.data7).join(',')
|
362
|
+
const tempTypeList = records.map(record => record.temptype).join(',')
|
363
|
+
|
364
|
+
// 提取patientInfo中的数据
|
365
|
+
const name = patientInfo.name || ''
|
366
|
+
const dept = patientInfo.dept || ''
|
367
|
+
const bed = patientInfo.bed || ''
|
368
|
+
const inDate = patientInfo.indate || ''
|
369
|
+
const diag = patientInfo.diag || ''
|
370
|
+
|
371
|
+
// 生成合并后的对象
|
372
|
+
const mergedData = {
|
373
|
+
bed: bed.toString(),
|
374
|
+
sphygmus: sphygmusList,
|
375
|
+
notes: notesList,
|
376
|
+
medicalNo: id, // 示例中的固定值
|
377
|
+
diag: diag,
|
378
|
+
type: 'normal', // 示例中的固定值
|
379
|
+
breath: breathList,
|
380
|
+
temperature: temperatureList,
|
381
|
+
id: id, // 示例中的固定值
|
382
|
+
tempType: tempTypeList,
|
383
|
+
data7: data7List,
|
384
|
+
pain: painList,
|
385
|
+
data6: data6List,
|
386
|
+
data5: data5List,
|
387
|
+
data4: data4List,
|
388
|
+
data3: data3List,
|
389
|
+
data2: data2List,
|
390
|
+
inDate: inDate.split(' ')[0], // 只取日期部分
|
391
|
+
data1: data1List,
|
392
|
+
dept: dept,
|
393
|
+
heart: heartList,
|
394
|
+
labels: '血压(mmHg)|入水量(ml)|出水量(ml)|大便(次)|小便(次)|身高(cm)|体重(kg)', // 示例中的固定值
|
395
|
+
name: name,
|
396
|
+
begin: date, // 只取日期部分
|
397
|
+
operateDate: operateDate // 只取日期部分
|
398
|
+
}
|
399
|
+
return mergedData
|
400
|
+
}
|
401
|
+
// 设置病历号的方法
|
402
|
+
function setMedicalRecordId (id) {
|
403
|
+
vitalSignsId.value = id
|
404
|
+
// console.log('病历号已设置为:', vitalSignsId.value)
|
405
|
+
}
|
406
|
+
// 生命周期钩子
|
407
|
+
onMounted(() => {
|
408
|
+
window.addEventListener('message', (event) => {
|
409
|
+
if (event.data?.type === 'editorReady' && !editorReady.value && editorComponent.value?.getEditor) {
|
410
|
+
try {
|
411
|
+
const editorFromComponent = editorComponent.value.getEditor()
|
412
|
+
if (editorFromComponent && typeof editorFromComponent.createVitalSigns === 'function') {
|
413
|
+
editor = editorFromComponent
|
414
|
+
editorReady.value = true
|
415
|
+
}
|
416
|
+
} catch (err) {
|
417
|
+
console.error('从组件获取editor对象错误:', err)
|
418
|
+
}
|
419
|
+
}
|
420
|
+
})
|
421
|
+
})
|
422
|
+
|
423
|
+
// 暴露方法和属性给父组件,使父组件可以通过ref访问
|
424
|
+
defineExpose({
|
425
|
+
// 属性
|
426
|
+
vitalSignsId,
|
427
|
+
// 清空体温单方法
|
428
|
+
clearVitalSigns,
|
429
|
+
// 展示更新和创建弹框 创建参数:(String) create, 更新参数:(String) update
|
430
|
+
showVitalSignsModal,
|
431
|
+
// 触发打印函数 参数:(String) print
|
432
|
+
execCommand,
|
433
|
+
// 获取当前体温单ID的方法
|
434
|
+
getVitalSignsId: () => vitalSignsId.value,
|
435
|
+
// 设置体温单ID的方法
|
436
|
+
setVitalSignsId: (id) => {
|
437
|
+
vitalSignsId.value = id
|
438
|
+
},
|
439
|
+
// 创建体温单 参数:(Object) data
|
440
|
+
handleSubmit,
|
441
|
+
// 设置病历号
|
442
|
+
setMedicalRecordId,
|
443
|
+
// 获取表单数据
|
444
|
+
mergeAndTransformData
|
445
|
+
})
|
446
|
+
</script>
|
447
|
+
|
448
|
+
<style scoped>
|
449
|
+
.box {
|
450
|
+
display: flex;
|
451
|
+
align-items: center;
|
452
|
+
padding: 1%;
|
453
|
+
}
|
454
|
+
|
455
|
+
/* 体温单生成加载遮罩样式 */
|
456
|
+
.generating-mask {
|
457
|
+
position: fixed;
|
458
|
+
top: 0;
|
459
|
+
left: 0;
|
460
|
+
right: 0;
|
461
|
+
bottom: 0;
|
462
|
+
background-color: rgba(0, 0, 0, 0.5);
|
463
|
+
display: flex;
|
464
|
+
justify-content: center;
|
465
|
+
align-items: center;
|
466
|
+
z-index: 9999;
|
467
|
+
}
|
468
|
+
|
469
|
+
.generating-content {
|
470
|
+
background-color: white;
|
471
|
+
padding: 20px 40px;
|
472
|
+
border-radius: 4px;
|
473
|
+
text-align: center;
|
474
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
475
|
+
}
|
476
|
+
|
477
|
+
.generating-text {
|
478
|
+
margin-top: 16px;
|
479
|
+
color: rgba(0, 0, 0, 0.85);
|
480
|
+
font-size: 16px;
|
481
|
+
}
|
482
|
+
</style>
|