vue2-client 1.14.41 → 1.14.44

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