From bdc9c244a4d96dfdbc2f14947348da209cceccf4 Mon Sep 17 00:00:00 2001
From: lilinyuan <1084668738@qq.com>
Date: Mon, 13 May 2024 22:22:55 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=BB=84=E4=BB=B6?=
=?UTF-8?q?=E5=88=97=E5=B1=95=E7=A4=BA=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/fvcomponents/fvTable/index.vue | 143 +++++++++++++++++++++++++----
1 file changed, 124 insertions(+), 19 deletions(-)
diff --git a/src/fvcomponents/fvTable/index.vue b/src/fvcomponents/fvTable/index.vue
index 1b42ff2..c90af06 100644
--- a/src/fvcomponents/fvTable/index.vue
+++ b/src/fvcomponents/fvTable/index.vue
@@ -2,15 +2,48 @@
-
- {{ btn.name }}
-
+
+
+ {{ btn.name }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -30,7 +63,7 @@
ref="tableInstance"
>
-
+
@@ -80,10 +113,17 @@ const props = defineProps({
pagination: {
type: Boolean,
default: true
+ },
+ // 是否显示列配置
+ isSettingCol: {
+ type: Boolean,
+ default: true
}
})
const tableInstance = ref()
+const buttonRef = ref()
+const popoverRef = ref()
const localData = reactive({
list: [], // 表格数据
@@ -92,7 +132,12 @@ const localData = reactive({
pageNum: 1
},
total: 0,
- loading: false
+ loading: false,
+ // 列展示设置
+ columns: [],
+ allColShow: true, // 默认全部列都展示
+ indeterminate: false,
+ checkGroup: []
})
const emits = defineEmits(['headBtnClick', 'selectionChange', 'rowClick', 'rowDblclick', 'getBaseQuery', 'cellClick'])
@@ -101,6 +146,52 @@ const handleClickBtns = (key) => {
emits('headBtnClick', key)
}
+const filterColumns = () => {
+ localData.columns = props.tableConfig.columns.map(item=>{
+ if(item.prop) {
+ return {
+ ...item
+ }
+ }
+ })
+}
+
+const changeIsShowAll = (val) => {
+ if(val) {
+ filterColumns()
+ localData.indeterminate = false
+ localData.checkGroup = props.tableConfig.columns.map(item=>item.prop)
+ } else {
+ localData.columns.length = 0
+ localData.checkGroup.length = 0
+ localData.indeterminate = false
+ }
+}
+
+const changeColShow = (val) => {
+ if(val.length == props.tableConfig.columns.length) {
+ localData.indeterminate = false
+ localData.allColShow = true
+ } else if(val.length !== props.tableConfig.columns.length && val.length != 0) {
+ localData.allColShow = false
+ localData.indeterminate = true
+ } else {
+ localData.indeterminate = false
+ localData.allColShow = false
+ }
+ const template = []
+ props.tableConfig.columns.forEach(item=>{
+ val.forEach(v=>{
+ if(item.prop == v) {
+ template.push(item)
+ }
+ })
+ })
+ localData.columns = template
+}
+
+filterColumns()
+
const getList = async () => {
const { api, params } = props.tableConfig
const queryParmas = {...localData.query, ...params}
@@ -154,13 +245,11 @@ const handleCurrentChange = (val) => {
getList()
}
-// watchEffect(()=>{
-// if(!props.tableConfig.api) {
-// localData.list = props.data
-// }else {
-// getList()
-// }
-// })
+watchEffect(()=>{
+ if(localData.allColShow) {
+ localData.checkGroup = props.tableConfig.columns.map(item=>item.prop)
+ }
+})
//刷新
const refresh = ({resetPage=false}={}) => {
resetPage ? localData.query.pageNum = 1 : null
@@ -184,5 +273,21 @@ onMounted(() => {
\ No newline at end of file