sr %!s(int64=4) %!d(string=hai) anos
pai
achega
6b443e3431

+ 23 - 30
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.TypeReference;
 import com.boman.common.core.constant.GenConstants;
 import com.boman.common.core.utils.DateUtils;
 import com.boman.common.core.utils.SecurityUtils;
+import com.boman.common.core.utils.array.ArrayUtils;
 import com.boman.common.core.utils.collection.CollectionUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.common.core.web.domain.AjaxResult;
@@ -16,7 +17,6 @@ import com.boman.domain.SysDictData;
 import com.boman.domain.constant.*;
 import com.boman.gen.api.RemoteGenTableColumnService;
 import com.boman.gen.api.RemoteGenTableService;
-//import com.boman.gen.controller.MyController;
 import com.boman.domain.GenTable;
 import com.boman.domain.GenTableColumn;
 import com.boman.system.api.RemoteDictDataService;
@@ -31,6 +31,7 @@ import com.boman.web.core.utils.IdUtils;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.math.NumberUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
@@ -88,6 +89,8 @@ public class TableServiceCmdService {
         checkColumn(commitData, context.getColumns());
         // 必填项
         handlerRequired(commitData, context.getColumns());
+        // 处理输入类型
+        handlerInputType(commitData, context.getColumns());
 
         // 新增
         if (ActionType.INSERT.equals(context.getActionType())) {
@@ -114,6 +117,22 @@ public class TableServiceCmdService {
 
     }
 
+    private void handlerInputType(JSONObject commitData, List<GenTableColumn> columns) {
+        for (Map.Entry<String, Object> entry : commitData.entrySet()) {
+            Object value =entry.getValue();
+            for (GenTableColumn column : columns) {
+                if (entry.getKey().equals(column.getColumnName())
+                        && ArrayUtils.arraysContains(GenConstants.COLUMNTYPE_NUMBER, getDbType(column.getColumnType()))) {
+                    if ((value instanceof Number)) {
+                        // ignore 这里的if不能删掉,因为else if有一个强转
+                    } else if (!NumberUtils.isCreatable(((String) value))) {
+                        throw new IllegalArgumentException(column.getColumnComment() + "只能输入数字");
+                    }
+                }
+            }
+        }
+    }
+
     private void handlerRequired(JSONObject commitData, List<GenTableColumn> columns) {
         for (GenTableColumn column : columns) {
             if (GenTableColumn.IS_REQUIRED.equalsIgnoreCase(column.getIsRequired())) {
@@ -272,33 +291,6 @@ public class TableServiceCmdService {
                     jsonObject.put(SINGLE_OBJ_NAME, primaryTableFkValue);
                     jsonObject.put(SINGLE_OBJ_VALUE, value);
                     json.put(selfColumnName.toLowerCase(), jsonObject);
-
-
-                    // method();=> fkTableName、fkColumnName
-                    // 外键在table_column中的id
-//                    Long fkColumnId = Long.parseLong(column.getForeignKey());
-//                    GenTableColumn fkTableColumn = remoteGenTableColumnService.getById(fkColumnId);
-//                    String fkColumnName = fkTableColumn.getColumnName();
-//                    Long fkTableId = fkTableColumn.getTableId();
-//                    GenTable fkGenTable = remoteGenTableService.getByTableId(fkTableId);
-//                    // 显示键 table_column 表的id
-//                    Long dkColumnId = fkGenTable.getDkColumn();
-//                    GenTableColumn dkTableColumn = remoteGenTableColumnService.getById(dkColumnId);
-//                    String dkColumnName = dkTableColumn.getColumnName();
-//                    String fkTableName = fkGenTable.getTableName();
-//                    Object primaryTableFkValue = json.get(selfColumnName);
-//                    // "DEPT_ID": {"value": 104, "name": "开发部"}
-//                    JSONObject param = new JSONObject();
-//                    param.put(fkColumnName, primaryTableFkValue);
-//                    List<JSONObject> fkList = selectService.getByMap(fkTableName, param);
-//
-//                    for (JSONObject object : fkList) {
-//                        Object value = object.get(dkColumnName);
-//                        jsonObject.put(SINGLE_OBJ_NAME, primaryTableFkValue);
-//                        jsonObject.put(SINGLE_OBJ_VALUE, value);
-//                        json.put(selfColumnName.toLowerCase(), jsonObject);
-//                        break;
-//                    }
                 }
             }
         }
@@ -462,7 +454,7 @@ public class TableServiceCmdService {
     /**
      * 功能描述: 获取表单查询字段、按钮、表头
      * 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
-     * 刷新的入口为 {@link MyController#loadTable(GenTable)}
+     *
      * <p>
      * eg:{
      * "table": "sys_config",
@@ -498,13 +490,14 @@ public class TableServiceCmdService {
         jsonObject.put(FormDataConstant.BUTTON_LIST, Strings.nullToEmpty(genTable.getMenuRole()));
 
         jsonObject.put(ViewConst.VIEW_TYPE, Strings.nullToEmpty(genTable.getTplCategory()));
+        jsonObject.put(RULES, packRequireColumn(columns));
         return AjaxResult.success(jsonObject);
     }
 
     /**
      * 功能描述: 获取表单查询字段
      * 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
-     * 刷新的入口为 {@link MyController#loadTable(GenTable)}
+     *
      * <p>
      * eg:{
      * "table": "sys_config"

+ 15 - 0
boman-web-core/src/main/java/com/boman/web/core/utils/ColumnUtils.java

@@ -3,6 +3,7 @@ package com.boman.web.core.utils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.SecurityUtils;
+import com.boman.common.core.utils.StringUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.domain.GenTableColumn;
 import com.boman.domain.exception.UnknownColumnException;
@@ -280,4 +281,18 @@ public class ColumnUtils {
         requireNonNull(columns, "columns is empty");
         return filter(columns, col -> !HR.equalsIgnoreCase(col.getHtmlType()));
     }
+
+    /**
+     * varchar(20) => varchar
+     *
+     * @param columnType 列类型
+     * @return 截取后的列类型
+     */
+    public static String getDbType(String columnType) {
+        if (StringUtils.indexOf(columnType, "(") > 0) {
+            return StringUtils.substringBefore(columnType, "(");
+        } else {
+            return columnType;
+        }
+    }
 }

+ 19 - 1
ruoyi-ui/src/App.vue

@@ -1,12 +1,30 @@
 <template>
   <div id="app">
-    <router-view />
+    <router-view v-if="isRouterAlive"/>
   </div>
 </template>
 
 <script>
 export default  {
   name:  'App',
+  provide () {
+    return{
+      reload: this.reload
+    }
+  },
+  data() {
+    return {
+        isRouterAlive: true
+    }
+  },
+  methods:{
+    reload(){
+      this.isRouterAlive = false
+      this.$nextTick(function(){
+        this.isRouterAlive = true
+      })
+    }
+  }
 }
 </script>
 <style>

+ 2 - 2
ruoyi-ui/src/settings.js

@@ -1,10 +1,10 @@
 module.exports = {
   title: '潜山市云数据中心',
   // urls: `http://192.168.101.11:8090`,
-  urls: `http://192.168.101.110:8090`,
+  // urls: `http://192.168.101.110:8090`,
   // urls: `http://192.168.101.49:8080`,
 
-  // urls: ``,
+  urls: ``,
 
   /**
    * 侧边栏主题 深色主题theme-dark,浅色主题theme-light

+ 25 - 15
ruoyi-ui/src/views/system/table/index.vue

@@ -33,7 +33,8 @@
     delMenutab
   } from '@/api/system/table.js'
   export default {
-    name: "index",
+    name: "index",
+    inject: ['reload'],
     data() {
       return {
         // 显示搜索条件
@@ -79,7 +80,7 @@
         },
         jeigneu:[],
         jeigneutwo:[],
-        xidugje:'保存',
+        xidugje:0,
         tijeq:0
       };
     },
@@ -182,16 +183,22 @@
              path: '/business/table',
              query: {id:-1,tables:this.forme.table},
            })
-          // this.forme.objId = "-1"
-          this.xidugje = '新增'
-          this.tableZbie.fixedData.id = -1
-          this.formy.id = '-1'
-          this.init()
+          // // this.forme.objId = "-1"
+          //  this.queryParams = {}
+          this.xidugje = 0
+          // this.tableZbie.fixedData.id = -1
+          // this.formy.id = '-1'
+          // this.init()
+          this.reload()
          }else if(index == '返回'){
-           this.$router.go(-1)
+           if(this.xidugje ==0){
+              this.$router.go(-2)
+           }else{
+             this.$router.go(-1)
+           }
          }else if(index == '刷新'){
-           this.xidugje = '刷新'
-           this.init()
+           this.xidugje = 1
+           this.reload()
          }
 
 
@@ -206,6 +213,7 @@
           this.tableZbie
         ).then(res => {
           let data = res.data
+          console.log(res.data)
           this.queryData = {}
           this.queryData = data
           this.jeigneutwo = []
@@ -255,6 +263,7 @@
           this.jeigneutwo.push('刷新')
           this.jeigneutwo.push('返回')
           console.log(this.jeigneutwo,567)
+          console.log(this.xidugje)
           if(this.xidugje == '刷新'){
             if(res.code == 200){
               this.msgSuccess("操作成功");
@@ -288,11 +297,12 @@
               addbjectSave(this.forme).then(response => {
                 this.msgSuccess("保存成功");
                 this.open = false;
-                if(this.xidugje =="新增"){
-                   this.$router.go(-2)
-                }else{
-                  this.$router.go(-1)
-                }
+                console.log(this.xidugje)
+                // if(this.xidugje =="新增"){
+                //    this.$router.go(-2)
+                // }else{
+                  this.$router.replace('surface')
+                // }
 
                 // this.getList();
               });