vue2-client 1.8.133 → 1.8.136

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,330 +1,357 @@
1
- <template>
2
- <tr>
3
- <!-- 预览页展示 -->
4
- <template v-if="display">
5
- <template v-if="!inputColumns">
6
- <td
7
- v-for="(cell, cellIndex) in columns"
8
- v-if="!cell.dontShowRow"
9
- :key="cellIndex"
10
- :class=" cell.noBoarder ? 'tdNoBorder' : 'tdWithBorder'"
11
- :style="cell.style ? cell.style : undefined"
12
- :colspan="cell.colSpan ? cell.colSpan : undefined">
13
- <template v-if="cell.type === 'column'">
14
- {{ cell.text }}
15
- </template>
16
- <template v-else-if="cell.type === 'placeHolderColumn'">
17
- <!-- 占位 -->
18
- </template>
19
- <template v-else-if="cell.type === 'value'">
20
- {{ cell.value }}
21
- </template>
22
- <template v-else-if="cell.type === 'input'">
23
- {{ configData[cell.dataIndex] }}
24
- </template>
25
- <template v-else-if="cell.type === 'inputs'">
26
- {{ showSubRowValue(cell) }}
27
- </template>
28
- </td>
29
- </template>
30
- <template v-else>
31
- <td
32
- v-for="(cell, cellIndex) in columns"
33
- :key="cellIndex"
34
- :class=" cell.noBoarder ? 'tdNoBorder' : 'tdWithBorder'"
35
- :colspan="cell.colSpan ? cell.colSpan : undefined"
36
- :style="cell.style ? cell.style : undefined"
37
- :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
38
- <template v-if="cell.type === 'column'">
39
- {{ cell.text }}
40
- </template>
41
- <template v-else-if="cell.type === 'value'">
42
- {{ cell.value }}
43
- </template>
44
- <template v-else-if="cell.type === 'increment'">
45
- {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
46
- </template>
47
- <template v-else-if="cell.type === 'input'">
48
- {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
49
- </template>
50
- <template v-else-if="cell.type === 'inputs'">
51
- {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
52
- </template>
53
- </td>
54
- </template>
55
- </template>
56
- <!-- 不是动态行 -->
57
- <template v-else-if="!inputColumns">
58
- <td
59
- v-for="(cell, cellIndex) in columns"
60
- :key="cellIndex"
61
- :class=" cell.noBoarder ? 'tdNoBorder' : 'tdWithBorder'"
62
- :colspan="cell.colSpan ? cell.colSpan : undefined"
63
- :style="cell.style ? cell.style : undefined"
64
- :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
65
- <template v-if="cell.type === 'column'">
66
- {{ cell.text }}
67
- </template>
68
- <template v-else-if="cell.type === 'placeHolderColumn'">
69
- <!-- 占位 -->
70
- </template>
71
- <template v-else-if="cell.type === 'value'">
72
- {{ cell.value }}
73
- </template>
74
- <template v-else-if="cell.type === 'input'">
75
- <a-input v-model="configData[cell.dataIndex]" :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
76
- </template>
77
- <template v-else-if="cell.type === 'inputs'">
78
- <div class="inputsDiv">
79
- <div class="inputsDivItem" v-for="(num, index) of calcFormatInputNum(cell.format)" :key="index">
80
- <span class="inputsDivItemLabel">{{ displayFormatStartText(cell.format) }}</span>
81
- <a-input v-model="configData[cell.dataIndex][index]" :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
82
- <span class="inputsDivItemLabel">{{ displayFormatText(cell.format, index) }}</span>
83
- </div>
84
- </div>
85
- </template>
86
- </td>
87
- </template>
88
- <!-- 动态行插入按钮 -->
89
- <template v-else-if="inputColumnsButton">
90
- <td :colspan="maxColSpan" class="tdWithBorder">
91
- <a-button-group>
92
- <a-button @click="addData(configData[columns[0].dataIndex], columns)"><a-icon type="plus"/></a-button>
93
- <a-button @click="removeData(configData[columns[0].dataIndex])"><a-icon type="minus"/></a-button>
94
- </a-button-group>
95
- </td>
96
- </template >
97
- <!-- 普通行 -->
98
- <template v-else>
99
- <td
100
- v-for="(cell, cellIndex) in columns"
101
- :key="cellIndex"
102
- :class=" cell.noBoarder ? 'tdNoBorder' : 'tdWithBorder'"
103
- :colspan="cell.colSpan ? cell.colSpan : undefined"
104
- :style="cell.style ? cell.style : undefined"
105
- :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
106
- <template v-if="cell.type === 'column'">
107
- {{ cell.text }}
108
- </template>
109
- <template v-else-if="cell.type === 'value'">
110
- {{ cell.value }}
111
- </template>
112
- <template v-else-if="cell.type === 'increment'">
113
- {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
114
- </template>
115
- <template v-else-if="cell.type === 'input'">
116
- <a-input v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]" :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
117
- </template>
118
- <template v-else-if="cell.type === 'inputs'">
119
- <a-input v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]" :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
120
- </template>
121
- </td>
122
- </template>
123
- </tr>
124
- </template>
125
-
126
- <script>
127
-
128
- export default {
129
- name: 'XReportTrGroup',
130
- props: {
131
- // 每一行的配置
132
- columns: {
133
- type: Array,
134
- required: true
135
- },
136
- config: {
137
- type: Object,
138
- default: function () {
139
- return {}
140
- }
141
- },
142
- // 原始配置
143
- configData: {
144
- type: Object,
145
- required: true
146
- },
147
- // 是否为动态行
148
- inputColumns: {
149
- type: Boolean,
150
- default: false
151
- },
152
- // 是否为动态行按钮
153
- inputColumnsButton: {
154
- type: Boolean,
155
- default: false
156
- },
157
- // 动态行的Index
158
- inputColumnsDefinitionIndex: {
159
- type: Number,
160
- default: undefined
161
- },
162
- // 是否为展示行
163
- display: {
164
- type: Boolean,
165
- default: false
166
- }
167
- },
168
- data () {
169
- return {
170
- maxColSpan: 12
171
- // tableConfig: {}
172
- }
173
- },
174
- methods: {
175
- removeData (dataItem) {
176
- if (dataItem.length === 0) {
177
- this.$message.warn('已经没有更多了')
178
- return
179
- }
180
- dataItem.pop()
181
- },
182
- // 添加一行
183
- addData (dataItem, row) {
184
- // 获取定义
185
- const defs = row[0].definition
186
-
187
- // 获取外层对象名
188
- const dataName = row[0].dataIndex
189
- const temp = {}
190
-
191
- defs.forEach(def => {
192
- // 找到数组中最后一个数据的值
193
- let lastDataNo = 0
194
- if (this.configData[dataName][this.configData[dataName].length - 1]) {
195
- lastDataNo = this.configData[dataName][this.configData[dataName].length - 1][def.dataIndex]
196
- }
197
-
198
- // 如果没有值,检查是否声明了初始值
199
- if (lastDataNo === 0 && def.initialValue) {
200
- lastDataNo = def.initialValue
201
- }
202
-
203
- // 检查是否有步长
204
- let step = 1
205
- if (def.step) {
206
- step = def.step
207
- }
208
-
209
- // 如果单元格类型为increment,则进行自增
210
- if (def.type === 'increment') {
211
- temp[def.dataIndex] = lastDataNo + step
212
- }
213
- })
214
- dataItem.push(temp)
215
- },
216
- // 根据format计算需要多少个输入框
217
- calcFormatInputNum (formatStr) {
218
- let count = 0
219
- for (let i = 0; i < formatStr.length; i++) {
220
- if (formatStr[i] === '{') {
221
- count++
222
- }
223
- }
224
- return count
225
- },
226
- // 根据format计算输入框之后的文字显示
227
- displayFormatText (formatStr, num) {
228
- let start = 0
229
- let count = 0
230
- num++
231
- for (let i = 0; i < formatStr.length; i++) {
232
- if (formatStr[i] === '}') {
233
- start = i
234
- count++
235
- }
236
- if (count === num) {
237
- for (let j = start + 1; j < formatStr.length; j++) {
238
- if (formatStr[j] === '{') {
239
- return formatStr.slice(start + 1, j)
240
- }
241
- if (j === formatStr.length - 1 && formatStr[j] !== '}') {
242
- return formatStr[j]
243
- }
244
- }
245
- }
246
- }
247
- },
248
- // 根据format计算输入框之前的文字显示
249
- displayFormatStartText (formatStr) {
250
- let count = 0
251
- for (let i = 0; i < formatStr.length; i++) {
252
- if (formatStr[i] === '{') {
253
- break
254
- } else {
255
- count++
256
- }
257
- }
258
- return formatStr.slice(0, count)
259
- },
260
- // 拼接被自动拆分的单元格内容
261
- showSubRowValue (cell) {
262
- const dataName = cell.dataIndex
263
- const formatArr = []
264
- const dataArr = []
265
-
266
- // 从config中取出所有数据,根据dataIndex的开头内容进行拼接
267
- this.config.columns.forEach(row => row.forEach(cell => {
268
- if (cell.dataIndex && cell.dataIndex.startsWith(dataName)) {
269
- formatArr.push(cell.format)
270
- dataArr.push(this.configData[cell.dataIndex])
271
- }
272
- }))
273
-
274
- const text = []
275
- const data = []
276
-
277
- formatArr.forEach(word => {
278
- const temp = word.split('{}')
279
- temp.forEach(char => {
280
- if (char !== '') {
281
- text.push(char)
282
- }
283
- })
284
- })
285
-
286
- dataArr.forEach(item => {
287
- item.forEach(num => {
288
- data.push(num)
289
- })
290
- })
291
-
292
- let result = ''
293
- for (let i = 0; i < data.length; i++) {
294
- result += data[i]
295
- result += text[i]
296
- }
297
-
298
- return result
299
- },
300
- },
301
- }
302
-
303
- </script>
304
-
305
- <style scoped lang="less">
306
- .inputsDiv {
307
- display: flex;
308
- justify-content: space-between;
309
- .inputsDivItem {
310
- display: flex;
311
- align-items: center;
312
- padding: 0 4px;
313
- white-space: nowrap;
314
- .inputsDivItemLabel {
315
- padding: 0 4px;
316
- }
317
- }
318
- }
319
-
320
- .tdNoBorder {
321
- border-left: 1px solid #000;
322
- border-right: 1px solid #000;
323
- padding: 8px;
324
- }
325
-
326
- .tdWithBorder {
327
- border: 1px solid #000;
328
- padding: 8px;
329
- }
330
- </style>
1
+ <template>
2
+ <tr>
3
+ <!-- 预览页展示 -->
4
+ <template v-if="display">
5
+ <template v-if="!inputColumns">
6
+ <td
7
+ v-for="(cell, cellIndex) in columns"
8
+ v-if="!cell.dontShowRow"
9
+ :key="cellIndex"
10
+ :class=" cell.noBoarder ? 'tdNoBorder' : 'tdWithBorder'"
11
+ :style="cell.style ? cell.style : undefined"
12
+ :colspan="cell.colSpan ? cell.colSpan : undefined">
13
+ <template v-if="cell.type === 'column'">
14
+ {{ cell.text }}
15
+ </template>
16
+ <template v-else-if="cell.type === 'placeHolderColumn'">
17
+ <!-- 占位 -->
18
+ </template>
19
+ <template v-else-if="cell.type === 'value'">
20
+ {{ cell.value }}
21
+ </template>
22
+ <template v-else-if="cell.type === 'input'">
23
+ {{ configData[cell.dataIndex] }}
24
+ </template>
25
+ <template v-else-if="cell.type === 'inputs'">
26
+ {{ showSubRowValue(cell) }}
27
+ </template>
28
+ <template v-else-if="cell.type === 'images'">
29
+ <template v-for="(img,imgIndex) in configData.images[cell.dataIndex]">
30
+ <span :key="imgIndex" style="margin-right: 5%">{{img.name}}</span>
31
+ </template>
32
+ </template>
33
+ </td>
34
+ </template>
35
+ <template v-else>
36
+ <td
37
+ v-for="(cell, cellIndex) in columns"
38
+ :key="cellIndex"
39
+ :class=" cell.noBoarder ? 'tdNoBorder' : 'tdWithBorder'"
40
+ :colspan="cell.colSpan ? cell.colSpan : undefined"
41
+ :style="cell.style ? cell.style : undefined"
42
+ :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
43
+ <template v-if="cell.type === 'column'">
44
+ {{ cell.text }}
45
+ </template>
46
+ <template v-else-if="cell.type === 'value'">
47
+ {{ cell.value }}
48
+ </template>
49
+ <template v-else-if="cell.type === 'increment'">
50
+ {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
51
+ </template>
52
+ <template v-else-if="cell.type === 'input'">
53
+ {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
54
+ </template>
55
+ <template v-else-if="cell.type === 'inputs'">
56
+ {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
57
+ </template>
58
+ </td>
59
+ </template>
60
+ </template>
61
+ <!-- 不是动态行 -->
62
+ <template v-else-if="!inputColumns">
63
+ <td
64
+ v-for="(cell, cellIndex) in columns"
65
+ :key="cellIndex"
66
+ :class=" cell.noBoarder ? 'tdNoBorder' : 'tdWithBorder'"
67
+ :colspan="cell.colSpan ? cell.colSpan : undefined"
68
+ :style="cell.style ? cell.style : undefined"
69
+ :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
70
+ <template v-if="cell.type === 'column'">
71
+ {{ cell.text }}
72
+ </template>
73
+ <template v-else-if="cell.type === 'placeHolderColumn'">
74
+ <!-- 占位 -->
75
+ </template>
76
+ <template v-else-if="cell.type === 'value'">
77
+ {{ cell.value }}
78
+ </template>
79
+ <template v-else-if="cell.type === 'input'">
80
+ <a-input v-model="configData[cell.dataIndex]" :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
81
+ </template>
82
+ <template v-else-if="cell.type === 'inputs'">
83
+ <div class="inputsDiv">
84
+ <div class="inputsDivItem" v-for="(num, index) of calcFormatInputNum(cell.format)" :key="index">
85
+ <span class="inputsDivItemLabel">{{ displayFormatStartText(cell.format) }}</span>
86
+ <a-input v-model="configData[cell.dataIndex][index]" :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
87
+ <span class="inputsDivItemLabel">{{ displayFormatText(cell.format, index) }}</span>
88
+ </div>
89
+ </div>
90
+ </template>
91
+ <template v-else-if="cell.type === 'images'">
92
+ <div style="display: flex">
93
+ <upload
94
+ :model="{type: 'image', accept: ['*'], resUploadStock: 1, pathKey: 'cs'}"
95
+ service-name="af-system"
96
+ :images="configData.images[cell.dataIndex]"
97
+ :outer-container-index="cell.dataIndex"
98
+ @setFiles="setImages"
99
+ :upload-style="'simple'"
100
+ />
101
+ </div>
102
+ </template>
103
+ </td>
104
+ </template>
105
+ <!-- 动态行插入按钮 -->
106
+ <template v-else-if="inputColumnsButton">
107
+ <td :colspan="maxColSpan" class="tdWithBorder">
108
+ <a-button-group>
109
+ <a-button @click="addData(configData[columns[0].dataIndex], columns)"><a-icon type="plus"/></a-button>
110
+ <a-button @click="removeData(configData[columns[0].dataIndex])"><a-icon type="minus"/></a-button>
111
+ </a-button-group>
112
+ </td>
113
+ </template >
114
+ <!-- 其他行 -->
115
+ <template v-else>
116
+ <td
117
+ v-for="(cell, cellIndex) in columns"
118
+ :key="cellIndex"
119
+ :class=" cell.noBoarder ? 'tdNoBorder' : 'tdWithBorder'"
120
+ :colspan="cell.colSpan ? cell.colSpan : undefined"
121
+ :style="cell.style ? cell.style : undefined"
122
+ :rowspan="cell.rowSpan ? cell.rowSpan : undefined">
123
+ <template v-if="cell.type === 'column'">
124
+ {{ cell.text }}
125
+ </template>
126
+ <template v-else-if="cell.type === 'value'">
127
+ {{ cell.value }}
128
+ </template>
129
+ <template v-else-if="cell.type === 'increment'">
130
+ {{ configData.arr[inputColumnsDefinitionIndex][cell.dataIndex] }}
131
+ </template>
132
+ <template v-else-if="cell.type === 'input'">
133
+ <a-input v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]" :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
134
+ </template>
135
+ <template v-else-if="cell.type === 'inputs'">
136
+ <a-input v-model="configData.arr[inputColumnsDefinitionIndex][cell.dataIndex]" :style="'width:' + (cell.inputWidth ? cell.inputWidth : '100') + '%'"/>
137
+ </template>
138
+ </td>
139
+ </template>
140
+ </tr>
141
+ </template>
142
+
143
+ <script>
144
+ import Upload from '@vue2-client/base-client/components/common/Upload'
145
+
146
+ export default {
147
+ name: 'XReportTrGroup',
148
+ components: {
149
+ Upload
150
+ },
151
+ props: {
152
+ // 每一行的配置
153
+ columns: {
154
+ type: Array,
155
+ required: true
156
+ },
157
+ config: {
158
+ type: Object,
159
+ default: function () {
160
+ return {}
161
+ }
162
+ },
163
+ // 原始配置
164
+ configData: {
165
+ type: Object,
166
+ required: true
167
+ },
168
+ // 是否为动态行
169
+ inputColumns: {
170
+ type: Boolean,
171
+ default: false
172
+ },
173
+ // 是否为动态行按钮
174
+ inputColumnsButton: {
175
+ type: Boolean,
176
+ default: false
177
+ },
178
+ // 动态行的Index
179
+ inputColumnsDefinitionIndex: {
180
+ type: Number,
181
+ default: undefined
182
+ },
183
+ // 是否为展示行
184
+ display: {
185
+ type: Boolean,
186
+ default: false
187
+ }
188
+ },
189
+ data () {
190
+ return {
191
+ maxColSpan: 12
192
+ // tableConfig: {}
193
+ }
194
+ },
195
+ methods: {
196
+ setImages (imageIds, dataIndex) {
197
+ console.warn('接收', imageIds)
198
+ this.configData.images[dataIndex] = imageIds
199
+ },
200
+ removeData (dataItem) {
201
+ if (dataItem.length === 0) {
202
+ this.$message.warn('已经没有更多了')
203
+ return
204
+ }
205
+ dataItem.pop()
206
+ },
207
+ // 添加一行
208
+ addData (dataItem, row) {
209
+ // 获取定义
210
+ const defs = row[0].definition
211
+
212
+ // 获取外层对象名
213
+ const dataName = row[0].dataIndex
214
+ const temp = {}
215
+
216
+ defs.forEach(def => {
217
+ // 找到数组中最后一个数据的值
218
+ let lastDataNo = 0
219
+ if (this.configData[dataName][this.configData[dataName].length - 1]) {
220
+ lastDataNo = this.configData[dataName][this.configData[dataName].length - 1][def.dataIndex]
221
+ }
222
+
223
+ // 如果没有值,检查是否声明了初始值
224
+ if (lastDataNo === 0 && def.initialValue) {
225
+ lastDataNo = def.initialValue
226
+ }
227
+
228
+ // 检查是否有步长
229
+ let step = 1
230
+ if (def.step) {
231
+ step = def.step
232
+ }
233
+
234
+ // 如果单元格类型为increment,则进行自增
235
+ if (def.type === 'increment') {
236
+ temp[def.dataIndex] = lastDataNo + step
237
+ }
238
+ })
239
+ dataItem.push(temp)
240
+ },
241
+ // 根据format计算需要多少个输入框
242
+ calcFormatInputNum (formatStr) {
243
+ let count = 0
244
+ for (let i = 0; i < formatStr.length; i++) {
245
+ if (formatStr[i] === '{') {
246
+ count++
247
+ }
248
+ }
249
+ return count
250
+ },
251
+ // 根据format计算输入框之后的文字显示
252
+ displayFormatText (formatStr, num) {
253
+ let start = 0
254
+ let count = 0
255
+ num++
256
+ for (let i = 0; i < formatStr.length; i++) {
257
+ if (formatStr[i] === '}') {
258
+ start = i
259
+ count++
260
+ }
261
+ if (count === num) {
262
+ for (let j = start + 1; j < formatStr.length; j++) {
263
+ if (formatStr[j] === '{') {
264
+ return formatStr.slice(start + 1, j)
265
+ }
266
+ if (j === formatStr.length - 1 && formatStr[j] !== '}') {
267
+ return formatStr[j]
268
+ }
269
+ }
270
+ }
271
+ }
272
+ },
273
+ // 根据format计算输入框之前的文字显示
274
+ displayFormatStartText (formatStr) {
275
+ let count = 0
276
+ for (let i = 0; i < formatStr.length; i++) {
277
+ if (formatStr[i] === '{') {
278
+ break
279
+ } else {
280
+ count++
281
+ }
282
+ }
283
+ return formatStr.slice(0, count)
284
+ },
285
+ // 拼接被自动拆分的单元格内容
286
+ showSubRowValue (cell) {
287
+ const dataName = cell.dataIndex
288
+ const formatArr = []
289
+ const dataArr = []
290
+
291
+ // 从config中取出所有数据,根据dataIndex的开头内容进行拼接
292
+ this.config.columns.forEach(row => row.forEach(cell => {
293
+ if (cell.dataIndex && cell.dataIndex.startsWith(dataName)) {
294
+ formatArr.push(cell.format)
295
+ dataArr.push(this.configData[cell.dataIndex])
296
+ }
297
+ }))
298
+
299
+ const text = []
300
+ const data = []
301
+
302
+ formatArr.forEach(word => {
303
+ const temp = word.split('{}')
304
+ temp.forEach(char => {
305
+ if (char !== '') {
306
+ text.push(char)
307
+ }
308
+ })
309
+ })
310
+
311
+ dataArr.forEach(item => {
312
+ item.forEach(num => {
313
+ data.push(num)
314
+ })
315
+ })
316
+
317
+ let result = ''
318
+ for (let i = 0; i < data.length; i++) {
319
+ result += data[i]
320
+ result += text[i]
321
+ }
322
+
323
+ return result
324
+ },
325
+ },
326
+ beforeMount () {
327
+ }
328
+ }
329
+
330
+ </script>
331
+
332
+ <style scoped lang="less">
333
+ .inputsDiv {
334
+ display: flex;
335
+ justify-content: space-between;
336
+ .inputsDivItem {
337
+ display: flex;
338
+ align-items: center;
339
+ padding: 0 4px;
340
+ white-space: nowrap;
341
+ .inputsDivItemLabel {
342
+ padding: 0 4px;
343
+ }
344
+ }
345
+ }
346
+
347
+ .tdNoBorder {
348
+ border-left: 1px solid #000;
349
+ border-right: 1px solid #000;
350
+ padding: 8px;
351
+ }
352
+
353
+ .tdWithBorder {
354
+ border: 1px solid #000;
355
+ padding: 8px;
356
+ }
357
+ </style>