vue2-client 1.8.413 → 1.8.415

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.
@@ -478,7 +478,7 @@ export default {
478
478
  // tableConfig: {}
479
479
  }
480
480
  },
481
- inject: ['openDialog', 'registerComponent', 'getComponentByName', 'runLogic', 'getMixinData', 'getSelectedId'],
481
+ inject: ['openDialog', 'registerComponent', 'getComponentByName', 'runLogic', 'getMixinData', 'getSelectedId', 'isInAModal'],
482
482
  methods: {
483
483
  onComponentMounted (h, cell, cellIndex) {
484
484
  if (this.getMixinData && this.getMixinData()) {
@@ -499,7 +499,7 @@ export default {
499
499
  }
500
500
  this.$refs[`dynamicComponent_${cell.slotRef || cellIndex}`][0].init({
501
501
  formItems: res.formJson,
502
- showSubmitBtn: false,
502
+ showSubmitBtn: !this.isInAModal,
503
503
  businessType: '新增',
504
504
  layout: res.xAddFormLayout,
505
505
  ...res,
@@ -1,158 +1,166 @@
1
- <template>
2
- <div>
3
- <a-row type="flex" justfy="space-around">
4
- <template v-for="(item, index) in config">
5
- <!-- 展示项 -->
6
- <a-col :key="'col' + index" :span="Math.floor(24 / config.length)">
7
- <div class="item">
8
- <!-- 标题 -->
9
- <p class="label">{{ item.label }}</p>
10
- <!-- 内容 - 进度条 -->
11
- <template v-if="item.type === 'percent'">
12
- <p class="value" :style="'color: ' + determineColor(data[item.key])">{{ data[item.key] }}%</p>
13
- </template>
14
- <!-- 内容 - 非进度条 -->
15
- <template v-else>
16
- <p class="value" :style="item.style ? item.style : ''">{{ data[item.key] }}</p>
17
- </template>
18
- </div>
19
- </a-col>
20
- <!-- 分割线 -->
21
- <a-col :key="'col' + index + 'after'" :span="1" v-if="index !== config.length - 1" class="divider-col">
22
- <a-divider type="vertical" class="divider"/>
23
- </a-col>
24
- </template>
25
- </a-row>
26
- </div>
27
- </template>
28
-
29
- <script>
30
-
31
- import { getConfigByName } from '@vue2-client/services/api/common'
32
-
33
- export default {
34
- name: 'XSimpleDescriptions',
35
- props: {
36
- // 配置
37
- dataConfig: {
38
- type: Array,
39
- default: undefined
40
- },
41
- // 数据
42
- dataContent: {
43
- type: Object,
44
- default: undefined
45
- },
46
- // 配置名
47
- dataConfigName: {
48
- type: String,
49
- default: undefined
50
- },
51
- // 服务名
52
- serviceName: {
53
- type: String,
54
- default: process.env.VUE_APP_SYSTEM_NAME
55
- }
56
- },
57
- data () {
58
- return {
59
- // 配置
60
- config: [],
61
- // 数据
62
- data: {},
63
- }
64
- },
65
- mounted () {
66
- // 初始化配置
67
- if (this.dataConfig) {
68
- this.config = this.dataConfig
69
- } else if (this.dataConfigName) {
70
- getConfigByName(this.dataConfigName, this.serviceName, (res) => {
71
- this.config = res.config
72
- })
73
- } else {
74
- this.config = [
75
- {
76
- label: '未能正确获取配置',
77
- key: 'totalUser'
78
- },
79
- {
80
- label: '未能正确获取配置',
81
- key: 'totalResidentArea'
82
- },
83
- {
84
- label: '未能正确获取配置',
85
- key: 'doneNum'
86
- },
87
- {
88
- label: '未能正确获取配置',
89
- key: 'todoNum'
90
- },
91
- {
92
- label: '未能正确获取配置',
93
- key: 'ratio',
94
- type: 'percent'
95
- }
96
- ]
97
- }
98
-
99
- // 初始化数据
100
- if (this.dataContent) {
101
- this.data = this.dataContent
102
- } else {
103
- this.data = {
104
- totalUser: 0,
105
- totalResidentArea: 0,
106
- doneNum: 0,
107
- todoNum: 0,
108
- ratio: 20
109
- }
110
- }
111
- },
112
- methods: {
113
- // 根据完成率决定颜色
114
- determineColor (ratio) {
115
- let result
116
- if (ratio >= 90) {
117
- result = 'rgb( 1,245, 38 )'
118
- } else if (ratio >= 75) {
119
- result = 'rgb( 139,245, 0)'
120
- } else if (ratio >= 40) {
121
- result = 'rgb(245,163, 0)'
122
- } else if (ratio >= 20) {
123
- result = 'rgb(244, 96, 0)'
124
- } else {
125
- result = 'rgb(255, 0, 0)'
126
- }
127
- return result
128
- }
129
- }
130
- }
131
- </script>
132
-
133
- <style lang="less" scoped>
134
- .item {
135
- padding: 5%;
136
-
137
- .label {
138
- color: rgba(117, 117, 117, 0.8);
139
- text-align: center;
140
- }
141
-
142
- .value {
143
- color: rgb( 51,157,255 );
144
- font-size: 1.6em;
145
- text-align: center;
146
- }
147
- }
148
-
149
- .divider-col {
150
- display: flex;
151
- justify-content: center;
152
-
153
- .divider {
154
- margin-top: 35%;
155
- height: 40px;
156
- }
157
- }
158
- </style>
1
+ <template>
2
+ <div>
3
+ <a-row type="flex" justfy="space-around">
4
+ <template v-for="(item, index) in config">
5
+ <!-- 展示项 -->
6
+ <a-col :key="'col' + index" :span="Math.floor(24 / config.length)">
7
+ <div class="item">
8
+ <!-- 标题 -->
9
+ <p class="label">{{ item.label }}</p>
10
+ <!-- 内容 - 进度条 -->
11
+ <template v-if="item.type === 'percent'">
12
+ <p class="value" :style="'color: ' + determineColor(data[item.key])">{{ data[item.key] }}%</p>
13
+ </template>
14
+ <!-- 内容 - 非进度条 -->
15
+ <template v-else>
16
+ <p class="value" :style="item.style ? item.style : ''">{{ data[item.key] }}</p>
17
+ </template>
18
+ </div>
19
+ </a-col>
20
+ <!-- 分割线 -->
21
+ <a-col :key="'col' + index + 'after'" :span="1" v-if="index !== config.length - 1" class="divider-col">
22
+ <a-divider type="vertical" class="divider"/>
23
+ </a-col>
24
+ </template>
25
+ </a-row>
26
+ </div>
27
+ </template>
28
+
29
+ <script>
30
+
31
+ import { getConfigByName } from '@vue2-client/services/api/common'
32
+
33
+ export default {
34
+ name: 'XSimpleDescriptions',
35
+ props: {
36
+ // 配置
37
+ dataConfig: {
38
+ type: Array,
39
+ default: undefined
40
+ },
41
+ // 数据
42
+ dataContent: {
43
+ type: Object,
44
+ default: undefined
45
+ },
46
+ // 配置名
47
+ dataConfigName: {
48
+ type: String,
49
+ default: undefined
50
+ },
51
+ // 服务名
52
+ serviceName: {
53
+ type: String,
54
+ default: process.env.VUE_APP_SYSTEM_NAME
55
+ }
56
+ },
57
+ data () {
58
+ return {
59
+ // 配置
60
+ config: [],
61
+ // 数据
62
+ data: {},
63
+ }
64
+ },
65
+ mounted () {
66
+ // 初始化配置
67
+ if (this.dataConfig) {
68
+ this.config = this.dataConfig
69
+ } else if (this.dataConfigName) {
70
+ getConfigByName(this.dataConfigName, this.serviceName, (res) => {
71
+ this.config = res.config
72
+ })
73
+ } else {
74
+ this.config = [
75
+ {
76
+ label: '未能正确获取配置',
77
+ key: 'totalUser'
78
+ },
79
+ {
80
+ label: '未能正确获取配置',
81
+ key: 'totalResidentArea'
82
+ },
83
+ {
84
+ label: '未能正确获取配置',
85
+ key: 'doneNum'
86
+ },
87
+ {
88
+ label: '未能正确获取配置',
89
+ key: 'todoNum'
90
+ },
91
+ {
92
+ label: '未能正确获取配置',
93
+ key: 'ratio',
94
+ type: 'percent'
95
+ }
96
+ ]
97
+ }
98
+
99
+ // 初始化数据
100
+ if (this.dataContent) {
101
+ this.data = this.dataContent
102
+ } else {
103
+ this.data = {
104
+ totalUser: 0,
105
+ totalResidentArea: 0,
106
+ doneNum: 0,
107
+ todoNum: 0,
108
+ ratio: 20
109
+ }
110
+ }
111
+ },
112
+ methods: {
113
+ // 根据完成率决定颜色
114
+ determineColor (ratio) {
115
+ let result
116
+ if (ratio >= 90) {
117
+ result = 'rgb( 1,245, 38 )'
118
+ } else if (ratio >= 75) {
119
+ result = 'rgb( 139,245, 0)'
120
+ } else if (ratio >= 40) {
121
+ result = 'rgb(245,163, 0)'
122
+ } else if (ratio >= 20) {
123
+ result = 'rgb(244, 96, 0)'
124
+ } else {
125
+ result = 'rgb(255, 0, 0)'
126
+ }
127
+ return result
128
+ }
129
+ },
130
+ watch: {
131
+ dataContent: {
132
+ handler (newValue) {
133
+ this.data = newValue
134
+ },
135
+ deep: true
136
+ }
137
+ }
138
+ }
139
+ </script>
140
+
141
+ <style lang="less" scoped>
142
+ .item {
143
+ padding: 5%;
144
+
145
+ .label {
146
+ color: rgba(117, 117, 117, 0.8);
147
+ text-align: center;
148
+ }
149
+
150
+ .value {
151
+ color: rgb( 51,157,255 );
152
+ font-size: 1.6em;
153
+ text-align: center;
154
+ }
155
+ }
156
+
157
+ .divider-col {
158
+ display: flex;
159
+ justify-content: center;
160
+
161
+ .divider {
162
+ margin-top: 35%;
163
+ height: 40px;
164
+ }
165
+ }
166
+ </style>
@@ -6,21 +6,34 @@
6
6
  :key="index"
7
7
  :tab="tab.title"
8
8
  >
9
- <component :is="tab.slotType" :key="index" :serviceName="tab.serviceName" :queryParamsName="tab.slotConfig" />
9
+ <component
10
+ :is="tab.slotType"
11
+ :key="index"
12
+ :ref="`tab_com_${tab.slotType}_${index}`"
13
+ :serviceName="tab.serviceName"
14
+ :serverName="tab.serviceName"
15
+ :queryParamsName="tab.slotConfig"
16
+ v-on="getEventHandlers(tab)"
17
+ @hook:mounted="(h)=>onComponentMounted(h,tab,index)"
18
+ :config-name="tab.slotConfig"
19
+ />
10
20
  </a-tab-pane>
11
21
  </a-tabs>
12
22
  </div>
13
23
  </template>
14
24
 
15
25
  <script>
16
- import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable'
17
- import { getConfigByName } from '@vue2-client/services/api/common'
26
+ import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
27
+ import { executeStrFunctionByContext } from '@/utils/runEvalFunction'
18
28
 
19
29
  export default {
20
30
  name: 'XTab',
21
31
  components: {
22
- XFormTable,
32
+ XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable'),
33
+ XAddNativeForm: () => import('@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'),
34
+ XReportGrid: () => import('@vue2-client/base-client/components/common/XReportGrid/XReport.vue')
23
35
  },
36
+ inject: ['isInAModal', 'getSelectedId'],
24
37
  data () {
25
38
  return {
26
39
  activeKey: 0,
@@ -41,7 +54,49 @@ export default {
41
54
  getConfigByName(this.configName, this.serverName, res => {
42
55
  this.config = res.data
43
56
  })
44
- }
57
+ },
58
+ getEventHandlers (tab) {
59
+ const handlers = {}
60
+ if (!tab?.events || tab?.events?.length === 0) {
61
+ return handlers
62
+ }
63
+ tab.events.forEach(event => {
64
+ handlers[event.type] = (...args) => {
65
+ console.info('Event handled:', event.type, args)
66
+ executeStrFunctionByContext(this, event.customFunction, args)
67
+ }
68
+ })
69
+ return handlers
70
+ },
71
+ onComponentMounted (h, tab, index) {
72
+ console.log(`插槽组件已经初始化 slotType ${tab.slotType},ref= tab_com_${tab.slotType}_${index} , serviceName = ${tab.serviceName}`)
73
+ if (tab.slotType === 'x-add-native-form') {
74
+ // 建议表单需要主动调用初始化方法
75
+ getConfigByName(tab.slotConfig, tab.serviceName, async (res) => {
76
+ // 如果配置了 表单初始化logic
77
+ // 调用 logic 获取参数
78
+ let param = {}
79
+ if (res.paramLogicName) {
80
+ param = Object.assign(param, await runLogic(res.paramLogicName, {
81
+ selectedId: (!!this.getSelectedId && this.getSelectedId()) || undefined,
82
+ ...this.mixinData
83
+ }, tab.serviceName))
84
+ }
85
+ this.$refs[`tab_com_${tab.slotType}_${index}`][0].init({
86
+ formItems: res.formJson,
87
+ showSubmitBtn: !this.isInAModal,
88
+ businessType: '新增',
89
+ layout: res.xAddFormLayout,
90
+ ...res,
91
+ fixedAddForm: param,
92
+ modifyModelData: {
93
+ files: param.files,
94
+ images: param.images
95
+ }
96
+ })
97
+ })
98
+ }
99
+ },
45
100
  },
46
101
  props: {
47
102
  // 配置名
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div>
3
- <x-tab :config-name="configName" server-name="af-system"></x-tab>
3
+ <x-tab :config-name="configName" server-name="af-his"></x-tab>
4
4
  </div>
5
5
  </template>
6
6
 
@@ -14,7 +14,7 @@ export default {
14
14
  },
15
15
  data () {
16
16
  return {
17
- configName: 'tab标签页测试'
17
+ configName: 'test1'
18
18
  }
19
19
  },
20
20
  methods: {},
@@ -78,7 +78,7 @@ routerResource.example = {
78
78
  {
79
79
  path: 'default',
80
80
  name: '示例页面',
81
- component: () => import('@vue2-client/base-client/components/common/XReportGrid/XReportDemo.vue'),
81
+ component: () => import('@vue2-client/base-client/components/common/XTab/XTabDemo.vue'),
82
82
  meta: {
83
83
  // 菜单中不显示
84
84
  invisible: true,