fix: 同步移动端审批抄送 (#1339)

Reviewed-on: daoyoucloud/tachybase#1339
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-07-18 12:32:09 +08:00 committed by sealday
parent 49a8e2e534
commit 456df870a3
8 changed files with 227 additions and 16 deletions

View File

@ -0,0 +1,185 @@
import { approvalNoticeStatusOptions, ApprovalStatusEnums, COLLECTION_NAME_APPROVAL_CARBON_COPY } from '../constants';
import { NAMESPACE, tval } from '../locale';
export const CollectionApprovalCarbonCopy = {
title: tval('ApprovalCarbonCopy'),
name: COLLECTION_NAME_APPROVAL_CARBON_COPY,
fields: [
{
type: 'bigInt',
name: 'approvalId',
interface: 'number',
uiSchema: {
type: 'number',
title: 'ID',
'x-component': 'InputNumber',
},
},
{
type: 'belongsTo',
name: 'createdBy',
target: 'users',
foreignKey: 'createdById',
interface: 'm2o',
uiSchema: {
type: 'number',
title: `{{t("Initiator", { ns: "${NAMESPACE}" })}}`,
'x-component': 'RemoteSelect',
'x-component-props': {
fieldNames: {
label: 'nickname',
value: 'id',
},
service: {
resource: 'users',
},
},
},
},
{
type: 'bigInt',
name: 'id',
interface: 'number',
uiSchema: {
type: 'number',
title: 'ID',
'x-component': 'InputNumber',
},
},
{
type: 'belongsTo',
name: 'user',
target: 'users',
foreignKey: 'userId',
interface: 'm2o',
uiSchema: {
type: 'number',
title: tval('The Notified Person'),
'x-component': 'RemoteSelect',
'x-component-props': {
fieldNames: {
label: 'nickname',
value: 'id',
},
service: { resource: 'users' },
},
},
},
{
type: 'belongsTo',
name: 'node',
target: 'flow_nodes',
foreignKey: 'nodeId',
interface: 'm2o',
isAssociation: true,
uiSchema: {
type: 'number',
title: `{{t("Task node", { ns: "${NAMESPACE}" })}}`,
'x-component': 'RemoteSelect',
'x-component-props': {
fieldNames: {
label: 'title',
value: 'id',
},
service: {
resource: 'flow_nodes',
},
},
},
},
{
type: 'belongsTo',
name: 'workflow',
target: 'workflows',
foreignKey: 'workflowId',
interface: 'm2o',
uiSchema: {
type: 'number',
title: '{{t("Workflow", { ns: "workflow" })}}',
'x-component': 'RemoteSelect',
'x-component-props': {
fieldNames: {
label: 'title',
value: 'id',
},
service: { resource: 'workflows' },
},
},
},
{
type: 'integer',
name: 'status',
interface: 'select',
uiSchema: {
type: 'number',
title: '{{t("Status", { ns: "workflow" })}}',
'x-component': 'Select',
enum: approvalNoticeStatusOptions,
},
},
{
type: 'text',
name: 'comment',
interface: 'markdown',
uiSchema: {
type: 'string',
'x-component': 'Markdown',
title: `{{t("Comment", { ns: "${NAMESPACE}" })}}`,
},
},
{
name: 'createdAt',
type: 'date',
interface: 'createdAt',
uiSchema: {
type: 'datetime',
title: '{{t("Created at")}}',
'x-component': 'DatePicker',
'x-component-props': {
showTime: true,
},
},
},
{
name: 'updatedAt',
type: 'date',
interface: 'updatedAt',
uiSchema: {
type: 'datetime',
title: '{{t("Updated at")}}',
'x-component': 'DatePicker',
'x-component-props': {
showTime: true,
},
},
},
{
type: 'string',
name: 'summary',
interface: 'input',
uiSchema: {
type: 'string',
title: tval('Summary'),
'x-component': 'ApprovalsSummary',
'x-component-props': {
style: {
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
},
},
},
},
{
type: 'integer',
name: 'status',
interface: 'select',
uiSchema: {
type: 'number',
title: '{{t("Status", { ns: "workflow" })}}',
'x-component': 'Select',
enum: ApprovalStatusEnums,
},
},
],
};

View File

@ -16,6 +16,10 @@ import {
import { lang, NAMESPACE, tval } from './locale'; import { lang, NAMESPACE, tval } from './locale';
export const NOTICE_INSTRUCTION_NAMESPACE = 'notice';
export const COLLECTION_NOTICE_NAME = 'workflowNotice';
export const COLLECTION_NAME_APPROVAL_CARBON_COPY = 'approvalCarbonCopy';
/**显示状态 */ /**显示状态 */
export const APPROVAL_STATUS = { export const APPROVAL_STATUS = {
/**已分配 */ /**已分配 */
@ -242,3 +246,12 @@ export const ExecutionStatusOptions = [
description: 'General failed but should do another try.', description: 'General failed but should do another try.',
}, },
]; ];
export const ApprovalNoticeStatusOptions = [
{ value: EXECUTION_STATUS.QUEUEING, label: 'Assigned', color: 'blue' },
{ value: EXECUTION_STATUS.STARTED, label: 'Pending', color: 'gold' },
// { value: EXECUTION_STATUS.RETURNED, label: `{{t("Returned", { ns: "${NAMESPACE}" })}}`, color: 'purple' },
{ value: 2, label: 'Approved', color: 'green' },
{ value: EXECUTION_STATUS.REJECTED, label: 'Rejected', color: 'red' },
// { value: EXECUTION_STATUS.WITHDRAWN, label: `{{t("Withdrawn", { ns: "${NAMESPACE}" })}}` },
];

View File

@ -8,7 +8,13 @@ import { useAsyncEffect } from 'ahooks';
import { Empty, List, Space, Tag } from 'antd-mobile'; import { Empty, List, Space, Tag } from 'antd-mobile';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { APPROVAL_STATUS, ApprovalPriorityType, approvalStatusOptions, ExecutionStatusOptions } from '../../constants'; import {
APPROVAL_STATUS,
ApprovalPriorityType,
ApprovalStatusEnums,
approvalStatusOptions,
ExecutionStatusOptions,
} from '../../constants';
import { useTranslation } from '../../locale'; import { useTranslation } from '../../locale';
export const TabApprovalItem = observer((props) => { export const TabApprovalItem = observer((props) => {
@ -189,11 +195,14 @@ const changeUsersJobsService = (api, t, cm, compile, input, setData, params, fil
export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, params, filter, user) => { export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, params, filter, user) => {
api api
.request({ .request({
url: 'workflowNotice:listCentralized', url: 'approvalCarbonCopy:list',
params: { params: {
pageSize: 9999, pageSize: 9999,
filter: { ...params, ...filter }, filter: { ...params, ...filter },
appends: [ appends: [
'createdBy.id',
'createdBy.nickname',
'approval.status',
'user.id', 'user.id',
'user.nickname', 'user.nickname',
'node.id', 'node.id',
@ -228,13 +237,14 @@ export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData,
(Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '',
}; };
}); });
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;
return { return {
...item, ...item,
title: `${nickName}${categoryTitle}`, title: `${nickName}${categoryTitle}`,
categoryTitle: categoryTitle, categoryTitle: categoryTitle,
statusTitle: null, statusTitle: t(statusType.label),
statusColor: null, statusColor: statusType.color,
reason: summary, reason: summary,
priorityTitle: priorityType.label, priorityTitle: priorityType.label,
priorityColor: priorityType.color, priorityColor: priorityType.color,

View File

@ -23,6 +23,7 @@ import '../../style/style.css';
import { MobileProvider } from '@tachybase/plugin-mobile-client/client'; import { MobileProvider } from '@tachybase/plugin-mobile-client/client';
import { observer } from '@tachybase/schema'; import { observer } from '@tachybase/schema';
import { COLLECTION_NAME_APPROVAL_CARBON_COPY } from '../../constants';
import { ContextApprovalExecution } from '../../context/ApprovalExecution'; import { ContextApprovalExecution } from '../../context/ApprovalExecution';
import { useWorkflowNoticeFormBlockProps } from '../hook/useFormBlockProps'; import { useWorkflowNoticeFormBlockProps } from '../hook/useFormBlockProps';
import { usePropsNoticeDetail } from '../hook/usePropsNoticeDetail'; import { usePropsNoticeDetail } from '../hook/usePropsNoticeDetail';
@ -40,10 +41,10 @@ export const ViewTodosWorkflowNoticeContent = observer((props) => {
useEffect(() => { useEffect(() => {
api api
.request({ .request({
url: 'workflowNotice:get', url: `${COLLECTION_NAME_APPROVAL_CARBON_COPY}:get`,
params: { params: {
filterByTk: id, filterByTk: id,
appends: ['execution', 'node', 'job', 'workflow', 'workflow.nodes', 'execution.jobs', 'user'], appends: ['node', 'job', 'workflow', 'workflow.nodes', 'execution', 'execution.jobs', 'user'],
except: ['workflow.config', 'workflow.options', 'nodes.config'], except: ['workflow.config', 'workflow.options', 'nodes.config'],
sort: ['-createdAt'], sort: ['-createdAt'],
}, },
@ -58,7 +59,7 @@ export const ViewTodosWorkflowNoticeContent = observer((props) => {
nodes, nodes,
execution, execution,
}); });
setSchemaId(node?.config.showNoticeDetail); setSchemaId(node?.config.showCarbonCopyDetail);
setNoticeData(data.data); setNoticeData(data.data);
return; return;
}) })

View File

@ -1,7 +1,7 @@
import { NAMESPACE } from '../locale'; import { NAMESPACE } from '../locale';
export const CollectionWorkflows = { export const CollectionWorkflows = {
title: `{{t("Workflow", { ns: "${NAMESPACE}" })}}`, title: `{{t("Approval Launch", { ns: "${NAMESPACE}" })}}`,
name: 'workflows', name: 'workflows',
fields: [ fields: [
{ {

View File

@ -35,12 +35,12 @@ export const SchemaApprovalBlockLaunch = {
'x-component-props': { icon: 'ReloadOutlined' }, 'x-component-props': { icon: 'ReloadOutlined' },
'x-align': 'right', 'x-align': 'right',
}, },
apply: { // apply: {
type: 'void', // type: 'void',
title: `{{t("Apply new", { ns: "${NAMESPACE}" })}}`, // title: `{{t("Apply new", { ns: "${NAMESPACE}" })}}`,
'x-component': 'ApplyButton', // 'x-component': 'ApplyButton',
'x-align': 'right', // 'x-align': 'right',
}, // },
}, },
}, },
table: { table: {

View File

@ -280,5 +280,6 @@
"Are you sure you want to resubmit it?": "Are you sure you want to resubmit it?", "Are you sure you want to resubmit it?": "Are you sure you want to resubmit it?",
"MyLaunch":"MyLaunch", "MyLaunch":"MyLaunch",
"CarbonCopy":"CarbonCopy", "CarbonCopy":"CarbonCopy",
"ApprovalCarbonCopy":"Approval:CarbonCopy" "ApprovalCarbonCopy":"Approval:CarbonCopy",
"Approval Launch":"Approval Launch"
} }

View File

@ -361,5 +361,6 @@
"Are you sure you want to resubmit it?": "是否确定重新发起?", "Are you sure you want to resubmit it?": "是否确定重新发起?",
"MyLaunch":"我的发起", "MyLaunch":"我的发起",
"CarbonCopy":"抄送", "CarbonCopy":"抄送",
"ApprovalCarbonCopy":"审批:抄送" "ApprovalCarbonCopy":"审批:抄送",
"Approval Launch":"审批发起"
} }