mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-07 17:07:19 +08:00
perf: dict perfect
This commit is contained in:
parent
105409a278
commit
c10e38cdf2
@ -49,12 +49,15 @@ import { useMapGetters } from "../store";
|
|||||||
import { useRouter, useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { useStore } from "vuex";
|
import { useStore } from "vuex";
|
||||||
import { storageSession } from "/@/utils/storage";
|
import { storageSession } from "/@/utils/storage";
|
||||||
import { useI18n } from "vue-i18n";
|
|
||||||
import ch from "/@/assets/ch.png";
|
import ch from "/@/assets/ch.png";
|
||||||
import en from "/@/assets/en.png";
|
import en from "/@/assets/en.png";
|
||||||
import favicon from "/favicon.ico";
|
import favicon from "/favicon.ico";
|
||||||
import { emitter } from "/@/utils/mitt";
|
import { emitter } from "/@/utils/mitt";
|
||||||
import { deviceDetection } from "/@/utils/deviceDetection";
|
import { deviceDetection } from "/@/utils/deviceDetection";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { locale as eleplusLocale } from "element-plus";
|
||||||
|
import enLocale from "element-plus/lib/locale/lang/en";
|
||||||
|
import zhLocale from "element-plus/lib/locale/lang/zh-cn";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "Navbar",
|
name: "Navbar",
|
||||||
@ -77,7 +80,13 @@ export default defineComponent({
|
|||||||
// 国际化语言切换
|
// 国际化语言切换
|
||||||
const toggleLang = (): void => {
|
const toggleLang = (): void => {
|
||||||
langs.value = !langs.value;
|
langs.value = !langs.value;
|
||||||
langs.value ? (locale.value = "zh") : (locale.value = "en");
|
if (langs.value) {
|
||||||
|
locale.value = "zh";
|
||||||
|
eleplusLocale(zhLocale);
|
||||||
|
} else {
|
||||||
|
locale.value = "en";
|
||||||
|
eleplusLocale(enLocale);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@ -121,7 +130,9 @@ export default defineComponent({
|
|||||||
en,
|
en,
|
||||||
favicon,
|
favicon,
|
||||||
onPanel,
|
onPanel,
|
||||||
deviceDetection
|
deviceDetection,
|
||||||
|
locale,
|
||||||
|
t
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -26,6 +26,8 @@ import {
|
|||||||
ElPopover,
|
ElPopover,
|
||||||
ElPopper,
|
ElPopper,
|
||||||
ElTooltip,
|
ElTooltip,
|
||||||
|
ElDrawer,
|
||||||
|
ElPagination,
|
||||||
} from "element-plus";
|
} from "element-plus";
|
||||||
|
|
||||||
const components = [
|
const components = [
|
||||||
@ -54,6 +56,8 @@ const components = [
|
|||||||
ElPopover,
|
ElPopover,
|
||||||
ElPopper,
|
ElPopper,
|
||||||
ElTooltip,
|
ElTooltip,
|
||||||
|
ElDrawer,
|
||||||
|
ElPagination,
|
||||||
];
|
];
|
||||||
|
|
||||||
const plugins = [ElLoading];
|
const plugins = [ElLoading];
|
||||||
|
@ -3,6 +3,12 @@
|
|||||||
import zhVxeTable from "vxe-table/lib/locale/lang/zh-CN";
|
import zhVxeTable from "vxe-table/lib/locale/lang/zh-CN";
|
||||||
import enVxeTable from "vxe-table/lib/locale/lang/en-US";
|
import enVxeTable from "vxe-table/lib/locale/lang/en-US";
|
||||||
|
|
||||||
|
// element-plus国际化
|
||||||
|
import { locale } from "element-plus";
|
||||||
|
import enLocale from "element-plus/lib/locale/lang/en";
|
||||||
|
import zhLocale from "element-plus/lib/locale/lang/zh-cn";
|
||||||
|
locale(zhLocale);
|
||||||
|
|
||||||
export const menusConfig = {
|
export const menusConfig = {
|
||||||
zh: {
|
zh: {
|
||||||
message: {
|
message: {
|
||||||
@ -106,9 +112,11 @@ export const localesConfigs = {
|
|||||||
zh: {
|
zh: {
|
||||||
message: Object.assign({}, ...localesList.map((v) => v.zh.message)),
|
message: Object.assign({}, ...localesList.map((v) => v.zh.message)),
|
||||||
...zhVxeTable,
|
...zhVxeTable,
|
||||||
|
...zhLocale,
|
||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
message: Object.assign({}, ...localesList.map((v) => v.en.message)),
|
message: Object.assign({}, ...localesList.map((v) => v.en.message)),
|
||||||
...enVxeTable,
|
...enVxeTable,
|
||||||
|
...enLocale,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ import { localesConfigs } from "./config";
|
|||||||
|
|
||||||
export const i18n = createI18n({
|
export const i18n = createI18n({
|
||||||
locale: "zh", // set locale
|
locale: "zh", // set locale
|
||||||
fallbackLocale: "zh", // set fallback locale
|
fallbackLocale: "en", // set fallback locale
|
||||||
messages: localesConfigs,
|
messages: localesConfigs,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ VXETable.setup({
|
|||||||
// 鼠标移到行是否要高亮显示
|
// 鼠标移到行是否要高亮显示
|
||||||
highlightHoverRow: true,
|
highlightHoverRow: true,
|
||||||
},
|
},
|
||||||
|
input: {
|
||||||
|
clearable: true,
|
||||||
|
},
|
||||||
// 对组件内置的提示语进行国际化翻译
|
// 对组件内置的提示语进行国际化翻译
|
||||||
i18n: (key, args) => i18n.global.t(key, args),
|
i18n: (key, args) => i18n.global.t(key, args),
|
||||||
// 可选,对参数中的列头、校验提示..等进行自动翻译(只对支持国际化的有效)
|
// 可选,对参数中的列头、校验提示..等进行自动翻译(只对支持国际化的有效)
|
||||||
@ -66,6 +69,9 @@ VXETable.setup({
|
|||||||
if (key && key.indexOf("message.") > -1) {
|
if (key && key.indexOf("message.") > -1) {
|
||||||
return i18n.global.t(key, args);
|
return i18n.global.t(key, args);
|
||||||
}
|
}
|
||||||
|
if (key && key.indexOf("el.") > -1) {
|
||||||
|
return i18n.global.t(key, args);
|
||||||
|
}
|
||||||
return key;
|
return key;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -233,7 +233,9 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
{
|
{
|
||||||
path: "/system/dict",
|
path: "/system/dict",
|
||||||
component: () =>
|
component: () =>
|
||||||
import(/* webpackChunkName: "system" */ "../views/system/dict.vue"),
|
import(
|
||||||
|
/* webpackChunkName: "system" */ "../views/system/dict/index.vue"
|
||||||
|
),
|
||||||
meta: {
|
meta: {
|
||||||
// icon: '',
|
// icon: '',
|
||||||
title: "message.hsDict",
|
title: "message.hsDict",
|
||||||
|
177
src/views/system/dict/config.vue
Normal file
177
src/views/system/dict/config.vue
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
<template>
|
||||||
|
<div class="config">
|
||||||
|
<el-drawer
|
||||||
|
:model-value="drawer"
|
||||||
|
:title="drawTitle"
|
||||||
|
:direction="direction"
|
||||||
|
:before-close="handleClose"
|
||||||
|
destroy-on-close
|
||||||
|
size="620px"
|
||||||
|
>
|
||||||
|
<el-divider></el-divider>
|
||||||
|
<!-- 列表 -->
|
||||||
|
<div class="list">
|
||||||
|
<vxe-table
|
||||||
|
ref="xTable"
|
||||||
|
border
|
||||||
|
:data="tableData"
|
||||||
|
@checkbox-change="checkboxChangeEvent"
|
||||||
|
@checkbox-all="checkboxChangeEvent"
|
||||||
|
>
|
||||||
|
<vxe-table-column type="checkbox" width="60"></vxe-table-column>
|
||||||
|
<vxe-table-column field="name" title="名称"></vxe-table-column>
|
||||||
|
<vxe-table-column field="dataval" title="数据值"></vxe-table-column>
|
||||||
|
<vxe-table-column title="操作" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<vxe-button type="text" icon="el-icon-edit" @click="editConfig(row)">编辑</vxe-button>
|
||||||
|
<vxe-button type="text" icon="el-icon-delete" @click="delConfig(row)">删除</vxe-button>
|
||||||
|
</template>
|
||||||
|
</vxe-table-column>
|
||||||
|
</vxe-table>
|
||||||
|
<vxe-pager
|
||||||
|
perfect
|
||||||
|
v-model:current-page="tablePage.currentPage"
|
||||||
|
v-model:page-size="tablePage.pageSize"
|
||||||
|
:total="tablePage.total"
|
||||||
|
:layouts="['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
|
||||||
|
>
|
||||||
|
<template #left>
|
||||||
|
<span class="page-left">
|
||||||
|
<vxe-checkbox
|
||||||
|
v-model="isAllChecked"
|
||||||
|
:indeterminate="isIndeterminate"
|
||||||
|
@change="changeAllEvent"
|
||||||
|
></vxe-checkbox>
|
||||||
|
<span class="select-count">已选中{{ selectRecords.length }}条</span>
|
||||||
|
<vxe-button>删除</vxe-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</vxe-pager>
|
||||||
|
</div>
|
||||||
|
</el-drawer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent, reactive, toRefs, ref } from "vue";
|
||||||
|
import { propTypes } from "/@/utils/propTypes";
|
||||||
|
import { VxeTableEvents } from "vxe-table";
|
||||||
|
import { templateRef } from "@vueuse/core";
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
props: {
|
||||||
|
drawer: propTypes.bool.def(false),
|
||||||
|
drawTitle: propTypes.string.def(""),
|
||||||
|
direction: propTypes.string.def("rtl")
|
||||||
|
},
|
||||||
|
emits: ["handleClose"],
|
||||||
|
setup(props, ctx) {
|
||||||
|
const { emit } = ctx;
|
||||||
|
|
||||||
|
const xTable = templateRef<any>("xTable", null);
|
||||||
|
|
||||||
|
const configData = reactive({
|
||||||
|
tableData: [
|
||||||
|
{
|
||||||
|
name: "禁用",
|
||||||
|
dataval: "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "启用",
|
||||||
|
dataval: "1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
isAllChecked: false,
|
||||||
|
isIndeterminate: false,
|
||||||
|
selectRecords: [] as any[],
|
||||||
|
tablePage: {
|
||||||
|
total: 0,
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 10
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 抽屉关闭
|
||||||
|
function handleClose(done) {
|
||||||
|
configData.isAllChecked = false;
|
||||||
|
configData.isIndeterminate = false;
|
||||||
|
emit("handleClose");
|
||||||
|
}
|
||||||
|
|
||||||
|
function editConfig(row) {
|
||||||
|
console.log(
|
||||||
|
"%crow===>>>: ",
|
||||||
|
"color: MidnightBlue; background: Aquamarine; font-size: 20px;",
|
||||||
|
row
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function delConfig(row) {
|
||||||
|
console.log(
|
||||||
|
"%crow===>>>: ",
|
||||||
|
"color: MidnightBlue; background: Aquamarine; font-size: 20px;",
|
||||||
|
row
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeAllEvent = () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log(xTable);
|
||||||
|
}, 1000);
|
||||||
|
const $table = xTable.value;
|
||||||
|
$table.setAllCheckboxRow(configData.isAllChecked);
|
||||||
|
configData.selectRecords = $table.getCheckboxRecords();
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkboxChangeEvent: VxeTableEvents.CheckboxChange = ({
|
||||||
|
records
|
||||||
|
}) => {
|
||||||
|
const $table = xTable.value;
|
||||||
|
configData.isAllChecked = $table.isAllCheckboxChecked();
|
||||||
|
configData.isIndeterminate = $table.isCheckboxIndeterminate();
|
||||||
|
configData.selectRecords = records;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...toRefs(configData),
|
||||||
|
handleClose,
|
||||||
|
editConfig,
|
||||||
|
delConfig,
|
||||||
|
changeAllEvent,
|
||||||
|
checkboxChangeEvent
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.list {
|
||||||
|
padding: 10px;
|
||||||
|
.page-left {
|
||||||
|
position: absolute;
|
||||||
|
left: 10px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
:deep(.select-count) {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
:deep(.el-drawer__header) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
:deep(.el-drawer__header span) {
|
||||||
|
color: rgba(0, 0, 0, 0.85);
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
:deep(.el-divider--horizontal) {
|
||||||
|
margin: 13px 0;
|
||||||
|
}
|
||||||
|
:deep(.el-icon-close) {
|
||||||
|
&:hover {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,13 +1,9 @@
|
|||||||
<template>
|
.<template>
|
||||||
<div class="dict-container">
|
<div class="dict-container">
|
||||||
<!-- 工具栏 -->
|
<!-- 工具栏 -->
|
||||||
<vxe-toolbar>
|
<vxe-toolbar>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<vxe-input
|
<vxe-input v-model="filterName" :placeholder="$t('message.hssearch')" @keyup="searchEvent"></vxe-input>
|
||||||
v-model="dictData.filterName"
|
|
||||||
:placeholder="$t('message.hssearch')"
|
|
||||||
@keyup="searchEvent"
|
|
||||||
></vxe-input>
|
|
||||||
</template>
|
</template>
|
||||||
<template #tools>
|
<template #tools>
|
||||||
<vxe-button
|
<vxe-button
|
||||||
@ -34,13 +30,13 @@
|
|||||||
border
|
border
|
||||||
resizable
|
resizable
|
||||||
:tree-config="{children: 'children', iconOpen: 'fa fa-minus-square-o', iconClose: 'fa fa-plus-square-o'}"
|
:tree-config="{children: 'children', iconOpen: 'fa fa-minus-square-o', iconClose: 'fa fa-plus-square-o'}"
|
||||||
:data="dictData.tableData"
|
:data="tableData"
|
||||||
@cell-dblclick="cellDBLClickEvent"
|
@cell-dblclick="cellDBLClickEvent"
|
||||||
>
|
>
|
||||||
<vxe-table-column tree-node field="name" title="字典名称"></vxe-table-column>
|
<vxe-table-column tree-node field="name" title="字典名称"></vxe-table-column>
|
||||||
<vxe-table-column title="字典类型">
|
<vxe-table-column title="字典类型">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tooltip effect="dark" :content="'双击复制:'+row.model" placement="top-end">
|
<el-tooltip effect="dark" :content="'双击复制:'+row.model" placement="right">
|
||||||
<span class="text-model">{{ row.model }}</span>
|
<span class="text-model">{{ row.model }}</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
@ -49,36 +45,43 @@
|
|||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<vxe-button type="text" icon="el-icon-edit" @click="onEdit(row)">编辑</vxe-button>
|
<vxe-button type="text" icon="el-icon-edit" @click="onEdit(row)">编辑</vxe-button>
|
||||||
<vxe-button type="text" icon="el-icon-circle-plus-outline" @click="onAddChild(row)">新增子类型</vxe-button>
|
<vxe-button type="text" icon="el-icon-circle-plus-outline" @click="onAddChild(row)">新增子类型</vxe-button>
|
||||||
<vxe-button v-show="row.model" type="text" icon="el-icon-setting">字典配置</vxe-button>
|
<vxe-button
|
||||||
|
v-show="row.model"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-setting"
|
||||||
|
@click="onDeploy(row)"
|
||||||
|
>字典配置</vxe-button>
|
||||||
<vxe-button type="text" icon="el-icon-delete" @click="confirmEvent">删除</vxe-button>
|
<vxe-button type="text" icon="el-icon-delete" @click="confirmEvent">删除</vxe-button>
|
||||||
</template>
|
</template>
|
||||||
</vxe-table-column>
|
</vxe-table-column>
|
||||||
</vxe-table>
|
</vxe-table>
|
||||||
|
|
||||||
<!-- 配置弹框 -->
|
<!-- 修改、添加弹框 -->
|
||||||
<vxe-modal
|
<vxe-modal
|
||||||
resize
|
resize
|
||||||
width="450"
|
width="450"
|
||||||
v-model="dictData.showEdit"
|
v-model="showEdit"
|
||||||
:title="dictData.selectRow ? '编辑' : '新增'"
|
:title="selectRow ? '编辑' : '新增'"
|
||||||
:loading="dictData.submitLoading"
|
:loading="submitLoading"
|
||||||
@hide="$refs.xForm.reset();"
|
@hide="$refs.xForm.reset();"
|
||||||
>
|
>
|
||||||
<template #default>
|
<template #default>
|
||||||
<vxe-form
|
<vxe-form
|
||||||
ref="xForm"
|
ref="xForm"
|
||||||
:data="dictData.formData"
|
:data="formData"
|
||||||
:items="dictData.formItems"
|
:items="formItems"
|
||||||
title-align="right"
|
title-align="right"
|
||||||
title-width="100"
|
title-width="100"
|
||||||
@submit="dictData.submitEvent"
|
@submit="submitEvent"
|
||||||
></vxe-form>
|
></vxe-form>
|
||||||
</template>
|
</template>
|
||||||
</vxe-modal>
|
</vxe-modal>
|
||||||
|
|
||||||
|
<Config :drawer="drawer" drawTitle="字典列表" @handleClose="handleClose" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { reactive, ref, unref, nextTick } from "vue";
|
import { reactive, ref, unref, nextTick, toRefs } from "vue";
|
||||||
import XEUtils from "xe-utils";
|
import XEUtils from "xe-utils";
|
||||||
import { cloneDeep } from "lodash-es";
|
import { cloneDeep } from "lodash-es";
|
||||||
import { templateRef } from "@vueuse/core";
|
import { templateRef } from "@vueuse/core";
|
||||||
@ -90,8 +93,12 @@ import {
|
|||||||
VxeTablePropTypes,
|
VxeTablePropTypes,
|
||||||
VxeFormPropTypes
|
VxeFormPropTypes
|
||||||
} from "vxe-table";
|
} from "vxe-table";
|
||||||
|
import Config from "./config.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
Config
|
||||||
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const dictData = reactive({
|
const dictData = reactive({
|
||||||
submitLoading: false,
|
submitLoading: false,
|
||||||
@ -129,7 +136,7 @@ export default {
|
|||||||
span: 24,
|
span: 24,
|
||||||
itemRender: {
|
itemRender: {
|
||||||
name: "$input",
|
name: "$input",
|
||||||
props: { placeholder: "请输入字典名称", clearable: true }
|
props: { placeholder: "请输入字典名称" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -141,8 +148,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
placeholder: "请输入字典类型",
|
placeholder: "请输入字典类型",
|
||||||
//这里vxe-table文档并没有提到,可以配置所选组件的所有属性,比如这里可以配置关于vxe-input的所有属性
|
//这里vxe-table文档并没有提到,可以配置所选组件的所有属性,比如这里可以配置关于vxe-input的所有属性
|
||||||
disabled: true,
|
disabled: true
|
||||||
clearable: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -270,8 +276,18 @@ export default {
|
|||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let drawer = ref(false);
|
||||||
|
|
||||||
|
function onDeploy(row: any) {
|
||||||
|
drawer.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClose() {
|
||||||
|
drawer.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dictData,
|
...toRefs(dictData),
|
||||||
formatDate,
|
formatDate,
|
||||||
searchEvent,
|
searchEvent,
|
||||||
confirmEvent,
|
confirmEvent,
|
||||||
@ -279,7 +295,10 @@ export default {
|
|||||||
submitEvent,
|
submitEvent,
|
||||||
onEdit,
|
onEdit,
|
||||||
onAddChild,
|
onAddChild,
|
||||||
onAdd
|
onAdd,
|
||||||
|
onDeploy,
|
||||||
|
drawer,
|
||||||
|
handleClose
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user