vue2-client 1.16.49 → 1.16.51

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 (45) hide show
  1. package/package.json +112 -112
  2. package/src/assets/svg/female.svg +1 -0
  3. package/src/assets/svg/male.svg +1 -0
  4. package/src/base-client/components/common/HIS/HButtons/HButtons.vue +371 -371
  5. package/src/base-client/components/common/HIS/HFormGroup/HFormGroup.vue +120 -120
  6. package/src/base-client/components/common/HIS/HFormGroup/index.js +3 -3
  7. package/src/base-client/components/common/HIS/HFormTable/HFormTable.vue +379 -257
  8. package/src/base-client/components/common/HIS/demo.vue +61 -61
  9. package/src/base-client/components/common/XCollapse/XCollapse.vue +461 -461
  10. package/src/base-client/components/common/XInput/XInput.vue +147 -147
  11. package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +824 -824
  12. package/src/base-client/components/common/XTable/XTable.vue +1610 -1610
  13. package/src/base-client/components/common/XTimeline/XTimeline.vue +454 -454
  14. package/src/base-client/components/his/XHisEditor/XHisEditor.vue +705 -705
  15. package/src/base-client/components/his/XList/XList.vue +829 -607
  16. package/src/base-client/components/his/threeTestOrders/editor.vue +113 -113
  17. package/src/pages/WorkflowDetail/WorkFlowDemo3.vue +203 -225
  18. package/src/pages/userInfoDetailManage/ExceptionRecordQuery/index.vue +45 -45
  19. package/src/router/async/router.map.js +129 -129
  20. package/src/services/api/common.js +0 -2
  21. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926145434.vue +0 -641
  22. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926145453.vue +0 -641
  23. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926145610.vue +0 -647
  24. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926145629.vue +0 -647
  25. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926145901.vue +0 -645
  26. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926145907.vue +0 -651
  27. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926145920.vue +0 -651
  28. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926150047.vue +0 -651
  29. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926151820.vue +0 -646
  30. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926151827.vue +0 -646
  31. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926152115.vue +0 -646
  32. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926152212.vue +0 -653
  33. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926152215.vue +0 -653
  34. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926152337.vue +0 -657
  35. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926152341.vue +0 -657
  36. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926152826.vue +0 -657
  37. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926152828.vue +0 -646
  38. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926153121.vue +0 -654
  39. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926153242.vue +0 -654
  40. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926153318.vue +0 -646
  41. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926153415.vue +0 -646
  42. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926153435.vue +0 -655
  43. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926153606.vue +0 -655
  44. package/.history/src/base-client/components/common/XDataCard/XDataCard_20250926153653.vue +0 -655
  45. package/src/base-client/components/common/XDataCard/test.vue +0 -367
