| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917 |
- package core.page;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.IOException;
- import java.io.StringReader;
- import java.lang.reflect.Type;
- import java.nio.charset.StandardCharsets;
- import java.sql.SQLException;
- import java.util.*;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import com.google.gson.Gson;
- import com.google.gson.JsonObject;
- import com.google.gson.JsonParser;
- import com.google.gson.reflect.TypeToken;
- import org.apache.commons.io.FileUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
- import core.PrjApp;
- import ss.AppC;
- import ss.ccp.CcpB;
- import ss.ccp.CcpFieldB;
- import ss.cmn.file.FileU;
- import ss.cmn.str.StrU;
- import ss.cms.CmsC;
- import ss.db.Db;
- import ss.db.SqlCmd;
- import ss.obj.ObjB;
- import ss.obj.ObjC;
- import ss.obj.ObjFieldB;
- import ss.page.PageU;
- public class PageCompU {
- // === "新UI增加的 start" ===
- /**
- * 生成JSP静态include指令
- * @param filePath 包含文件的路径
- * @return 完整的include指令字符串
- */
- public static String getIncludeTag(String filePath) {
- return "<%@ include file=\"" + filePath + "\" %>";
- }
- private static String getAttributeStr(Map<String, String> map, String name) {
- if (StringUtils.isBlank(map.get(name))) // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin
- return "";
- if ("button".equals(name)){
- if(map.get(name).contains("'"))
- return name + "=\"" + map.get(name) + "\"";
- return name + "='" + map.get(name) + "'";
- }
- if(map.get(name).contains("\"")){
- return name + "='" + map.get(name) + "'";
- }else{
- return name + "=\"" + map.get(name) + "\"";
- }
- }
- public static void setTagAttr(StringBuilder sb,String attrName,String attrValue){
- sb.append(PageCompC.LINE_BREAK).append(attrName).append("=\"").append(attrValue).append("\"");
- }
- /**
- * "<ss:serv name='"+ m_service +"' dest='"+ m_bjid +"' parm='"+ m_parm +"'/>"
- * @return
- */
- public static String getServiceTag(String serviceName,
- String dest,
- Map<String, String> parmMap){
- String destStr = "";
- if(StringUtils.isNotBlank(dest)){
- destStr = " dest='"+ dest +"'";
- }
- String parmStr = "";
- if(parmMap!=null&&parmMap.size()>0){
- // 使用Map创建JSON对象
- Gson gson = new Gson();
- parmStr = " parm='"+ gson.toJson(parmMap) +"'";
- }
- return "<ss:serv name='"+serviceName +"'"+destStr+parmStr+" />";
- }
- public static String getElExp(ObjB vo,String fieldName){
- return "${"+vo.getName()+"."+fieldName+"}";
- }
- private static Map String2Map(String jsonString){
- Gson gson = new Gson();
- Map<String, String> map = gson.fromJson(jsonString, Map.class);
- return map;
- }
- //返回初始化级联组件的html
- public static String getCcpInputCode(String componentType, //组件类弄
- Map<String, String> inputproperties,//低级写法的组件属性
- ObjB vo,
- String name, //input的name属性
- boolean isCombField, //是隐藏字段
- List<CcpB> ccpList, //级联菜单配置
- String prfx, //级联菜单前缀
- /**
- * 级联菜单filter放在这
- *
- * 高级写法:
- * 利用此属性传width、value等属性,而不通过inputproperties参数传
- */
- Map<String, Map<String, String>> cascadingTagNewAttribute
- ){
- StringBuilder sb = new StringBuilder();
- // 1.下面叫xxStr,都是input页面的发布程序,即低级写法发布时抽取的属性
- String heightStr = null;
- String widthStr = null;
- String maxHeightStr = null;
- String valueStr = null;
- String placeholderStr = null;
- String classStr = null;
- String styleStr = null;
- String ssChgStr = null;
- // 2. 下面是ccp.ss高级写法,抽取出来的属性
- String width = null;
- String value = null;
- String inpClass = null;
- String style = null;
- String onChange = null;
- String placeholder = null;
- ObjFieldB objField = vo.fieldMap.get(name); // 再增加,增加支持 <obj <field 里的属性。Lin
- Map<String, String> cascadingInpNewAttributeMap = null;
- if(cascadingTagNewAttribute!=null)
- cascadingInpNewAttributeMap = cascadingTagNewAttribute.get("inpTag");
- if(cascadingInpNewAttributeMap!=null){//高级写法 <objp.ss onChange='xxx'/>
- width = cascadingInpNewAttributeMap.get("width");
- inpClass = cascadingInpNewAttributeMap.get("class");
- style = cascadingInpNewAttributeMap.get("style");
- //高级写法 <objp.ss onChange='xxx'/> Ben(20251218)
- onChange = cascadingInpNewAttributeMap.get(PageCompC.TAG_ATTR_onChange);
- value = cascadingInpNewAttributeMap.get("value");
- placeholder = cascadingInpNewAttributeMap.get("placeholder");
- }else {//低级写法<input ssChg=‘xxx’/>
- heightStr = getAttributeStr(inputproperties, "height");
- widthStr = getAttributeStr(inputproperties, "width");
- maxHeightStr = getAttributeStr(inputproperties, "maxHeight");
- valueStr = inputproperties.get("value");
- /* 再改,改为取值 "建筑物"。原为 "placeholder="建筑物"",导致输出到 vue 组件的 placeholder= 为 placeholder="placeholder="建筑物""。Lin
- placeholderStr = getAttributeStr(inputproperties, "placeholder");
- */ placeholderStr = inputproperties.get("placeholder");
- classStr = getAttributeStr(inputproperties, "class");
- styleStr = getAttributeStr(inputproperties, "style");
- //增加支持onchange事件 <input ssChg=‘xxx’/> Ben(20251218)
- ssChgStr = getAttributeStr(inputproperties, PageCompC.TAG_ATTR_ssChg);
- }
- // ObjFieldB objFieldB = vo.fieldMap.get(name);
- // if(StringUtils.isBlank(placeholder)){
- // placeholder = objFieldB.getDesc();
- // }
- //
- // Integer width = objFieldB.getWidth();
- // Integer height = objFieldB.height;
- // String ssFilter = inputproperties.get("ssFilter");
- CcpB ccp = ccpList.get(0);
- String closingTag = null;
- if(isCombField){//是隐藏字段
- /**
- <ss-hidden
- v-model="hkdqm"
- name="hkdqm"
- rule="226699"
- :param="{'fieldOrd':['hksheng','hkshi','hkxian']}"
- url="/service?ssServ=loadObjpOpt&objectpickerdropdown1=1" <%-- 向后台拿数据的url --%>
- ></ss-hidden>
- */
- closingTag = "</ss-hidden>";
- sb.append(PageCompC.LINE_BREAK).append("<ss-hidden");
- setTagAttr(sb,PageCompC.TAG_ATTR_rule,ccp.combField.rule);
- List<String> fieldList = new ArrayList<>();
- /* 再去掉,共用 CcpB.combField.fieldList(List<CcpFieldB>) 里的 CcpFieldB.name。Lin
- for (Integer index : ccp.fieldNameMap.keySet()) {
- fieldList.add(prfx+ccp.fieldNameMap.get(index));
- */
- for (CcpFieldB field : ccp.combField.fieldList) {
- fieldList.add(prfx + field.name);
- }
- Map<String,List<String>> parmMap = new HashMap<>();
- parmMap.put("fieldOrd",fieldList);
- Gson gson = new Gson();
- String parmStr = gson.toJson(parmMap).replace("\"", "'");
- setTagAttr(sb,PageCompC.TAG_ATTR_param,parmStr);
- }else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_ccpsingle)){
- /**
- <ss-ccp
- v-model="hksheng"
- placeholder="省"
- width="200px"
- @change="hkshengChange"
- name="hksheng"<%-- 本下拉菜单的name,根据name和ccpOrd可以算出在下拉菜单中的顺序 --%>
- mode="1" <%-- 1代表带隐藏字段的级联,2代表不带隐藏字段的级联--%>
- :param="{'name':'dqm','combField':'hkdqm','fieldOrd':['hksheng','hkshi','hkxian'],'filter':{dwid:'678'},'codebook':'sheng'}"
- url="/service?ssServ=loadObjpOpt&objectpickerdropdown1=1" <%-- 向后台拿数据的url --%>
- onChange="callBackFunName"
- ></ss-ccp>
- */
- closingTag = "</ss-ccp>";
- sb.append(PageCompC.LINE_BREAK).append("<ss-ccp");
- setTagAttr(sb,PageCompC.TAG_ATTR_mode,"1");
- if(StringUtils.isNotBlank(placeholderStr))
- /* 再改,对指定的 placeholder,不加 "请选择" 前缀。Lin
- setTagAttr(sb, PageCompC.TAG_ATTR_placeholder,
- PageCompC.TAG_PLACEHOLDER_PREFIX_select + placeholderStr);
- */ setTagAttr(sb, PageCompC.TAG_ATTR_placeholder, placeholderStr);
- else if(StringUtils.isNotBlank(placeholder))
- /* 再改,对指定的 placeholder,不加 "请选择" 前缀。Lin
- setTagAttr(sb, PageCompC.TAG_ATTR_placeholder,
- PageCompC.TAG_PLACEHOLDER_PREFIX_select + placeholder);
- */ setTagAttr(sb, PageCompC.TAG_ATTR_placeholder, placeholder);
- Map<String,Object> parmMap = new HashMap<>();
- parmMap.put("name",ccp.name);
- String fullCombFieldName = null;
- if(StringUtils.isNotBlank(prfx)) {
- fullCombFieldName = prfx + ccp.combField.name;
- }
- else {
- fullCombFieldName = ccp.combField.name;
- }
- parmMap.put("combField", fullCombFieldName);
- List<String> fieldList = new ArrayList<>();
- for (int i = 0; i < ccp.combField.fieldList.size(); i ++) {
- String fieldName = prfx + ccp.combField.fieldList.get(i).name;
- String cbName = ccp.combField.fieldList.get(i).cbName;
- fieldList.add(fieldName);
- if(fieldName.equals(name))
- parmMap.put("codebook", cbName);
- }
- // for (Integer index : ccp.fieldNameMap.keySet()) {
- // fieldList.add(ccp.fieldNameMap.get(index));
- // }
- parmMap.put("fieldOrd",fieldList);
- String filter = null;
- Map<String, String> cascadingTagNewAttributeMap = cascadingTagNewAttribute.get(prfx+ccp.name);
- filter = cascadingTagNewAttributeMap.get("filter");
- if(StringUtils.isNotBlank(filter)) {
- Map filterMap = String2Map(filter);
- parmMap.put("filter", filterMap);
- }
- Gson gson = new Gson();
- String parmStr = gson.toJson(parmMap).replace("\"", "'");
- setTagAttr(sb,PageCompC.TAG_ATTR_param,parmStr);
- }else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_ccpmutiple)){
- /**
- <ss-ccp
- v-model="dwid"
- name="dwid"
- placeholder="请选择单位"
- width="250px"
- mode="2"
- :param="[{'name':'dw_bm','fieldOrd':['dwid','bmid'],'filter':{ryid:'111121'},'codebook':'dw'},{'name':'dw_sjry','fieldOrd':['dwid','sjryid'],'filter':{ryid:'111121'},'codebook':'dw'}]"
- url="/service?ssServ=loadObjpOpt&objectpickerdropdown1=1" <%-- 向后台拿数据的url --%>
- ></ss-ccp>
- <ss-ccp
- v-model="bmid"
- name="bmid"
- placeholder="请选择部门"
- width="250px"
- @change="myChange"
- mode="2"
- :param="{'name':'dw_bm','fieldOrd':['dwid','bmid'],'filter':{ryid:'111121'},'codebook':'bmByDw'}"
- url="/service?ssServ=loadObjpOpt&objectpickerdropdown1=1" <%-- 向后台拿数据的url --%>
- ></ss-ccp>
- */
- closingTag = "</ss-ccp>";
- sb.append(PageCompC.LINE_BREAK).append("<ss-ccp");
- setTagAttr(sb,PageCompC.TAG_ATTR_mode,"2");
- if(StringUtils.isNotBlank(placeholderStr))
- /* 再改,对指定的 placeholder,不加 "请选择" 前缀。Lin
- setTagAttr(sb, PageCompC.TAG_ATTR_placeholder,
- PageCompC.TAG_PLACEHOLDER_PREFIX_select + placeholderStr);
- */ setTagAttr(sb, PageCompC.TAG_ATTR_placeholder, placeholderStr);
- else if(StringUtils.isNotBlank(placeholder))
- /* 再改,对指定的 placeholder,不加 "请选择" 前缀。Lin
- setTagAttr(sb, PageCompC.TAG_ATTR_placeholder,
- PageCompC.TAG_PLACEHOLDER_PREFIX_select + placeholder);
- */ setTagAttr(sb, PageCompC.TAG_ATTR_placeholder, placeholder);
- /// 再增加,输出 :inp=,SsCcp 支持 inp="true" -- <ccp <combField <field inp="true" 和 <obj <field inp="true"。Lin
- boolean hasInp = false;
- String inpStr = inputproperties.get(PageCompC.TAG_ATTR_inp);
- if (StringUtils.isNotBlank(inpStr) && "true".equals(inpStr)) { // 有 <input ssInp="true"。Lin
- hasInp = true;
- } else {
- for (CcpB c : ccpList) {
- for (CcpFieldB cField : c.combField.fieldList) {
- if (cField.name.equals(name)) { // 找到 <input name= 对应的 <ccp <combField <field name=。Lin
- if (cField.inpable) // 有 <ccp <combField <field inp="true"。Lin
- hasInp = true;
- break;
- }
- }
- }
- if (!hasInp) { // 没有 <ccp <combField <field inp="true"。Lin
- if (vo.fieldMap.get(name).inpable) // 有 <obj <field inp="true"。Lin
- hasInp = true;
- }
- }
- if (hasInp)
- setTagAttr(sb, PageCompC.VUE_ATTR_inp, "true");
- ///
- Object paramValue = null;
- List<Map<String,Object>> parmList = new ArrayList<>();
- for (CcpB ccpB : ccpList) {
- ccp = ccpB;
- Map<String,Object> parmMap = new HashMap<>();
- parmList.add(parmMap);
- parmMap.put("name",ccp.name);
- String fullCombFieldName = null;
- if(StringUtils.isNotBlank(prfx)) {
- fullCombFieldName = prfx + ccp.combField.name;
- }
- else {
- fullCombFieldName = ccp.combField.name;
- }
- parmMap.put("combField", fullCombFieldName);
- List<String> fieldList = new ArrayList<>();
- for (int i = 0; i < ccp.combField.fieldList.size(); i ++) {
- CcpFieldB cField = ccp.combField.fieldList.get(i);
- String fieldName = prfx + cField.name;
- String cbName = cField.cbName;
- fieldList.add(fieldName);
- if(fieldName.equals(name)) {
- parmMap.put("codebook", cbName);
- if (StringUtils.isNotBlank(cField.filterField))
- parmMap.put("filterfield", cField.filterField);
- }
- }
- // for (Integer index : ccp.fieldNameMap.keySet()) {
- // fieldList.add(ccp.fieldNameMap.get(index));
- // }
- parmMap.put("fieldOrd",fieldList);
- String filter = null;
- Map<String, String> cascadingTagNewAttributeMap = cascadingTagNewAttribute.get(prfx+ccp.name);
- filter = cascadingTagNewAttributeMap.get("filter");
- if(StringUtils.isNotBlank(filter)) {
- Map filterMap = String2Map(filter);
- parmMap.put("filter", filterMap);
- }
- }
- Gson gson = new Gson();
- String parmStr = null;
- if(parmList.size()>1) {
- parmStr = gson.toJson(parmList);
- }else {
- parmStr = gson.toJson(parmList.get(0));
- }
- setTagAttr(sb,PageCompC.TAG_ATTR_param,parmStr.replace("\"", "'"));
- }
- Map<String, String> paramMap = new HashMap<>();
- paramMap.put("objectpickerdropdown1", "1");
- String url = getServiceTag("loadObjpOpt",
- null,
- paramMap);
- setTagAttr(sb,PageCompC.TAG_ATTR_url,url);
- setTagAttr(sb,PageCompC.TAG_ATTR_vmodel,name);
- setTagAttr(sb,PageCompC.TAG_ATTR_name,name);
- setTagAttr(sb,PageCompC.TAG_ATTR_readonly,PageCompC.VALUE_FALSE);
- if(StringUtils.isNotBlank(widthStr)){
- sb.append(PageCompC.LINE_BREAK).append(widthStr);
- } else if (StringUtils.isNotBlank(width)) {
- setTagAttr(sb,PageCompC.TAG_ATTR_width,width);
- }
- /// 再增加,支持 <ccp <combField <field width= 和 <obj <field width= -- 对单个字段,需要在 ccp 配置文件里写。Lin
- else {
- int cfgWidth = 0;
- for (CcpB c : ccpList) {
- for (CcpFieldB cField : c.combField.fieldList) {
- if ((prfx + cField.name).equals(name)) { // 找到 <input name= 对应的 <ccp <combField <field name=。Lin
- if (cField.width != null && cField.width > 0) // 有 <ccp <combField <field width=。Lin
- cfgWidth = cField.width;
- break;
- }
- }
- }
- if (cfgWidth == 0) { // 没有 <ccp <combField <field width=。Lin
- if (objField != null && // 对单个字段的 ccp,对象配置文件没有字段 -- sheng、shi、xian。Lin
- objField.width != null && objField.width > 0) // 有 <obj <field width=。Lin
- cfgWidth = objField.width;
- }
- if (cfgWidth > 0)
- setTagAttr(sb, PageCompC.VUE_ATTR_width, cfgWidth +"px");
- }
- ///
- if(StringUtils.isNotBlank(heightStr)&&!componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_html)){
- sb.append(PageCompC.LINE_BREAK).append(heightStr);
- }
- if(StringUtils.isNotBlank(classStr)){
- sb.append(PageCompC.LINE_BREAK).append(classStr);
- }else if(StringUtils.isNotBlank(inpClass)){
- setTagAttr(sb, PageCompC.TAG_ATTR_class,
- inpClass);
- }
- if(StringUtils.isNotBlank(styleStr)){
- sb.append(PageCompC.LINE_BREAK).append(styleStr);
- }else if(StringUtils.isNotBlank(style)){
- setTagAttr(sb, PageCompC.TAG_ATTR_style,
- style);
- }
- //增加支持onchange事件 <input ssChg=‘xxx’/> Ben(20251218)
- if(StringUtils.isNotBlank(ssChgStr)){
- /* 再改,改用增加的 VUE_ATTR_onChange = "onChange" -- <ss-objp 里的 onChange= 不改。Lin
- * 原,混用 PageCompC.TAG_ATTR_onChange,导致 <ss-objp 里的 onChange= 也被改为 chg=
- sb.append(PageCompC.LINE_BREAK).append(ssChgStr.replace(PageCompC.TAG_ATTR_ssChg,
- PageCompC.TAG_ATTR_onChange));
- */ sb.append(PageCompC.LINE_BREAK).append(ssChgStr.replace(PageCompC.TAG_ATTR_ssChg, PageCompC.VUE_ATTR_onChange));
- }else if(StringUtils.isNotBlank(onChange)){//高级写法 <objp.ss onChange='xxx'/> Ben(20251218)
- /* 再改,改用增加的 VUE_ATTR_onChange = "onChange" -- <ss-objp 里的 onChange= 不改。Lin
- * 原,混用 PageCompC.TAG_ATTR_onChange,导致 <ss-objp 里的 onChange= 也被改为 chg=
- setTagAttr(sb, PageCompC.TAG_ATTR_onChange,
- onChange);
- */ setTagAttr(sb, PageCompC.VUE_ATTR_onChange, onChange);
- }
- sb.append(PageCompC.LINE_BREAK).append(">").append(PageCompC.LINE_BREAK).append(closingTag).append(PageCompC.LINE_BREAK);
- return sb.toString();
- }
- //扩展判断是否 属性名=“{}” 这种json对象格式 start Ben(20260401)
- /**
- * 提取赋值表达式右侧的值部分
- */
- private static String extractValuePart(String input) {
- Matcher matcher = Pattern.compile("^\\s*(\\w+)\\s*=\\s*(.+)$").matcher(input.trim());
- if (matcher.matches()) {
- return matcher.group(2).trim();
- }
- return null;
- }
- /**
- * 去除值部分可能存在的引号
- */
- private static String removeQuotes(String value) {
- if (value == null || value.isEmpty()) {
- return value;
- }
- String trimmedValue = value.trim();
- // 检查是否以引号开头和结尾
- if ((trimmedValue.startsWith("\"") && trimmedValue.endsWith("\"")) ||
- (trimmedValue.startsWith("'") && trimmedValue.endsWith("'"))) {
- return trimmedValue.substring(1, trimmedValue.length() - 1);
- }
- return trimmedValue;
- }
- /**
- * 判断字符串是否是JSON对象赋值格式
- * 通过正则表达式快速判断格式
- */
- public static boolean isJsonObj(String input) {
- if (input == null || input.trim().isEmpty()) {
- return false;
- }
- // 提取等号右侧的值
- String valuePart = extractValuePart(input);
- if (valuePart == null) {
- return false;
- }
- // 去除可能的引号
- String value = removeQuotes(valuePart);
- // 快速检查:以{开头,以}结尾
- String trimmedValue = value.trim();
- if (!trimmedValue.startsWith("{") || !trimmedValue.endsWith("}")) {
- return false;
- }
- // 使用正则表达式检查是否是对象格式
- return Pattern.compile("^\\s*\\{.*\\}\\s*$").matcher(trimmedValue).matches();
- }
- //扩展判断是否 属性名=“{}” 这种json对象格式 end Ben(20260401)
- private static String getFirstNonBlank(Map<String, String> attrs, String... keys) {
- if (attrs == null || keys == null) {
- return null;
- }
- for (String key : keys) {
- if (StringUtils.isBlank(key)) {
- continue;
- }
- String value = attrs.get(key);
- if (StringUtils.isNotBlank(value)) {
- return value;
- }
- }
- return null;
- }
- public static String getEditorStoreNameForTag(Map<String, String> tagData, String rawName) {
- String storeName = getFirstNonBlank(tagData,
- PageCompC.TAG_ATTR_storeName,
- "storeName",
- "storename");
- if (StringUtils.isNotBlank(storeName)) {
- return storeName;
- }
- if (StringUtils.isBlank(rawName)) {
- return "";
- }
- return rawName.endsWith("wj") ? rawName : rawName + "wj";
- }
- public static String getEditorHtmlInputName(Map<String, String> attrs, String storeName, String rawName) {
- String htmlName = getFirstNonBlank(attrs,
- PageCompC.TAG_ATTR_htmlName,
- "htmlName",
- "htmlname");
- if (StringUtils.isNotBlank(htmlName)) {
- return htmlName;
- }
- String baseName = null;
- if (StringUtils.isNotBlank(storeName)) {
- baseName = storeName.endsWith("wj") ? storeName.substring(0, storeName.length() - 2) : storeName;
- } else if (StringUtils.isNotBlank(rawName)) {
- baseName = rawName.endsWith("wj") ? rawName.substring(0, rawName.length() - 2) : rawName;
- }
- if (StringUtils.isBlank(baseName)) {
- return "";
- }
- return baseName + "Edit";
- }
- private static boolean isAttachmentButtonName(String btnName) {
- return StringUtils.isNotBlank(btnName) && "fjid".equals(btnName.trim());
- }
- private static void patchAttachmentButton(Map<String, String> btnMap) {
- if (btnMap == null) {
- return;
- }
- if (!isAttachmentButtonName(btnMap.get("name"))) {
- return;
- }
- btnMap.put("cmsUpdUrl", "@cmsUpdateUrl@");
- btnMap.put("cmsAddUrl", "@cmsAddUrl@");
- }
- public static Object parseButtonConfigWithCms(String button) {
- if (StringUtils.isBlank(button)) {
- return null;
- }
- String trimmed = button.trim();
- try {
- if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
- Map<String, String> btnMap = new Gson().fromJson(trimmed,
- new TypeToken<Map<String, String>>() {}.getType());
- patchAttachmentButton(btnMap);
- return btnMap;
- }
- if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
- Type listType = new TypeToken<List<Map<String, String>>>() {}.getType();
- List<Map<String, String>> btnList = new Gson().fromJson(trimmed, listType);
- if (btnList != null) {
- for (Map<String, String> btnMap : btnList) {
- patchAttachmentButton(btnMap);
- }
- }
- return btnList;
- }
- } catch (Exception e) {
- log4j.error("PageCompU.parseButtonConfigWithCms( 异常", e);
- }
- return null;
- }
- public static boolean hasAttachmentButton(Object buttonConfig) {
- if (buttonConfig instanceof Map<?, ?> btnMap) {
- Object btnName = btnMap.get("name");
- if (btnName != null && isAttachmentButtonName(String.valueOf(btnName))) {
- return true;
- }
- return btnMap.get("cmsUpdUrl") != null && btnMap.get("cmsAddUrl") != null;
- }
- if (buttonConfig instanceof List<?> btnList) {
- for (Object item : btnList) {
- if (hasAttachmentButton(item)) {
- return true;
- }
- }
- }
- return false;
- }
- /**
- 示例
- <ss-inp
- v-model="xm"
- name="xm"
- placeholder="请输入姓名"
- type="text"
- ></ss-inp>
- */
- public static String getInputCode(String componentType, //组件类弄
- Map<String, String> inputproperties,//组件属性
- ObjB vo,
- String name, //input的name属性
- Map<String,Object>... paramArr //不写在input标签上的,组件参数
- ){
- //20251024新加 getInputCode方法的paramArr参数
- //下面相当于 boolean isInfo = pageobj.isInfo; pageobj就是当前发布的页面
- Boolean isInfo = false;
- if(paramArr!=null&¶mArr.length>0){
- Map<String,Object> param = paramArr[0];
- Object isInfoObj = param.get("isInfo");
- if(isInfoObj!=null){
- isInfo = (Boolean)isInfoObj;
- }
- }
- // 默认值
- String heightStr = getAttributeStr(inputproperties, "height");
- String widthStr = getAttributeStr(inputproperties, "width");
- String maxHeightStr = getAttributeStr(inputproperties, "maxHeight");
- String valueStr = inputproperties.get("value");
- /* 再改,改为取值 "建筑物"。原为 "placeholder="建筑物"",导致输出到 vue 组件的 placeholder= 为 placeholder="placeholder="建筑物""。Lin
- String placeholder = getAttributeStr(inputproperties, "placeholder");
- */ String placeholder = inputproperties.get("placeholder");
- String classStr = getAttributeStr(inputproperties, "class");
- String styleStr = getAttributeStr(inputproperties, "style");
- //增加支持onchange事件 <input ssChg=‘xxx’/> Ben(20251218)
- String ssChgStr = getAttributeStr(inputproperties, PageCompC.TAG_ATTR_ssChg);
- //= "ssBtn=\"{desc:'附件',name:'fjid',val:'${dw.fjid}'}\""
- String ssBtnStr = getAttributeStr(inputproperties, "ssBtn");
- String ssBtnVal = null;
- //ssBtn扩展支持多个自定义按钮 20260402
- if(StringUtils.isNotBlank(ssBtnStr)) {
- //是json对象,示例:ssBtn="{desc:'附件',name:'fjid',val:'${dw.fjid}'}"
- if(isJsonObj(ssBtnStr)) {
- int startIndex = ssBtnStr.indexOf('{'); // 找到第一个 '{' 的位置
- int endIndex = ssBtnStr.lastIndexOf('}'); // 找到最后一个 '}' 的位置
- if (startIndex != -1 && endIndex != -1 && endIndex > startIndex) {
- ssBtnVal = ssBtnStr.substring(startIndex, endIndex + 1); // 提取 {} 及内部内容
- }
- //是json数组
- //示例:ssBtn="[{desc:'附件',name:'fjid',val:'${dw.fjid}'},{'desc':'插入模板','name':'insertTemplate','icon':'editor-icon-file','func':'window.handleInsertTemplate'},{'desc':'清空','name':'clearContent','icon':'editor-icon-eraser','func':'window.handleClearEditor'}]"
- }else{
- int startIndex = ssBtnStr.indexOf('['); // 找到第一个 '[' 的位置
- int endIndex = ssBtnStr.lastIndexOf(']'); // 找到最后一个 ']' 的位置
- if (startIndex != -1 && endIndex != -1 && endIndex > startIndex) {
- ssBtnVal = ssBtnStr.substring(startIndex, endIndex + 1); // 提取 {} 及内部内容
- }
- }
- }
- ObjFieldB objFieldB = vo.fieldMap.get(name);
- /* 再去掉,去掉没有写 placeholder 时的默认值 "文书类别" 等
- if(StringUtils.isBlank(placeholder)){
- placeholder = objFieldB.getDesc();
- }
- */
- Integer width = objFieldB.getWidth();
- Integer height = objFieldB.height;
- String closingTag = null;
- // String buttonStr = getAttributeStr(inputproperties, "button");
- // if (StringUtils.isNotBlank(buttonStr)) // 增加,转为新标准。Lin
- // buttonStr = buttonStr.replace("button=", "btn=");
- //布尔类型的对象属性的onoffButton改为在这处理 Ben(20251206)
- if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_onoffbtn)
- &&(objFieldB.type == ObjC.FIELD_boolType)){
- return getonoffInputCode(componentType, //组件类弄
- inputproperties,//组件属性
- vo,
- name, //input的name属性
- isInfo
- );
- }
- //返回初始化录入组件的JS
- StringBuilder sb = getInitInputComponentJs(componentType, //组件类弄
- name,//表单元素name
- valueStr //表单元素默认值
- );
- //隐藏字段 add by Ben(20260413)
- if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_hiden)) {
- /**
- <ss-hidden
- v-model="hkdqm"
- name="hkdqm"
- ></ss-hidden>
- */
- closingTag = "</ss-hidden>";
- sb.append(PageCompC.LINE_BREAK).append("<ss-hidden");
- //文本框
- }else
- //文本框
- if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_input)){
- /*
- <ss-inp
- v-model="xm"
- name="xm"
- placeholder="请输入姓名"
- :param="{'mode':'${dataType=='change'?'change':'edit'}','button':{'val':'${dw.fjid}','name':'fjid','desc':'附件','jlztm':'${dw.jlztm}','cmsUpdUrl':'<ss:serv name='regCms' dest='cmsHome' parm='{"wdConfirmationCaptchaService":"0"}' />','cmsAddUrl':'<ss:serv name='makeAttCms' parm='{"wdConfirmationCaptchaService":"0"}' />'}}"
- ></ss-inp>
- */
- closingTag = "</ss-inp>";
- sb.append("<ss-inp");
- /* 再去掉,去掉录入页里的默认 placeholder。Lin
- setTagAttr(sb, PageCompC.TAG_ATTR_placeholder,
- PageCompC.TAG_PLACEHOLDER_PREFIX_input + placeholder);
- */
- //如果有在input上标上附件按钮
- if(StringUtils.isNotBlank(ssBtnVal)) {
- // 使用Map创建JSON对象
- Map<String, Object> parmMap = new HashMap<>();
- parmMap.put("mode", "@dataType@");
- String cmsUpdateUrl = null;
- String cmsAddUrl = null;
- // 使用 TypeToken 明确指定 Map 的泛型类型
- Map<String, String> fjBtn = new Gson().fromJson(ssBtnVal,
- new TypeToken<Map<String, String>>(){}.getType());
- parmMap.put("button", fjBtn);
- /* 再改,去掉 "wdConfirmationCaptchaService":"0"。Lin
- Map<String, String> cmsUpdateMap = new HashMap<>();
- cmsUpdateMap.put(WebC.REQ_captchaServ, "0"); // ("wdConfirmationCaptchaService",。Lin
- cmsUpdateUrl = getServiceTag("regCms",
- "cmsHome",
- cmsUpdateMap);
- */
- /* 再改,cmsHome.ss.jsp 改为 cmsEdit.jsp,与 cmsPlay 对应。Lin
- cmsUpdateUrl = getServiceTag("regCms", "cmsHome", null);
- */ cmsUpdateUrl = getServiceTag("regCms", CmsC.CMS_editPage, null);
- /* 再改,去掉 "wdConfirmationCaptchaService":"0"。Lin
- Map<String, String> cmsAddMap = new HashMap<>();
- cmsAddMap.put(WebC.REQ_captchaServ, "0"); // ("wdConfirmationCaptchaService",。Lin
- cmsAddUrl = getServiceTag("makeAttCms",
- null,
- cmsAddMap);
- */ cmsAddUrl = getServiceTag("makeAttCms", null, null);
- fjBtn.put("cmsUpdUrl","@cmsUpdateUrl@");
- fjBtn.put("cmsAddUrl","@cmsAddUrl@");
- parmMap.put("button", fjBtn);
- Gson gson = new Gson();
- String parmStr = gson.toJson(parmMap)
- .replace("@dataType@","${dataType==\"change\"?\"change\":\"edit\"}")
- .replace("\"", "'");
- parmStr = parmStr.replace("@cmsUpdateUrl@",cmsUpdateUrl);
- parmStr = parmStr.replace("@cmsAddUrl@",cmsAddUrl);
- setTagAttr(sb,PageCompC.TAG_ATTR_param,parmStr);
- }
- }else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_time)||
- componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_date)){
- /*
- <ss-date-picker
- v-model="csrq"
- name="csrq"
- type="date"
- placeholder="请选择生日日期"
- width="300px"
- fmt="yyyy-MM-dd"
- ></ss-date-picker>
- */
- closingTag = "</ss-date-picker>";
- sb.append("<ss-date-picker");
- String type = PageCompC.TAG_ATTR_VALUE_date;
- if(objFieldB.type == ObjC.FIELD_dateType) { //只要有日期的,类似年朋日时分这样的,也必需在obj.xml配置为日期格式
- type = PageCompC.TAG_ATTR_VALUE_date;
- } else if (objFieldB.type == ObjC.FIELD_timeType) {
- type = PageCompC.TAG_ATTR_VALUE_time;
- }
- setTagAttr(sb,PageCompC.VUE_ATTR_type,type);
- if(StringUtils.isNotBlank(objFieldB.fmt)){
- setTagAttr(sb,PageCompC.TAG_ATTR_fmt,objFieldB.fmt);
- }
- if(StringUtils.isNotBlank(placeholder))
- /* 再改,对指定的 placeholder,不加 "请选择" 前缀。Lin
- setTagAttr(sb, PageCompC.TAG_ATTR_placeholder,
- PageCompC.TAG_PLACEHOLDER_PREFIX_select + placeholder);
- */ setTagAttr(sb, PageCompC.TAG_ATTR_placeholder, placeholder);
- }else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_img)){
- /**
- <ss-img
- name="zjzwj"
- v-model="zjzwj"
- class="id-photo"
- :cropper-opt="{
- width: 300,
- height: 420,
- aspectRatio: 5/7
- }"
- <%--下载download图片url--%>
- dl-url="/service?ssServ=dlByHttp&wdConfirmationCaptchaService=0&type=img"
- <%--上传upload图片url--%>
- ul-url="/service?ssServ=ulByA&type=img"
- ></ss-img>
- */
- closingTag = "</ss-img>";
- sb.append("<ss-img");
- // 使用Map创建JSON对象
- Map<String, String> parmMap = new HashMap<>();
- /* 再去掉,去掉 "wdConfirmationCaptchaService":"0"。Lin
- parmMap.put(WebC.REQ_captchaServ, "0"); // ("wdConfirmationCaptchaService",。Lin
- */
- parmMap.put("type", "img");
- // 将Map转换为JSON字符串
- String dlUrl = getServiceTag("dlByHttp",
- null,
- parmMap);
- setTagAttr(sb,PageCompC.TAG_ATTR_downloadUrl,dlUrl);
- parmMap = new HashMap<>();
- parmMap.put("type", "img");
- String ulUrl = getServiceTag("ulByHttp",//原值为"ulByA" Ben(20251205)
- null,
- parmMap);
- setTagAttr(sb,PageCompC.TAG_ATTR_uploadUrl,ulUrl);
- //裁剪图片宽高
- /* 改,默认值是 0.Lin
- if(width!=null&&height!=null){
- */ if (width > 0 && height > 0) {
- /// **
- // :cropper-opt="{
- // width: 300,
- // height: 420,
- // aspectRatio: 5/7
- // }
- /// *
- setTagAttr(sb,PageCompC.TAG_ATTR_VALUE_cropperOpt,"{width:"+width+",height:"+height+"}");
- }
- if(StringUtils.isNotBlank(placeholder))
- setTagAttr(sb, PageCompC.TAG_ATTR_placeholder,//修复设置少了placeholder属性名的问题 Ben(20251209)
- placeholder);
- }else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_html)){
- // sb.append("<% session.setAttribute(((DwPo)(request.getAttribute(\"dw\"))).getMswj(),wdUeditorPath); %>");
- /**
- *
- * 下面这个 wdConfirmationCaptchaService 是"强制验证码"的意思,后台的程序估计没用到
- *
- * 当附件ID为空时,点击附件按钮后,要先调用此cmsAddUrl服务创建一个内容,再调用cmsUpdUrl调用弹出附件编辑的页面
- <script type="text/javascript" charset="utf-8">
- function fjidfjEdit() {
- var fjName = 'fjid';
- var fjid = document.getElementsByName('fjid')[0].value;
- if (fjid == null || fjid == '') {//建一个新的内容,并返回内容ID
- $.ajax({
- type: 'post',
- url: '<ss:serv name='makeAttCms' parm='{"wdConfirmationCaptchaService":"0"}'/>',
- async: false,
- data: {name: 'fjid', ssNrObjName: 'sh', ssNrObjId: '${shid}'},
- success: function (_fjid) {
- fjid = _fjid;
- alert('新建的内容:'+fjid);
- document.getElementsByName('fjid')[0].value = fjid;
- }
- });
- }
- ;var str = '&nrid=T-' + fjid + '&objectId=' + fjid + '&objectName=' + fjName + '&callback=' + (window['fjidCallbackName'] || '');
- wd.display.showComponent({
- show: ['wdDialog'],
- url: '<ss:serv name='regCms' parm='{"wdConfirmationCaptchaService":"0"}' dest='cmsHome'/>' + str,
- title: '编辑',
- width: 900,
- high: 664
- });
- }
- </script>
- *
- <ss-editor
- v-model="mswj"
- name="mswj"
- :height="500"
- :readonly="false"
- placeholder="请输入内容"
- url="/service?ssServ=loadEditorBody"
- :param="{'obj':'dw','button':[{'desc':'附件','name':'fjid','val':'${dw.fjid}','cmsUpdUrl':'<ss:serv name='regCms' parm='{"wdConfirmationCaptchaService":"0"}' dest='cmsHome'/>','cmsAddUrl':'<ss:serv name='makeAttCms' parm='{"wdConfirmationCaptchaService":"0"}}],'mode':'change','jlztm':'${dw.jlztm}'}"
- ></ss-editor>
- */
- closingTag = "</ss-editor>";
- String cmsUpdateUrl = null;
- String cmsAddUrl = null;
- sb.append("<ss-editor");
- if(StringUtils.isNotBlank(heightStr)){
- sb.append(PageCompC.LINE_BREAK).append(PageCompC.COLON).append(heightStr.replace("px", ""));
- }
- setTagAttr(sb,PageCompC.TAG_ATTR_html,name+"Html");//ss-editor富文本编辑器扩展的正文内容属性 Ben(20260408)
- //获取要回显的富文本的url属性
- String url = getServiceTag("loadEditorBody",
- null,
- null);
- setTagAttr(sb,PageCompC.TAG_ATTR_url,url);
- // 使用Map创建JSON对象
- Map<String, Object> parmMap = new HashMap<>();
- parmMap.put("obj", vo.getName());
- // parmMap.put("mode", "${dataType==\"change\"?\"change\":\"edit\"}");
- parmMap.put("mode", "@dataType@");
- parmMap.put("jlztm", getElExp(vo,"jlztm"));
- //附件按钮
- // if(vo.fieldMap.get("fjid")!=null) {
- //如果有在input上标上附件按钮
- if(StringUtils.isNotBlank(ssBtnVal)) {
- // List<Map<String, String>> buttonList = new ArrayList<>();
- // parmMap.put("button", buttonList);
- // Map<String, String> fjBtn = new HashMap<>();
- //以前ssBtnVal只支持附件按钮,现在扩展支持自定义按钮 start Ben(20260401)
- ssBtnVal = ssBtnVal.trim();
- //如果只有一个按钮
- if (ssBtnVal.startsWith("{") && ssBtnVal.endsWith("}")) {
- // 使用 TypeToken 明确指定 Map 的泛型类型
- Map<String, String> btnMap = new Gson().fromJson(ssBtnVal,
- new TypeToken<Map<String, String>>(){}.getType());
- parmMap.put("button", btnMap);//加到发布后的数组
- // 如果是附件按钮,补属性
- String btnName = btnMap.get("name");
- if (StringUtils.isNotBlank(btnName)&&"fjid".equals(btnName)) {
- // buttonList.add(fjBtn);
- // fjBtn.put("desc", "附件");
- // fjBtn.put("name", "fjid");
- // fjBtn.put("val",getElExp(vo,"fjid"));
- // fjBtn.put("name", "附件");
- // fjBtn.put("key", "fjid");
- // fjBtn.put("value",getElExp(vo,"fjid"));
- /* 再改,去掉 "wdConfirmationCaptchaService":"0"。Lin
- Map<String, String> cmsUpdateMap = new HashMap<>();
- cmsUpdateMap.put(WebC.REQ_captchaServ, "0"); // ("wdConfirmationCaptchaService",。Lin
- cmsUpdateUrl = getServiceTag("regCms",
- "cmsHome",
- cmsUpdateMap);
- */
- /* 再改,cmsHome.ss.jsp 改为 cmsEdit.jsp,与 cmsPlay 对应。Lin
- cmsUpdateUrl = getServiceTag("regCms", "cmsHome", null);
- */ cmsUpdateUrl = getServiceTag("regCms", CmsC.CMS_editPage, null);
- /* 再改,去掉 "wdConfirmationCaptchaService":"0"。Lin
- Map<String, String> cmsAddMap = new HashMap<>();
- cmsAddMap.put(WebC.REQ_captchaServ, "0"); // ("wdConfirmationCaptchaService",。Lin
- cmsAddUrl = getServiceTag("makeAttCms",
- null,
- cmsAddMap);
- */ cmsAddUrl = getServiceTag("makeAttCms", null, null);
- btnMap.put("cmsUpdUrl","@cmsUpdateUrl@");
- btnMap.put("cmsAddUrl","@cmsAddUrl@");
- }
- //是数组,表示有多个按钮
- } else if (ssBtnVal.startsWith("[") && ssBtnVal.endsWith("]")) {
- Type listType = new TypeToken<List<Map<String, String>>>(){}.getType();
- List<Map<String, String>> btnList = new Gson().fromJson(ssBtnVal, listType);
- parmMap.put("button", btnList);//加到发布后的数组
- // 遍历查找并修改
- for (Map<String, String> btnMap : btnList) {
- // 如果是附件按钮,补属性
- String btnName = btnMap.get("name");
- if (StringUtils.isNotBlank(btnName)&&"fjid".equals(btnName)) {
- /* 再改,cmsHome.ss.jsp 改为 cmsEdit.jsp,与 cmsPlay 对应。Lin
- cmsUpdateUrl = getServiceTag("regCms", "cmsHome", null);
- */ cmsUpdateUrl = getServiceTag("regCms", CmsC.CMS_editPage, null);
- cmsAddUrl = PageCompU.getServiceTag("makeAttCms", null, null);
- btnMap.put("cmsUpdUrl", "@cmsUpdateUrl@");
- btnMap.put("cmsAddUrl", "@cmsAddUrl@");
- break;
- }
- }
- } else {
- System.out.println("错误:ssBtn内容字符串不是有效的JSON格式!!");
- }
- //以前ssBtnVal只支持附件按钮,现在扩展支持自定义按钮 end Ben(20260401)
- }
- Gson gson = new Gson();
- String parmStr = gson.toJson(parmMap)
- .replace("@dataType@","${dataType==\"change\"?\"change\":\"edit\"}")
- .replace("\"", "'");
- if(StringUtils.isNotBlank(cmsUpdateUrl))
- parmStr = parmStr.replace("@cmsUpdateUrl@",cmsUpdateUrl);
- if(StringUtils.isNotBlank(cmsAddUrl))
- parmStr = parmStr.replace("@cmsAddUrl@",cmsAddUrl);
- setTagAttr(sb,PageCompC.TAG_ATTR_param,parmStr);
- }else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_objp)){
- /**
- <ss-objp
- v-model="xbm"
- name="xbm"
- :opt="xbmOption"
- placeholder="请选择性别"
- :filter="{'dwid':'88'}"
- width="100px"
- inp="true"
- url="/service?ssServ=loadObjpOpt&objectpickerdropdown1=1"
- cb="xb"
- onChange="callBackFunName"
- ></ss-objp>
- */
- closingTag = "</ss-objp>";
- sb.append("<ss-objp");
- setTagAttr(sb,PageCompC.TAG_ATTR_opt,name+"Option");
- if(StringUtils.isNotBlank(placeholder))
- /* 再改,对指定的 placeholder,不加 "请选择" 前缀。Lin
- setTagAttr(sb, PageCompC.TAG_ATTR_placeholder,
- PageCompC.TAG_PLACEHOLDER_PREFIX_select + placeholder);
- */ setTagAttr(sb, PageCompC.TAG_ATTR_placeholder, placeholder);
- if (inputproperties.get("ssFilterField") != null)// add by Ben(20260313)
- setTagAttr(sb,PageCompC.TAG_ATTR_filterField,inputproperties.get("ssFilterField"));
- /// 再增加,增加支持 <field filter="dwid"。Lin
- else if (objFieldB.filterFieldStr != null)
- setTagAttr(sb, PageCompC.TAG_ATTR_filterField, objFieldB.filterFieldStr);
- ///
- if (inputproperties.get("ssFilter") != null)
- setTagAttr(sb,PageCompC.TAG_ATTR_filter,inputproperties.get("ssFilter"));
- else if (objFieldB.cbParmStr != null) // <field cbParm=,里层的引号,要用 "。Lin
- setTagAttr(sb,PageCompC.TAG_ATTR_filter,objFieldB.cbParmStr);
- String inputValue = inputproperties.get(PageCompC.TAG_ATTR_inp) ; // ("inp")。Lin
- // String inputValue = inputproperties.get("wdInput") == null ?
- // inputproperties.get("input") : inputproperties.get("wdInput");
- if (StringUtils.isBlank(inputValue)) // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin
- inputValue = ((objFieldB.inpable) ? "true" : "false");
- setTagAttr(sb,PageCompC.VUE_ATTR_inp,inputValue);
- // 使用Map创建JSON对象
- Map<String, String> parmMap = new HashMap<>();
- parmMap.put("objectpickerdropdown1", "1");
- /// 再增加,增加支持 <field filter="dwid"。Lin
- // url="<ss:serv name='loadObjpOpt' parm='{"objectpickerdropdown1":"1","objectpickerfilterField":"dwid"}' />"
- if (objFieldB.filterFieldStr != null)
- parmMap.put("objectpickerfilterField", objFieldB.filterFieldStr);
- ///
- // 将Map转换为JSON字符串
- String url = getServiceTag("loadObjpOpt",
- null,
- parmMap);
- setTagAttr(sb,PageCompC.TAG_ATTR_url,url);
- String cbName = null;
- if (inputproperties.get("wdCodebook") != null)
- cbName = inputproperties.get("wdCodebook");
- else if (objFieldB.inpCbName != null)
- cbName = objFieldB.inpCbName;
- else if (objFieldB.cbName != null)
- cbName = objFieldB.cbName;
- setTagAttr(sb,PageCompC.TAG_ATTR_cb,cbName);
- //对象属性类型为boolean的onoff
- }
- // 布尔类型onoffBtn改为在前面处理 Ben(20251206)
- // else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_onoffbtn)
- // &&(objFieldB.type == ObjC.FIELD_boolType)) {
- //
- // /**
- // <ss-onoff
- // v-model="sfqy"
- // name="sfqy"
- // label="是"
- // value="1"
- // :multiple="false"
- // :readonly="false"
- // />
- // <ss-onoff
- // v-model="sfqy"
- // name="sfqy"
- // label="否"
- // value="1"
- // :multiple="false"
- // />
- // */
- //
- //
- // }
- setTagAttr(sb,PageCompC.TAG_ATTR_vmodel,name);
- setTagAttr(sb,PageCompC.TAG_ATTR_name,name);
- if(isInfo)
- setTagAttr(sb,PageCompC.TAG_ATTR_readonly,"true");
- else
- setTagAttr(sb,PageCompC.TAG_ATTR_readonly,"false");
- if(StringUtils.isNotBlank(widthStr)){
- sb.append(PageCompC.LINE_BREAK).append(widthStr);
- }
- /// 再增加,增加支持 <obj <field width="200"。Lin
- // 把 width:200px 也加到 stype= 里
- else if (objFieldB.width > 0) {
- setTagAttr(sb, PageCompC.VUE_ATTR_width, objFieldB.width + "px");
- // 写到 styleStr 里 -- 下面才用 styleStr 输出到 sb 里。Lin
- if (StringUtils.isBlank(styleStr))
- styleStr = "style=\"";
- else // "style=\"xxx:yyy;\""。Lin
- styleStr = styleStr.substring(0, styleStr.length() -1);
- styleStr += "width:" + objFieldB.width + "px;\"";
- }
- ///
- if(StringUtils.isNotBlank(heightStr)&&!componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_html)){
- sb.append(PageCompC.LINE_BREAK).append(heightStr);
- }
- if(StringUtils.isNotBlank(classStr)){
- sb.append(PageCompC.LINE_BREAK).append(classStr);
- }
- if(StringUtils.isNotBlank(styleStr)){
- sb.append(PageCompC.LINE_BREAK).append(styleStr);
- }
- //增加支持onchange事件 <input ssChg=‘xxx’/> Ben(20251218)
- if(StringUtils.isNotBlank(ssChgStr)){
- /* 再改,改用增加的 VUE_ATTR_onChange = "onChange" -- <ss-objp 里的 onChange= 不改。Lin
- * 原,混用 PageCompC.TAG_ATTR_onChange,导致 <ss-objp 里的 onChange= 也被改为 chg=
- sb.append(PageCompC.LINE_BREAK).append(ssChgStr.replace(PageCompC.TAG_ATTR_ssChg,
- PageCompC.TAG_ATTR_onChange));
- */ sb.append(PageCompC.LINE_BREAK).append(ssChgStr.replace(PageCompC.TAG_ATTR_ssChg, PageCompC.VUE_ATTR_onChange));
- }
- sb.append(PageCompC.LINE_BREAK).append(">").//"/>"改为">" Ben(20251218)
- append(PageCompC.LINE_BREAK)
- .append(PageCompC.LINE_BREAK).append(closingTag).append(PageCompC.LINE_BREAK);
- return sb.toString();
- }
- public static String getonoffInputCode(String componentType, //组件类弄
- Map<String, String> inputproperties,//组件属性
- ObjB vo,
- String name, //input的name属性
- Boolean isReadonly
- ){
- ObjFieldB objFieldB = vo.fieldMap.get(name);
- if((!componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_onoffbtn))
- ||(objFieldB.type != ObjC.FIELD_boolType)){
- return null;
- }
- // 默认值
- String heightStr = getAttributeStr(inputproperties, "height");
- String widthStr = getAttributeStr(inputproperties, "width");
- String valueStr = inputproperties.get("value");
- String classStr = getAttributeStr(inputproperties, "class");
- String styleStr = getAttributeStr(inputproperties, "style");
- //返回初始化录入组件的JS
- StringBuilder sb = getInitInputComponentJs(componentType, //组件类弄
- name,//表单元素name
- valueStr //表单元素默认值
- );
- /**
- <ss-onoff
- v-model="sfqy"
- name="sfqy"
- label="是"
- value="1"
- :multiple="false"
- />
- <ss-onoff
- v-model="sfqy"
- name="sfqy"
- label="否"
- value="1"
- :multiple="false"
- />
- */
- String ClosingTag = "</ss-onoff>";
- //是按钮
- sb.append("<ss-onoff");
- setTagAttr(sb,PageCompC.TAG_ATTR_vmodel,name);
- setTagAttr(sb,PageCompC.TAG_ATTR_name,name);
- setTagAttr(sb,PageCompC.TAG_ATTR_label,"是");
- setTagAttr(sb,PageCompC.TAG_ATTR_value, AppC.IF_true+"");
- setTagAttr(sb,PageCompC.TAG_ATTR_multiple,PageCompC.VALUE_FALSE);
- if(StringUtils.isNotBlank(widthStr)){
- sb.append(PageCompC.LINE_BREAK).append(widthStr);
- }
- if(StringUtils.isNotBlank(heightStr)&&!componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_html)){
- sb.append(PageCompC.LINE_BREAK).append(heightStr);
- }
- if(StringUtils.isNotBlank(classStr)){
- sb.append(PageCompC.LINE_BREAK).append(classStr);
- }
- if(StringUtils.isNotBlank(styleStr)){
- sb.append(PageCompC.LINE_BREAK).append(styleStr);
- }
- setTagAttr(sb,PageCompC.TAG_ATTR_readonly,"false");
- /* 再改。Ben
- sb.append(PageCompC.LINE_BREAK).append("/>").append(PageCompC.LINE_BREAK);
- */ sb.append(PageCompC.LINE_BREAK).append(">").append(ClosingTag).append(PageCompC.LINE_BREAK);
- //否按钮
- sb.append("<ss-onoff");
- setTagAttr(sb,PageCompC.TAG_ATTR_vmodel,name);
- setTagAttr(sb,PageCompC.TAG_ATTR_name,name);
- setTagAttr(sb,PageCompC.TAG_ATTR_label,"否");
- setTagAttr(sb,PageCompC.TAG_ATTR_value,AppC.IF_false+"");
- setTagAttr(sb,PageCompC.TAG_ATTR_multiple,PageCompC.VALUE_FALSE);
- if(StringUtils.isNotBlank(widthStr)){
- sb.append(PageCompC.LINE_BREAK).append(widthStr);
- }
- if(StringUtils.isNotBlank(heightStr)&&!componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_html)){
- sb.append(PageCompC.LINE_BREAK).append(heightStr);
- }
- if(StringUtils.isNotBlank(classStr)){
- sb.append(PageCompC.LINE_BREAK).append(classStr);
- }
- if(StringUtils.isNotBlank(styleStr)){
- sb.append(PageCompC.LINE_BREAK).append(styleStr);
- }
- setTagAttr(sb,PageCompC.TAG_ATTR_readonly,"false");
- /* 再改。Ben
- sb.append(PageCompC.LINE_BREAK).append("/>").append(PageCompC.LINE_BREAK)
- */ sb.append(PageCompC.LINE_BREAK).append(">").append(ClosingTag).append(PageCompC.LINE_BREAK);;
- return sb.toString();
- }
- //返回初始化级联菜单录入组件的JS
- public static String getInitInputCcpComponentJs(String componentType, //组件类弄
- CcpB ccp,//级联菜单配置
- String prfx, //级联配置中的前缀
- String dxm, //对象名
- String val //整个级联的值(通常是带编码规则的)
- ){
- StringBuilder sb = new StringBuilder(PageCompC.TAG_JS_SCRIPT_start);
- if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_ccpsingle)){
- /*
- ss.dom.formElemConfig.hkdqm={value:'${ry.hkdqm}',type: 51};
- */
- String inputName = prfx + ccp.combField.name;
- String value = val;
- if(StringUtils.isBlank(value))
- value = (new StringBuilder("${").append(dxm).append(".")
- .append(inputName).append("}")).toString();
- sb.append("ss.dom.formElemConfig.").append(inputName).append("={");
- sb.append("val:'").append(value).append("',type:").append(componentType)
- .append("};").append(PageCompC.LINE_BREAK);
- //下面的可能没用,先去掉
- // for (CcpFieldB input : ccp.combField.fieldList) {
- // inputName = prfx + input.name;
- // sb.append("ss.dom.formElemConfig.").append(inputName).append("={");
- // sb.append("val:'-1',type:").append(componentType)
- // .append("};").append(PageCompC.LINE_BREAK);
- // }
- }else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_ccpmutiple)){
- /*
- 改为:
- ss.dom.formElemConfig.xbm={value:'${ry.dwid}',type: 52};
- ss.dom.formElemConfig.xbm={value:'${ry.bmid}',type: 52};
- ss.dom.formElemConfig.xbm={value:'${ry.sjryid}',type: 52};
- */
- for (CcpFieldB input : ccp.combField.fieldList) {
- String inputName = prfx + input.name;
- sb.append("ss.dom.formElemConfig.").append(inputName).append("={");
- sb.append("val:'").append("${").append(dxm).append(".")
- .append(inputName).append("}',type:").append(componentType)
- .append("};").append(PageCompC.LINE_BREAK);
- }
- }
- sb.append(PageCompC.TAG_JS_SCRIPT_end);
- return sb.toString();
- }
- //返回初始化录入组件的JS
- public static StringBuilder getInitInputComponentJs(String componentType, //组件类弄
- String inputName,//表单元素name
- String inputValue //表单元素默认值
- ){
- // "ss.dom.formElemConfig.xm={value:'"
- StringBuilder sb = new StringBuilder(PageCompC.TAG_JS_SCRIPT_start);
- if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_ccpsingle)){
- }else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_ccpmutiple)){
- // }else if(componentType.equals(PageCompC.FORM_PLUGIN_JS_TYPE_onoffbtn)){
- // sb.append("if(!ss.dom.formElemConfig.").append(inputName).append(")\r\n ");
- // sb.append("ss.dom.formElemConfig.").append(inputName).append("={");
- //
- // if(StringUtils.isNotBlank(inputValue))
- // sb.append("val:'").append(inputValue).append("',type:").append(componentType);
- // else
- // sb.append("val:null,type:").append(componentType);
- //
- // sb.append("};");
- }else{
- sb.append("ss.dom.formElemConfig.").append(inputName).append("={");
- if(StringUtils.isNotBlank(inputValue))
- /* 下面从"'"改为"`",防止值有特殊字符20260512
- sb.append("val:'").append(inputValue).append("',type:").append(componentType);
- */ sb.append("val:`").append(inputValue).append("`,type:").append(componentType);
- else
- sb.append("val:null,type:").append(componentType);
- sb.append("};");
- }
- sb.append(PageCompC.TAG_JS_SCRIPT_end);
- return sb;
- }
- public static String compTagByContext(String content,
- //保存发布页面时,行与行之间的关联
- Map<String,List<Map<String,String>>> context
- ) {
- StringBuilder sb = new StringBuilder();
- //匹配<xxx.ss 标签
- for (String patt : PageCompC.PAGE_ssTagReg) { // patterns。Lin
- sb.setLength(0);
- Matcher matcher = Pattern.compile(patt).matcher(content);
- while (matcher.find()) {
- String tag = matcher.group();
- try {
- tag = TagComper.compTagByContext(tag,context);
- } catch (Exception e) {
- log4j.error("PageCompU.compTag( 异常", e);
- }
- if(StringUtils.isNotBlank(tag))
- matcher.appendReplacement(sb, Matcher.quoteReplacement(tag));
- }
- matcher.appendTail(sb);
- content = sb.toString();
- }
- /**
- 解决 input标签属性中有ss闭标签<ss:xx />,导致下面通过XML的方式解析input标签失败的问题 Ben(20251208)
- <ss:xx > xxx </ss:xx>这种非闭标签的情况先不处理,以后页面全面改为ajax方式时,这种非标签的应该就不存在
- (非标签的应该都是逻辑标签,以后逻辑通过JS实现)。
- */
- //start
- Map<String,String> tmpMarkMap = new HashMap<>();
- content = replaceSsTags2TmpMark(content,tmpMarkMap);
- //end
- //匹配<input 标签
- for (String patt : PageCompC.PAGE_inputTagReg) { // patterns。Lin
- sb.setLength(0);
- Matcher matcher = Pattern.compile(patt).matcher(content);
- while (matcher.find()) {
- String tag = matcher.group();
- try {
- tag = TagComper.compInputTagByContext(tag,context);
- if(tag==null)
- continue;
- } catch (Exception e) {
- log4j.error("PageCompU.compTag( 异常2", e);
- }
- matcher.appendReplacement(sb, Matcher.quoteReplacement(tag));
- }
- matcher.appendTail(sb);
- content = sb.toString();
- }
- //替换临时标记为<ss:xx /> Ben(20251208)
- content = replaceTmpMark2SsTags(content,tmpMarkMap);
- return content;
- }
- //替换<ss:xx />为临时标记,避免XML解析冲突 Ben(20251208)
- public static String replaceSsTags2TmpMark(String input,Map<String,String> tmpMarkMap) {
- // 匹配 <ss:任意单词 后面跟着任意属性直到/> 的标签
- String regex = "<ss:\\w+\\s+[^>]*/>";
- Pattern pattern = Pattern.compile(regex);
- Matcher matcher = pattern.matcher(input);
- int serialNumber = 1;
- StringBuffer result = new StringBuffer();
- while (matcher.find()) {
- // matcher.group() 返回当前匹配到的完整字符串
- String matchedText = matcher.group();
- String replacement = "@ss:" + (serialNumber++) + "@";
- matcher.appendReplacement(result, Matcher.quoteReplacement(replacement));
- tmpMarkMap.put(replacement,matchedText);
- }
- matcher.appendTail(result);
- return result.toString();
- }
- //替换临时标记为<ss:xx /> Ben(20251208)
- public static String replaceTmpMark2SsTags(String input,Map<String,String> tmpMarkMap) {
- for (String s : tmpMarkMap.keySet()) {
- String v = tmpMarkMap.get(s);
- input = input.replace(s,v);
- }
- return input;
- }
- // === "新UI增加的 end" ===
- // 增加,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
- private static final Logger log4j = LogManager.getLogger(PageCompU.class);
- // 来自 FileTranslator.transformCommonwrite(StringReader reader, String dm, String ymid, String wzid, GeneralDBAccess gdba)。Lin
- // 去掉 ymid、wzid、gdba
- // 去掉 dm,没用到了
- // reader(StringReader) 改为 fileName(String) -- 移到 compFile() 里读入
- // 改为 public
- public static StringReader compFile(String fileName) throws IOException {
- StringReader reader = getSourceCode(fileName); // 增加,在这读入。Lin
- // System.out.println("进入common:write转换程序");
- // System.out.println("转换:" + file);
- // String content = FileUtils.readFileToString(file, "utf-8");
- // if (!CoreConstVars.TRANSFORM_COMMONWRITE_TAG) {
- // return new StringReader(content);
- // }
- BufferedReader in = new BufferedReader(reader);
- String s;
- /* 再改,IDEA:'StringBuffer content' may be declared as 'StringBuilder'。Lin
- StringBuffer content=new StringBuffer();
- */ StringBuilder content=new StringBuilder();
- /// 改为新UI,增加。Lin
- //保存发布页面时,行与行之间的关联
- Map<String,List<Map<String,String>>> context = new HashMap<>();
- ///
- while ((s = in.readLine()) != null){
- /* 去掉 dm,不支持多个应用。Lin
- content.append(transformCommonwrite(s, dm, ymid, wzid, gdba)+"\r\n");
- */
- /* 再改,IDEA:String concatenation as argument to 'StringBuilder.append()' call。Lin
- content.append(compTag(s)+"\r\n");
- */
- /* 改为新UI。Lin
- content.append(compTag(s)).append("\r\n");
- */ content.append(compTagByContext(s, context)).append("\r\n");
- }
- // System.out.println("common:write转换完毕·-·");
- return new StringReader(content.toString());
- }
-
- // 来自 FileTranslator.transformCommonwrite(String content, String dm, String ymid, String wzid, GeneralDBAccess wdGdba)。Lin
- // 去掉 public,改为私有 private
- // 去掉入口参数 ymid、wzid、gdba(wdgdba)
- // 去掉 dm,直接用 PrjApp.prjName。Lin
- public static String compTag(String content) {
- /* 改为 <xxx@ss />。Lin
- String[] patterns = new String[] {
- "<(wd|common):write[^>]*?/>", "<(wd|common):write[^>]*?></\\1:write[^>]*?>"
- };
- */
- /* 再改用 PageCompC.PAGE_ssReg。Lin
- String[] patterns = new String[] {"<[a-z]*@ss[^>]*?/>",
- "<[a-z]*@ss[^>]*?>",
- "</[a-z]*@ss[^>]*?>"}; // 包含 "</@ss>"。Lin
- */
- /* 去掉 CommonWriteFactory 的构造方法,去掉了 CommonWriteFactory 的那些变量。Lin
- * 去掉 dm,直接用 PrjApp.prjName
- * 去掉 CommonWriteFactory 了,纳入 TagComper
- CommonWriteFactory cwf = new CommonWriteFactory(dm, wzid, ymid, wdGdba);
- */
- /* 再改,IDEA:'StringBuffer sb' may be declared as 'StringBuilder'。Lin
- StringBuffer sb = new StringBuffer();
- */ StringBuilder sb = new StringBuilder();
- for (String patt : PageCompC.PAGE_ssTagReg) { // patterns。Lin
- // System.out.println(patt);
- sb.setLength(0);
- Matcher matcher = Pattern.compile(patt).matcher(content);
- // dm = dm == null ? "" : dm;
- // ymid = ymid == null ? "" : ymid;
- // wzid = wzid == null ? "" : wzid;
- // String otherparamsString = " appName_0=\"" + dm + "\" ymid_0=\""
- // +
- // ymid
- // + "\" wzid_0=\"" + wzid + "\"";
- while (matcher.find()) {
- String tag = matcher.group();
- // System.out.println("<<<" + tag);
- // .replaceFirst("(wd:write)",
- // "$1 " + otherparamsString);
- // TagTransformer t = cwf
- // .getTransformer((String) TagTransformerAdapter
- // .parseAttrFromSrc(tag).get("type"));
- // if (t != null)
- // tag = t.transform(tag);
- try {
- tag = TagComper.compTag(tag); // cwf.。Lin
- /* 再改,IDEA:'catch' branch identical to 'RuntimeException' branch。Lin
- } catch (RuntimeException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
- */
- } catch (Exception e) {
- /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
- e.printStackTrace();
- */ log4j.error("PageCompU.compTag( 异常", e);
- }
- // System.out.println(">>>" + tag);
- // tag =
- // tag.replaceAll("(appName|ymid|wzid)_0\\s*=('|\").*?\\2",
- // "");
- matcher.appendReplacement(sb, Matcher.quoteReplacement(tag));
- }
- matcher.appendTail(sb);
- content = sb.toString();
- }
- return content;
- }
-
- // 来自 PageBuilderFactory.getSourceCode()。Lin
- // 去掉 public,改为私有 private
- // 加了入口参数 fileName -- 绕过一大堆乱七八糟的东西。Lin
- private static StringReader getSourceCode(String fileName) {
- try {
- /* 去掉,部件在另一套程序里处理 -- 不会调用此方法 getSourceCode()。Lin
- if(this.getPageobj()!=null)
- return getSourceCode(this.getPageobj());
- */
- /* 去掉 PageBuilderFactory.sourcePath,直接使用入口参数。Lin
- String content=FileAssistant.readFileToString(sourcePath);
- */ String content = FileU.rdStr(fileName);
- /// 再增加,IDEA -- Argument 'content' might be null。Lin
- if (content == null)
- content = "";
- ///
- BufferedReader in = new BufferedReader(new StringReader(content));
- /* 再改为 IDEA 规范。Lin
- StringBuffer sb = new StringBuffer();
- */ StringBuilder sb = new StringBuilder();
- String s;
- while ((s = in.readLine()) != null) {
- //非加密模式加密部件
- if (PrjApp.thdPrjApp.get().inDebug) { // (PrjApp.inDebug)。Lin
- /* 再改,IDEA:String concatenation as argument to 'StringBuilder.append()' call。Lin
- sb.append(s + "\r\n");
- */ sb.append(s).append("\r\n");
- } else {
- /* 去掉 translateSourceCode() 的 appName 入口参数,不支持多个应用。Lin
- * 去掉 translateSourceCode() 的 bjlbm(String) 入口参数
- sb.append(translateSourceCode(s, this.getWebapp().getName(),null) + "\r\n");
- */
- /* 再改,IDEA:String concatenation as argument to 'StringBuilder.append()' call。Lin
- sb.append(translateSourceCode(s) +"\r\n");
- */ sb.append(translateSourceCode(s)).append("\r\n");
- }
- }
- return new StringReader(sb.toString());
- }catch (Exception e) {
- /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
- e.printStackTrace();
- */ log4j.error("PageCompU.getSourceCode() 异常", e);
- }
- return new StringReader("");
- }
-
-
- // 来自 PageBuilderFactory.(String) getSourceContent(String path)。Lin
- // 与 (StringReader) getSourceCode(String fileName) 几乎一样
- /* 去掉,统一用 CompFile() -- 用 getSourceCode()。Lin
- public static String getSourceContent(String path){
- String c="";
- try {
-
-
- String content = FileU.rdStr(path); // FileAssistant.readFileToString(。Lin
- BufferedReader in = new BufferedReader(new StringReader(content));
- StringBuffer sb=new StringBuffer();
- String s="";
- while ((s = in.readLine()) != null) {
- //非加密模式加密部件
- if(!PrjApp.inDebug){ // getWebapp().isDevelopMode()==false。Lin
- /// * 去掉 appName,不支持多个应用。Lin
- // * 去掉 bjlbm(String),不允许同名
- // sb.append(translateSourceCode(s,this.getWebapp().getName(),null) + "\r\n");
- /// *
- sb.append(translateSourceCode(s) + "\r\n");
- }else{
- sb.append(s + "\r\n");
- }
- }
- return sb.toString();
-
- }catch (Exception e) {
- e.printStackTrace();
- }
-
- return c;
- }
- */
-
- // 来自 PageBuilderFactory.translateSourceCode()。Lin
- // 去掉 static,改为非静态
- // 去掉 appName 入口参数,不支持多个应用。Lin
- // 去掉 bjlbm(String),getSourceCode() 调用时转为 null
- private static String translateSourceCode(String html){
-
- // boolean isMobile=isMobile(bjlbm);
- // System.out.println("isMobile:"+isMobile);
- try {
- for (String reg : new String[] {
- /* 再改,IDEA:'\'' is unnecessarily escaped。Lin
- * 用到再改,规范命名???Lin
- * @service > <serv.ss
- * dest > ssDest
- * wdOutputComponent1 > ssMdDest
- "@service\\{.*?(dest\\s*\\:\\s*[\"\'](.*?)[\"\']).*?\\}@",
- "@service\\{.*?(dest\\s*\\:\\s*\\{.*?name\\s*\\:\\s*[\"\'](.*?)[\"\'].*?\\}).*?\\}@",
- "@service\\{.*?(wdOutputComponent1\\s*\\:\\s*[\"\'](.*?)[\"\']).*?\\}@"
- */
- "@service\\{.*?(dest\\s*\\:\\s*[\"'](.*?)[\"']).*?\\}@",
- "@service\\{.*?(dest\\s*\\:\\s*\\{.*?name\\s*\\:\\s*[\"'](.*?)[\"'].*?\\}).*?\\}@",
- "@service\\{.*?(wdOutputComponent1\\s*\\:\\s*[\"'](.*?)[\"']).*?\\}@"
- }
- ) {
- Pattern p = Pattern.compile(reg);
- // @service{name:"sq_cx",dest:{name:"sq_cx",type:"80"}}@
- Matcher m = p.matcher(html);
- while (m.find()) {
- String atservice = m.group(0); //@service{name:\"sq_cx\",dest:\"lc.sd_sq_cx\",show:\"wdDialog\",param:{dxid:\"${dxid}\"}}@
- String destAttr = m.group(1); //dest:\"lc.sd_sq_cx\"
- String dest = m.group(2); //lc.sd_sq_cx
- /* 去掉 UrlTranslator,isEl()移到 StrUtil。Lin
- if(UrlTranslator.isEl(dest))
- */
- if (StrU.isEl(dest))
- continue;
- //noinspection DuplicatedCode
- String id = PageU.md5PageName(dest); // FileAssistant.encriptDesignId()。Lin
-
- // if(isMobile){
- // //移动端首页
- // if(WebUtil.findPageObjectById(dest, wd.core.web.entity.page.PageObject.BJLBM_MOBILE_PAD_SY, appName)!=null){
- // id=dest;
- // }else if(WebUtil.findPageObjectById(dest, wd.core.web.entity.page.PageObject.BJLBM_MOBILE_SY, appName)!=null){
- // id=dest;
- // }
- // }
-
- //dest:'aaaaaaa'
- String newDestAttr = destAttr.replaceFirst(Pattern.quote(dest),
- Matcher.quoteReplacement(id)); //第一个参数是正则,要转成不是正则,不然就报错了
- String newatservice = atservice.replaceFirst(Pattern.quote(destAttr),
- Matcher.quoteReplacement(newDestAttr));
- html = html.replaceFirst(Pattern.quote(atservice),
- Matcher.quoteReplacement(newatservice));
- }
- }
- for (String reg : new String[]{
- /* 再改,IDEA:'\'' is unnecessarily escaped。Lin
- "@service\\{.*?(name\\s*\\:\\s*[\"\'](homePlugin.*?)\\_load[\"\']).*?\\}@"
- */ "@service\\{.*?(name\\s*\\:\\s*[\"'](homePlugin.*?)\\_load[\"']).*?\\}@"
- }
- ) {
- Pattern p = Pattern.compile(reg);
- // @service{name:"sq_cx",dest:{name:"sq_cx",type:"80"}}@
- Matcher m = p.matcher(html);
- while(m.find()){
- String atservice = m.group(0); //@service{name:\"sq_cx\",dest:\"lc.sd_sq_cx\",show:\"wdDialog\",param:{dxid:\"${dxid}\"}}@
- String destAttr = m.group(1); //dest:\"lc.sd_sq_cx\"
- String dest = m.group(2); //lc.sd_sq_cx
- //noinspection DuplicatedCode
- String id = PageU.md5PageName(dest); // FileAssistant.encriptDesignId()。Lin
- //dest:'aaaaaaa'
- String newDestAttr = destAttr.replaceFirst(Pattern.quote(dest),
- Matcher.quoteReplacement(id)); //第一个参数是正则,要转成不是正则,不然就报错了
- String newatservice = atservice.replaceFirst(Pattern.quote(destAttr),
- Matcher.quoteReplacement(newDestAttr));
- html = html.replaceFirst(Pattern.quote(atservice),
- Matcher.quoteReplacement(newatservice));
- }
- }
- } catch (Exception e) {
- /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
- e.printStackTrace();
- */ log4j.error("PageCompU.translateSourceCode() 异常", e);
- }
-
- return html;
- }
- // === 临时,从 source 读入 部件名 到 pageJson 表
- public static void loadPageJson() throws IOException {
- try (Db gdba = Db.makeConn()) {
- File source = new File("D:/Source/服务器上运行的PMS和项目备份/PMS/PMS中的大母体开发、党校母体开发源码备份/ProjectSrcInPmsBackup/backup_by_programn/pms/story//000000");
- for (File file : FileU.rdFileListByExt(source, "json")) {
- String fileName = file.getName();
- if (!"page.json".equals(fileName))
- continue;
- String dirName = file.getParent();
- long id = Long.parseLong(StringUtils.substringAfterLast(dirName, "\\"));
- String jsonStr = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
- JsonObject jsonObj = JsonParser.parseString(jsonStr).getAsJsonObject();
- String name = jsonObj.get("name").getAsString();
- String desc = jsonObj.get("desc").getAsString();
- String type = jsonObj.get("type").getAsString();
- SqlCmd sqlc = new SqlCmd("insert into \"pageJson\"(name,ms,id,type) values(:name,:ms,:id,:type)");
- sqlc.wrStrParm("name", name);
- sqlc.wrStrParm("ms", desc);
- sqlc.wrLongParm("id", id);
- sqlc.wrLongParm("type", type);
- gdba.doInsByC(sqlc, "id");
- }
- gdba.commit();
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
- }
|