vue2-client 1.16.32 → 1.16.33

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,186 +1,186 @@
1
- // print.js
2
-
3
- export function printElement (elementToPrint) {
4
- // 创建一个新的浏览器窗口
5
- const printWindow = window.open('', '_blank', 'height=1024,width=768')
6
- // 设置新窗口的文档内容
7
- printWindow.document.write(`
8
- <html>
9
- <head>
10
- <title>Print</title>
11
- <style>
12
- @page {
13
- size: auto;
14
- margin: 0mm;
15
- }
16
- html, body {
17
- margin: 0;
18
- padding: 0;
19
- width: 100%;
20
- height: 100%;
21
- }
22
- #print-container {
23
- display: none
24
- }
25
- .img{
26
- width: 95%;
27
- height: 180px;
28
- object-fit: cover;
29
- }
30
- .reportMain {
31
- text-align: center;
32
- margin: 0 auto;
33
- font-size: 16px;
34
- color: #000;
35
- background-color: #fff;
36
- padding: 15px;
37
- border-radius: 8px;
38
-
39
- .reportTitle {
40
- font-weight: bold;
41
- }
42
-
43
- .subTitle {
44
- display: flex;
45
- justify-content: space-between;
46
- margin-bottom: 1%;
47
-
48
- .subTitleItems {
49
- max-width: 30%;
50
- }
51
- }
52
-
53
- .inputsDiv {
54
- display: flex;
55
- justify-content: space-between;
56
- .inputsDivItem {
57
- display: flex;
58
- align-items: center;
59
- padding: 0 4px;
60
- white-space: nowrap;
61
- .inputsDivItemLabel {
62
- padding: 0 4px;
63
- }
64
- }
65
- }
66
-
67
- .reportTable {
68
- width: 100%;
69
- border-collapse: collapse;
70
- table-layout:fixed;
71
- word-break:break-all;
72
- text-align: center;
73
- }
74
- }
75
- .reportMainForDisplay {
76
- text-align: center;
77
- margin: 10% auto;
78
- font-size: 16px;
79
- color: #000;
80
- background-color: #fff;
81
- padding: 15px;
82
- border-radius: 8px;
83
-
84
- .reportTitle {
85
- font-weight: bold;
86
- }
87
-
88
- .subTitle {
89
- display: flex;
90
- justify-content: space-between;
91
-
92
- .subTitleItems {
93
- max-width: 30%;
94
- }
95
- }
96
-
97
- .inputsDiv {
98
- display: flex;
99
- justify-content: space-around;
100
- .inputsDivItem {
101
- display: flex;
102
- align-items: center;
103
- padding: 0 4px;
104
- white-space: nowrap;
105
- .inputsDivItemLabel {
106
- padding: 0 4px;
107
- }
108
- }
109
- }
110
-
111
- .reportTable {
112
- width: 100%;
113
- border-collapse: collapse;
114
- table-layout:fixed;
115
- word-break:break-all;
116
- }
117
- }
118
- .reportMainNoPadding {
119
- text-align: center;
120
- margin: 0 auto;
121
- font-size: 16px;
122
- color: #000;
123
- background-color: #fff;
124
- border-radius: 8px;
125
-
126
- .reportTitle {
127
- font-weight: bold;
128
- }
129
-
130
- .subTitle {
131
- display: flex;
132
- justify-content: space-between;
133
-
134
- .subTitleItems {
135
- max-width: 30%;
136
- }
137
- }
138
-
139
- .inputsDiv {
140
- display: flex;
141
- justify-content: space-between;
142
- .inputsDivItem {
143
- display: flex;
144
- align-items: center;
145
- padding: 0 4px;
146
- white-space: nowrap;
147
- .inputsDivItemLabel {
148
- padding: 0 4px;
149
- }
150
- }
151
- }
152
-
153
- .reportTable {
154
- width: 100%;
155
- border-collapse: collapse;
156
- table-layout:fixed;
157
- word-break:break-all;
158
- }
159
- }
160
- .tools{
161
- position: fixed;
162
- right: 2%;
163
- text-align: right;
164
- width: 60%;
165
- cursor: pointer;
166
- .toolsItem{
167
- width: 15%;
168
- margin-right: 3%;
169
- display: inline-block;
170
- }
171
- }
172
- </style>
173
- </head>
174
- <body>
175
- <!-- 将需要打印的元素内容复制到新窗口中 -->
176
- ${elementToPrint.innerHTML}
177
- </body>
178
- </html>
179
- `)
180
- // 延迟执行打印,以确保新窗口的内容已加载完成
181
- printWindow.document.close() // 关闭文档流,确保内容完全加载
182
- setTimeout(() => {
183
- printWindow.print() // 调用打印方法
184
- printWindow.close()
185
- }, 500) // 延迟500毫秒后执行打印
186
- }
1
+ // print.js
2
+
3
+ export function printElement (elementToPrint) {
4
+ // 创建一个新的浏览器窗口
5
+ const printWindow = window.open('', '_blank', 'height=1024,width=768')
6
+ // 设置新窗口的文档内容
7
+ printWindow.document.write(`
8
+ <html>
9
+ <head>
10
+ <title>Print</title>
11
+ <style>
12
+ @page {
13
+ size: auto;
14
+ margin: 0mm;
15
+ }
16
+ html, body {
17
+ margin: 0;
18
+ padding: 0;
19
+ width: 100%;
20
+ height: 100%;
21
+ }
22
+ #print-container {
23
+ display: none
24
+ }
25
+ .img{
26
+ width: 95%;
27
+ height: 180px;
28
+ object-fit: cover;
29
+ }
30
+ .reportMain {
31
+ text-align: center;
32
+ margin: 0 auto;
33
+ font-size: 16px;
34
+ color: #000;
35
+ background-color: #fff;
36
+ padding: 15px;
37
+ border-radius: 8px;
38
+
39
+ .reportTitle {
40
+ font-weight: bold;
41
+ }
42
+
43
+ .subTitle {
44
+ display: flex;
45
+ justify-content: space-between;
46
+ margin-bottom: 1%;
47
+
48
+ .subTitleItems {
49
+ max-width: 30%;
50
+ }
51
+ }
52
+
53
+ .inputsDiv {
54
+ display: flex;
55
+ justify-content: space-between;
56
+ .inputsDivItem {
57
+ display: flex;
58
+ align-items: center;
59
+ padding: 0 4px;
60
+ white-space: nowrap;
61
+ .inputsDivItemLabel {
62
+ padding: 0 4px;
63
+ }
64
+ }
65
+ }
66
+
67
+ .reportTable {
68
+ width: 100%;
69
+ border-collapse: collapse;
70
+ table-layout:fixed;
71
+ word-break:break-all;
72
+ text-align: center;
73
+ }
74
+ }
75
+ .reportMainForDisplay {
76
+ text-align: center;
77
+ margin: 10% auto;
78
+ font-size: 16px;
79
+ color: #000;
80
+ background-color: #fff;
81
+ padding: 15px;
82
+ border-radius: 8px;
83
+
84
+ .reportTitle {
85
+ font-weight: bold;
86
+ }
87
+
88
+ .subTitle {
89
+ display: flex;
90
+ justify-content: space-between;
91
+
92
+ .subTitleItems {
93
+ max-width: 30%;
94
+ }
95
+ }
96
+
97
+ .inputsDiv {
98
+ display: flex;
99
+ justify-content: space-around;
100
+ .inputsDivItem {
101
+ display: flex;
102
+ align-items: center;
103
+ padding: 0 4px;
104
+ white-space: nowrap;
105
+ .inputsDivItemLabel {
106
+ padding: 0 4px;
107
+ }
108
+ }
109
+ }
110
+
111
+ .reportTable {
112
+ width: 100%;
113
+ border-collapse: collapse;
114
+ table-layout:fixed;
115
+ word-break:break-all;
116
+ }
117
+ }
118
+ .reportMainNoPadding {
119
+ text-align: center;
120
+ margin: 0 auto;
121
+ font-size: 16px;
122
+ color: #000;
123
+ background-color: #fff;
124
+ border-radius: 8px;
125
+
126
+ .reportTitle {
127
+ font-weight: bold;
128
+ }
129
+
130
+ .subTitle {
131
+ display: flex;
132
+ justify-content: space-between;
133
+
134
+ .subTitleItems {
135
+ max-width: 30%;
136
+ }
137
+ }
138
+
139
+ .inputsDiv {
140
+ display: flex;
141
+ justify-content: space-between;
142
+ .inputsDivItem {
143
+ display: flex;
144
+ align-items: center;
145
+ padding: 0 4px;
146
+ white-space: nowrap;
147
+ .inputsDivItemLabel {
148
+ padding: 0 4px;
149
+ }
150
+ }
151
+ }
152
+
153
+ .reportTable {
154
+ width: 100%;
155
+ border-collapse: collapse;
156
+ table-layout:fixed;
157
+ word-break:break-all;
158
+ }
159
+ }
160
+ .tools{
161
+ position: fixed;
162
+ right: 2%;
163
+ text-align: right;
164
+ width: 60%;
165
+ cursor: pointer;
166
+ .toolsItem{
167
+ width: 15%;
168
+ margin-right: 3%;
169
+ display: inline-block;
170
+ }
171
+ }
172
+ </style>
173
+ </head>
174
+ <body>
175
+ <!-- 将需要打印的元素内容复制到新窗口中 -->
176
+ ${elementToPrint.innerHTML}
177
+ </body>
178
+ </html>
179
+ `)
180
+ // 延迟执行打印,以确保新窗口的内容已加载完成
181
+ printWindow.document.close() // 关闭文档流,确保内容完全加载
182
+ setTimeout(() => {
183
+ printWindow.print() // 调用打印方法
184
+ printWindow.close()
185
+ }, 500) // 延迟500毫秒后执行打印
186
+ }
@@ -0,0 +1,243 @@
1
+ # XTable 表格组件使用指南
2
+
3
+ ## 进度组件使用
4
+
5
+ XTable 支持两种类型的进度显示:
6
+
7
+ 1. **静态进度**: 使用 Ant Design 的 `a-progress` 组件显示静态进度值
8
+ 2. **实时进度**: 使用 `XWebSocketProgress` 组件通过 WebSocket 实时更新进度值
9
+
10
+ ### 1. 静态进度
11
+
12
+ 用于显示静态的进度值,不需要实时更新。
13
+
14
+ ```javascript
15
+ // 表格列配置
16
+ const columns = [
17
+ {
18
+ title: '任务名称',
19
+ dataIndex: 'taskName',
20
+ key: 'taskName'
21
+ },
22
+ {
23
+ title: '进度',
24
+ dataIndex: 'progress',
25
+ key: 'progress',
26
+ slotType: 'progress' // 使用静态进度组件
27
+ }
28
+ ]
29
+
30
+ // 表格数据
31
+ const tableData = [
32
+ {
33
+ taskName: '任务1',
34
+ progress: 75 // 显示 75% 进度
35
+ },
36
+ {
37
+ taskName: '任务2',
38
+ progress: 100 // 显示 100% 进度
39
+ }
40
+ ]
41
+ ```
42
+
43
+ ### 2. 实时进度
44
+
45
+ 用于实时更新进度值,通过 WebSocket 连接获取最新的进度信息。
46
+
47
+ ```javascript
48
+ // 表格列配置
49
+ const columns = [
50
+ {
51
+ title: '任务名称',
52
+ dataIndex: 'taskName',
53
+ key: 'taskName'
54
+ },
55
+ {
56
+ title: '进度',
57
+ dataIndex: 'progress',
58
+ key: 'progress',
59
+ slotType: 'progress',
60
+ websocketUrl: 'ws://localhost:8080/progress/task1', // WebSocket 连接地址
61
+ showConnectionStatus: true // 是否显示连接状态
62
+ }
63
+ ]
64
+
65
+ // 表格数据
66
+ const tableData = [
67
+ {
68
+ taskName: '实时任务1',
69
+ progress: 0 // 初始进度值
70
+ }
71
+ ]
72
+ ```
73
+
74
+ ### 3. 混合使用
75
+
76
+ 可以在同一个表格中混合使用两种进度显示:
77
+
78
+ ```javascript
79
+ const columns = [
80
+ {
81
+ title: '任务名称',
82
+ dataIndex: 'taskName',
83
+ key: 'taskName'
84
+ },
85
+ {
86
+ title: '静态进度',
87
+ dataIndex: 'staticProgress',
88
+ key: 'staticProgress',
89
+ slotType: 'progress' // 使用静态进度
90
+ },
91
+ {
92
+ title: '实时进度',
93
+ dataIndex: 'realtimeProgress',
94
+ key: 'realtimeProgress',
95
+ slotType: 'progress',
96
+ websocketUrl: 'ws://localhost:8080/progress/realtime', // 使用实时进度
97
+ showConnectionStatus: true
98
+ }
99
+ ]
100
+ ```
101
+
102
+ ## WebSocket 消息格式
103
+
104
+ WebSocket 进度组件支持以下消息格式:
105
+
106
+ ### 1. 标准格式
107
+
108
+ ```json
109
+ {
110
+ "progress": 75
111
+ }
112
+ ```
113
+
114
+ ### 2. 自定义字段名
115
+
116
+ ```json
117
+ {
118
+ "percentage": 60
119
+ }
120
+ ```
121
+
122
+ ### 3. 包含其他信息
123
+
124
+ ```json
125
+ {
126
+ "progress": 50,
127
+ "message": "正在处理数据...",
128
+ "status": "processing"
129
+ }
130
+ ```
131
+
132
+ ### 4. 纯数字
133
+
134
+ ```json
135
+ 80
136
+ ```
137
+
138
+ ## 事件处理
139
+
140
+ WebSocket 进度组件会触发以下事件:
141
+
142
+ ```javascript
143
+ // 在表格组件中监听进度更新事件
144
+ methods: {
145
+ handleProgressUpdated(data, record, dataIndex) {
146
+ console.log('进度更新:', {
147
+ value: data.value,
148
+ record: record,
149
+ field: dataIndex
150
+ })
151
+ }
152
+ }
153
+ ```
154
+
155
+ ## 完整示例
156
+
157
+ ```vue
158
+ <template>
159
+ <x-table
160
+ :columns="columns"
161
+ :data="tableData"
162
+ @progress-updated="handleProgressUpdated"
163
+ />
164
+ </template>
165
+
166
+ <script>
167
+ export default {
168
+ data() {
169
+ return {
170
+ columns: [
171
+ {
172
+ title: '任务ID',
173
+ dataIndex: 'id',
174
+ key: 'id',
175
+ width: 80
176
+ },
177
+ {
178
+ title: '任务名称',
179
+ dataIndex: 'name',
180
+ key: 'name'
181
+ },
182
+ {
183
+ title: '静态进度',
184
+ dataIndex: 'staticProgress',
185
+ key: 'staticProgress',
186
+ slotType: 'progress'
187
+ },
188
+ {
189
+ title: '实时进度',
190
+ dataIndex: 'realtimeProgress',
191
+ key: 'realtimeProgress',
192
+ slotType: 'progress',
193
+ websocketUrl: 'ws://localhost:8080/progress',
194
+ showConnectionStatus: true,
195
+ progressField: 'percentage'
196
+ },
197
+ {
198
+ title: '状态',
199
+ dataIndex: 'status',
200
+ key: 'status',
201
+ width: 100
202
+ }
203
+ ],
204
+ tableData: [
205
+ {
206
+ id: 1,
207
+ name: '数据处理任务',
208
+ staticProgress: 100,
209
+ realtimeProgress: 0,
210
+ status: '进行中'
211
+ },
212
+ {
213
+ id: 2,
214
+ name: '文件上传任务',
215
+ staticProgress: 75,
216
+ realtimeProgress: 0,
217
+ status: '等待中'
218
+ }
219
+ ]
220
+ }
221
+ },
222
+ methods: {
223
+ handleProgressUpdated(data, record, dataIndex) {
224
+ // 更新表格数据
225
+ this.$set(record, dataIndex, data.value)
226
+
227
+ // 可以在这里添加其他业务逻辑
228
+ if (data.value === 100) {
229
+ record.status = '已完成'
230
+ }
231
+ }
232
+ }
233
+ }
234
+ </script>
235
+ ```
236
+
237
+ ## 注意事项
238
+
239
+ 1. **WebSocket URL**: 确保 WebSocket 服务器地址正确且可访问
240
+ 2. **消息格式**: 确保服务器发送的消息格式符合组件要求
241
+ 3. **性能考虑**: 如果表格数据量大,建议只在需要实时更新的列使用 WebSocket 进度组件
242
+ 4. **错误处理**: WebSocket 连接失败时会自动重连,但建议监听错误事件
243
+ 5. **内存管理**: 组件销毁时会自动断开 WebSocket 连接
@@ -153,6 +153,7 @@
153
153
  <template v-if="isTableMode">
