@weitutech/by-components 1.0.27 → 1.0.30
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/CHANGELOG.md +38 -38
- package/README.md +469 -469
- package/docs/extension.md +15 -0
- package/docs/form.md +26 -0
- package/docs/table.md +26 -0
- package/lib/by-components.common.js +29353 -29328
- package/lib/by-components.umd.js +28985 -28960
- package/lib/by-components.umd.min.js +142 -142
- package/package.json +30 -30
- package/postcss.config.js +6 -6
- package/src/components/custom-column/index.vue +369 -369
- package/src/components/fold-search/index.vue +29 -29
- package/src/components/form/comps/custom-date-picker.vue +109 -109
- package/src/components/form/comps/date-picker-range.vue +78 -78
- package/src/components/form/comps/pair-number-input.vue +67 -67
- package/src/components/form/comps/select.vue +127 -127
- package/src/components/form/form.vue +351 -351
- package/src/components/page-search/page-search.vue +114 -114
- package/src/components/pager/index.vue +81 -81
- package/src/components/table/index.vue +240 -219
- package/src/index.js +30 -30
- package/src/plugin/vxeTable.js +300 -300
- package/src/plugin/vxeTable.scss +14 -14
- package/src/style/custom-column.scss +194 -194
- package/src/style/fold-search.scss +21 -21
- package/src/style/form.scss +342 -342
- package/src/style/index.scss +6 -6
- package/src/style/page-search.scss +26 -26
- package/src/style/pager.scss +40 -40
- package/src/style/table.scss +39 -39
- package/src/utils/index.js +31 -31
|
@@ -1,219 +1,240 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<vxe-grid
|
|
4
|
-
ref="xGrid"
|
|
5
|
-
v-bind="options"
|
|
6
|
-
v-on="eventListeners"
|
|
7
|
-
@cell-click="handleCellClick"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
:
|
|
28
|
-
:
|
|
29
|
-
|
|
30
|
-
@
|
|
31
|
-
@
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<vxe-grid
|
|
4
|
+
ref="xGrid"
|
|
5
|
+
v-bind="options"
|
|
6
|
+
v-on="eventListeners"
|
|
7
|
+
@cell-click="handleCellClick"
|
|
8
|
+
@resizable-change="handleResizableChange"
|
|
9
|
+
>
|
|
10
|
+
<template v-for="item in slotMap" #[item]="context">
|
|
11
|
+
<slot :name="item" v-bind="context" />
|
|
12
|
+
</template>
|
|
13
|
+
<template v-if="options.pagerConfig" #pager>
|
|
14
|
+
<!-- 📢 由于BPager利用的是ElementUi分页目前只支持vxeTable中分页配置中的currentPage、pageSize、total、pageSizes选项配置 -->
|
|
15
|
+
<by-pager
|
|
16
|
+
:page="options.pagerConfig.currentPage"
|
|
17
|
+
:limit="options.pagerConfig.pageSize"
|
|
18
|
+
:total-count="options.pagerConfig.total"
|
|
19
|
+
:page-sizes="options.pagerConfig.pageSizes"
|
|
20
|
+
@onChange="pageChange"
|
|
21
|
+
/>
|
|
22
|
+
</template>
|
|
23
|
+
</vxe-grid>
|
|
24
|
+
<CustomColumn
|
|
25
|
+
v-if="gridOptions.customColumnConfig && gridOptions.customColumnConfig.showCustomColumn"
|
|
26
|
+
ref="CustomColumnRef"
|
|
27
|
+
:info-method="gridOptions.customColumnConfig.infoMethod"
|
|
28
|
+
:submit-method="gridOptions.customColumnConfig.submitMethod"
|
|
29
|
+
:dialog-visible="customTableVisible"
|
|
30
|
+
@closeDialog="closeCustomColumnDialog"
|
|
31
|
+
@changeTable="changeTableFields"
|
|
32
|
+
@changeTableGroup="changeTableGroupFields"
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script>
|
|
38
|
+
import CustomColumn from "../custom-column/index.vue"
|
|
39
|
+
export default {
|
|
40
|
+
name: 'BYTable',
|
|
41
|
+
components: {
|
|
42
|
+
CustomColumn
|
|
43
|
+
},
|
|
44
|
+
props: {
|
|
45
|
+
gridOptions: {
|
|
46
|
+
type: Object,
|
|
47
|
+
default: () => {}
|
|
48
|
+
},
|
|
49
|
+
name: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: ""
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
data() {
|
|
55
|
+
return {
|
|
56
|
+
/**
|
|
57
|
+
* @see https://vxetable.cn/v3.8/#/grid/api
|
|
58
|
+
*/
|
|
59
|
+
events: [
|
|
60
|
+
"keydown", "current-change", "radio-change", "checkbox-change", "checkbox-all",
|
|
61
|
+
"checkbox-range-start", "checkbox-range-change", "checkbox-range-end",
|
|
62
|
+
"cell-dblclick", "cell-menu", "cell-mouseenter", "cell-mouseleave", "cell-delete-value",
|
|
63
|
+
"header-cell-click", "header-cell-dblclick", "header-cell-menu", "footer-cell-click",
|
|
64
|
+
"footer-cell-dblclick", "footer-cell-menu", "clear-merge", "sort-change", "clear-sort",
|
|
65
|
+
"filter-visible", "filter-change", "clear-filter", "toggle-row-expand",
|
|
66
|
+
"toggle-tree-expand", "menu-click", "cell-selected", "edit-closed", "edit-activated", "edit-disabled",
|
|
67
|
+
"valid-error", "scroll", "custom", "page-change", "form-submit", "form-submit-invalid", "form-reset",
|
|
68
|
+
"form-collapse", "proxy-query", "proxy-delete", "proxy-save", "toolbar-button-click", "toolbar-tool-click",
|
|
69
|
+
"zoom"
|
|
70
|
+
],
|
|
71
|
+
// 自定义对话框显示和隐藏控制
|
|
72
|
+
customTableVisible: false
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
computed: {
|
|
76
|
+
options() {
|
|
77
|
+
const { customColumnConfig, columns, ...others } = this.gridOptions
|
|
78
|
+
const cols = JSON.parse(localStorage.getItem(this.name)) || undefined
|
|
79
|
+
if (cols && this.name) {
|
|
80
|
+
columns.forEach(item => {
|
|
81
|
+
item.width = (cols.find(col => col.field === item.field) || {}).width || undefined
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
border: true,
|
|
86
|
+
resizable: true,
|
|
87
|
+
showOverflow: true,
|
|
88
|
+
height: 550,
|
|
89
|
+
align: "left",
|
|
90
|
+
copyFields: [],
|
|
91
|
+
pagerConfig: false,
|
|
92
|
+
emptyText: "暂无数据",
|
|
93
|
+
loadingConfig: {
|
|
94
|
+
text: "加载中..."
|
|
95
|
+
},
|
|
96
|
+
columns,
|
|
97
|
+
...others,
|
|
98
|
+
resizableConfig: {
|
|
99
|
+
minWidth: 50,
|
|
100
|
+
...this.gridOptions.resizableConfig
|
|
101
|
+
},
|
|
102
|
+
rowConfig: {
|
|
103
|
+
height: 41,
|
|
104
|
+
isHover: true,
|
|
105
|
+
...this.gridOptions.rowConfig
|
|
106
|
+
},
|
|
107
|
+
sortConfig: {
|
|
108
|
+
remote: true,
|
|
109
|
+
trigger: "cell",
|
|
110
|
+
...this.gridOptions.sortConfig
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// 插槽集合
|
|
115
|
+
slotMap() {
|
|
116
|
+
const slotSet = new Set([])
|
|
117
|
+
const slots = this.gridOptions?.customColumnConfig?.slots ?? []
|
|
118
|
+
this.options.columns.forEach(col => {
|
|
119
|
+
if (col.slots) {
|
|
120
|
+
const slots = Object.values(col.slots)
|
|
121
|
+
slots.forEach(slot => slotSet.add(slot))
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
return [...Array.from(slotSet), ...slots]
|
|
125
|
+
},
|
|
126
|
+
// 注册emit事件
|
|
127
|
+
eventListeners() {
|
|
128
|
+
const listeners = {}
|
|
129
|
+
this.events.forEach(eventName => {
|
|
130
|
+
listeners[eventName] = (event) => this.$emit(eventName, event)
|
|
131
|
+
})
|
|
132
|
+
return listeners
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
methods: {
|
|
136
|
+
handleCellClick(context) {
|
|
137
|
+
if (this.options.copyFields.includes(context.column.field)) {
|
|
138
|
+
const text = context.cell.outerText
|
|
139
|
+
this.copy(text)
|
|
140
|
+
}
|
|
141
|
+
this.$emit("cell-click", context)
|
|
142
|
+
},
|
|
143
|
+
handleResizableChange(context) {
|
|
144
|
+
this.$emit("resizable-change", context)
|
|
145
|
+
if (!this.name) return
|
|
146
|
+
const collectColumn = context.$table.collectColumn
|
|
147
|
+
console.log(collectColumn, "collectColumn")
|
|
148
|
+
const clos = collectColumn.map(col => ({ field: col.field, width: col.renderWidth }))
|
|
149
|
+
localStorage.setItem(this.name, JSON.stringify(clos))
|
|
150
|
+
},
|
|
151
|
+
pageChange(values) {
|
|
152
|
+
this.$emit("page-change", values)
|
|
153
|
+
},
|
|
154
|
+
copy(text) {
|
|
155
|
+
const oInput = document.createElement("input")
|
|
156
|
+
oInput.value = text
|
|
157
|
+
document.body.appendChild(oInput)
|
|
158
|
+
oInput.select() // 选择对象;
|
|
159
|
+
document.execCommand("Copy") // 执行浏览器复制命令
|
|
160
|
+
this.$message({
|
|
161
|
+
message: "复制成功",
|
|
162
|
+
type: "success"
|
|
163
|
+
})
|
|
164
|
+
oInput.remove()
|
|
165
|
+
},
|
|
166
|
+
getCustomColumnRef() {
|
|
167
|
+
return this.$refs.CustomColumnRef
|
|
168
|
+
},
|
|
169
|
+
handleOpenCustomColumn() {
|
|
170
|
+
this.customTableVisible = true
|
|
171
|
+
},
|
|
172
|
+
// 改变表头字段
|
|
173
|
+
changeTableFields(cols) {
|
|
174
|
+
const columns = []
|
|
175
|
+
cols.forEach(item => {
|
|
176
|
+
if (!columns.some(col => col.field === item.key) && item.type) {
|
|
177
|
+
columns.push(
|
|
178
|
+
{
|
|
179
|
+
field: item.key,
|
|
180
|
+
title: item.label,
|
|
181
|
+
minWidth: item.minWidth || item.width,
|
|
182
|
+
maxWidth: item.maxWidth,
|
|
183
|
+
sortable: typeof (item.sortable) === "undefined" ? true : JSON.parse(item.sortable),
|
|
184
|
+
fixed: item.fixed,
|
|
185
|
+
slots: this.gridOptions.customColumnConfig.slots.includes(item.key) ? { default: item.key } : undefined
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
this.$emit("setColumn", columns)
|
|
191
|
+
},
|
|
192
|
+
// 多层级表头
|
|
193
|
+
changeTableGroupFields(cols) {
|
|
194
|
+
const recursiveData = (cols)=> {
|
|
195
|
+
const arr = []
|
|
196
|
+
cols.forEach((item,index)=> {
|
|
197
|
+
if(item.data && item.data.length > 0) {
|
|
198
|
+
arr.push({
|
|
199
|
+
title: item.label,
|
|
200
|
+
align: 'center',
|
|
201
|
+
children: recursiveData(item.data)
|
|
202
|
+
})
|
|
203
|
+
if(index < cols.length - 1) {
|
|
204
|
+
arr.push({
|
|
205
|
+
title: '',
|
|
206
|
+
width: 5,
|
|
207
|
+
headerClassName: 'group-split',
|
|
208
|
+
className: 'group-split',
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
}else {
|
|
212
|
+
if (!arr.some(col => col.field === item.key) && item.type) {
|
|
213
|
+
arr.push({
|
|
214
|
+
field: item.key,
|
|
215
|
+
title: item.label,
|
|
216
|
+
minWidth: item.minWidth || item.width,
|
|
217
|
+
maxWidth: item.maxWidth,
|
|
218
|
+
sortable: typeof (item.sortable) === "undefined" ? true : JSON.parse(item.sortable),
|
|
219
|
+
fixed: item.fixed,
|
|
220
|
+
slots: this.gridOptions.customColumnConfig.slots.includes(item.key) ? { default: item.key } : undefined
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
return arr
|
|
226
|
+
}
|
|
227
|
+
this.$emit("setGroupColumn", recursiveData(cols))
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
// 关闭自定义表头弹框
|
|
231
|
+
closeCustomColumnDialog() {
|
|
232
|
+
this.customTableVisible = false
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
</script>
|
|
237
|
+
|
|
238
|
+
<style lang="scss" scoped>
|
|
239
|
+
|
|
240
|
+
</style>
|
package/src/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import ByPager from './components/pager/index'
|
|
2
|
-
import ByTable from './components/table/index'
|
|
3
|
-
import ByForm from './components/form/form'
|
|
4
|
-
import ByPageSearch from './components/page-search/page-search'
|
|
5
|
-
import ByFoldSearch from './components/fold-search/index'
|
|
6
|
-
import BySelect from './components/form/comps/select.vue'
|
|
7
|
-
import ByDatePickerRange from './components/form/comps/date-picker-range.vue'
|
|
8
|
-
import domZindex from 'dom-zindex'
|
|
9
|
-
const components = {
|
|
10
|
-
ByPager,
|
|
11
|
-
ByTable,
|
|
12
|
-
ByForm,
|
|
13
|
-
ByPageSearch,
|
|
14
|
-
ByFoldSearch,
|
|
15
|
-
BySelect,
|
|
16
|
-
ByDatePickerRange
|
|
17
|
-
}
|
|
18
|
-
// 设置当前 z-index 起始值
|
|
19
|
-
domZindex.setCurrent(99999)
|
|
20
|
-
|
|
21
|
-
const install = (Vue) => {
|
|
22
|
-
Object.keys(components).forEach(name => {
|
|
23
|
-
Vue.component(name, components[name])
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// 支持直接通过 script 标签引入
|
|
28
|
-
if (typeof window !== 'undefined' && window.Vue) {
|
|
29
|
-
install(window.Vue)
|
|
30
|
-
}
|
|
1
|
+
import ByPager from './components/pager/index'
|
|
2
|
+
import ByTable from './components/table/index'
|
|
3
|
+
import ByForm from './components/form/form'
|
|
4
|
+
import ByPageSearch from './components/page-search/page-search'
|
|
5
|
+
import ByFoldSearch from './components/fold-search/index'
|
|
6
|
+
import BySelect from './components/form/comps/select.vue'
|
|
7
|
+
import ByDatePickerRange from './components/form/comps/date-picker-range.vue'
|
|
8
|
+
import domZindex from 'dom-zindex'
|
|
9
|
+
const components = {
|
|
10
|
+
ByPager,
|
|
11
|
+
ByTable,
|
|
12
|
+
ByForm,
|
|
13
|
+
ByPageSearch,
|
|
14
|
+
ByFoldSearch,
|
|
15
|
+
BySelect,
|
|
16
|
+
ByDatePickerRange
|
|
17
|
+
}
|
|
18
|
+
// 设置当前 z-index 起始值
|
|
19
|
+
domZindex.setCurrent(99999)
|
|
20
|
+
|
|
21
|
+
const install = (Vue) => {
|
|
22
|
+
Object.keys(components).forEach(name => {
|
|
23
|
+
Vue.component(name, components[name])
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 支持直接通过 script 标签引入
|
|
28
|
+
if (typeof window !== 'undefined' && window.Vue) {
|
|
29
|
+
install(window.Vue)
|
|
30
|
+
}
|
|
31
31
|
export default {install }
|