@lambo-design/schema-paging-table 1.0.0-beta.17 → 1.0.0-beta.19
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 +155 -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.19",
|
|
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/schema-form": "^1.0.0-beta.40",
|
|
14
|
-
"@lambo-design/paging-table": "^1.0.0-beta.72",
|
|
15
13
|
"@lambo-design/core": "^4.7.1-beta.114",
|
|
16
|
-
"@lambo-design/shared": "^1.0.0-beta.
|
|
14
|
+
"@lambo-design/shared": "^1.0.0-beta.101",
|
|
15
|
+
"@lambo-design/paging-table": "^1.0.0-beta.73",
|
|
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: [],
|
|
@@ -143,7 +139,13 @@ export default {
|
|
|
143
139
|
default: 4
|
|
144
140
|
},
|
|
145
141
|
customComponents: Object,
|
|
146
|
-
customValidates: Object
|
|
142
|
+
customValidates: Object,
|
|
143
|
+
//父组件回填已选中的值
|
|
144
|
+
selectedKey: {
|
|
145
|
+
type: Array,
|
|
146
|
+
require: false,
|
|
147
|
+
default: () => {return []}
|
|
148
|
+
}
|
|
147
149
|
},
|
|
148
150
|
computed: {
|
|
149
151
|
tableColumn: function () {
|
|
@@ -159,58 +161,58 @@ export default {
|
|
|
159
161
|
}else if(obj.hasOwnProperty("type") && obj.type === "operate"){
|
|
160
162
|
obj.render = (h, param) => {
|
|
161
163
|
return h('div',
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
164
|
+
obj.button.map((item,index)=>{
|
|
165
|
+
let doms = operateHref(self, h, param.row, item.name || param.row[obj.key], (vm, currentRow) => {
|
|
166
|
+
if(item.clickEvent?.type==="route"){
|
|
167
|
+
// self.$Message.info(item.clickEvent.name)
|
|
168
|
+
let query = item.clickEvent?.route?.keys?.reduce((acc,sourceItem)=>{
|
|
169
|
+
return Object.assign(acc,{[sourceItem]:currentRow[sourceItem]})
|
|
170
|
+
},{})
|
|
171
|
+
self.$router.push({
|
|
172
|
+
path: item.clickEvent?.route?.path,
|
|
173
|
+
query
|
|
174
|
+
})
|
|
175
|
+
}else if(item.clickEvent?.type==="request"){
|
|
176
|
+
// self.$Message.info(item.clickEvent.name)
|
|
177
|
+
let data = item.clickEvent?.request?.keys?.reduce((acc,sourceItem)=>{
|
|
178
|
+
return Object.assign(acc,{[sourceItem]:currentRow[sourceItem]})
|
|
179
|
+
},{})
|
|
180
|
+
let request = {
|
|
181
|
+
url:item.clickEvent.request.url,
|
|
182
|
+
method:item.clickEvent.request.method,
|
|
183
|
+
param:data,
|
|
184
|
+
}
|
|
185
|
+
let response = item.clickEvent.response
|
|
186
|
+
if(item.clickEvent.tips){
|
|
187
|
+
let tips = item.clickEvent.tips
|
|
188
|
+
this.$Modal.confirm({
|
|
189
|
+
title: tips.title,
|
|
190
|
+
content: '<p>'+ tips.content + '</p>',
|
|
191
|
+
onOk: () => {
|
|
192
|
+
self.fetch(request,response)
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}else{
|
|
196
|
+
self.fetch(request,response)
|
|
197
|
+
}
|
|
198
|
+
}else if(item.clickEvent?.type==="method"){
|
|
199
|
+
let args = item.clickEvent?.method?.keys?.reduce((total,current)=>{
|
|
200
|
+
return Object.assign(total,{[current]:currentRow[current]})
|
|
201
|
+
},{})
|
|
202
|
+
self.$emit(item.clickEvent?.method?.name,args)
|
|
203
|
+
}else if(item.clickEvent?.type==="modal"){
|
|
204
|
+
self.$Message.info(item.clickEvent.name)
|
|
195
205
|
}
|
|
196
|
-
}
|
|
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)
|
|
206
|
+
},item.permission)
|
|
205
207
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
if(item && typeof item.condition == "function"){
|
|
209
|
+
if(item.condition(param)){
|
|
210
|
+
return doms
|
|
211
|
+
}
|
|
212
|
+
}else{
|
|
208
213
|
return doms
|
|
209
214
|
}
|
|
210
|
-
}
|
|
211
|
-
return doms
|
|
212
|
-
}
|
|
213
|
-
})
|
|
215
|
+
})
|
|
214
216
|
)
|
|
215
217
|
}
|
|
216
218
|
}
|
|
@@ -218,11 +220,13 @@ export default {
|
|
|
218
220
|
})
|
|
219
221
|
return columns
|
|
220
222
|
},
|
|
221
|
-
spreadButton: function () {
|
|
222
|
-
|
|
223
|
-
},
|
|
223
|
+
// spreadButton: function () {
|
|
224
|
+
// return this.buttonList.slice(0,3)
|
|
225
|
+
// },
|
|
224
226
|
dropDownButton: function () {
|
|
225
|
-
|
|
227
|
+
// let list = [...this.buttonList,...this.buttonList]
|
|
228
|
+
// return list.splice(0,7)
|
|
229
|
+
return this.buttonList
|
|
226
230
|
},
|
|
227
231
|
multiSelect: function() {
|
|
228
232
|
return this.columnList.some((item)=>{
|
|
@@ -233,11 +237,57 @@ export default {
|
|
|
233
237
|
watch:{
|
|
234
238
|
form: function(val) {
|
|
235
239
|
this.queryForm = val
|
|
240
|
+
},
|
|
241
|
+
selectedKey: function () {
|
|
242
|
+
this.selectedKeys = this.selectedKey
|
|
243
|
+
//重置标签
|
|
244
|
+
this.selectTags = []
|
|
245
|
+
if (this.rowKey) {
|
|
246
|
+
for (let item of this.selectedKeys) {
|
|
247
|
+
this.selectRows[item[this.rowKey]] = item;
|
|
248
|
+
let tagItem = {"key": item[this.rowKey], "value": item[this.rowName]}
|
|
249
|
+
this.selectTags.push(tagItem);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
236
252
|
}
|
|
237
253
|
},
|
|
238
254
|
created() {
|
|
255
|
+
let self = this
|
|
256
|
+
setTimeout(()=>{
|
|
257
|
+
self.calculateButtonsInFirstRow();
|
|
258
|
+
},500)
|
|
259
|
+
window.addEventListener('resize', this.calculateButtonsInFirstRow);
|
|
260
|
+
},
|
|
261
|
+
beforeDestroy() {
|
|
262
|
+
window.removeEventListener('resize', this.calculateButtonsInFirstRow);
|
|
239
263
|
},
|
|
240
264
|
methods: {
|
|
265
|
+
//计算第一行有多少个button,根据父div宽度和每个button的宽度计算
|
|
266
|
+
calculateButtonsInFirstRow() {
|
|
267
|
+
let container = this.$refs.container
|
|
268
|
+
if (!container){return}
|
|
269
|
+
let containerWidth = ''
|
|
270
|
+
if (container.offsetWidth === undefined){
|
|
271
|
+
}
|
|
272
|
+
containerWidth = container.offsetWidth
|
|
273
|
+
const buttons = this.$refs.buttons;
|
|
274
|
+
let totalWidth = 0;
|
|
275
|
+
let buttonsInFirstRow = 0;
|
|
276
|
+
for (let i = 0; i < buttons.length; i++) {
|
|
277
|
+
totalWidth += buttons[i].$el.offsetWidth + 5
|
|
278
|
+
if (totalWidth <= containerWidth) {
|
|
279
|
+
buttonsInFirstRow++;
|
|
280
|
+
} else {
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
this.totalButtons = this.dropDownButton
|
|
285
|
+
this.buttonsInFirstRow = buttonsInFirstRow;
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
setCollapse: function() {
|
|
289
|
+
this.collapsed = !this.collapsed
|
|
290
|
+
},
|
|
241
291
|
doClick(item){
|
|
242
292
|
let self = this;
|
|
243
293
|
if(item.clickEvent?.type==="route"){
|
|
@@ -425,5 +475,9 @@ export default {
|
|
|
425
475
|
.tags {
|
|
426
476
|
margin: 10px auto;
|
|
427
477
|
}
|
|
478
|
+
.buttons-hidden{
|
|
479
|
+
height:33px;
|
|
480
|
+
overflow: hidden;
|
|
481
|
+
}
|
|
428
482
|
</style>
|
|
429
483
|
|