浏览代码

修复数据建模查询、分页bug。表单、数据表添加修改完成关闭当前tab页面。优化切换数据源下发ip配置文件统一管理。重写创建数据表非空校验逻辑。

韩帛霖 2 年之前
父节点
当前提交
4ef6485288

+ 26 - 22
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java

@@ -3,15 +3,12 @@ package com.ruoyi.web.controller.system;
 import java.util.List;
 import java.util.Set;
 
-import com.alibaba.fastjson2.JSON;
-import com.ruoyi.common.constant.IpConstants;
 import com.ruoyi.common.core.domain.entity.DataSource;
 import com.ruoyi.common.core.domain.entity.SysTenant;
-import com.ruoyi.common.utils.http.HttpUtils;
 import com.ruoyi.system.service.IDataSourceService;
 import com.ruoyi.system.service.impl.SysTenantServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -31,12 +28,11 @@ import javax.annotation.Resource;
 
 /**
  * 登录验证
- * 
+ *
  * @author ruoyi
  */
 @RestController
-public class SysLoginController
-{
+public class SysLoginController {
     @Autowired
     private SysLoginService loginService;
 
@@ -52,19 +48,29 @@ public class SysLoginController
     @Resource
     private IDataSourceService dataSourceService;
 
-    RestTemplate restTemplate = new RestTemplate();
+    /**
+     * 数据引擎切换数据源接口地址
+     */
+    @Value("${parameter.ip.DATA_ENGINE_IP}")
+    public String DATA_ENGINE_IP;
 
+    /**
+     * 动态表单切换数据源接口地址
+     */
+    @Value("${parameter.ip.DRAG_FORM_IP}")
+    public String DRAG_FORM_IP;
+
+    RestTemplate restTemplate = new RestTemplate();
 
 
     /**
      * 登录方法
-     * 
+     *
      * @param loginBody 登录信息
      * @return 结果
      */
     @PostMapping("/login")
-    public AjaxResult login(@RequestBody LoginBody loginBody)
-    {
+    public AjaxResult login(@RequestBody LoginBody loginBody) {
         AjaxResult ajax = AjaxResult.success();
         // 生成令牌
         String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
@@ -75,12 +81,11 @@ public class SysLoginController
 
     /**
      * 获取用户信息
-     * 
+     *
      * @return 用户信息
      */
     @GetMapping("getInfo")
-    public AjaxResult getInfo()
-    {
+    public AjaxResult getInfo() {
         SysUser user = SecurityUtils.getLoginUser().getUser();
         // 角色集合
         Set<String> roles = permissionService.getRolePermission(user);
@@ -91,29 +96,28 @@ public class SysLoginController
         ajax.put("roles", roles);
         ajax.put("permissions", permissions);
         //租户信息
-        if(user.getTenantId() != null){
+        if (user.getTenantId() != null) {
             //租户信息
             SysTenant sysTenant = sysTenantService.selectSysTenantByTenantId(user.getTenantId());
-            ajax.put("tenant",sysTenant);
+            ajax.put("tenant", sysTenant);
             //数据源信息
             DataSource dataSource = dataSourceService.selectById(sysTenant.getDatasourceId());
-            ajax.put("dataSource",dataSource);
+            ajax.put("dataSource", dataSource);
             //调用数据引擎服务切换数据源接口
-            restTemplate.postForEntity(IpConstants.DATA_ENGINE_IP, dataSource, DataSource.class);
+            restTemplate.postForEntity(DATA_ENGINE_IP, dataSource, DataSource.class);
             //调用表单引擎服务切换数据源接口
-            restTemplate.postForEntity(IpConstants.DRAG_FORM_IP, dataSource, DataSource.class);
+            restTemplate.postForEntity(DRAG_FORM_IP, dataSource, DataSource.class);
         }
         return ajax;
     }
 
     /**
      * 获取路由信息
-     * 
+     *
      * @return 路由信息
      */
     @GetMapping("getRouters")
-    public AjaxResult getRouters()
-    {
+    public AjaxResult getRouters() {
         Long userId = SecurityUtils.getUserId();
         List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
         return AjaxResult.success(menuService.buildMenus(menus));

+ 32 - 24
ruoyi-admin/src/main/resources/application.yml

@@ -53,15 +53,15 @@ spring:
   messages:
     # 国际化资源文件路径
     basename: i18n/messages
-  profiles: 
+  profiles:
     active: druid
   # 文件上传
   servlet:
-     multipart:
-       # 单个文件大小
-       max-file-size:  10MB
-       # 设置总上传的文件大小
-       max-request-size:  20MB
+    multipart:
+      # 单个文件大小
+      max-file-size: 10MB
+      # 设置总上传的文件大小
+      max-request-size: 20MB
   # 服务模块
   devtools:
     restart:
@@ -70,13 +70,13 @@ spring:
   # redis 配置
   redis:
     # 地址
-    host: localhost
+    host: 192.168.110.15
     # 端口,默认为6379
     port: 6379
     # 数据库索引
     database: 0
     # 密码
-    password: 
+    password:
     # 连接超时时间
     timeout: 10s
     lettuce:
@@ -92,27 +92,27 @@ spring:
 
 # token配置
 token:
-    # 令牌自定义标识
-    header: Authorization
-    # 令牌密钥
-    secret: abcdefghijklmnopqrstuvwxyz
-    # 令牌有效期(默认30分钟)
-    expireTime: 30
-  
+  # 令牌自定义标识
+  header: Authorization
+  # 令牌密钥
+  secret: abcdefghijklmnopqrstuvwxyz
+  # 令牌有效期(默认30分钟)
+  expireTime: 30
+
 # MyBatis配置
 mybatis:
-    # 搜索指定包别名
-    typeAliasesPackage: com.ruoyi.**.domain
-    # 配置mapper的扫描,找到所有的mapper.xml映射文件
-    mapperLocations: classpath*:mapper/**/*Mapper.xml
-    # 加载全局的配置文件
-    configLocation: classpath:mybatis/mybatis-config.xml
+  # 搜索指定包别名
+  typeAliasesPackage: com.ruoyi.**.domain
+  # 配置mapper的扫描,找到所有的mapper.xml映射文件
+  mapperLocations: classpath*:mapper/**/*Mapper.xml
+  # 加载全局的配置文件
+  configLocation: classpath:mybatis/mybatis-config.xml
 
 # PageHelper分页插件
-pagehelper: 
+pagehelper:
   helperDialect: mysql
   supportMethodsArguments: true
-  params: count=countSql 
+  params: count=countSql
 
 # Swagger配置
 swagger:
@@ -122,10 +122,18 @@ swagger:
   pathMapping: /dev-api
 
 # 防止XSS攻击
-xss: 
+xss:
   # 过滤开关
   enabled: true
   # 排除链接(多个用逗号分隔)
   excludes: /system/notice
   # 匹配链接
   urlPatterns: /system/*,/monitor/*,/tool/*
+
+# 参数配置项
+parameter:
+  ip:
+    # 数据引擎切换数据源接口地址
+    DATA_ENGINE_IP: http://192.168.110.59:8088/dataSource/changeDataSource
+    # 动态表单切换数据源接口地址
+    DRAG_FORM_IP: http://192.168.110.59:8099/dataSource/changeDataSource

+ 0 - 21
ruoyi-common/src/main/java/com/ruoyi/common/constant/IpConstants.java

@@ -1,21 +0,0 @@
-package com.ruoyi.common.constant;
-
-/**
- * 其他服务IP地址常量信息
- *
- * @author ruoyi
- */
-public class IpConstants {
-
-    /**
-     * 数据引擎切换数据源接口地址
-     */
-    public static final String DATA_ENGINE_IP = "http://192.168.110.52:8099/dataSource/changeDataSource";
-
-    /**
-     * 动态表单切换数据源接口地址
-     */
-    public static final String DRAG_FORM_IP = "http://192.168.110.59:8088/dataSource/changeDataSource";
-
-
-}

+ 228 - 225
ruoyi-ui/src/views/dataEngine/datamodeling/editTable.vue

@@ -1,239 +1,242 @@
 <template>
-    <div class="app-container">
-        <el-card style="margin-bottom: 15px;">
-            <el-form ref="form" :model="form" label-width="100px">
-                <!-- <el-form-item label="数据库名称">
-                    <el-input v-model="form.dataBaseName" style="width: 600px;"></el-input>
-                </el-form-item> -->
-                <el-form-item label="数据表名称">
-                    <el-input v-model="form.tableName" style="width: 600px;" :disabled="true"></el-input>
-                </el-form-item>
-                <el-form-item label="表描述">
-                    <el-input v-model="form.tableComment" style="width: 600px;"></el-input>
-                </el-form-item>
-            </el-form>
-        </el-card>
-        <el-card>
-            <div class="titleitem">
-                <span>数据表字段</span>
-            </div>
-            <el-table :data="experienceData" stripe style="width: 100%">
-                <el-table-column prop="fieldName" label="字段名称" width="200">
-                    <template slot-scope="scope">
-                        <el-input v-model="scope.row.fieldName"></el-input>
-                    </template>
-                </el-table-column>
-
-                <el-table-column prop="fieldType" label="字段类型" width="200">
-                    <template slot-scope="scope">
-                        <el-select v-model="scope.row.fieldType">
-                            <el-option label="int" value="int"></el-option>
-                            <el-option label="varchar" value="varchar"></el-option>
-                        </el-select>
-                    </template>
-
-                </el-table-column>
-
-                <el-table-column prop="fieldLength" label="长度" width="200">
-                    <template slot-scope="scope">
-                        <el-input v-model="scope.row.fieldLength"></el-input>
-                    </template>
-                </el-table-column>
-
-                <!-- <el-table-column prop="isNull" label="不是null" width="200">
-                    <template slot-scope="scope">
-                        <el-radio-group v-model="scope.row.isNull">
-                            <el-radio :label="true">是</el-radio>
-                            <el-radio :label="false">否</el-radio>
-                        </el-radio-group>
-                    </template>
-                </el-table-column>
-
-
-
-                <el-table-column prop="isPrimary" label="键" width="200">
-                    <template slot-scope="scope">
-                        <el-radio-group v-model="scope.row.isPrimary">
-                            <el-radio :label="true">是</el-radio>
-                            <el-radio :label="false">否</el-radio>
-                        </el-radio-group>
-                    </template>
-                </el-table-column>
-
-                <el-table-column prop="isAuto" label="自增" width="200">
-                    <template slot-scope="scope">
-                        <el-radio-group v-show="scope.row.isPrimary" v-model="scope.row.isAuto">
-                            <el-radio :label="true">是</el-radio>
-                            <el-radio :label="false">否</el-radio>
-                        </el-radio-group>
-                    </template>
-                </el-table-column> -->
-
-                <el-table-column prop="isNull" label="不是null" width="100">
-                    <template slot-scope="scope">
-                        <!-- <el-radio-group v-model="scope.row.isNull">
-                            <el-radio :label="true">是</el-radio>
-                            <el-radio :label="false">否</el-radio>
-                        </el-radio-group> -->
-                        <el-checkbox v-model="scope.row.isNull"></el-checkbox>
-                    </template>
-                </el-table-column>
-
-
-                <el-table-column prop="isPrimary" label="键" width="100">
-                    <template slot-scope="scope">
-                        <!-- <el-radio-group v-model="scope.row.isPrimary">
-                            <el-radio :label="true">是</el-radio>
-                            <el-radio :label="false">否</el-radio>
-                        </el-radio-group> -->
-
-                        <!-- <span v-if="scope.$index == 0"></span> -->
-                        <el-checkbox v-model="scope.row.isPrimary" @change="hanleCheckbox(scope.$index)"></el-checkbox>
-                    </template>
-                </el-table-column>
-
-                <el-table-column prop="isAuto" label="自增" width="100">
-                    <template slot-scope="scope">
-                        <!-- <el-radio-group v-show="scope.row.isPrimary" v-model="scope.row.isAuto">
-                            <el-radio :label="true">是</el-radio>
-                            <el-radio :label="false">否</el-radio>
-                        </el-radio-group> -->
-                        <el-checkbox v-model="scope.row.isAuto"></el-checkbox>
-                    </template>
-                </el-table-column>
-
-                <el-table-column prop="fieldDescription" label="字段描述" width="200">
-                    <template slot-scope="scope">
-                        <el-input v-model="scope.row.fieldDescription"></el-input>
-                    </template>
-                </el-table-column>
-                <el-table-column prop="operate" label="操作">
-                    <template slot-scope="scope">
-                        <el-button size="mini" type="success" icon="el-icon-save"
-                            @click="handlesaveExperience(scope.$index, scope.row)">保存
-                        </el-button>
-                        <el-button size="mini" type="danger" icon="el-icon-delete"
-                            @click="handleDeleteExperience(scope.$index, scope.row)">删除
-                        </el-button>
-
-                    </template>
-                </el-table-column>
-            </el-table>
-            <div>
-                <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddExperienceline">新增字段
-                </el-button>
-            </div>
-        </el-card>
-
-        <div style="margin-top: 15px;">
-            <el-button @click="edit" type="primary">修改</el-button>
-        </div>
+  <div class="app-container">
+    <el-card style="margin-bottom: 15px;">
+      <el-form ref="form" :model="form" label-width="100px">
+        <!-- <el-form-item label="数据库名称">
+            <el-input v-model="form.dataBaseName" style="width: 600px;"></el-input>
+        </el-form-item> -->
+        <el-form-item label="数据表名称">
+          <el-input v-model="form.tableName" style="width: 600px;" :disabled="true"></el-input>
+        </el-form-item>
+        <el-form-item label="表描述">
+          <el-input v-model="form.tableComment" style="width: 600px;"></el-input>
+        </el-form-item>
+      </el-form>
+    </el-card>
+    <el-card>
+      <div class="titleitem">
+        <span>数据表字段</span>
+      </div>
+      <el-table :data="experienceData" stripe style="width: 100%">
+        <el-table-column prop="fieldName" label="字段名称" width="200">
+          <template slot-scope="scope">
+            <el-input v-model="scope.row.fieldName"></el-input>
+          </template>
+        </el-table-column>
+
+        <el-table-column prop="fieldType" label="字段类型" width="200">
+          <template slot-scope="scope">
+            <el-select v-model="scope.row.fieldType">
+              <el-option label="int" value="int"></el-option>
+              <el-option label="varchar" value="varchar"></el-option>
+            </el-select>
+          </template>
+
+        </el-table-column>
+
+        <el-table-column prop="fieldLength" label="长度" width="200">
+          <template slot-scope="scope">
+            <el-input v-model="scope.row.fieldLength"></el-input>
+          </template>
+        </el-table-column>
+
+        <!-- <el-table-column prop="isNull" label="不是null" width="200">
+            <template slot-scope="scope">
+                <el-radio-group v-model="scope.row.isNull">
+                    <el-radio :label="true">是</el-radio>
+                    <el-radio :label="false">否</el-radio>
+                </el-radio-group>
+            </template>
+        </el-table-column>
+
+
+
+        <el-table-column prop="isPrimary" label="键" width="200">
+            <template slot-scope="scope">
+                <el-radio-group v-model="scope.row.isPrimary">
+                    <el-radio :label="true">是</el-radio>
+                    <el-radio :label="false">否</el-radio>
+                </el-radio-group>
+            </template>
+        </el-table-column>
+
+        <el-table-column prop="isAuto" label="自增" width="200">
+            <template slot-scope="scope">
+                <el-radio-group v-show="scope.row.isPrimary" v-model="scope.row.isAuto">
+                    <el-radio :label="true">是</el-radio>
+                    <el-radio :label="false">否</el-radio>
+                </el-radio-group>
+            </template>
+        </el-table-column> -->
+
+        <el-table-column prop="isNull" label="不是null" width="100">
+          <template slot-scope="scope">
+            <!-- <el-radio-group v-model="scope.row.isNull">
+                <el-radio :label="true">是</el-radio>
+                <el-radio :label="false">否</el-radio>
+            </el-radio-group> -->
+            <el-checkbox v-model="scope.row.isNull"></el-checkbox>
+          </template>
+        </el-table-column>
+
+
+        <el-table-column prop="isPrimary" label="键" width="100">
+          <template slot-scope="scope">
+            <!-- <el-radio-group v-model="scope.row.isPrimary">
+                <el-radio :label="true">是</el-radio>
+                <el-radio :label="false">否</el-radio>
+            </el-radio-group> -->
+
+            <!-- <span v-if="scope.$index == 0"></span> -->
+            <el-checkbox v-model="scope.row.isPrimary" @change="hanleCheckbox(scope.$index)"></el-checkbox>
+          </template>
+        </el-table-column>
+
+        <el-table-column prop="isAuto" label="自增" width="100">
+          <template slot-scope="scope">
+            <!-- <el-radio-group v-show="scope.row.isPrimary" v-model="scope.row.isAuto">
+                <el-radio :label="true">是</el-radio>
+                <el-radio :label="false">否</el-radio>
+            </el-radio-group> -->
+            <el-checkbox v-model="scope.row.isAuto"></el-checkbox>
+          </template>
+        </el-table-column>
+
+        <el-table-column prop="fieldDescription" label="字段描述" width="200">
+          <template slot-scope="scope">
+            <el-input v-model="scope.row.fieldDescription"></el-input>
+          </template>
+        </el-table-column>
+        <el-table-column prop="operate" label="操作">
+          <template slot-scope="scope">
+            <el-button size="mini" type="success" icon="el-icon-save"
+                       @click="handlesaveExperience(scope.$index, scope.row)">保存
+            </el-button>
+            <el-button size="mini" type="danger" icon="el-icon-delete"
+                       @click="handleDeleteExperience(scope.$index, scope.row)">删除
+            </el-button>
+
+          </template>
+        </el-table-column>
+      </el-table>
+      <div>
+        <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddExperienceline">新增字段
+        </el-button>
+      </div>
+    </el-card>
+
+    <div style="margin-top: 15px;">
+      <el-button @click="edit" type="primary">修改</el-button>
     </div>
+  </div>
 </template>
 
 <script>
-import { tableInfo, editTable } from '@/api/dataEngine/index'
+import {tableInfo, editTable} from '@/api/dataEngine/index'
+
 export default {
-    name: "Datasheet",
-    data() {
-        return {
-            form: {
-                dataBaseName: '',
-                tableName: '',
-                tableComment: '',
-            },
-            experienceData: [],
-            dataBase: {}
+  name: "Datasheet",
+  data() {
+    return {
+      form: {
+        dataBaseName: '',
+        tableName: '',
+        tableComment: '',
+      },
+      experienceData: [],
+      dataBase: {}
 
+    }
+  },
+  created() {
+    this.info()
+  },
+  methods: {
+    hanleCheckbox(ind) {
+      this.experienceData.forEach((item, index) => {
+        if (index != ind) {
+          item.isPrimary = false;
+        }
+        if (index == ind) {
+          item.isNull = true
         }
+
+      })
+    },
+    //增加经验行
+    handleAddExperienceline() {
+      if (this.experienceData == undefined) {
+        this.experienceData = new Array();
+      }
+      let obj = {
+        fieldName: '',
+        fieldType: '',
+        fieldLength: undefined,
+        isNull: false,
+        isPrimary: false,
+        fieldDescription: '',
+        isAuto: false
+      };
+
+      this.experienceData.push(obj);
     },
-    created() {
-        this.info()
+    //保存经验行
+    handlesaveExperience(a, b) {
+      console.log(a + b);
+      console.log(b);
     },
-    methods: {
-        hanleCheckbox(ind) {
-            this.experienceData.forEach((item, index) => {
-                if (index != ind) {
-                    item.isPrimary = false;
-                }
-                if (index == ind) {
-                    item.isNull = true
-                }
-
-            })
-        },
-        //增加经验行
-        handleAddExperienceline() {
-            if (this.experienceData == undefined) {
-                this.experienceData = new Array();
-            }
-            let obj = {
-                fieldName: '',
-                fieldType: '',
-                fieldLength: undefined,
-                isNull: false,
-                isPrimary: false,
-                fieldDescription: '',
-                isAuto: false
-            };
-
-            this.experienceData.push(obj);
-        },
-        //保存经验行
-        handlesaveExperience(a, b) {
-            console.log(a + b);
-            console.log(b);
-        },
-        //删除经验行
-        handleDeleteExperience(index) {
-            console.log(index);
-            this.experienceData.splice(index, 1)
-        },
-        info() {
-            const tableName = this.$route.query.tableName
-            const tableComment = this.$route.query.tableComment
-
-            let data = {
-                tableName: this.$route.query.tableName,
-                databaseType: this.$store.state.user.dataSource.databaseType,
-                databaseName: this.$store.state.user.dataSource.databaseName,
-            }
-
-            tableInfo(data).then(response => {
-                console.log(response);
-                this.experienceData = response.data
-                this.form.tableName = tableName
-                this.form.tableComment = tableComment
-            });
-        },
-        edit() {
-            this.experienceData.forEach((field) => {
-                if (field.fieldLength) {
-                    field.fieldType = `${field.fieldType}(${field.fieldLength})`
-                }
-            })
-            let query = {
-                databaseType: this.$store.state.user.dataSource.databaseType,
-                databaseName: this.$store.state.user.dataSource.databaseName,
-                tableName: this.form.tableName,
-                tableComment: this.form.tableComment,
-                field: this.experienceData
-            }
-            editTable(query).then(res => {
-
-                this.$modal.msgSuccess(res.msg);
-                if (res.code === 200) {
-                    this.visible = false;
-                    this.$emit("ok");
-                    Object.keys(this.form).forEach(key => (this.form[key] = ''));
-                    this.experienceData = []
-
-                }
-            }).catch(err => {
-                console.log(err);
-            })
+    //删除经验行
+    handleDeleteExperience(index) {
+      console.log(index);
+      this.experienceData.splice(index, 1)
+    },
+    info() {
+      const tableName = this.$route.query.tableName
+      const tableComment = this.$route.query.tableComment
+
+      let data = {
+        tableName: this.$route.query.tableName,
+        databaseType: this.$store.state.user.dataSource.databaseType,
+        databaseName: this.$store.state.user.dataSource.databaseName,
+      }
+
+      tableInfo(data).then(response => {
+        console.log(response);
+        this.experienceData = response.data
+        this.form.tableName = tableName
+        this.form.tableComment = tableComment
+      });
+    },
+    edit() {
+      this.experienceData.forEach((field) => {
+        if (field.fieldLength) {
+          field.fieldType = `${field.fieldType}(${field.fieldLength})`
         }
+      })
+      let query = {
+        databaseType: this.$store.state.user.dataSource.databaseType,
+        databaseName: this.$store.state.user.dataSource.databaseName,
+        tableName: this.form.tableName,
+        tableComment: this.form.tableComment,
+        field: this.experienceData
+      }
+      editTable(query).then(res => {
+
+        this.$modal.msgSuccess(res.msg);
+        if (res.code === 200) {
+          this.visible = false;
+          this.$emit("ok");
+          Object.keys(this.form).forEach(key => (this.form[key] = ''));
+          this.experienceData = []
 
+        }
+      }).catch(err => {
+        console.log(err);
+      })
+      // 关闭当前页面
+      this.$tab.closePage();
     }
+
+  }
 }
-</script>
+</script>

+ 22 - 18
ruoyi-ui/src/views/dataEngine/datamodeling/index.vue

@@ -2,10 +2,12 @@
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="表名称" prop="tableName">
-        <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable @keyup.enter.native="handleQuery" />
+        <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable
+                  @keyup.enter.native="handleQuery"/>
       </el-form-item>
       <el-form-item label="表描述" prop="tableComment">
-        <el-input v-model="queryParams.tableComment" placeholder="请输入表描述" clearable @keyup.enter.native="handleQuery" />
+        <el-input v-model="queryParams.tableComment" placeholder="请输入表描述" clearable
+                  @keyup.enter.native="handleQuery"/>
       </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -21,9 +23,9 @@
     </el-row>
 
     <el-table v-loading="loading" :data="aaaList">
-      <el-table-column label="表名称" align="center" prop="tableName" />
-      <el-table-column label="表描述" align="center" prop="tableComment" />
-      <el-table-column label="创建时间" align="center" prop="createTime" />
+      <el-table-column label="表名称" align="center" prop="tableName"/>
+      <el-table-column label="表描述" align="center" prop="tableComment"/>
+      <el-table-column label="创建时间" align="center" prop="createTime"/>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-dropdown>
@@ -31,10 +33,15 @@
               处理<i class="el-icon-arrow-down el-icon--right"></i>
             </el-button>
             <el-dropdown-menu slot="dropdown">
-              <el-dropdown-item><el-button size="mini" type="text" icon="el-icon-delete"
-                  @click="handleDelete(scope.row)">删除</el-button></el-dropdown-item>
-              <el-dropdown-item><el-button size="mini" type="text" icon="el-icon-edit"
-                  @click="handleUpdate(scope.row)">修改</el-button>
+              <el-dropdown-item>
+                <el-button size="mini" type="text" icon="el-icon-delete"
+                           @click="handleDelete(scope.row)">删除
+                </el-button>
+              </el-dropdown-item>
+              <el-dropdown-item>
+                <el-button size="mini" type="text" icon="el-icon-edit"
+                           @click="handleUpdate(scope.row)">修改
+                </el-button>
               </el-dropdown-item>
             </el-dropdown-menu>
           </el-dropdown>
@@ -46,12 +53,13 @@
     </el-table>
 
     <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
-      @pagination="getList" />
+                @pagination="getList"/>
   </div>
 </template>
 
 <script>
-import { tableInfoList, removeTable } from "@/api/dataEngine/index";
+import {tableInfoList, removeTable} from "@/api/dataEngine/index";
+
 export default {
   name: "dataModeling",
   data() {
@@ -77,12 +85,7 @@ export default {
   methods: {
     getList() {
       this.loading = true;
-      tableInfoList({
-        pageNum: 1,
-        pageSize: 10,
-        databaseType: this.$store.state.user.dataSource.databaseType,
-        databaseName: this.$store.state.user.dataSource.databaseName,
-      }).then((response) => {
+      tableInfoList(this.queryParams).then((response) => {
         this.aaaList = response.data;
         this.total = response.total;
         this.loading = false;
@@ -119,7 +122,8 @@ export default {
           this.getList();
           this.$modal.msgSuccess("删除成功");
         })
-        .catch(() => { });
+        .catch(() => {
+        });
     },
     handleUpdate(row) {
       this.$router.push({

+ 24 - 24
ruoyi-ui/src/views/tool/datasheet/index.vue

@@ -27,13 +27,12 @@
               </el-form-item>
             </template>
           </el-table-column>
-
           <el-table-column prop="fieldType" label="字段类型" width="200">
             <template slot-scope="scope">
               <el-form-item :prop="'fieldType' + scope.$index" :name="'fieldType' + scope.$index"
                             style="margin: 0px;padding: 0px;">
                 <el-select v-model="scope.row.fieldType" filterable @blur="selectBlur(scope)"
-                           @change="testasd(dict.type.mysql_data_type.find(item => item.label === scope.row.fieldType), scope)">
+                           @change="handleSelected(dict.type.mysql_data_type.find(item => item.label === scope.row.fieldType), scope)">
                   <!-- <el-option v-for="item in list" :key="item" :label="item" :value="item">
                   </el-option> -->
                   <!--
@@ -52,7 +51,7 @@
               <el-form-item :prop="'fieldLength' + scope.$index" :name="'fieldLength' + scope.$index"
                             style="margin: 0px;padding: 0px;">
                 <!--                <el-input v-model="scope.row.fieldLength"-->
-                <!--                          :disabled="testasd(dict.type.mysql_data_type.find(item => item.label === scope.row.fieldType), scope)"></el-input>-->
+                <!--                          :disabled="handleSelected(dict.type.mysql_data_type.find(item => item.label === scope.row.fieldType), scope)"></el-input>-->
                 <el-input v-model="scope.row.fieldLength"
                           :disabled="changduclick(scope.$index)"></el-input>
               </el-form-item>
@@ -170,22 +169,20 @@ export default {
     }
   },
   methods: {
-
-
     // 处理长度框是否可输入
     changduclick(inputIndex) {
       return this.Inoputdisabled[inputIndex];
     },
-
-
     // 下拉选中事件  // 处理选中类型后长度输入框是否禁用
-    testasd(tem, scope) {
+    handleSelected(tem, scope) {
       if (tem == undefined) return;
       if (tem.raw.listClass === 'success') {
-        this.Inoputdisabled[scope.$index] = true;
+        this.Inoputdisabled[scope.$index] = true;// 禁用长度输入框
+        this.tableform['fieldLength' + scope.$index].required = false; // 禁用长度输入框的校验
         return this.$set(this.experienceDataForm, "fieldType" + scope.$index, scope.row.fieldType);
       }
-      this.Inoputdisabled[scope.$index] = false;
+      this.Inoputdisabled[scope.$index] = false;// 解除禁用
+      this.tableform['fieldLength' + scope.$index].required = true; // 启用长度输入框的校验
       return this.$set(this.experienceDataForm, "fieldType" + scope.$index, scope.row.fieldType);
     },
 
@@ -198,18 +195,25 @@ export default {
 
 
     // 处理非空校验问题
-    handleRules() {
-      let rulesAdd = {};
-      this.experienceData.forEach((item, index) => {
+    handleRules(type, delindex) {
+      if (type == 'add') {
+        let rulesAdd = {};
+        // 得到添加一行的下标
+        let index = this.experienceData.length - 1;
         rulesAdd['fieldName' + index] = {required: true, message: '请输入字段名称', trigger: 'blur'}
         rulesAdd['fieldType' + index] = {required: true, message: '请选择', trigger: 'blur'}
         rulesAdd['fieldLength' + index] = {required: true, message: '请输入', trigger: 'blur'}
-
+        // 序列化当前校验规则对象
         this.tableform = {
+          ...this.tableform,
           ...rulesAdd
         }
-      })
-      console.log(this.tableform)
+      } else if (type == 'del') {
+        // 删除校验规则对象中的元素
+        this.$delete(this.tableform, 'fieldName' + delindex);
+        this.$delete(this.tableform, 'fieldType' + delindex);
+        this.$delete(this.tableform, 'fieldLength' + delindex);
+      }
     },
     // 处理主键选框问题
     hanleCheckbox(ind) {
@@ -239,7 +243,7 @@ export default {
         isAuto: false
       };
       this.experienceData.push(obj);
-      this.handleRules();
+      this.handleRules('add');
       this.Inoputdisabled.push(false)
     },
     //保存经验行
@@ -249,9 +253,8 @@ export default {
     },
     //删除经验行
     handleDeleteExperience(index) {
-      console.log(index);
       this.experienceData.splice(index, 1)
-      this.handleRules();
+      this.handleRules('del', index);
     },
     add() {
       const rule1 = new Promise((resolve, reject) => {
@@ -272,7 +275,6 @@ export default {
           }
         })
       })
-
       Promise.all([rule1, rule2]).then(() => {
         if (this.experienceData.length == 0) {
           this.$modal.msgWarning("字段不可为空!")
@@ -283,7 +285,6 @@ export default {
             field.fieldType = `${field.fieldType}(${field.fieldLength})`
           }
         })
-
         let query = {
           databaseType: this.$store.state.user.dataSource.databaseType,
           databaseName: this.$store.state.user.dataSource.databaseName,
@@ -292,21 +293,20 @@ export default {
           field: this.experienceData
         }
         createDatabase(query).then(res => {
-
           this.$modal.msgSuccess(res.msg);
           if (res.code === 200) {
             this.visible = false;
             this.$emit("ok");
             Object.keys(this.form).forEach(key => (this.form[key] = ''));
             this.experienceData = []
+            // 新增成功之后关闭当前页面
+            this.$tab.closePage();
           }
         }).catch(err => {
           console.log(err);
         })
       })
     }
-
-
   }
 }
 </script>