|
|
@ -2,7 +2,11 @@
|
|
|
|
<el-breadcrumb class="app-breadcrumb" separator="/">
|
|
|
|
<el-breadcrumb class="app-breadcrumb" separator="/">
|
|
|
|
<transition-group name="breadcrumb">
|
|
|
|
<transition-group name="breadcrumb">
|
|
|
|
<el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path">
|
|
|
|
<el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path">
|
|
|
|
<span v-if="item.redirect === 'noRedirect' || index == levelList.length - 1" class="no-redirect">{{ item.meta.title }}</span>
|
|
|
|
<span
|
|
|
|
|
|
|
|
v-if="item.redirect === 'noRedirect' || index == levelList.length - 1"
|
|
|
|
|
|
|
|
class="no-redirect"
|
|
|
|
|
|
|
|
>{{ item.meta.title }}</span
|
|
|
|
|
|
|
|
>
|
|
|
|
<a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
|
|
|
|
<a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
|
|
|
|
</el-breadcrumb-item>
|
|
|
|
</el-breadcrumb-item>
|
|
|
|
</transition-group>
|
|
|
|
</transition-group>
|
|
|
@ -10,80 +14,173 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
<script setup>
|
|
|
|
import usePermissionStore from '@/store/modules/permission'
|
|
|
|
import usePermissionStore from "@/store/modules/permission";
|
|
|
|
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
const route = useRoute();
|
|
|
|
const router = useRouter()
|
|
|
|
const router = useRouter();
|
|
|
|
const permissionStore = usePermissionStore()
|
|
|
|
const permissionStore = usePermissionStore();
|
|
|
|
const levelList = ref([])
|
|
|
|
const levelList = ref([]);
|
|
|
|
|
|
|
|
|
|
|
|
function getBreadcrumb() {
|
|
|
|
function getBreadcrumb() {
|
|
|
|
// only show routes with meta.title
|
|
|
|
// only show routes with meta.title
|
|
|
|
let matched = []
|
|
|
|
// 当前全部侧边栏
|
|
|
|
const pathNum = findPathNum(route.path)
|
|
|
|
let sidebarRouters = permissionStore.sidebarRouters;
|
|
|
|
// multi-level menu
|
|
|
|
let matched = route.matched.filter((item) => item.meta && item.meta.title);
|
|
|
|
if (pathNum > 2) {
|
|
|
|
if (matched[0].path == "/assetsAuth") {
|
|
|
|
const reg = /\/\w+/gi
|
|
|
|
// 管理端--资产管理--新增资产
|
|
|
|
const pathList = route.path.match(reg).map((item, index) => {
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
if (index !== 0) item = item.slice(1)
|
|
|
|
(item) => item.path == "/assetsManage"
|
|
|
|
return item
|
|
|
|
);
|
|
|
|
})
|
|
|
|
const childrenRoute = activeRoute[0].children;
|
|
|
|
getMatched(pathList, permissionStore.defaultRoutes, matched)
|
|
|
|
levelList.value = [
|
|
|
|
|
|
|
|
activeRoute[0],
|
|
|
|
|
|
|
|
childrenRoute[Number(matched[0].meta.type)],
|
|
|
|
|
|
|
|
matched[0],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
} else if (
|
|
|
|
|
|
|
|
matched[0].path == "/taskInfo" ||
|
|
|
|
|
|
|
|
matched[0].path == "/taskAudit"
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
// 管理端--任务管理--任务审核/任务详情
|
|
|
|
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "/" && item.children[0].path == "task"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
levelList.value = [activeRoute[0].children[0], matched[0]];
|
|
|
|
|
|
|
|
} else if (
|
|
|
|
|
|
|
|
matched[0].path == "/mytaskInfo" ||
|
|
|
|
|
|
|
|
matched[0].path == "/mytaskAudit"
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
// 单位端--我的任务--资产核查/任务详情
|
|
|
|
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "/" && item.children[0].path == "myTask"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
levelList.value = [activeRoute[0].children[0], matched[0]];
|
|
|
|
|
|
|
|
} else if (matched[0].path == "/myAssetsAuth") {
|
|
|
|
|
|
|
|
// 单位端--我的资产--资产详情
|
|
|
|
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "/myAssets"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
const childrenRoute = activeRoute[0].children;
|
|
|
|
|
|
|
|
levelList.value = [
|
|
|
|
|
|
|
|
activeRoute[0],
|
|
|
|
|
|
|
|
childrenRoute[Number(matched[0].meta.type)],
|
|
|
|
|
|
|
|
matched[0],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
} else if (matched[0].path == "/taskAuditInfo") {
|
|
|
|
|
|
|
|
// 管理端--任务管理--任务审核--资产审核
|
|
|
|
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "/" && item.children[0].path == "task"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
const route = sidebarRouters.filter((item) => item.path == "");
|
|
|
|
|
|
|
|
const twoActiveRoute = route[0].children.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "taskInfo"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
levelList.value = [
|
|
|
|
|
|
|
|
activeRoute[0].children[0],
|
|
|
|
|
|
|
|
twoActiveRoute[0],
|
|
|
|
|
|
|
|
matched[0],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
} else if (matched[0].path == "/taskAuditInfolishichakan") {
|
|
|
|
|
|
|
|
// 管理端--任务管理--任务审核--任务管理历史详情
|
|
|
|
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "/" && item.children[0].path == "task"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
const route = sidebarRouters.filter((item) => item.path == "");
|
|
|
|
|
|
|
|
const twoActiveRoute = route[0].children.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "taskInfo"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
levelList.value = [
|
|
|
|
|
|
|
|
activeRoute[0].children[0],
|
|
|
|
|
|
|
|
twoActiveRoute[0],
|
|
|
|
|
|
|
|
matched[0],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
} else if (matched[0].path == "/mytaskAuditInfo") {
|
|
|
|
|
|
|
|
// 单位端--我的任务--资产核查--资产审核详情
|
|
|
|
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "/" && item.children[0].path == "myTask"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
const route = sidebarRouters.filter((item) => item.path == "");
|
|
|
|
|
|
|
|
const twoActiveRoute = route[0].children.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "mytaskInfo"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
levelList.value = [
|
|
|
|
|
|
|
|
activeRoute[0].children[0],
|
|
|
|
|
|
|
|
twoActiveRoute[0],
|
|
|
|
|
|
|
|
matched[0],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
} else if (matched[0].path == "/unitAuth") {
|
|
|
|
|
|
|
|
// 管理端--单位管理--新增单位/修改单位/查看单位
|
|
|
|
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "/" && item.children[0].path == "unit"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
levelList.value = [activeRoute[0].children[0], matched[0]];
|
|
|
|
|
|
|
|
} else if (matched[0].path == "/assetsAuthRecord") {
|
|
|
|
|
|
|
|
// 单位端--资产填报记录--查看详情/修改资产
|
|
|
|
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "/" && item.children[0].path == "assetRecord"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
levelList.value = [activeRoute[0].children[0], matched[0]];
|
|
|
|
|
|
|
|
} else if (matched[0].path == "/unitAssetsAuth") {
|
|
|
|
|
|
|
|
// 管理端--单位自主填报--查看详情/审核资产
|
|
|
|
|
|
|
|
const activeRoute = sidebarRouters.filter(
|
|
|
|
|
|
|
|
(item) => item.path == "/" && item.children[0].path == "unitFill"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
levelList.value = [activeRoute[0].children[0], matched[0]];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
matched = route.matched.filter((item) => item.meta && item.meta.title)
|
|
|
|
levelList.value = matched.filter(
|
|
|
|
|
|
|
|
(item) => item.meta && item.meta.title && item.meta.breadcrumb !== false
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 判断是否为首页
|
|
|
|
};
|
|
|
|
if (!isDashboard(matched[0])) {
|
|
|
|
|
|
|
|
matched = [{ path: "/index", meta: { title: "首页" } }].concat(matched)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
levelList.value = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function findPathNum(str, char = "/") {
|
|
|
|
function findPathNum(str, char = "/") {
|
|
|
|
let index = str.indexOf(char)
|
|
|
|
let index = str.indexOf(char);
|
|
|
|
let num = 0
|
|
|
|
let num = 0;
|
|
|
|
while (index !== -1) {
|
|
|
|
while (index !== -1) {
|
|
|
|
num++
|
|
|
|
num++;
|
|
|
|
index = str.indexOf(char, index + 1)
|
|
|
|
index = str.indexOf(char, index + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return num
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getMatched(pathList, routeList, matched) {
|
|
|
|
function getMatched(pathList, routeList, matched) {
|
|
|
|
let data = routeList.find(item => item.path == pathList[0] || (item.name += '').toLowerCase() == pathList[0])
|
|
|
|
let data = routeList.find(
|
|
|
|
|
|
|
|
(item) =>
|
|
|
|
|
|
|
|
item.path == pathList[0] || (item.name += "").toLowerCase() == pathList[0]
|
|
|
|
|
|
|
|
);
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
matched.push(data)
|
|
|
|
matched.push(data);
|
|
|
|
if (data.children && pathList.length) {
|
|
|
|
if (data.children && pathList.length) {
|
|
|
|
pathList.shift()
|
|
|
|
pathList.shift();
|
|
|
|
getMatched(pathList, data.children, matched)
|
|
|
|
getMatched(pathList, data.children, matched);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function isDashboard(route) {
|
|
|
|
function isDashboard(route) {
|
|
|
|
const name = route && route.name
|
|
|
|
const name = route && route.name;
|
|
|
|
if (!name) {
|
|
|
|
if (!name) {
|
|
|
|
return false
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return name.trim() === 'Index'
|
|
|
|
return name.trim() === "Index";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function handleLink(item) {
|
|
|
|
function handleLink(item) {
|
|
|
|
const { redirect, path } = item
|
|
|
|
const { redirect, path } = item;
|
|
|
|
if (redirect) {
|
|
|
|
if (redirect) {
|
|
|
|
router.push(redirect)
|
|
|
|
router.push(redirect);
|
|
|
|
return
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
router.push(path)
|
|
|
|
router.push(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
watchEffect(() => {
|
|
|
|
// if you go to the redirect page, do not update the breadcrumbs
|
|
|
|
// if you go to the redirect page, do not update the breadcrumbs
|
|
|
|
if (route.path.startsWith('/redirect/')) {
|
|
|
|
if (route.path.startsWith("/redirect/")) {
|
|
|
|
return
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getBreadcrumb()
|
|
|
|
getBreadcrumb();
|
|
|
|
})
|
|
|
|
});
|
|
|
|
getBreadcrumb()
|
|
|
|
getBreadcrumb();
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang='scss' scoped>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.app-breadcrumb.el-breadcrumb {
|
|
|
|
.app-breadcrumb.el-breadcrumb {
|
|
|
|
display: inline-block;
|
|
|
|
display: inline-block;
|
|
|
|
font-size: 14px;
|
|
|
|
font-size: 14px;
|
|
|
@ -95,4 +192,4 @@ getBreadcrumb()
|
|
|
|
cursor: text;
|
|
|
|
cursor: text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|