fix(approval): 审批-发起, 去除硬编码 & 给审批-发起,添加默认的筛选条件 (#1544)

Reviewed-on: daoyoucloud/tachybase#1544
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: bai.zixv <bai.zixv@foxmail.com>
Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
bai.zixv 2024-09-19 22:23:04 +08:00 committed by sealday
parent 2bc64c504a
commit ad5b23654f
5 changed files with 27 additions and 10 deletions

View File

@ -21,7 +21,7 @@ export const ApprovalTemplateType = observer((props) => {
}) })
.then((res) => { .then((res) => {
const columnsData = res.data.data.map((value) => { const columnsData = res.data.data.map((value) => {
return { label: value.title?.replace('审批流:', '') || '', value: value.id }; return { label: value.title || '', value: value.id };
}); });
columnsData.unshift({ columnsData.unshift({
value: 'all', value: 'all',

View File

@ -93,7 +93,7 @@ const changService = (api, setData, user, filter, t, setDefaultData, cm, compile
const result = res.data?.data.map((item) => { const result = res.data?.data.map((item) => {
const priorityType = ApprovalPriorityType.find((priorityItem) => priorityItem.value === item.data.priority); const priorityType = ApprovalPriorityType.find((priorityItem) => priorityItem.value === item.data.priority);
const statusType = approvalTodoListStatus(item, t); const statusType = approvalTodoListStatus(item, t);
const categoryTitle = item.workflow.title.replace('审批流:', ''); const categoryTitle = item.workflow.title;
const collectionName = item.workflow?.config?.collection || item.execution?.context?.collectionName; const collectionName = item.workflow?.config?.collection || item.execution?.context?.collectionName;
const summary = Object.entries(item.summary)?.map(([key, value]) => { const summary = Object.entries(item.summary)?.map(([key, value]) => {
const field = cm.getCollectionField(`${collectionName}.${key}`); const field = cm.getCollectionField(`${collectionName}.${key}`);

View File

@ -37,13 +37,13 @@ export const InitiationsItem = observer((props) => {
<div <div
style={{ display: 'flex', flexDirection: 'column', alignContent: 'center' }} style={{ display: 'flex', flexDirection: 'column', alignContent: 'center' }}
onClick={(c) => { onClick={(c) => {
navigate(`/mobile/${value.title?.replace('审批流:', '') || ''}/approval/${value.id}/page`); navigate(`/mobile/${value.title || ''}/approval/${value.id}/page`);
}} }}
> >
<div> <div>
<TeamFill /> <TeamFill />
</div> </div>
{value.title?.replace('审批流:', '') || ''} {value.title || ''}
</div> </div>
), ),
}; };

View File

@ -106,7 +106,7 @@ const changeApprovalRecordsService = (api, params, filter, cm, compile, t, setDa
const result = res.data?.data.map((item) => { const result = res.data?.data.map((item) => {
const priorityType = ApprovalPriorityType.find((priorityItem) => priorityItem.value === item.snapshot.priority); const priorityType = ApprovalPriorityType.find((priorityItem) => priorityItem.value === item.snapshot.priority);
const statusType = approvalTodoListStatus(item, t); const statusType = approvalTodoListStatus(item, t);
const categoryTitle = item.workflow.title.replace('审批流:', ''); const categoryTitle = item.workflow.title;
const collectionName = item.workflow?.config?.collection || item.execution?.context?.collectionName; const collectionName = item.workflow?.config?.collection || item.execution?.context?.collectionName;
const summary = Object.entries(item.summary)?.map(([key, value]) => { const summary = Object.entries(item.summary)?.map(([key, value]) => {
@ -165,7 +165,7 @@ const changeUsersJobsService = (api, t, cm, compile, input, setData, params, fil
(priorityItem) => priorityItem.value === item.execution.context?.data?.priority, (priorityItem) => priorityItem.value === item.execution.context?.data?.priority,
); );
const statusType = ExecutionStatusOptions.find((value) => value.value === item.status); const statusType = ExecutionStatusOptions.find((value) => value.value === item.status);
const categoryTitle = item.workflow.title.replace('审批流:', ''); const categoryTitle = item.workflow.title;
const nickName = item.execution?.context?.data?.createdBy?.nickname; const nickName = item.execution?.context?.data?.createdBy?.nickname;
return { return {
...item, ...item,
@ -225,7 +225,7 @@ export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData,
const priorityType = ApprovalPriorityType.find( const priorityType = ApprovalPriorityType.find(
(priorityItem) => priorityItem.value === item.snapshot?.priority, (priorityItem) => priorityItem.value === item.snapshot?.priority,
); );
const categoryTitle = item.workflow.title.replace('审批流:', ''); const categoryTitle = item.workflow.title;
const collectionName = item.collectionName; const collectionName = item.collectionName;
const summary = Object.entries(item.summary).map(([key, value]) => { const summary = Object.entries(item.summary).map(([key, value]) => {
const field = cm.getCollectionField(`${collectionName}.${key}`); const field = cm.getCollectionField(`${collectionName}.${key}`);

View File

@ -34,9 +34,26 @@ export const ApprovalBlockLaunchApplication = (props) => {
resource: decorator?.collection, resource: decorator?.collection,
action: decorator?.action, action: decorator?.action,
params: { params: {
pageSize: 99999, pagination: false,
filter: { ...decorator?.params?.filter },
sort: 'createdAt', sort: 'createdAt',
filter: {
$and: [
// NOTE: 将审批类型的且处于启用状态的筛选出来
{
type: {
$eq: 'approval',
},
},
{
enabled: {
$eq: true,
},
},
{
...decorator?.params?.filter,
},
],
},
}, },
}, },
{ {
@ -133,7 +150,7 @@ export const ApprovalBlockLaunchApplication = (props) => {
onClick(item); onClick(item);
}} }}
> >
{item.title.replace('审批流:', '')} {item.title}
</Button> </Button>
</Col> </Col>
); );