vue2-client 1.8.237 → 1.8.239

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.
@@ -2,6 +2,7 @@
2
2
  <div>
3
3
  <template v-if="this.activatedConfig.designMode === 'json'">
4
4
  <XReportJsonRender
5
+ :display-only="displayOnly"
5
6
  :show-title="showTitle"
6
7
  :no-padding="noPadding"
7
8
  :no-top-border="noTopBorder"
@@ -50,6 +51,8 @@
50
51
  <template v-if="row[0].type !== 'inputColumns' && row[0].type !== 'list'">
51
52
  <template v-if="!forDisplay">
52
53
  <x-report-tr-group
54
+ @updateImg="updateImg"
55
+ :use-oss-for-img="useOssForImg"
53
56
  :key="rowIndex"
54
57
  :columns="row"
55
58
  :no-top-border="noTopBorder"
@@ -59,6 +62,8 @@
59
62
  </template>
60
63
  <template v-else>
61
64
  <x-report-tr-group
65
+ @updateImg="updateImg"
66
+ :use-oss-for-img="useOssForImg"
62
67
  :config="activatedConfig"
63
68
  :key="rowIndex"
64
69
  :columns="row"
@@ -73,6 +78,8 @@
73
78
  <template v-for="(num, listIndex) in row[0].listLength + 1">
74
79
  <template v-if="!forDisplay">
75
80
  <x-report-tr-group
81
+ @updateImg="updateImg"
82
+ :use-oss-for-img="useOssForImg"
76
83
  :config="activatedConfig"
77
84
  :key="rowIndex + listIndex"
78
85
  :columns="row"
@@ -83,6 +90,8 @@
83
90
  </template>
84
91
  <template v-else>
85
92
  <x-report-tr-group
93
+ @updateImg="updateImg"
94
+ :use-oss-for-img="useOssForImg"
86
95
  :config="activatedConfig"
87
96
  :key="rowIndex + listIndex"
88
97
  :columns="row"
@@ -98,6 +107,8 @@
98
107
  <template v-else>
99
108
  <template v-if="forDisplay">
100
109
  <x-report-tr-group
110
+ @updateImg="updateImg"
111
+ :use-oss-for-img="useOssForImg"
101
112
  :config="activatedConfig"
102
113
  :columns="row[0].definition"
103
114
  :config-data="{arr: activatedConfig.data[row[0].dataIndex]}"
@@ -110,6 +121,8 @@
110
121
  </template>
111
122
  <template v-if="!forDisplay">
112
123
  <x-report-tr-group
124
+ @updateImg="updateImg"
125
+ :use-oss-for-img="useOssForImg"
113
126
  :config="activatedConfig"
114
127
  :columns="row[0].definition"
115
128
  :config-data="{arr: activatedConfig.data[row[0].dataIndex]}"
@@ -120,6 +133,8 @@
120
133
  :key="row[0].dataIndex + definitionIndex + rowIndex"></x-report-tr-group>
121
134
  <!-- 动态行交互按钮 -->
122
135
  <x-report-tr-group
136
+ @updateImg="updateImg"
137
+ :use-oss-for-img="useOssForImg"
123
138
  :config="activatedConfig"
124
139
  :key="rowIndex"
125
140
  :columns="row"
