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

Merge remote-tracking branch 'origin/master'

Administrator 4 жил өмнө
parent
commit
1ae3c15bba

+ 1 - 1
boman-api/boman-domain/src/main/java/com.boman.domain/constant/ViewConst.java → boman-api/boman-domain/src/main/java/com.boman.domain/constant/ViewTypeConst.java

@@ -4,7 +4,7 @@ package com.boman.domain.constant;
  * @author shiqian
  * @date 2021年04月20日 16:20
  **/
-public class ViewConst {
+public class ViewTypeConst {
 
     public static final String VIEW_TYPE = "viewType";
 

+ 16 - 8
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -17,7 +17,6 @@ import com.boman.gen.api.RemoteGenTableService;
 import com.boman.domain.GenTable;
 import com.boman.domain.GenTableColumn;
 import com.boman.system.api.RemoteDictDataService;
-import com.boman.domain.SysFile;
 import com.boman.web.core.domain.*;
 import com.boman.web.core.service.delete.IBaseDeleteService;
 import com.boman.web.core.service.save.IBaseSaveService;
@@ -239,6 +238,10 @@ public class TableServiceCmdService {
 
         List<JSONObject> result = selectService.selectByCondition(tableName, condition, packCondition, showData, dto);
         result = filter(result, ObjectUtils::isNotEmpty);
+
+        // 查询时为null的列不显示的处理
+        handleNullColumnValue(result, showData);
+
         // 处理blob
         handleBlob(result, genTable.getIsContainsBlob());
         // 处理日期、外键、字典值
@@ -271,18 +274,23 @@ public class TableServiceCmdService {
             return getByTableName(tableName, columns, isUi);
         }
 
-        // 默认查所有字段,不支持自定义
+        List<GenTableColumn> updateVisibleColumns = filterData(columns, 2, MaskConstant.UPDATE_VISIBLE::equals);
+        List<String> showData = map(updateVisibleColumns, GenTableColumn::getColumnName);
         String pkName = IdUtils.getPkName(genTable.getColumns());
-        JSONObject json = selectService.selectById(tableName, pkName, id);
-        requireNonNull(json, "id 为[" + id + "]的数据不存在, 表名为[" + tableName + "]");
-        // 处理blob
-        handleBlob(Collections.singletonList(json), genTable.getIsContainsBlob());
 
+        List<JSONObject> jsonList = selectService.selectByIdList(tableName, pkName, Lists.newArrayList(id), showData);
+        requireNonNull(jsonList, "id 为[" + id + "]的数据不存在, 模块为[" + genTable.getFunctionName() + "]");
+        // 查询时为null的列不显示的处理
+        handleNullColumnValue(jsonList, showData);
+        JSONObject json = jsonList.get(0);
+
+        // 处理blob
+        handleBlob(jsonList, genTable.getIsContainsBlob());
         List<GenTableColumn> parentColumns = filterHrAndSort(columns);
         // 处理成hr的形式
         for (GenTableColumn hrColumn : parentColumns) {
             List<GenTableColumn> children = Lists.newArrayListWithCapacity(16);
-            for (GenTableColumn column : columns) {
+            for (GenTableColumn column : updateVisibleColumns) {
                 if (hrColumn.getId().equals(column.getHrParentId())) {
                     String columnName = column.getColumnName();
                     String columnType = column.getColumnType();
@@ -361,7 +369,7 @@ public class TableServiceCmdService {
         // genTable.getMenuRole() 暂时数据库没有数据,
         jsonObject.put(FormDataConstant.BUTTON_LIST, Strings.nullToEmpty(genTable.getMenuRole()));
 
-        jsonObject.put(ViewConst.VIEW_TYPE, Strings.nullToEmpty(genTable.getTplCategory()));
+        jsonObject.put(ViewTypeConst.VIEW_TYPE, Strings.nullToEmpty(genTable.getTplCategory()));
         jsonObject.put(RULES, packRequireColumn(columns));
         return AjaxResult.success(jsonObject);
     }

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

@@ -110,6 +110,39 @@ public class ColumnUtils {
         return returnData;
     }
 
+
+    /**
+     * 功能描述: 把新增可见或者修改可见或者.....的列名过滤出来
+     *
+     * @param allColumns 所有的列
+     * @param sort       那六个1的顺序 [1,1,1,1,1,1]
+     *                   sort=0  =>  新增可见
+     *                   sort=1  =>  新增可修改
+     *                   sort=2  =>  修改可见
+     *                   sort=3  =>  修改可修改
+     *                   sort=4  =>  列表可见
+     *                   sort=5  =>  列表可修改
+     * @return List<GenTableColumn>
+     */
+    public static List<String> filterMaskColumnName(List<GenTableColumn> allColumns, int sort, Predicate<String> predicate) {
+        assert sort < 6;
+        List<String> returnData = Lists.newArrayListWithCapacity(16);
+        for (GenTableColumn allColumn : allColumns) {
+            if (!HR.equalsIgnoreCase(allColumn.getHtmlType())) {
+                String[] maskArray = requireNonNull(allColumn.getMask(), "mask is empty").split("");
+                assert maskArray.length == 6;
+                // sort
+                String insertVisible = maskArray[sort];
+                if (predicate.test(insertVisible)) {
+                    returnData.add(allColumn.getColumnName());
+                }
+            }
+
+        }
+
+        return returnData;
+    }
+
     /**
      * 功能描述: 按照predicate的规则过滤allColumns中包含data并且符合过滤规则的数据, <p>过滤掉hr !!!</p>
      *

+ 37 - 0
boman-web-core/src/main/java/com/boman/web/core/utils/HandlerFormDataUtils.java

@@ -1,6 +1,7 @@
 package com.boman.web.core.utils;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.boman.common.core.utils.DateUtils;
@@ -20,6 +21,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
 import static com.boman.domain.constant.FormDataConstant.*;
@@ -190,4 +192,39 @@ public class HandlerFormDataUtils {
         return result;
     }
 
+    /**
+     * 功能描述: 查找result中是否有showData中不存在的列,如果不存在则置为null
+     *
+     * @param result   result
+     * @param showData showData
+     */
+    public static void handleNullColumnValue(List<JSONObject> result, JSONArray showData) {
+        for (JSONObject jsonObject : result) {
+            Set<String> resultKeySet = jsonObject.keySet();
+            for (Object columnNameObj : showData) {
+                String columnName = (String) columnNameObj;
+                if (!resultKeySet.contains(columnName)) {
+                    jsonObject.put(columnName, "");
+                }
+            }
+        }
+    }
+
+    /**
+     * 功能描述: 查找result中是否有showData中不存在的列,如果不存在则置为null
+     *
+     * @param result   result
+     * @param showData showData
+     */
+    public static void handleNullColumnValue(List<JSONObject> result, List<String> showData) {
+        for (JSONObject jsonObject : result) {
+            Set<String> resultKeySet = jsonObject.keySet();
+            for (String columnName : showData) {
+                if (!resultKeySet.contains(columnName)) {
+                    jsonObject.put(columnName, "");
+                }
+            }
+        }
+    }
+
 }

+ 13 - 8
ruoyi-ui/src/views/system/editing/index.vue

@@ -130,6 +130,7 @@
         this.tabledeLise.table = this.tabldie[index].tableName
         this.formeanti.table = this.tabldie[index].tableName
         this.forme.table = this.tabldie[index].tableName
+
         this.tableZbie.table = this.tabldie[index].tableName
         // this.edingelsie()
         this.init()
@@ -169,6 +170,7 @@
               }
             } else if (route == 'Q') {
               route = '查询'
+              this.jeigneutwo.push(route)
             } else if (route == 'S') {
               route = '提交'
               if (this.formy.id != -1) {
@@ -181,8 +183,10 @@
               }
             } else if (route == 'I') {
               route = '导入'
+              this.jeigneutwo.push(route)
             } else if (route == 'E') {
               route = '导出'
+              this.jeigneutwo.push(route)
             }
 
           })
@@ -193,11 +197,14 @@
           if(this.queryData.showData.length !==0){
            this.queryData.showData.filter(route => {
                if(route.hrChildren.length !== 0){
-                  if(route.hrChildren[1].readonly == true){
-                        this.imgShoew = true
-                  }else{
-                    this.imgShoew = false
-                  }
+                 if(route.hrChildren[0].readonly !== null){
+                   if(route.hrChildren[0].readonly == true){
+                         this.imgShoew = true
+                   }else{
+                     this.imgShoew = false
+                   }
+                 }
+
                }
            })
           }
@@ -220,9 +227,6 @@
         geteditindeTab(this.tableZbietabg).then(response => {
           this.tabldie = response.data.ref
           if (this.tabldie.length !== 0) {
-            this.tabledeLise.table = this.tabldie[0].tableName
-            this.formeanti.table = this.tabldie[0].tableName
-            this.forme.table = this.tabldie[0].tableName
             this.tableZbie.table = this.tabldie[0].tableName
             this.init()
           } else {
@@ -302,6 +306,7 @@
       },
       /** 新增 修改提交按钮 */
       submitForm: function() {
+        console.log(3456)
         this.$refs["queryForm"].validate(valid => {
           if (valid) {
             addbjectSave(this.forme).then(response => {

+ 69 - 5
ruoyi-ui/src/views/system/form/index.vue

@@ -29,7 +29,16 @@
               <span :class="[index == numtab ? 'span' : '']">{{item.tableComment}}</span>
             </p>
           </div>
-          <el-divider></el-divider>
+          <el-divider></el-divider>
+          <!-- v-show="showSearch" -->
+         <el-form :model="queryParamstwoi" ref="queryForm" :inline="true" >
+           <dynamic-forms :ref="item.columnName" :config="queryParamstwoi" @inputs="changeFn" :formConfig="item" v-for="(item,index) in queryDatatao.showData"
+             :key='index' />
+           <el-form-item>
+             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQueryiu">搜索</el-button>
+             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+           </el-form-item>
+         </el-form>
           <el-table stripe v-loading="loading" :data="postList.rows" @selection-change="handleSelectionChange">
             <el-table-column :label="item.columnComment" align="center" :prop="item.columnName" v-for="(item,index) in postList.tableHeadList" :key="index" />
           </el-table>
@@ -82,18 +91,34 @@
           },
           isUi:true
         },
-        queryData: {},
+        objParamstue:{
+          table: 'obj_test',
+          fixedData: {
+            id: -1
+          },
+          isUi:false
+        },
+        queryData: {},
+        queryDatatao:{},
         // 查询参数
         queryParams: {
           dictName: undefined,
           dictType: undefined,
           status: undefined
         },
+        queryParamstwoi:{
+         dictName: undefined,
+         dictType: undefined,
+         status: undefined
+        },
         queryParamslist: {
           pageNo: 1,
           pageSize: 10,
           orderBy:'create_time desc',
           table: '',
+          fixedData:{
+            condition:{}
+          }
         },
         labletit: '查询参数1233',
         surlable: '实际数据库表',
@@ -153,11 +178,12 @@
       this.forme.objId = this.$route.query.id
       this.formy.id = this.$route.query.id
       this.tableZbietabg.table = this.$route.query.tables
-      this.objParams.table = this.$route.query.tables
+      // this.objParams.table = this.$route.query.tables
       this.objParams.fixedData.id = this.$route.query.id
       this.deledlid.table = this.$route.query.tables
       this.deledlid.idList.push(this.$route.query.id)
       this.queryParamslist.table = this.$route.query.tables
+      this.objParamstue.fixedData.id = this.$route.query.id
       this.init()
       this.edingelsietab()
     },
@@ -204,16 +230,18 @@
           console.log(res)
           let data = res.data
           this.queryData = data
-
           // 图片的显示隐藏
           if(this.queryData.showData.length !==0){
            this.queryData.showData.filter(route => {
                if(route.hrChildren.length !== 0){
-                  if(route.hrChildren[1].readonly == true){
+                 if(route.hrChildren[0].readonly !== null){
+                  if(route.hrChildren[0].readonly == true){
                         this.imgShoew = true
                   }else{
                     this.imgShoew = false
                   }
+                 }
+
                }
            })
           }
@@ -230,8 +258,10 @@
           if(response.data.ref.length !==0){
             this.tabldie = response.data.ref
             this.queryParamslist.table = this.tabldie[0].tableName
+            this.objParamstue.table = this.tabldie[0].tableName
             this.tabShoes = true
             this.foremliseju()
+            this.foremlisejuque()
           }else{
             this.tabShoes = false
           }
@@ -252,6 +282,16 @@
          console.log(this.postList,567)
 
        })
+      },
+      // 列表查询接口
+      foremlisejuque(){
+       getObject(this.objParamstue).then(res => {
+         console.log(res)
+         this.queryDatatao = res.data
+         // let data = res.data
+         // this.queryData = data
+         // 图片的显示隐藏
+       })
       },
       // tab点击
       tabSbu(index) {
@@ -332,6 +372,30 @@
         console.log(this.forme)
         // this.getList();
       },
+      // 搜索列表
+      handleQueryiu(){
+       for(let item of this.queryDatatao.showData){
+         // for(var i = 0 ; i < item.hrChildren.length ; i++){
+           if(item.htmlType == 'checkbox'){
+             this.queryParamstwoi[item.columnName] = this.$refs[item.columnName][0].config
+           }else if(item.htmlType == 'imageUpload' || item.htmlType == 'fileUpload'){
+             this.queryParamstwoi[item.columnName] = JSON.stringify(this.$refs[item.columnName][0].config)
+           } else{
+             this.queryParamstwoi[item.columnName] = this.$refs[item.columnName][0].config[item.columnName]
+           }
+         // }
+
+       }
+       for(var items in this.queryParamstwoi){
+         if(this.queryParamstwoi[items] == ''){
+           this.queryParamstwoi[items] = undefined
+         }
+       }
+       this.queryParamslist.fixedData.condition = this.queryParamstwoi
+       this.foremliseju()
+        console.log(this.queryParamstwoi)
+
+      },
      /** 新增 修改提交按钮 */
      submitForm: function() {
        this.$refs["queryForm"].validate(valid => {

+ 5 - 1
ruoyi-ui/src/views/system/table/index.vue

@@ -85,7 +85,7 @@
         jeigneutwo:[],
         xidugje:0,
         tijeq:0,
-        imgShoew:true
+        imgShoew:false
       };
     },
     // filters:{
@@ -253,6 +253,7 @@
               }
             }else if(route == 'Q'){
               route = '查询'
+              this.jeigneutwo.push(route)
             }else if(route == 'S'){
               route = '提交'
               if(this.formy.id != -1){
@@ -265,11 +266,14 @@
               }
             }else if(route == 'I'){
               route = '导入'
+              this.jeigneutwo.push(route)
             }else if(route == 'E'){
               route = '导出'
+              this.jeigneutwo.push(route)
             }
 
           })
+
           this.jeigneutwo.push('刷新')
           this.jeigneutwo.push('返回')
           // console.log(this.jeigneutwo,567)