vue2-client 1.14.94 → 1.14.97

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 (145) hide show
  1. package/docs/Logic/345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +0 -1
  2. package/docs//345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +2 -4
  3. package/package.json +1 -1
  4. package/src/base-client/components/common/XFormTable/XFormTable.vue +6 -0
  5. package/src/base-client/components/common/XTab/XTab.vue +40 -8
  6. package/src/base-client/components/common/XTable/XTable.vue +30 -23
  7. package/src/base-client/components/common/XTable/XTableWrapper.vue +13 -6
  8. package/src/base-client/components/common/XUploadFilesView/index.vue +485 -485
  9. package/src/base-client/components/his/XList/XList.vue +35 -35
  10. package/src/base-client/components/his/XQuestionnaire/XQuestionnaire.json +0 -34
  11. package/src/base-client/components/his/XQuestionnaire/XQuestionnaire.vue +51 -23
  12. package/src/base-client/components/his/XQuestionnaire/XQuestionnaireDemo.vue +19 -2
  13. package/src/base-client/components/his/XQuestionnaire/XQuestionnaireItem.vue +39 -56
  14. package/src/base-client/components/his/XShiftSchedule/XShiftSchedule.vue +1 -1
  15. package/src/base-client/components/his/XTextCard/XTextCard.vue +207 -207
  16. package/src/base-client/components/his/XTreeRows/TreeNode.vue +100 -100
  17. package/src/base-client/components/his/XTreeRows/XTreeRows.vue +197 -197
  18. package/src/base-client/components/his/threeTestOrders/editor.vue +111 -111
  19. package/src/base-client/components/layout/XPageView/RenderRow.vue +88 -90
  20. package/src/base-client/components/layout/XPageView/XPageRowTemplate.vue +37 -0
  21. package/src/base-client/components/layout/XPageView/XPageView.vue +223 -222
  22. package/src/base-client/components/layout/XPageView/XTab/XTab.vue +96 -0
  23. package/src/base-client/components/layout/XPageView/XTab/index.js +3 -0
  24. package/src/base-client/components/layout/XPageView/componentTypes.js +22 -0
  25. package/src/base-client/components/layout/XPageView/index.js +1 -0
  26. package/src/base-client/components/layout/XPageView/index.md +19 -0
  27. package/src/pages/WorkflowDetail/WorkflowPageDetail/LeaveMessage.vue +388 -388
  28. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandle.vue +10 -4
  29. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowTimeline.vue +1 -1
  30. package/src/pages/XPageViewExample/index.vue +149 -71
  31. package/.history/public/his/editor/editor_20250606134713.html +0 -51
  32. package/.history/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox_20250527173925.vue +0 -509
  33. package/.history/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox_20250527174316.vue +0 -524
  34. package/.history/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox_20250527174419.vue +0 -524
  35. package/.history/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox_20250527174422.vue +0 -524
  36. package/.history/src/base-client/components/common/XAddReport/XAddReport_20250611172825.vue +0 -207
  37. package/.history/src/base-client/components/common/XAddReport/XAddReport_20250611172945.vue +0 -211
  38. package/.history/src/base-client/components/common/XAddReport/XAddReport_20250611172949.vue +0 -212
  39. package/.history/src/base-client/components/common/XAddReport/XAddReport_20250611173010.vue +0 -212
  40. package/.history/src/base-client/components/common/XForm/XFormItem_20250508134122.vue +0 -1320
  41. package/.history/src/base-client/components/common/XForm/XFormItem_20250527171604.vue +0 -1332
  42. package/.history/src/base-client/components/common/XForm/XFormItem_20250527171613.vue +0 -1331
  43. package/.history/src/base-client/components/common/XForm/XFormItem_20250527171703.vue +0 -1331
  44. package/.history/src/base-client/components/common/XForm/XFormItem_20250527171720.vue +0 -1331
  45. package/.history/src/base-client/components/common/XForm/XFormItem_20250527174327.vue +0 -1339
  46. package/.history/src/base-client/components/common/XReportGrid/XReportTrGroup_20250612092804.vue +0 -731
  47. package/.history/src/base-client/components/common/XReportGrid/XReportTrGroup_20250612112546.vue +0 -748
  48. package/.history/src/base-client/components/common/XReportGrid/XReportTrGroup_20250612113808.vue +0 -748
  49. package/.history/src/base-client/components/common/XReportGrid/XReport_20250612115237.vue +0 -1071
  50. package/.history/src/base-client/components/common/XReportGrid/XReport_20250612115346.vue +0 -1078
  51. package/.history/src/base-client/components/common/XReportGrid/XReport_20250612115350.vue +0 -1077
  52. package/.history/src/base-client/components/common/XReportGrid/XReport_20250612115415.vue +0 -1077
  53. package/.history/src/base-client/components/common/XReportGrid/XReport_20250612115429.vue +0 -1077
  54. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611091619.vue +0 -442
  55. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611092547.vue +0 -442
  56. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611092552.vue +0 -442
  57. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611092744.vue +0 -475
  58. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611092955.vue +0 -475
  59. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611092957.vue +0 -475
  60. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611095652.vue +0 -477
  61. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611095701.vue +0 -477
  62. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611095704.vue +0 -477
  63. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611100005.vue +0 -473
  64. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611100011.vue +0 -473
  65. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611100014.vue +0 -473
  66. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611100833.vue +0 -473
  67. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611100853.vue +0 -473
  68. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611100940.vue +0 -473
  69. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101011.vue +0 -473
  70. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101013.vue +0 -473
  71. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101014.vue +0 -473
  72. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101159.vue +0 -473
  73. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101238.vue +0 -474
  74. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101240.vue +0 -474
  75. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101242.vue +0 -474
  76. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101404.vue +0 -472
  77. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101410.vue +0 -472
  78. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101459.vue +0 -472
  79. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101500.vue +0 -472
  80. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101502.vue +0 -472
  81. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101504.vue +0 -472
  82. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101610.vue +0 -501
  83. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101700.vue +0 -501
  84. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101702.vue +0 -501
  85. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101741.vue +0 -504
  86. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101749.vue +0 -504
  87. package/.history/src/base-client/components/his/XHisEditor/XHisEditor_20250611101759.vue +0 -504
  88. package/.history/src/base-client/components/his/XHisEditor/dome_20250611091349.vue +0 -131
  89. package/.history/src/base-client/components/his/XHisEditor/dome_20250611105854.vue +0 -160
  90. package/.history/src/base-client/components/his/XHisEditor/dome_20250611105902.vue +0 -160
  91. package/.history/src/base-client/components/his/XHisEditor/dome_20250611105924.vue +0 -160
  92. package/.history/src/base-client/components/his/XHisEditor/dome_20250611105932.vue +0 -158
  93. package/.history/src/base-client/components/his/XList/XList_20250609135848.vue +0 -173
  94. package/.history/src/base-client/components/his/XList/XList_20250609141026.vue +0 -222
  95. package/.history/src/base-client/components/his/XList/XList_20250609141035.vue +0 -229
  96. package/.history/src/base-client/components/his/XList/XList_20250609141103.vue +0 -229
  97. package/.history/src/base-client/components/his/XList/XList_20250609141105.vue +0 -229
  98. package/.history/src/base-client/components/his/XList/XList_20250609141334.vue +0 -241
  99. package/.history/src/base-client/components/his/XList/XList_20250609141404.vue +0 -241
  100. package/.history/src/base-client/components/his/XList/XList_20250609141406.vue +0 -241
  101. package/.history/src/base-client/components/his/XList/XList_20250609141801.vue +0 -245
  102. package/.history/src/base-client/components/his/XList/XList_20250609142033.vue +0 -245
  103. package/.history/src/base-client/components/his/XList/XList_20250609142038.vue +0 -245
  104. package/.history/src/base-client/components/his/XList/XList_20250609142435.vue +0 -255
  105. package/.history/src/base-client/components/his/XList/XList_20250609142503.vue +0 -255
  106. package/.history/src/base-client/components/his/XList/XList_20250609142504.vue +0 -255
  107. package/.history/src/base-client/components/his/XList/XList_20250609143012.vue +0 -270
  108. package/.history/src/base-client/components/his/XList/XList_20250609143044.vue +0 -270
  109. package/.history/src/base-client/components/his/XList/XList_20250609143046.vue +0 -270
  110. package/.history/src/base-client/components/his/XList/XList_20250609143210.vue +0 -270
  111. package/.history/src/base-client/components/his/XList/XList_20250609144339.vue +0 -294
  112. package/.history/src/base-client/components/his/XList/XList_20250609144410.vue +0 -294
  113. package/.history/src/base-client/components/his/XList/XList_20250609144412.vue +0 -294
  114. package/.history/src/base-client/components/his/XList/XList_20250609144647.vue +0 -303
  115. package/.history/src/base-client/components/his/XList/XList_20250609144716.vue +0 -303
  116. package/.history/src/base-client/components/his/XList/XList_20250609144729.vue +0 -303
  117. package/.history/src/base-client/components/his/XList/XList_20250609151232.vue +0 -288
  118. package/.history/src/base-client/components/his/XList/XList_20250609151247.vue +0 -288
  119. package/.history/src/base-client/components/his/XList/XList_20250609151252.vue +0 -288
  120. package/.history/src/base-client/components/his/XList/XList_20250609161220.vue +0 -317
  121. package/.history/src/base-client/components/his/XList/XList_20250609161258.vue +0 -306
  122. package/.history/src/base-client/components/his/XList/XList_20250609161319.vue +0 -306
  123. package/.history/src/base-client/components/his/XList/XList_20250609161320.vue +0 -306
  124. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250609151519.vue +0 -222
  125. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250612155514.vue +0 -183
  126. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250612155556.vue +0 -183
  127. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250612155600.vue +0 -183
  128. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250612181609.vue +0 -206
  129. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250612181629.vue +0 -209
  130. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613095553.vue +0 -242
  131. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613095610.vue +0 -242
  132. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613095612.vue +0 -242
  133. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613100041.vue +0 -251
  134. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613100047.vue +0 -251
  135. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613100054.vue +0 -250
  136. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613100105.vue +0 -250
  137. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613100107.vue +0 -250
  138. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613100114.vue +0 -250
  139. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613140844.vue +0 -238
  140. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613140910.vue +0 -238
  141. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250613140912.vue +0 -238
  142. package/Users/objecrt/af-vue2-client/src/base-client/components/his/XShiftSchedule/XShiftSchedule.vue +0 -36
  143. package/src/base-client/components/TreeList/TreeList.vue +0 -91
  144. package/src/base-client/components/TreeList/TreeNode.vue +0 -81
  145. package/src/base-client/components/common/XCardSet/XTiltle.vue +0 -191
