Skip to content

Commit

Permalink
feat: RePureTableBar组件搭配pure-admin-table支持表头国际化切换
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxian521 committed Mar 26, 2024
1 parent bc1da0b commit 52103ab
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/components/RePureTableBar/src/bar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Sortable from "sortablejs";
import { transformI18n } from "@/plugins/i18n";
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
import { defineComponent, ref, computed, type PropType, nextTick } from "vue";
import {
Expand All @@ -8,7 +10,6 @@ import {
getKeyList
} from "@pureadmin/utils";

import Sortable from "sortablejs";
import DragIcon from "./svg/drag.svg?component";
import ExpandIcon from "./svg/expand.svg?component";
import RefreshIcon from "./svg/refresh.svg?component";
Expand Down Expand Up @@ -118,14 +119,17 @@ export default defineComponent({
}

function handleCheckedColumnsChange(value: string[]) {
checkedColumns.value = value;
const checkedCount = value.length;
checkAll.value = checkedCount === checkColumnList.length;
isIndeterminate.value =
checkedCount > 0 && checkedCount < checkColumnList.length;
}

function handleCheckColumnListChange(val: boolean, label: string) {
dynamicColumns.value.filter(item => item.label === label)[0].hide = !val;
dynamicColumns.value.filter(
item => transformI18n(item.label) === transformI18n(label)
)[0].hide = !val;
}

async function onReset() {
Expand Down Expand Up @@ -198,7 +202,9 @@ export default defineComponent({
};

const isFixedColumn = (label: string) => {
return dynamicColumns.value.filter(item => item.label === label)[0].fixed
return dynamicColumns.value.filter(
item => transformI18n(item.label) === transformI18n(label)
)[0].fixed
? true
: false;
};
Expand Down Expand Up @@ -293,15 +299,15 @@ export default defineComponent({
<div class="pt-[6px] pl-[11px]">
<el-scrollbar max-height="36vh">
<el-checkbox-group
v-model={checkedColumns.value}
modelValue={checkedColumns.value}
onChange={value => handleCheckedColumnsChange(value)}
>
<el-space
direction="vertical"
alignment="flex-start"
size={0}
>
{checkColumnList.map(item => {
{checkColumnList.map((item, index) => {
return (
<div class="flex items-center">
<DragIcon
Expand All @@ -316,17 +322,18 @@ export default defineComponent({
}) => rowDrop(event)}
/>
<el-checkbox
key={item}
key={index}
label={item}
value={item}
onChange={value =>
handleCheckColumnListChange(value, item)
}
>
<span
title={item}
title={transformI18n(item)}
class="inline-block w-[120px] truncate hover:text-text_color_primary"
>
{item}
{transformI18n(item)}
</span>
</el-checkbox>
</div>
Expand Down

1 comment on commit 52103ab

@xiaoxian521
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用例如下:

image

Please sign in to comment.