@@ -1,705 +1,705 @@
1
- <template>
2
- <div>
3
- <div v-show="ready">
4
- <a-row v-if="this.readonly" class="editor-action-container" type="flex" justify="space-between">
5
- <a-col class="editor-tools">
6
- <a-space>
7
- <template v-if="resList.length > 0">
8
- <a-select
9
- style="width: 200px"
10
- v-model="toggleResId"
11
- placeholder="请选择文档"
12
- show-search
13
- @change="changeRes"
14
- >
15
- <a-select-option v-for="item of resListCp" :key="item.value" :value="item.value">{{ item.label }}</a-select-option>
16
- </a-select>
17
- <!-- <template v-if="this.modeType !== 'readonly' && this.resId !== -1">-->
18
- <!-- <a-button icon="plus" @click="addRes"/>-->
19
- <!-- </template>-->
20
- </template>
21
- <a-radio-group
22
- class="custom-radio-group"
23
- v-show="showModeChoose"
24
- button-style="solid"
25
- @change="changeMode"
26
- v-model="modeType">
27
- <a-radio-button v-for="item of modeList" :key="item.value" :value="item.value">
28
- {{ item.label }}
29
- </a-radio-button>
30
- </a-radio-group>
31
- </a-space>
32
- </a-col>
33
- <a-col class="editor-action-button">
34
- <a-space>
35
- <template v-if="this.modeType !== 'readonly'">
36
- <!-- <a-button-->
37
- <!-- type="primary"-->
38
- <!-- v-if = "userTemplateVisible"-->
39
- <!-- @click="useTemplateData"-->
40
- <!-- >-->
41
- <!-- 使用-->
42
- <!-- </a-button>-->
43
- <a-button type="primary" @click="Recording" v-if="canRecord" v-model="recording">
44
- {{ recording? '停止' : '录音' }}
45
- </a-button>
46
- <a-button type="primary" @click="openRenameModal" v-if="this.resId !== -1">
47
- 重命名
48
- </a-button>
49
- <!-- 组合按钮容器 -->
50
- <div class="save-btn-main">
51
- <!-- 保存按钮 (左侧) -->
52
- <a-button
53
- type="primary"
54
- class="save-btn-main"
55
- @click="showSaveModal('normal')"
56
- >
57
- 保存
58
- </a-button>
59
-
60
- <!-- 下拉部分 (右侧) -->
61
- <!-- 下拉触发部分 -->
62
- <template v-if="modeType !== 'design'">
63
- <a-dropdown
64
- :trigger="['click']"
65
- placement="bottomRight">
66
- <a-button
67
- type="primary"
68
- class="dropdown-trigger-btn">
69
- <a-icon type="down" />
70
- </a-button>
71
- <a-menu slot="overlay">
72
- <a-menu-item @click="showSaveModal('template')">
73
- 保存并作为模板
74
- </a-menu-item>
75
- </a-menu>
76
- </a-dropdown>
77
- </template>
78
- </div>
79
- <a-modal
80
- title="保存"
81
- :visible="saveVisible"
82
- :confirm-loading="false"
83
- @ok="handleSaveConfirm"
84
- @cancel="saveVisible = false"
85
- >
86
- <a-form-item label="文件名" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
87
- <a-input
88
- v-model="fileName"
89
- placeholder="请输入文件名"
90
- @pressEnter="handleSaveConfirm"
91
- />
92
- </a-form-item>
93
- </a-modal>
94
- </template>
95
- <a-button type="primary" @click="print">
96
- 打印
97
- </a-button>
98
- <a-button @click="refresh">
99
- 刷新
100
- </a-button>
101
- </a-space>
102
- <a-dropdown>
103
- <a-menu slot="overlay" @click="handleExportMenuClick">
104
- <a-menu-item key="exportPdf">导出为Pdf</a-menu-item>
105
- <a-menu-item key="exportWord">导出为Word</a-menu-item>
106
- <a-menu-item key="exportHtmlWithStyle">导出为Html</a-menu-item>
107
- </a-menu>
108
- <a-button style="margin-left: 8px"> 导出 <a-icon type="down" /> </a-button>
109
- </a-dropdown>
110
- </a-col>
111
- </a-row>
112
- <a-divider/>
113
- <a-spin tip="加载中,马上好" :spinning="loading">
114
- <iframe
115
- id="x-editor"
116
- src="/his/editor/editor.html"
117
- v-bind="objectOfAttrs"
118
- @load="onload"
119
- style="height: calc(-200px - 3rem + 100vh);">
120
- </iframe>
121
- </a-spin>
122
- </div>
123
- <div v-show="!ready">
124
- <a-empty description="请选择文书" />
125
- </div>
126
- <a-modal
127
- :destroyOnClose="true"
128
- :title="this.resDataModalMode === 'modify' ? '修改文档' : '新建文档'"
129
- :visible="resDataModalVisible"
130
- okText="提交"
131
- @cancel="resDataModalVisible = false"
132
- @ok="onSubmit">
133
- <a-form-model ref="resModifyForm" :model="modifyResModel" :rules="resRules">
134
- <a-form-model-item prop="f_file_name" label="文档名">
135
- <a-input v-model="modifyResModel.f_file_name" placeholder="请输入文档名"/>
136
- </a-form-model-item>
137
- </a-form-model>
138
- </a-modal></div>
139
- </template>
140
-
141
- <script>
142
-
143
- import { runLogic } from '@vue2-client/services/api/common'
144
- import { initDiagnosisDropdown } from './diagnosisAutocomplete'
145
-
146
- export default {
147
- name: 'XHisEditor',
148
- computed: {
149
- resListCp () {
150
- const list = this.resList
151
- if (this.resId === -1) {
152
- list.push({
153
- label: '未保存文档*', value: -1
154
- })
155
- }
156
- return list
157
- }
158
- },
159
- data () {
160
- return {
161
- temporaryParameter: {},
162
- canRecord: false,
163
- recording: false, // 是否正在录音
164
- readonly: false,
165
- ready: false,
166
- loading: false,
167
- resDataModalMode: 'modify',
168
- resDataModalVisible: false,
169
- saveVisible: false,
170
- // 使用按钮显隐控制
171
- // userTemplateVisible: false,
172
- objectOfAttrs: {
173
- width: '100%',
174
- height: '650vh',
175
- frameborder: 0
176
- },
177
- // 数据模式
178
- modeType: 'form',
179
- // 是否显示模式切换功能
180
- showModeChoose: true,
181
- // 是否作为模板 1 是,0 否
182
- isTemplate: 0,
183
- // 模板id
184
- templateId: undefined,
185
- admissionId: undefined,
186
- // 保存类型
187
- saveType: 'normal',
188
- fileName: '',
189
- // 数据模式列表
190
- modeList: [
191
- {
192
- label: '预览',
193
- value: 'readonly'
194
- },
195
- {
196
- label: '表单',
197
- value: 'form'
198
- },
199
- {
200
- label: '设计',
201
- value: 'design'
202
- }
203
- ],
204
- // 编辑器实例
205
- editorRef: null,
206
- // 文档资源列表
207
- resList: [],
208
- // 文档资源ID
209
- resId: undefined,
210
- // 文档链接
211
- fileUrl: undefined,
212
- // 文档绑定数据
213
- bindObject: undefined,
214
- // 合并模板数据后文档数据
215
- assignBindObject: undefined,
216
- // 数据模式 template:模板编辑;data:数据编辑
217
- dataMode: undefined,
218
- // 保存数据调用的Logic名称
219
- saveDataLogicName: undefined,
220
- // 保存数据调用Logic传入的额外参数
221
- logicExtraParams: undefined,
222
- // 服务名
223
- serviceName: undefined,
224
- // 当前文档信息
225
- currResData: {},
226
- // 切换的文档id
227
- toggleResId: undefined,
228
- // 待提交的修改信息
229
- modifyResModel: {},
230
- codeData: {},
231
- resRules: {
232
- f_file_name: [{ required: true, message: '请输入文档名', trigger: 'blur' }],
233
- }
234
- }
235
- },
236
- // 初始化 保存后 加载文件后 诊断选择
237
- emits: ['init', 'saveafter', 'afterLoadFile', 'selected'],
238
- methods: {
239
- runLogic,
240
- /* eslint-disable */
241
- async initDiagnosisAutocomplete (dropDownBoxParams) {
242
- console.log('dropDownBoxParams',dropDownBoxParams)
243
- if (!this.editorRef || !this.editorRef.document) {
244
- return
245
- }
246
-
247
- // 添加参数检查
248
- if (!dropDownBoxParams || !Array.isArray(dropDownBoxParams) || dropDownBoxParams.length === 0) {
249
- return
250
- }
251
-
252
- // 创建一个简单的自定义事件系统
253
- // 1. 创建一个隐藏的DOM元素作为事件通道
254
- const eventChannel = this.editorRef.document.createElement('div');
255
- eventChannel.id = 'diagnosis-event-channel';
256
- eventChannel.style.display = 'none';
257
- this.editorRef.document.body.appendChild(eventChannel);
258
- // 2. 在iframe文档中监听自定义事件
259
- const that = this;
260
- this.editorRef.document.addEventListener('diagnosis-selected', function(e) {
261
- if (e && e.detail) {
262
- that.$emit('selected', { item: e.detail, editor: that.editorRef });
263
- that.codeData = { ...that.codeData, ...{[e.detail.codeKey]: e.detail.code} }
264
- }
265
- });
266
-
267
- for (const param of dropDownBoxParams) {
268
- if (param.identificationCode && param.dataLogic) {
269
- try {
270
- let preliDiagnoData = null
271
- // 保留获取后端数据的逻辑
272
- await runLogic(param.dataLogic,
273
- {}, 'af-his').then(res => {
274
- preliDiagnoData = res
275
- })
276
-
277
- // 创建脚本元素
278
- const scriptElement = this.editorRef.document.createElement('script')
279
-
280
- // 注入自定义事件触发函数和初始化代码
281
- scriptElement.textContent = `
282
- // 定义一个函数来触发自定义事件
283
- function triggerDiagnosisSelected(data) {
284
- const event = new CustomEvent('diagnosis-selected', {
285
- detail: data,
286
- bubbles: true
287
- });
288
- document.dispatchEvent(event);
289
- }
290
-
291
- // 初始化诊断下拉菜单,使用自定义事件触发函数
292
- (${initDiagnosisDropdown.toString()})(
293
- editor,
294
- ${JSON.stringify(preliDiagnoData)},
295
- '${param.identificationCode}',
296
- triggerDiagnosisSelected
297
- );
298
- `;
299
-
300
- this.editorRef.document.body.appendChild(scriptElement);
301
- } catch (error) {
302
- console.error('初始化诊断自动完成失败:', error);
303
- }
304
- }
305
- }
306
- },
307
- showSaveModal (type) {
308
- this.saveType = type // 记录当前保存类型
309
- if (type === 'template') {
310
- this.saveVisible = true
311
- }else {
312
- if (this.resId !== -1 || this.resId !== undefined) {
313
- this.save()
314
- } else {
315
- this.openAddResModal()
316
- }
317
- }
318
-
319
- },
320
- handleSaveConfirm () {
321
- if (!this.fileName.trim()) {
322
- this.$message.error('文件名不能为空')
323
- return
324
- }
325
- this.saveAsTemplate()
326
- },
327
- /* eslint-disable */
328
- // 初始化文档
329
- onload (e) {
330
- if (e && e.target && e.target.contentWindow) {
331
- this.editorRef = e.target.contentWindow.editor
332
- // 等待文档加载完成
333
- this.$emit('init', {})
334
- }
335
- },
336
- init (params, loadResList = true) {
337
- console.log("===============>",params)
338
- this.temporaryParameter = params
339
- this.canRecord = params.canRecord == undefined || params.canRecord == null? false : params.canRecord
340
- const {
341
- fileUrl,
342
- resId,
343
- currResData = {},
344
- bindObject,
345
- saveDataLogicName,
346
- logicExtraParams,
347
- dropDownBoxParams,
348
- serviceName,
349
- showModeChoose = true,
350
- modeType = 'form'
351
- } = params
352
- this.resId = resId
353
- if (bindObject) {
354
- this.dataMode = 'data'
355
- this.bindObject = bindObject
356
- } else {
357
- this.dataMode = 'template'
358
- }
359
- if (logicExtraParams?.admissionId !== undefined && logicExtraParams?.templateId !== undefined) {
360
- this.admissionId = logicExtraParams.admissionId
361
- this.templateId = logicExtraParams.templateId
362
- } else {
363
- console.warn('病例id:admissionId不存在或模板id:templateId不存在')
364
- }
365
- this.saveDataLogicName = saveDataLogicName
366
- this.logicExtraParams = logicExtraParams
367
- this.serviceName = serviceName
368
- this.showModeChoose = showModeChoose
369
- this.modeType = (modeType === "readonly!" ? "readonly" :modeType)
370
- this.readonly = (modeType !== "readonly!")
371
- this.ready = true
372
- // 先加载文件
373
- this.loadFile(fileUrl, bindObject, currResData).then(async () => {
374
- // 文件加载完成后再初始化自动完成
375
- await this.initDiagnosisAutocomplete(dropDownBoxParams)
376
- })
377
- if(loadResList){
378
- this.loadResList()
379
- }
380
- },
381
- // 加载文档
382
- loadFile (fileUrl, bindObject, currResData) {
383
- this.loading = true
384
- return new Promise((resolve) => {
385
- this.editorRef.loadUrl(fileUrl).then(() => {
386
- if (bindObject) {
387
- this.editorRef.setBindObject(bindObject)
388
- if (bindObject.template) {
389
- for (const key of Object.keys(bindObject.template)) {
390
- this.editorRef.bindDataList(key, bindObject.template[key])
391
- }
392
- }
393
- }
394
- // 拿取多于模板中的数据
395
- const diff = this.bindObject? Object.fromEntries(
396
- Object.entries(this.bindObject)
397
- .filter(([key]) => !(key in this.editorRef.getBindObject()))
398
- ) : {}
399
- this.codeData = {...this.codeData,...diff}
400
- this.changeMode()
401
- this.fileUrl = fileUrl
402
- if (!currResData.f_file_name) {
403
- currResData.f_file_name = '未命名'
404
- }
405
- this.currResData = currResData
406
- this.loading = false
407
- this.$emit('afterLoadFile', {})
408
- resolve()
409
- })
410
- })
411
- },
412
- // 保存并作为模板
413
- saveAsTemplate () {
414
- this.isTemplate = 1
415
- this.save()
416
- },
417
- // 加载文档列表
418
- loadResList () {
419
- console.log("getTemplateListLogic=======",this.logicExtraParams)
420
- runLogic('getTemplateListLogic', this.logicExtraParams, this.serviceName).then(res => {
421
- this.resList = res
422
- this.toggleResId = this.resId
423
- })
424
- },
425
- // 修改模式
426
- changeMode (e) {
427
- this.editorRef.execCommand(this.modeType)
428
- },
429
- // 启动录音功能
430
- async Recording () {
431
- this.recording = !this.recording
432
- if (this.recording) {
433
- const recording = await this.$recording.startRecording()
434
- this.$message.warn(recording.msg)
435
- } else {
436
- try {
437
- // 1. 获取录音和接口数据
438
- const recording = this.$recording.stopRecording()
439
- this.$message.warn(recording.msg)
440
- const data = await this.$recording.getRecordingData()
441
- const result = await this.runLogic('communacation', {record_content: data}, 'af-his')
442
- // 验证基础结构
443
- if (!result || typeof result.value !== 'string') {
444
- throw new Error('接口返回格式错误,缺少有效的value字段')
445
- }
446
- // 2. 处理外层JSON字符串(关键修复)
447
- let outerJsonStr = result.value
448
- // 修复1:处理布尔值
449
- outerJsonStr = outerJsonStr.replace(/\bTrue\b/g, 'true')
450
- // 修复2:移除所有控制字符
451
- outerJsonStr = outerJsonStr.replace(/[\x00-\x1F]/g, '')
452
- // 修复3:精准转义data字段内的双引号
453
- // 匹配 "data": "..." 结构并转义内容中的双引号
454
- outerJsonStr = outerJsonStr.replace(/"data":\s*"([^"]*)"/g, (match, content) => {
455
- // 转义内容中的双引号为\"
456
- const escapedContent = content.replace(/"/g, '\\"')
457
- return `"data": "${escapedContent}"`
458
- })
459
- // 直接在整个字符串里匹配 ```json{...}```
460
- const regex = /```json([\s\S]*?)```/
461
- const match = outerJsonStr.match(regex)
462
- let extractedJsonStr = ''
463
- if (match && match[1]) {
464
- extractedJsonStr = match[1].trim()
465
- }
466
- const outerObj = JSON.parse(extractedJsonStr)
467
- console.log("outerObj = ", outerObj)
468
- this.temporaryParameter.bindObject = {...this.temporaryParameter.bindObject, ...outerObj}
469
- this.init(this.temporaryParameter)
470
- } catch (e) {
471
- console.error('总错误:', e.message)
472
- this.$message.error(`解析失败: ${e.message}`)
473
- }
474
- }
475
- },
476
- // 打开文档信息修改面板
477
- openRenameModal () {
478
- this.resDataModalMode = 'modify'
479
- this.modifyResModel = {
480
- f_file_name: this.currResData.f_file_name
481
- }
482
- this.resDataModalVisible = true
483
- },
484
- // 提交文档信息修改
485
- onSubmit () {
486
- this.$refs.resModifyForm.validate(valid => {
487
- if (valid) {
488
- if (this.resDataModalMode === 'modify' && this.modifyResModel.f_file_name === this.currResData.f_file_name) {
489
- this.$message.warn('新文档名不能与原文档名一致!')
490
- return false
491
- }
492
- this.save()
493
- return true
494
- } else {
495
- return false
496
- }
497
- })
498
- },
499
- // 打开文档新建面板
500
- openAddResModal () {
501
- this.resDataModalMode = 'add'
502
- this.modifyResModel = {
503
- f_file_name: undefined
504
- }
505
- this.resDataModalVisible = true
506
- },
507
- // 新建文档
508
- addRes () {
509
- this.$emit('add', {})
510
- // const params = Object.assign({
511
- // isAddForce: true
512
- // }, this.logicExtraParams)
513
- // this.reload(params)
514
- },
515
- // 重新加载
516
- reload (params) {
517
- runLogic('getFileInformation', params , this.serviceName).then(res => {
518
- this.resDataModalVisible = false
519
- this.assignBindObject = this.assignTemplates(this.bindObject, res.bindObject)
520
- this.useTemplateData()
521
- })
522
- },
523
- // 合并模板数据
524
- assignTemplates (newBindObject, templateData) {
525
- // 检查templates数组是否存在
526
- if (!templateData.templates || !Array.isArray(templateData.templates)) {
527
- console.warn('templateData.templates不存在或不是数组')
528
- return newBindObject
529
- }
530
- // 遍历templates数组中的每个属性名
531
- templateData.templates.forEach(propName => {
532
- // 检查templateData是否有该属性
533
- if (propName in templateData) {
534
- // 无论newBindObject是否有该属性,都进行赋值/添加
535
- newBindObject[propName] = templateData[propName]
536
- } else {
537
- console.warn(`templateData中不存在属性: ${propName}`)
538
- }
539
- })
540
- return newBindObject
541
- },
542
- useTemplateData () {
543
- // 确认是否有合并后的模板数据
544
- if (!this.assignBindObject) {
545
- this.$message.warning('没有可用的模板数据');
546
- return;
547
- }
548
- this.editorRef.setBindObject(this.assignBindObject)
549
- // console.log('resId', this.resId)
550
- },
551
- // 切换文档
552
- changeRes (value) {
553
- console.log('value', value)
554
- let params = {
555
- resId: value
556
- }
557
- if (value === -1) {
558
- params = {
559
- ...params,
560
- admissionId: this.admissionId,
561
- f_template_id: this.templateId
562
- }
563
- const that = this
564
- this.$confirm({
565
- title: '确认切换文档吗?',
566
- content: '您有尚未保存的文档,切换文档将丢失所有的修改',
567
- onOk () {
568
- that.reload(params)
569
- // that.userTemplateVisible = true
570
- },
571
- onCancel () {
572
- that.toggleResId = that.resId
573
- },
574
- })
575
- } else {
576
- const selectedItem = this.resListCp.find(item => item.value === value);
577
- console.log('selectedItem=================', selectedItem)
578
- if(selectedItem.templateId != this.templateId){
579
- runLogic('getFileInformation', selectedItem.params.params , this.serviceName).then(res => {
580
- this.init({
581
- modeType: this.modeType,
582
- fileUrl: res.url,
583
- resId: res.id,
584
- currResData: res.currResData,
585
- bindObject: res.bindObject,
586
- saveDataLogicName: params?.saveDataLogicName,
587
- serviceName: this.serviceName,
588
- logicExtraParams: params?.logicExtraParams,
589
- dropDownBoxParams: params?.dropDownBoxParams
590
- }, false)
591
- })
592
- }else{
593
- this.reload({resId: selectedItem.id})
594
- }
595
- }
596
- },
597
- // 保存文档
598
- save () {
599
- // 验证必须输入项
600
- if (this.editorRef.validate()) {
601
- // 获取HTML文档和结构化数据(JSON)
602
- console.log('save',this.editorRef.getBindObject())
603
- const data = {
604
- doc: this.editorRef.getHtml(),
605
- dataObject: {
606
- ...this.editorRef.getBindObject(),
607
- ...this.codeData // 合并 codeData 数据
608
- },
609
- dataMode: this.dataMode,
610
- resId: this.resId,
611
- modifyResModel: this.modifyResModel,
612
- logicExtraParams: this.logicExtraParams,
613
- is_template: this.isTemplate,
614
- f_file_name: this.fileName
615
- }
616
- // 保存HTML文档和结构化数据到后端服务
617
- runLogic(this.saveDataLogicName, data, this.serviceName).then(res => {
618
- this.$message.success('保存成功')
619
- this.changeRes(res.currResData.id)
620
- this.$emit('saveafter', data.dataObject)
621
- }).finally(() => {
622
- this.resDataModalVisible = false
623
- this.saveVisible = false
624
- })
625
- } else {
626
- this.$message.error('请检查未填写的项目')
627
- }
628
- },
629
- // 打印文档
630
- print () {
631
- this.editorRef.execCommand('print')
632
- },
633
- // 关闭编辑器
634
- close () {
635
- this.ready = false
636
- },
637
- // 刷新文档
638
- refresh () {
639
- this.loadFile(this.fileUrl, this.bindObject, this.currResData)
640
- },
641
- // 导出下拉菜单
642
- handleExportMenuClick (e) {
643
- const key = e.key
644
- this.editorRef.execCommand(key)
645
- }
646
- }
647
- }
648
- </script>
649
- <style scoped lang="less">
650
- .editor-action-container {
651
- height: 40px;
652
- }
653
- .editor-action-button {
654
- .ant-btn-primary {
655
- background-color: rgb(0, 87, 254) !important;
656
- }
657
- }
658
- :deep(.ant-divider-horizontal) {
659
- margin: 4px 0;
660
- }
661
- /* 组合按钮容器 - 关键修正 */
662
- .combined-save-btn {
663
- display: inline-flex;
664
- height: 32px;
665
- }
666
-
667
- /* 主保存按钮 - 保持原有样式 */
668
- .save-btn-main {
669
- border-top-right-radius: 0 !important;
670
- border-bottom-right-radius: 0 !important;
671
- border-right: none !important;
672
- height: 32px;
673
- padding: 0 15px;
674
- display: inline-flex;
675
- align-items: center;
676
- justify-content: center;
677
- margin-right: -1px; /* 关键:负边距消除间距 */
678
- }
679
-
680
- /* 下拉按钮 - 仅调整间距 */
681
- .dropdown-trigger-btn {
682
- height: 32px !important;
683
- width: 24px !important;
684
- min-width: 24px !important;
685
- padding: 0 !important;
686
- border-top-left-radius: 0 !important;
687
- border-bottom-left-radius: 0 !important;
688
- border-left: 1px solid rgba(255, 255, 255, 0.3) !important;
689
- display: inline-flex;
690
- align-items: center;
691
- justify-content: center;
692
- margin-left: 0px;
693
- }
694
-
695
- /* 下拉图标保持原样 */
696
- .dropdown-trigger-btn .anticon {
697
- font-size: 12px;
698
- margin: 0 !important;
699
- }
700
- .custom-radio-group {
701
- .ant-radio-button-wrapper-checked {
702
- background-color: rgb(0, 87, 254) !important;
703
- }
704
- }
705
- </style>
1
+ <template>
2
+ <div>
3
+ <div v-show="ready">
4
+ <a-row v-if="this.readonly" class="editor-action-container" type="flex" justify="space-between">
5
+ <a-col class="editor-tools">
6
+ <a-space>
7
+ <template v-if="resList.length > 0">
8
+ <a-select
9
+ style="width: 200px"
10
+ v-model="toggleResId"
11
+ placeholder="请选择文档"
12
+ show-search
13
+ @change="changeRes"
14
+ >
15
+ <a-select-option v-for="item of resListCp" :key="item.value" :value="item.value">{{ item.label }}</a-select-option>
16
+ </a-select>
17
+ <!-- <template v-if="this.modeType !== 'readonly' && this.resId !== -1">-->
18
+ <!-- <a-button icon="plus" @click="addRes"/>-->
19
+ <!-- </template>-->
20
+ </template>
21
+ <a-radio-group
22
+ class="custom-radio-group"
23
+ v-show="showModeChoose"
24
+ button-style="solid"
25
+ @change="changeMode"
26
+ v-model="modeType">
27
+ <a-radio-button v-for="item of modeList" :key="item.value" :value="item.value">
28
+ {{ item.label }}
29
+ </a-radio-button>
30
+ </a-radio-group>
31
+ </a-space>
32
+ </a-col>
33
+ <a-col class="editor-action-button">
34
+ <a-space>
35
+ <template v-if="this.modeType !== 'readonly'">
36
+ <!-- <a-button-->
37
+ <!-- type="primary"-->
38
+ <!-- v-if = "userTemplateVisible"-->
39
+ <!-- @click="useTemplateData"-->
40
+ <!-- >-->
41
+ <!-- 使用-->
42
+ <!-- </a-button>-->
43
+ <a-button type="primary" @click="Recording" v-if="canRecord" v-model="recording">
44
+ {{ recording? '停止' : '录音' }}
45
+ </a-button>
46
+ <a-button type="primary" @click="openRenameModal" v-if="this.resId !== -1">
47
+ 重命名
48
+ </a-button>
49
+ <!-- 组合按钮容器 -->
50
+ <div class="save-btn-main">
51
+ <!-- 保存按钮 (左侧) -->
52
+ <a-button
53
+ type="primary"
54
+ class="save-btn-main"
55
+ @click="showSaveModal('normal')"
56
+ >
57
+ 保存
58
+ </a-button>
59
+
60
+ <!-- 下拉部分 (右侧) -->
61
+ <!-- 下拉触发部分 -->
62
+ <template v-if="modeType !== 'design'">
63
+ <a-dropdown
64
+ :trigger="['click']"
65
+ placement="bottomRight">
66
+ <a-button
67
+ type="primary"
68
+ class="dropdown-trigger-btn">
69
+ <a-icon type="down" />
70
+ </a-button>
71
+ <a-menu slot="overlay">
72
+ <a-menu-item @click="showSaveModal('template')">
73
+ 保存并作为模板
74
+ </a-menu-item>
75
+ </a-menu>
76
+ </a-dropdown>
77
+ </template>
78
+ </div>
79
+ <a-modal
80
+ title="保存"
81
+ :visible="saveVisible"
82
+ :confirm-loading="false"
83
+ @ok="handleSaveConfirm"
84
+ @cancel="saveVisible = false"
85
+ >
86
+ <a-form-item label="文件名" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
87
+ <a-input
88
+ v-model="fileName"
89
+ placeholder="请输入文件名"
90
+ @pressEnter="handleSaveConfirm"
91
+ />
92
+ </a-form-item>
93
+ </a-modal>
94
+ </template>
95
+ <a-button type="primary" @click="print">
96
+ 打印
97
+ </a-button>
98
+ <a-button @click="refresh">
99
+ 刷新
100
+ </a-button>
101
+ </a-space>
102
+ <a-dropdown>
103
+ <a-menu slot="overlay" @click="handleExportMenuClick">
104
+ <a-menu-item key="exportPdf">导出为Pdf</a-menu-item>
105
+ <a-menu-item key="exportWord">导出为Word</a-menu-item>
106
+ <a-menu-item key="exportHtmlWithStyle">导出为Html</a-menu-item>
107
+ </a-menu>
108
+ <a-button style="margin-left: 8px"> 导出 <a-icon type="down" /> </a-button>
109
+ </a-dropdown>
110
+ </a-col>
111
+ </a-row>
112
+ <a-divider/>
113
+ <a-spin tip="加载中,马上好" :spinning="loading">
114
+ <iframe
115
+ id="x-editor"
116
+ src="/his/editor/editor.html"
117
+ v-bind="objectOfAttrs"
118
+ @load="onload"
119
+ style="height: calc(-200px - 3rem + 100vh);">
120
+ </iframe>
121
+ </a-spin>
122
+ </div>
123
+ <div v-show="!ready">
124
+ <a-empty description="请选择文书" />
125
+ </div>
126
+ <a-modal
127
+ :destroyOnClose="true"
128
+ :title="this.resDataModalMode === 'modify' ? '修改文档' : '新建文档'"
129
+ :visible="resDataModalVisible"
130
+ okText="提交"
131
+ @cancel="resDataModalVisible = false"
132
+ @ok="onSubmit">
133
+ <a-form-model ref="resModifyForm" :model="modifyResModel" :rules="resRules">
134
+ <a-form-model-item prop="f_file_name" label="文档名">
135
+ <a-input v-model="modifyResModel.f_file_name" placeholder="请输入文档名"/>
136
+ </a-form-model-item>
137
+ </a-form-model>
138
+ </a-modal></div>
139
+ </template>
140
+
141
+ <script>
142
+
143
+ import { runLogic } from '@vue2-client/services/api/common'
144
+ import { initDiagnosisDropdown } from './diagnosisAutocomplete'
145
+
146
+ export default {
147
+ name: 'XHisEditor',
148
+ computed: {
149
+ resListCp () {
150
+ const list = this.resList
151
+ if (this.resId === -1) {
152
+ list.push({
153
+ label: '未保存文档*', value: -1
154
+ })
155
+ }
156
+ return list
157
+ }
158
+ },
159
+ data () {
160
+ return {
161
+ temporaryParameter: {},
162
+ canRecord: false,
163
+ recording: false, // 是否正在录音
164
+ readonly: false,
165
+ ready: false,
166
+ loading: false,
167
+ resDataModalMode: 'modify',
168
+ resDataModalVisible: false,
169
+ saveVisible: false,
170
+ // 使用按钮显隐控制
171
+ // userTemplateVisible: false,
172
+ objectOfAttrs: {
173
+ width: '100%',
174
+ height: '650vh',
175
+ frameborder: 0
176
+ },
177
+ // 数据模式
178
+ modeType: 'form',
179
+ // 是否显示模式切换功能
180
+ showModeChoose: true,
181
+ // 是否作为模板 1 是,0 否
182
+ isTemplate: 0,
183
+ // 模板id
184
+ templateId: undefined,
185
+ admissionId: undefined,
186
+ // 保存类型
187
+ saveType: 'normal',
188
+ fileName: '',
189
+ // 数据模式列表
190
+ modeList: [
191
+ {
192
+ label: '预览',
193
+ value: 'readonly'
194
+ },
195
+ {
196
+ label: '表单',
197
+ value: 'form'
198
+ },
199
+ {
200
+ label: '设计',
201
+ value: 'design'
202
+ }
203
+ ],
204
+ // 编辑器实例
205
+ editorRef: null,
206
+ // 文档资源列表
207
+ resList: [],
208
+ // 文档资源ID
209
+ resId: undefined,
210
+ // 文档链接
211
+ fileUrl: undefined,
212
+ // 文档绑定数据
213
+ bindObject: undefined,
214
+ // 合并模板数据后文档数据
215
+ assignBindObject: undefined,
216
+ // 数据模式 template:模板编辑;data:数据编辑
217
+ dataMode: undefined,
218
+ // 保存数据调用的Logic名称
219
+ saveDataLogicName: undefined,
220
+ // 保存数据调用Logic传入的额外参数
221
+ logicExtraParams: undefined,
222
+ // 服务名
223
+ serviceName: undefined,
224
+ // 当前文档信息
225
+ currResData: {},
226
+ // 切换的文档id
227
+ toggleResId: undefined,
228
+ // 待提交的修改信息
229
+ modifyResModel: {},
230
+ codeData: {},
231
+ resRules: {
232
+ f_file_name: [{ required: true, message: '请输入文档名', trigger: 'blur' }],
233
+ }
234
+ }
235
+ },
236
+ // 初始化 保存后 加载文件后 诊断选择
237
+ emits: ['init', 'saveafter', 'afterLoadFile', 'selected'],
238
+ methods: {
239
+ runLogic,
240
+ /* eslint-disable */
241
+ async initDiagnosisAutocomplete (dropDownBoxParams) {
242
+ console.log('dropDownBoxParams',dropDownBoxParams)
243
+ if (!this.editorRef || !this.editorRef.document) {
244
+ return
245
+ }
246
+
247
+ // 添加参数检查
248
+ if (!dropDownBoxParams || !Array.isArray(dropDownBoxParams) || dropDownBoxParams.length === 0) {
249
+ return
250
+ }
251
+
252
+ // 创建一个简单的自定义事件系统
253
+ // 1. 创建一个隐藏的DOM元素作为事件通道
254
+ const eventChannel = this.editorRef.document.createElement('div');
255
+ eventChannel.id = 'diagnosis-event-channel';
256
+ eventChannel.style.display = 'none';
257
+ this.editorRef.document.body.appendChild(eventChannel);
258
+ // 2. 在iframe文档中监听自定义事件
259
+ const that = this;
260
+ this.editorRef.document.addEventListener('diagnosis-selected', function(e) {
261
+ if (e && e.detail) {
262
+ that.$emit('selected', { item: e.detail, editor: that.editorRef });
263
+ that.codeData = { ...that.codeData, ...{[e.detail.codeKey]: e.detail.code} }
264
+ }
265
+ });
266
+
267
+ for (const param of dropDownBoxParams) {
268
+ if (param.identificationCode && param.dataLogic) {
269
+ try {
270
+ let preliDiagnoData = null
271
+ // 保留获取后端数据的逻辑
272
+ await runLogic(param.dataLogic,
273
+ {}, 'af-his').then(res => {
274
+ preliDiagnoData = res
275
+ })
276
+
277
+ // 创建脚本元素
278
+ const scriptElement = this.editorRef.document.createElement('script')
279
+
280
+ // 注入自定义事件触发函数和初始化代码
281
+ scriptElement.textContent = `
282
+ // 定义一个函数来触发自定义事件
283
+ function triggerDiagnosisSelected(data) {
284
+ const event = new CustomEvent('diagnosis-selected', {
285
+ detail: data,
286
+ bubbles: true
287
+ });
288
+ document.dispatchEvent(event);
289
+ }
290
+
291
+ // 初始化诊断下拉菜单,使用自定义事件触发函数
292
+ (${initDiagnosisDropdown.toString()})(
293
+ editor,
294
+ ${JSON.stringify(preliDiagnoData)},
295
+ '${param.identificationCode}',
296
+ triggerDiagnosisSelected
297
+ );
298
+ `;
299
+
300
+ this.editorRef.document.body.appendChild(scriptElement);
301
+ } catch (error) {
302
+ console.error('初始化诊断自动完成失败:', error);
303
+ }
304
+ }
305
+ }
306
+ },
307
+ showSaveModal (type) {
308
+ this.saveType = type // 记录当前保存类型
309
+ if (type === 'template') {
310
+ this.saveVisible = true
311
+ }else {
312
+ if (this.resId !== -1 || this.resId !== undefined) {
313
+ this.save()
314
+ } else {
315
+ this.openAddResModal()
316
+ }
317
+ }
318
+
319
+ },
320
+ handleSaveConfirm () {
321
+ if (!this.fileName.trim()) {
322
+ this.$message.error('文件名不能为空')
323
+ return
324
+ }
325
+ this.saveAsTemplate()
326
+ },
327
+ /* eslint-disable */
328
+ // 初始化文档
329
+ onload (e) {
330
+ if (e && e.target && e.target.contentWindow) {
331
+ this.editorRef = e.target.contentWindow.editor
332
+ // 等待文档加载完成
333
+ this.$emit('init', {})
334
+ }
335
+ },
336
+ init (params, loadResList = true) {
337
+ console.log("===============>",params)
338
+ this.temporaryParameter = params
339
+ this.canRecord = params.canRecord == undefined || params.canRecord == null? false : params.canRecord
340
+ const {
341
+ fileUrl,
342
+ resId,
343
+ currResData = {},
344
+ bindObject,
345
+ saveDataLogicName,
346
+ logicExtraParams,
347
+ dropDownBoxParams,
348
+ serviceName,
349
+ showModeChoose = true,
350
+ modeType = 'form'
351
+ } = params
352
+ this.resId = resId
353
+ if (bindObject) {
354
+ this.dataMode = 'data'
355
+ this.bindObject = bindObject
356
+ } else {
357
+ this.dataMode = 'template'
358
+ }
359
+ if (logicExtraParams?.admissionId !== undefined && logicExtraParams?.templateId !== undefined) {
360
+ this.admissionId = logicExtraParams.admissionId
361
+ this.templateId = logicExtraParams.templateId
362
+ } else {
363
+ console.warn('病例id:admissionId不存在或模板id:templateId不存在')
364
+ }
365
+ this.saveDataLogicName = saveDataLogicName
366
+ this.logicExtraParams = logicExtraParams
367
+ this.serviceName = serviceName
368
+ this.showModeChoose = showModeChoose
369
+ this.modeType = (modeType === "readonly!" ? "readonly" :modeType)
370
+ this.readonly = (modeType !== "readonly!")
371
+ this.ready = true
372
+ // 先加载文件
373
+ this.loadFile(fileUrl, bindObject, currResData).then(async () => {
374
+ // 文件加载完成后再初始化自动完成
375
+ await this.initDiagnosisAutocomplete(dropDownBoxParams)
376
+ })
377
+ if(loadResList){
378
+ this.loadResList()
379
+ }
380
+ },
381
+ // 加载文档
382
+ loadFile (fileUrl, bindObject, currResData) {
383
+ this.loading = true
384
+ return new Promise((resolve) => {
385
+ this.editorRef.loadUrl(fileUrl).then(() => {
386
+ if (bindObject) {
387
+ this.editorRef.setBindObject(bindObject)
388
+ if (bindObject.template) {
389
+ for (const key of Object.keys(bindObject.template)) {
390
+ this.editorRef.bindDataList(key, bindObject.template[key])
391
+ }
392
+ }
393
+ }
394
+ // 拿取多于模板中的数据
395
+ const diff = this.bindObject? Object.fromEntries(
396
+ Object.entries(this.bindObject)
397
+ .filter(([key]) => !(key in this.editorRef.getBindObject()))
398
+ ) : {}
399
+ this.codeData = {...this.codeData,...diff}
400
+ this.changeMode()
401
+ this.fileUrl = fileUrl
402
+ if (!currResData.f_file_name) {
403
+ currResData.f_file_name = '未命名'
404
+ }
405
+ this.currResData = currResData
406
+ this.loading = false
407
+ this.$emit('afterLoadFile', {})
408
+ resolve()
409
+ })
410
+ })
411
+ },
412
+ // 保存并作为模板
413
+ saveAsTemplate () {
414
+ this.isTemplate = 1
415
+ this.save()
416
+ },
417
+ // 加载文档列表
418
+ loadResList () {
419
+ console.log("getTemplateListLogic=======",this.logicExtraParams)
420
+ runLogic('getTemplateListLogic', this.logicExtraParams, this.serviceName).then(res => {
421
+ this.resList = res
422
+ this.toggleResId = this.resId
423
+ })
424
+ },
425
+ // 修改模式
426
+ changeMode (e) {
427
+ this.editorRef.execCommand(this.modeType)
428
+ },
429
+ // 启动录音功能
430
+ async Recording () {
431
+ this.recording = !this.recording
432
+ if (this.recording) {
433
+ const recording = await this.$recording.startRecording()
434
+ this.$message.warn(recording.msg)
435
+ } else {
436
+ try {
437
+ // 1. 获取录音和接口数据
438
+ const recording = this.$recording.stopRecording()
439
+ this.$message.warn(recording.msg)
440
+ const data = await this.$recording.getRecordingData()
441
+ const result = await this.runLogic('communacation', {record_content: data}, 'af-his')
442
+ // 验证基础结构
443
+ if (!result || typeof result.value !== 'string') {
444
+ throw new Error('接口返回格式错误,缺少有效的value字段')
445
+ }
446
+ // 2. 处理外层JSON字符串(关键修复)
447
+ let outerJsonStr = result.value
448
+ // 修复1:处理布尔值
449
+ outerJsonStr = outerJsonStr.replace(/\bTrue\b/g, 'true')
450
+ // 修复2:移除所有控制字符
451
+ outerJsonStr = outerJsonStr.replace(/[\x00-\x1F]/g, '')
452
+ // 修复3:精准转义data字段内的双引号
453
+ // 匹配 "data": "..." 结构并转义内容中的双引号
454
+ outerJsonStr = outerJsonStr.replace(/"data":\s*"([^"]*)"/g, (match, content) => {
455
+ // 转义内容中的双引号为\"
456
+ const escapedContent = content.replace(/"/g, '\\"')
457
+ return `"data": "${escapedContent}"`
458
+ })
459
+ // 直接在整个字符串里匹配 ```json{...}```
460
+ const regex = /```json([\s\S]*?)```/
461
+ const match = outerJsonStr.match(regex)
462
+ let extractedJsonStr = ''
463
+ if (match && match[1]) {
464
+ extractedJsonStr = match[1].trim()
465
+ }
466
+ const outerObj = JSON.parse(extractedJsonStr)
467
+ console.log("outerObj = ", outerObj)
468
+ this.temporaryParameter.bindObject = {...this.temporaryParameter.bindObject, ...outerObj}
469
+ this.init(this.temporaryParameter)
470
+ } catch (e) {
471
+ console.error('总错误:', e.message)
472
+ this.$message.error(`解析失败: ${e.message}`)
473
+ }
474
+ }
475
+ },
476
+ // 打开文档信息修改面板
477
+ openRenameModal () {
478
+ this.resDataModalMode = 'modify'
479
+ this.modifyResModel = {
480
+ f_file_name: this.currResData.f_file_name
481
+ }
482
+ this.resDataModalVisible = true
483
+ },
484
+ // 提交文档信息修改
485
+ onSubmit () {
486
+ this.$refs.resModifyForm.validate(valid => {
487
+ if (valid) {
488
+ if (this.resDataModalMode === 'modify' && this.modifyResModel.f_file_name === this.currResData.f_file_name) {
489
+ this.$message.warn('新文档名不能与原文档名一致!')
490
+ return false
491
+ }
492
+ this.save()
493
+ return true
494
+ } else {
495
+ return false
496
+ }
497
+ })
498
+ },
499
+ // 打开文档新建面板
500
+ openAddResModal () {
501
+ this.resDataModalMode = 'add'
502
+ this.modifyResModel = {
503
+ f_file_name: undefined
504
+ }
505
+ this.resDataModalVisible = true
506
+ },
507
+ // 新建文档
508
+ addRes () {
509
+ this.$emit('add', {})
510
+ // const params = Object.assign({
511
+ // isAddForce: true
512
+ // }, this.logicExtraParams)
513
+ // this.reload(params)
514
+ },
515
+ // 重新加载
516
+ reload (params) {
517
+ runLogic('getFileInformation', params , this.serviceName).then(res => {
518
+ this.resDataModalVisible = false
519
+ this.assignBindObject = this.assignTemplates(this.bindObject, res.bindObject)
520
+ this.useTemplateData()
521
+ })
522
+ },
523
+ // 合并模板数据
524
+ assignTemplates (newBindObject, templateData) {
525
+ // 检查templates数组是否存在
526
+ if (!templateData.templates || !Array.isArray(templateData.templates)) {
527
+ console.warn('templateData.templates不存在或不是数组')
528
+ return newBindObject
529
+ }
530
+ // 遍历templates数组中的每个属性名
531
+ templateData.templates.forEach(propName => {
532
+ // 检查templateData是否有该属性
533
+ if (propName in templateData) {
534
+ // 无论newBindObject是否有该属性,都进行赋值/添加
535
+ newBindObject[propName] = templateData[propName]
536
+ } else {
537
+ console.warn(`templateData中不存在属性: ${propName}`)
538
+ }
539
+ })
540
+ return newBindObject
541
+ },
542
+ useTemplateData () {
543
+ // 确认是否有合并后的模板数据
544
+ if (!this.assignBindObject) {
545
+ this.$message.warning('没有可用的模板数据');
546
+ return;
547
+ }
548
+ this.editorRef.setBindObject(this.assignBindObject)
549
+ // console.log('resId', this.resId)
550
+ },
551
+ // 切换文档
552
+ changeRes (value) {
553
+ console.log('value', value)
554
+ let params = {
555
+ resId: value
556
+ }
557
+ if (value === -1) {
558
+ params = {
559
+ ...params,
560
+ admissionId: this.admissionId,
561
+ f_template_id: this.templateId
562
+ }
563
+ const that = this
564
+ this.$confirm({
565
+ title: '确认切换文档吗?',
566
+ content: '您有尚未保存的文档,切换文档将丢失所有的修改',
567
+ onOk () {
568
+ that.reload(params)
569
+ // that.userTemplateVisible = true
570
+ },
571
+ onCancel () {
572
+ that.toggleResId = that.resId
573
+ },
574
+ })
575
+ } else {
576
+ const selectedItem = this.resListCp.find(item => item.value === value);
577
+ console.log('selectedItem=================', selectedItem)
578
+ if(selectedItem.templateId != this.templateId){
579
+ runLogic('getFileInformation', selectedItem.params.params , this.serviceName).then(res => {
580
+ this.init({
581
+ modeType: this.modeType,
582
+ fileUrl: res.url,
583
+ resId: res.id,
584
+ currResData: res.currResData,
585
+ bindObject: res.bindObject,
586
+ saveDataLogicName: params?.saveDataLogicName,
587
+ serviceName: this.serviceName,
588
+ logicExtraParams: params?.logicExtraParams,
589
+ dropDownBoxParams: params?.dropDownBoxParams
590
+ }, false)
591
+ })
592
+ }else{
593
+ this.reload({resId: selectedItem.id})
594
+ }
595
+ }
596
+ },
597
+ // 保存文档
598
+ save () {
599
+ // 验证必须输入项
600
+ if (this.editorRef.validate()) {
601
+ // 获取HTML文档和结构化数据(JSON)
602
+ console.log('save',this.editorRef.getBindObject())
603
+ const data = {
604
+ doc: this.editorRef.getHtml(),
605
+ dataObject: {
606
+ ...this.editorRef.getBindObject(),
607
+ ...this.codeData // 合并 codeData 数据
608
+ },
609
+ dataMode: this.dataMode,
610
+ resId: this.resId,
611
+ modifyResModel: this.modifyResModel,
612
+ logicExtraParams: this.logicExtraParams,
613
+ is_template: this.isTemplate,
614
+ f_file_name: this.fileName
615
+ }
616
+ // 保存HTML文档和结构化数据到后端服务
617
+ runLogic(this.saveDataLogicName, data, this.serviceName).then(res => {
618
+ this.$message.success('保存成功')
619
+ this.changeRes(res.currResData.id)
620
+ this.$emit('saveafter', data.dataObject)
621
+ }).finally(() => {
622
+ this.resDataModalVisible = false
623
+ this.saveVisible = false
624
+ })
625
+ } else {
626
+ this.$message.error('请检查未填写的项目')
627
+ }
628
+ },
629
+ // 打印文档
630
+ print () {
631
+ this.editorRef.execCommand('print')
632
+ },
633
+ // 关闭编辑器
634
+ close () {
635
+ this.ready = false
636
+ },
637
+ // 刷新文档
638
+ refresh () {
639
+ this.loadFile(this.fileUrl, this.bindObject, this.currResData)
640
+ },
641
+ // 导出下拉菜单
642
+ handleExportMenuClick (e) {
643
+ const key = e.key
644
+ this.editorRef.execCommand(key)
645
+ }
646
+ }
647
+ }
648
+ </script>
649
+ <style scoped lang="less">
650
+ .editor-action-container {
651
+ height: 40px;
652
+ }
653
+ .editor-action-button {
654
+ .ant-btn-primary {
655
+ background-color: rgb(0, 87, 254) !important;
656
+ }
657
+ }
658
+ :deep(.ant-divider-horizontal) {
659
+ margin: 4px 0;
660
+ }
661
+ /* 组合按钮容器 - 关键修正 */
662
+ .combined-save-btn {
663
+ display: inline-flex;
664
+ height: 32px;
665
+ }
666
+
667
+ /* 主保存按钮 - 保持原有样式 */
668
+ .save-btn-main {
669
+ border-top-right-radius: 0 !important;
670
+ border-bottom-right-radius: 0 !important;
671
+ border-right: none !important;
672
+ height: 32px;
673
+ padding: 0 15px;
674
+ display: inline-flex;
675
+ align-items: center;
676
+ justify-content: center;
677
+ margin-right: -1px; /* 关键:负边距消除间距 */
678
+ }
679
+
680
+ /* 下拉按钮 - 仅调整间距 */
681
+ .dropdown-trigger-btn {
682
+ height: 32px !important;
683
+ width: 24px !important;
684
+ min-width: 24px !important;
685
+ padding: 0 !important;
686
+ border-top-left-radius: 0 !important;
687
+ border-bottom-left-radius: 0 !important;
688
+ border-left: 1px solid rgba(255, 255, 255, 0.3) !important;
689
+ display: inline-flex;
690
+ align-items: center;
691
+ justify-content: center;
692
+ margin-left: 0px;
693
+ }
694
+
695
+ /* 下拉图标保持原样 */
696
+ .dropdown-trigger-btn .anticon {
697
+ font-size: 12px;
698
+ margin: 0 !important;
699
+ }
700
+ .custom-radio-group {
701
+ .ant-radio-button-wrapper-checked {
702
+ background-color: rgb(0, 87, 254) !important;
703
+ }
704
+ }
705
+ </style>