vue2-client 1.13.18 → 1.13.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -162,10 +162,11 @@ export default {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
},
|
|
165
|
-
// 初始化 保存后 加载文件后
|
|
166
|
-
emits: ['init', 'saveafter', 'afterLoadFile'],
|
|
165
|
+
// 初始化 保存后 加载文件后 诊断选择
|
|
166
|
+
emits: ['init', 'saveafter', 'afterLoadFile', 'selected'],
|
|
167
167
|
methods: {
|
|
168
168
|
runLogic,
|
|
169
|
+
/* eslint-disable */
|
|
169
170
|
async initDiagnosisAutocomplete (dropDownBoxParams) {
|
|
170
171
|
if (!this.editorRef || !this.editorRef.document) {
|
|
171
172
|
return
|
|
@@ -176,7 +177,21 @@ export default {
|
|
|
176
177
|
return
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
// 创建一个简单的自定义事件系统
|
|
181
|
+
// 1. 创建一个隐藏的DOM元素作为事件通道
|
|
182
|
+
const eventChannel = this.editorRef.document.createElement('div');
|
|
183
|
+
eventChannel.id = 'diagnosis-event-channel';
|
|
184
|
+
eventChannel.style.display = 'none';
|
|
185
|
+
this.editorRef.document.body.appendChild(eventChannel);
|
|
186
|
+
// 2. 在iframe文档中监听自定义事件
|
|
187
|
+
const that = this;
|
|
188
|
+
this.editorRef.document.addEventListener('diagnosis-selected', function(e) {
|
|
189
|
+
if (e && e.detail) {
|
|
190
|
+
that.$emit('selected', { item: e.detail, editor: that.editorRef });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
for (const param of dropDownBoxParams) {
|
|
180
195
|
if (param.identificationCode && param.dataLogic) {
|
|
181
196
|
try {
|
|
182
197
|
let preliDiagnoData = null
|
|
@@ -185,15 +200,38 @@ export default {
|
|
|
185
200
|
{}, 'af-his').then(res => {
|
|
186
201
|
preliDiagnoData = res
|
|
187
202
|
})
|
|
203
|
+
|
|
204
|
+
// 创建脚本元素
|
|
188
205
|
const scriptElement = this.editorRef.document.createElement('script')
|
|
189
|
-
scriptElement.textContent = `(${initDiagnosisDropdown.toString()})(editor,${JSON.stringify(preliDiagnoData)},'${param.identificationCode}')`
|
|
190
|
-
this.editorRef.document.body.appendChild(scriptElement)
|
|
191
|
-
} catch (error) {
|
|
192
206
|
|
|
207
|
+
// 注入自定义事件触发函数和初始化代码
|
|
208
|
+
scriptElement.textContent = `
|
|
209
|
+
// 定义一个函数来触发自定义事件
|
|
210
|
+
function triggerDiagnosisSelected(data) {
|
|
211
|
+
const event = new CustomEvent('diagnosis-selected', {
|
|
212
|
+
detail: data,
|
|
213
|
+
bubbles: true
|
|
214
|
+
});
|
|
215
|
+
document.dispatchEvent(event);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// 初始化诊断下拉菜单,使用自定义事件触发函数
|
|
219
|
+
(${initDiagnosisDropdown.toString()})(
|
|
220
|
+
editor,
|
|
221
|
+
${JSON.stringify(preliDiagnoData)},
|
|
222
|
+
'${param.identificationCode}',
|
|
223
|
+
triggerDiagnosisSelected
|
|
224
|
+
);
|
|
225
|
+
`;
|
|
226
|
+
|
|
227
|
+
this.editorRef.document.body.appendChild(scriptElement);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error('初始化诊断自动完成失败:', error);
|
|
193
230
|
}
|
|
194
231
|
}
|
|
195
|
-
}
|
|
232
|
+
}
|
|
196
233
|
},
|
|
234
|
+
/* eslint-disable */
|
|
197
235
|
// 初始化文档
|
|
198
236
|
onload (e) {
|
|
199
237
|
if (e && e.target && e.target.contentWindow) {
|
|
@@ -229,9 +267,9 @@ export default {
|
|
|
229
267
|
this.modeType = modeType
|
|
230
268
|
this.ready = true
|
|
231
269
|
// 先加载文件
|
|
232
|
-
this.loadFile(fileUrl, bindObject, currResData).then(() => {
|
|
270
|
+
this.loadFile(fileUrl, bindObject, currResData).then(async () => {
|
|
233
271
|
// 文件加载完成后再初始化自动完成
|
|
234
|
-
this.initDiagnosisAutocomplete(dropDownBoxParams)
|
|
272
|
+
await this.initDiagnosisAutocomplete(dropDownBoxParams)
|
|
235
273
|
})
|
|
236
274
|
this.loadResList()
|
|
237
275
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export function initDiagnosisDropdown (editor, data, identificationCode, emitFunc) {
|
|
2
3
|
if (typeof editor === 'undefined' || !editor.$) {
|
|
3
4
|
return
|
|
4
5
|
}
|
|
@@ -213,6 +214,27 @@ export function initDiagnosisDropdown (editor, data, identificationCode) {
|
|
|
213
214
|
e.stopPropagation()
|
|
214
215
|
if (isEditableMode()) {
|
|
215
216
|
const name = editor.$(this).find('.ant-list-item-title').text()
|
|
217
|
+
const code = editor.$(this).find('.ant-list-item-description').text()
|
|
218
|
+
// 根据选中的name和code查找完整数据
|
|
219
|
+
const selectedItem = mockDiagnosisList.find(item =>
|
|
220
|
+
item.name === name && item.code === code
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
// 打印完整数据,包括id、name和code
|
|
224
|
+
if (selectedItem) {
|
|
225
|
+
// 使用传入的emit函数触发事件
|
|
226
|
+
if (typeof emitFunc === 'function') {
|
|
227
|
+
// 只传递数据参数,不再传递事件名
|
|
228
|
+
emitFunc(selectedItem)
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
// 如果找不到完整数据,至少打印出已知信息
|
|
232
|
+
// 使用传入的emit函数触发事件,发送部分数据
|
|
233
|
+
if (typeof emitFunc === 'function') {
|
|
234
|
+
// 只传递数据参数,不再传递事件名
|
|
235
|
+
emitFunc({name, code, element: identificationCode})
|
|
236
|
+
}
|
|
237
|
+
}
|
|
216
238
|
fieldElement.textContent = name
|
|
217
239
|
dropdownList.style.display = 'none'
|
|
218
240
|
fieldElement.focus()
|