@weitutech/by-components 1.0.27

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.
@@ -0,0 +1,81 @@
1
+ <template>
2
+ <div id="pager" class="pager fixed bottom-0 right-0 w-full flex justify-center items-center z-50">
3
+ <el-pagination
4
+ :current-page="pager['page']"
5
+ :page-size="pager['limit']"
6
+ :page-sizes="pageSizes"
7
+ background
8
+ layout="total, prev, pager, next,sizes, jumper"
9
+ :total="totalCount"
10
+ @size-change="(value) => handleValueChange(value, 'limit')"
11
+ @current-change="(value) => handleValueChange(value, 'page')"
12
+ />
13
+ </div>
14
+ </template>
15
+
16
+ <script>
17
+ export default {
18
+ name: 'BYPager',
19
+ props: {
20
+ limit: {
21
+ type: Number,
22
+ default: 15
23
+ },
24
+ page: {
25
+ type: Number,
26
+ default: 1
27
+ },
28
+ totalCount: {
29
+ type: Number,
30
+ required: true,
31
+ default: 25
32
+ },
33
+ pageSizes: {
34
+ type: Array,
35
+ default: () => [10, 15, 20, 25, 30, 50, 100]
36
+ }
37
+ },
38
+
39
+ data() {
40
+ return {
41
+ pager: {
42
+ page: this.page,
43
+ limit: this.limit
44
+ }
45
+ }
46
+ },
47
+
48
+ watch: {
49
+ page: {
50
+ handler: function(val, oldVal) {
51
+ this.pager.page = val
52
+ },
53
+ immediate: true
54
+ },
55
+ limit: {
56
+ handler: function(val, oldVal) {
57
+ this.pager.limit = val
58
+ },
59
+ immediate: true
60
+ }
61
+ },
62
+ mounted() {
63
+ // 修改分页文案
64
+ document.getElementsByClassName("el-pagination__jump")[0].childNodes[0].nodeValue = "跳至"
65
+ document.getElementsByClassName("el-pagination__jump")[0].childNodes[2].nodeValue = ""
66
+ },
67
+
68
+ methods: {
69
+ handleValueChange(value, field) {
70
+ if (!value) return
71
+ const values = {
72
+ ...this.pager,
73
+ [field]: value,
74
+ page: field === "limit" ? 1 : value
75
+ }
76
+ this.$emit("onChange", values)
77
+ }
78
+ }
79
+ }
80
+ </script>
81
+
@@ -0,0 +1,219 @@
1
+ <template>
2
+ <div>
3
+ <vxe-grid
4
+ ref="xGrid"
5
+ v-bind="options"
6
+ v-on="eventListeners"
7
+ @cell-click="handleCellClick"
8
+ >
9
+ <template v-for="item in slotMap" #[item]="context">
10
+ <slot :name="item" v-bind="context" />
11
+ </template>
12
+ <template v-if="options.pagerConfig" #pager>
13
+ <!-- 📢 由于BPager利用的是ElementUi分页目前只支持vxeTable中分页配置中的currentPage、pageSize、total、pageSizes选项配置 -->
14
+ <by-pager
15
+ :page="options.pagerConfig.currentPage"
16
+ :limit="options.pagerConfig.pageSize"
17
+ :total-count="options.pagerConfig.total"
18
+ :page-sizes="options.pagerConfig.pageSizes"
19
+ @onChange="pageChange"
20
+ />
21
+ </template>
22
+ </vxe-grid>
23
+ <CustomColumn
24
+ v-if="gridOptions.customColumnConfig && gridOptions.customColumnConfig.showCustomColumn"
25
+ ref="CustomColumnRef"
26
+ :info-method="gridOptions.customColumnConfig.infoMethod"
27
+ :submit-method="gridOptions.customColumnConfig.submitMethod"
28
+ :dialog-visible="customTableVisible"
29
+ @closeDialog="closeCustomColumnDialog"
30
+ @changeTable="changeTableFields"
31
+ @changeTableGroup="changeTableGroupFields"
32
+ />
33
+ </div>
34
+ </template>
35
+
36
+ <script>
37
+ import CustomColumn from "../custom-column/index.vue"
38
+ export default {
39
+ name: 'BYTable',
40
+ components: {
41
+ CustomColumn
42
+ },
43
+ props: {
44
+ gridOptions: {
45
+ type: Object,
46
+ default: () => {}
47
+ }
48
+ },
49
+ data() {
50
+ return {
51
+ /**
52
+ * @see https://vxetable.cn/v3.8/#/grid/api
53
+ */
54
+ events: [
55
+ "keydown", "current-change", "radio-change", "checkbox-change", "checkbox-all",
56
+ "checkbox-range-start", "checkbox-range-change", "checkbox-range-end",
57
+ "cell-dblclick", "cell-menu", "cell-mouseenter", "cell-mouseleave", "cell-delete-value",
58
+ "header-cell-click", "header-cell-dblclick", "header-cell-menu", "footer-cell-click",
59
+ "footer-cell-dblclick", "footer-cell-menu", "clear-merge", "sort-change", "clear-sort",
60
+ "filter-visible", "filter-change", "clear-filter", "resizable-change", "toggle-row-expand",
61
+ "toggle-tree-expand", "menu-click", "cell-selected", "edit-closed", "edit-activated", "edit-disabled",
62
+ "valid-error", "scroll", "custom", "page-change", "form-submit", "form-submit-invalid", "form-reset",
63
+ "form-collapse", "proxy-query", "proxy-delete", "proxy-save", "toolbar-button-click", "toolbar-tool-click",
64
+ "zoom"
65
+ ],
66
+ customTableVisible: false
67
+ }
68
+ },
69
+ computed: {
70
+ options() {
71
+ const { customColumnConfig, ...others } = this.gridOptions
72
+ return {
73
+ border: true,
74
+ resizable: true,
75
+ showOverflow: true,
76
+ height: 550,
77
+ align: "left",
78
+ copyFields: [],
79
+ pagerConfig: false,
80
+ emptyText: "暂无数据",
81
+ loadingConfig: {
82
+ text: "加载中..."
83
+ },
84
+ ...others,
85
+ resizableConfig: {
86
+ minWidth: 50,
87
+ ...this.gridOptions.resizableConfig
88
+ },
89
+ rowConfig: {
90
+ height: 41,
91
+ isHover: true,
92
+ ...this.gridOptions.rowConfig
93
+ },
94
+ sortConfig: {
95
+ remote: true,
96
+ trigger: "cell",
97
+ ...this.gridOptions.sortConfig
98
+ }
99
+ }
100
+ },
101
+ // 插槽集合
102
+ slotMap() {
103
+ const slotSet = new Set([])
104
+ const slots = this.gridOptions?.customColumnConfig?.slots ?? []
105
+ this.options.columns.forEach(col => {
106
+ if (col.slots) {
107
+ const slots = Object.values(col.slots)
108
+ slots.forEach(slot => slotSet.add(slot))
109
+ }
110
+ })
111
+ return [...Array.from(slotSet), ...slots]
112
+ },
113
+ // 注册emit事件
114
+ eventListeners() {
115
+ const listeners = {}
116
+ this.events.forEach(eventName => {
117
+ listeners[eventName] = (event) => this.$emit(eventName, event)
118
+ })
119
+ return listeners
120
+ }
121
+ },
122
+ methods: {
123
+ handleCellClick(context) {
124
+ if (this.options.copyFields.includes(context.column.field)) {
125
+ const text = context.cell.outerText
126
+ this.copy(text)
127
+ }
128
+ this.$emit("cell-click", context)
129
+ },
130
+ pageChange(values) {
131
+ this.$emit("page-change", values)
132
+ },
133
+ copy(text) {
134
+ const oInput = document.createElement("input")
135
+ oInput.value = text
136
+ document.body.appendChild(oInput)
137
+ oInput.select() // 选择对象;
138
+ document.execCommand("Copy") // 执行浏览器复制命令
139
+ this.$message({
140
+ message: "复制成功",
141
+ type: "success"
142
+ })
143
+ oInput.remove()
144
+ },
145
+ getCustomColumnRef() {
146
+ return this.$refs.CustomColumnRef
147
+ },
148
+ handleOpenCustomColumn() {
149
+ this.customTableVisible = true
150
+ },
151
+ // 改变表头字段
152
+ changeTableFields(cols) {
153
+ const columns = []
154
+ cols.forEach(item => {
155
+ if (!columns.some(col => col.field === item.key) && item.type) {
156
+ columns.push(
157
+ {
158
+ field: item.key,
159
+ title: item.label,
160
+ minWidth: item.minWidth || item.width,
161
+ maxWidth: item.maxWidth,
162
+ sortable: typeof (item.sortable) === "undefined" ? true : JSON.parse(item.sortable),
163
+ fixed: item.fixed,
164
+ slots: this.gridOptions.customColumnConfig.slots.includes(item.key) ? { default: item.key } : undefined
165
+ }
166
+ )
167
+ }
168
+ })
169
+ this.$emit("setColumn", columns)
170
+ },
171
+ // 多层级表头
172
+ changeTableGroupFields(cols) {
173
+ const recursiveData = (cols)=> {
174
+ const arr = []
175
+ cols.forEach((item,index)=> {
176
+ if(item.data && item.data.length > 0) {
177
+ arr.push({
178
+ title: item.label,
179
+ align: 'center',
180
+ children: recursiveData(item.data)
181
+ })
182
+ if(index < cols.length - 1) {
183
+ arr.push({
184
+ title: '',
185
+ width: 5,
186
+ headerClassName: 'group-split',
187
+ className: 'group-split',
188
+ })
189
+ }
190
+ }else {
191
+ if (!arr.some(col => col.field === item.key) && item.type) {
192
+ arr.push({
193
+ field: item.key,
194
+ title: item.label,
195
+ minWidth: item.minWidth || item.width,
196
+ maxWidth: item.maxWidth,
197
+ sortable: typeof (item.sortable) === "undefined" ? true : JSON.parse(item.sortable),
198
+ fixed: item.fixed,
199
+ slots: this.gridOptions.customColumnConfig.slots.includes(item.key) ? { default: item.key } : undefined
200
+ })
201
+ }
202
+ }
203
+ })
204
+ return arr
205
+ }
206
+ this.$emit("setGroupColumn", recursiveData(cols))
207
+ },
208
+
209
+ // 关闭自定义表头弹框
210
+ closeCustomColumnDialog() {
211
+ this.customTableVisible = false
212
+ }
213
+ }
214
+ }
215
+ </script>
216
+
217
+ <style lang="scss" scoped>
218
+
219
+ </style>
package/src/index.js ADDED
@@ -0,0 +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
+ }
31
+ export default {install }
@@ -0,0 +1,300 @@
1
+ import Vue from "vue"
2
+ // import XEUtils from "xe-utils"
3
+ import {
4
+ // 全局实例对象
5
+ // VXETable,
6
+
7
+ // 可选表格模块
8
+ // VxeTableFilterModule,
9
+ // VxeTableEditModule,
10
+ // VxeTableMenuModule,
11
+ // VxeTableExportModule,
12
+ // VxeTableKeyboardModule,
13
+ // VxeTableValidatorModule,
14
+ // VxeTableCustomModule,
15
+
16
+ // 可选组件
17
+ VxeIcon,
18
+ VxeTable,
19
+ VxeColumn,
20
+ VxeColgroup,
21
+ VxeGrid,
22
+ VxeTooltip,
23
+ VxeToolbar,
24
+ VxePager,
25
+ // VxeForm,
26
+ // VxeFormItem,
27
+ // VxeFormGather,
28
+ // VxeCheckbox,
29
+ // VxeCheckboxGroup,
30
+ // VxeRadio,
31
+ // VxeRadioGroup,
32
+ // VxeRadioButton,
33
+ // VxeSwitch,
34
+ // VxeInput,
35
+ VxeSelect
36
+ // VxeOptgroup,
37
+ // VxeOption,
38
+ // VxeTextarea,
39
+ // VxeButton,
40
+ // VxeButtonGroup,
41
+ // VxeModal,
42
+ // VxeList,
43
+ // VxePulldown
44
+ } from "vxe-table"
45
+
46
+ // 旧版本使用 setup({}) 或者 config({})
47
+ // VXETable.config({
48
+ // // size: null, // 全局尺寸
49
+ // // zIndex: 999, // 全局 zIndex 起始值,如果项目的的 z-index 样式值过大时就需要跟随设置更大,避免被遮挡;新版本可以使用 dom-zindex 共享配置
50
+ // // version: 0, // 版本号,对于某些带数据缓存的功能有用到,上升版本号可以用于重置数据
51
+ // // loadingText: '加载中...', // 全局loading提示内容,如果为null则不显示文本
52
+ // table: {
53
+ // // showHeader: true,
54
+ // // keepSource: false,
55
+ // // showOverflow: null,
56
+ // // showHeaderOverflow: null,
57
+ // // showFooterOverflow: null,
58
+ // // size: null,
59
+ // // autoResize: false,
60
+ // // stripe: false,
61
+ // // border: false,
62
+ // // round: false,
63
+ // // minHeight: 144,
64
+ // emptyText: "暂无数据"
65
+ // // resizeConfig: {
66
+ // // refreshDelay: 250
67
+ // // },
68
+ // // rowConfig: {
69
+ // // keyField: '_X_ROW_KEY' // 行数据的唯一主键字段名
70
+ // // },
71
+ // // radioConfig: {
72
+ // // trigger: 'default'
73
+ // // },
74
+ // // checkboxConfig: {
75
+ // // strict: false,
76
+ // // highlight: false,
77
+ // // range: false,
78
+ // // trigger: 'default'
79
+ // // },
80
+ // // sortConfig: {
81
+ // // remote: false,
82
+ // // trigger: 'default',
83
+ // // orders: ['asc', 'desc', null],
84
+ // // sortMethod: null
85
+ // // },
86
+ // // filterConfig: {
87
+ // // remote: false,
88
+ // // filterMethod: null
89
+ // // },
90
+ // // expandConfig: {
91
+ // // trigger: 'default',
92
+ // // showIcon: true
93
+ // // },
94
+ // // treeConfig: {
95
+ // // rowField: 'id',
96
+ // // parentField: 'parentId',
97
+ // // children: 'children',
98
+ // // hasChild: 'hasChild',
99
+ // // mapChildren: '_X_ROW_CHILD',
100
+ // // indent: 20,
101
+ // // showIcon: true
102
+ // // },
103
+ // // tooltipConfig: {
104
+ // // enterable: true
105
+ // // },
106
+ // // menuConfig: {
107
+ // // visibleMethod () {}
108
+ // // },
109
+ // // editConfig: {
110
+ // // mode: 'cell',
111
+ // // showAsterisk: true
112
+ // // },
113
+ // // importConfig: {
114
+ // // modes: ['insert', 'covering']
115
+ // // },
116
+ // // exportConfig: {
117
+ // // modes: ['current', 'selected']
118
+ // // },
119
+ // // customConfig: {
120
+ // // storage: false,
121
+ // // mode: 'simple' // 默认自定义列方式
122
+ // // },
123
+ // // area-config: {
124
+ // // multiple: false
125
+ // // },
126
+ // // scrollX: {
127
+ // // enabled: false, // 是否默认开启横向虚拟滚动
128
+ // // gt: 60 // 当列大于指定数量时自动触发启用虚拟滚动
129
+ // // },
130
+ // // scrollY: {
131
+ // // enabled: false, // 是否默认开启纵向虚拟滚动
132
+ // // gt: 100 // 当数据大于指定数量时自动触发启用虚拟滚动
133
+ // // },
134
+ // // loading: {
135
+ // // icon: 'vxe-icon-spinner roll',
136
+ // // text: '加载中...'
137
+ // // }
138
+ // }
139
+ // // grid: {
140
+ // // emptyText: "暂无数据"
141
+ // // size: null,
142
+ // // zoomConfig: {
143
+ // // escRestore: true
144
+ // // },
145
+ // // pagerConfig: {
146
+ // // },
147
+ // // toolbarConfig: {
148
+ // // },
149
+ // // proxyConfig: {
150
+ // // autoLoad: true,
151
+ // // message: true,
152
+ // // props: {
153
+ // // list: null, // 用于列表,读取响应数据
154
+ // // result: 'result', // 用于分页,读取响应数据
155
+ // // total: 'page.total' // 用于分页,读取总条数
156
+ // // }
157
+ // // beforeItem: null,
158
+ // // beforeColumn: null,
159
+ // // beforeQuery: null,
160
+ // // afterQuery: null,
161
+ // // beforeDelete: null,
162
+ // // afterDelete: null,
163
+ // // beforeSave: null,
164
+ // // afterSave: null
165
+ // // }
166
+ // // }
167
+ // // pager: {
168
+ // // size: null,
169
+ // // autoHidden: false,
170
+ // // pageSize: 10,
171
+ // // pagerCount: 7,
172
+ // // pageSizes: [10, 15, 20, 50, 100],
173
+ // // layouts: ['PrevJump', 'PrevPage', 'Jump', 'PageCount', 'NextPage', 'NextJump', 'Sizes', 'Total']
174
+ // // },
175
+ // // form: {
176
+ // // preventSubmit: false
177
+ // // size: null,
178
+ // // colon: false,
179
+ // // validConfig: {
180
+ // // autoPos: true
181
+ // // },
182
+ // // tooltipConfig: {
183
+ // // enterable: true
184
+ // // },
185
+ // // titleAsterisk: true
186
+ // // },
187
+ // // input: {
188
+ // // size: null,
189
+ // // transfer: false
190
+ // // parseFormat: 'yyyy-MM-dd HH:mm:ss.SSS',
191
+ // // labelFormat: '',
192
+ // // valueFormat: '',
193
+ // // startDay: 1,
194
+ // // digits: 2,
195
+ // // controls: true
196
+ // // },
197
+ // // textarea: {
198
+ // // size: null
199
+ // // autosize: {
200
+ // // minRows: 1,
201
+ // // maxRows: 10
202
+ // // }
203
+ // // },
204
+ // // select: {
205
+ // // size: null,
206
+ // // transfer: false,
207
+ // // optionConfig: {
208
+ // // keyField: '_X_OPTION_KEY' // 选项数据的唯一主键字段名
209
+ // // },
210
+ // // multiCharOverflow: 8
211
+ // // },
212
+ // // toolbar: {
213
+ // // size: null,
214
+ // // import: {
215
+ // // mode: 'covering'
216
+ // // },
217
+ // // export: {
218
+ // // types: ['csv', 'html', 'xml', 'txt']
219
+ // // },
220
+ // // buttons: [],
221
+ // // tools: []
222
+ // // },
223
+ // // button: {
224
+ // // size: null,
225
+ // // transfer: false
226
+ // // },
227
+ // // radio: {
228
+ // // size: null
229
+ // // },
230
+ // // checkbox: {
231
+ // // size: null
232
+ // // },
233
+ // // switch: {
234
+ // // size: null
235
+ // // },
236
+ // // modal: {
237
+ // // // size: null,
238
+ // // minWidth: 340,
239
+ // // minHeight: 200,
240
+ // // lockView: true,
241
+ // // mask: true,
242
+ // // duration: 3000,
243
+ // // marginSize: 0,
244
+ // // dblclickZoom: true,
245
+ // // showTitleOverflow: true
246
+ // // storage: false
247
+ // // },
248
+ // // list: {
249
+ // // scrollY: {
250
+ // // gt: 100
251
+ // // }
252
+ // // }
253
+ // })
254
+
255
+ // 导入默认的语言
256
+ // import zhCN from "vxe-table/lib/locale/lang/zh-CN"
257
+
258
+ // 按需加载的方式默认是不带国际化的,自定义国际化需要自行解析占位符 '{0}',例如:
259
+ // VXETable.setConfig({
260
+ // i18n: (key, args) => XEUtils.toFormatString(XEUtils.get(zhCN, key), args)
261
+ // })
262
+
263
+ // 可选表格模块
264
+ // Vue.use(VxeTableFilterModule)
265
+ // Vue.use(VxeTableEditModule)
266
+ // Vue.use(VxeTableMenuModule)
267
+ // Vue.use(VxeTableExportModule)
268
+ // Vue.use(VxeTableKeyboardModule)
269
+ // Vue.use(VxeTableValidatorModule)
270
+ // Vue.use(VxeTableCustomModule)
271
+
272
+ // 可选组件
273
+ Vue.use(VxeIcon)
274
+ Vue.use(VxeTable)
275
+ Vue.use(VxeColumn)
276
+ Vue.use(VxeColgroup)
277
+ Vue.use(VxeGrid)
278
+ Vue.use(VxeTooltip)
279
+ Vue.use(VxeToolbar)
280
+ Vue.use(VxePager)
281
+ // Vue.use(VxeForm)
282
+ // Vue.use(VxeFormItem)
283
+ // Vue.use(VxeFormGather)
284
+ // Vue.use(VxeCheckbox)
285
+ // Vue.use(VxeCheckboxGroup)
286
+ // Vue.use(VxeRadio)
287
+ // Vue.use(VxeRadioGroup)
288
+ // Vue.use(VxeRadioButton)
289
+ // Vue.use(VxeSwitch)
290
+ // Vue.use(VxeInput)
291
+ Vue.use(VxeSelect)
292
+ // Vue.use(VxeOptgroup)
293
+ // Vue.use(VxeOption)
294
+ // Vue.use(VxeTextarea)
295
+ // Vue.use(VxeButton)
296
+ // Vue.use(VxeButtonGroup)
297
+ // Vue.use(VxeModal)
298
+ // Vue.use(VxeList)
299
+ // Vue.use(VxePulldown)
300
+ import "./vxeTable.scss"
@@ -0,0 +1,14 @@
1
+ // 修改scss变量
2
+ $vxe-font-size: 12px;
3
+ $vxe-table-header-font-color: #000;
4
+ $vxe-table-header-background-color: #fafafa;
5
+ $vxe-font-color: #606266;
6
+ // $vxe-primary-color: #409eff;
7
+ // $vxe-table-font-color: $vxe-font-color;
8
+ $vxe-table-border-color: #ebeef5;
9
+ // $vxe-table-border-radius: 4px;
10
+ $vxe-table-row-height-default: 41px;
11
+ $vxe-table-column-padding-default: 9.5px 0;
12
+ // ...
13
+
14
+ @import 'vxe-table/styles/index.scss';