带图标的列左对齐

This commit is contained in:
mll
2026-03-26 16:22:56 +08:00
parent f4eca63a29
commit a4a03fb756

View File

@@ -14,6 +14,7 @@
v-bind="crudBind" v-bind="crudBind"
:summary-method=summaryMethod1 :summary-method=summaryMethod1
:row-style="rowStyleMethod" :row-style="rowStyleMethod"
:cell-class-name="cellClassNameMethod"
@search-change="searchChange" @search-change="searchChange"
@search-reset="resetChange" @search-reset="resetChange"
@refresh-change="refreshChange" @refresh-change="refreshChange"
@@ -187,6 +188,7 @@ const fieldList = ref<any[]>([]) // 添加fieldList引用
const hideFeilds= ref<any>({}) const hideFeilds= ref<any>({})
const hideCols=ref<any>([]) const hideCols=ref<any>([])
const dictFieldList=ref<any>([]) const dictFieldList=ref<any>([])
const textAlignFiels=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(() => {
@@ -277,6 +279,12 @@ const summaryMethod1=({columns,data})=>{
}) })
return styleObj return styleObj
} }
const cellClassNameMethod=({row,column,rowIndex,columnIndex})=>{
if(textAlignFiels.value[column.property]){
return 'textAlignCell'
}
}
function getCurrentDate() { function getCurrentDate() {
const now = new Date(); const now = new Date();
// 补零函数小于10则前面加0 // 补零函数小于10则前面加0
@@ -568,12 +576,15 @@ const getSearchData = () => {
resolve(searchObj) resolve(searchObj)
}) })
} }
const computedIncluedes=(row,prop)=>{
return (typeof row[prop])==='string'&&(row[prop].includes('🔴')||row[prop].includes('🟢'))
}
const getTableData = async (isLoading = true) => { const getTableData = async (isLoading = true) => {
if (timerObj.value.getTableData) clearTimeout(timerObj.value.getTableData) if (timerObj.value.getTableData) clearTimeout(timerObj.value.getTableData)
await new Promise((resolve) => { await new Promise((resolve) => {
timerObj.value.getTableData = setTimeout(() => resolve(true), 100) timerObj.value.getTableData = setTimeout(() => resolve(true), 100)
}) })
textAlignFiels.value={}
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
if (isLoading) loading.value = true if (isLoading) loading.value = true
const searchObj = await getSearchData() const searchObj = await getSearchData()
@@ -721,9 +732,10 @@ const getTableData = async (isLoading = true) => {
// 没有分组字段,直接处理数据 // 没有分组字段,直接处理数据
processedData = data.records.map((record, recordIndex) => { processedData = data.records.map((record, recordIndex) => {
const flatRecord = { ...record } const flatRecord = { ...record }
// 处理固定列 // 处理固定列
fieldList.value.forEach(field => { fieldList.value.forEach(field => {
computedIncluedes(record,field.fieldCode)&&!textAlignFiels.value[field.fieldCode]?textAlignFiels.value[field.fieldCode]=true:''
if (field.isFixedColumn === 'Y' && field.fixedColumnValue) { if (field.isFixedColumn === 'Y' && field.fixedColumnValue) {
const fixedValues = field.fixedColumnValue.split(',') const fixedValues = field.fixedColumnValue.split(',')
flatRecord[field.fieldCode] = fixedValues[recordIndex] || '' flatRecord[field.fieldCode] = fixedValues[recordIndex] || ''
@@ -915,6 +927,7 @@ defineExpose({
} }
.el-table__body tr.hover-row>td.el-table__cell{ .el-table__body tr.hover-row>td.el-table__cell{
background-color: #FFFFD2; background-color: #FFFFD2;
} }
&.el-table--enable-row-hover .el-table__body tr:hover>td.el-table__cell{ &.el-table--enable-row-hover .el-table__body tr:hover>td.el-table__cell{
background-color: #FFFFD2; background-color: #FFFFD2;
@@ -925,6 +938,13 @@ defineExpose({
border-right: 1px solid #000 !important; border-right: 1px solid #000 !important;
} }
td.textAlignCell .cell{
span{
text-align: left;
width: 100%;
display: inline-block;
}
}
--el-table-border-color: #000; --el-table-border-color: #000;
tfoot .el-table__cell{ tfoot .el-table__cell{
border-top: 1px solid #000 !important; border-top: 1px solid #000 !important;