154
154
  <x-table-wrapper
155
155
  ref="table"
156
+ :queryParamsName="queryParamsName"
156
157
  :disableAction="disableAction"
157
158
  @rowClick="handleRowClick"
158
159
  @beforeDataChange="beforeDataChange"
@@ -211,7 +211,16 @@
211
211
  <ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
212
212
  </span>
213
213
  <span v-else-if="item.slotType === 'progress'" :key="'progress-' + c_index">
214
- <a-progress :percent="text" status="active" style="padding-right: 20px;" />
214
+ <!-- websocket-id (配置名称-字段名称-用户id-页码-数据行id) -->
215
+ <x-web-socket-progress
216
+ v-if="item.webSocket"
217
+ :key="`${tableContext.requestParameters?.pageNo || 1}-${item.dataIndex}-${record[tableContext.rowKey] || index}`"
218
+ :websocket-id="`${queryParamsName}-${item.dataIndex}-${currUser.id}-${tableContext.requestParameters?.pageNo || 1}-${record[tableContext.rowKey] || index}`"
219
+ :initial-value="text || 0"
220
+ @progress-updated="(data) => handleProgressUpdated(data, record, item.dataIndex)"
221
+ />
222
+ <!-- 表格进度组件 -->
223
+ <a-progress v-else :percent="text" status="active" style="padding-right: 20px;" />
215
224
  </span>
