瀏覽代碼

Merge remote-tracking branch 'origin/master'

Administrator 4 年之前
父節點
當前提交
3395bb2d52

+ 7 - 1
boman-api/boman-domain/src/main/java/com.boman.domain/constant/FormDataConstant.java

@@ -178,6 +178,12 @@ public class FormDataConstant {
     /** dkColumnName */
     public static final String DK_COLUMN_NAME = "dkColumnName";
 
-
+    /** rules */
+    public static final String RULES = "rules";
+    public static final String TRIGGER = "trigger";
+    public static final String MESSAGE = "message";
+    public static final String PATTERN = "pattern";
+    public static final String BLUR = "blur";
+    public static final String REQUIRED = "required";
 
 }

+ 21 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/array/ArrayUtils.java

@@ -0,0 +1,21 @@
+package com.boman.common.core.utils.array;
+
+import java.util.Arrays;
+
+/**
+ * @author shiqian
+ * @date 2021年04月25日 14:05
+ **/
+public class ArrayUtils extends org.apache.commons.lang3.ArrayUtils {
+
+    /**
+     * 校验数组是否包含指定值
+     *
+     * @param arr         数组
+     * @param targetValue 值
+     * @return 是否包含
+     */
+    public static boolean arraysContains(String[] arr, String targetValue) {
+        return Arrays.asList(arr).contains(targetValue);
+    }
+}

+ 27 - 0
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -754,9 +754,36 @@ public class TableServiceCmdService {
         JSONObject result = new JSONObject();
         result.put(BUTTON_LIST, getButton(tableName));
         result.put(SHOW_DATA, resultCols);
+        result.put(RULES, packRequireColumn(allColumns));
         return AjaxResult.success(result);
     }
 
+    private JSONObject packRequireColumn(List<GenTableColumn> allColumns) {
+        JSONObject jsonObject = new JSONObject();
+        String msg = "请输入正确的";
+        for (GenTableColumn column : allColumns) {
+            ArrayList<JSONObject> list = Lists.newArrayList();
+            if (GenTableColumn.IS_REQUIRED.equals(column.getIsRequired())) {
+                JSONObject inner1 = new JSONObject();
+                inner1.put(TRIGGER, BLUR);
+                inner1.put(MESSAGE, msg + column.getColumnComment());
+                inner1.put(REQUIRED, true);
+                list.add(inner1);
+                if (isNotEmpty(column.getRegular())) {
+                    JSONObject inner2 = new JSONObject();
+                    inner2.put(PATTERN, column.getRegular());
+                    inner2.put(TRIGGER, BLUR);
+                    inner2.put(MESSAGE, msg + column.getColumnComment());
+                    list.add(inner2);
+                }
+
+                jsonObject.put(column.getColumnName(), list);
+            }
+        }
+
+        return jsonObject;
+    }
+
     public void packDictDataToColumns(List<GenTableColumn> columns, Predicate<String> predicate) {
         if (isEmpty(columns)) {
             return;

+ 20 - 12
ruoyi-ui/src/views/tool/gen/editTable.vue

@@ -330,7 +330,7 @@
         </el-form-item>
         <el-form-item label="字段:" prop="relationChildId">
           <el-select style="width: 100%;" v-model="form.relationChildId" placeholder="请选择字段" v-loadmore="loadMore">
-            <el-option v-for="item in genList" :key="item.columnId" :label="item.columnName" :value="item.columnId">
+            <el-option v-for="item in genList" v-if="item.foreignKey" :key="item.columnId" :label="item.columnName" :value="item.columnId">
             </el-option>
           </el-select>
         </el-form-item>
@@ -761,9 +761,12 @@
         getByIdWithForeignKey(id).then(response => {
           let data = response.data
           data.foreignKey = data.foreignKey ? data.foreignKey - 0 : ''
-          this.formZd = data;
-          this.ForeName = data.fkInfo.value
-          this.openZd = true;
+          this.formZd = data;
+          console.log(data,8890)
+          if(data.fkInfo){
+            this.ForeName = data.fkInfo.value
+          }
+          this.openZd = true;
           this.title = "修改字段信息";
         });
       },
@@ -773,10 +776,11 @@
         qurGenTable(id).then(response => {
           let data = response.data
           data.relationType = data.relationType + ""
-          data.embedEdit = data.embedEdit + ""
+          data.embedEdit = data.embedEdit?(data.embedEdit + ""): data.embedEdit
+
           getGenTable(data.relationParentId).then(res => {
             this.genList = res.data.rows;
-            this.form = response.data;
+            this.form = data;
             this.open = true;
             this.title = "修改关联表";
           });
@@ -784,15 +788,17 @@
       },
       addGlfn() {
         this.$refs["form"].validate(valid => {
-          if (valid) {
-            if (this.form.id != undefined) {
-              setGenTable(this.form).then(response => {
+          if (valid) {
+            let datas = JSON.parse(JSON.stringify(this.form))
+            datas.relationParentId = this.info.tableId
+            if (this.form.id != undefined) {
+              setGenTable(datas).then(response => {
                 this.msgSuccess("修改成功");
                 this.open = false;
                 this.tabList();
               });
             } else {
-              addGenTable(this.form).then(response => {
+              addGenTable(datas).then(response => {
                 this.msgSuccess("新增成功");
                 this.open = false;
                 this.tabList();
@@ -840,7 +846,9 @@
       /** 新增按钮操作 */
       handleAdd_gl() {
         this.reset();
-        this.open = true;
+        this.open = true;
+        console.log(this.form)
+
         this.title = "新增关联表";
       },
       handleDel_gl(row) {
@@ -860,7 +868,7 @@
       // 表单重置
       reset() {
         this.form = {
-
+          isDel: 'N'
         };
         this.resetForm("form");
       },