Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master'

Administrator 4 жил өмнө
parent
commit
0b7c3337e5

+ 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,7 +1,7 @@
 module.exports = {
   title: '潜山市云数据中心',
-  urls: `http://192.168.101.11:8090`,
-  // urls: `http://192.168.101.110:8090`,
+  // urls: `http://192.168.101.11:8090`,
+  urls: `http://192.168.101.110:8090`,
   // urls: `http://192.168.101.49:8080`,
 
   // urls: ``,

+ 70 - 37
ruoyi-ui/src/views/system/table/index.vue

@@ -4,7 +4,7 @@
       <!-- <p>单表</p>
       <el-divider></el-divider> -->
       <div class="table_headerBtun" v-if="queryData.buttonList">
-        <el-button type="primary" size="small"  plain v-for="(item,index) in jeigneutwo" :key="index" @click="handleQuery(item)">{{item }}</el-button>
+        <el-button type="primary" size="mini"  plain v-for="(item,index) in jeigneutwo" :key="index" @click="handleQuery(item)">{{item }}</el-button>
       </div>
     </div>
     <!-- 内容 -->
@@ -33,7 +33,8 @@
     delMenutab
   } from '@/api/system/table.js'
   export default {
-    name: "index",
+    name: "index",
+    inject: ['reload'],
     data() {
       return {
         // 显示搜索条件
@@ -78,31 +79,33 @@
           idList:[]
         },
         jeigneu:[],
-        jeigneutwo:[]
+        jeigneutwo:[],
+        xidugje:0,
+        tijeq:0
       };
     },
-    filters:{
-      btnConversion(val) {
-        switch(val){
-          case 'A':
-          return '保存';
-          case 'M':
-          return '保存';
-          case 'D':
-          return '删除';
-          case 'Q':
-          return '查询';
-          case 'S':
-          return '提交';
-          case 'U':
-          return '反提交';
-          case 'I':
-          return '导入';
-          case 'E':
-          return '导出';
-        }
-      }
-    },
+    // filters:{
+    //   btnConversion(val) {
+    //     switch(val){
+    //       case 'A':
+    //       return '保存';
+    //       case 'M':
+    //       return '保存';
+    //       case 'D':
+    //       return '删除';
+    //       case 'Q':
+    //       return '查询';
+    //       case 'S':
+    //       return '提交';
+    //       case 'U':
+    //       return '反提交';
+    //       case 'I':
+    //       return '导入';
+    //       case 'E':
+    //       return '导出';
+    //     }
+    //   }
+    // },
     mounted() {
       // this.tableZbie.fixedData.id = 0
        this.deledlid.idList = []
@@ -114,7 +117,7 @@
        this.tableZbie.fixedData.id = this.$route.query.id
        this.formy.id = this.$route.query.id
        this.deledlid.table = this.$route.query.tables
-       this.deledlid.idList.push(this.$route.query.tables)
+       this.deledlid.idList.push(this.$route.query.id)
        console.log(this.$route.query.id)
        console.log(this.tableZbie.table)
 
@@ -172,6 +175,7 @@
            this.antiSubmission()
          }else if(index == '保存'){
            // 修改
+           // this.xidugje = '保存'
            this.forme.fixedData = this.queryParams
            this.submitForm()
          }else if(index == '新增'){
@@ -180,13 +184,24 @@
              path: '/business/table',
              query: {id:-1,tables:this.forme.table},
            })
-           this.$router.go(0)
+          // // 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.$router.go(0)
+           this.xidugje = 1
+           this.reload()
          }
-         
+
 
         console.log(this.forme)
         // this.getList();
@@ -194,16 +209,21 @@
       getList() {
 
       },
-      init() {
+      init() {
+
         getTableQuery(
           this.tableZbie
         ).then(res => {
-          let data = res.data
+          let data = res.data
+          console.log(res.data)
+          this.queryData = {}
           this.queryData = data
           this.jeigneutwo = []
-          this.queryData.jeigneu = data.buttonList.split('')
-          console.log(this.queryData.jeigneu)
-          this.queryData.jeigneu.filter(route => {
+          this.jeigneu = []
+          this.jeigneu = data.buttonList.split('')
+          console.log(data.buttonList)
+          console.log(this.jeigneu)
+          this.jeigneu.filter(route => {
             // route.dept_id = route.dept_id.value
             console.log(route)
             if(route == 'A'){
@@ -244,7 +264,14 @@
           })
           this.jeigneutwo.push('刷新')
           this.jeigneutwo.push('返回')
-          console.log(this.jeigneutwo,567)
+          console.log(this.jeigneutwo,567)
+          console.log(this.xidugje)
+          if(this.xidugje == '刷新'){
+            if(res.code == 200){
+              this.msgSuccess("操作成功");
+            }
+          }
+
         })
       },
       tablsie(){
@@ -272,7 +299,13 @@
               addbjectSave(this.forme).then(response => {
                 this.msgSuccess("保存成功");
                 this.open = false;
-                this.$router.go(-1)
+                console.log(this.xidugje)
+                // if(this.xidugje =="新增"){
+                //    this.$router.go(-2)
+                // }else{
+                  this.$router.go(-1)
+                // }
+
                 // this.getList();
               });
       },