Forráskód Böngészése

fix: 修改多语言组件bug

liaojiaxing 4 hónapja
szülő
commit
5c63d96dd1

+ 2 - 2
apps/er-designer/src/components/LangInput.tsx

@@ -22,8 +22,8 @@ export default function LangInput({
   const [lanOptions, setLanOptions] = React.useState<any[]>([]);
   const [formModel, setFormModel] = React.useState({
     langText: "",
-    en: value?.find(item => item.name = 'en')?.value || "",
-    ["zh-CN"]: value?.find(item => item.name = 'zh-CN')?.value || "",
+    en: value?.find(item => item.name === 'en')?.value || "",
+    ["zh-CN"]: value?.find(item => item.name === 'zh-CN')?.value || "",
   });
   const { run } = useRequest(ListLangBySearchKey, {
     manual: true,

+ 2 - 2
apps/er-designer/src/components/LangInputTextarea.tsx

@@ -18,8 +18,8 @@ export default function LangInputTextarea({
   const [lanOptions, setLanOptions] = React.useState<any[]>([]);
   const [formModel, setFormModel] = React.useState({
     langText: "",
-    en: value?.find(item => item.name = 'en')?.value || "",
-    ["zh-CN"]: value?.find(item => item.name = 'zh-CN')?.value || "",
+    en: value?.find(item => item.name === 'en')?.value || "",
+    ["zh-CN"]: value?.find(item => item.name === 'zh-CN')?.value || "",
   });
   const { run } = useRequest(ListLangBySearchKey, {
     manual: true,

+ 12 - 8
apps/er-designer/src/components/TableEdit.tsx

@@ -118,7 +118,7 @@ export default function TableEdit(props: {
     },
     {
       title: "字段名称",
-      dataIndex: "langNameList",
+      dataIndex: "langName",
       valueType: "text",
       width: 150,
       render: (_dom, entity) => {
@@ -131,14 +131,18 @@ export default function TableEdit(props: {
       renderFormItem: (_schema, config, form) => {
         const model = config.record;
         const rowKey = config.recordKey;
+        console.log(model)
         return (
-          <LangInput
-            value={model.langNameList}
-            style={{width: 150}}
-            onChange={(langValue) =>
-              form.setFieldValue([rowKey || "", "langNameList"], langValue)
-            }
-          />
+          <span>
+            <LangInput
+              style={{ width: 150 }}
+              value={model.langNameList}
+              onChange={(langValue, key) => {
+                form.setFieldValue([rowKey || "", "langNameList"], langValue);
+                form.setFieldValue([rowKey || "", "langName"], "");
+              }}
+            />
+          </span>
         );
       },
     },

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

@@ -145,7 +145,7 @@ export default function index() {
         )?.value;
         const newItem = {
           key: item.table.id,
-          label: item.table.schemaName + `${name ? `(${name})}` : ""}`,
+          label: item.table.schemaName + `${name ? `(${name})` : ""}`,
           icon: <i className="iconfont icon-biaogebeifen" />,
         };
         if (!item.table.parentBusinessTableId) {
@@ -369,13 +369,14 @@ export default function index() {
                       dataSource={currentTable?.table}
                       editable={{
                         onSave: async (keypath, newInfo, oriInfo) => {
-                          console.log(keypath, newInfo, oriInfo);
                           currentTable &&
                             updateTable({
                               ...currentTable,
                               table: {
                                 ...currentTable?.table,
                                 ...newInfo,
+                                langName: "",
+                                langDescription: "",
                               },
                             });
                           return true;
@@ -387,7 +388,7 @@ export default function index() {
                           dataIndex: "type",
                           valueType: "select",
                           valueEnum: {
-                            1: "业务表",
+                            3: "业务表",
                             2: "流程表",
                           },
                           editable: false,
@@ -425,7 +426,14 @@ export default function index() {
                             );
                           },
                           renderFormItem: (_schema, config, form) => {
-                            return <LangInput style={{width: 200}}  onChange={(val) => form.setFieldValue("langNameList", val)}/>;
+                            return (
+                              <LangInput
+                                style={{ width: 200 }}
+                                onChange={(val) =>
+                                  form.setFieldValue("langNameList", val)
+                                }
+                              />
+                            );
                           },
                         },
                         {
@@ -438,10 +446,17 @@ export default function index() {
                               )?.value || "-"
                             );
                           },
-                          renderFormItem: () => {
+                          renderFormItem: (_schema, config, form) => {
                             return (
                               <>
-                                <LangInputTextarea />
+                                <LangInputTextarea
+                                  onChange={(val) =>
+                                    form.setFieldValue(
+                                      "langDescriptionList",
+                                      val
+                                    )
+                                  }
+                                />
                               </>
                             );
                           },