Browse Source

fix: 修改数据模型问题

liaojiaxing 1 month ago
parent
commit
14b5ef197a

+ 12 - 0
apps/designer/src/pages/flow/components/MenuBar/index.tsx

@@ -483,6 +483,18 @@ export default function MenuBar() {
           onClick: () => graph && handleDelete(graph),
           icon: <i className="w-20px iconfont " />,
         },
+        {
+          key: "2-13",
+          label: (
+            <div className="flex justify-between">
+              <span>清空画布</span>
+              <span>Delete/Backspace</span>
+            </div>
+          ),
+          disabled: !selectedCell.length,
+          onClick: () => graph && handleDelete(graph),
+          icon: <i className="w-20px iconfont " />,
+        },
       ],
     },
     {

+ 1 - 0
apps/er-designer/src/components/DiffTable.tsx

@@ -293,6 +293,7 @@ export default function DiffTable({
           </div>
           <Table
             pagination={false}
+            rowKey={'id'}
             columns={baseColumns}
             dataSource={tableColumnRes?.result?.model || []}
             rowSelection={{

+ 10 - 6
apps/er-designer/src/components/ImportResultModal.tsx

@@ -15,8 +15,8 @@ export default forwardRef(function ImportResultModal(
   const [modal, contextHolder] = Modal.useModal();
   useImperativeHandle(ref, () => {
     return {
-      open: (data: any[], columnList: ColumnItem[]) => {
-        originData.current = columnList;
+      open: (data: any[], origin: ColumnItem[]) => {
+        originData.current = origin;
         setDataSource(data);
         setOpen(true);
       },
@@ -154,6 +154,7 @@ export default forwardRef(function ImportResultModal(
     {
       title: "字段名",
       dataIndex: "字段名",
+      width: 150,
       render: (text) => {
         const msg = validateSchemaName(text);
         return (
@@ -168,6 +169,7 @@ export default forwardRef(function ImportResultModal(
     {
       title: "类型",
       dataIndex: "类型",
+      width: 90,
       render: (text) => {
         const msg = validateTypeValue(text);
         return (
@@ -180,6 +182,7 @@ export default forwardRef(function ImportResultModal(
     {
       title: "长度",
       dataIndex: "长度",
+      width: 90,
       render: (text, record) => {
         const msg = validateLength(text, record?.["类型"]);
         return (
@@ -189,11 +192,11 @@ export default forwardRef(function ImportResultModal(
         );
       },
     },
-    { title: "中文名", dataIndex: "中文名" },
-    { title: "英文名", dataIndex: "英文名" },
-    { title: "是否必填", dataIndex: "是否必填" },
+    { title: "中文名", dataIndex: "中文名", width: 120 },
+    { title: "英文名", dataIndex: "英文名", width: 120 },
+    { title: "是否必填", dataIndex: "是否必填", width: 90 },
     { title: "描述", dataIndex: "描述" },
-    { title: "默认值", dataIndex: "默认值" },
+    { title: "默认值", dataIndex: "默认值", width: 120 },
   ];
 
   return (
@@ -211,6 +214,7 @@ export default forwardRef(function ImportResultModal(
         scroll={{ y: 400 }}
         columns={columns}
         dataSource={dataSource}
+        size="small"
       />
     </Modal>
   );

+ 9 - 4
apps/er-designer/src/components/TableEdit.tsx

@@ -44,6 +44,10 @@ export default function TableEdit(props: {
   useEffect(() => {
     props.onChange?.(dataSource);
   }, [dataSource]);
+
+  useEffect(() => {
+    setDataSource(props.data);
+  }, [props.data]);
   const DefaultValueComp = ({
     value,
     onChange,
@@ -129,7 +133,7 @@ export default function TableEdit(props: {
     {
       title: "操作",
       valueType: "option",
-      width: 120,
+      width: 130,
       render: (_text, record, _, action) =>
         record.isPreDefined
           ? []
@@ -206,7 +210,7 @@ export default function TableEdit(props: {
       title: "类型",
       dataIndex: "type",
       valueType: "select",
-      width: 120,
+      width: 90,
       fieldProps: (form, { rowKey }) => {
         return {
           options: DATA_TYPE_OPTIONS,
@@ -230,7 +234,7 @@ export default function TableEdit(props: {
       title: "长度",
       dataIndex: "maxLength",
       valueType: "digit",
-      width: 120,
+      width: 90,
       fieldProps: {
         precision: 0,
       },
@@ -304,7 +308,7 @@ export default function TableEdit(props: {
       title: "描述",
       dataIndex: "memo",
       valueType: "textarea",
-      width: 120,
+      width: 150,
       renderFormItem: () => {
         return <Input.TextArea placeholder="描述..." />;
       },
@@ -362,6 +366,7 @@ export default function TableEdit(props: {
       <EditableProTable
         columns={columns}
         rowKey="id"
+        size="small"
         value={dataSource}
         onChange={setDataSource}
         recordCreatorProps={{

+ 1 - 1
apps/er-designer/src/constants/index.ts

@@ -57,5 +57,5 @@ export const DEFAULT_SETTING = {
   showGrid: true,
   showRelation: true,
   autoUpdate: false,
-  tableWidth: 220,
+  tableWidth: 300,
 };

+ 6 - 7
apps/er-designer/src/hooks/useChat.ts

@@ -194,16 +194,15 @@ export function useChat({ app_name, onStart, onSuccess, onUpdate, onError }: Cha
               const data = JSON.parse(chunk.data);
               if (data?.event === "message") {
                 onUpdate(data);
-              }
-              if (data?.event === "message_end") {
+              } else if (data?.event === "message_end") {
                 onSuccess(data);
-              }
-              if (data?.event === "message_error") {
-                onError(data);
-              }
-              if (data?.event === "ping") {
+              } else if (data?.event === "ping") {
                 console.log(">>>> stream start <<<<");
                 onStart?.(data);
+              } else {
+                console.log(">>>> stream error <<<<");
+                console.log(data);
+                onError(data?.message || "请求失败");
               }
             }
           }

+ 3 - 1
apps/er-designer/src/models/erModel.tsx

@@ -262,7 +262,9 @@ export default function erModel() {
         },
       })
     );
-    instance.use(new Scroller());
+    instance.use(new Scroller({
+      pannable: true
+    }));
     instance.use(new Keyboard());
     instance.use(new Export());
     instance.use(

+ 1 - 1
apps/er-designer/src/pages/detail/index.tsx

@@ -52,7 +52,7 @@ export default function index() {
   const syncModalRef = useRef<{ open: () => void }>();
   const [isFullscreen, { enterFullscreen, exitFullscreen }] =
     useFullscreen(erRef);
-  const [collapsed, setCollapsed] = useState(false);
+  const [collapsed, setCollapsed] = useState(true);
   const [seachColumn, setSearchColumn] = useState("");
 
   // 双击选中表数据

+ 9 - 7
apps/er-designer/src/pages/home/ProjectCard.tsx

@@ -142,14 +142,16 @@ export default function ProjectCard({
     >
       <Card.Meta
         title={
-          <span className="flex items-center justify-between">
-            <Tooltip title={record.name}>
-              <span className="flex-1 truncate ">{record.name}</span>
-            </Tooltip>
-            <span className="text-12px font-normal color-#999">
+          <div>
+            <div>
+              <Tooltip title={record.name}>
+                <span className="flex-1 truncate ">{record.name}</span>
+              </Tooltip>
+            </div>
+            <div className="text-12px font-normal color-#999">
               更新:{record.updateTime}
-            </span>
-          </span>
+            </div>
+          </div>
         }
         description={
           <span className="block truncate">