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