Skip to content

Commit b41cb12

Browse files
author
www.zerocode.net.cn
committed
📝 fix(erd): bug修复
1 parent 138b522 commit b41cb12

File tree

12 files changed

+550
-11
lines changed

12 files changed

+550
-11
lines changed

config/routes.ts

+8
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@
102102
path: '/design/table/version/all',
103103
component: './design/version',
104104
},
105+
{
106+
path: '/design/table/version/order',
107+
component: './design/version/order',
108+
},
109+
{
110+
path: '/design/table/version/approval',
111+
component: './design/version/approval',
112+
},
105113
]
106114
},
107115
{

src/access.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export default function access(initialState: and) {
1616
}
1717

1818
return {
19+
person: person,//是否是个人项目
20+
enterprise: !person,//是否是企业项目
1921
initialized: person || (permission && permission.includes('initialized')),//标记是否初始化了权限
2022
canErdProjectGroupEdit: person || (permission && permission.includes('erd_project_group_edit')),//团队基础设置 -修改
2123
canErdProjectGroupDel: person || (permission && permission.includes('erd_project_group_del')),//团队基础设置 -删除
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import React from 'react';
2+
import {ModalForm, ProFormSelect, ProFormText, ProFormTextArea} from '@ant-design/pro-components';
3+
import defaultData from "@/utils/defaultData.json";
4+
import {Button, message} from "antd";
5+
import _ from "lodash";
6+
import {addProject} from "@/services/project";
7+
import {addGroupProject} from "@/services/group-project";
8+
import {CopyOutlined} from "@ant-design/icons";
9+
import useProjectStore from "@/store/project/useProjectStore";
10+
import shallow from "zustand/shallow";
11+
12+
export type CopyProjectProps = {
13+
projectJSON: any;
14+
};
15+
16+
const CopyProject: React.FC<CopyProjectProps> = (props) => {
17+
const {profile, dataTypeDomains} = useProjectStore(state => ({
18+
profile: state.project?.projectJSON?.profile,
19+
dataTypeDomains: state.project?.projectJSON?.dataTypeDomains,
20+
}), shallow);
21+
const emptyProject = {
22+
"projectName": "",
23+
"description": "",
24+
"tags": "",
25+
"projectJSON": {
26+
...defaultData
27+
},
28+
"configJSON": {synchronous: {upgradeType: "increment"}},
29+
}
30+
31+
32+
return (<>
33+
<ModalForm
34+
title="复刻为新项目(从当前版本创建新项目)"
35+
trigger={
36+
<Button key="copy" size={"small"} type={"link"} icon={<CopyOutlined/>}>复刻</Button>
37+
}
38+
onFinish={async (values: any) => {
39+
40+
console.log(39, values);
41+
console.log(39, props.projectJSON);
42+
if (values.type.value === 1) {
43+
addProject({
44+
...emptyProject,
45+
projectJSON: {
46+
profile,
47+
dataTypeDomains,
48+
modules: props.projectJSON?.modules || emptyProject.projectJSON.modules
49+
},
50+
projectName: values.projectName,
51+
description: values.description,
52+
tags: _.join(values.tags, ',')
53+
}).then((r) => {
54+
console.log(54, r);
55+
if (r.code === 200) {
56+
message.success(
57+
<>
58+
复刻成功,
59+
<a href="/project/recent">立即打开</a>
60+
</>, 5
61+
);
62+
}
63+
});
64+
} else {
65+
addGroupProject({
66+
...emptyProject,
67+
projectJSON: {
68+
profile,
69+
dataTypeDomains,
70+
modules: props.projectJSON?.modules || emptyProject.projectJSON.modules
71+
},
72+
projectName: values.projectName,
73+
description: values.description,
74+
tags: _.join(values.tags, ',')
75+
}).then((r) => {
76+
console.log(54, r);
77+
if (r.code === 200) {
78+
message.success(
79+
<>
80+
复刻成功,
81+
<a href="/project/recent">立即打开</a>
82+
</>, 5
83+
);
84+
}
85+
});
86+
}
87+
}}
88+
>
89+
<ProFormText
90+
width="md"
91+
name="projectName"
92+
label="项目名"
93+
placeholder="请输入项目名"
94+
formItemProps={{
95+
rules: [
96+
{
97+
required: true,
98+
message: '不能为空',
99+
},
100+
{
101+
max: 100,
102+
message: '不能大于 100 个字符',
103+
},
104+
],
105+
}}
106+
/>
107+
<ProFormSelect
108+
name="type"
109+
width="md"
110+
label="项目类型"
111+
fieldProps={{
112+
labelInValue: true,
113+
}}
114+
options={[
115+
{label: '个人项目', value: 1},
116+
{label: '团队项目', value: 2},
117+
]}
118+
/>
119+
<ProFormSelect
120+
width="md"
121+
name="tags"
122+
label="标签"
123+
placeholder="请输入项目标签,按回车分割"
124+
formItemProps={{
125+
rules: [
126+
{
127+
required: true,
128+
message: '不能为空',
129+
},
130+
],
131+
}}
132+
fieldProps={{
133+
mode: "tags",
134+
tokenSeparators: [',']
135+
}}
136+
/>
137+
138+
<ProFormTextArea
139+
width="md"
140+
name="description"
141+
label="项目描述"
142+
placeholder="请输入项目描述"
143+
formItemProps={{
144+
rules: [
145+
{
146+
required: true,
147+
message: '不能为空',
148+
},
149+
{
150+
max: 100,
151+
message: '不能大于 100 个字符',
152+
},
153+
],
154+
}}
155+
/>
156+
</ModalForm>
157+
</>);
158+
}
159+
160+
export default React.memo(CopyProject)

src/components/dialog/version/CompareVersion.tsx

+25-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ import {Button, message, Typography} from "antd";
99
import moment from "moment";
1010
import * as File from '@/utils/file';
1111
import _ from 'lodash';
12-
import {CloudSyncOutlined, DiffOutlined, ExportOutlined, FileTextOutlined, FlagOutlined} from "@ant-design/icons";
12+
import {
13+
CloudSyncOutlined,
14+
CloudUploadOutlined,
15+
DiffOutlined,
16+
ExportOutlined,
17+
FileTextOutlined,
18+
FlagOutlined
19+
} from "@ant-design/icons";
1320
import {Access, useAccess} from "@@/plugin-access";
14-
import SqlApproval from "@/components/dialog/version/SqlAproval";
21+
import SqlApproval from "@/components/dialog/approval/SqlApproval";
22+
import {useSearchParams} from "@@/exports";
23+
import * as cache from "@/utils/cache";
24+
import {CONSTANT} from "@/utils/constant";
1525

1626
const {Paragraph} = Typography;
1727

@@ -99,6 +109,12 @@ const CompareVersion: React.FC<CompareVersionProps> = (props) => {
99109

100110
const isDetail = props.type === CompareVersionType.DETAIL;
101111
const isCompare = props.type === CompareVersionType.COMPARE;
112+
113+
const [searchParams] = useSearchParams();
114+
let projectId = searchParams.get("projectId") || '';
115+
if (!projectId || projectId === '') {
116+
projectId = cache.getItem(CONSTANT.PROJECT_ID) || '';
117+
}
102118
return (<>
103119
<ModalForm
104120
title={isDetail ? "版本变更详情" : "任意版本比较"}
@@ -122,7 +138,12 @@ const CompareVersion: React.FC<CompareVersionProps> = (props) => {
122138
accessible={access.enterprise}
123139
fallback={<></>}
124140
>
125-
<SqlApproval/>
141+
<SqlApproval
142+
projectId={projectId}
143+
approveSql={data}
144+
versionId={currentVersion.id}
145+
display={(isDetail && currentVersion.version && compareStringVersion(currentVersion.version, dbVersion) > 0) ? '' : 'none'}
146+
/>
126147
</Access>,
127148
<Button type="primary" key="save" onClick={onSave}>
128149
<ExportOutlined/>导出
@@ -140,7 +161,7 @@ const CompareVersion: React.FC<CompareVersionProps> = (props) => {
140161
}}
141162
onClick={() => execSQL(true, 'synchronous')}
142163
>
143-
<CloudSyncOutlined/>
164+
<CloudUploadOutlined/>
144165
{state.synchronous ? '正在同步' : '同步'}
145166
</Button>
146167
</Access>,

src/layouts/DesignLayout/_defaultProps.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
Audit,
23
Column,
34
DatabaseConfig,
45
DatabaseDownload,
@@ -11,7 +12,7 @@ import {
1112
Outbound,
1213
SettingConfig,
1314
SettingTwo,
14-
Sphere,
15+
Sphere, TransactionOrder,
1516
Warehousing
1617
} from "@icon-park/react";
1718

@@ -42,6 +43,16 @@ export default {
4243
icon: <History theme="filled" size="18" fill="#DE2910" strokeWidth={2}/>,
4344
access: 'canErdHisprojectAll',
4445
},
46+
{
47+
path: '/design/table/version/order',
48+
name: '我的工单',
49+
icon: <TransactionOrder theme="filled" size="18" fill="#DE2910" strokeWidth={2}/>,
50+
},
51+
{
52+
path: '/design/table/version/approval',
53+
name: '我的审批',
54+
icon: <Audit theme="filled" size="18" fill="#DE2910" strokeWidth={2}/>,
55+
},
4556
],
4657
},
4758
{

0 commit comments

Comments
 (0)