Skip to content

Commit

Permalink
feat: Update taskCard status
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoBingyu committed Dec 14, 2023
1 parent 9ab91db commit 9b4b348
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
8 changes: 4 additions & 4 deletions clients/home/pages/new-approvals/all-approvals/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class AllApprovalStore extends Store {
this.loading = true;
try {
// const { dataList = [], total } = await getAllTaskList(this.query);
const { dataList = [], total } = await formatApprovalTaskCard(this.query, 'all');
await updateFinish(dataList);
const { dataList = [], total, validFlowID = [] } = await formatApprovalTaskCard(this.query, 'all');
await updateFinish(dataList, validFlowID);
this.approvals = dataList;
this.total = total;
this.loading = false;
Expand All @@ -59,9 +59,9 @@ class AllApprovalStore extends Store {
// page: this.query.page,
// limit: this.query.size,
// });
const { dataList = [], total } = await formatFillInTaskCard(this.query, 'all');
const { dataList = [], total, validFlowID = [] } = await formatFillInTaskCard(this.query, 'all');

await updateFinish(dataList);
await updateFinish(dataList, validFlowID);
// filter item without id
this.approvals = dataList.filter((item: ApprovalTask) => item.id);
this.total = total;
Expand Down
8 changes: 4 additions & 4 deletions clients/home/pages/new-approvals/done-approvals/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class DoneApprovalStore extends Store {
fetchAll = async () => {
this.loading = true;
try {
const { dataList = [], total } = await formatApprovalTaskCard(this.query, 'Finish');
await updateFinish(dataList);
const { dataList = [], total, validFlowID = [] } = await formatApprovalTaskCard(this.query, 'Finish');
await updateFinish(dataList, validFlowID);
this.approvals = dataList;
this.total = total;
this.loading = false;
Expand All @@ -54,7 +54,7 @@ class DoneApprovalStore extends Store {
fetchFillInAll = async () => {
this.loading = true;
try {
const { dataList = [], total } = await formatFillInTaskCard({
const { dataList = [], total, validFlowID = [] } = await formatFillInTaskCard({
page: this.query.page,
size: this.query.size,
}, 'Finish');
Expand All @@ -64,7 +64,7 @@ class DoneApprovalStore extends Store {
// limit: this.query.size,
// });
// filter item without id
await updateFinish(dataList);
await updateFinish(dataList, validFlowID);
this.approvals = dataList.filter((item: ApprovalTask) => item.id);
this.total = total;
this.loading = false;
Expand Down
8 changes: 4 additions & 4 deletions clients/home/pages/new-approvals/my-applies/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class MyAppliedApprovalStore extends Store {
fetchAll = async () => {
this.loading = true;
try {
const { dataList = [], total } = await formatApprovalTaskCard(this.query, 'myApply');
await updateFinish(dataList);
const { dataList = [], total, validFlowID = [] } = await formatApprovalTaskCard(this.query, 'myApply');
await updateFinish(dataList, validFlowID);
this.approvals = dataList.filter((item: ApprovalTask) => item.id); // filter item without id
this.total = total - (dataList.length - this.approvals.length);
this.loading = false;
Expand All @@ -71,8 +71,8 @@ class MyAppliedApprovalStore extends Store {
fetchFillInAll = async () => {
this.loading = true;
try {
const { dataList = [], total } = await formatFillInTaskCard(this.query, 'myApply');
await updateFinish(dataList);
const { dataList = [], total, validFlowID = [] } = await formatFillInTaskCard(this.query, 'myApply');
await updateFinish(dataList, validFlowID);
this.approvals = dataList.filter((item: ApprovalTask) => item.id); // filter item without id
this.total = total;
this.loading = false;
Expand Down
4 changes: 2 additions & 2 deletions clients/home/pages/new-approvals/todo-approvals/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TodoApprovalStore extends Store {
fetchAll = async () => {
this.loading = true;
try {
const { dataList, total } = await formatApprovalTaskCard(this.query, 'Pending');
const { dataList, total, validFlowID = [] } = await formatApprovalTaskCard(this.query, 'Pending');
this.approvals = dataList || [];
this.total = total;
this.loading = false;
Expand All @@ -71,7 +71,7 @@ class TodoApprovalStore extends Store {
fetchFillInAll = async () => {
this.loading = true;
try {
const { dataList, total } = await formatFillInTaskCard(this.query, 'Pending');
const { dataList, total, validFlowID = [] } = await formatFillInTaskCard(this.query, 'Pending');
this.approvals = dataList || [];
this.total = total;
this.loading = false;
Expand Down
22 changes: 12 additions & 10 deletions clients/home/pages/new-approvals/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ const getArrList = (data: any, type)=>{
const formatData = (data: any, res: any, pipelineType: any, type: any)=>{
const appNameList = res?.[0]?.apps;
const userNameList = res?.[1]?.users;
const pipelineInfo = res?.[2];
const pipelineFormInfo = res?.[3];
const pipelineFormSchemaInfo = res?.[4];
const pipelineInfo = res?.[2]?.filter((item: any)=>!!item);
const pipelineFormInfo = res?.[3]?.filter((item: any)=>!!item);
const pipelineFormSchemaInfo = res?.[4]?.filter((item: any)=>!!item);

const validFlowID = [...new Set(pipelineInfo?.map((item: any)=>item?.name))];
const dataList = data?.map((item: any)=>{
const { id, taskID, userID, createBy, examineType, nodeResult, createdAt, appID, formTableID, formDataID, flowID, nodeDefKey, nodeInfo, createdBy } = item;
const appName = appNameList?.find((item: any)=>{
Expand Down Expand Up @@ -219,7 +220,7 @@ const formatData = (data: any, res: any, pipelineType: any, type: any)=>{
};
return obj;
});
return dataList;
return { dataList, validFlowID };
};

export const formatApprovalTaskCard = async (query: any, type?: any)=>{
Expand All @@ -238,8 +239,8 @@ export const formatApprovalTaskCard = async (query: any, type?: any)=>{
const { data, total } = await apiList[type](params) as any; // 获取审批列表
const arrList = getArrList(data || [], 'approval');
const res = await Promise.all(arrList?.map((item: any)=>item()));
const dataList = formatData(data, res, 'approval', type); // 格式化 data
return { dataList, total };
const { dataList, validFlowID } = formatData(data, res, 'approval', type); // 格式化 data
return { dataList, total, validFlowID };
};

export const formatFillInTaskCard = async (query: any, type: any)=>{
Expand All @@ -258,8 +259,8 @@ export const formatFillInTaskCard = async (query: any, type: any)=>{
const { data, total } = await apiList[type](params) as any; // 获取填写列表
const arrList = getArrList(data || [], 'fillIn');
const res = await Promise.all(arrList?.map((item: any)=>item()));
const dataList = formatData(data, res, 'fillIn', type); // 格式化 data
return { dataList, total };
const { dataList, validFlowID } = formatData(data, res, 'fillIn', type); // 格式化 data
return { dataList, total, validFlowID };
};

// 格式化pipeline 动态
Expand Down Expand Up @@ -468,8 +469,9 @@ export const getApplyParams = (query: any)=>{
return res;
};

export const updateFinish = async (dataList: any) => {
const updatePromises = dataList.map(async (item: any) => {
export const updateFinish = async (dataList: any, validFlowID: any) => {
const _dataList = dataList?.filter((item: any)=>validFlowID?.includes(item?.flowID));
const updatePromises = _dataList.map(async (item: any) => {
const { procInstId } = item || {};
const processInfo = await getAllProcessInfo(procInstId);
const pipelineProcess = await getAllPipelineProcess(processInfo?.[0]?.Data, processInfo?.[1]?.data);
Expand Down

0 comments on commit 9b4b348

Please sign in to comment.