From 4314fc52f25cc4a3edffa00e5ef912797b64e0d5 Mon Sep 17 00:00:00 2001
From: xlzy <1017866168@qq.com>
Date: Thu, 11 Feb 2021 18:56:22 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=A1=A8=E6=A0=BC?=
=?UTF-8?q?=E5=BF=AB=E6=8D=B7=E6=93=8D=E4=BD=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
_web/package.json | 1 +
_web/src/components/Table/columnSetting.vue | 81 ++++++++++++
_web/src/components/Table/index.js | 129 +++++++++++++++++++-
_web/src/components/Table/index.less | 54 ++++++++
_web/src/views/system/user/index.vue | 7 +-
5 files changed, 266 insertions(+), 6 deletions(-)
create mode 100644 _web/src/components/Table/columnSetting.vue
create mode 100644 _web/src/components/Table/index.less
diff --git a/_web/package.json b/_web/package.json
index 9f92061c..c2c21703 100644
--- a/_web/package.json
+++ b/_web/package.json
@@ -30,6 +30,7 @@
"nprogress": "^0.2.0",
"print-js": "^1.0.63",
"raphael": "^2.3.0",
+ "screenfull": "^5.1.0",
"viser-vue": "^2.4.6",
"vue": "^2.6.10",
"vue-clipboard2": "^0.2.1",
diff --git a/_web/src/components/Table/columnSetting.vue b/_web/src/components/Table/columnSetting.vue
new file mode 100644
index 00000000..a5b2e44c
--- /dev/null
+++ b/_web/src/components/Table/columnSetting.vue
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
diff --git a/_web/src/components/Table/index.js b/_web/src/components/Table/index.js
index 0397f88c..2d4d7322 100644
--- a/_web/src/components/Table/index.js
+++ b/_web/src/components/Table/index.js
@@ -1,7 +1,14 @@
import T from 'ant-design-vue/es/table/Table'
import get from 'lodash.get'
+import screenfull from 'screenfull'
+import draggable from 'vuedraggable'
+import columnSetting from './columnSetting'
+import './index.less'
export default {
+ components: {
+ draggable, columnSetting
+ },
data () {
return {
needTotalList: [],
@@ -11,7 +18,15 @@ export default {
localLoading: false,
localDataSource: [],
- localPagination: Object.assign({}, this.pagination)
+ localPagination: Object.assign({}, this.pagination),
+ isFullscreen: false,
+ customSize: this.size,
+
+ // 列配置
+ indeterminate: true,
+ checkAll: false,
+ checkedList: [],
+ columnsSetting: []
}
},
props: Object.assign({}, T.props, {
@@ -74,6 +89,10 @@ export default {
pageURI: {
type: Boolean,
default: false
+ },
+ extraTool: {
+ type: Array,
+ default: () => ([])
}
}),
watch: {
@@ -116,6 +135,7 @@ export default {
// console.log('this.localPagination', this.localPagination)
this.needTotalList = this.initTotalList(this.columns)
this.loadData()
+ this.columnsSetting = this.columns
},
methods: {
/**
@@ -276,11 +296,109 @@ export default {
) */
+ },
+ columnChange(val) {
+ this.columnsSetting = val
+ },
+ renderHeader () {
+ let tools = [
+ {
+ icon: 'reload',
+ title: '刷新',
+ onClick: () => {
+ this.refresh()
+ }
+ },
+ {
+ icon: 'column-height',
+ title: '密度',
+ isDropdown: true,
+ menu: () => {
+ const onClick = ({ key }) => {
+ this.customSize = key
+ }
+ return (
+
+ 默认
+ 中等
+ 紧凑
+
+ )
+ },
+ onClick: () => {
+ }
+ },
+ {
+ icon: 'setting',
+ title: '列设置',
+ isDropdown: true,
+ menu: () => {
+ return
+ },
+ onClick: () => {
+ }
+ },
+ {
+ icon: this.isFullscreen ? 'fullscreen-exit' : 'fullscreen',
+ title: '全屏',
+ onClick: () => {
+ if (screenfull.isEnabled) {
+ const table = document.querySelector('.table-wrapper')
+ const antdCard = table.parentNode.parentNode
+ if (antdCard.classList.contains('ant-card')) {
+ screenfull.toggle(antdCard)
+ this.isFullscreen = !this.isFullscreen
+ }
+ }
+ }
+ }
+ ]
+ if (this.extraTool.length) {
+ tools = tools.concat(this.extraTool)
+ }
+
+ return (
+
+ )
+ /* return (
+
+
+ 已选择: {this.selectedRows.length}
+ {needTotalItems}
+ {clearItem}
+
+
+ ) */
}
},
render () {
- const props = {}
+ let props = {}
const localKeys = Object.keys(this.$data)
const showAlert = (typeof this.alert === 'object' && this.alert !== null && this.alert.show) && typeof this.rowSelection.selectedRowKeys !== 'undefined' || this.alert
@@ -311,6 +429,12 @@ export default {
}
}
this[k] && (props[k] = this[k])
+ // 此处配置表格大小与要显示的列
+ props = {
+ ...props,
+ size: this.customSize,
+ columns: this.columnsSetting.filter(value => value.checked === undefined || value.checked)
+ }
return props[k]
})
const table = (
@@ -321,6 +445,7 @@ export default {
return (
+ { this.renderHeader() }
{ showAlert ? this.renderAlert() : null }
{ table }
diff --git a/_web/src/components/Table/index.less b/_web/src/components/Table/index.less
new file mode 100644
index 00000000..3ef67936
--- /dev/null
+++ b/_web/src/components/Table/index.less
@@ -0,0 +1,54 @@
+.table-wrapper{
+ background: #fff;
+}
+.s-table-tool{
+ display: flex;
+ margin-bottom: 16px;
+ .s-table-tool-left{
+ flex: 1;
+ }
+ .s-table-tool-right{
+ display: inline-flex;
+ align-items: center;
+ .s-tool-item{
+ font-size: 16px;
+ margin-left: 16px;
+ cursor: pointer;
+
+ }
+ }
+}
+
+.s-tool-column-item{
+ display: flex;
+ align-items: center;
+ padding: 4px 16px 4px 4px;
+ .ant-checkbox-wrapper{
+ flex: 1;
+ }
+ .s-tool-column-handle{
+ opacity: .8;
+ cursor: move;
+ .anticon-more{
+ font-size: 12px;
+ margin-top: 2px;
+ & + .anticon-more{
+ margin: 2px 4px 0 -8px;
+ }
+ }
+ }
+}
+.s-tool-column-header{
+ padding: 5px 16px 10px 24px;
+ min-width: 180px;
+}
+.s-tool-column{
+ .ant-divider{
+ margin: 0;
+ }
+ .ant-checkbox-group{
+ padding: 4px 0;
+ display: block;
+ }
+}
+
diff --git a/_web/src/views/system/user/index.vue b/_web/src/views/system/user/index.vue
index 0606b278..6dab6a40 100644
--- a/_web/src/views/system/user/index.vue
+++ b/_web/src/views/system/user/index.vue
@@ -43,10 +43,6 @@
-
-
+
+ 新增用户
+
{{ sexFilter(text) }}