fix:审批创建日期复制后重新提交还是之前的日期&审批移动端始终将创建日期排在第一个(取审批的创建日期) (#1581)

Reviewed-on: daoyoucloud/tachybase#1581
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-10-09 15:42:12 +08:00 committed by bai.zixv
parent d61da53c93
commit 9ec524171d
4 changed files with 49 additions and 22 deletions

View File

@ -95,18 +95,26 @@ const changService = (api, setData, user, filter, t, setDefaultData, cm, compile
const statusType = approvalTodoListStatus(item, t); const statusType = approvalTodoListStatus(item, t);
const categoryTitle = item.workflow.title; 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)?.forEach(([key, value]) => {
const field = cm.getCollectionField(`${collectionName}.${key}`); const field = cm.getCollectionField(`${collectionName}.${key}`);
let resonValue = value; let resonValue = value;
if (field.type === 'date' && value) { if (field.type === 'date' && value) {
resonValue = dayjs(value as string).format('YYYY-MM-DD HH:mm:ss'); resonValue = dayjs(value as string).format('YYYY-MM-DD HH:mm:ss');
} }
if (key === 'createdAt') {
return { summary.unshift({
label: compile(field?.uiSchema?.title || key), label: compile(field?.uiSchema?.title || key),
value: value:
(Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '',
}; });
} else {
summary.push({
label: compile(field?.uiSchema?.title || key),
value:
(Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '',
});
}
}); });
return { return {
...item, ...item,

View File

@ -27,7 +27,8 @@ export function useCreateSubmit() {
from.submit(); from.submit();
field.data = field.data || {}; field.data = field.data || {};
field.data.loading = true; field.data.loading = true;
delete from.values['createdAt'];
delete from.values['updatedAt'];
const res = await apiClient.resource('approvals').create({ const res = await apiClient.resource('approvals').create({
values: { values: {
collectionName: joinCollectionName(collection.dataSource, collection.name), collectionName: joinCollectionName(collection.dataSource, collection.name),

View File

@ -109,18 +109,26 @@ const changeApprovalRecordsService = (api, params, filter, cm, compile, t, setDa
const categoryTitle = item.workflow.title; 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)?.forEach(([key, value]) => {
const field = cm.getCollectionField(`${collectionName}.${key}`); const field = cm.getCollectionField(`${collectionName}.${key}`);
let resonValue = value; let resonValue = value;
if (field.type === 'date' && value) { if (field.type === 'date' && value) {
resonValue = dayjs(value as string).format('YYYY-MM-DD HH:mm:ss'); resonValue = dayjs(value as string).format('YYYY-MM-DD HH:mm:ss');
} }
if (key === 'createdAt') {
return { summary.unshift({
label: compile(field?.uiSchema?.title || key), label: compile(field?.uiSchema?.title || key),
value: value:
(Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '',
}; });
} else {
summary.push({
label: compile(field?.uiSchema?.title || key),
value:
(Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '',
});
}
}); });
const nickName = item.snapshot.createdBy?.nickname || item.execution?.context?.data.createdBy?.nickname; const nickName = item.snapshot.createdBy?.nickname || item.execution?.context?.data.createdBy?.nickname;
return { return {
@ -227,17 +235,26 @@ export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData,
); );
const categoryTitle = item.workflow.title; 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)?.forEach(([key, value]) => {
const field = cm.getCollectionField(`${collectionName}.${key}`); const field = cm.getCollectionField(`${collectionName}.${key}`);
let resonValue = value; let resonValue = value;
if (field.type === 'date' && value) { if (field.type === 'date' && value) {
resonValue = dayjs(value as string).format('YYYY-MM-DD HH:mm:ss'); resonValue = dayjs(value as string).format('YYYY-MM-DD HH:mm:ss');
} }
return { if (key === 'createdAt') {
summary.unshift({
label: compile(field?.uiSchema?.title || key), label: compile(field?.uiSchema?.title || key),
value: value:
(Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '',
}; });
} else {
summary.push({
label: compile(field?.uiSchema?.title || key),
value:
(Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '',
});
}
}); });
const statusType = ApprovalStatusEnums.find((value) => value.value === item.approval?.status); const statusType = ApprovalStatusEnums.find((value) => value.value === item.approval?.status);
const nickName = user.find((userItem) => userItem.id === item.snapshot?.createdById)?.nickname; const nickName = user.find((userItem) => userItem.id === item.snapshot?.createdById)?.nickname;

View File

@ -28,7 +28,8 @@ export function useSubmitCreate() {
from.submit(); from.submit();
field.data = field.data || {}; field.data = field.data || {};
field.data.loading = true; field.data.loading = true;
delete from.values['createdAt'];
delete from.values['updatedAt'];
await apiClient.resource('approvals').create({ await apiClient.resource('approvals').create({
values: { values: {
collectionName: joinCollectionName(collection.dataSource, collection.name), collectionName: joinCollectionName(collection.dataSource, collection.name),