Commit d3fa137ab2dd1805f438a3dbf997089a87a98fcf

Authored by zichun
1 parent 52d7bade

fix(locate): search by sBillNo when record keyword looks like a bill number

作废/审核/修改 by bill number failed — locateRecord/lookupRecord always
filtered on the %Name field which can't match bill numbers.
src/main/java/com/xly/service/FormResolverService.java
@@ -83,6 +83,15 @@ public class FormResolverService { @@ -83,6 +83,15 @@ public class FormResolverService {
83 "ORDER BY iFormUses DESC LIMIT 1", table); 83 "ORDER BY iFormUses DESC LIMIT 1", table);
84 } 84 }
85 85
  86 + /** 按关键词形态选检索字段:形如单号(字母前缀+数字)且表有 sBillNo 列 → 用单号列;否则名称列。 */
  87 + public String searchField(String table, String keyword) {
  88 + if (keyword != null && keyword.trim().matches("[A-Za-z]{1,6}\\d{4,}")
  89 + && columnTypes(table).containsKey("sBillNo")) {
  90 + return "sBillNo";
  91 + }
  92 + return resolveNameField(table);
  93 + }
  94 +
86 /** 同 {@link #resolveNameField},但从 formId 出发(经表单目录找到数据源表)。 */ 95 /** 同 {@link #resolveNameField},但从 formId 出发(经表单目录找到数据源表)。 */
87 public String resolveNameFieldByFormId(String formId) { 96 public String resolveNameFieldByFormId(String formId) {
88 return queryOne( 97 return queryOne(
src/main/java/com/xly/tool/ErpReadTool.java
@@ -57,7 +57,7 @@ public class ErpReadTool { @@ -57,7 +57,7 @@ public class ErpReadTool {
57 if (!identity.canAccessModule(moduleId)) { 57 if (!identity.canAccessModule(moduleId)) {
58 return "你没有访问「" + entityKeyword + "」的权限。"; 58 return "你没有访问「" + entityKeyword + "」的权限。";
59 } 59 }
60 - String nameField = resolver.resolveNameField(table); 60 + String nameField = resolver.searchField(table, recordKeyword.trim());
61 61
62 JsonNode root; 62 JsonNode root;
63 try { 63 try {
src/main/java/com/xly/tool/ProposeWriteTool.java
@@ -501,7 +501,7 @@ public class ProposeWriteTool { @@ -501,7 +501,7 @@ public class ProposeWriteTool {
501 l.error = err("你没有" + verb + "「" + entityKeyword + "」的权限。"); 501 l.error = err("你没有" + verb + "「" + entityKeyword + "」的权限。");
502 return l; 502 return l;
503 } 503 }
504 - String nameField = resolver.resolveNameField(l.table); 504 + String nameField = resolver.searchField(l.table, recordKeyword);
505 JsonNode root; 505 JsonNode root;
506 try { 506 try {
507 root = erp.readForm(identity.token(), l.formId, l.moduleId, 1, 5, nameField, recordKeyword.trim()); 507 root = erp.readForm(identity.token(), l.formId, l.moduleId, 1, 5, nameField, recordKeyword.trim());