init: userbase front/service/deploy source (CI builds front via Gitea Actions)

This commit is contained in:
ab
2026-08-04 21:24:50 +08:00
commit e02dcc23da
407 changed files with 48134 additions and 0 deletions
+113
View File
@@ -0,0 +1,113 @@
import { defineStore } from "pinia";
import Utils from "@/utils";
import { SchLenLevel, SchoolStageDict, Subject, UserRoleEnum } from "@/types";
import { get } from "lodash";
import { BaseDict } from "@/types/Basics";
import Apis from "@/api/index";
import { alovaInstance } from "@/utils/alova/alova-iview";
import { getMenuList } from "@/assets/config/menu";
export interface IModule {
id: number;
modId: number;
name: string;
page: string;
url?: string;
icon?: string;
childState?: boolean;
children?: IModule[];
[key: string]: any;
}
export interface IdefaultStore {
curStatsDate: Date;
userRole: UserRoleEnum;
lenLevel: Array<SchLenLevel>;
subjects: Array<Subject>;
/** 系统字典(GetSysDict 接口返回) */
sysDict: Record<string, any>;
/** 模块列表(当前写死,后续接入接口) */
modules: Array<IModule>;
}
export const useDefaultStore = defineStore("defaultStore", {
state: (): IdefaultStore => {
return {
curStatsDate: new Date(),
userRole: UserRoleEnum.School,
lenLevel: [],
subjects: [],
sysDict: {},
modules: [],
};
},
actions: {
setCurStatsDate(dt: Date) {
this.curStatsDate = dt;
},
setUserRole(role: UserRoleEnum) {
this.userRole = role;
},
setSchLenLevel(len: Array<SchLenLevel>) {
this.lenLevel = len;
},
/** 获取系统字典 */
async fetchSysDict() {
try {
const data = await alovaInstance.Request(Apis.Base.getSysDict());
this.sysDict = (data as Record<string, any>) || {};
} catch (e) {
console.error("获取系统字典失败", e);
this.sysDict = {};
}
},
/** 获取模块列表(数据来源见 src/assets/config/menu.ts,后续接入接口无缝替换) */
async fetchModules() {
this.modules = await getMenuList();
},
},
getters: {
getCurrentStatsDateObj() {
let dt = Utils.dateFormat(this.curStatsDate!, "yyyy-MM-dd");
return {
startDate: dt + " 00:00:00",
endDate: dt + " 00:00:00",
};
},
getSchLenLevel(): Array<SchLenLevel> {
return this.lenLevel;
},
/**获取学校学段 */
getSchLenStage(): Array<BaseDict> {
let arr: SchLenLevel[] = this.lenLevel;
let obj = arr.sort((a, b) => a.stage - b.stage).map(item => ({ k: item.stage, v: item.name }));
return obj || [];
},
/**获取学校年级 */
getSchLenGrade(): SchLenLevel["grades"] {
let arr: SchLenLevel[] = this.lenLevel;
let obj = arr.map(item => item.grades);
let result = obj.flat().sort((a, b) => a.gradeId - b.gradeId);
return result || [];
},
getStageSubjects(): Array<BaseDict> {
let arr: BaseDict[] = [];
this.subjects.forEach(element => {
const stageName = SchoolStageDict.find(x => x.k == element.stage)?.v;
arr.push({
k: element.id,
v: stageName + (element.alias || element.name),
name: element.alias || element.name,
stage: element.stage,
code: element.code,
});
});
arr.sort((a, b) => a.stage - b.stage);
return arr;
},
/**获取系统字典 */
getSysDict(): Record<string, any> {
return this.sysDict;
},
},
});