Files
fini-ui/src/stores/ipo.ts
T
2023-06-16 16:02:24 +08:00

73 lines
1.8 KiB
TypeScript

import { defineStore } from 'pinia'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import en from 'element-plus/dist/locale/en.mjs'
import zhTw from 'element-plus/dist/locale/zh-tw.mjs'
import request from "@/utils/request";
enum Api {
selectUrl="/api/ipo/refdata/searchAndFilter",
}
export const ipoStore = defineStore({
id: 'app',
state: () => ({
//1代表英文 2代表繁体中文 3代表简体中文
locale:1,
homeDay:new Date(),
mobileActiveShow:1,
mainExpand:-1,
filterObj:{}, //把过滤条件放在这里
keyWord:"",
selectedArr:{},
ipoIds:[] as any
}),
getters: {
localeLang(state) {
return [en,zhTw,zhCn][state.locale-1];
},
},
actions: {
//更改语言的方法
setLocale(data: number) {
this.locale = data
},
setHomeDay(day:string|Date){
this.homeDay=day as Date;
},
setMobileActiveShow(num:number){
this.mobileActiveShow=num;
},
setMainExpand(num:number){
this.mainExpand=num;
},
setFilterObje(obj:any){
this.filterObj=obj;
},
// reqSearchList(keyworld:string){
// }
setSelectedArr(data:any){
this.selectedArr=data;
},
setKeyWord(keyWord:string){
this.keyWord=keyWord;
},
getSearchSelectList(){
const keyWord=this.keyWord;
const selectedArr=this.selectedArr;
return request.post<any, null>(Api.selectUrl,{keyWord,...selectedArr});
},
setIpoIds(ipoId:string|number){
const arr=this.$state.ipoIds;
const hasId= arr.some((i:any)=>i==ipoId);
const index=arr.findIndex((i:any)=>i==ipoId);
hasId&&arr.splice(index,1)
!hasId&&arr.push(ipoId)
},
isExpand(ipoId:string|number){
return this.$state.ipoIds.some((i:any)=>i==ipoId);
}
},
})