feat: 国际化管理添加按钮级权限管理
This commit is contained in:
@@ -31,6 +31,18 @@ export const deleteLocaleAPI = (id: string) => {
|
||||
return http.request<null>("post", `/api/i18n/deleteLocale/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* 批量删除语言类型
|
||||
*/
|
||||
export const deleteLocaleListAPI = (ids: string[]) => {
|
||||
return http.request<null>("post", `/api/i18n/deleteLocaleList`, {
|
||||
data: {
|
||||
ids
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改语言类型
|
||||
*/
|
||||
@@ -138,6 +150,18 @@ export const getI18nInfoAPI = (id: string) => {
|
||||
export const deleteI18nAPI = (id: string) => {
|
||||
return http.request<null>("post", `/api/i18n/deleteI18n/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* 批量删除翻译
|
||||
*/
|
||||
export const deleteI18nListAPI = (ids: string[]) => {
|
||||
return http.request<null>("post", `/api/i18n/deleteI18nList`, {
|
||||
data: {
|
||||
ids
|
||||
}
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 修改翻译
|
||||
* @param data
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
<PureTableBar title="国际化管理" :columns="columns" @refresh="onSearch">
|
||||
<template #buttons>
|
||||
<el-button
|
||||
v-if="hasAuth('i18n:btn:add')"
|
||||
type="primary"
|
||||
:icon="useRenderIcon(AddFill)"
|
||||
@click="openDialog('新增')"
|
||||
@@ -78,9 +79,18 @@
|
||||
{{ t("buttons:Deselect") }}
|
||||
</el-button>
|
||||
</div>
|
||||
<el-popconfirm title="是否确认删除?">
|
||||
<el-popconfirm
|
||||
v-if="hasAuth('i18n:btn:delete')"
|
||||
title="是否确认删除?"
|
||||
@confirm="onbatchDel"
|
||||
>
|
||||
<template #reference>
|
||||
<el-button type="danger" text class="mr-1">
|
||||
<el-button
|
||||
type="danger"
|
||||
text
|
||||
class="mr-1"
|
||||
:disabled="selectedNum < 0 || !hasAuth('i18n:btn:delete')"
|
||||
>
|
||||
{{ t("buttons:DeleteInBatches") }}
|
||||
</el-button>
|
||||
</template>
|
||||
@@ -115,6 +125,7 @@
|
||||
link
|
||||
type="primary"
|
||||
:size="size"
|
||||
:disabled="!hasAuth('i18n:btn:update')"
|
||||
:icon="useRenderIcon(EditPen)"
|
||||
@click="openDialog('修改', row)"
|
||||
>
|
||||
@@ -130,6 +141,7 @@
|
||||
link
|
||||
type="danger"
|
||||
:size="size"
|
||||
:disabled="!hasAuth('i18n:btn:delete')"
|
||||
:icon="useRenderIcon(Delete)"
|
||||
>
|
||||
{{ t("buttons:Delete") }}
|
||||
@@ -148,7 +160,7 @@ defineOptions({
|
||||
name: "I18nIndex"
|
||||
});
|
||||
import { ref } from "vue";
|
||||
import { useI18n } from "./hook";
|
||||
import { useI18n } from "./utils/hook";
|
||||
import { useI18n as i18n } from "vue-i18n";
|
||||
import { PureTableBar } from "@/components/RePureTableBar";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
@@ -156,6 +168,7 @@ import Delete from "@iconify-icons/ep/delete";
|
||||
import EditPen from "@iconify-icons/ep/edit-pen";
|
||||
import Refresh from "@iconify-icons/ep/refresh";
|
||||
import AddFill from "@iconify-icons/ri/add-circle-line";
|
||||
import { hasAuth } from "@/utils/auth";
|
||||
const { t } = i18n();
|
||||
/**
|
||||
* 表格Ref
|
||||
@@ -177,7 +190,8 @@ const {
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
handleSelectionChange,
|
||||
onSelectionCancel
|
||||
onSelectionCancel,
|
||||
onbatchDel
|
||||
} = useI18n(tableRef);
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import dayjs from "dayjs";
|
||||
import editForm from "./components/form.vue";
|
||||
import editForm from "../components/form.vue";
|
||||
import { message } from "@/utils/message";
|
||||
import { type Ref, ref, reactive, onMounted, h } from "vue";
|
||||
import type { LanguageInfo, TranslationInfo } from "types/system";
|
||||
@@ -7,11 +7,13 @@ import type { PaginationProps } from "@pureadmin/table";
|
||||
import { addDialog } from "@/components/ReDialog";
|
||||
import {
|
||||
deleteI18nAPI,
|
||||
deleteI18nListAPI,
|
||||
getI18nListAPI,
|
||||
getLocaleListAPI,
|
||||
postAddI18nAPI,
|
||||
putUpdateI18nAPI
|
||||
} from "@/api/i18n";
|
||||
import { getKeyList } from "@pureadmin/utils";
|
||||
|
||||
export const useI18n = (tableRef: Ref) => {
|
||||
/**
|
||||
@@ -188,6 +190,23 @@ export const useI18n = (tableRef: Ref) => {
|
||||
// 用于多选表格,清空用户的选择
|
||||
tableRef.value.getTableRef().clearSelection();
|
||||
};
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
const onbatchDel = async () => {
|
||||
// 返回当前选中的行
|
||||
const curSelected = tableRef.value.getTableRef().getSelectionRows();
|
||||
const res = await deleteI18nListAPI(getKeyList(curSelected, "id"));
|
||||
if (res.success) {
|
||||
message(res.msg, {
|
||||
type: "success"
|
||||
});
|
||||
tableRef.value.getTableRef().clearSelection();
|
||||
onSearch();
|
||||
} else {
|
||||
message(res.msg, { type: "error", duration: 5000 });
|
||||
}
|
||||
};
|
||||
|
||||
const openDialog = async (title = "新增", row?: TranslationInfo) => {
|
||||
addDialog({
|
||||
@@ -283,6 +302,7 @@ export const useI18n = (tableRef: Ref) => {
|
||||
handleCurrentChange,
|
||||
handleSelectionChange,
|
||||
onSelectionCancel,
|
||||
onbatchDel,
|
||||
getLocaleList
|
||||
};
|
||||
};
|
||||
@@ -39,6 +39,7 @@
|
||||
<PureTableBar title="语言类型管理" :columns="columns" @refresh="onSearch">
|
||||
<template #buttons>
|
||||
<el-button
|
||||
v-if="hasAuth('locale:btn:add')"
|
||||
type="primary"
|
||||
:icon="useRenderIcon(AddFill)"
|
||||
@click="openDialog('新增')"
|
||||
@@ -63,9 +64,18 @@
|
||||
{{ t("buttons:Deselect") }}
|
||||
</el-button>
|
||||
</div>
|
||||
<el-popconfirm title="是否确认删除?">
|
||||
<el-popconfirm
|
||||
v-if="hasAuth('locale:btn:delete')"
|
||||
title="是否确认删除?"
|
||||
@confirm="onbatchDel"
|
||||
>
|
||||
<template #reference>
|
||||
<el-button type="danger" text class="mr-1">
|
||||
<el-button
|
||||
type="danger"
|
||||
:disabled="!selectedNum || !hasAuth('locale:btn:delete')"
|
||||
text
|
||||
class="mr-1"
|
||||
>
|
||||
{{ t("buttons:DeleteInBatches") }}</el-button
|
||||
>
|
||||
</template>
|
||||
@@ -101,6 +111,7 @@
|
||||
type="primary"
|
||||
:size="size"
|
||||
:icon="useRenderIcon(EditPen)"
|
||||
:disabled="!hasAuth('locale:btn:update')"
|
||||
@click="openDialog('修改', row)"
|
||||
>
|
||||
{{ t("buttons:Update") }}
|
||||
@@ -115,6 +126,7 @@
|
||||
link
|
||||
type="primary"
|
||||
:size="size"
|
||||
:disabled="!hasAuth('i18n:btn:infoList')"
|
||||
:icon="useRenderIcon(Download)"
|
||||
>
|
||||
{{ t("buttons:Export") }}
|
||||
@@ -131,6 +143,7 @@
|
||||
link
|
||||
type="danger"
|
||||
:size="size"
|
||||
:disabled="!hasAuth('locale:btn:delete')"
|
||||
:icon="useRenderIcon(Delete)"
|
||||
>
|
||||
{{ t("buttons:Delete") }}
|
||||
@@ -149,7 +162,7 @@ defineOptions({
|
||||
name: "LocaleIndex"
|
||||
});
|
||||
import { ref } from "vue";
|
||||
import { useLocale } from "./hook";
|
||||
import { useLocale } from "./utils/hook";
|
||||
import { PureTableBar } from "@/components/RePureTableBar";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
import { useI18n } from "vue-i18n";
|
||||
@@ -159,6 +172,7 @@ import Refresh from "@iconify-icons/ep/refresh";
|
||||
import AddFill from "@iconify-icons/ri/add-circle-line";
|
||||
import Download from "@iconify-icons/ri/file-download-line";
|
||||
const { t } = useI18n();
|
||||
import { hasAuth } from "@/utils/auth";
|
||||
/**
|
||||
* 表格Ref
|
||||
*/
|
||||
@@ -179,7 +193,8 @@ const {
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
handleSelectionChange,
|
||||
onSelectionCancel
|
||||
onSelectionCancel,
|
||||
onbatchDel
|
||||
} = useLocale(tableRef);
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import dayjs from "dayjs";
|
||||
import editForm from "./components/form.vue";
|
||||
import editForm from "../components/form.vue";
|
||||
import { message } from "@/utils/message";
|
||||
import { type Ref, ref, reactive, onMounted, h } from "vue";
|
||||
import type { LanguageInfo, TranslationInfo } from "types/system";
|
||||
@@ -8,12 +8,14 @@ import { addDialog } from "@/components/ReDialog";
|
||||
import {
|
||||
getLocaleListAPI,
|
||||
deleteLocaleAPI,
|
||||
deleteLocaleListAPI,
|
||||
postAddLocaleAPI,
|
||||
putUpdateLocaleAPI,
|
||||
getI18nHandleListAPI
|
||||
} from "@/api/i18n";
|
||||
|
||||
import jsyaml from "js-yaml";
|
||||
import { getKeyList } from "@pureadmin/utils";
|
||||
|
||||
export const useLocale = (tableRef: Ref) => {
|
||||
/**
|
||||
@@ -179,6 +181,24 @@ export const useLocale = (tableRef: Ref) => {
|
||||
tableRef.value.getTableRef().clearSelection();
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
const onbatchDel = async () => {
|
||||
// 返回当前选中的行
|
||||
const curSelected = tableRef.value.getTableRef().getSelectionRows();
|
||||
const res = await deleteLocaleListAPI(getKeyList(curSelected, "id"));
|
||||
if (res.success) {
|
||||
message(res.msg, {
|
||||
type: "success"
|
||||
});
|
||||
tableRef.value.getTableRef().clearSelection();
|
||||
onSearch();
|
||||
} else {
|
||||
message(res.msg, { type: "error", duration: 5000 });
|
||||
}
|
||||
};
|
||||
|
||||
const openDialog = async (title = "新增", row?: LanguageInfo) => {
|
||||
addDialog({
|
||||
title: `${title}国际化项`,
|
||||
@@ -277,6 +297,7 @@ export const useLocale = (tableRef: Ref) => {
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
handleSelectionChange,
|
||||
onSelectionCancel
|
||||
onSelectionCancel,
|
||||
onbatchDel
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user