@@ -1,90 +1,88 @@
1
- <template>
2
- <a-row
3
- type="flex"
4
- :gutter="row.gutter || 0"
5
- :align="row.align || 'top'"
6
- :justify="row.justify || 'start'"
7
- >
8
- <a-col
9
- v-for="col in getColumns"
10
- :key="`page-col-${col.id}`"
11
- :span="col.span || 24"
12
- :xs="col.xs"
13
- :sm="col.sm"
14
- :md="col.md"
15
- :lg="col.lg"
16
- :xl="col.xl"
17
- :xxl="col.xxl"
18
- >
19
- <!-- 行类型,递归渲染子行 -->
20
- <template v-if="col.type === 'row'">
21
- <render-row
22
- v-for="(nestedRow, index) in col.children"
23
- :row="nestedRow"
24
- :key="`nested-row-${col.id}-${index}`"
25
- />
26
- </template>
27
-
28
- <!-- 组件类型,渲染动态组件 -->
29
- <template v-else>
30
- <component
31
- :ref="(el) => registerComponentRef(col.id, el)"
32
- :is="resolveComponentType(col.type)"
33
- v-bind="col.props"
34
- >
35
- <!-- 如果组件有子组件,递归渲染子行 -->
36
- <template v-if="col.children?.length">
37
- <render-row
38
- v-for="(nestedRow, index) in col.children"
39
- :row="nestedRow"
40
- :key="`comp-child-${col.id}-${index}`"
41
- />
42
- </template>
43
- </component>
44
- </template>
45
- </a-col>
46
- </a-row>
47
- </template>
48
-
49
- <script setup>
50
- import { defineProps, inject, computed } from 'vue'
51
-
52
- // 注入注册组件方法
53
- const registerComponent = inject('registerComponent')
54
-
55
- // 支持的组件类型映射
56
- const components = {
57
- XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable'),
58
- XAddNativeForm: () => import('@vue2-client/base-client/components/common/XAddNativeForm'),
59
- XErrorView: () => import('@vue2-client/base-client/components/layout/XPageView/XErrorView')
60
- }
61
-
62
- // 定义属性
63
- const props = defineProps({
64
- row: {
65
- type: Object,
66
- required: true
67
- }
68
- })
69
-
70
- // 获取列数组
71
- const getColumns = computed(() => {
72
- return props.row.type === 'row' ? props.row.children : [props.row]
73
- })
74
-
75
- // 解析组件类型
76
- const resolveComponentType = (type) => {
77
- if (!type) return components.XErrorView
78
- return components[type] || components.XErrorView
79
- }
80
-
81
- // 注册组件引用
82
- const registerComponentRef = (id, el) => {
83
- if (el) {
84
- registerComponent(id, el)
85
- }
86
- }
87
- </script>
88
-
89
- <style scoped lang="less">
90
- </style>
1
+ <template>
2
+ <a-row
3
+ type="flex"
4
+ :gutter="row.gutter || 0"
5
+ :align="row.align || 'top'"
6
+ :justify="row.justify || 'start'"
7
+ >
8
+ <a-col
9
+ v-for="col in getColumns"
10
+ :key="`page-col-${col.id}`"
11
+ :span="col.span || 24"
12
+ :xs="col.xs"
13
+ :sm="col.sm"
14
+ :md="col.md"
15
+ :lg="col.lg"
16
+ :xl="col.xl"
17
+ :xxl="col.xxl"
18
+ >
19
+ <!-- 行类型,递归渲染子行 -->
20
+ <template v-if="col.type === 'row'">
21
+ <x-page-row-template :template="col.template">
22
+ <render-row
23
+ v-for="(nestedRow, index) in col.children"
24
+ :row="nestedRow"
25
+ :key="`nested-row-${col.id}-${index}`"
26
+ />
27
+ </x-page-row-template>
28
+ </template>
29
+
30
+ <!-- 组件类型,渲染动态组件 -->
31
+ <template v-else>
32
+ <x-page-row-template :template="col.template">
33
+ <component
34
+ :ref="(el) => registerComponentRef(col.id, el)"
35
+ :is="resolveComponentType(col.type)"
36
+ v-bind="col.props"
37
+ >
38
+ <!-- 如果组件有子组件,递归渲染子行 -->
39
+ <template v-if="col.children && col.children.length">
40
+ <!-- 处理纯文本节点 -->
41
+ <template v-for="(nestedItem, index) in col.children">
42
+ <template v-if="nestedItem.text">{{ nestedItem.text }}</template>
43
+ <render-row
44
+ v-else
45
+ :row="nestedItem"
46
+ :key="`comp-child-${col.id}-${index}`"
47
+ />
48
+ </template>
49
+ </template>
50
+ </component>
51
+ </x-page-row-template>
52
+ </template>
53
+ </a-col>
54
+ </a-row>
55
+ </template>
56
+
57
+ <script setup>
58
+ import { defineProps, inject, computed } from 'vue'
59
+ import XPageRowTemplate from './XPageRowTemplate.vue'
60
+
61
+ import { resolveComponentType } from './componentTypes'
62
+
63
+ // 注入注册组件方法
64
+ const registerComponent = inject('registerComponent')
65
+
66
+ // 定义属性
67
+ const props = defineProps({
68
+ row: {
69
+ type: Object,
70
+ required: true
71
+ }
72
+ })
73
+
74
+ // 获取列数组
75
+ const getColumns = computed(() => {
76
+ return props.row.type === 'row' ? props.row.children : [props.row]
77
+ })
78
+
79
+ // 注册组件引用
80
+ const registerComponentRef = (id, el) => {
81
+ if (el) {
82
+ registerComponent(id, el)
83
+ }
84
+ }
85
+ </script>
86
+
87
+ <style scoped lang="less">
88
+ </style>
@@ -0,0 +1,37 @@
1
+ <template>
2
+ <div>
3
+ <template v-if="finalTemplate === 'card'">
4
+ <a-card :bordered="false" class="x-page-row-template-card">
5
+ <slot></slot>
6
+ </a-card>
7
+ </template>
8
+ <template v-else>
9
+ <div class="simple-template-card">
10
+ <slot></slot>
11
+ </div>
12
+ </template>
13
+ </div>
14
+ </template>
15
+
16
+ <script setup>
17
+ import { computed } from 'vue'
18
+
19
+ // 定义组件属性
20
+ const props = defineProps({
21
+ template: {
22
+ type: String,
23
+ default: 'card'
24
+ }
25
+ })
26
+
27
+ // 计算最终使用的模板类型
28
+ const finalTemplate = computed(() => {
29
+ return props.template || 'card'
30
+ })
31
+ </script>
32
+
33
+ <style scoped lang="less">
34
+ .x-page-row-template-card {
35
+ border-radius: 8px;
36
+ }
37
+ </style>
@@ -1,222 +1,223 @@
1
- <script setup>
2
- import { getConfigByName } from '@vue2-client/services/api/common'
3
- import { reactive, ref, provide } from 'vue'
4
- import RenderRow from './RenderRow'
5
- import XErrorView from '@vue2-client/base-client/components/layout/XPageView/XErrorView.vue'
6
-
7
- // 页面布局配置
8
- const layout = ref(null)
9
-
10
- // 加载状态:0-加载中,1-已加载,2-出现错误
11
- const loadingStatus = {
12
- LOADING: 0,
13
- LOADED: 1,
14
- ERROR: 2
15
- }
16
- const loaded = ref(loadingStatus.LOADING)
17
-
18
- // 组件计数
19
- const componentTotal = ref(0)
20
- const registerComponentTotal = ref(0)
21
-
22
- // 组件注册集合
23
- const componentRefMap = reactive({})
24
-
25
- // 数据上下文
26
- const dataContext = reactive({
27
- comps: componentRefMap,
28
- func: {
29
- getConfigByName
30
- }
31
- })
32
-
33
- /**
34
- * 初始化构建页面组件
35
- */
36
- const init = (params) => {
37
- const { configName, configValue, serviceName } = params
38
-
39
- // 重置状态
40
- loaded.value = loadingStatus.LOADING
41
- componentTotal.value = 0
42
- registerComponentTotal.value = 0
43
- Object.keys(componentRefMap).forEach(key => delete componentRefMap[key])
44
-
45
- const processConfig = (config) => {
46
- if (!config) {
47
- loaded.value = loadingStatus.ERROR
48
- return
49
- }
50
-
51
- layout.value = config
52
- setComponentTotal(layout.value.children)
53
- loaded.value = loadingStatus.LOADED
54
- }
55
-
56
- if (configName) {
57
- getConfigByName(configName, serviceName, processConfig)
58
- } else if (configValue) {
59
- try {
60
- const config = typeof configValue === 'string' ? JSON.parse(configValue) : configValue
61
- processConfig(config)
62
- } catch (error) {
63
- console.error('配置解析错误:', error)
64
- loaded.value = loadingStatus.ERROR
65
- }
66
- } else {
67
- loaded.value = loadingStatus.ERROR
68
- }
69
- }
70
-
71
- /**
72
- * 注册组件
73
- */
74
- const registerComponent = (name, vm) => {
75
- if (!vm) return
76
-
77
- componentRefMap[name] = vm
78
- registerComponentTotal.value++
79
- console.debug(`总组件数量:${componentTotal.value},已注册数量:${registerComponentTotal.value}`)
80
-
81
- // 初始化页面
82
- if (layout.value?.onMounted && registerComponentTotal.value === 1) {
83
- initPage()
84
- }
85
-
86
- // 所有组件都已注册完成
87
- if (registerComponentTotal.value >= componentTotal.value) {
88
- registerEvents(layout.value.children)
89
- }
90
- }
91
- provide('registerComponent', registerComponent)
92
-
93
- /**
94
- * 初始化页面
95
- */
96
- const initPage = () => {
97
- if (!layout.value?.onMounted) return
98
-
99
- try {
100
- // 使用 Function 构造函数替代 eval
101
- // eslint-disable-next-line no-new-func
102
- const onMountedFun = new Function('data', `return (${layout.value.onMounted})(data)`)
103
- onMountedFun(dataContext)
104
- } catch (error) {
105
- console.error('页面初始化错误:', error)
106
- }
107
- }
108
-
109
- /**
110
- * 设置需要注册的组件总数
111
- */
112
- const setComponentTotal = (children) => {
113
- if (!children?.length) return
114
-
115
- children.forEach((child) => {
116
- // 如果不是row类型,追加组件数量
117
- if (child.type !== 'row') {
118
- componentTotal.value++
119
- }
120
-
121
- // 递归追加子组件数量
122
- if (child.children?.length) {
123
- setComponentTotal(child.children)
124
- }
125
- })
126
- }
127
-
128
- /**
129
- * 注册组件事件
130
- */
131
- const registerEvents = (children) => {
132
- if (!children?.length) return
133
-
134
- children.forEach((child) => {
135
- // 如果有事件,注册它们
136
- if (child.event) {
137
- Object.entries(child.event).forEach(([eventName, handler]) => {
138
- try {
139
- // 使用 Function 构造函数替代 eval
140
- // eslint-disable-next-line no-new-func
141
- const eventHandler = new Function('...args', `return (${handler})(...args)`)
142
- const componentInstance = componentRefMap[child.id]
143
-
144
- if (componentInstance) {
145
- componentInstance.$on(eventName, (...args) => {
146
- eventHandler.call(componentInstance, ...args, dataContext)
147
- })
148
- }
149
- } catch (error) {
150
- console.error(`注册事件 ${eventName} 错误:`, error)
151
- }
152
- })
153
- }
154
-
155
- // 递归注册子组件的事件
156
- if (child.children?.length) {
157
- registerEvents(child.children)
158
- }
159
- })
160
- }
161
-
162
- // 导出组件接口
163
- defineExpose({ init })
164
- </script>
165
-
166
- <template>
167
- <a-row
168
- type="flex"
169
- :gutter="layout?.gutter || 0"
170
- :align="layout?.align || 'top'"
171
- :justify="layout?.justify || 'start'"
172
- class="liuli-page">
173
- <template v-if="loaded === loadingStatus.LOADED">
174
- <template v-if="layout.children?.length">
175
- <a-col v-for="row in layout.children" :key="`page-col-${row.id}`">
176
- <render-row :row="row"/>
177
- </a-col>
178
- </template>
179
- <template v-else>
180
- <div class="liuli-page__empty">
181
- <a-empty description="无页面内容" />
182
- </div>
183
- </template>
184
- </template>
185
-
186
- <template v-else-if="loaded === loadingStatus.LOADING">
187
- <div class="liuli-page__loading">
188
- <a-spin tip="页面加载中..." />
189
- </div>
190
- </template>
191
-
192
- <template v-else>
193
- <div class="liuli-page__error">
194
- <XErrorView />
195
- </div>
196
- </template>
197
- </a-row>
198
- </template>
199
-
200
- <style scoped lang="less">
201
- .liuli-page {
202
- position: relative;
203
- width: 100%;
204
- height: 100%;
205
-
206
- &__content {
207
- min-height: 100px;
208
- }
209
-
210
- &__loading, &__error, &__empty {
211
- display: flex;
212
- width: 100%;
213
- justify-content: center;
214
- align-items: center;
215
- min-height: 200px;
216
- }
217
-
218
- &__error {
219
- width: 100%;
220
- }
221
- }
222
- </style>
1
+ <script setup>
2
+ import { getConfigByName } from '@vue2-client/services/api/common'
3
+ import { reactive, ref, provide } from 'vue'
4
+ import RenderRow from './RenderRow'
5
+ import XErrorView from '@vue2-client/base-client/components/layout/XPageView/XErrorView.vue'
6
+
7
+ // 页面布局配置
8
+ const layout = ref(null)
9
+
10
+ // 加载状态:0-加载中,1-已加载,2-出现错误
11
+ const loadingStatus = {
12
+ LOADING: 0,
13
+ LOADED: 1,
14
+ ERROR: 2
15
+ }
16
+ const loaded = ref(loadingStatus.LOADING)
17
+
18
+ // 组件计数
19
+ const componentTotal = ref(0)
20
+ const registerComponentTotal = ref(0)
21
+
22
+ // 组件注册集合
23
+ const componentRefMap = reactive({})
24
+
25
+ // 数据上下文
26
+ const dataContext = reactive({
27
+ comps: componentRefMap,
28
+ func: {
29
+ getConfigByName
30
+ },
31
+ data: {}
32
+ })
33
+
34
+ /**
35
+ * 初始化构建页面组件
36
+ */
37
+ const init = (params) => {
38
+ const { configName, configValue, serviceName } = params
39
+
40
+ // 重置状态
41
+ loaded.value = loadingStatus.LOADING
42
+ componentTotal.value = 0
43
+ registerComponentTotal.value = 0
44
+ Object.keys(componentRefMap).forEach(key => delete componentRefMap[key])
45
+
46
+ const processConfig = (config) => {
47
+ if (!config) {
48
+ loaded.value = loadingStatus.ERROR
49
+ return
50
+ }
51
+
52
+ layout.value = config
53
+ setComponentTotal(layout.value.children)
54
+ loaded.value = loadingStatus.LOADED
55
+ }
56
+
57
+ if (configName) {
58
+ getConfigByName(configName, serviceName, processConfig)
59
+ } else if (configValue) {
60
+ try {
61
+ const config = typeof configValue === 'string' ? JSON.parse(configValue) : configValue
62
+ processConfig(config)
63
+ } catch (error) {
64
+ console.error('配置解析错误:', error)
65
+ loaded.value = loadingStatus.ERROR
66
+ }
67
+ } else {
68
+ loaded.value = loadingStatus.ERROR
69
+ }
70
+ }
71
+
72
+ /**
73
+ * 注册组件
74
+ */
75
+ const registerComponent = (name, vm) => {
76
+ if (!vm) return
77
+
78
+ componentRefMap[name] = vm
79
+ registerComponentTotal.value++
80
+ console.debug(`总组件数量:${componentTotal.value},已注册数量:${registerComponentTotal.value}`)
81
+
82
+ // 所有组件都已注册完成
83
+ if (registerComponentTotal.value >= componentTotal.value) {
84
+ registerEvents(layout.value.children)
85
+ // 初始化页面
86
+ initPage()
87
+ }
88
+ }
89
+ provide('registerComponent', registerComponent)
90
+ // 提供数据上下文给子组件
91
+ provide('dataContext', dataContext)
92
+
93
+ /**
94
+ * 初始化页面
95
+ */
96
+ const initPage = () => {
97
+ if (!layout.value?.onMounted) return
98
+
99
+ console.info('开始初始化页面')
100
+ try {
101
+ // 使用 Function 构造函数替代 eval
102
+ // eslint-disable-next-line no-new-func
103
+ const onMountedFun = new Function('data', `return (${layout.value.onMounted})(data)`)
104
+ onMountedFun(dataContext)
105
+ } catch (error) {
106
+ console.error('页面初始化错误:', error)
107
+ }
108
+ }
109
+
110
+ /**
111
+ * 设置需要注册的组件总数
112
+ */
113
+ const setComponentTotal = (children) => {
114
+ if (!children?.length) return
115
+
116
+ children.forEach((child) => {
117
+ // 如果不是row和text类型,追加组件数量
118
+ if (child.type !== 'row' && child.type !== 'text') {
119
+ componentTotal.value++
120
+ }
121
+
122
+ // 递归追加子组件数量
123
+ if (child.children?.length) {
124
+ setComponentTotal(child.children)
125
+ }
126
+ })
127
+ }
128
+
129
+ /**
130
+ * 注册组件事件
131
+ */
132
+ const registerEvents = (children) => {
133
+ if (!children?.length) return
134
+
135
+ children.forEach((child) => {
136
+ // 如果有事件,注册它们
137
+ if (child.event) {
138
+ Object.entries(child.event).forEach(([eventName, handler]) => {
139
+ try {
140
+ // 使用 Function 构造函数替代 eval
141
+ // eslint-disable-next-line no-new-func
142
+ const eventHandler = new Function('...args', `return (${handler})(...args)`)
143
+ const componentInstance = componentRefMap[child.id]
144
+
145
+ if (componentInstance) {
146
+ componentInstance.$on(eventName, (...args) => {
147
+ eventHandler.call(componentInstance, ...args, dataContext)
148
+ })
149
+ }
150
+ } catch (error) {
151
+ console.error(`注册事件 ${eventName} 错误:`, error)
152
+ }
153
+ })
154
+ }
155
+
156
+ // 递归注册子组件的事件
157
+ if (child.children?.length) {
158
+ registerEvents(child.children)
159
+ }
160
+ })
161
+ }
162
+
163
+ // 导出组件接口
164
+ defineExpose({ init })
165
+ </script>
166
+
167
+ <template>
168
+ <a-row
169
+ type="flex"
170
+ :gutter="layout?.gutter || 0"
171
+ :align="layout?.align || 'top'"
172
+ :justify="layout?.justify || 'start'"
173
+ class="liuli-page">
174
+ <template v-if="loaded === loadingStatus.LOADED">
175
+ <template v-if="layout.children?.length">
176
+ <a-col v-for="row in layout.children" :key="`page-col-${row.id}`" :span="24">
177
+ <render-row :row="row"/>
178
+ </a-col>
179
+ </template>
180
+ <template v-else>
181
+ <div class="liuli-page__empty">
182
+ <a-empty description="无页面内容" />
183
+ </div>
184
+ </template>
185
+ </template>
186
+
187
+ <template v-else-if="loaded === loadingStatus.LOADING">
188
+ <div class="liuli-page__loading">
189
+ <a-spin tip="页面加载中..." />
190
+ </div>
191
+ </template>
192
+
193
+ <template v-else>
194
+ <div class="liuli-page__error">
195
+ <XErrorView />
196
+ </div>
197
+ </template>
198
+ </a-row>
199
+ </template>
200
+
201
+ <style scoped lang="less">
202
+ .liuli-page {
203
+ position: relative;
204
+ width: 100%;
205
+ height: 100%;
206
+
207
+ &__content {
208
+ min-height: 100px;
209
+ }
210
+
211
+ &__loading, &__error, &__empty {
212
+ display: flex;
213
+ width: 100%;
214
+ justify-content: center;
215
+ align-items: center;
216
+ min-height: 200px;
217
+ }
218
+
219
+ &__error {
220
+ width: 100%;
221
+ }
222
+ }
223
+ </style>