Commit 5402f91a authored by zs嵩's avatar zs嵩

6

parent 0eeea998
<template>
<div v-if="!item.hidden">
<template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
<template v-if="hasOneShowingChild(item.children, item) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow">
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
<item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="$l(onlyOneChild.meta, 'title')" :badge="badge" />
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }">
<item :icon="onlyOneChild.meta.icon || (item.meta && item.meta.icon)" :title="$l(onlyOneChild.meta, 'title')" :badge="badge" />
</el-menu-item>
</app-link>
</template>
......@@ -12,27 +12,20 @@
<template slot="title">
<item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="$l(item.meta, 'title')" :badge="badge" />
</template>
<sidebar-item
v-for="child in item.children"
:key="child.path"
:is-nest="true"
:item="child"
:base-path="resolvePath(child.path)"
class="nest-menu"
/>
<sidebar-item v-for="(child, index) in item.children" :key="index" :is-nest="true" :item="child" :base-path="resolvePath(child.path)" class="nest-menu" />
</el-submenu>
</div>
</template>
<script>
import path from 'path'
import { isExternal } from '@/utils/validate'
import Item from './Item'
import AppLink from './Link'
import FixiOSBug from './FixiOSBug'
import path from "path"
import { isExternal } from "@/utils/validate"
import Item from "./Item"
import AppLink from "./Link"
import FixiOSBug from "./FixiOSBug"
export default {
name: 'SidebarItem',
name: "SidebarItem",
components: { Item, AppLink },
mixins: [FixiOSBug],
props: {
......@@ -47,24 +40,24 @@ export default {
},
basePath: {
type: String,
default: ''
default: ""
}
},
data() {
this.onlyOneChild = null
return {}
},
computed:{
badge(){
computed: {
badge() {
return this.$store.getters.badgeData[this.item.meta?.badgeField]
}
},
methods: {
hasOneShowingChild(children = [], parent) {
if (!children) {
children = [];
children = []
}
const showingChildren = children.filter(item => {
const showingChildren = children.filter((item) => {
if (item.hidden) {
return false
} else {
......@@ -81,7 +74,7 @@ export default {
// Show parent if there are no child router to display
if (showingChildren.length === 0) {
this.onlyOneChild = { ... parent, path: '', noShowingChildren: true }
this.onlyOneChild = { ...parent, path: "", noShowingChildren: true }
return true
}
......
......@@ -1021,8 +1021,8 @@ export default {
return true
}
})
let typeIds = this.form.products.map(item=>item.typeId)
if(new Set(typeIds).size !== typeIds.length) {
let typeIds = this.form.products.map((item) => item.typeId)
if (new Set(typeIds).size !== typeIds.length) {
callback(new Error(this.$t("主营类别不能重复")))
return
}
......@@ -1321,6 +1321,9 @@ export default {
competitorIds: Number(response.data.competitorIds),
productTypes: this.stringArrToNumberArr(response.data.productTypes)
}
if (!this.form.products) {
this.form.products = []
}
if (!this.form.products.length) {
this.form.products.push({ typeId: undefined, productIds: [], productList: [] })
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment