Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
blryli committed May 16, 2024
1 parent fa68742 commit a96f0cc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dk-vui",
"version": "0.1.17",
"version": "0.1.18",
"description": "dk-vui",
"private": false,
"author": "blryli",
Expand Down
44 changes: 36 additions & 8 deletions packages/components/Table/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ const merge = XEUtils.merge({}, XEUtils.clone(GlobalConfig.table, true), useAttr
const initColumn = (columns) => {
const cols = columns.map(d => {
const { type, field, slots, line = 1, copy = false } = d
d.params = d.fixed
d.fixed = ''
if(d.fixed) {
if(!d.params) {
d.params = d.fixed
}
d.fixed = ''
}
if (!type && !slots) {
d.slots = {}
d.slots.default = ({ row }) => <VText value={row[field]} line={line} copy={copy} />
Expand Down Expand Up @@ -317,8 +321,18 @@ const fixs = computed(() => columnList.value.reduce((acc, cur) => {
}, {lefts: [], rights: []}))
const {columns} = merge
const cellStyle = (ags) => {
const {params, id} = ags.column
const style = typeof attrs.cellStyle === 'function' ? attrs.cellStyle(ags) : {}
const {row, column} = ags
const {params, id} = column
let style = {}
if(row) {
if(typeof attrs.cellStyle === 'function') {
style = attrs.cellStyle(ags)
}
} else {
if(typeof attrs.headerCellStyle === 'function') {
style = attrs.headerCellStyle(ags)
}
}
if(params) {
if(params === 'left') {
const index = fixs.value?.lefts.findIndex(d => d.id === id)
Expand All @@ -327,18 +341,32 @@ const cellStyle = (ags) => {
if(params === 'right') {
const index = fixs.value?.rights.findIndex(d => d.id === id)
const {scrollHeight, clientHeight} = bodyRect.value
const scrollW = !ags.row && scrollHeight > clientHeight ? 6 : 0
const scrollW = !row && scrollHeight > clientHeight ? 6 : 0
style.right = scrollW + (fixs.value?.rights.filter((d, i) => i > index).reduce((acc, cur) => acc+ (cur.renderWidth || cur.width),0) || 0) + 'px'
}
}
return style
}
const cellClassName = (ags) => {
const {params, id} = ags.column
let classes = typeof attrs.cellClassName === 'function' ? attrs.cellClassName(ags) : typeof attrs.cellClassName === 'string' ? attrs.cellClassName : ''
const {row, column} = ags
const {params, id} = column
let classes = ''
if(row) {
if(typeof attrs.cellClassName === 'function') {
style = attrs.cellClassName(ags)
} else if(typeof attrs.cellClassName === 'string') {
attrs.cellClassName
}
} else {
if(typeof attrs.headerCellClassName === 'function') {
style = attrs.headerCellClassName(ags)
} else if(typeof attrs.headerCellClassName === 'string') {
attrs.headerCellClassName
}
}
if(params) {
classes += ags.row ? ' cell--fixed' : ' header-cell--fixed'
classes += row ? ' cell--fixed' : ' header-cell--fixed'
if(params === 'left') {
const index = fixs.value?.lefts.findIndex(d => d.id === id)
if(fixs.value?.lefts.length - 1 === index && bodyRect.value.scrollLeft) {
Expand Down

0 comments on commit a96f0cc

Please sign in to comment.