| | |
| | | <el-menu-item v-for="itm in item.children" :key="itm.id" :index="itm.path">{{ itm.title }}</el-menu-item> |
| | | </el-submenu> |
| | | </el-menu> |
| | | <!-- <el-empty v-if="!this.menus" description="没有侧栏菜单"></el-empty> --> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getMenuTreeByRole } from "@/api/menus/index" |
| | | import { mapMutations } from "vuex" |
| | | export default { |
| | | name: "AppSidebar", |
| | | props: {}, |
| | | data() { |
| | | return { |
| | | menus: [] |
| | | menus: this.$store.state.menus |
| | | } |
| | | }, |
| | | watch: {}, |
| | | created() { |
| | | this.initNavMenu() |
| | | this.getMenuTreeByRole() |
| | | }, |
| | | computed: { |
| | | // ...mapState(['menus']), |
| | | }, |
| | | methods: { |
| | | ...mapMutations(["setMenus"]), |
| | | getMenuTreeByRole() { |
| | | getMenuTreeByRole().then((res) => { |
| | | res.data.list.map((item) => { |
| | | if (item.systemType === 3) { |
| | | this.menus = item.menus |
| | | } |
| | | }) |
| | | }) |
| | | }, |
| | | // 监听路由 |
| | | initNavMenu() { |
| | | // console.log(this.$route.name) |
| | |
| | | import warehouseManageRouter from "./warehouseManage/index.js" // 仓库管理 |
| | | import reportRouter from "./report/index.js" // 报表 |
| | | import {getMenuTreeByRole} from "@/api/menus/index" |
| | | import store from '@/store/index.js'; |
| | | |
| | | Vue.use(Router) |
| | | const login = (resolve) => require(["@/views/other/login/index"], resolve) |
| | |
| | | }; |
| | | const foundObject = res.data.list.find(obj => obj.systemType === 3); |
| | | if (foundObject) { |
| | | // 存储进vuex |
| | | store.commit('setMenus', foundObject.menus); |
| | | foundObject.menus.forEach(item => { |
| | | const nextPath = item.children.find(obj => obj.path === routePath); |
| | | if (nextPath) { |
| | |
| | | from: item.fromLocation.name, |
| | | to: item.toLocation.name, |
| | | productName: product.name, |
| | | amount: product.amount, |
| | | amount: item.details[0].amount, |
| | | unit: product.unit |
| | | } |
| | | }) |