Browse Source

REPORT-75998 增加搜索模板Web属性引用JS

feature/x
Destiny.Lin 2 years ago
parent
commit
9094e69ddf
  1. 20
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java
  2. 58
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java
  3. 4
      designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java

20
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java

@ -4,6 +4,7 @@ import com.fr.design.actions.replace.info.JSInfo;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.info.base.SearchTag;
import com.fr.design.actions.replace.utils.SearchJSUtils; import com.fr.design.actions.replace.utils.SearchJSUtils;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
@ -19,6 +20,7 @@ import com.fr.report.web.util.ReportEngineEventMapping;
import com.fr.web.attr.ReportWebAttr; import com.fr.web.attr.ReportWebAttr;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -86,12 +88,30 @@ public class SearchWebJSAction implements SearchJS {
content.setTemplateName(jTemplate.getTemplateName()); content.setTemplateName(jTemplate.getTemplateName());
content.setJumpAble(false); content.setJumpAble(false);
addWebContent2Array(webAttr); addWebContent2Array(webAttr);
//处理引用JS
dealImportJS(content,jsInfos,webAttr);
for (int i = 0; i < arrayList.size(); i++) { for (int i = 0; i < arrayList.size(); i++) {
addJSInfos2ListFromArray(content, jsInfos, arrayList.get(i)); addJSInfos2ListFromArray(content, jsInfos, arrayList.get(i));
} }
} }
} }
private void dealImportJS(ITContent content, List<JSInfo> jsInfos, ReportWebAttr webAttr) {
if (webAttr != null){
for (String jsStr : webAttr.getJSImport()){
ITContent jsContent = ITContent.copy(content);
jsContent.addOtherPos(
Toolkit.i18nText("Fine-Design_Basic_Report_Web_Attributes"),
Toolkit.i18nText("Fine-Design_Report_Import_JavaScript")
);
jsContent.setReplaceObject(jsStr);
jsContent.setHoldObject(webAttr);
jsContent.setTag(SearchTag.IMPORT_JS);
jsInfos.add(new JSInfo(jsContent));
}
}
}
private void addJSInfos2ListFromServerWebAttr(ITContent content, List<JSInfo> jsInfos, WebContent webContent) { private void addJSInfos2ListFromServerWebAttr(ITContent content, List<JSInfo> jsInfos, WebContent webContent) {
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);
if (SERVER_MAP.containsKey(webContent.getClass().getSimpleName())) { if (SERVER_MAP.containsKey(webContent.getClass().getSimpleName())) {

58
designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java

@ -3,13 +3,16 @@ package com.fr.design.actions.replace.info;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.form.event.Listener; import com.fr.form.event.Listener;
import com.fr.general.GeneralUtils;
import com.fr.js.JavaScriptImpl; import com.fr.js.JavaScriptImpl;
import com.fr.js.NameJavaScript; import com.fr.js.NameJavaScript;
import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.collections.combination.Pair; import com.fr.stable.collections.combination.Pair;
import com.fr.web.attr.ReportWebAttr;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -184,36 +187,77 @@ public enum ReplaceObject implements DealWithInfoValue {
return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr());
} }
}, },
/**
* 模板Web属性引用JS
*/
IMPORT_JS("String") {
@Override
public Map<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
addValue2Map(contentKey, GeneralUtils.objectToString(o[0]), map);
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) {
if (info.getContent().getHoldObject() instanceof ReportWebAttr) {
ReportWebAttr attr = (ReportWebAttr) info.getContent().getHoldObject();
List<String> jsImports = Arrays.asList(attr.getJSImport());
String jsName = GeneralUtils.objectToString(info.getContent().getReplaceObject());
for (int i = 0, len = jsImports.size(); i < len; i++) {
if (StringUtils.equals(jsImports.get(i), jsName)) {
jsImports.set(i, ShowValueUtils.replaceAll(jsName, findStr, replaceStr));
}
}
attr.clearJSImportList();
for (int i = 0, len = jsImports.size(); i < len; i++) {
attr.addJSImport(jsImports.get(i));
}
}
}
@Override
public String getInfoShowStr(Info info) {
return GeneralUtils.objectToString(info.getContent().getReplaceObject());
}
@Override
boolean check(Info info) {
return true;
}
},
/** /**
* DBTableDataSQL * DBTableDataSQL
*/ */
DB_TABLE_DATA("DBTableData") { DB_TABLE_DATA("DBTableData") {
@Override @Override
boolean check(Info info) { boolean check (Info info){
DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject();
return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr()); return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr());
} }
@Override @Override
public Map<String, String> getValue(Object... o) { public Map<String, String> getValue (Object...o){
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map); addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map);
return map; return map;
} }
@Override @Override
public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) { public void setValue (Info info, String findStr, String
replaceStr, List < Pair < Integer, Integer >> operatorArray){
DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject();
info.updateOldStr(dbTableData.getQuery(), findStr); info.updateOldStr(dbTableData.getQuery(), findStr);
dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr)); dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr));
//todo DesignTableDataManager
} }
@Override @Override
public String getInfoShowStr(Info info) { public String getInfoShowStr (Info info){
return info.getInfoShowStr(info); return info.getInfoShowStr(info);
} }
}; }
;
String name; String name;
@ -256,4 +300,4 @@ public enum ReplaceObject implements DealWithInfoValue {
abstract boolean check(Info info); abstract boolean check(Info info);
} }

4
designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java

@ -52,6 +52,10 @@ public class SearchTag {
* 数据字典-公式-实际值 * 数据字典-公式-实际值
*/ */
public static final int DICT_PRODUCE = 10; public static final int DICT_PRODUCE = 10;
/**
* 引用JS
*/
public static final int IMPORT_JS = 11;

Loading…
Cancel
Save