维度隐藏列

This commit is contained in:
mll
2026-02-09 20:16:36 +08:00
parent f9393dfca8
commit bcac3326a3
5 changed files with 62 additions and 6 deletions

View File

@@ -68,7 +68,7 @@
></InputTimeRange> ></InputTimeRange>
</template> </template>
<template #header v-if="Object.keys(dimensionFields)?.length"> <template #header v-if="Object.keys(dimensionFields)?.length">
<div style="display:flex;margin-left:40px"> <div style="display:flex;margin-left:40px">
<el-checkbox-group @change="searchDimension" v-model="tableSearch['Group by']" <el-checkbox-group @change="searchDimension" v-model="tableSearch['Group by']"
placeholder="请选择内容"> placeholder="请选择内容">
<template v-for="(item,key) in dimensionFields"> <template v-for="(item,key) in dimensionFields">
@@ -136,6 +136,7 @@ const crudRef = ref()
const dimensionFields=ref<any>({}) const dimensionFields=ref<any>({})
const exportLoading = ref(false) const exportLoading = ref(false)
const fieldList = ref<any[]>([]) // 添加fieldList引用 const fieldList = ref<any[]>([]) // 添加fieldList引用
const hideFeilds= ref<any>({})
const permissions = const permissions =
wsCache.get(CACHE_KEY.USER).lideeYunjipermissions?.[route.meta.menuDataId as string] || false wsCache.get(CACHE_KEY.USER).lideeYunjipermissions?.[route.meta.menuDataId as string] || false
const selectIds = computed(() => { const selectIds = computed(() => {
@@ -258,6 +259,8 @@ const initTable = async () => {
} }
if(item.isDimension=='Y'){ if(item.isDimension=='Y'){
dimensionFields.value[config.prop]=config dimensionFields.value[config.prop]=config
hideFeilds.value[config.prop]=item.isHideDimension
} }
if (item.queryMode == 'RANGE') config.searchRange = true if (item.queryMode == 'RANGE') config.searchRange = true
@@ -301,6 +304,7 @@ const initTable = async () => {
initTableLayout() initTableLayout()
} }
const searchDimension=()=>{ const searchDimension=()=>{
searchChange() searchChange()
} }
const initTableLayout = () => { const initTableLayout = () => {
@@ -467,6 +471,15 @@ const clearSearch = () => {
const searchChange = (params?, done?) => { const searchChange = (params?, done?) => {
if (tablePage.value) tablePage.value['currentPage'] = 1 if (tablePage.value) tablePage.value['currentPage'] = 1
getTableData().finally(() => { getTableData().finally(() => {
let field=tableSearch.value['Group by']
let hides=[]
if(field.length){
hides=Object.keys(hideFeilds.value).length?hideFeilds.value[field].split(','):[]
}
Object.keys(tableOption.value.column).forEach(key=>{
let item=tableOption.value.column[key]
item.hide=hides.includes(item.prop)
})
if (done) done() if (done) done()
}) })
} }

View File

@@ -183,6 +183,43 @@ export const useRenderVxeColumn = (useType = 'table') => {
) )
} }
}, },
LowSelectMultiple: {
default: (renderOpts, { row, column }, isStop = false) => {
const { dicData } = renderOpts
const value = row[column.field]
const valStr=dicData.filter(item=>value.includes(item.value)).map(item=>item.label).join('')
return <span>{valStr}</span>
},
edit: (renderOpts, { row, rowIndex, column }) => {
const { multiple, filterable, allowCreate, typeKey ,dicData} = renderOpts
interface DictItem {
label: string;
value: string | number;
[key: string]: any; // 兼容其他可能的字段
}
return (
<el-select
popper-class="vxe-table--ignore-clear"
v-model={row[column.field]}
placeholder={'请选择 ' + column.title}
multiple={multiple}
filterable={filterable}
collapseTags={true}
collapseTagsTooltip={true}
allowCreate={allowCreate}
clearable={true}
>
{dicData.map((item: DictItem, index: number) => (
<el-option
key={index} // 建议用 item.value 作为 key更稳定
label={item.label}
value={item.value}
/>
))}
</el-select>
)
}
},
LowSummaryBottomSql: { LowSummaryBottomSql: {
default: (renderOpts, { row, column }, isStop = false) => { default: (renderOpts, { row, column }, isStop = false) => {
const { dicObj } = renderOpts const { dicObj } = renderOpts

View File

@@ -89,6 +89,7 @@ const parentFieldMap = ref(new Map())
const fieldList = computed(() => { const fieldList = computed(() => {
let dicData: Array<{ label: string; value: string; type: string }> = [] let dicData: Array<{ label: string; value: string; type: string }> = []
infoData.value.basics.forEach((item) => { infoData.value.basics.forEach((item) => {
if (item.fieldCode && item.isDb == 'Y') if (item.fieldCode && item.isDb == 'Y')
dicData.push({ dicData.push({
label: `${item.fieldCode}${item.fieldName ? '' + item.fieldName + '' : ''}`, label: `${item.fieldCode}${item.fieldName ? '' + item.fieldName + '' : ''}`,
@@ -257,7 +258,9 @@ const initEditInfoData = () => {
if (fieldItem.hasChildren === 'Y') { if (fieldItem.hasChildren === 'Y') {
fieldItem.hasChildren = 'Y' fieldItem.hasChildren = 'Y'
} }
if (!!fieldItem.isHideDimension&&Object.prototype.toString.call(fieldItem.isHideDimension) == '[object String]') {
fieldItem.isHideDimension=fieldItem.isHideDimension.split(',')
}
fieldList.push(fieldItem) fieldList.push(fieldItem)
}) })
@@ -282,7 +285,9 @@ onMounted(() => {
}) })
} }
} }
tableInfoOption.infoColumn.fieldColumn.isHideDimension.editRender.dicData = infoData.value.basics.map(({fieldCode,fieldName})=>{
return {label:fieldName,value:fieldCode}
})
// 设置父字段下拉选项 // 设置父字段下拉选项
const updateParentFieldOptions = () => { const updateParentFieldOptions = () => {
// 获取所有parentFieldCode为空的字段作为可选父字段 // 获取所有parentFieldCode为空的字段作为可选父字段

View File

@@ -159,7 +159,8 @@ const infoColumn = {
isExport: { title: '是否可导出', width: 90, align: "center", editRender: { name: 'LowCheckbox' } }, isExport: { title: '是否可导出', width: 90, align: "center", editRender: { name: 'LowCheckbox' } },
isAmount: { title: '是否合计', width: 75, align: "center", editRender: { name: 'LowCheckboxSum' } }, isAmount: { title: '是否合计', width: 75, align: "center", editRender: { name: 'LowCheckboxSum' } },
isDimension: { title: '是否维度', width: 75, align: "center", editRender: { name: 'LowCheckbox' } }, isDimension: { title: '是否维度', width: 75, align: "center", editRender: { name: 'LowCheckbox' } },
isHideDimension: { title: '维度隐藏列', width: 180, editRender: { name: 'LowSelectMultiple', verifyEdit: true, filterable: true, multiple:true,dicData: [] } },
isShowSort: { title: '是否排序', width: 75, align: "center", editRender: { name: 'LowCheckbox' } }, isShowSort: { title: '是否排序', width: 75, align: "center", editRender: { name: 'LowCheckbox' } },
hasChildren: { title: '子字段', width: 90, align: "center", editRender: { name: 'LowButton', disabled: (row) => row.isSubField === true, buttonText: '添加子字段', buttonType: 'primary', buttonSize: 'small' } }, hasChildren: { title: '子字段', width: 90, align: "center", editRender: { name: 'LowButton', disabled: (row) => row.isSubField === true, buttonText: '添加子字段', buttonType: 'primary', buttonSize: 'small' } },
}, },
@@ -187,7 +188,7 @@ for (const key in infoColumn) {
//默认值 //默认值
const infoDefaultData = { const infoDefaultData = {
basics: { basics: {
fieldCode: '', fieldName: '', parentFieldName: '', labelI18n: '', fieldType: 'String', queryIsDb: 'N', queryIsWeb: 'N', queryMode: 'LIKE', dictCode: '', isExport: 'Y', isShowSort: 'N', isAmount: '', isDimension: '', hasChildren: 'N', isSubField: false, parentFieldId: '', parentFieldCode: '', fieldCode: '', fieldName: '', parentFieldName: '', labelI18n: '', fieldType: 'String', queryIsDb: 'N', queryIsWeb: 'N', queryMode: 'LIKE', dictCode: '', isExport: 'Y', isShowSort: 'N', isAmount: '', isDimension: '',isHideDimension:'', hasChildren: 'N', isSubField: false, parentFieldId: '', parentFieldCode: '',
}, },
} }

View File

@@ -349,7 +349,7 @@ const tableFormVerify = (type) => {
const index = Number(i) const index = Number(i)
const item = filedData[index] const item = filedData[index]
item.sortNum = index + 1 item.sortNum = index + 1
item.isHideDimension?item.isHideDimension=item.isHideDimension.join(','):''
let messageText = '' let messageText = ''
let tabKey = 'mysql' let tabKey = 'mysql'
// 子字段不能再包含子字段 // 子字段不能再包含子字段