fix: submit (#1294)

Reviewed-on: daoyoucloud/tachybase#1294
This commit is contained in:
sealday 2024-07-09 11:30:35 +08:00
parent 2d7af4bdac
commit 462f4e0760
9 changed files with 20 additions and 56 deletions

View File

@ -1,79 +1,40 @@
import React from 'react';
import { CompatibleSchemaInitializer, InitializerWithSwitch, useSchemaInitializerItem } from '@tachybase/client';
import { InitializerWithSwitch, SchemaInitializer, useSchemaInitializerItem } from '@tachybase/client';
import { JOB_STATUS } from '../../../../../constants';
import { APPROVAL_ACTION_STATUS } from '../../../constants';
import { NAMESPACE } from '../../../locale';
/**
* @deprecated
*/
// NOTE: 似乎没用, 但删除又报错, 先保留着
const addActionButton_deprecated = new CompatibleSchemaInitializer({
export const ApprovalAddActionButton = new SchemaInitializer({
name: 'ApprovalAddActionButton',
title: '{{t("Configure actions")}}',
items: [
{
name: 'jobStatusResolved',
name: 'approvalStatusResolved',
title: `{{t("Continue the process", { ns: "${NAMESPACE}" })}}`,
Component: ActionInitializer,
action: JOB_STATUS.RESOLVED,
statusApproval: APPROVAL_ACTION_STATUS.APPROVED,
actionProps: {
type: 'primary',
},
},
{
name: 'jobStatusRejected',
name: 'approvalStatusRejected',
title: `{{t("Terminate the process", { ns: "${NAMESPACE}" })}}`,
Component: ActionInitializer,
action: JOB_STATUS.REJECTED,
statusApproval: APPROVAL_ACTION_STATUS.REJECTED,
actionProps: {
danger: true,
},
},
{
name: 'jobStatusPending',
name: 'approvalStatusPending',
title: `{{t("Save temporarily", { ns: "${NAMESPACE}" })}}`,
Component: ActionInitializer,
action: JOB_STATUS.PENDING,
statusApproval: APPROVAL_ACTION_STATUS.PENDING,
},
],
});
export const ApprovalAddActionButton = new CompatibleSchemaInitializer(
{
name: 'ApprovalAddActionButton',
title: '{{t("Configure actions")}}',
items: [
{
name: 'approvalStatusResolved',
title: `{{t("Continue the process", { ns: "${NAMESPACE}" })}}`,
Component: ActionInitializer,
statusApproval: APPROVAL_ACTION_STATUS.APPROVED,
actionProps: {
type: 'primary',
},
},
{
name: 'approvalStatusRejected',
title: `{{t("Terminate the process", { ns: "${NAMESPACE}" })}}`,
Component: ActionInitializer,
statusApproval: APPROVAL_ACTION_STATUS.REJECTED,
actionProps: {
danger: true,
},
},
{
name: 'approvalStatusPending',
title: `{{t("Save temporarily", { ns: "${NAMESPACE}" })}}`,
Component: ActionInitializer,
statusApproval: APPROVAL_ACTION_STATUS.PENDING,
},
],
},
addActionButton_deprecated,
);
function ActionInitializer() {
const itemConfig = useSchemaInitializerItem();
const { statusApproval, actionProps, ...others } = itemConfig;

View File

@ -1,4 +1,5 @@
import { SchemaInitializerItemType } from '@tachybase/client';
import { ISchema } from '@tachybase/schema';
import { Registry } from '@tachybase/utils/client';
import { JOB_STATUS } from '../../../../../constants';

View File

@ -56,7 +56,7 @@ export const LauncherActionConfigReSubmit = () => {
useAction: '{{ useActionResubmit }}',
},
'x-designer': 'Action.Designer',
'x-action': `reSubmit`,
'x-action': `Resubmit`,
'x-action-settings': {
assignedValues: {},
},

View File

@ -26,7 +26,7 @@ export const LauncherActionConfigInitializer = new SchemaInitializer({
action: APPROVAL_STATUS.DRAFT,
},
{
name: 'reSubmit',
name: 'Resubmit',
type: 'item',
title: `{{t("resubmit", { ns: "${NAMESPACE}" })}}`,
action: APPROVAL_STATUS.RESUBMIT,

View File

@ -66,7 +66,7 @@ export const ApprovalStatusEnums = [
},
{
value: APPROVAL_STATUS.RESUBMIT,
label: `{{t("reSubmit", { ns: "${NAMESPACE}" })}}`,
label: `{{t("Resubmit", { ns: "${NAMESPACE}" })}}`,
color: 'blue',
editable: true,
},

View File

@ -11,7 +11,8 @@ export function ProviderActionResubmit(props) {
const isSameId = data.data.id === createdById;
const isDraft = status === APPROVAL_STATUS.DRAFT;
if (isSameId && !isResubmit && !isDraft) {
const isReturned = status === APPROVAL_STATUS.RETURNED;
if (isSameId && !isResubmit && !isDraft && !isReturned) {
return props.children;
}

View File

@ -276,6 +276,6 @@
"\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" only support \"application/json\", and no need to specify",
"concat": "concat",
"ms": "ms",
"reSubmit": "reSubmit",
"Resubmit": "Resubmit",
"Are you sure you want to resubmit it?": "Are you sure you want to resubmit it?"
}

View File

@ -111,7 +111,8 @@
"Custom form": "自定义表单",
"Data of associated collection": "关联数据表数据",
"Data of collection": "数据表数据",
"Data operation nodes in workflow will run in a same transaction until any interruption. Any failure will cause data rollback, and will also rollback the history of the execution.": "工作流中的节点将在同一个事务中运行。任何失败都会导致数据回滚,同时也会回滚相应的执行历史。", "Data record": "数据记录",
"Data operation nodes in workflow will run in a same transaction until any interruption. Any failure will cause data rollback, and will also rollback the history of the execution.": "工作流中的节点将在同一个事务中运行。任何失败都会导致数据回滚,同时也会回滚相应的执行历史。",
"Data record": "数据记录",
"Data will be updated": "更新的数据",
"Date variables": "日期变量",
"Days": "天",
@ -356,6 +357,6 @@
"\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" 请求头仅支持 \"application/json\",无需填写",
"concat": "连接",
"ms": "毫秒",
"reSubmit": "需重新提交",
"Are you sure you want to resubmit it?": "确定生成一份新的草稿吗?"
"Resubmit": "重新发起",
"Are you sure you want to resubmit it?": "是否确定重新发起?"
}

View File

@ -116,7 +116,7 @@ const approvals = {
},
// NOTE: 和 create 逻辑雷同, 但是 因为原本的 create 并非纯操作, 因此拷贝一份以便方便改动
async reSubmit(context, next) {
async resubmit(context, next) {
const { status, collectionName, data, workflowId, collectionAppends } = context.action.params.values ?? {};
const [dataSourceName, cName] = parseCollectionName(collectionName);
const dataSource = context.app.dataSourceManager.dataSources.get(dataSourceName);