vue2-client 1.14.18 → 1.14.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.
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
- attr: 用于传递参数绑定到 modal 弹框上
|
|
18
18
|
- getOutEnv 获取获取 outEnv
|
|
19
19
|
- this.getRealKeyData(obj) 获取真实的数据 传递 {a_a:"1"} 返回 {a:"1"}
|
|
20
|
+
- this.currUser.operaInfo 获取当前用户信息
|
|
20
21
|
|
|
21
22
|
```js
|
|
22
23
|
this.openDialog('xxx', 5, {}, {}, {})
|
|
@@ -58,6 +59,7 @@ this.openDialog('xxx', 5, {}, {}, {})
|
|
|
58
59
|
- curdAddBefore(func) 点击新增按钮时触发 传参为 打开新增表单函数
|
|
59
60
|
afterDelete( res (删除接口返回数据)) 删除后触发
|
|
60
61
|
action(record (当前记录), id (当前记录主键), actionType (操作类型)) 操作按钮触发
|
|
62
|
+
- expandedGrid:"栅格名"
|
|
61
63
|
|
|
62
64
|
# x-report 插槽 使用说明
|
|
63
65
|
|
|
@@ -102,7 +104,7 @@ function() {
|
|
|
102
104
|
### 获取表单数据之后 提交 执行logic写法
|
|
103
105
|
|
|
104
106
|
```js
|
|
105
|
-
function() {
|
|
107
|
+
function () {
|
|
106
108
|
// 获取主formtable组件
|
|
107
109
|
const res = await this.getComponentByName('from').asyncSubmit()
|
|
108
110
|
// 把组件当前选中的项及select_id传给后台业务逻辑
|
|
@@ -113,7 +115,7 @@ function() {
|
|
|
113
115
|
### OpenDialog 弹框确认事件
|
|
114
116
|
|
|
115
117
|
```js
|
|
116
|
-
function() {
|
|
118
|
+
function () {
|
|
117
119
|
// 获取主formtable组件 在OpenDialog 事件中使用 getComponentByName 获取 既可以获取到打开的栅格中的组件对象,也可以获取到上级调用这个栅格的栅格的对象
|
|
118
120
|
const res = this.getComponentByName('main')
|
|
119
121
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref, reactive, watch } from 'vue'
|
|
3
3
|
import { message } from 'ant-design-vue'
|
|
4
|
-
import { runLogic } from '
|
|
4
|
+
import { runLogic } from '@vue2-client/services/api/common'
|
|
5
5
|
|
|
6
6
|
// 定义组件属性
|
|
7
7
|
const props = defineProps({
|
|
8
8
|
visible: Boolean,
|
|
9
9
|
id: {
|
|
10
|
-
type:
|
|
11
|
-
default:
|
|
10
|
+
type: Number,
|
|
11
|
+
default: 180
|
|
12
12
|
},
|
|
13
13
|
modalType: {
|
|
14
14
|
type: String,
|
|
@@ -10,14 +10,32 @@
|
|
|
10
10
|
<a-button-group style="margin: 0 20px;">
|
|
11
11
|
<a-button plain type="primary" @click="showVitalSignsModal('baby')" :loading="loading" :disabled="!editorReady">新生儿体温单</a-button>
|
|
12
12
|
</a-button-group>
|
|
13
|
-
<a-button-group style="margin
|
|
13
|
+
<a-button-group style="margin: 0 20px;">
|
|
14
14
|
<a-button plain type="primary" @click="execCommand('preview')" :loading="loading" :disabled="!editorReady">打印预览</a-button>
|
|
15
15
|
<a-button plain type="primary" @click="execCommand('print')" :loading="loading" :disabled="!editorReady">打印</a-button>
|
|
16
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>
|
|
17
26
|
</a-row>
|
|
18
27
|
<div v-if="!editorReady" style="margin: 10px 0; padding: 10px; background-color: #fffbe6; border: 1px solid #ffe58f;">
|
|
19
28
|
<a-icon type="loading" /> 体温单编辑器加载中...
|
|
20
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
|
+
|
|
21
39
|
<Editor @editor-ready="onEditorReady" style="margin: 10px 0;" ref="editorComponent"></Editor>
|
|
22
40
|
|
|
23
41
|
<!-- 使用TextBox组件替代原有弹窗 -->
|
|
@@ -26,7 +44,7 @@
|
|
|
26
44
|
:modalType="modalType"
|
|
27
45
|
:initialId="vitalSignsId"
|
|
28
46
|
:editorReady="editorReady"
|
|
29
|
-
:id="vitalSignsId"
|
|
47
|
+
:id="Number(vitalSignsId) || 180"
|
|
30
48
|
@submit="handleSubmit"
|
|
31
49
|
@cancel="closeModal"
|
|
32
50
|
/>
|
|
@@ -35,8 +53,8 @@
|
|
|
35
53
|
|
|
36
54
|
<script setup>
|
|
37
55
|
import { ref, onMounted } from 'vue'
|
|
38
|
-
import Editor from '
|
|
39
|
-
import TextBox from '
|
|
56
|
+
import Editor from './editor.vue'
|
|
57
|
+
import TextBox from './textBox.vue'
|
|
40
58
|
import { message } from 'ant-design-vue'
|
|
41
59
|
|
|
42
60
|
// 响应式状态
|
|
@@ -46,6 +64,7 @@ const editorReady = ref(false)
|
|
|
46
64
|
const editorComponent = ref(null)
|
|
47
65
|
const modalVisible = ref(false)
|
|
48
66
|
const modalType = ref('create')
|
|
67
|
+
const generating = ref(false) // 添加体温单生成中状态
|
|
49
68
|
let editor = null
|
|
50
69
|
// 定义组件事件
|
|
51
70
|
const emit = defineEmits(['submit'])
|
|
@@ -107,27 +126,170 @@ const execCommand = (cmd) => {
|
|
|
107
126
|
}
|
|
108
127
|
}
|
|
109
128
|
|
|
110
|
-
//
|
|
129
|
+
// 清空体温单
|
|
130
|
+
const clearVitalSigns = async () => {
|
|
131
|
+
if (!editorReady.value || !editor) {
|
|
132
|
+
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
loading.value = true
|
|
137
|
+
generating.value = true
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
// 重新加载editor.html页面来完全重置编辑器
|
|
141
|
+
try {
|
|
142
|
+
const iframe = editorComponent.value.$refs.editorIframe
|
|
143
|
+
if (iframe) {
|
|
144
|
+
// 保存当前src
|
|
145
|
+
const currentSrc = iframe.src
|
|
146
|
+
// 确认提示
|
|
147
|
+
message.loading('正在清空体温单...', 1)
|
|
148
|
+
// 重新加载iframe
|
|
149
|
+
iframe.onload = async () => {
|
|
150
|
+
try {
|
|
151
|
+
// 等待iframe重新加载完成
|
|
152
|
+
await new Promise(resolve => setTimeout(resolve, 500))
|
|
153
|
+
|
|
154
|
+
// 获取新的editor对象
|
|
155
|
+
const newEditorObj = iframe.contentWindow.editor
|
|
156
|
+
if (newEditorObj) {
|
|
157
|
+
// 等待editor初始化
|
|
158
|
+
if (typeof newEditorObj.init === 'function') {
|
|
159
|
+
await new Promise((resolve) => {
|
|
160
|
+
const checkInterval = setInterval(() => {
|
|
161
|
+
if (newEditorObj.isReady) {
|
|
162
|
+
clearInterval(checkInterval)
|
|
163
|
+
resolve()
|
|
164
|
+
}
|
|
165
|
+
}, 100)
|
|
166
|
+
|
|
167
|
+
// 最多等待5秒
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
clearInterval(checkInterval)
|
|
170
|
+
resolve()
|
|
171
|
+
}, 5000)
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 更新全局editor引用
|
|
176
|
+
editor = newEditorObj
|
|
177
|
+
window.iframeEditor = newEditorObj
|
|
178
|
+
} else {
|
|
179
|
+
throw new Error('重新加载后无法获取editor对象')
|
|
180
|
+
}
|
|
181
|
+
} catch (err) {
|
|
182
|
+
console.error('重新加载iframe后清空体温单出错:', err)
|
|
183
|
+
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
|
184
|
+
} finally {
|
|
185
|
+
loading.value = false
|
|
186
|
+
generating.value = false
|
|
187
|
+
// 移除临时onload处理器
|
|
188
|
+
iframe.onload = null
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 重新加载iframe
|
|
193
|
+
iframe.src = currentSrc + '?t=' + new Date().getTime()
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
} catch (reloadErr) {
|
|
197
|
+
console.warn('重新加载iframe失败,将尝试其他方法清空体温单:', reloadErr)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// 备用清空方法
|
|
201
|
+
try {
|
|
202
|
+
const iframe = editorComponent.value.$refs.editorIframe
|
|
203
|
+
if (iframe?.contentWindow) {
|
|
204
|
+
iframe.contentWindow.eval(`
|
|
205
|
+
try {
|
|
206
|
+
// 尝试使用编辑器提供的各种可能的清空方法
|
|
207
|
+
if (editor) {
|
|
208
|
+
if (typeof editor.loadUrl === 'function') {
|
|
209
|
+
editor.loadUrl('');
|
|
210
|
+
} else if (typeof editor.resetDocument === 'function') {
|
|
211
|
+
editor.resetDocument();
|
|
212
|
+
} else if (typeof editor.clearContent === 'function') {
|
|
213
|
+
editor.clearContent();
|
|
214
|
+
} else if (typeof editor.clear === 'function') {
|
|
215
|
+
editor.clear();
|
|
216
|
+
} else if (typeof editor.setEditorContent === 'function') {
|
|
217
|
+
editor.setEditorContent('');
|
|
218
|
+
} else if (editor.document) {
|
|
219
|
+
try {
|
|
220
|
+
editor.document.body.innerHTML = '';
|
|
221
|
+
} catch(clearErr) {
|
|
222
|
+
console.warn('清空编辑器内容失败');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
} catch(e) {
|
|
227
|
+
console.error('清空体温单失败:', e);
|
|
228
|
+
}
|
|
229
|
+
`)
|
|
230
|
+
} else if (window.iframeEditor) {
|
|
231
|
+
const editorObj = window.iframeEditor
|
|
232
|
+
if (typeof editorObj.loadUrl === 'function') {
|
|
233
|
+
editorObj.loadUrl('')
|
|
234
|
+
} else if (typeof editorObj.resetDocument === 'function') {
|
|
235
|
+
editorObj.resetDocument()
|
|
236
|
+
} else if (typeof editorObj.clearContent === 'function') {
|
|
237
|
+
editorObj.clearContent()
|
|
238
|
+
} else if (typeof editorObj.clear === 'function') {
|
|
239
|
+
editorObj.clear()
|
|
240
|
+
} else if (typeof editorObj.setEditorContent === 'function') {
|
|
241
|
+
editorObj.setEditorContent('')
|
|
242
|
+
}
|
|
243
|
+
} else if (editor) {
|
|
244
|
+
if (typeof editor.loadUrl === 'function') {
|
|
245
|
+
editor.loadUrl('')
|
|
246
|
+
} else if (typeof editor.resetDocument === 'function') {
|
|
247
|
+
editor.resetDocument()
|
|
248
|
+
} else if (typeof editor.clearContent === 'function') {
|
|
249
|
+
editor.clearContent()
|
|
250
|
+
} else if (typeof editor.clear === 'function') {
|
|
251
|
+
editor.clear()
|
|
252
|
+
} else if (typeof editor.setEditorContent === 'function') {
|
|
253
|
+
editor.setEditorContent('')
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
throw new Error('无法获取编辑器对象')
|
|
257
|
+
}
|
|
258
|
+
} catch (err) {
|
|
259
|
+
console.error('清空体温单出错:', err)
|
|
260
|
+
message.error(`清空体温单失败: ${err.message || '未知错误'}`)
|
|
261
|
+
}
|
|
262
|
+
} finally {
|
|
263
|
+
loading.value = false
|
|
264
|
+
generating.value = false
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// 处理表单提交(修改为直接叠加创建,无需清空)
|
|
111
269
|
const handleSubmit = async (formData) => {
|
|
112
270
|
if (!editorReady.value || !editor) {
|
|
113
|
-
message.error('
|
|
271
|
+
message.error('体温单编辑器未加载完成,请等待或刷新页面重试')
|
|
114
272
|
return
|
|
115
273
|
}
|
|
116
274
|
loading.value = true
|
|
275
|
+
generating.value = true // 开始生成,显示加载遮罩
|
|
276
|
+
|
|
117
277
|
try {
|
|
118
|
-
//
|
|
278
|
+
// 简化代码,直接在现有体温单上创建新的体温单(不再清空)
|
|
119
279
|
let result
|
|
120
280
|
try {
|
|
121
281
|
const iframe = editorComponent.value.$refs.editorIframe
|
|
122
282
|
if (iframe?.contentWindow) {
|
|
123
283
|
const dataStr = JSON.stringify(formData)
|
|
124
|
-
const script = `
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
284
|
+
const script = `
|
|
285
|
+
try {
|
|
286
|
+
const data = JSON.parse('${dataStr.replace(/'/g, "\\'")}');
|
|
287
|
+
return editor.createVitalSigns(data);
|
|
288
|
+
} catch(e) {
|
|
289
|
+
console.error('iframe执行错误:', e);
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
`
|
|
131
293
|
result = iframe.contentWindow.eval(script)
|
|
132
294
|
} else if (window.iframeEditor) {
|
|
133
295
|
result = window.iframeEditor.createVitalSigns(formData)
|
|
@@ -142,6 +304,7 @@ const handleSubmit = async (formData) => {
|
|
|
142
304
|
throw new Error('无法调用createVitalSigns方法')
|
|
143
305
|
}
|
|
144
306
|
}
|
|
307
|
+
|
|
145
308
|
vitalSignsId.value = result || formData.id
|
|
146
309
|
modalVisible.value = false
|
|
147
310
|
message.success(`${modalTitles[modalType.value]}成功`)
|
|
@@ -151,6 +314,7 @@ const handleSubmit = async (formData) => {
|
|
|
151
314
|
message.error(`创建体温单失败: ${err.message || '未知错误'}`)
|
|
152
315
|
} finally {
|
|
153
316
|
loading.value = false
|
|
317
|
+
generating.value = false // 无论成功失败,都结束加载遮罩
|
|
154
318
|
}
|
|
155
319
|
}
|
|
156
320
|
|
|
@@ -178,4 +342,32 @@ onMounted(() => {
|
|
|
178
342
|
align-items: center;
|
|
179
343
|
padding: 1%;
|
|
180
344
|
}
|
|
345
|
+
|
|
346
|
+
/* 体温单生成加载遮罩样式 */
|
|
347
|
+
.generating-mask {
|
|
348
|
+
position: fixed;
|
|
349
|
+
top: 0;
|
|
350
|
+
left: 0;
|
|
351
|
+
right: 0;
|
|
352
|
+
bottom: 0;
|
|
353
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
354
|
+
display: flex;
|
|
355
|
+
justify-content: center;
|
|
356
|
+
align-items: center;
|
|
357
|
+
z-index: 9999;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.generating-content {
|
|
361
|
+
background-color: white;
|
|
362
|
+
padding: 20px 40px;
|
|
363
|
+
border-radius: 4px;
|
|
364
|
+
text-align: center;
|
|
365
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.generating-text {
|
|
369
|
+
margin-top: 16px;
|
|
370
|
+
color: rgba(0, 0, 0, 0.85);
|
|
371
|
+
font-size: 16px;
|
|
372
|
+
}
|
|
181
373
|
</style>
|