216
225
  <span v-else-if="item.slotType === 'badge'" :key="'badge-' + c_index">
217
226
  <x-badge
@@ -277,7 +286,9 @@ import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormIte
277
286
  import CustomFuncCel from '@vue2-client/base-client/components/common/XTable/CustomFuncCel.vue'
278
287
  import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
279
288
  import XRate from '@vue2-client/base-client/components/common/XRate/index.vue'
289
+ import XWebSocketProgress from '@vue2-client/base-client/components/common/XWebSocketProgress'
280
290
  import VueDraggableResizable from 'vue-draggable-resizable'
291
+ import { mapState } from 'vuex'
281
292
 
282
293
  export default {
283
294
  name: 'XTableWrapper',
@@ -288,6 +299,7 @@ export default {
288
299
  XFormItem,
289
300
  XRate,
290
301
  CustomFuncCel,
302
+ XWebSocketProgress,
291
303
  VueDraggableResizable
292
304
  },
293
305
  data () {
@@ -298,6 +310,7 @@ export default {
298
310
  }
299
311
  },
300
312
  computed: {
313
+ ...mapState('account', { currUser: 'user' }),
301
314
  localDataSource () {
302
315
  return this.activeTable?.localDataSource
303
316
  },
@@ -426,6 +439,13 @@ export default {
426
439
  }
427
440
  },
428
441
  props: {
442
+ // 查询配置文件名
443
+ queryParamsName: {
444
+ type: String,
445
+ default: () => {
446
+ return ''
447
+ }
448
+ },
429
449
  loadSelectedData: {
430
450
  type: Boolean,
431
451
  required: false,
@@ -547,7 +567,20 @@ export default {
547
567
  },
548
568
  handleResizeColumn (w, col) {
549
569
  col.width = w
550
- }
570
+ },
571
+
572
+ /**
573
+ * 处理进度更新事件
574
+ * @param {Object} data 进度数据
575
+ * @param {Object} record 行数据
576
+ * @param {String} dataIndex 列字段名
577
+ */
578
+ handleProgressUpdated (data, record, dataIndex) {
579
+ // 更新行数据中的进度值
580
+ if (record && dataIndex) {
581
+ this.$set(record, dataIndex, data.value)
582
+ }
583
+ },
551
584
  }
552
585
  }
553
586
  </script>