feat: table组件增加 disabled 行样式

This commit is contained in:
baiqi 2023-06-16 18:57:13 +08:00 committed by 刘瑞斌
parent 48dc33212f
commit 800de216e8
3 changed files with 45 additions and 8 deletions

View File

@ -12,6 +12,16 @@
}
}
}
.ms-table-row-disabled {
td:not(.arco-table-col-fixed-right),
&:hover,
td:not(.arco-table-col-fixed-right)::before,
.arco-checkbox-icon,
.arco-tag {
color: var(--color-text-4);
background-color: var(--color-text-n8) !important;
}
}
/** Tabs 组件样式 **/
.arco-tabs-nav-add-btn {
@ -45,6 +55,18 @@
background-color: rgb(var(--primary-3)) !important;
}
}
.arco-btn-status-danger {
background-color: rgb(var(--danger-6)) !important;
&:not(:disabled):hover {
background-color: rgb(var(--danger-5)) !important;
}
&:not(:disabled):active {
background-color: rgb(var(--danger-7)) !important;
}
&:disabled {
background-color: rgb(var(--danger-2)) !important;
}
}
.arco-btn-secondary {
color: var(--clolor-text-1) !important;
background-color: var(--color-text-n8) !important;

View File

@ -7,7 +7,12 @@
:current="selectCurrent"
@change="handleChange"
/>
<a-table v-bind="$attrs" :selected-keys="props.selectedKeys" @selection-change="(e) => selectionChange(e, true)">
<a-table
v-bind="$attrs"
:row-class="getRowClass"
:selected-keys="props.selectedKeys"
@selection-change="(e) => selectionChange(e, true)"
>
<template v-for="(item, key, i) in slots" :key="i" #[key]="{ record, rowIndex, column }">
<slot :name="key" v-bind="{ rowIndex, record, column }"></slot>
</template>
@ -30,12 +35,13 @@
</template>
<script lang="ts" setup>
// eslint-disable no-console
import { useSlots, useAttrs, computed, ref, onMounted } from 'vue';
import selectAll from './select-all.vue';
import { MsTableProps, SelectAllEnum, MsPaginationI } from './type';
import BatchAction from './batchAction.vue';
import type { TableData } from '@arco-design/web-vue';
const batchleft = ref('10px');
const props = defineProps({
selectedKeys: {
@ -122,6 +128,12 @@
}
};
function getRowClass(record: TableData) {
if (record.disabled) {
return 'ms-table-row-disabled';
}
}
onMounted(() => {
batchleft.value = getBatchLeft();
});

View File

@ -2,13 +2,13 @@
// hook/table-props.ts
import { ref } from 'vue';
import { MsTableProps, MsTableData, MsTableColumn } from './type';
import { CommonList } from '@/models/api-test';
import { TableData } from '@arco-design/web-vue';
import dayjs from 'dayjs';
import { QueryParams } from '@/models/common';
import { TableQueryParams } from '@/models/common';
import { useAppStore } from '@/store';
import type { TableData } from '@arco-design/web-vue';
import type { MsTableProps, MsTableData, MsTableColumn } from './type';
export interface Pagination {
current: number;
pageSize: number;
@ -16,9 +16,11 @@ export interface Pagination {
showPageSize: boolean;
}
type GetListFunc = (v: QueryParams) => Promise<CommonList>;
const appStore = useAppStore();
export default function useTableProps(loadListFunc: GetListFunc, props?: Partial<MsTableProps>) {
export default function useTableProps(
loadListFunc: (v: TableQueryParams) => Promise<any>,
props?: Partial<MsTableProps>
) {
// 行选择
const rowSelection = {
type: 'checkbox',
@ -152,6 +154,7 @@ export default function useTableProps(loadListFunc: GetListFunc, props?: Partial
setPagination({ current: data.current, total: data.total });
return data;
} catch (err) {
console.log(err);
// TODO 表格异常放到solt的empty
} finally {
setLoading(false);