vue2-client 1.14.39 → 1.14.41
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/Users/objecrt/af-vue2-client/src/base-client/components/his/XShiftSchedule/XShiftSchedule.vue +36 -0
- package/package.json +1 -1
- package/src/base-client/components/TreeList/TreeList.vue +91 -0
- package/src/base-client/components/TreeList/TreeNode.vue +81 -0
- package/src/base-client/components/common/AmapMarker/index.js +3 -3
- package/src/base-client/components/common/XCardSet/XTiltle.vue +191 -0
- package/src/base-client/components/common/XDetailsView/index.js +3 -3
- package/src/base-client/components/common/XFormGroupDetails/index.js +3 -3
- package/src/base-client/components/common/XFormTable/XFormTable.vue +1 -0
- package/src/base-client/components/common/XTable/ExportExcel.vue +6 -0
- package/src/base-client/components/common/XTable/XTable.vue +12 -0
- package/src/base-client/components/common/XTable/XTableWrapper.vue +2 -0
- package/src/base-client/components/his/XTextCard/XTextCard.vue +207 -207
- package/src/base-client/components/his/XTreeRows/TreeNode.vue +100 -100
- package/src/base-client/components/his/XTreeRows/XTreeRows.vue +197 -197
- package/src/base-client/components/his/threeTestOrders/editor.vue +111 -111
- package/src/base-client/components/his/threeTestOrders/threeTestOrders.vue +386 -386
- package/src/components/STable/index.js +42 -5
- package/src/pages/WorkflowDetail/WorkFlowDemo.vue +1 -1
|
@@ -1,386 +1,386 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- <Source src="/code/VitalSigns.vue"></Source>-->
|
|
3
|
-
<div>
|
|
4
|
-
<a-row class="box">
|
|
5
|
-
病历号 <a-input v-model="vitalSignsId" style="width: 160px"></a-input>
|
|
6
|
-
<a-button-group style="margin-left: 20px;">
|
|
7
|
-
<a-button plain type="primary" @click="showVitalSignsModal('create')" :loading="loading" :disabled="!editorReady">创建体温单</a-button>
|
|
8
|
-
<a-button plain type="primary" @click="showVitalSignsModal('update')" :loading="loading" :disabled="!editorReady">更新体温单</a-button>
|
|
9
|
-
</a-button-group>
|
|
10
|
-
<a-button-group style="margin: 0 20px;">
|
|
11
|
-
<a-button plain type="primary" @click="showVitalSignsModal('baby')" :loading="loading" :disabled="!editorReady">新生儿体温单</a-button>
|
|
12
|
-
</a-button-group>
|
|
13
|
-
<a-button-group style="margin: 0 20px;">
|
|
14
|
-
<a-button plain type="primary" @click="execCommand('preview')" :loading="loading" :disabled="!editorReady">打印预览</a-button>
|
|
15
|
-
<a-button plain type="primary" @click="execCommand('print')" :loading="loading" :disabled="!editorReady">打印</a-button>
|
|
16
|
-
</a-button-group>
|
|
17
|
-
<!-- 修改清空体温单按钮样式,使其更加醒目 -->
|
|
18
|
-
<a-button type="primary"
|
|
19
|
-
danger
|
|
20
|
-
@click="clearVitalSigns"
|
|
21
|
-
:loading="loading"
|
|
22
|
-
:disabled="!editorReady"
|
|
23
|
-
style="margin-left: 10px;">
|
|
24
|
-
<a-icon type="delete" /> 清空体温单
|
|
25
|
-
</a-button>
|
|
26
|
-
</a-row>
|
|
27
|
-
<div v-if="!editorReady" style="margin: 10px 0; padding: 10px; background-color: #fffbe6; border: 1px solid #ffe58f;">
|
|
28
|
-
<a-icon type="loading" /> 体温单编辑器加载中...
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
<!-- 添加体温单生成加载遮罩 -->
|
|
32
|
-
<div v-if="generating" class="generating-mask">
|
|
33
|
-
<div class="generating-content">
|
|
34
|
-
<a-spin size="large" />
|
|
35
|
-
<div class="generating-text">体温单生成中,请稍候...</div>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<Editor @editor-ready="onEditorReady" style="margin: 10px 0;" ref="editorComponent"></Editor>
|
|
40
|
-
|
|
41
|
-
<!-- 使用TextBox组件替代原有弹窗 -->
|
|
42
|
-
<TextBox
|
|
43
|
-
:visible="modalVisible"
|
|
44
|
-
:modalType="modalType"
|
|
45
|
-
:editorReady="editorReady"
|
|
46
|
-
:id="Number(vitalSignsId) || 180"
|
|
47
|
-
@submit="handleSubmit"
|
|
48
|
-
@cancel="closeModal"
|
|
49
|
-
/>
|
|
50
|
-
</div>
|
|
51
|
-
</template>
|
|
52
|
-
|
|
53
|
-
<script setup>
|
|
54
|
-
import { ref, onMounted } from 'vue'
|
|
55
|
-
import Editor from './editor.vue'
|
|
56
|
-
import TextBox from './textBox.vue'
|
|
57
|
-
import { message } from 'ant-design-vue'
|
|
58
|
-
|
|
59
|
-
// 响应式状态
|
|
60
|
-
const vitalSignsId = ref(null)
|
|
61
|
-
const loading = ref(false)
|
|
62
|
-
const editorReady = ref(false)
|
|
63
|
-
const editorComponent = ref(null)
|
|
64
|
-
const modalVisible = ref(false)
|
|
65
|
-
const modalType = ref('create')
|
|
66
|
-
const generating = ref(false) // 添加体温单生成中状态
|
|
67
|
-
let editor = null
|
|
68
|
-
// 定义组件事件
|
|
69
|
-
const emit = defineEmits(['submit'])
|
|
70
|
-
// 常量
|
|
71
|
-
const modalTitles = {
|
|
72
|
-
create: '创建体温单',
|
|
73
|
-
update: '更新体温单',
|
|
74
|
-
baby: '新生儿体温单'
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 显示弹窗
|
|
78
|
-
const showVitalSignsModal = (type) => {
|
|
79
|
-
modalType.value = type
|
|
80
|
-
modalVisible.value = true
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// 关闭弹窗
|
|
84
|
-
const closeModal = () => {
|
|
85
|
-
modalVisible.value = false
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// 编辑器初始化
|
|
89
|
-
const onEditorReady = (editorObj) => {
|
|
90
|
-
try {
|
|
91
|
-
if (!editorObj) {
|
|
92
|
-
throw new Error('传入的editor对象为null或undefined')
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 尝试获取编辑器对象
|
|
96
|
-
if (typeof editorObj.createVitalSigns === 'function') {
|
|
97
|
-
editor = editorObj
|
|
98
|
-
} else if (editorObj.getEditor && typeof editorObj.getEditor === 'function') {
|
|
99
|
-
const editorFromComponent = editorObj.getEditor()
|
|
100
|
-
editor = editorFromComponent && typeof editorFromComponent.createVitalSigns === 'function'
|
|
101
|
-
? editorFromComponent
|
|
102
|
-
: (typeof editorObj.createVitalSigns === 'function' ? editorObj : null)
|
|
103
|
-
}
|
|
104
|
-
if (!editor) {
|
|
105
|
-
throw new Error('无法获取有效的editor对象')
|
|
106
|
-
}
|
|
107
|
-
editorReady.value = true
|
|
108
|
-
} catch (err) {
|
|
109
|
-
console.error('设置editor对象失败:', err)
|
|
110
|
-
message.error('体温单编辑器初始化失败,请刷新页面重试')
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 执行命令
|
|
115
|
-
const execCommand = (cmd) => {
|
|
116
|
-
if (!editorReady.value || !editor) return
|
|
117
|
-
loading.value = true
|
|
118
|
-
try {
|
|
119
|
-
editor.execCommand(cmd)
|
|
120
|
-
} catch (err) {
|
|
121
|
-
console.error('执行命令出错:', err)
|
|
122
|
-
message.error(`执行${cmd}命令失败`)
|
|
123
|
-
} finally {
|
|
124
|
-
loading.value = false
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// 清空体温单
|
|
129
|
-
const clearVitalSigns = async () => {
|
|
130
|
-
if (!editorReady.value || !editor) {
|
|
131
|
-
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
loading.value = true
|
|
136
|
-
generating.value = true
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
// 重新加载editor.html页面来完全重置编辑器
|
|
140
|
-
try {
|
|
141
|
-
const iframe = editorComponent.value.$refs.editorIframe
|
|
142
|
-
if (iframe) {
|
|
143
|
-
// 保存当前src
|
|
144
|
-
const currentSrc = iframe.src
|
|
145
|
-
// 确认提示
|
|
146
|
-
message.loading('正在清空体温单...', 1)
|
|
147
|
-
// 重新加载iframe
|
|
148
|
-
iframe.onload = async () => {
|
|
149
|
-
try {
|
|
150
|
-
// 等待iframe重新加载完成
|
|
151
|
-
await new Promise(resolve => setTimeout(resolve, 500))
|
|
152
|
-
|
|
153
|
-
// 获取新的editor对象
|
|
154
|
-
const newEditorObj = iframe.contentWindow.editor
|
|
155
|
-
if (newEditorObj) {
|
|
156
|
-
// 等待editor初始化
|
|
157
|
-
if (typeof newEditorObj.init === 'function') {
|
|
158
|
-
await new Promise((resolve) => {
|
|
159
|
-
const checkInterval = setInterval(() => {
|
|
160
|
-
if (newEditorObj.isReady) {
|
|
161
|
-
clearInterval(checkInterval)
|
|
162
|
-
resolve()
|
|
163
|
-
}
|
|
164
|
-
}, 100)
|
|
165
|
-
|
|
166
|
-
// 最多等待5秒
|
|
167
|
-
setTimeout(() => {
|
|
168
|
-
clearInterval(checkInterval)
|
|
169
|
-
resolve()
|
|
170
|
-
}, 5000)
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// 更新全局editor引用
|
|
175
|
-
editor = newEditorObj
|
|
176
|
-
window.iframeEditor = newEditorObj
|
|
177
|
-
} else {
|
|
178
|
-
throw new Error('重新加载后无法获取editor对象')
|
|
179
|
-
}
|
|
180
|
-
} catch (err) {
|
|
181
|
-
console.error('重新加载iframe后清空体温单出错:', err)
|
|
182
|
-
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
|
183
|
-
} finally {
|
|
184
|
-
loading.value = false
|
|
185
|
-
generating.value = false
|
|
186
|
-
// 移除临时onload处理器
|
|
187
|
-
iframe.onload = null
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// 重新加载iframe
|
|
192
|
-
iframe.src = currentSrc + '?t=' + new Date().getTime()
|
|
193
|
-
return
|
|
194
|
-
}
|
|
195
|
-
} catch (reloadErr) {
|
|
196
|
-
console.warn('重新加载iframe失败,将尝试其他方法清空体温单:', reloadErr)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// 备用清空方法
|
|
200
|
-
try {
|
|
201
|
-
const iframe = editorComponent.value.$refs.editorIframe
|
|
202
|
-
if (iframe?.contentWindow) {
|
|
203
|
-
iframe.contentWindow.eval(`
|
|
204
|
-
try {
|
|
205
|
-
// 尝试使用编辑器提供的各种可能的清空方法
|
|
206
|
-
if (editor) {
|
|
207
|
-
if (typeof editor.loadUrl === 'function') {
|
|
208
|
-
editor.loadUrl('');
|
|
209
|
-
} else if (typeof editor.resetDocument === 'function') {
|
|
210
|
-
editor.resetDocument();
|
|
211
|
-
} else if (typeof editor.clearContent === 'function') {
|
|
212
|
-
editor.clearContent();
|
|
213
|
-
} else if (typeof editor.clear === 'function') {
|
|
214
|
-
editor.clear();
|
|
215
|
-
} else if (typeof editor.setEditorContent === 'function') {
|
|
216
|
-
editor.setEditorContent('');
|
|
217
|
-
} else if (editor.document) {
|
|
218
|
-
try {
|
|
219
|
-
editor.document.body.innerHTML = '';
|
|
220
|
-
} catch(clearErr) {
|
|
221
|
-
console.warn('清空编辑器内容失败');
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
} catch(e) {
|
|
226
|
-
console.error('清空体温单失败:', e);
|
|
227
|
-
}
|
|
228
|
-
`)
|
|
229
|
-
} else if (window.iframeEditor) {
|
|
230
|
-
const editorObj = window.iframeEditor
|
|
231
|
-
if (typeof editorObj.loadUrl === 'function') {
|
|
232
|
-
editorObj.loadUrl('')
|
|
233
|
-
} else if (typeof editorObj.resetDocument === 'function') {
|
|
234
|
-
editorObj.resetDocument()
|
|
235
|
-
} else if (typeof editorObj.clearContent === 'function') {
|
|
236
|
-
editorObj.clearContent()
|
|
237
|
-
} else if (typeof editorObj.clear === 'function') {
|
|
238
|
-
editorObj.clear()
|
|
239
|
-
} else if (typeof editorObj.setEditorContent === 'function') {
|
|
240
|
-
editorObj.setEditorContent('')
|
|
241
|
-
}
|
|
242
|
-
} else if (editor) {
|
|
243
|
-
if (typeof editor.loadUrl === 'function') {
|
|
244
|
-
editor.loadUrl('')
|
|
245
|
-
} else if (typeof editor.resetDocument === 'function') {
|
|
246
|
-
editor.resetDocument()
|
|
247
|
-
} else if (typeof editor.clearContent === 'function') {
|
|
248
|
-
editor.clearContent()
|
|
249
|
-
} else if (typeof editor.clear === 'function') {
|
|
250
|
-
editor.clear()
|
|
251
|
-
} else if (typeof editor.setEditorContent === 'function') {
|
|
252
|
-
editor.setEditorContent('')
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
throw new Error('无法获取编辑器对象')
|
|
256
|
-
}
|
|
257
|
-
} catch (err) {
|
|
258
|
-
console.error('清空体温单出错:', err)
|
|
259
|
-
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
|
260
|
-
}
|
|
261
|
-
} finally {
|
|
262
|
-
loading.value = false
|
|
263
|
-
generating.value = false
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
// 处理表单提交
|
|
267
|
-
const handleSubmit = async (formData) => {
|
|
268
|
-
if (!editorReady.value || !editor) {
|
|
269
|
-
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
|
270
|
-
return
|
|
271
|
-
}
|
|
272
|
-
loading.value = true
|
|
273
|
-
generating.value = true // 开始生成,显示加载遮罩
|
|
274
|
-
try {
|
|
275
|
-
// 简化代码,直接在现有体温单上创建新的体温单(不再清空)
|
|
276
|
-
let result
|
|
277
|
-
try {
|
|
278
|
-
const iframe = editorComponent.value.$refs.editorIframe
|
|
279
|
-
if (iframe?.contentWindow) {
|
|
280
|
-
const dataStr = JSON.stringify(formData)
|
|
281
|
-
const script = `
|
|
282
|
-
try {
|
|
283
|
-
const data = JSON.parse('${dataStr.replace(/'/g, "\\'")}');
|
|
284
|
-
return editor.createVitalSigns(data);
|
|
285
|
-
} catch(e) {
|
|
286
|
-
console.error('iframe执行错误:', e);
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
`
|
|
290
|
-
result = iframe.contentWindow.eval(script)
|
|
291
|
-
} else if (window.iframeEditor) {
|
|
292
|
-
result = window.iframeEditor.createVitalSigns(formData)
|
|
293
|
-
} else {
|
|
294
|
-
throw new Error('无法访问iframe')
|
|
295
|
-
}
|
|
296
|
-
} catch (err) {
|
|
297
|
-
// 备用方案
|
|
298
|
-
if (editor && typeof editor.createVitalSigns === 'function') {
|
|
299
|
-
result = editor.createVitalSigns(formData)
|
|
300
|
-
} else {
|
|
301
|
-
throw new Error('无法调用createVitalSigns方法')
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
vitalSignsId.value = result || formData.id
|
|
306
|
-
modalVisible.value = false
|
|
307
|
-
message.success(`${modalTitles[modalType.value]}成功`)
|
|
308
|
-
emit('submit', formData)
|
|
309
|
-
} catch (err) {
|
|
310
|
-
console.error('创建体温单出错:', err)
|
|
311
|
-
message.error(`创建体温单失败: ${err.message || '未知错误'}`)
|
|
312
|
-
} finally {
|
|
313
|
-
loading.value = false
|
|
314
|
-
generating.value = false // 无论成功失败,都结束加载遮罩
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// 生命周期钩子
|
|
319
|
-
onMounted(() => {
|
|
320
|
-
window.addEventListener('message', (event) => {
|
|
321
|
-
if (event.data?.type === 'editorReady' && !editorReady.value && editorComponent.value?.getEditor) {
|
|
322
|
-
try {
|
|
323
|
-
const editorFromComponent = editorComponent.value.getEditor()
|
|
324
|
-
if (editorFromComponent && typeof editorFromComponent.createVitalSigns === 'function') {
|
|
325
|
-
editor = editorFromComponent
|
|
326
|
-
editorReady.value = true
|
|
327
|
-
}
|
|
328
|
-
} catch (err) {
|
|
329
|
-
console.error('从组件获取editor对象错误:', err)
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
})
|
|
333
|
-
})
|
|
334
|
-
|
|
335
|
-
// 暴露方法和属性给父组件,使父组件可以通过ref访问
|
|
336
|
-
defineExpose({
|
|
337
|
-
// 属性
|
|
338
|
-
vitalSignsId,
|
|
339
|
-
// 方法
|
|
340
|
-
clearVitalSigns,
|
|
341
|
-
showVitalSignsModal,
|
|
342
|
-
execCommand,
|
|
343
|
-
// 获取当前体温单ID的方法
|
|
344
|
-
getVitalSignsId: () => vitalSignsId.value,
|
|
345
|
-
// 设置体温单ID的方法
|
|
346
|
-
setVitalSignsId: (id) => {
|
|
347
|
-
vitalSignsId.value = id
|
|
348
|
-
}
|
|
349
|
-
})
|
|
350
|
-
</script>
|
|
351
|
-
|
|
352
|
-
<style scoped>
|
|
353
|
-
.box {
|
|
354
|
-
display: flex;
|
|
355
|
-
align-items: center;
|
|
356
|
-
padding: 1%;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/* 体温单生成加载遮罩样式 */
|
|
360
|
-
.generating-mask {
|
|
361
|
-
position: fixed;
|
|
362
|
-
top: 0;
|
|
363
|
-
left: 0;
|
|
364
|
-
right: 0;
|
|
365
|
-
bottom: 0;
|
|
366
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
367
|
-
display: flex;
|
|
368
|
-
justify-content: center;
|
|
369
|
-
align-items: center;
|
|
370
|
-
z-index: 9999;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
.generating-content {
|
|
374
|
-
background-color: white;
|
|
375
|
-
padding: 20px 40px;
|
|
376
|
-
border-radius: 4px;
|
|
377
|
-
text-align: center;
|
|
378
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
.generating-text {
|
|
382
|
-
margin-top: 16px;
|
|
383
|
-
color: rgba(0, 0, 0, 0.85);
|
|
384
|
-
font-size: 16px;
|
|
385
|
-
}
|
|
386
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<!-- <Source src="/code/VitalSigns.vue"></Source>-->
|
|
3
|
+
<div>
|
|
4
|
+
<a-row class="box">
|
|
5
|
+
病历号 <a-input v-model="vitalSignsId" style="width: 160px"></a-input>
|
|
6
|
+
<a-button-group style="margin-left: 20px;">
|
|
7
|
+
<a-button plain type="primary" @click="showVitalSignsModal('create')" :loading="loading" :disabled="!editorReady">创建体温单</a-button>
|
|
8
|
+
<a-button plain type="primary" @click="showVitalSignsModal('update')" :loading="loading" :disabled="!editorReady">更新体温单</a-button>
|
|
9
|
+
</a-button-group>
|
|
10
|
+
<a-button-group style="margin: 0 20px;">
|
|
11
|
+
<a-button plain type="primary" @click="showVitalSignsModal('baby')" :loading="loading" :disabled="!editorReady">新生儿体温单</a-button>
|
|
12
|
+
</a-button-group>
|
|
13
|
+
<a-button-group style="margin: 0 20px;">
|
|
14
|
+
<a-button plain type="primary" @click="execCommand('preview')" :loading="loading" :disabled="!editorReady">打印预览</a-button>
|
|
15
|
+
<a-button plain type="primary" @click="execCommand('print')" :loading="loading" :disabled="!editorReady">打印</a-button>
|
|
16
|
+
</a-button-group>
|
|
17
|
+
<!-- 修改清空体温单按钮样式,使其更加醒目 -->
|
|
18
|
+
<a-button type="primary"
|
|
19
|
+
danger
|
|
20
|
+
@click="clearVitalSigns"
|
|
21
|
+
:loading="loading"
|
|
22
|
+
:disabled="!editorReady"
|
|
23
|
+
style="margin-left: 10px;">
|
|
24
|
+
<a-icon type="delete" /> 清空体温单
|
|
25
|
+
</a-button>
|
|
26
|
+
</a-row>
|
|
27
|
+
<div v-if="!editorReady" style="margin: 10px 0; padding: 10px; background-color: #fffbe6; border: 1px solid #ffe58f;">
|
|
28
|
+
<a-icon type="loading" /> 体温单编辑器加载中...
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<!-- 添加体温单生成加载遮罩 -->
|
|
32
|
+
<div v-if="generating" class="generating-mask">
|
|
33
|
+
<div class="generating-content">
|
|
34
|
+
<a-spin size="large" />
|
|
35
|
+
<div class="generating-text">体温单生成中,请稍候...</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<Editor @editor-ready="onEditorReady" style="margin: 10px 0;" ref="editorComponent"></Editor>
|
|
40
|
+
|
|
41
|
+
<!-- 使用TextBox组件替代原有弹窗 -->
|
|
42
|
+
<TextBox
|
|
43
|
+
:visible="modalVisible"
|
|
44
|
+
:modalType="modalType"
|
|
45
|
+
:editorReady="editorReady"
|
|
46
|
+
:id="Number(vitalSignsId) || 180"
|
|
47
|
+
@submit="handleSubmit"
|
|
48
|
+
@cancel="closeModal"
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script setup>
|
|
54
|
+
import { ref, onMounted } from 'vue'
|
|
55
|
+
import Editor from './editor.vue'
|
|
56
|
+
import TextBox from './textBox.vue'
|
|
57
|
+
import { message } from 'ant-design-vue'
|
|
58
|
+
|
|
59
|
+
// 响应式状态
|
|
60
|
+
const vitalSignsId = ref(null)
|
|
61
|
+
const loading = ref(false)
|
|
62
|
+
const editorReady = ref(false)
|
|
63
|
+
const editorComponent = ref(null)
|
|
64
|
+
const modalVisible = ref(false)
|
|
65
|
+
const modalType = ref('create')
|
|
66
|
+
const generating = ref(false) // 添加体温单生成中状态
|
|
67
|
+
let editor = null
|
|
68
|
+
// 定义组件事件
|
|
69
|
+
const emit = defineEmits(['submit'])
|
|
70
|
+
// 常量
|
|
71
|
+
const modalTitles = {
|
|
72
|
+
create: '创建体温单',
|
|
73
|
+
update: '更新体温单',
|
|
74
|
+
baby: '新生儿体温单'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 显示弹窗
|
|
78
|
+
const showVitalSignsModal = (type) => {
|
|
79
|
+
modalType.value = type
|
|
80
|
+
modalVisible.value = true
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 关闭弹窗
|
|
84
|
+
const closeModal = () => {
|
|
85
|
+
modalVisible.value = false
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 编辑器初始化
|
|
89
|
+
const onEditorReady = (editorObj) => {
|
|
90
|
+
try {
|
|
91
|
+
if (!editorObj) {
|
|
92
|
+
throw new Error('传入的editor对象为null或undefined')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 尝试获取编辑器对象
|
|
96
|
+
if (typeof editorObj.createVitalSigns === 'function') {
|
|
97
|
+
editor = editorObj
|
|
98
|
+
} else if (editorObj.getEditor && typeof editorObj.getEditor === 'function') {
|
|
99
|
+
const editorFromComponent = editorObj.getEditor()
|
|
100
|
+
editor = editorFromComponent && typeof editorFromComponent.createVitalSigns === 'function'
|
|
101
|
+
? editorFromComponent
|
|
102
|
+
: (typeof editorObj.createVitalSigns === 'function' ? editorObj : null)
|
|
103
|
+
}
|
|
104
|
+
if (!editor) {
|
|
105
|
+
throw new Error('无法获取有效的editor对象')
|
|
106
|
+
}
|
|
107
|
+
editorReady.value = true
|
|
108
|
+
} catch (err) {
|
|
109
|
+
console.error('设置editor对象失败:', err)
|
|
110
|
+
message.error('体温单编辑器初始化失败,请刷新页面重试')
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 执行命令
|
|
115
|
+
const execCommand = (cmd) => {
|
|
116
|
+
if (!editorReady.value || !editor) return
|
|
117
|
+
loading.value = true
|
|
118
|
+
try {
|
|
119
|
+
editor.execCommand(cmd)
|
|
120
|
+
} catch (err) {
|
|
121
|
+
console.error('执行命令出错:', err)
|
|
122
|
+
message.error(`执行${cmd}命令失败`)
|
|
123
|
+
} finally {
|
|
124
|
+
loading.value = false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 清空体温单
|
|
129
|
+
const clearVitalSigns = async () => {
|
|
130
|
+
if (!editorReady.value || !editor) {
|
|
131
|
+
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
loading.value = true
|
|
136
|
+
generating.value = true
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
// 重新加载editor.html页面来完全重置编辑器
|
|
140
|
+
try {
|
|
141
|
+
const iframe = editorComponent.value.$refs.editorIframe
|
|
142
|
+
if (iframe) {
|
|
143
|
+
// 保存当前src
|
|
144
|
+
const currentSrc = iframe.src
|
|
145
|
+
// 确认提示
|
|
146
|
+
message.loading('正在清空体温单...', 1)
|
|
147
|
+
// 重新加载iframe
|
|
148
|
+
iframe.onload = async () => {
|
|
149
|
+
try {
|
|
150
|
+
// 等待iframe重新加载完成
|
|
151
|
+
await new Promise(resolve => setTimeout(resolve, 500))
|
|
152
|
+
|
|
153
|
+
// 获取新的editor对象
|
|
154
|
+
const newEditorObj = iframe.contentWindow.editor
|
|
155
|
+
if (newEditorObj) {
|
|
156
|
+
// 等待editor初始化
|
|
157
|
+
if (typeof newEditorObj.init === 'function') {
|
|
158
|
+
await new Promise((resolve) => {
|
|
159
|
+
const checkInterval = setInterval(() => {
|
|
160
|
+
if (newEditorObj.isReady) {
|
|
161
|
+
clearInterval(checkInterval)
|
|
162
|
+
resolve()
|
|
163
|
+
}
|
|
164
|
+
}, 100)
|
|
165
|
+
|
|
166
|
+
// 最多等待5秒
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
clearInterval(checkInterval)
|
|
169
|
+
resolve()
|
|
170
|
+
}, 5000)
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 更新全局editor引用
|
|
175
|
+
editor = newEditorObj
|
|
176
|
+
window.iframeEditor = newEditorObj
|
|
177
|
+
} else {
|
|
178
|
+
throw new Error('重新加载后无法获取editor对象')
|
|
179
|
+
}
|
|
180
|
+
} catch (err) {
|
|
181
|
+
console.error('重新加载iframe后清空体温单出错:', err)
|
|
182
|
+
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
|
183
|
+
} finally {
|
|
184
|
+
loading.value = false
|
|
185
|
+
generating.value = false
|
|
186
|
+
// 移除临时onload处理器
|
|
187
|
+
iframe.onload = null
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 重新加载iframe
|
|
192
|
+
iframe.src = currentSrc + '?t=' + new Date().getTime()
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
} catch (reloadErr) {
|
|
196
|
+
console.warn('重新加载iframe失败,将尝试其他方法清空体温单:', reloadErr)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 备用清空方法
|
|
200
|
+
try {
|
|
201
|
+
const iframe = editorComponent.value.$refs.editorIframe
|
|
202
|
+
if (iframe?.contentWindow) {
|
|
203
|
+
iframe.contentWindow.eval(`
|
|
204
|
+
try {
|
|
205
|
+
// 尝试使用编辑器提供的各种可能的清空方法
|
|
206
|
+
if (editor) {
|
|
207
|
+
if (typeof editor.loadUrl === 'function') {
|
|
208
|
+
editor.loadUrl('');
|
|
209
|
+
} else if (typeof editor.resetDocument === 'function') {
|
|
210
|
+
editor.resetDocument();
|
|
211
|
+
} else if (typeof editor.clearContent === 'function') {
|
|
212
|
+
editor.clearContent();
|
|
213
|
+
} else if (typeof editor.clear === 'function') {
|
|
214
|
+
editor.clear();
|
|
215
|
+
} else if (typeof editor.setEditorContent === 'function') {
|
|
216
|
+
editor.setEditorContent('');
|
|
217
|
+
} else if (editor.document) {
|
|
218
|
+
try {
|
|
219
|
+
editor.document.body.innerHTML = '';
|
|
220
|
+
} catch(clearErr) {
|
|
221
|
+
console.warn('清空编辑器内容失败');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
} catch(e) {
|
|
226
|
+
console.error('清空体温单失败:', e);
|
|
227
|
+
}
|
|
228
|
+
`)
|
|
229
|
+
} else if (window.iframeEditor) {
|
|
230
|
+
const editorObj = window.iframeEditor
|
|
231
|
+
if (typeof editorObj.loadUrl === 'function') {
|
|
232
|
+
editorObj.loadUrl('')
|
|
233
|
+
} else if (typeof editorObj.resetDocument === 'function') {
|
|
234
|
+
editorObj.resetDocument()
|
|
235
|
+
} else if (typeof editorObj.clearContent === 'function') {
|
|
236
|
+
editorObj.clearContent()
|
|
237
|
+
} else if (typeof editorObj.clear === 'function') {
|
|
238
|
+
editorObj.clear()
|
|
239
|
+
} else if (typeof editorObj.setEditorContent === 'function') {
|
|
240
|
+
editorObj.setEditorContent('')
|
|
241
|
+
}
|
|
242
|
+
} else if (editor) {
|
|
243
|
+
if (typeof editor.loadUrl === 'function') {
|
|
244
|
+
editor.loadUrl('')
|
|
245
|
+
} else if (typeof editor.resetDocument === 'function') {
|
|
246
|
+
editor.resetDocument()
|
|
247
|
+
} else if (typeof editor.clearContent === 'function') {
|
|
248
|
+
editor.clearContent()
|
|
249
|
+
} else if (typeof editor.clear === 'function') {
|
|
250
|
+
editor.clear()
|
|
251
|
+
} else if (typeof editor.setEditorContent === 'function') {
|
|
252
|
+
editor.setEditorContent('')
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
throw new Error('无法获取编辑器对象')
|
|
256
|
+
}
|
|
257
|
+
} catch (err) {
|
|
258
|
+
console.error('清空体温单出错:', err)
|
|
259
|
+
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
|
260
|
+
}
|
|
261
|
+
} finally {
|
|
262
|
+
loading.value = false
|
|
263
|
+
generating.value = false
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// 处理表单提交
|
|
267
|
+
const handleSubmit = async (formData) => {
|
|
268
|
+
if (!editorReady.value || !editor) {
|
|
269
|
+
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
loading.value = true
|
|
273
|
+
generating.value = true // 开始生成,显示加载遮罩
|
|
274
|
+
try {
|
|
275
|
+
// 简化代码,直接在现有体温单上创建新的体温单(不再清空)
|
|
276
|
+
let result
|
|
277
|
+
try {
|
|
278
|
+
const iframe = editorComponent.value.$refs.editorIframe
|
|
279
|
+
if (iframe?.contentWindow) {
|
|
280
|
+
const dataStr = JSON.stringify(formData)
|
|
281
|
+
const script = `
|
|
282
|
+
try {
|
|
283
|
+
const data = JSON.parse('${dataStr.replace(/'/g, "\\'")}');
|
|
284
|
+
return editor.createVitalSigns(data);
|
|
285
|
+
} catch(e) {
|
|
286
|
+
console.error('iframe执行错误:', e);
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
`
|
|
290
|
+
result = iframe.contentWindow.eval(script)
|
|
291
|
+
} else if (window.iframeEditor) {
|
|
292
|
+
result = window.iframeEditor.createVitalSigns(formData)
|
|
293
|
+
} else {
|
|
294
|
+
throw new Error('无法访问iframe')
|
|
295
|
+
}
|
|
296
|
+
} catch (err) {
|
|
297
|
+
// 备用方案
|
|
298
|
+
if (editor && typeof editor.createVitalSigns === 'function') {
|
|
299
|
+
result = editor.createVitalSigns(formData)
|
|
300
|
+
} else {
|
|
301
|
+
throw new Error('无法调用createVitalSigns方法')
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
vitalSignsId.value = result || formData.id
|
|
306
|
+
modalVisible.value = false
|
|
307
|
+
message.success(`${modalTitles[modalType.value]}成功`)
|
|
308
|
+
emit('submit', formData)
|
|
309
|
+
} catch (err) {
|
|
310
|
+
console.error('创建体温单出错:', err)
|
|
311
|
+
message.error(`创建体温单失败: ${err.message || '未知错误'}`)
|
|
312
|
+
} finally {
|
|
313
|
+
loading.value = false
|
|
314
|
+
generating.value = false // 无论成功失败,都结束加载遮罩
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 生命周期钩子
|
|
319
|
+
onMounted(() => {
|
|
320
|
+
window.addEventListener('message', (event) => {
|
|
321
|
+
if (event.data?.type === 'editorReady' && !editorReady.value && editorComponent.value?.getEditor) {
|
|
322
|
+
try {
|
|
323
|
+
const editorFromComponent = editorComponent.value.getEditor()
|
|
324
|
+
if (editorFromComponent && typeof editorFromComponent.createVitalSigns === 'function') {
|
|
325
|
+
editor = editorFromComponent
|
|
326
|
+
editorReady.value = true
|
|
327
|
+
}
|
|
328
|
+
} catch (err) {
|
|
329
|
+
console.error('从组件获取editor对象错误:', err)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
})
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
// 暴露方法和属性给父组件,使父组件可以通过ref访问
|
|
336
|
+
defineExpose({
|
|
337
|
+
// 属性
|
|
338
|
+
vitalSignsId,
|
|
339
|
+
// 方法
|
|
340
|
+
clearVitalSigns,
|
|
341
|
+
showVitalSignsModal,
|
|
342
|
+
execCommand,
|
|
343
|
+
// 获取当前体温单ID的方法
|
|
344
|
+
getVitalSignsId: () => vitalSignsId.value,
|
|
345
|
+
// 设置体温单ID的方法
|
|
346
|
+
setVitalSignsId: (id) => {
|
|
347
|
+
vitalSignsId.value = id
|
|
348
|
+
}
|
|
349
|
+
})
|
|
350
|
+
</script>
|
|
351
|
+
|
|
352
|
+
<style scoped>
|
|
353
|
+
.box {
|
|
354
|
+
display: flex;
|
|
355
|
+
align-items: center;
|
|
356
|
+
padding: 1%;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/* 体温单生成加载遮罩样式 */
|
|
360
|
+
.generating-mask {
|
|
361
|
+
position: fixed;
|
|
362
|
+
top: 0;
|
|
363
|
+
left: 0;
|
|
364
|
+
right: 0;
|
|
365
|
+
bottom: 0;
|
|
366
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
367
|
+
display: flex;
|
|
368
|
+
justify-content: center;
|
|
369
|
+
align-items: center;
|
|
370
|
+
z-index: 9999;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.generating-content {
|
|
374
|
+
background-color: white;
|
|
375
|
+
padding: 20px 40px;
|
|
376
|
+
border-radius: 4px;
|
|
377
|
+
text-align: center;
|
|
378
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.generating-text {
|
|
382
|
+
margin-top: 16px;
|
|
383
|
+
color: rgba(0, 0, 0, 0.85);
|
|
384
|
+
font-size: 16px;
|
|
385
|
+
}
|
|
386
|
+
</style>
|