vue2-client 1.18.69 → 1.19.0

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.
@@ -1,113 +1,113 @@
1
- <template>
2
- <!-- 根据实际部署环境修改 editor.html 的路径 -->
3
- <iframe
4
- src="/his/editor/editor.html"
5
- width="100%"
6
- height="800"
7
- frameborder="0"
8
- @load="onIframeLoad"
9
- ref="editorIframe">
10
- </iframe>
11
- </template>
12
-
13
- <script setup>
14
-
15
- import { ref, onBeforeUnmount } from 'vue'
16
-
17
- const editorIframe = ref(null)
18
- const checkEditorTimer = ref(null)
19
- const checkCount = ref(0)
20
- const editor = ref(null)
21
- const iframeWindow = ref(null)
22
- // 对外暴露的获取editor方法
23
- const getEditor = () => {
24
- if (editor.value) {
25
- return editor.value
26
- }
27
- if (iframeWindow.value && iframeWindow.value.editor) {
28
- editor.value = iframeWindow.value.editor
29
- return editor.value
30
- }
31
- if (editorIframe.value && editorIframe.value.contentWindow && editorIframe.value.contentWindow.editor) {
32
- editor.value = editorIframe.value.contentWindow.editor
33
- return editor.value
34
- }
35
- return null
36
- }
37
- // 创建体温单方法
38
- const createVitalSigns = (data) => {
39
- const editorObj = getEditor()
40
- if (!editorObj) {
41
- throw new Error('editor对象未初始化,无法创建体温单')
42
- }
43
- if (typeof editorObj.createVitalSigns === 'function') {
44
- return editorObj.createVitalSigns(data)
45
- } else {
46
- throw new Error('editor对象未包含createVitalSigns方法')
47
- }
48
- }
49
-
50
- // 检查editor对象是否已初始化
51
- const startEditorCheck = (frameWindow, iframe) => {
52
- if (checkEditorTimer.value) {
53
- clearInterval(checkEditorTimer.value)
54
- }
55
- checkCount.value = 0
56
- checkEditorTimer.value = setInterval(() => {
57
- checkCount.value++
58
- try {
59
- const editorObj = frameWindow.editor
60
- if (editorObj && typeof editorObj.createVitalSigns === 'function') {
61
- clearInterval(checkEditorTimer.value)
62
- editor.value = editorObj
63
- // 将editor对象暴露到全局
64
- window.iframeEditor = editorObj
65
- window.iframeWindow = frameWindow
66
- // 触发事件
67
- emit('editor-ready', editorObj)
68
- emit('load', { target: iframe, editor: editorObj })
69
- // 发送消息通知
70
- window.parent.postMessage({ type: 'editorReady' }, '*')
71
- }
72
- } catch (err) {
73
- console.error('检查editor对象时出错:', err)
74
- }
75
- if (checkCount.value >= 20) {
76
- clearInterval(checkEditorTimer.value)
77
- console.error('Editor 对象加载失败')
78
- }
79
- }, 500)
80
- }
81
- // iframe加载完成的处理
82
- const onIframeLoad = (e) => {
83
- const iframe = e.target
84
- const frameWindow = iframe.contentWindow
85
- iframeWindow.value = frameWindow
86
- if (!frameWindow) {
87
- console.error('无法访问 iframe 内容')
88
- return
89
- }
90
- // 关闭文书工具栏
91
- iframe.contentWindow.editor.option.toolbar = false
92
- startEditorCheck(frameWindow, iframe)
93
- }
94
- // 组件销毁前清理
95
- onBeforeUnmount(() => {
96
- if (checkEditorTimer.value) {
97
- clearInterval(checkEditorTimer.value)
98
- }
99
- })
100
- // 暴露方法给父组件
101
- defineExpose({ getEditor, createVitalSigns })
102
-
103
- // 定义事件
104
- const emit = defineEmits(['editor-ready', 'load'])
105
- </script>
106
-
107
- <style scoped>
108
- iframe {
109
- border: none;
110
- width: 100%;
111
- min-height: 800px;
112
- }
113
- </style>
1
+ <template>
2
+ <!-- 根据实际部署环境修改 editor.html 的路径 -->
3
+ <iframe
4
+ src="/his/editor/editor.html"
5
+ width="100%"
6
+ height="800"
7
+ frameborder="0"
8
+ @load="onIframeLoad"
9
+ ref="editorIframe">
10
+ </iframe>
11
+ </template>
12
+
13
+ <script setup>
14
+
15
+ import { ref, onBeforeUnmount } from 'vue'
16
+
17
+ const editorIframe = ref(null)
18
+ const checkEditorTimer = ref(null)
19
+ const checkCount = ref(0)
20
+ const editor = ref(null)
21
+ const iframeWindow = ref(null)
22
+ // 对外暴露的获取editor方法
23
+ const getEditor = () => {
24
+ if (editor.value) {
25
+ return editor.value
26
+ }
27
+ if (iframeWindow.value && iframeWindow.value.editor) {
28
+ editor.value = iframeWindow.value.editor
29
+ return editor.value
30
+ }
31
+ if (editorIframe.value && editorIframe.value.contentWindow && editorIframe.value.contentWindow.editor) {
32
+ editor.value = editorIframe.value.contentWindow.editor
33
+ return editor.value
34
+ }
35
+ return null
36
+ }
37
+ // 创建体温单方法
38
+ const createVitalSigns = (data) => {
39
+ const editorObj = getEditor()
40
+ if (!editorObj) {
41
+ throw new Error('editor对象未初始化,无法创建体温单')
42
+ }
43
+ if (typeof editorObj.createVitalSigns === 'function') {
44
+ return editorObj.createVitalSigns(data)
45
+ } else {
46
+ throw new Error('editor对象未包含createVitalSigns方法')
47
+ }
48
+ }
49
+
50
+ // 检查editor对象是否已初始化
51
+ const startEditorCheck = (frameWindow, iframe) => {
52
+ if (checkEditorTimer.value) {
53
+ clearInterval(checkEditorTimer.value)
54
+ }
55
+ checkCount.value = 0
56
+ checkEditorTimer.value = setInterval(() => {
57
+ checkCount.value++
58
+ try {
59
+ const editorObj = frameWindow.editor
60
+ if (editorObj && typeof editorObj.createVitalSigns === 'function') {
61
+ clearInterval(checkEditorTimer.value)
62
+ editor.value = editorObj
63
+ // 将editor对象暴露到全局
64
+ window.iframeEditor = editorObj
65
+ window.iframeWindow = frameWindow
66
+ // 触发事件
67
+ emit('editor-ready', editorObj)
68
+ emit('load', { target: iframe, editor: editorObj })
69
+ // 发送消息通知
70
+ window.parent.postMessage({ type: 'editorReady' }, '*')
71
+ }
72
+ } catch (err) {
73
+ console.error('检查editor对象时出错:', err)
74
+ }
75
+ if (checkCount.value >= 20) {
76
+ clearInterval(checkEditorTimer.value)
77
+ console.error('Editor 对象加载失败')
78
+ }
79
+ }, 500)
80
+ }
81
+ // iframe加载完成的处理
82
+ const onIframeLoad = (e) => {
83
+ const iframe = e.target
84
+ const frameWindow = iframe.contentWindow
85
+ iframeWindow.value = frameWindow
86
+ if (!frameWindow) {
87
+ console.error('无法访问 iframe 内容')
88
+ return
89
+ }
90
+ // 关闭文书工具栏
91
+ iframe.contentWindow.editor.option.toolbar = false
92
+ startEditorCheck(frameWindow, iframe)
93
+ }
94
+ // 组件销毁前清理
95
+ onBeforeUnmount(() => {
96
+ if (checkEditorTimer.value) {
97
+ clearInterval(checkEditorTimer.value)
98
+ }
99
+ })
100
+ // 暴露方法给父组件
101
+ defineExpose({ getEditor, createVitalSigns })
102
+
103
+ // 定义事件
104
+ const emit = defineEmits(['editor-ready', 'load'])
105
+ </script>
106
+
107
+ <style scoped>
108
+ iframe {
109
+ border: none;
110
+ width: 100%;
111
+ min-height: 800px;
112
+ }
113
+ </style>
@@ -1,131 +1,146 @@
1
- import { manageApi, post } from '@vue2-client/services/api'
1
+ import { manageApi } from '@vue2-client/services/api'
2
2
  import { handleTree } from '@vue2-client/utils/util'
