|
@@ -9,6 +9,7 @@ import {
|
|
|
Empty,
|
|
|
Spin,
|
|
|
} from "antd";
|
|
|
+import { ProDescriptions } from "@ant-design/pro-components";
|
|
|
import type { DescriptionsProps, MenuProps } from "antd";
|
|
|
import { DownOutlined, PlusOutlined, SearchOutlined } from "@ant-design/icons";
|
|
|
import TableEdit from "@/components/TableEdit";
|
|
@@ -21,6 +22,9 @@ import { ColumnItem, ProjectInfo, TableItemType } from "@/type";
|
|
|
import { useFullscreen } from "ahooks";
|
|
|
import AddModel from "@/components/AddModel";
|
|
|
import insertCss from "insert-css";
|
|
|
+import LangInput from "@/components/LangInput";
|
|
|
+import LangInputTextarea from "@/components/LangInputTextarea";
|
|
|
+import { validateAliasName, validateTableCode } from "@/utils/validator";
|
|
|
|
|
|
const { Content, Header } = Layout;
|
|
|
export default function index() {
|
|
@@ -81,7 +85,7 @@ export default function index() {
|
|
|
{
|
|
|
key: "2",
|
|
|
label: "创建用户",
|
|
|
- children: project?.createdBy || "-",
|
|
|
+ children: project?.createdByName || "-",
|
|
|
},
|
|
|
{
|
|
|
key: "3",
|
|
@@ -125,31 +129,41 @@ export default function index() {
|
|
|
children?: MenuProps["items"];
|
|
|
}[] = [];
|
|
|
|
|
|
- tables.forEach((item) => {
|
|
|
- const name = item.table.langNameList?.find(
|
|
|
- (item) => item.name === "zh-CN"
|
|
|
- )?.value;
|
|
|
- const newItem = {
|
|
|
- key: item.table.id,
|
|
|
- label: item.table.schemaName + `${name ? `(${name})}` : ""}`,
|
|
|
- icon: <i className="iconfont icon-biaogebeifen" />,
|
|
|
- };
|
|
|
- if (!item.table.parentBusinessTableId) {
|
|
|
- treeList.push(newItem);
|
|
|
- } else {
|
|
|
- const parent = treeList.find(
|
|
|
- (tableItem) => tableItem?.key === item.table.parentBusinessTableId
|
|
|
+ tables
|
|
|
+ .filter((item) => {
|
|
|
+ const tableName = item.table.langNameList?.find(
|
|
|
+ (item) => item.name === "zh-CN"
|
|
|
+ )?.value;
|
|
|
+ return (
|
|
|
+ item.table.schemaName.includes(searchKeyword) ||
|
|
|
+ tableName?.includes(searchKeyword)
|
|
|
);
|
|
|
- if (parent) {
|
|
|
- if (!parent?.children) {
|
|
|
- parent.children = [];
|
|
|
+ })
|
|
|
+ .forEach((item) => {
|
|
|
+ const name = item.table.langNameList?.find(
|
|
|
+ (item) => item.name === "zh-CN"
|
|
|
+ )?.value;
|
|
|
+ const newItem = {
|
|
|
+ key: item.table.id,
|
|
|
+ label: item.table.schemaName + `${name ? `(${name})}` : ""}`,
|
|
|
+ icon: <i className="iconfont icon-biaogebeifen" />,
|
|
|
+ };
|
|
|
+ if (!item.table.parentBusinessTableId) {
|
|
|
+ treeList.push(newItem);
|
|
|
+ } else {
|
|
|
+ const parent = treeList.find(
|
|
|
+ (tableItem) => tableItem?.key === item.table.parentBusinessTableId
|
|
|
+ );
|
|
|
+ if (parent) {
|
|
|
+ if (!parent?.children) {
|
|
|
+ parent.children = [];
|
|
|
+ }
|
|
|
+ parent.children?.push(newItem);
|
|
|
}
|
|
|
- parent.children?.push(newItem);
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
return treeList;
|
|
|
- }, [project]);
|
|
|
+ }, [project, searchKeyword]);
|
|
|
|
|
|
const currentTable = useMemo(() => {
|
|
|
return project.tables.find((item) => item.table.id === selectKey);
|
|
@@ -178,11 +192,12 @@ export default function index() {
|
|
|
|
|
|
// 修改表格字段
|
|
|
const handleChangeColumn = (columns: readonly ColumnItem[]) => {
|
|
|
- currentTable && updateTable({
|
|
|
- ...currentTable,
|
|
|
- tableColumnList: [...columns]
|
|
|
- })
|
|
|
- }
|
|
|
+ currentTable &&
|
|
|
+ updateTable({
|
|
|
+ ...currentTable,
|
|
|
+ tableColumnList: [...columns],
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
const extra = (
|
|
|
<div className="flex gap-12px">
|
|
@@ -349,8 +364,90 @@ export default function index() {
|
|
|
) : (
|
|
|
<div>
|
|
|
<div className="p-y-10px p-l-20px">
|
|
|
- <span className="font-bold">当前表格:</span>
|
|
|
- {currentTable?.table.schemaName}
|
|
|
+ <ProDescriptions
|
|
|
+ title={currentTable?.table.schemaName}
|
|
|
+ dataSource={currentTable?.table}
|
|
|
+ editable={{
|
|
|
+ onSave: async (keypath, newInfo, oriInfo) => {
|
|
|
+ console.log(keypath, newInfo, oriInfo);
|
|
|
+ currentTable &&
|
|
|
+ updateTable({
|
|
|
+ ...currentTable,
|
|
|
+ table: {
|
|
|
+ ...currentTable?.table,
|
|
|
+ ...newInfo,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ columns={[
|
|
|
+ {
|
|
|
+ label: "类型",
|
|
|
+ dataIndex: "type",
|
|
|
+ valueType: "select",
|
|
|
+ valueEnum: {
|
|
|
+ 1: "业务表",
|
|
|
+ 2: "流程表",
|
|
|
+ },
|
|
|
+ editable: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "编码",
|
|
|
+ dataIndex: "schemaName",
|
|
|
+ valueType: "text",
|
|
|
+ formItemProps: {
|
|
|
+ rules: [
|
|
|
+ { required: true, message: "请输入编码" },
|
|
|
+ validateTableCode,
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "别名",
|
|
|
+ dataIndex: "aliasName",
|
|
|
+ valueType: "text",
|
|
|
+ formItemProps: {
|
|
|
+ rules: [
|
|
|
+ { required: true, message: "请输入别名" },
|
|
|
+ validateAliasName,
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "名称",
|
|
|
+ dataIndex: "langNameList",
|
|
|
+ render: (_, record) => {
|
|
|
+ return (
|
|
|
+ record.langNameList?.find(
|
|
|
+ (item) => item.name === "zh-CN"
|
|
|
+ )?.value || "-"
|
|
|
+ );
|
|
|
+ },
|
|
|
+ renderFormItem: (_schema, config, form) => {
|
|
|
+ return <LangInput style={{width: 200}} onChange={(val) => form.setFieldValue("langNameList", val)}/>;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "描述",
|
|
|
+ dataIndex: "langDescriptionList",
|
|
|
+ render: (_, record) => {
|
|
|
+ return (
|
|
|
+ record?.langDescriptionList?.find(
|
|
|
+ (item) => item.name === "zh-CN"
|
|
|
+ )?.value || "-"
|
|
|
+ );
|
|
|
+ },
|
|
|
+ renderFormItem: () => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <LangInputTextarea />
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ ></ProDescriptions>
|
|
|
</div>
|
|
|
<TableEdit
|
|
|
key={selectKey}
|