Skip to content

Commit

Permalink
refactor:TTable组件--单击编辑单元格--默认表头显示编辑icon
Browse files Browse the repository at this point in the history
  • Loading branch information
wocwin committed Nov 29, 2024
1 parent d62a02a commit 34402d7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/components/TTable/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ TTable/expand
| ----canEdit | 是否开启单元格编辑功能 | Boolean | false |
| ----isClickEdit<el-tag>1.4.15</el-tag> | 是否开启单击-单元格编辑功能 | Boolean | false |
| ----isShowEditIcon<el-tag>1.4.15</el-tag> | 开启单击-单元格编辑后表头是否显示编辑图标 | Boolean | false |
| ----editIconAlign<el-tag>1.4.15</el-tag> | 编辑icon表头的对齐方式(可选值:flex-end、center、flex-start) | String | 'center' |
| ----configEdit | 表格编辑配置(开启编辑功能有效) | Object | - |
| ----------rules | 规则(可依据 elementPlus el-form 配置————对应 columns 的 prop 值) | Object | - |
| ----------label | placeholder 显示 | String | - |
Expand All @@ -411,6 +412,7 @@ TTable/expand
| ----------arrKey | type:select-arr/radio/checkbox 时对应显示的数字字段 | String | key |
| ----------ref | 当前使用组件的 ref 标识(可以通过 getRefs 事件返回) | String | - |
| ----------isShowTips<el-tag>1.4.15</el-tag> | 开启单击-单元格编辑后鼠标移入是否显示tip | Boolean | false |
| ----------tipbind<el-tag>1.4.15</el-tag> | 继承el-tooltip的所有属性 | Object | - |
| ----filters | 字典过滤 | Object | - |
| ----------list | listTypeInfo 里面对应的下拉数据源命名 | String | - |
| ----------key | 数据源的 key 字段 | String | 'value' |
Expand Down
2 changes: 0 additions & 2 deletions docs/examples/TTable/editSingle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const table = ref<TableTypes.Table>({
label: "爱好单选",
minWidth: "180",
isClickEdit: true,
isShowEditIcon: true,
configEdit: {
label: "爱好单选",
type: "select-arr",
Expand All @@ -68,7 +67,6 @@ const table = ref<TableTypes.Table>({
event: "hobbyList",
arrLabel: "label",
arrKey: "value",
isShowTips: true
}
},
{
Expand Down
21 changes: 18 additions & 3 deletions packages/table/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,13 @@
<span style="color: #f56c6c; font-size: 16px; margin-right: 3px">*</span>
<span>{{ item.label }}</span>
</div>
<div v-if="item.isClickEdit">
<div
v-if="item.isClickEdit"
class="click_edit"
:style="{ justifyContent: item.editIconAlign || align || 'center' }"
>
<span>{{ item.label }}</span>
<el-icon v-if="!item.isShowEditIcon" v-bind="{ ...item.editIconBind }">
<el-icon v-if="!item.isShowEditIcon" v-bind="{ size: 14, ...item.editIconBind }">
<Edit />
</el-icon>
</div>
Expand Down Expand Up @@ -1093,7 +1097,18 @@ defineExpose({
}
}
}
.el-table {
.cell {
.click_edit {
display: flex;
align-items: center;
line-height: 1;
.el-icon {
margin-left: 2px;
}
}
}
}
.el-table th,
.el-table td {
padding: 8px 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/singleEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
effect: 'light',
content: '单击可编辑',
placement: 'top',
...configEdit.bind
...configEdit.tipbind
}"
>
<div v-if="childCom.includes(configEdit.type)">{{ childVal }}&nbsp;</div>
Expand Down

0 comments on commit 34402d7

Please sign in to comment.