@lambo-design/schema-paging-table 1.0.0-beta.16 → 1.0.0-beta.18
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.
- package/package.json +4 -4
- package/src/index.vue +138 -101
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambo-design/schema-paging-table",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "lambo",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"registry": "https://registry.npmjs.org/"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@lambo-design/core": "^4.7.1-beta.
|
|
13
|
+
"@lambo-design/core": "^4.7.1-beta.114",
|
|
14
|
+
"@lambo-design/paging-table": "^1.0.0-beta.73",
|
|
14
15
|
"@lambo-design/shared": "^1.0.0-beta.100",
|
|
15
|
-
"@lambo-design/schema-form": "^1.0.0-beta.40"
|
|
16
|
-
"@lambo-design/paging-table": "^1.0.0-beta.72"
|
|
16
|
+
"@lambo-design/schema-form": "^1.0.0-beta.40"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {}
|
|
19
19
|
}
|
package/src/index.vue
CHANGED
|
@@ -1,64 +1,57 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<LamboPagingTable
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
ref="schemaPagingTable"
|
|
4
|
+
:dataUrl="dataUrl"
|
|
5
|
+
:columns="tableColumn"
|
|
6
|
+
:searchParams="tableSearchParams"
|
|
7
|
+
:transformResponse="transformResponse"
|
|
8
|
+
:showTableOption="showTableOption"
|
|
9
|
+
@on-row-click="onRowClick"
|
|
10
|
+
@on-selection-change="onSelectionChange"
|
|
11
|
+
@on-select="onSelect"
|
|
12
|
+
@on-select-cancel="onSelectCancel"
|
|
13
|
+
@on-select-all="onSelectAll"
|
|
14
|
+
@on-select-all-cancel="onSelectAllCancel">
|
|
15
15
|
<div slot="search">
|
|
16
16
|
<LamboSchemaForm
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
ref="lamboSchemaForm"
|
|
18
|
+
v-model="queryForm"
|
|
19
|
+
:form-type="'search'"
|
|
20
|
+
:fieldList="formFields"
|
|
21
|
+
:labelWidth="labelWidth"
|
|
22
|
+
:default-rows="2"
|
|
23
|
+
:grid-columns="gridColumns"
|
|
24
|
+
:customComponents="customComponents"
|
|
25
|
+
:customValidates="customValidates"
|
|
26
|
+
@doSearch="doSearch" @reset="onReset"/>
|
|
27
27
|
<div v-if="rowName" class="tags">
|
|
28
28
|
<Tag v-for="item in selectTags" :key="item.key" :name="item.key" closable @on-close="tagClose">
|
|
29
29
|
{{ item.value }}
|
|
30
30
|
</Tag>
|
|
31
31
|
</div>
|
|
32
32
|
</div>
|
|
33
|
-
<div slot="buttons">
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
:ghost="true"
|
|
39
|
-
:icon="item.icon"
|
|
40
|
-
v-permission="item.permission"
|
|
41
|
-
:key="index"
|
|
42
|
-
@click="doClick(item)"
|
|
43
|
-
style="margin-right: 5px">
|
|
44
|
-
{{ item.name }}
|
|
45
|
-
</Button>
|
|
46
|
-
<Dropdown v-if="dropDownButton.length > 0">
|
|
47
|
-
<Button type="primary" :ghost="true" icon="md-more">
|
|
48
|
-
更多操作
|
|
49
|
-
<Icon type="ios-arrow-down"></Icon>
|
|
50
|
-
</Button>
|
|
51
|
-
<DropdownMenu slot="list">
|
|
52
|
-
<DropdownItem
|
|
33
|
+
<div slot="buttons" style="display: flex">
|
|
34
|
+
<div ref="container" :class="collapsed ? 'buttons-hidden' : ''" style="width: 100%">
|
|
35
|
+
<Button
|
|
36
|
+
ref="buttons"
|
|
37
|
+
v-if="dropDownButton.length > 0"
|
|
53
38
|
v-for="(item,index) in dropDownButton"
|
|
39
|
+
type="primary"
|
|
40
|
+
:ghost="true"
|
|
41
|
+
:icon="item.icon"
|
|
54
42
|
v-permission="item.permission"
|
|
55
43
|
:key="index"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
@click="doClick(item)"
|
|
45
|
+
style="margin:0 5px 5px 0">
|
|
46
|
+
{{ item.name }}
|
|
47
|
+
</Button>
|
|
48
|
+
</div>
|
|
49
|
+
<div>
|
|
50
|
+
<Button v-if="totalButtons.length > buttonsInFirstRow" type="text" class="more-btn" @click=setCollapse>
|
|
51
|
+
{{collapsed ?'展开':'收起'}}
|
|
52
|
+
<Icon :type="collapsed ? 'ios-arrow-down' : 'ios-arrow-up'"></Icon>
|
|
53
|
+
</Button>
|
|
54
|
+
</div>
|
|
62
55
|
</div>
|
|
63
56
|
</LamboPagingTable>
|
|
64
57
|
</template>
|
|
@@ -76,6 +69,9 @@ export default {
|
|
|
76
69
|
},
|
|
77
70
|
data() {
|
|
78
71
|
return {
|
|
72
|
+
buttonsInFirstRow:0,
|
|
73
|
+
totalButtons:0,
|
|
74
|
+
collapsed:true,
|
|
79
75
|
queryForm: {},
|
|
80
76
|
tableSearchParams: {},
|
|
81
77
|
selection: [],
|
|
@@ -159,58 +155,58 @@ export default {
|
|
|
159
155
|
}else if(obj.hasOwnProperty("type") && obj.type === "operate"){
|
|
160
156
|
obj.render = (h, param) => {
|
|
161
157
|
return h('div',
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
158
|
+
obj.button.map((item,index)=>{
|
|
159
|
+
let doms = operateHref(self, h, param.row, item.name || param.row[obj.key], (vm, currentRow) => {
|
|
160
|
+
if(item.clickEvent?.type==="route"){
|
|
161
|
+
// self.$Message.info(item.clickEvent.name)
|
|
162
|
+
let query = item.clickEvent?.route?.keys?.reduce((acc,sourceItem)=>{
|
|
163
|
+
return Object.assign(acc,{[sourceItem]:currentRow[sourceItem]})
|
|
164
|
+
},{})
|
|
165
|
+
self.$router.push({
|
|
166
|
+
path: item.clickEvent?.route?.path,
|
|
167
|
+
query
|
|
168
|
+
})
|
|
169
|
+
}else if(item.clickEvent?.type==="request"){
|
|
170
|
+
// self.$Message.info(item.clickEvent.name)
|
|
171
|
+
let data = item.clickEvent?.request?.keys?.reduce((acc,sourceItem)=>{
|
|
172
|
+
return Object.assign(acc,{[sourceItem]:currentRow[sourceItem]})
|
|
173
|
+
},{})
|
|
174
|
+
let request = {
|
|
175
|
+
url:item.clickEvent.request.url,
|
|
176
|
+
method:item.clickEvent.request.method,
|
|
177
|
+
param:data,
|
|
178
|
+
}
|
|
179
|
+
let response = item.clickEvent.response
|
|
180
|
+
if(item.clickEvent.tips){
|
|
181
|
+
let tips = item.clickEvent.tips
|
|
182
|
+
this.$Modal.confirm({
|
|
183
|
+
title: tips.title,
|
|
184
|
+
content: '<p>'+ tips.content + '</p>',
|
|
185
|
+
onOk: () => {
|
|
186
|
+
self.fetch(request,response)
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}else{
|
|
190
|
+
self.fetch(request,response)
|
|
191
|
+
}
|
|
192
|
+
}else if(item.clickEvent?.type==="method"){
|
|
193
|
+
let args = item.clickEvent?.method?.keys?.reduce((total,current)=>{
|
|
194
|
+
return Object.assign(total,{[current]:currentRow[current]})
|
|
195
|
+
},{})
|
|
196
|
+
self.$emit(item.clickEvent?.method?.name,args)
|
|
197
|
+
}else if(item.clickEvent?.type==="modal"){
|
|
198
|
+
self.$Message.info(item.clickEvent.name)
|
|
182
199
|
}
|
|
183
|
-
|
|
184
|
-
if(item.clickEvent.tips){
|
|
185
|
-
let tips = item.clickEvent.tips
|
|
186
|
-
this.$Modal.confirm({
|
|
187
|
-
title: tips.title,
|
|
188
|
-
content: '<p>'+ tips.content + '</p>',
|
|
189
|
-
onOk: () => {
|
|
190
|
-
self.fetch(request,response)
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}else{
|
|
194
|
-
self.fetch(request,response)
|
|
195
|
-
}
|
|
196
|
-
}else if(item.clickEvent?.type==="method"){
|
|
197
|
-
let args = item.clickEvent?.method?.keys?.reduce((total,current)=>{
|
|
198
|
-
return Object.assign(total,{[current]:currentRow[current]})
|
|
199
|
-
},{})
|
|
200
|
-
self.$emit(item.clickEvent?.method?.name,args)
|
|
201
|
-
}else if(item.clickEvent?.type==="modal"){
|
|
202
|
-
self.$Message.info(item.clickEvent.name)
|
|
203
|
-
}
|
|
204
|
-
},item.permission)
|
|
200
|
+
},item.permission)
|
|
205
201
|
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
if(item && typeof item.condition == "function"){
|
|
203
|
+
if(item.condition(param)){
|
|
204
|
+
return doms
|
|
205
|
+
}
|
|
206
|
+
}else{
|
|
208
207
|
return doms
|
|
209
208
|
}
|
|
210
|
-
}
|
|
211
|
-
return doms
|
|
212
|
-
}
|
|
213
|
-
})
|
|
209
|
+
})
|
|
214
210
|
)
|
|
215
211
|
}
|
|
216
212
|
}
|
|
@@ -218,11 +214,13 @@ export default {
|
|
|
218
214
|
})
|
|
219
215
|
return columns
|
|
220
216
|
},
|
|
221
|
-
spreadButton: function () {
|
|
222
|
-
|
|
223
|
-
},
|
|
217
|
+
// spreadButton: function () {
|
|
218
|
+
// return this.buttonList.slice(0,3)
|
|
219
|
+
// },
|
|
224
220
|
dropDownButton: function () {
|
|
225
|
-
|
|
221
|
+
// let list = [...this.buttonList,...this.buttonList]
|
|
222
|
+
// return list.splice(0,7)
|
|
223
|
+
return this.buttonList
|
|
226
224
|
},
|
|
227
225
|
multiSelect: function() {
|
|
228
226
|
return this.columnList.some((item)=>{
|
|
@@ -236,8 +234,42 @@ export default {
|
|
|
236
234
|
}
|
|
237
235
|
},
|
|
238
236
|
created() {
|
|
237
|
+
let self = this
|
|
238
|
+
setTimeout(()=>{
|
|
239
|
+
self.calculateButtonsInFirstRow();
|
|
240
|
+
},500)
|
|
241
|
+
window.addEventListener('resize', this.calculateButtonsInFirstRow);
|
|
242
|
+
},
|
|
243
|
+
beforeDestroy() {
|
|
244
|
+
window.removeEventListener('resize', this.calculateButtonsInFirstRow);
|
|
239
245
|
},
|
|
240
246
|
methods: {
|
|
247
|
+
//计算第一行有多少个button,根据父div宽度和每个button的宽度计算
|
|
248
|
+
calculateButtonsInFirstRow() {
|
|
249
|
+
let container = this.$refs.container
|
|
250
|
+
if (!container){return}
|
|
251
|
+
let containerWidth = ''
|
|
252
|
+
if (container.offsetWidth === undefined){
|
|
253
|
+
}
|
|
254
|
+
containerWidth = container.offsetWidth
|
|
255
|
+
const buttons = this.$refs.buttons;
|
|
256
|
+
let totalWidth = 0;
|
|
257
|
+
let buttonsInFirstRow = 0;
|
|
258
|
+
for (let i = 0; i < buttons.length; i++) {
|
|
259
|
+
totalWidth += buttons[i].$el.offsetWidth + 5
|
|
260
|
+
if (totalWidth <= containerWidth) {
|
|
261
|
+
buttonsInFirstRow++;
|
|
262
|
+
} else {
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
this.totalButtons = this.dropDownButton
|
|
267
|
+
this.buttonsInFirstRow = buttonsInFirstRow;
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
setCollapse: function() {
|
|
271
|
+
this.collapsed = !this.collapsed
|
|
272
|
+
},
|
|
241
273
|
doClick(item){
|
|
242
274
|
let self = this;
|
|
243
275
|
if(item.clickEvent?.type==="route"){
|
|
@@ -282,7 +314,8 @@ export default {
|
|
|
282
314
|
this.tableSearchParams = Object.assign({}, this.queryForm)
|
|
283
315
|
},
|
|
284
316
|
onReset() {
|
|
285
|
-
Object.assign(this.queryForm, this.$options.propsData.form)
|
|
317
|
+
// Object.assign(this.queryForm, this.$options.propsData.form)
|
|
318
|
+
this.queryForm = this.$options.propsData.form;
|
|
286
319
|
this.doSearch()
|
|
287
320
|
},
|
|
288
321
|
fetch: function (request,response) {
|
|
@@ -424,5 +457,9 @@ export default {
|
|
|
424
457
|
.tags {
|
|
425
458
|
margin: 10px auto;
|
|
426
459
|
}
|
|
460
|
+
.buttons-hidden{
|
|
461
|
+
height:33px;
|
|
462
|
+
overflow: hidden;
|
|
463
|
+
}
|
|
427
464
|
</style>
|
|
428
465
|
|