Zlpt_Portal/src/store/user.ts

188 lines
7.3 KiB
TypeScript
Raw Normal View History

2024-11-26 09:11:25 +08:00
import { el } from 'element-plus/es/locale'
2023-12-05 17:05:54 +08:00
import { get, post } from 'http/index'
2024-11-26 09:11:25 +08:00
2024-12-09 09:38:06 +08:00
2023-12-04 17:42:11 +08:00
export const useStore = defineStore('myUser', {
state: () => {
return {
currentMenuType: true,
2024-12-02 15:33:53 +08:00
currentMenuItem: 'goodsManagement',
2023-12-04 17:42:11 +08:00
menuList: [
{ title: '基础信息', name: 'baseInfo' },
{ title: '订单管理', name: 'orderManagement' },
2023-12-09 21:53:41 +08:00
{ title: '子账号管理', name: 'subAccount' },
{ title: '业务开通', name: 'business' },
{ title: '寻源需求', name: 'sourcingNeed' },
2023-12-05 17:05:54 +08:00
],
provinceList: [], // 省份信息
marketList: [], // 市级信息
areaList: [], // 区级信息
idTypeList: [], // 证件类型
companyTypeList: [],//企业类型
2023-12-06 09:38:11 +08:00
companyLtdList: [],//企业所属
deviceTypeList: [], // 设备类型大类
deviceTypeSonList: [], // 设备类型子类
deviceTypeSunList: [], // 设备类型小类
2024-11-27 15:16:53 +08:00
leaseAndLesseeList: [],
leaseAndLesseeUserList: [
2024-12-02 14:06:16 +08:00
{ title: '装备管理', name: 'goodsManagement' },
2024-12-01 16:21:35 +08:00
{ title: '订单管理', name: 'orderManagementCz' },
2024-12-02 14:06:16 +08:00
{ title: '接单管理', name: 'accept-orders' },
2024-11-29 09:27:46 +08:00
// { title: '机手管理', name: 'operatorManagement' },
// { title: '寻源竞价', name: 'sourcingBidding' },
// { title: '专区管理', name: 'zoneManag' },
2024-11-27 15:16:53 +08:00
],
2024-11-27 18:22:35 +08:00
isType: 1,
leaseUserList: [
{ title: '订单管理', name: 'orderManagementCz' },
2024-12-02 14:06:16 +08:00
{ title: '装备管理', name: 'goodsManagement' },
{ title: '接单管理', name: 'accept-orders' },
2024-11-28 17:41:16 +08:00
// { title: '商品上下架', name: 'goodsUpdown' },
// { title: '机手管理', name: 'operatorManagement' },
// { title: '寻源竞价', name: 'sourcingBidding' },
// { title: '专区管理', name: 'zoneManag' },
2024-11-27 18:22:35 +08:00
],
lesseeUserList: [
{ title: '寻源需求', name: 'sourcingNeed' },
{ title: '订单管理', name: 'orderManagement' },
2024-12-09 09:38:06 +08:00
],
companyList: [],
goodsClassList: []
2023-12-04 17:42:11 +08:00
}
},
getters: {
},
actions: {
updateText() {
console.log('updateText')
},
editCurrentMenuType(val: any) {
this.currentMenuType = val
},
editcurrentMenuItem(val: any) {
this.currentMenuItem = val
},
editcurrentMenuList(val: any) {
this.menuList = val
},
2023-12-05 17:05:54 +08:00
// 获取省份信息
async getprovinceList() {
2023-12-08 20:30:52 +08:00
const res: any = await post('/zlpt-system/baseAddress/selectAddress', {})
2023-12-05 17:05:54 +08:00
this.provinceList = res.data
},
// 获取市级信息
async getmarketList(val: any) {
2023-12-08 20:30:52 +08:00
const res: any = await post('/zlpt-system/baseAddress/selectAddress', { code: val })
2023-12-05 17:05:54 +08:00
console.log(res, '市区信息');
this.marketList = res.data
},
// 获取区级信息
async getareaList(val: any) {
2023-12-08 20:30:52 +08:00
const res: any = await post('/zlpt-system/baseAddress/selectAddress', { code: val })
2023-12-05 17:05:54 +08:00
this.areaList = res.data
},
// 获取证件类型
async getIdTypeList() {
2023-12-08 12:09:54 +08:00
const res: any = await post('/zlpt-company/company_type/selectIdCard', {})
2023-12-05 17:05:54 +08:00
console.log(res, '证件类型');
this.idTypeList = res.rows
},
// 获取企业类型
async getcompanyTypeList() {
2023-12-08 12:09:54 +08:00
const res: any = await post('/zlpt-company/company_type/selectCompanyTypeList', {})
2023-12-05 17:05:54 +08:00
console.log(res, '企业类型');
this.companyTypeList = res.rows
},
// 获取企业所属
async getcompanyLtdList() {
2023-12-08 12:09:54 +08:00
const res: any = await post('/zlpt-company/company_type/selectCompanyLtd', {})
2023-12-05 17:05:54 +08:00
console.log(res, '企业所属');
this.companyLtdList = res.rows
2023-12-06 09:38:11 +08:00
},
// 获取设备类型大类
async getDeviceTypeList() {
2023-12-08 12:09:54 +08:00
const res: any = await post('/zlpt-equip/type/list', {})
2023-12-06 09:38:11 +08:00
this.deviceTypeList = res.rows
console.log(res, '设备类型大类**---***');
},
// 获取设备类型小类
async getDeviceTypeSonList(val: any) {
2023-12-08 12:09:54 +08:00
const res: any = await post('/zlpt-equip/type/list', { typeId: val })
2023-12-06 09:38:11 +08:00
this.deviceTypeSonList = res.rows
console.log(res, '设备类型子类**---***');
},
// 获取设备类型大类
async getDeviceTypeSunList(val: any) {
2023-12-08 12:09:54 +08:00
const res: any = await post('/zlpt-equip/type/list', { typeId: val })
2023-12-06 09:38:11 +08:00
this.deviceTypeSunList = res.rows
console.log(res, '设备类型小类**---***');
},
2024-11-26 09:11:25 +08:00
// 修改承租方 出租方菜单
editMenuList(type: number) {
let baseList: any = [
{ name: '首页', routerName: 'home' },
{ name: '装备共享大厅', routerName: 'equipList' },
{ name: '租赁需求大厅', routerName: 'parity' },
{ name: '装备管理', routerName: '/home' },
{ name: '订单管理', routerName: '/home' },
2024-12-26 13:57:12 +08:00
{ name: '通知', routerName: 'enterpriseZone' },
2024-11-26 09:11:25 +08:00
]
if (type == 1) {
this.leaseAndLesseeList = baseList
2024-11-27 18:22:35 +08:00
this.isType = 1
2024-11-26 09:11:25 +08:00
} else {
this.leaseAndLesseeList = baseList
this.leaseAndLesseeList.splice(3, 1)
2024-11-27 18:22:35 +08:00
this.isType = 2
2024-11-26 09:11:25 +08:00
}
2024-11-27 15:16:53 +08:00
},
editUserMenuList(type: number) {
const leaseList: any = [
{ title: '订单管理', name: 'orderManagementCz' },
2024-11-29 13:30:02 +08:00
{ title: '装备管理', name: 'goodsManagement' },
2024-12-02 14:06:16 +08:00
{ title: '接单管理', name: 'accept-orders' },
2024-11-29 09:27:46 +08:00
// { title: '机手管理', name: 'operatorManagement' },
// { title: '寻源竞价', name: 'sourcingBidding' },
// { title: '专区管理', name: 'zoneManag' },
2024-11-27 15:16:53 +08:00
]
const lesseeList: any = [
2024-11-29 13:30:02 +08:00
{ title: '需求管理', name: 'sourcingNeed' },
2024-11-27 15:16:53 +08:00
{ title: '订单管理', name: 'orderManagement' },
]
this.leaseAndLesseeUserList = []
if (type == 1) {
this.leaseAndLesseeUserList = leaseList
} else {
this.leaseAndLesseeUserList = lesseeList
}
2024-12-09 09:38:06 +08:00
},
setCompanyList(list: any) {
this.companyList = list
},
setGoodsClassList(list: any) {
this.goodsClassList = list
},
2023-12-04 17:42:11 +08:00
},
persist: {
enabled: true, // 开启数据缓存
strategies: [
{
// 自定义存储的 key默认是 store.$id
key: 'myUser',
2024-11-27 18:22:35 +08:00
storage: localStorage, //缓存模式 可选 localStorage sessionStorage
2023-12-04 17:42:11 +08:00
// state 中的字段名,按组打包储存
2024-12-09 09:38:06 +08:00
paths: ['currentMenuType', 'currentMenuItem', 'menuList', 'leaseAndLesseeList', 'isType', 'companyList', 'goodsClassList'] //需要缓存的字段 与 state中相关联
2023-12-04 17:42:11 +08:00
}
]
}
})