3
3
  import { indexedDB } from '@vue2-client/utils/indexedDB'
4
4
  import { getConfigByName } from '@vue2-client/services/api/common'
5
5
 
6
+ // 字典缓存
7
+ const dictCache = new Map()
8
+
6
9
  const GetAppDataService = {
7
10
  install (Vue) {
8
- // 给vue增添对话框显示方法
9
11
  Vue.$appdata = Vue.prototype.$appdata = GetAppDataService
10
12
  },
13
+
11
14
  async load () {
12
- const params = {}
13
- await post(manageApi.getDictionaryValue, {}).then((res) => {
14
- Object.assign(params, res)
15
- const badgeItemArray = {}
16
- for (const key of Object.keys(params)) {
17
- badgeItemArray[key] = {}
18
- for (const item of params[key]) {
19
- let status
20
- if (!item.status) {
21
- status = 'none'
22
- } else {
23
- status = item.status
24
- }
25
- badgeItemArray[key][item.value] = {
26
- status: status,
27
- text: item.text
28
- }
29
- }
30
- }
31
- // 追加参数
32
- localStorage.setItem(process.env.VUE_APP_DICTIONARY_KEY, JSON.stringify(params))
33
- localStorage.setItem(process.env.VUE_APP_BADGE_KEY, JSON.stringify(badgeItemArray))
34
- })
15
+ localStorage.setItem(
16
+ process.env.VUE_APP_DICTIONARY_KEY,
17
+ JSON.stringify({})
18
+ )
19
+ localStorage.setItem(
20
+ process.env.VUE_APP_BADGE_KEY,
21
+ JSON.stringify({})
22
+ )
35
23
  },
24
+
36
25
  // 返回树形省市区
37
26
  async getDivisionsOhChinaForTree () {
38
- // 获取省市区数据
39
27
  return new Promise((resolve, reject) => {
40
28
  try {
41
- indexedDB.getByWeb('divisionsOhChina', manageApi.getDivisionsOhChina, {}, res => {
42
- resolve(res)
43
- }, processRes => {
44
- return handleTree(processRes, 'code', 'parentcode')
45
- })
29
+ indexedDB.getByWeb(
30
+ 'divisionsOhChina',
31
+ manageApi.getDivisionsOhChina,
32
+ {},
33
+ res => resolve(res),
34
+ processRes => handleTree(processRes, 'code', 'parentcode')
35
+ )
46
36
  } catch (e) {
47
37
  reject(e)
48
38
  }
49
39
  })
50
40
  },
51
- // 旧版获取配置中心字典
52
- getDictionaryList (key) {
53
- const str = localStorage.getItem(process.env.VUE_APP_DICTIONARY_KEY)
54
- const object = JSON.parse(str)
55
- return object[key]
56
- },
57
- async getDictValue (dictKey, value, func, isDev = false, serviceName = process.env.VUE_APP_SYSTEM_NAME) {
58
- const processResult = (result) => {
59
- if (!result.value) {
60
- return {
61
- status: 'none',
62
- text: value
63
- }
64
- }
65
- const item = result.value.find(item => item.value == value)
66
- if (item) {
67
- return {
68
- status: item.status || 'none',
69
- text: item.label
70
- }
71
- }
41
+ // 用于徽标解析字典值
42
+ parseDictValue (dictList, value) {
43
+ if (!Array.isArray(dictList)) {
72
44
  return {
73
45
  status: 'none',
74
46
  text: value
75
47
  }
76
48
  }
77
- if (func) {
78
- getConfigByName(dictKey, serviceName, result => {
79
- func(processResult(result))
80
- }, isDev)
49
+
50
+ const item = dictList.find(i => i.value == value)
51
+ if (item) {
52
+ return {
53
+ status: item.status || 'none',
54
+ text: item.label
55
+ }
56
+ }
57
+
58
+ return {
59
+ status: 'none',
60
+ text: value
61
+ }
62
+ },
63
+
64
+ // 获取徽标字典值
65
+ async getDictValue (
66
+ dictKey,
67
+ value,
68
+ callback,
69
+ isDev = false,
70
+ serviceName = process.env.VUE_APP_SYSTEM_NAME
71
+ ) {
72
+ const dictList = await this.getDictByKeyAsync(
73
+ dictKey,
74
+ serviceName,
75
+ isDev
76
+ )
77
+ const result = this.parseDictValue(dictList, value)
78
+
79
+ if (typeof callback === 'function') {
80
+ callback(result)
81
81
  } else {
82
- const result = await new Promise((resolve) => {
83
- getConfigByName(dictKey, serviceName, resolve, isDev)
84
- })
85
- return processResult(result)
82
+ return result
86
83
  }
87
84
  },
85
+
88
86
  // 获取琉璃字典(Callback 版本)
89
- getDictByKey(dictKey, serviceName, callback, isDev) {
90
- this.getDictByKeyAsync(dictKey, serviceName, isDev).then(callback)
91
- },
92
- // 获取琉璃字典(Promise 版本)
93
- getDictByKeyAsync(dictKey, serviceName = process.env.VUE_APP_SYSTEM_NAME, isDev) {
94
- return new Promise(resolve => {
95
- getConfigByName(dictKey, serviceName, res => resolve(res.value), isDev)
96
- })
87
+ getDictByKey (dictKey, serviceName, callback, isDev) {
88
+ this.getDictByKeyAsync(dictKey, serviceName, isDev)
89
+ .then(res => {
90
+ if (typeof callback === 'function') {
91
+ callback(res)
92
+ }
93
+ })
97
94
  },
98
95
 
99
- getParam (key, value, callback) {
100
- const str = localStorage.getItem(process.env.VUE_APP_BADGE_KEY)
101
- const object = JSON.parse(str)
102
- if (object && object[key]) {
103
- const result = object[key]
104
- if (Object.prototype.hasOwnProperty.call(result, value)) {
105
- return result[value]
106
- } else {
107
- return { status: 'none', text: value }
108
- }
96
+ // 获取琉璃字典(Promise 版本,核心实现)
97
+ async getDictByKeyAsync (
98
+ dictKey,
99
+ serviceName = process.env.VUE_APP_SYSTEM_NAME,
100
+ isDev = false
101
+ ) {
102
+ const cacheKey = `${serviceName}:${dictKey}`
103
+
104
+ if (dictCache.has(cacheKey)) {
105
+ return dictCache.get(cacheKey)
109
106
  }
110
- return null
107
+
108
+ const dictList = await new Promise(resolve => {
109
+ getConfigByName(
110
+ dictKey,
111
+ serviceName,
112
+ res => resolve(res?.value || []),
113
+ isDev
114
+ )
115
+ })
116
+
117
+ dictCache.set(cacheKey, dictList)
118
+ return dictList
111
119
  },
120
+
112
121
  getParams () {
113
122
  const str = localStorage.getItem(process.env.VUE_APP_DICTIONARY_KEY)
114
- return JSON.parse(str)
123
+ return str ? JSON.parse(str) : {}
115
124
  },
125
+
116
126
  getSingleValues () {
117
127
  const str = localStorage.getItem(process.env.VUE_APP_BADGE_KEY)
118
- return JSON.parse(str)
128
+ return str ? JSON.parse(str) : {}
119
129
  },
130
+
120
131
  getWebConfigByKey (key) {
121
132
  const str = localStorage.getItem(process.env.VUE_APP_WEB_CONFIG_KEY)
133
+ if (!str) return undefined
122
134
  const object = JSON.parse(str)
123
- return object[key]
135
+ return object?.[key]
124
136
  },
137
+
125
138
  getStylesByKey (key) {
126
139
  const str = localStorage.getItem(process.env.VUE_APP_WEB_STYLES_KEY)
140
+ if (!str) return undefined
127
141
  const object = JSON.parse(str)
128
- return object[key]
129
- },
142
+ return object?.[key]
143
+ }
130
144
  }
145
+
131
146
  export default GetAppDataService
@@ -1125,7 +1125,7 @@ export default {
1125
1125
  if (stepDefine.formType === 'select') {
1126
1126
  let dictList
1127
1127
  if (stepDefine.selectType === 'key') {
1128
- dictList = this.$appdata.getDictionaryList(stepDefine.selectKey)
1128
+ dictList = []
1129
1129
  } else if (stepDefine.selectType === 'config') {
1130
1130
  const configName = stepDefine.selectKey.substring(7)
1131
1131
  dictList = await this.$appdata.getDictByKeyAsync(configName)
@@ -787,7 +787,7 @@ export default {
787
787
  if (stepDefine.formType === 'select') {
788
788
  let dictList
789
789
  if (stepDefine.selectType === 'key') {
790
- dictList = this.$appdata.getDictionaryList(stepDefine.selectKey)
790
+ dictList = []
791
791
  } else if (stepDefine.selectType === 'config') {
792
792
  const configName = stepDefine.selectKey.substring(7)
793
793
  dictList = await this.$appdata.getDictByKeyAsync(configName)
@@ -1,45 +1,45 @@
1
- <script>
2
- export default {
3
- name: 'ExceptionQuery',
4
- components: {
5
- XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue')
6
- },
7
- props: {
8
- currUserInfo: {
9
- type: Object,
10
- default: () => undefined
11
- }
12
- },
13
- mounted () {
14
- this.$refs.xFormTable.refresh(true)
15
- },
16
- data () {
17
- return {
18
- // 查询配置名称
19
- queryParamsName: 'ExceptionRecordQueryCRUD',
20
- fixedQueryForm: { ex_f_userfiles_id: this.currUserInfo.f_userfiles_id },
21
- // 新增表单固定值
22
- fixedAddForm: {},
23
- // 是否显示详情抽屉
24
- detailVisible: false,
25
- // 当前记录
26
- record: {}
27
- }
28
- }
29
- }
30
- </script>
31
-
32
- <template>
33
- <a-card :bordered="false">
34
- <x-form-table
35
- title="异常查询"
36
- :queryParamsName="queryParamsName"
37
- :fixedQueryForm="fixedQueryForm"
38
- ref="xFormTable">
39
- </x-form-table>
40
- </a-card>
41
- </template>
42
-
43
- <style scoped>
44
-
45
- </style>
1
+ <script>
2
+ export default {
3
+ name: 'ExceptionQuery',
4
+ components: {
5
+ XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue')
6
+ },
7
+ props: {
8
+ currUserInfo: {
9
+ type: Object,
10
+ default: () => undefined
11
+ }
12
+ },
13
+ mounted () {
14
+ this.$refs.xFormTable.refresh(true)
15
+ },
16
+ data () {
17
+ return {
18
+ // 查询配置名称
19
+ queryParamsName: 'ExceptionRecordQueryCRUD',
20
+ fixedQueryForm: { ex_f_userfiles_id: this.currUserInfo.f_userfiles_id },
21
+ // 新增表单固定值
22
+ fixedAddForm: {},
23
+ // 是否显示详情抽屉
24
+ detailVisible: false,
25
+ // 当前记录
26
+ record: {}
27
+ }
28
+ }
29
+ }
30
+ </script>
31
+
32
+ <template>
33
+ <a-card :bordered="false">
34
+ <x-form-table
35
+ title="异常查询"
36
+ :queryParamsName="queryParamsName"
37
+ :fixedQueryForm="fixedQueryForm"
38
+ ref="xFormTable">
39
+ </x-form-table>
40
+ </a-card>
41
+ </template>
42
+
43
+ <style scoped>
44
+
45
+ </style>