代码优化
This commit is contained in:
parent
68e431eb43
commit
6792becdbb
|
|
@ -9,8 +9,6 @@ declare module 'vue' {
|
|||
export interface GlobalComponents {
|
||||
Breadcrumb: typeof import('./src/components/Breadcrumb/index.vue')['default']
|
||||
ElBadge: typeof import('element-plus/es')['ElBadge']
|
||||
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
|
||||
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
ElCarousel: typeof import('element-plus/es')['ElCarousel']
|
||||
ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem']
|
||||
|
|
@ -18,31 +16,21 @@ declare module 'vue' {
|
|||
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||
ElCol: typeof import('element-plus/es')['ElCol']
|
||||
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
|
||||
ElCountdown: typeof import('element-plus/es')['ElCountdown']
|
||||
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
|
||||
ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||
ElEmpty: typeof import('element-plus/es')['ElEmpty']
|
||||
ElForm: typeof import('element-plus/es')['ElForm']
|
||||
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
||||
ElHeader: typeof import('element-plus/es')['ElHeader']
|
||||
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||
ElImage: typeof import('element-plus/es')['ElImage']
|
||||
ElImg: typeof import('element-plus/es')['ElImg']
|
||||
ElInput: typeof import('element-plus/es')['ElInput']
|
||||
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
|
||||
ElMenu: typeof import('element-plus/es')['ElMenu']
|
||||
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
|
||||
ElOption: typeof import('element-plus/es')['ElOption']
|
||||
ElPageHeader: typeof import('element-plus/es')['ElPageHeader']
|
||||
ElPagination: typeof import('element-plus/es')['ElPagination']
|
||||
ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']
|
||||
ElProgress: typeof import('element-plus/es')['ElProgress']
|
||||
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
|
||||
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
||||
ElRow: typeof import('element-plus/es')['ElRow']
|
||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
ElStep: typeof import('element-plus/es')['ElStep']
|
||||
ElSteps: typeof import('element-plus/es')['ElSteps']
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||
ElTag: typeof import('element-plus/es')['ElTag']
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ VITE_API_URL = '/proxyApi'
|
|||
|
||||
# VITE_proxyTarget = 'http://192.168.2.246:28080' # 马帅
|
||||
# VITE_proxyTarget = 'http://192.168.2.127:28080' # 梁超
|
||||
VITE_proxyTarget = 'http://36.33.26.201:17788/proxyApi' # 测试服务
|
||||
# VITE_proxyTarget = 'http://192.168.0.244:28580' # 测试服务
|
||||
# VITE_proxyTarget = 'http://36.33.26.201:17788/proxyApi' # 测试服务
|
||||
VITE_proxyTarget = 'http://192.168.0.244:28580' # 测试服务
|
||||
# VITE_proxyTarget = 'http://192.168.2.129:18080' # 马帅j
|
||||
|
||||
# VITE_proxyTarget = 'http://10.40.92.185:9206' # 赵福海 ( 设备类型)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { mainStore } from 'store/main'
|
|||
import { useStore } from 'store/user'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import headerLogo from 'assets/img/zulinlogo.png'
|
||||
import userClass from '../../hooks/userClass'
|
||||
const { getCompanyList } = userClass()
|
||||
const store: any = mainStore()
|
||||
const userStore = useStore()
|
||||
userStore.editMenuList(1)
|
||||
|
|
@ -12,6 +14,7 @@ const route = useRoute()
|
|||
const router = useRouter()
|
||||
const isRolesSelect = ref<boolean>(false)
|
||||
const rolesName = ref<any>('1')
|
||||
const activeLoginCompanyName = ref('')
|
||||
|
||||
rolesName.value = localStorage.getItem('rolesType') || 1
|
||||
|
||||
|
|
@ -20,6 +23,16 @@ const isShowLogout = computed(() => {
|
|||
return store.token
|
||||
})
|
||||
|
||||
if (userStore.companyList.length === 0) {
|
||||
getCompanyList()
|
||||
} else {
|
||||
const companyList = userStore.companyList
|
||||
const activeCompany: any = companyList.filter(
|
||||
(e: any) => e.companyId == store.userInfo.companyId,
|
||||
)
|
||||
activeLoginCompanyName.value = activeCompany[0].companyName
|
||||
}
|
||||
|
||||
const placeholderText = ref('搜索设备关键词')
|
||||
|
||||
// 退出登录
|
||||
|
|
@ -159,7 +172,9 @@ const isMyInfoPage = () => {
|
|||
/>
|
||||
<div class="header-item" v-if="isShowLogout">
|
||||
<!-- <img src="../assets/img/home/star.png" alt="" /> -->
|
||||
<a class="user-name">{{ store.userInfo.nickName }}</a>
|
||||
<a class="user-name"
|
||||
>{{ activeLoginCompanyName }} / {{ store.userInfo.nickName }}</a
|
||||
>
|
||||
</div>
|
||||
<div class="header-item">
|
||||
<a v-if="!isShowLogout" class="a-border-none" @click="$router.push('/login')"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
import { getCompanyListApi, getGoodsClassListApi } from 'http/api/home/index'
|
||||
import { useStore } from 'store/user'
|
||||
const store = useStore()
|
||||
|
||||
export default function () {
|
||||
const getCompanyList = async () => {
|
||||
const { data: res }: any = await getCompanyListApi()
|
||||
store.setCompanyList(res)
|
||||
}
|
||||
|
||||
const getGoodsClassList = async () => {
|
||||
const { data: res }: any = await getGoodsClassListApi()
|
||||
store.setGoodsClassList(res)
|
||||
}
|
||||
return {
|
||||
getCompanyList,
|
||||
getGoodsClassList
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5,6 +5,8 @@ import { useStore } from 'store/user'
|
|||
import { cartStore } from 'store/cart'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getHotSearchListApi, getBookCarDetailsApi } from 'http/api/home/index'
|
||||
import userClass from '../hooks/userClass'
|
||||
const { getCompanyList } = userClass()
|
||||
import imgSrc from '@/assets/img/logo.png'
|
||||
const store: any = mainStore()
|
||||
const userStore = useStore()
|
||||
|
|
@ -18,7 +20,8 @@ const rolesName = ref<any>('1')
|
|||
rolesName.value = localStorage.getItem('rolesType')
|
||||
const isAdmin = ref(false)
|
||||
const roles = store.userInfo.roles
|
||||
if (roles.length > 0) {
|
||||
const activeLoginCompanyName = ref('')
|
||||
if (roles?.length > 0) {
|
||||
isAdmin.value = roles.some((e: any) => e.roleKey == 'admin')
|
||||
}
|
||||
|
||||
|
|
@ -27,6 +30,17 @@ const isShowLogout = computed(() => {
|
|||
return store.token
|
||||
})
|
||||
|
||||
if (userStore.companyList.length === 0) {
|
||||
getCompanyList()
|
||||
} else {
|
||||
const companyList = userStore.companyList
|
||||
const activeCompany: any = companyList.filter(
|
||||
(e: any) => e.companyId == store.userInfo.companyId,
|
||||
)
|
||||
activeLoginCompanyName.value = activeCompany[0].companyName
|
||||
console.log(activeCompany, '用户信息')
|
||||
}
|
||||
|
||||
const placeholderText = ref('搜索设备关键词')
|
||||
|
||||
// 退出登录
|
||||
|
|
@ -163,7 +177,7 @@ const onCarts = () => {
|
|||
|
||||
const onJumpUser = () => {
|
||||
const roles = store.userInfo.roles
|
||||
if (roles.length > 0) {
|
||||
if (roles?.length > 0) {
|
||||
const isAdmin = roles.some((e: any) => e.roleKey == 'admin')
|
||||
if (isAdmin) {
|
||||
window.location.replace(`http://192.168.0.244:17788?token=${store.token}`)
|
||||
|
|
@ -181,7 +195,9 @@ const onJumpUser = () => {
|
|||
<div class="header-box wapper">
|
||||
<div class="header-item" v-if="isShowLogout">
|
||||
<!-- <img src="../assets/img/home/star.png" alt="" /> -->
|
||||
<a class="user-name">{{ store.userInfo.nickName }}</a>
|
||||
<a class="user-name"
|
||||
>{{ activeLoginCompanyName }} / {{ store.userInfo.nickName }}</a
|
||||
>
|
||||
<div class="line"></div>
|
||||
</div>
|
||||
<div class="header-item">
|
||||
|
|
|
|||
|
|
@ -651,7 +651,6 @@ const router = createRouter({
|
|||
routes
|
||||
})
|
||||
|
||||
console.log(router, '*****路由')
|
||||
|
||||
// 使页面跳转后滚动条恢复至顶部
|
||||
router.beforeEach((to, from, next) => {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { el } from 'element-plus/es/locale'
|
|||
import { get, post } from 'http/index'
|
||||
|
||||
|
||||
|
||||
export const useStore = defineStore('myUser', {
|
||||
state: () => {
|
||||
return {
|
||||
|
|
@ -45,7 +46,9 @@ export const useStore = defineStore('myUser', {
|
|||
lesseeUserList: [
|
||||
{ title: '寻源需求', name: 'sourcingNeed' },
|
||||
{ title: '订单管理', name: 'orderManagement' },
|
||||
]
|
||||
],
|
||||
companyList: [],
|
||||
goodsClassList: []
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
|
|
@ -161,7 +164,13 @@ export const useStore = defineStore('myUser', {
|
|||
} else {
|
||||
this.leaseAndLesseeUserList = lesseeList
|
||||
}
|
||||
}
|
||||
},
|
||||
setCompanyList(list: any) {
|
||||
this.companyList = list
|
||||
},
|
||||
setGoodsClassList(list: any) {
|
||||
this.goodsClassList = list
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
enabled: true, // 开启数据缓存
|
||||
|
|
@ -171,7 +180,7 @@ export const useStore = defineStore('myUser', {
|
|||
key: 'myUser',
|
||||
storage: localStorage, //缓存模式 可选 localStorage sessionStorage
|
||||
// state 中的字段名,按组打包储存
|
||||
paths: ['currentMenuType', 'currentMenuItem', 'menuList', 'leaseAndLesseeList', 'isType'] //需要缓存的字段 与 state中相关联
|
||||
paths: ['currentMenuType', 'currentMenuItem', 'menuList', 'leaseAndLesseeList', 'isType', 'companyList', 'goodsClassList'] //需要缓存的字段 与 state中相关联
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
<script setup lang="ts">
|
||||
import { loginApi, getUserInfoAPI } from 'http/api/login/index'
|
||||
import { getCompanyListApi } from 'http/api/home/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { User, Lock } from '@element-plus/icons-vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { mainStore } from 'store/main'
|
||||
import { useStore } from 'store/user'
|
||||
|
||||
const userStore = mainStore()
|
||||
const store = useStore()
|
||||
const router = useRouter()
|
||||
|
|
@ -30,15 +32,14 @@ const handlerLogin = async () => {
|
|||
if (res.code === 200) {
|
||||
userStore.setToken(res.data.access_token)
|
||||
const result: any = await getUserInfoAPI()
|
||||
console.log(result, '用户信息')
|
||||
ElMessage({
|
||||
showClose: true,
|
||||
message: '登录成功',
|
||||
type: 'success',
|
||||
})
|
||||
|
||||
// 获取公司
|
||||
userStore.setUserInfo(result.user)
|
||||
|
||||
if (rememberPassword.value) {
|
||||
localStorage.setItem('username', loginForm.value.username)
|
||||
localStorage.setItem('password', loginForm.value.password)
|
||||
|
|
|
|||
|
|
@ -3,17 +3,20 @@ import EquipCard from 'components/equipCard.vue'
|
|||
import EquipCardNew from 'components/equipCardNew/index.vue'
|
||||
import NavMenu from 'components/Navmenu/index.vue'
|
||||
import { getGoodsClassListApi, getCompanyListApi } from 'http/api/home'
|
||||
import { useStore } from 'store/user'
|
||||
import { mainStore } from 'store/main'
|
||||
import { getHotList } from 'http/api/equip'
|
||||
import { reactive, ref } from 'vue'
|
||||
import baseData from '@/assets/baseInformation.json'
|
||||
import userClass from '../../hooks/userClass'
|
||||
|
||||
import imgSrc from '../../assets/img/home/nw.png'
|
||||
import swiper_1 from '../../assets/img/home/swiper01.png'
|
||||
import swiper_2 from '../../assets/img/home/swiper02.png'
|
||||
import swiper_4 from '../../assets/img/home/swiper04.png'
|
||||
|
||||
const { getCompanyList, getGoodsClassList } = userClass()
|
||||
const router: any = useRouter()
|
||||
const userStore = useStore()
|
||||
const store: any = mainStore()
|
||||
|
||||
// const leftNavList: any = ref([])
|
||||
const companyList: any = ref([])
|
||||
|
|
@ -31,24 +34,37 @@ const loopList = ref([
|
|||
swiper_4,
|
||||
])
|
||||
// 获取商品分类
|
||||
const getGoodsClassList = async () => {
|
||||
const res: any = await getGoodsClassListApi()
|
||||
console.log(res, '商品分类列表')
|
||||
// const getGoodsClassList = async () => {
|
||||
// const res: any = await getGoodsClassListApi()
|
||||
// console.log(res, '商品分类列表')
|
||||
|
||||
// leftNavList.value = res.rows
|
||||
classList.value = res.data
|
||||
// // leftNavList.value = res.rows
|
||||
// classList.value = res.data
|
||||
// }
|
||||
|
||||
// getGoodsClassList()
|
||||
|
||||
if (userStore.companyList.length === 0) {
|
||||
getCompanyList()
|
||||
companyList.value = userStore.companyList
|
||||
} else {
|
||||
companyList.value = userStore.companyList
|
||||
}
|
||||
if (userStore.goodsClassList.length === 0) {
|
||||
getGoodsClassList()
|
||||
classList.value = userStore.goodsClassList
|
||||
} else {
|
||||
classList.value = userStore.goodsClassList
|
||||
}
|
||||
|
||||
getGoodsClassList()
|
||||
// // 获取公司名称
|
||||
// const getCompanyListData = async () => {
|
||||
// const res: any = await getCompanyListApi()
|
||||
// companyList.value = res.data
|
||||
// console.log('res公司名称', res)
|
||||
// }
|
||||
|
||||
// 获取公司名称
|
||||
const getCompanyListData = async () => {
|
||||
const res: any = await getCompanyListApi()
|
||||
companyList.value = res.data
|
||||
console.log('res公司名称', res)
|
||||
}
|
||||
|
||||
getCompanyListData()
|
||||
// getCompanyListData()
|
||||
|
||||
// 点击跳转装备共享大厅
|
||||
const onSharedHall = (level: number, typeId: any, name: any) => {
|
||||
|
|
@ -86,25 +102,19 @@ const handlerGoodsDetails = (...arg: any) => {
|
|||
})
|
||||
}
|
||||
|
||||
const goInformation = (id) => {
|
||||
router.push({
|
||||
path: `/consultationDetails/${id}`,
|
||||
})
|
||||
}
|
||||
|
||||
const detailsList = ref([])
|
||||
|
||||
const handelInformation = () => {
|
||||
detailsList.value = baseData.map((item) => {
|
||||
return {
|
||||
v_title: item.title,
|
||||
v_content_info: '',
|
||||
v_time: `[${item.create_time}]`,
|
||||
id: item.id,
|
||||
}
|
||||
})
|
||||
}
|
||||
handelInformation()
|
||||
// const handelInformation = () => {
|
||||
// detailsList.value = baseData.map((item) => {
|
||||
// return {
|
||||
// v_title: item.title,
|
||||
// v_content_info: '',
|
||||
// v_time: `[${item.create_time}]`,
|
||||
// id: item.id,
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// handelInformation()
|
||||
|
||||
const hotDeviceList: any = ref([])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue