tianyunperfect 5 лет назад
Родитель
Сommit
c5cdd48602
3 измененных файлов с 27 добавлено и 11 удалено
  1. 6 0
      bin/push.sh
  2. 1 0
      config/config.ts
  3. 20 11
      src/pages/ModelList/index.tsx

+ 6 - 0
bin/push.sh

@@ -0,0 +1,6 @@
+remote=worker@10.20.222.191
+
+# 在本地执行的代码,比如上传文件到服务器 scp 本地文件 user@ip:远程目录
+scp -r dist/* ${remote}:/apps/bainuo/bainuo-model2/static
+
+echo ok

+ 1 - 0
config/config.ts

@@ -8,6 +8,7 @@ const { winPath } = utils; // preview.pro.ant.design only do not use in your pro
 
 const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, REACT_APP_ENV, GA_KEY } = process.env;
 export default defineConfig({
+  history: { type: 'hash' }, // 默认是 browser
   hash: true,
   antd: {},
   analytics: GA_KEY

+ 20 - 11
src/pages/ModelList/index.tsx

@@ -4,9 +4,9 @@ import React, {useRef, useState} from 'react';
 import {PageHeaderWrapper} from '@ant-design/pro-layout';
 import ProTable, {ActionType, ProColumns} from '@ant-design/pro-table';
 import {SorterResult} from 'antd/es/table/interface';
+import QueryForm from '@/pages/ModelList/components/QueryForm';
 import {TableListItem} from './data.d';
 import service from './service';
-import QueryForm from '@/pages/ModelList/components/QueryForm';
 
 /**
  * 添加节点
@@ -15,10 +15,15 @@ import QueryForm from '@/pages/ModelList/components/QueryForm';
 const handleAdd = async (fields: TableListItem) => {
   const hide = message.loading('正在添加');
   try {
-    await service.addModel({...fields});
+    const res = await service.addModel({...fields});
     hide();
-    message.success('添加成功');
-    return true;
+    if (res.success) {
+      message.success('添加成功');
+      return true;
+    }
+    message.error('添加失败请重试!');
+    return false;
+
   } catch (error) {
     hide();
     message.error('添加失败请重试!');
@@ -33,10 +38,14 @@ const handleAdd = async (fields: TableListItem) => {
 const handleUpdate = async (fields: TableListItem) => {
   const hide = message.loading('正在配置');
   try {
-    await service.updateModel(fields);
+    const res = await service.updateModel(fields);
     hide();
-    message.success('配置成功');
-    return true;
+    if (res.success) {
+      message.success('配置成功');
+      return true;
+    }
+    message.error('配置失败请重试!');
+    return false;
   } catch (error) {
     hide();
     message.error('配置失败请重试!');
@@ -308,12 +317,12 @@ const TableList: React.FC<{}> = () => {
         <ProTable<TableListItem, TableListItem>
           onSubmit={async (value) => {
             let success = false;
-            if (!value.id) {
-              success = await handleAdd(value);
-            } else {
+            if ('id' in formValues) {
+              value['id'] = formValues['id']
               success = await handleUpdate(value);
+            } else {
+              success = await handleAdd(value);
             }
-
             if (success) {
               setModalVisible(false);
               if (actionRef.current) {