2024-09-29 16:52:09 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { onMounted, ref } from 'vue';
|
|
|
|
import { userI18nStore } from '@/store/i18n/i18n';
|
2024-09-29 23:47:08 +08:00
|
|
|
import { onAdd, onDelete, onSearch, onUpdate } from '@/views/i18n/i18n-setting/utils/hook';
|
2024-09-29 16:52:09 +08:00
|
|
|
import { useRenderIcon } from '@/components/ReIcon/src/hooks';
|
|
|
|
import AddFill from '@iconify-icons/ri/add-circle-line';
|
|
|
|
import EditPen from '@iconify-icons/ep/edit-pen';
|
|
|
|
import Delete from '@iconify-icons/ep/delete';
|
|
|
|
import PureTableBar from '@/components/TableBar/src/bar';
|
|
|
|
import PureTable from '@pureadmin/table';
|
|
|
|
import { columns } from '@/views/i18n/i18n-setting/utils/columns';
|
2024-09-29 23:47:08 +08:00
|
|
|
import Refresh from '@iconify-icons/ep/refresh';
|
|
|
|
import { resetForm } from '@/views/menu/utils/hook';
|
2024-09-29 16:52:09 +08:00
|
|
|
|
|
|
|
const tableRef = ref();
|
2024-09-29 23:47:08 +08:00
|
|
|
const formRef = ref();
|
2024-09-29 16:52:09 +08:00
|
|
|
const i18nStore = userI18nStore();
|
|
|
|
|
2024-09-29 23:47:08 +08:00
|
|
|
/**
|
|
|
|
* 重置表单
|
|
|
|
* @param formEl
|
|
|
|
*/
|
|
|
|
const resetForm = async formEl => {
|
|
|
|
if (!formEl) return;
|
|
|
|
formEl.resetFields();
|
|
|
|
await onSearch();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* * 当前页改变时
|
|
|
|
*/
|
|
|
|
const onCurrentPageChange = async (value: number) => {
|
|
|
|
i18nStore.pagination.currentPage = value;
|
|
|
|
await onSearch();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* * 当分页发生变化
|
|
|
|
* @param value
|
|
|
|
*/
|
|
|
|
const onPageSizeChange = async (value: number) => {
|
|
|
|
i18nStore.pagination.pageSize = value;
|
|
|
|
await onSearch();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* * 选择框点击的行
|
|
|
|
* @param row
|
|
|
|
*/
|
|
|
|
const onSelectionChange = (row: any) => {
|
|
|
|
ids.value = row.map((item: any) => item.id);
|
|
|
|
};
|
|
|
|
|
2024-09-29 16:52:09 +08:00
|
|
|
onMounted(() => {
|
2024-09-29 23:47:08 +08:00
|
|
|
onSearch();
|
2024-09-29 16:52:09 +08:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="main">
|
2024-09-29 23:47:08 +08:00
|
|
|
<el-form ref="formRef" :inline="true" :model="i18nStore.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
|
|
|
|
<el-form-item label="多语言key" prop="keyName">
|
|
|
|
<el-input v-model="i18nStore.form.keyName" class="!w-[180px]" clearable placeholder="输入多语言key" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="多语言翻译" prop="translation">
|
|
|
|
<el-input v-model="i18nStore.form.translation" class="!w-[180px]" clearable placeholder="输入多语言翻译" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-button :icon="useRenderIcon('ri:search-line')" :loading="i18nStore.loading" type="primary" @click="onSearch"> 搜索 </el-button>
|
|
|
|
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)"> 重置</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
2024-09-29 16:52:09 +08:00
|
|
|
|
2024-09-29 23:47:08 +08:00
|
|
|
<PureTableBar :columns="columns" :tableRef="tableRef?.getTableRef()" title="多语言管理" @fullscreen="tableRef.setAdaptive()" @refresh="onSearch">
|
2024-09-29 16:52:09 +08:00
|
|
|
<template #buttons>
|
2024-09-29 23:47:08 +08:00
|
|
|
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> 添加多语言</el-button>
|
2024-09-29 16:52:09 +08:00
|
|
|
</template>
|
|
|
|
<template v-slot="{ size, dynamicColumns }">
|
|
|
|
<pure-table
|
|
|
|
ref="tableRef"
|
|
|
|
:adaptiveConfig="{ offsetBottom: 45 }"
|
|
|
|
:columns="dynamicColumns"
|
2024-09-29 23:47:08 +08:00
|
|
|
:data="i18nStore.datalist"
|
2024-09-29 16:52:09 +08:00
|
|
|
:header-cell-style="{ background: 'var(--el-fill-color-light)', color: 'var(--el-text-color-primary)' }"
|
|
|
|
:loading="i18nStore.loading"
|
2024-09-29 23:47:08 +08:00
|
|
|
:pagination="i18nStore.pagination"
|
2024-09-29 16:52:09 +08:00
|
|
|
:size="size"
|
|
|
|
adaptive
|
|
|
|
align-whole="center"
|
|
|
|
row-key="id"
|
|
|
|
showOverflowTooltip
|
|
|
|
table-layout="auto"
|
2024-09-29 23:47:08 +08:00
|
|
|
@selection-change="onSelectionChange"
|
|
|
|
@page-size-change="onPageSizeChange"
|
|
|
|
@page-current-change="onCurrentPageChange"
|
2024-09-29 16:52:09 +08:00
|
|
|
>
|
|
|
|
<template #operation="{ row }">
|
2024-09-29 23:47:08 +08:00
|
|
|
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary" @click="onUpdate(row)"> 修改 </el-button>
|
2024-09-29 16:52:09 +08:00
|
|
|
<el-button v-show="row.menuType !== 3" :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary"> 新增 </el-button>
|
2024-09-29 23:47:08 +08:00
|
|
|
<el-popconfirm :title="`是否确认删除 ${row.translation}数据`" @confirm="onDelete(row)">
|
2024-09-29 16:52:09 +08:00
|
|
|
<template #reference>
|
|
|
|
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary"> 删除 </el-button>
|
|
|
|
</template>
|
|
|
|
</el-popconfirm>
|
|
|
|
</template>
|
|
|
|
</pure-table>
|
|
|
|
</template>
|
|
|
|
</PureTableBar>
|
|
|
|
</div>
|
|
|
|
</template>
|