middleground_code_v2/src/views/masterDataOptions/settingMenu.vue

232 lines
5.4 KiB
Vue

<template>
<div class="settingMenu">
<div class="menu">
<div class="appInfo">
<div class="img" v-loading="imgLoading">
<template v-if="imgUrl">
<img :src="imgUrl" alt="" style="width: 64px; height: 64px"/>
</template>
<template v-if="!imgUrl">
<img src="./images/icon.png" alt="" style="width: 64px; height: 64px"/>
</template>
</div>
<div class="appName">{{ name }}</div>
</div>
<div class="menuList">
<div class="item" v-for="(item, index) in settingMunu" :key="index" @click="menuClick(index, item)">
<div class="icon" :class="{ actived: index == menuActived }">
<svg-icon class="iconfont" :icon-class="item.icon" fill="currentColor"/>
</div>
<div class="title">{{ item.title }}</div>
</div>
</div>
</div>
<div class="content">
<router-view ref="routerChunk" :build="billid" @saveSuccess="saveSuccess" @saveSuccessInit="saveSuccessInit"
@flashActive="flashActive"
></router-view>
</div>
</div>
</template>
<script>
import { getApiModuleApi } from '@/api/apiChunks/index.js'
import configData from './configData'
// 应用信息
import masterDataAdd from './masterDataAdd.vue'
import request from '@/utils/request'
export default {
data() {
return {
menuActived: 0,
settingMunu: configData.settingMenu,
query: this.$route.query,
name: '',
imgUrl: '',
versionNumber: '',
imgLoading: false,
billid: ''
}
},
methods: {
//当新增完基本信息后
saveSuccessInit(res, fun) {
console.log(res, 'res')
this.billid = res.attribute.id
this.$refs.routerChunk.billid = this.billid
this.initEditFormData()
fun()
},
flashActive(val) {
this.menuActived = val
},
async initEditFormData() {
const res = await getApiModuleApi({
tl: 'mdmModuleService',
as: '',
dj: 'getMdm'
}, { id: this.billid })
if (res.status === '200') {
this.name = res.attribute.mdmName
//下载logo
this.imgLoading = true
return request({
url: '/kangarooDataCenterV3/entranceController/fileDownloadNew?id=' + res.attribute.mdmLogo,
method: 'get',
responseType: 'arraybuffer'
}).then((res) => {
this.imgLoading = false
if (!res.byteLength) {
this.imgUrl = false
return
}
this.imgUrl =
'data:image/png/jpg;base64,' + btoa(new Uint8Array(res).reduce((data, byte) => data + String.fromCharCode(byte), ''))
})
}
},
//菜单点击事件
saveSuccess() {
this.initEditFormData()
},
menuClick(index, item) {
console.log(index, item)
if (index !== 0 && !this.billid) {
this.$vmNews('当前为新增请先新增后再跳转该模块')
return
}
if (item.path && !this.$route.path.includes(item.path)) {
this.menuActived = index
this.$set(this.query, 'id', this.billid)
this.$router.replace({
name: item.path,
query: this.query
})
}
}
},
components: {
masterDataAdd
},
mounted() {
if (this.$route.query.flag !== 'new') {
this.billid = this.$route.query.id
this.initEditFormData()
}
}
}
</script>
<style scoped lang="scss">
.settingMenu {
width: 100%;
display: flex;
position: relative;
background: #fafafa !important;
overflow: auto;
.menu {
position: fixed;
width: 11%;
height: 90vh;
//margin-right: 1%;
background-color: #fff;
border-radius: 16px;
overflow: auto;
.appInfo {
padding: 16px 0;
border-bottom: 1px solid #f3f3f3;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
> .img {
width: 64px;
height: 64px;
}
.appName {
margin-top: 8px;
font-weight: 600;
font-size: 18px;
}
> .version {
margin-top: 1px;
font-size: 12px;
padding: 1px 2px;
border: 1px solid #ff8b0f;
color: #ff8b0f;
}
}
.menuList {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.item {
margin-bottom: 24px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
> .icon {
width: 64px;
height: 64px;
text-align: center;
border-radius: 12px;
display: flex;
justify-content: center;
align-items: center;
> .iconfont {
font-weight: 300;
font-size: 37px;
color: #000;
}
&:hover {
background-color: #1478f6 !important;
> .iconfont {
color: #fff !important;
}
}
}
> .title {
margin-top: 11px;
color: #333333;
font-size: 18px;
font-weight: 600;
user-select: none;
}
}
.actived {
background-color: #1478f6 !important;
> .iconfont {
color: #fff !important;
}
}
}
}
.content {
margin-left: 11.5%;
width: 88%;
border-radius: 16px;
}
}
</style>