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