|
@@ -265,70 +265,6 @@ export default forwardRef(function AddTable(
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- // 获取引入的表转换成模型表
|
|
|
- // const getNewTableByTable = async (
|
|
|
- // tableData: any,
|
|
|
- // columns: any[],
|
|
|
- // tableOther: Record<string, any> = {}
|
|
|
- // ): Promise<TableItemType> => {
|
|
|
- // const newTable = createTable(project.type, project.id);
|
|
|
- // const langKeyList: string[] = [];
|
|
|
- // if (tableData.langName) {
|
|
|
- // langKeyList.push(tableData.langName);
|
|
|
- // }
|
|
|
- // if (tableData.langDescription) {
|
|
|
- // langKeyList.push(tableData.langDescription);
|
|
|
- // }
|
|
|
- // columns.forEach((item) => {
|
|
|
- // if (item.langName) {
|
|
|
- // langKeyList.push(item.langName);
|
|
|
- // }
|
|
|
- // });
|
|
|
-
|
|
|
- // // 获取全部多语言数据
|
|
|
- // const langList = await Promise.all(
|
|
|
- // [...new Set(langKeyList)].map((key) =>
|
|
|
- // ListLangByKey({ key }).then((res) => res.result)
|
|
|
- // )
|
|
|
- // );
|
|
|
-
|
|
|
- // const langName = langList.find((item) => item.key === tableData.langName);
|
|
|
- // const descName = langList.find(
|
|
|
- // (item) => item.key === tableData.langDescription
|
|
|
- // );
|
|
|
- // return {
|
|
|
- // isTable: true,
|
|
|
- // // 表格数据
|
|
|
- // table: {
|
|
|
- // ...newTable.table,
|
|
|
- // ...pick(tableData, ["schemaName", "aliasName", "isDeleted"]),
|
|
|
- // langNameList: [
|
|
|
- // { name: "zh-CN", value: langName?.["zh-CN"] || "" },
|
|
|
- // { name: "en", value: langName?.["en"] || "" },
|
|
|
- // ],
|
|
|
- // langDescriptionList: [
|
|
|
- // { name: "zh-CN", value: descName?.["zh-CN"] || "" },
|
|
|
- // { name: "en", value: descName?.["en"] || "" },
|
|
|
- // ],
|
|
|
- // ...tableOther,
|
|
|
- // },
|
|
|
- // // 字段数据
|
|
|
- // tableColumnList: columns.map((item) => {
|
|
|
- // const column = createColumn(newTable.table.id);
|
|
|
- // const langName = langList.find((lang) => lang.key === item.langName);
|
|
|
-
|
|
|
- // return {
|
|
|
- // ...column,
|
|
|
- // ...pick(item, Object.keys(column)),
|
|
|
- // langNameList: [
|
|
|
- // { name: "zh-CN", value: langName?.["zh-CN"] || "" },
|
|
|
- // { name: "en", value: langName?.["en"] || "" },
|
|
|
- // ],
|
|
|
- // };
|
|
|
- // }),
|
|
|
- // };
|
|
|
- // };
|
|
|
-
|
|
|
const [loadingColumns, setLoadingColumns] = useState(false);
|
|
|
const handleOk = () => {
|
|
|
// 新建
|
|
@@ -353,77 +289,12 @@ export default forwardRef(function AddTable(
|
|
|
const values = form1.getFieldsValue();
|
|
|
try {
|
|
|
setLoadingColumns(true);
|
|
|
- // const requestList = values.table.map((tableId: string) => [
|
|
|
- // GetBusinessTablesByTableId(tableId),
|
|
|
- // GetAllBusinessTableColumns({
|
|
|
- // currentPage: 1,
|
|
|
- // pageSize: 2000,
|
|
|
- // orderByProperty: "isPreDefined DESC, DisplayOrder",
|
|
|
- // Ascending: true,
|
|
|
- // totalPage: 1,
|
|
|
- // totalCount: 1,
|
|
|
- // filters: [
|
|
|
- // {
|
|
|
- // name: "BusinessTableId",
|
|
|
- // value: tableId,
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // }),
|
|
|
- // ]);
|
|
|
+
|
|
|
if (values.table.length === 0) {
|
|
|
message.error("请选择要引入的表");
|
|
|
return;
|
|
|
}
|
|
|
- // const resArr = await Promise.allSettled(
|
|
|
- // (requestList as Promise<any>[]).flat(1)
|
|
|
- // );
|
|
|
-
|
|
|
- // const tableMap: Record<string, any> = {};
|
|
|
- // resArr.forEach((res) => {
|
|
|
- // if (res.status === "fulfilled") {
|
|
|
- // const value = res.value?.result;
|
|
|
- // // 表格数据
|
|
|
- // if (Array.isArray(value) && value[0]) {
|
|
|
- // tableMap[value[0].id] = {
|
|
|
- // table: value[0],
|
|
|
- // tableColumnList: [],
|
|
|
- // };
|
|
|
- // } else {
|
|
|
- // // 字段数据
|
|
|
- // const model = res.value?.result?.model;
|
|
|
- // const tableId = model?.[0]?.businessTableId;
|
|
|
- // if (tableId) {
|
|
|
- // if (tableMap[tableId]) {
|
|
|
- // tableMap[tableId].tableColumnList = model;
|
|
|
- // } else {
|
|
|
- // tableMap[tableId] = {
|
|
|
- // table: {},
|
|
|
- // tableColumnList: model,
|
|
|
- // };
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
-
|
|
|
- // const rect = graph?.getAllCellsBBox();
|
|
|
- // // 计算起始位置 默认往最后加
|
|
|
- // const startY = (rect?.height || 0) + (rect?.y || 0) + 20;
|
|
|
- // const result = Object.keys(tableMap).map(async (key, index) => {
|
|
|
- // const table = await getNewTableByTable(
|
|
|
- // tableMap[key].table,
|
|
|
- // tableMap[key].tableColumnList
|
|
|
- // );
|
|
|
- // table.table.style.y = startY;
|
|
|
- // table.table.style.x =
|
|
|
- // 100 + index * (project.setting.tableWidth + 20);
|
|
|
- // if (color) {
|
|
|
- // table.table.style.color = color;
|
|
|
- // }
|
|
|
- // return table;
|
|
|
- // });
|
|
|
|
|
|
- // const newTables = await Promise.all(result);
|
|
|
const businessTables =
|
|
|
data?.result
|
|
|
?.filter((item: any) => values.table.includes(item.id))
|
|
@@ -441,9 +312,16 @@ export default forwardRef(function AddTable(
|
|
|
businessTables,
|
|
|
});
|
|
|
console.log("导入结果:", res);
|
|
|
- // props.onChange(res.result);
|
|
|
- // form1.resetFields();
|
|
|
- // setOpen(false);
|
|
|
+ const rect = graph?.getAllCellsBBox();
|
|
|
+ // 计算起始位置 默认往最后加
|
|
|
+ const startY = (rect?.height || 0) + (rect?.y || 0) + 20;
|
|
|
+ props.onChange(res.result?.map((item: any) => {
|
|
|
+ item.table.style = JSON.parse(item.table.style || '{}');
|
|
|
+ item.table.style.y = startY;
|
|
|
+ return item
|
|
|
+ }));
|
|
|
+ form1.resetFields();
|
|
|
+ setOpen(false);
|
|
|
} catch (err) {
|
|
|
console.error(err);
|
|
|
message.warning("引入失败");
|