feat: add CLI carbon copy task query
This commit is contained in:
1 parent
1ef611eeab
commit
49b0359adb
5 files changed
+37
-6
No files matched your search
@@ -27,6 +27,10 @@ function selectForBacklog(): string {
|
||||
return "flowId(ownerId(id,name,enName),form(title,code,specificationId(active,id,name,enName,nameSpell,code),submitDate,submitterId(id,name,enName,nickName,code,email,cellphone,note),reviewStatus,expenseMoney,loanMoney,requisitionMoney,payMoney),`...`),`...`";
|
||||
}
|
||||
|
||||
function selectForCarbonCopy(): string {
|
||||
return "flowId(ownerId(id,name,enName),form(title,code,specificationId(active,id,name,enName,nameSpell,code),submitDate,submitterId(id,name,enName,nickName,code,email,cellphone,note),reviewStatus,expenseMoney,loanMoney,requisitionMoney,payMoney),`...`),`...`";
|
||||
}
|
||||
|
||||
export async function fetchTaskPage(
|
||||
client: KyInstance,
|
||||
corpId: string,
|
||||
@@ -36,6 +40,23 @@ export async function fetchTaskPage(
|
||||
const start = options.start ?? 0;
|
||||
const count = options.count ?? 20;
|
||||
|
||||
if (view === "cc") {
|
||||
const searchParams = new URLSearchParams({ corpId });
|
||||
searchParams.append("join", "flowId.id,nodeState,/flow/v2/backlogs/state");
|
||||
const state = options.read ? "READ" : "UNREAD";
|
||||
const response = await client.post("api/flow/v2/carbonCopy/search", {
|
||||
searchParams,
|
||||
json: {
|
||||
filterBy: `(state.in(\"${state}\"))&&((type != \"permit\"))`,
|
||||
limit: { start, count },
|
||||
select: selectForCarbonCopy(),
|
||||
orderBy: [{ value: "updateTime", order: "ASC" }],
|
||||
},
|
||||
});
|
||||
const json = (await response.json()) as { count?: number; items?: Record<string, unknown>[] };
|
||||
return { count: json.count ?? json.items?.length ?? 0, items: json.items ?? [] };
|
||||
}
|
||||
|
||||
if (view === "approved") {
|
||||
const response = await client.post("api/flow/v1/flows/approved", {
|
||||
searchParams: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const TaskViewSchema = z.enum(["todo", "approved", "processed"]);
|
||||
export const TaskViewSchema = z.enum(["todo", "approved", "processed", "cc"]);
|
||||
export type TaskView = z.infer<typeof TaskViewSchema>;
|
||||
|
||||
export interface TaskQueryOptions {
|
||||
@@ -9,6 +9,7 @@ export interface TaskQueryOptions {
|
||||
from?: number;
|
||||
to?: number;
|
||||
staffId?: string;
|
||||
read?: boolean;
|
||||
}
|
||||
|
||||
export interface TaskPerson {
|
||||
|
||||
Reference in new issue
Block a user