Skip to content

Commit

Permalink
feat: ✨add column props
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjone committed May 11, 2023
1 parent e3b27f8 commit c5d5b43
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
26 changes: 16 additions & 10 deletions src/components/column/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@
...$styleBox.getBorderColor()
}"
>
<div
class="cell"
:style="{ lineHeight: `${rowHeight}px`, height: `${rowHeight}px` }"
>
<div :style="{ lineHeight: `${rowHeight}px`, height: `${rowHeight}px` }">
<SelectionVue
v-if="props.__index === 0"
:data="data"
:indent="20"
:show-checkbox="$styleBox.showCheckbox"
/>

<slot v-if="slots.default" v-bind="toRowData(props.data)" />
<div
:class="['cell', { 'cell-center': props.center }, props.columnClass]"
:style="props.columnStyle"
>
<slot v-if="slots.default" v-bind="toRowData(props.data)" />

<template v-else-if="props.prop">{{
props.dateFormat
? formatDate(props.data?.data?.[props.prop], props.dateFormat)
: props.data?.data?.[props.prop]
}}</template>
<template v-else-if="props.prop">{{
props.dateFormat
? formatDate(originData, props.dateFormat)
: originData
}}</template>
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -55,6 +57,10 @@ watch(
}
);
const originData = computed(
() => props.data?.data?.[props.prop ?? ''] ?? props.emptyData
);
const { $styleBox, rowHeight } = useStyle();
const { toRowData } = useData();
Expand Down
8 changes: 0 additions & 8 deletions src/components/column/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ export default {
default: Variables.noData
},

/**
* 是否可以选择文本
*/
selectable: {
type: Boolean,
default: false
},

/**
* 内容样式
*/
Expand Down
1 change: 1 addition & 0 deletions src/components/column/selection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
}
"
>
<!-- TODO: 图标统一处理 -->
<svg
t="1682094638676"
class="icon"
Expand Down
20 changes: 13 additions & 7 deletions src/components/column/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@
box-sizing: border-box;
border-right: 1px solid;

.cell {
& > div {
width: calc(100% - 12px);
overflow: hidden;
white-space: nowrap;
font-size: 14px;
vertical-align: middle;
font-size: 13px;
text-overflow: ellipsis;
padding: 0 6px;
display: flex;
align-items: baseline;
justify-content: flex-start;

.expand-icon {
display: inline-block;
vertical-align: middle;
margin-right: 4px;
cursor: pointer;
transition: transform 0.2s ease-in-out;
position: relative;
transform-origin: center 45%;
}

.expand-icon__expanded {
Expand All @@ -31,5 +29,13 @@
.level-block {
display: inline-block;
}

.cell {
flex: 1;
}

.cell-center {
text-align: center;
}
}
}

0 comments on commit c5d5b43

Please sign in to comment.