condition building
This commit is contained in:
parent
1f8349f8d0
commit
ff253c73f0
9 changed files with 112 additions and 19 deletions
|
@ -1,7 +1,5 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type { CreateAwardViewModel, UpdateAwardViewModel, AwardViewModel } from "@/viewmodels/admin/award.models";
|
||||
import { http } from "@/serverCom";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import type { TableMeta } from "../../viewmodels/admin/query.models";
|
||||
import type { DynamicQueryStructure } from "../../types/dynamicQueries";
|
||||
|
||||
|
@ -12,7 +10,8 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
|
|||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
data: [] as Array<{ id: number; [key: string]: any }>,
|
||||
totalLength: 0 as number,
|
||||
loadingData: "failed" as "loading" | "fetched" | "failed",
|
||||
loadingData: "fetched" as "loading" | "fetched" | "failed",
|
||||
queryError: "" as string | { sql: string; code: string; msg: string },
|
||||
query: undefined as undefined | DynamicQueryStructure,
|
||||
isLoadedQuery: undefined as undefined | number,
|
||||
};
|
||||
|
@ -38,17 +37,25 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
|
|||
query: this.query,
|
||||
})
|
||||
.then((result) => {
|
||||
this.data = result.data.rows;
|
||||
this.totalLength = result.data.total;
|
||||
this.loadingData = "fetched";
|
||||
if (result.data.stats == "success") {
|
||||
this.data = result.data.rows;
|
||||
this.totalLength = result.data.total;
|
||||
this.loadingData = "fetched";
|
||||
} else {
|
||||
this.queryError = result.data ?? "An error occurred";
|
||||
this.loadingData = "failed";
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.queryError = "An error occurred";
|
||||
this.loadingData = "failed";
|
||||
});
|
||||
},
|
||||
clearResults() {
|
||||
this.data = [];
|
||||
this.totalLength = 0;
|
||||
this.queryError = "";
|
||||
this.loadingData = "fetched";
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue