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

6

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