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