@@ -155,38 +170,56 @@ import { getConfigByName } from '@vue2-client/services/api/common'
155
170
  export default {
156
171
  name: 'XReportDesign',
157
172
  props: {
173
+ // 配置
158
174
  config: {
159
175
  type: Object,
160
176
  require: true,
161
177
  default: () => {}
162
178
  },
179
+ // 是否是展示用
163
180
  forDisplay: {
164
181
  type: Boolean,
165
182
  default: false
166
183
  },
184
+ // 是否只能展示不可编辑
185
+ displayOnly: {
186
+ type: Boolean,
187
+ default: false
188
+ },
189
+ // 插槽名
167
190
  slotConfigName: {
168
191
  type: String,
169
192
  default: undefined
170
193
  },
194
+ // 将图片全部展示在表格之后,挨个罗列
171
195
  showImages: {
172
196
  type: Boolean,
173
197
  default: false
174
198
  },
199
+ // 图片罗列的数组
175
200
  imageList: {
176
201
  type: Array,
177
202
  default: undefined
178
203
  },
204
+ // 表格没有边距
179
205
  noPadding: {
180
206
  type: Boolean,
181
207
  default: false
182
208
  },
209
+ // 表格没有上边框,与noPadding搭配可以实现连续表格
183
210
  noTopBorder: {
184
211
  type: Boolean,
185
212
  default: false
186
213
  },
214
+ // 是否展示标题
187
215
  showTitle: {
188
216
  type: Boolean,
189
217
  default: true
218
+ },
219
+ // 图片是否使用OSS来保存
220
+ useOssForImg: {
221
+ type: Boolean,
222
+ default: true
190
223
  }
191
224
  },
192
225
  components: {
@@ -195,13 +228,20 @@ export default {
195
228
  },
196
229
  data () {
197
230
  return {
231
+ // 表单的数据
198
232
  data: this.config.data,
233
+ // 插槽配置
199
234
  slotConfig: undefined,
235
+ // 控制是否渲染
200
236
  render: false,
237
+ // 用于展示的配置
201
238
  activatedConfig: {}
202
239
  }
203
240
  },
204
241
  methods: {
242
+ updateImg (data) {
243
+ this.$emit('updateImg', data)
244
+ },
205
245
  // 根据format计算需要多少个输入框
206
246
  calcFormatInputNum (formatStr) {
207
247
  let count = 0
@@ -268,6 +308,8 @@ export default {
268
308
  }
269
309
  })
270
310
  },
311
+ mounted () {
312
+ },
271
313
  watch: {
272
314
  config: {
273
315
  deep: true,
@@ -2,6 +2,7 @@
2
2
  <div :class="noPadding ? 'reportMainNoPadding' : 'reportMain'">
3
3
  <table class="reportTable" :style="config.style ? config.style : undefined">
4
4
  <tbody class="'reportTable'">
5
+ <!-- 标题 -->
5
6
  <tr v-if="showTitle && config.title.type && config.title.type !== ''">
6
7
  <td :class="noTopBorder ? 'tdWithNoTopBorder' : 'tdWithBorder'" colspan="12">
7
8
  <template v-if="config.title.type === 'titleKey'">
@@ -13,6 +14,7 @@
13
14
  </td>
14
15
  </tr>
15
16
  <template v-for="(row, rowIndex) in config.content">
17
+ <!-- 数据对象是一个Obj -->
16
18
  <template v-if="row.type === 'jsonKey'">
17
19
  <tr :key="rowIndex">
18
20
  <!-- 表头 -->
@@ -32,13 +34,18 @@
32
34
  :class="noTopBorder ? 'tdWithNoTopBorder' : 'tdWithBorder'"
33
35
  :style="determineCellStyle(receivedFunction[rowIndex].valueFunction(config))"
34
36
  colspan="6">
35
- <template v-if="receivedFunction[rowIndex].valueFunction(config).type === 'key'">
36
- {{ config.data[receivedFunction[rowIndex].valueFunction(config).content] }}
37
+ <template v-if="displayOnly">
38
+ <template v-if="receivedFunction[rowIndex].valueFunction(config).type === 'key'">
39
+ {{ config.data[receivedFunction[rowIndex].valueFunction(config).content] }}
40
+ </template>
41
+ <template v-else-if="receivedFunction[rowIndex].valueFunction(config).type === 'value'">
42
+ {{ receivedFunction[rowIndex].valueFunction(config).content }}
43
+ </template>
37
44
  </template>
38
- <template v-else-if="receivedFunction[rowIndex].valueFunction(config).type === 'value'">
39
- {{ receivedFunction[rowIndex].valueFunction(config).content }}
45
+ <template v-else>
46
+ <a-input v-model="config.data[receivedFunction[rowIndex].valueFunction(config).originalKey]"/>
40
47
  </template>
41
- <template v-else-if="receivedFunction[rowIndex].valueFunction(config).type === 'img'">
48
+ <template v-if="receivedFunction[rowIndex].valueFunction(config).type === 'img'">
42
49
  <template v-for="(img, imgIndex) in receivedFunction[rowIndex].valueFunction(config).content">
43
50
  <span :key="imgIndex" class="imgText">
44
51
  <a-icon type="link"/>
@@ -50,6 +57,7 @@
50
57
  </td>
51
58
  </tr>
52
59
  </template>
60
+ <!-- 数据对象是一个Array -->
53
61
  <template v-else-if="row.type === 'jsonArray'">
54
62
  <tr :key="rowIndex + '' + jsonArrayItemIndex" v-for="(item, jsonArrayItemIndex) in config.data[row.jsonArrayDataIndex]">
55
63
  <!-- 表头 -->
@@ -69,11 +77,16 @@
69
77
  :class="noTopBorder ? 'tdWithNoTopBorder' : 'tdWithBorder'"
70
78
  :style="determineCellStyle(receivedFunction[rowIndex].valueFunction(config, item))"
71
79
  colspan="6">
72
- <template v-if="receivedFunction[rowIndex].valueFunction(config, item).type === 'key'">
73
- {{ item[receivedFunction[rowIndex].valueFunction(config, item).content] }}
80
+ <template v-if="displayOnly">
81
+ <template v-if="receivedFunction[rowIndex].valueFunction(config, item).type === 'key'">
82
+ {{ item[receivedFunction[rowIndex].valueFunction(config, item).content] }}
83
+ </template>
84
+ <template v-if="receivedFunction[rowIndex].valueFunction(config, item).type === 'value'">
85
+ {{ receivedFunction[rowIndex].valueFunction(config, item).content }}
86
+ </template>
74
87
  </template>
75
- <template v-if="receivedFunction[rowIndex].valueFunction(config, item).type === 'value'">
76
- {{ receivedFunction[rowIndex].valueFunction(config, item).content }}
88
+ <template v-else>
89
+ <a-input v-model="item[receivedFunction[rowIndex].valueFunction(config, item).originalKey]"/>
77
90
  </template>
78
91
  </td>
79
92
  </tr>
@@ -81,6 +94,7 @@
81
94
  </template>
82
95
  </tbody>
83
96
  </table>
97
+ <!-- 图片展示弹框 -->
84
98
  <a-modal
85
99
  title="图片"
86
100
  width="80%"
@@ -101,42 +115,59 @@
101
115
  export default {
102
116
  name: 'XReportJsonRender',
103
117
  props: {
118
+ // 配置
104
119
  config: {
105
120
  type: Object,
106
121
  required: true
107
122
  },
123
+ // 表格没有边距
108
124
  noPadding: {
109
125
  type: Boolean,
110
126
  default: false
111
127
  },
128
+ // 表格没有上边框,与noPadding搭配可以实现连续表格
112
129
  noTopBorder: {
113
130
  type: Boolean,
114
131
  default: false
115
132
  },
133
+ // 是否展示标题
116
134
  showTitle: {
117
135
  type: Boolean,
118
136
  default: true
137
+ },
138
+ // 是否仅展示
139
+ displayOnly: {
140
+ type: Boolean,
141
+ default: true
119
142
  }
120
143
  },
121
144
  data () {
122
145
  return {
146
+ // 储存所有json传递的函数
123
147
  receivedFunction: [],
148
+ // 控制弹框显隐
124
149
  showImgModal: false,
150
+ // 弹框中图片路径
125
151
  showImageSrc: undefined
126
152
  }
127
153
  },
128
154
  methods: {
155
+ // 判断单元格样式
129
156
  determineCellStyle (labelFunctionReturn, color = '#000', borderWidth = '1px') {
157
+ // 如果声明了边框颜色
130
158
  if (labelFunctionReturn.style.borderColor) {
131
159
  color = labelFunctionReturn.style.borderColor
132
160
  }
161
+ // 如果声明了边框宽度
133
162
  if (labelFunctionReturn.style.borderWidth) {
134
163
  borderWidth = labelFunctionReturn.style.borderWidth
135
164
  }
165
+ // 正常边框单元格
136
166
  const withBorder = {
137
167
  border: borderWidth + ' solid ' + color,
138
168
  padding: '8px'
139
169
  }
170
+ // 仅没有上边框单元格
140
171
  const NoTopBorder = {
141
172
  borderTopStyle: 'none',
142
173
  borderLeft: borderWidth + ' solid ' + color,
@@ -145,6 +176,7 @@ export default {
145
176
  padding: '8px'
146
177
  }
147
178
  let result = {}
179
+ // 判断表头是否有声明的样式
148
180
  if (labelFunctionReturn.style !== undefined) {
149
181
  if (this.noTopBorder) {
150
182
  result = { ...NoTopBorder, ...labelFunctionReturn.style }
@@ -177,6 +209,7 @@ export default {
177
209
  }
178
210
  },
179
211
  beforeMount () {
212
+ // 遍历配置,将所有JSON传递的方法保存到一个数组中,并用index来一一对应
180
213
  for (let i = 0; i < this.config.content.length; i++) {
181
214
  this.receivedFunction.push({
182
215
  // eslint-disable-next-line no-eval
@@ -239,14 +239,26 @@
239
239
  </template>
240
240
  <template v-else-if="cell.type === 'images'">
241
241
  <div>
242
- <upload
243
- :model="{type: 'image', accept: ['*'], resUploadStock: 1, pathKey: 'cs', resUploadMode: 'oss'}"
244
- service-name="af-system"
245
- :images="configData.images[cell.dataIndex]"
246
- :outer-container-index="cell.dataIndex"
247
- @setFiles="setImages"
248
- :upload-style="'simple'"
249
- />
242
+ <template v-if="configData.images[cell.dataIndex].length > 0">
243
+ <upload
244
+ :model="uploadParams"
245
+ service-name="af-system"
246
+ :images="checkImg(cell.dataIndex, 'configData')"
247
+ :outer-container-index="cell.dataIndex"
248
+ @setFiles="(...args) => {setImages(args, 'configData')}"
249
+ :upload-style="'simple'"
250
+ />
251
+ </template>
252
+ <template v-else>
253
+ <upload
254
+ :model="uploadParams"
255
+ service-name="af-system"
256
+ :images="checkImg(cell.dataIndex, 'config')"
257
+ :outer-container-index="cell.dataIndex"
258
+ @setFiles="(...args) => {setImages(args, 'config', cell.dataIndex)}"
259
+ :upload-style="'simple'"
260
+ />
261
+ </template>
250
262
  </div>
251
263
  </template>
252
264
  </td>
@@ -370,39 +382,84 @@ export default {
370
382
  type: Boolean,
371
383
  default: false
372
384
  },
373
- // listIndex
385
+ // list类型的下标,用于遍历列表时,获取对应的数据
374
386
  listIndex: {
375
387
  type: Number,
376
388
  default: undefined
377
389
  },
390
+ // 表格没有上边框
378
391
  noTopBorder: {
379
392
  type: Boolean,
380
393
  default: false
394
+ },
395
+ // 图片是否使用OSS来保存
396
+ useOssForImg: {
397
+ type: Boolean,
398
+ default: true
381
399
  }
382
400
  },
383
401
  data () {
384
402
  return {
385
- maxColSpan: 12
403
+ maxColSpan: 12,
404
+ uploadParams: {
405
+ type: 'image',
406
+ accept: ['*'],
407
+ resUploadStock: 1,
408
+ pathKey: 'cs'
409
+ }
386
410
  // tableConfig: {}
387
411
  }
388
412
  },
389
413
  methods: {
414
+ updateImg (data) {
415
+ this.$emit('updateImg', data)
416
+ },
417
+ checkImg (index, type) {
418
+ let target
419
+ if (type === 'configData') {
420
+ target = this.configData.images[index]
421
+ } else {
422
+ target = this.config.tempData[index]
423
+ }
424
+ target.forEach(obj => {
425
+ if (obj.uid === undefined) {
426
+ obj.uid = obj.id.toString()
427
+ }
428
+ if (obj.url === undefined) {
429
+ if (obj.path) {
430
+ obj.url = obj.path
431
+ }
432
+ }
433
+ if (obj.name === undefined) {
434
+ const withOutEndFix = obj.url.split('.')[0]
435
+ const temp = withOutEndFix.split('/')
436
+ obj.name = temp[temp.length - 1]
437
+ }
438
+ })
439
+ return target
440
+ },
441
+ // 判断单元格样式
390
442
  determineCellStyle (cell, color = '#000', borderWidth = '1px') {
443
+ // 如果声明了borderColor
391
444
  if (this.config.style.borderColor) {
392
445
  color = this.config.style.borderColor
393
446
  }
447
+ // 如果声明了borderWidth
394
448
  if (this.config.style.borderWidth) {
395
449
  borderWidth = this.config.style.borderWidth
396
450
  }
451
+ // 普通带边框单元格
397
452
  const withBorder = {
398
453
  border: borderWidth + ' solid ' + color,
399
454
  padding: '8px'
400
455
  }
456
+ // 只有左右边框的单元格
401
457
  const noBorder = {
402
458
  borderLeft: borderWidth + ' solid ' + color,
403
459
  borderRight: borderWidth + ' solid ' + color,
404
460
  padding: '8px'
405
461
  }
462
+ // 只没有上边框的单元格
406
463
  const NoTopBorder = {
407
464
  borderTopStyle: 'none',
408
465
  borderLeft: borderWidth + ' solid ' + color,
@@ -411,6 +468,7 @@ export default {
411
468
  padding: '8px'
412
469
  }
413
470
  let result = {}
471
+ // 如果表格也声明了样式,用表格样式将样式覆盖
414
472
  if (cell.style) {
415
473
  if (cell.noBorder) {
416
474
  result = { ...noBorder, ...cell.style }
@@ -423,6 +481,7 @@ export default {
423
481
  }
424
482
  return result
425
483
  }
484
+ // 如果表头声明了样式,则用其将基础样式覆盖
426
485
  if (cell.type === 'column') {
427
486
  if (this.config.labelStyle !== undefined) {
428
487
  if (cell.noBorder) {
@@ -448,9 +507,11 @@ export default {
448
507
  }
449
508
  return result
450
509
  },
510
+ // 表格中数据key含有@@@,需要手动触发更新
451
511
  handleInputDeepChange () {
452
512
  this.$forceUpdate()
453
513
  },
514
+ // 路径中含有@@@的key,将其解析,并返回其数据
454
515
  getDeepObject (obj, strPath) {
455
516
  const arr = strPath.split('@@@')
456
517
  let result = obj[arr[0]]
@@ -465,6 +526,7 @@ export default {
465
526
  }
466
527
  return result
467
528
  },
529
+ // 获取当前日期
468
530
  getNowDate (index1, index2) {
469
531
  if (index2) {
470
532
  // @click="getNowDate(configData.arr[inputColumnsDefinitionIndex][cell.dataIndex])"
@@ -474,14 +536,28 @@ export default {
474
536
  }
475
537
  this.configData = Object.assign({}, this.configData)
476
538
  },
539
+ // 反序列化函数并执行
477
540
  deserializeFunctionAndRun (functionStr, value) {
478
541
  // eslint-disable-next-line no-eval
479
542
  const fun = eval('(' + functionStr + ')')
480
543
  return fun(value, this.config)
481
544
  },
482
- setImages (imageIds, dataIndex) {
483
- this.configData.images[dataIndex] = imageIds
545
+ // 基础上传组件,图片改动后触发
546
+ setImages (args, type, index = undefined) {
547
+ // 如果基础上传组件在初始化完成后,就调用emit了setImage,此时图片并没有变化,直接返回
548
+ if (args[2] === 'created') {
549
+ return
550
+ }
551
+ if (type === 'configData') {
552
+ this.configData.images[args[1]] = args[0]
553
+ } else {
554
+ this.config.tempData[args[1]] = args[0]
555
+ if (index) {
556
+ this.$emit('updateImg', this.config.tempData[index])
557
+ }
558
+ }
484
559
  },
560
+ // 动态行删除
485
561
  removeData (index) {
486
562
  if (this.configData[index].length === 0) {
487
563
  this.$message.warn('已经没有更多了')
@@ -620,6 +696,9 @@ export default {
620
696
  },
621
697
  },
622
698
  beforeMount () {
699
+ if (this.useOssForImg) {
700
+ this.uploadParams.resUploadMode = 'oss'
701
+ }
623
702
  }
624
703
  }
625
704
 
@@ -1,48 +1,48 @@
1
- # XReportSlot 暂时废弃
2
-
3
-
4
- 动态报表的插槽组件,可以递归使用
5
-
6
-
7
- ## 何时使用
8
-
9
- > 当需要一个动态生成的报表时
10
-
11
- > 一般由XReportDesign嵌套使用,在XReportDesign中判断当前行如果类型是slot,
12
- > 则递归此组件
13
-
14
- 引用方式:
15
-
16
- ```javascript
17
- import XReportSlot from '@vue2-client/base-client/components/XReportSlot/XReportSlot'
18
-
19
- export default {
20
- components: {
21
- XReportSlot
22
- }
23
- }
24
- ```
25
-
26
-
27
- ## API
28
-
29
- | 参数 | 说明 | 类型 | 默认值 |
30
- |-----------------|--------------------------|--------|------|
31
- | config | 表格完整配置 | Object | 无(必填) |
32
- | forDisplay | 是否为展示页 | Boolean | false |
33
- | slotConfigName | 插槽名 | String | undefined |
34
-
35
- ## 例子1
36
- ----
37
- ```vue
38
- <XReportSlot
39
- :config="activatedConfig"
40
- :slot-config-name="slotConfig"
41
- :for-display="forDisplay">
42
- </XReportSlot>
43
- ```
44
- ## 注意事项
45
- > slotConfigName如果不填,则展示整个表格。
46
- > 如果填写,则仅展示插槽中的内容
47
-
48
- > 该组件可以递归调用
1
+ # XReportSlot 暂时废弃
2
+
3
+
4
+ 动态报表的插槽组件,可以递归使用
5
+
6
+
7
+ ## 何时使用
8
+
9
+ > 当需要一个动态生成的报表时
10
+
11
+ > 一般由XReportDesign嵌套使用,在XReportDesign中判断当前行如果类型是slot,
12
+ > 则递归此组件
13
+
14
+ 引用方式:
15
+
16
+ ```javascript
17
+ import XReportSlot from '@vue2-client/base-client/components/XReportSlot/XReportSlot'
18
+
19
+ export default {
20
+ components: {
21
+ XReportSlot
22
+ }
23
+ }
24
+ ```
25
+
26
+
27
+ ## API
28
+
29
+ | 参数 | 说明 | 类型 | 默认值 |
30
+ |-----------------|--------------------------|--------|------|
31
+ | config | 表格完整配置 | Object | 无(必填) |
32
+ | forDisplay | 是否为展示页 | Boolean | false |
33
+ | slotConfigName | 插槽名 | String | undefined |
34
+
35
+ ## 例子1
36
+ ----
37
+ ```vue
38
+ <XReportSlot
39
+ :config="activatedConfig"
40
+ :slot-config-name="slotConfig"
41
+ :for-display="forDisplay">
42
+ </XReportSlot>
43
+ ```
44
+ ## 注意事项
45
+ > slotConfigName如果不填,则展示整个表格。
46
+ > 如果填写,则仅展示插槽中的内容
47
+
48
+ > 该组件可以递归调用