Browse Source

移动端表单优化

晴为镜 1 month ago
parent
commit
c9231a84f3

+ 25 - 3
zkqy-admin/src/main/java/com/zkqy/web/controller/api/ApiMobilePageDesignDataController.java

@@ -26,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -58,14 +60,34 @@ public class ApiMobilePageDesignDataController extends BaseController {
      */
     @GetMapping(value = "/muti/tableLimitInfo")
     @ApiOperation(value = "获取表格页面的数据")
-    public TableDataInfo getMutiInfoLimit(Long pageId){
+    public TableDataInfo getMutiInfoLimit(@RequestParam Map<String,String> queryMap){
+        Long pageId = 0l;
+        if (queryMap != null && queryMap.get("pageId")!= null ){
+            pageId = Long.parseLong(queryMap.get("pageId").toString());
+            queryMap.remove("pageId");
+        }
         if (pageId == 0l){
             return new TableDataInfo();
         }
         MobilePageDesignData mobilePageDesignData = mobilePageDesignDataService.selectMobilePageDesignDataById(pageId);
         startPage();
-        String sql = mobilePageDesignDataService.mapToQuerySql(mobilePageDesignData.getPageJson());
-        List<Map<String,Object>> list = mobilePageDesignDataService.executeQuerySql(sql);
+        queryMap.remove("pageSize");
+        queryMap.remove("pageNum");
+        StringBuilder sqlBuilder = new StringBuilder(mobilePageDesignDataService.mapToQuerySql(mobilePageDesignData.getPageJson()));
+        // 循环将请求参数解码
+        for (Map.Entry<String, String> entry : queryMap.entrySet()) {
+            String key = entry.getKey();
+            String value = entry.getValue();
+            try {
+                sqlBuilder.append(" and ")
+                        .append(URLDecoder.decode(key, "UTF-8").replaceFirst("@", "."))
+                        .append(" = ")
+                        .append(URLDecoder.decode(value, "UTF-8"));
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        List<Map<String,Object>> list = mobilePageDesignDataService.executeQuerySql(sqlBuilder.toString());
         List<Map<String, Object>> underlineList = CollectionUtil.copyListMapWithCamelToUnderline(list);
         int total = new Long(new PageInfo(list).getTotal()).intValue();
         return new TableDataInfo(underlineList,total,200,"获取成功");

+ 3 - 2
zkqy-admin/src/main/java/com/zkqy/web/controller/mobilepage/MobilePageDesignDataController.java

@@ -105,8 +105,9 @@ public class MobilePageDesignDataController extends BaseController
         if (i > 0){
             mobilePageDesignDataService.fillPageIdToHtmlData(mobilePageDesignData);
             mobilePageDesignDataService.updateMobilePageDesignData(mobilePageDesignData);
-            List<Long> tableIds = mobilePageDesignData.getTableIds();
-            mobilePageDesignDataService.fillTableIdToForm(i,tableIds);
+//            暂时不用,后期跳转的时候可能会加
+//            List<Long> tableIds = mobilePageDesignData.getTableIds();
+//            mobilePageDesignDataService.fillTableIdToForm(i,tableIds);
         }
         return toAjax(i);
     }

+ 12 - 3
zkqy-system/src/main/java/com/zkqy/system/service/impl/MobilePageDesignDataServiceImpl.java

@@ -428,7 +428,7 @@ public class MobilePageDesignDataServiceImpl implements IMobilePageDesignDataSer
         JSONArray jsonArray = JSON.parseArray(oldJsonStr);
         for (int i = 0; i < jsonArray.size(); i++) {
             JSONObject jsonObject = jsonArray.getJSONObject(i);
-            if (jsonObject.get("type") != null && jsonObject.get("type").equals("zkqyTable") && jsonObject.getJSONObject("props") != null){
+            if (jsonObject.get("type") != null &&  jsonObject.getJSONObject("props") != null && (jsonObject.get("type").equals("zkqyTable") || jsonObject.get("type").equals("elCard"))){
                 JSONObject jsonObject1 = jsonObject.getJSONObject("props");
                 jsonObject1.put("pageId",id);
             }
@@ -447,8 +447,17 @@ public class MobilePageDesignDataServiceImpl implements IMobilePageDesignDataSer
             throw new RuntimeException(e);
         }
         mobilePageDesignData.setHtmlData(encodeHtml);
-        // 给pageOption里面也加上
-        mobilePageDesignData.setPageJson(newJsonStr);
+        // 给pageJson里面也加上
+        String pageJson = mobilePageDesignData.getPageJson();
+        JSONArray jsonArrayPro = JSON.parseArray(pageJson);
+        for (int i = 0; i < jsonArrayPro.size(); i++) {
+            JSONObject jsonObject = jsonArrayPro.getJSONObject(i);
+            if (jsonObject.get("type") != null &&  jsonObject.getJSONObject("props") != null && (jsonObject.get("type").equals("zkqyTable") || jsonObject.get("type").equals("elCard"))){
+                JSONObject jsonObject1 = jsonObject.getJSONObject("props");
+                jsonObject1.put("pageId",id);
+            }
+        }
+        mobilePageDesignData.setPageJson(jsonArrayPro.toString());
     }
 
     private  String buildSelectClause(JSONArray columns) {