/*
|
* @Description: 页面查询Store
|
* @Author: Ben Lin
|
* @version:
|
* @Date: 2024-06-18 15:09:47
|
* @LastEditors: Ben Lin
|
* @LastEditTime: 2024-10-23 22:52:45
|
*/
|
import { defineStore } from 'pinia';
|
import { store } from '@/store';
|
import { isNullOrEmpty } from '/@/utils/is';
|
import { useUserStore } from './user';
|
|
interface QueryState {
|
curSearchInfo: any[];
|
curPageName: string;
|
curCPInfo: any[];
|
}
|
|
export const useQueryStore = defineStore({
|
id: 'app-query',
|
state: (): QueryState => ({
|
curSearchInfo: [],
|
curPageName: '',
|
curCPInfo: [],
|
}),
|
getters: {
|
getCurSearchInfo(state): any[] {
|
return state.curSearchInfo;
|
},
|
getCurPageName(state): string {
|
return state.curPageName;
|
},
|
getCurCPInfo(state): any[] {
|
return state.curCPInfo;
|
},
|
},
|
actions: {
|
setCurSearchInfo(val: any) {
|
if (!isNullOrEmpty(val)) {
|
if (!this.curSearchInfo.some((q) => q.name == val.name)) {
|
this.curSearchInfo.push(val);
|
} else {
|
this.curSearchInfo.map((item) => {
|
if (item.name == val.name) {
|
item.searchInfo = val.searchInfo;
|
item.ByOrg = isNullOrEmpty(val.ByOrg) ? false : val.ByOrg;
|
item.searchInfo.option = !item.ByOrg
|
? ''
|
: {
|
//根据据点查询,必需带这个参数
|
UserId: useUserStore().getUserInfo.userId,
|
ByOrg: true,
|
CurOrg: useUserStore().getUserInfo.orgCode,
|
};
|
}
|
});
|
}
|
}
|
},
|
setCurCPInfo(val: any) {
|
if (!isNullOrEmpty(val)) {
|
if (!this.curCPInfo.some((q) => q.name == val.name)) {
|
this.curCPInfo.push(val);
|
} else {
|
this.curCPInfo.map((item) => {
|
if (item.name == val.name) {
|
item.treeInfo = val.treeInfo;
|
item.navInfo = val.navInfo;
|
item.config = val.config;
|
}
|
});
|
}
|
}
|
},
|
setCurPageName(val: string) {
|
this.curPageName = val;
|
},
|
resetState() {
|
this.curSearchInfo = [];
|
this.curPageName = '';
|
this.curCPInfo = [];
|
},
|
/**
|
* @description: 查询提交
|
* @param {string} tid
|
* @return {*}
|
*/
|
async submitFunc(name, f, ByOrg: boolean) {
|
this.setCurSearchInfo({ name: name, searchInfo: f.getFieldsValue(), ByOrg: ByOrg });
|
},
|
async resetFunc(name, f, ByOrg: boolean) {
|
this.setCurSearchInfo({ name: name, searchInfo: f.getFieldsValue(), ByOrg: ByOrg });
|
},
|
},
|
});
|
|
// Need to be used outside the setup
|
export function useQueryWithOut() {
|
return useQueryStore(store);
|
}
|