📝(component): 编写 table 行内编辑案例

This commit is contained in:
就眠儀式
2022-08-04 17:45:00 +08:00
parent a61c6d0bef
commit 42020ec132
4 changed files with 182 additions and 85 deletions

View File

@@ -127,7 +127,13 @@ const isDisabled = computed(() => {
><slot>{{ label }}</slot></span
>
<lay-icon
:type="props.isIndeterminate && isChecked ? 'layui-icon-subtraction' : isChecked ? 'layui-icon-ok' : ''"
:type="
props.isIndeterminate && isChecked
? 'layui-icon-subtraction'
: isChecked
? 'layui-icon-ok'
: ''
"
></lay-icon>
</div>
</span>

View File

@@ -84,17 +84,22 @@ const tableSelectedKey: WritableComputedRef<Recordable[]> = computed({
const isExpand: WritableComputedRef<any> = computed({
get() {
return tableExpandAll.value ? true : tableExpandKeys.value.includes(props.data[props.id]);
return tableExpandAll.value
? true
: tableExpandKeys.value.includes(props.data[props.id]);
},
set(val) {
let newTableExpandKeys = [...tableExpandKeys.value]
if (!val) {
newTableExpandKeys.splice(newTableExpandKeys.indexOf(props.data[props.id]), 1);
} else {
newTableExpandKeys.push(props.data[props.id]);
}
tableExpandAll.value = false;
tableExpandKeys.value = newTableExpandKeys;
let newTableExpandKeys = [...tableExpandKeys.value];
if (!val) {
newTableExpandKeys.splice(
newTableExpandKeys.indexOf(props.data[props.id]),
1
);
} else {
newTableExpandKeys.push(props.data[props.id]);
}
tableExpandAll.value = false;
tableExpandKeys.value = newTableExpandKeys;
},
});

View File

@@ -66,7 +66,7 @@ const props = withDefaults(defineProps<LayTableProps>(), {
cellStyle: "",
spanMethod: () => {},
defaultExpandAll: false,
expandKeys: () => []
expandKeys: () => [],
});
const tableId = uuidv4();
@@ -305,7 +305,10 @@ const getFixedColumn = () => {
hasr.value = true;
} else {
// @ts-ignore
if (tableBody.value?.scrollLeft + tableBody.value?.offsetWidth + 2 > tableBody.value?.scrollWidth) {
if (
tableBody.value?.scrollLeft + tableBody.value?.offsetWidth + 2 >
tableBody.value?.scrollWidth
) {
hasl.value = true;
hasr.value = false;
} else {