499 lines
24 KiB
Java
499 lines
24 KiB
Java
package com.tenwa.reckon.product;
|
||
|
||
import java.util.ArrayList;
|
||
import java.util.Hashtable;
|
||
|
||
import com.amarsoft.awe.dw.ASDataObject;
|
||
import com.amarsoft.awe.dw.ASHtmlEvent;
|
||
import com.amarsoft.awe.dw.ui.control.BasicInput;
|
||
import com.amarsoft.awe.dw.ui.control.ParentSelect;
|
||
import com.amarsoft.awe.dw.ui.control.Support;
|
||
import com.amarsoft.awe.dw.ui.datamodel.MData;
|
||
import com.amarsoft.awe.dw.ui.datamodel.MDataBuilder;
|
||
import com.amarsoft.awe.dw.ui.page.body.GenBodyData;
|
||
import com.amarsoft.awe.dw.ui.util.Const;
|
||
import com.amarsoft.awe.dw.ui.util.PublicFuns;
|
||
import com.amarsoft.awe.dw.ui.util.StringMatch;
|
||
import com.amarsoft.awe.dw.ui.util.WordConvertor;
|
||
import com.tenwa.reckon.util.NumberUtils;
|
||
|
||
public class GenBodyDataImpCalc extends GenBodyData{
|
||
|
||
public ArrayList hiddenDatas;
|
||
public ASObjectWindowCalc datawindow;
|
||
public int iColCount;
|
||
public ArrayList getHiddenDatas() {
|
||
return hiddenDatas;
|
||
}
|
||
|
||
public void setHiddenDatas(ArrayList hiddenDatas) {
|
||
this.hiddenDatas = hiddenDatas;
|
||
}
|
||
|
||
private GenBodyDataImpCalc(String dono, ArrayList datas, String modehtml) {
|
||
super(dono, datas, modehtml);
|
||
}
|
||
|
||
public GenBodyDataImpCalc(ASDataObject asObj, ArrayList datas, String modehtml) {
|
||
super(asObj, datas, modehtml);
|
||
}
|
||
public GenBodyDataImpCalc(ASDataObject asObj, ArrayList datas, String modehtml,ArrayList hiddenDatas,ASObjectWindowCalc datawindow,int iColCount) {
|
||
super(asObj, datas, modehtml);
|
||
this.hiddenDatas=hiddenDatas;
|
||
this.datawindow=datawindow;
|
||
this.iColCount=iColCount;
|
||
}
|
||
public String getGroupBody(Hashtable values, String webRootPath)
|
||
throws Exception {
|
||
String sMode = modehtml;
|
||
int iDockid = MDataBuilder.getColumnsIndex2("groupid");
|
||
String sDockId = "";
|
||
int iHorizonPosition = 0;
|
||
int col=0;
|
||
if (sMode.indexOf("<!--LOOP-->") == -1)
|
||
return sMode;
|
||
String aMode[] = sMode.split("<!--LOOP-->");
|
||
if (aMode.length != 5)
|
||
throw new Exception("GenBodyDataImp2.java");
|
||
StringBuffer sLoop = new StringBuffer();
|
||
String sLastBody = "";
|
||
if (datas != null) {
|
||
Hashtable htDepend = getColDepand();
|
||
StringBuffer sbColindexNameMap = new StringBuffer();
|
||
int iRowIndex = 0;
|
||
String sTr="";
|
||
for (int i = 0; i < datas.size(); i++) {
|
||
String sBody = "";
|
||
MData mdata = (MData) datas.get(i);
|
||
if (sDockId.equals(""))
|
||
sDockId = mdata.getField(iDockid).getValue();
|
||
int iColspan = MDataBuilder.getColumnsIndex2("colspan");
|
||
String sColspan = mdata.getField(iColspan).getValue();
|
||
if ("-1".equals(sColspan) || "-2".equals(sColspan))
|
||
continue;
|
||
int iColheader = MDataBuilder.getColumnsIndex2("colheader");
|
||
String sColheader = mdata.getField(iColheader).getValue();
|
||
if (!"1".equals(mdata.getField(MDataBuilder.getColumnsIndex2("colvisible")).getValue()))
|
||
sColheader = (new StringBuilder()).append("<font color=\"#CCCCCC\">").append(sColheader).append("</font>").toString();
|
||
if (!"1".equals(mdata.getField(MDataBuilder.getColumnsIndex2("isinuse")).getValue()))
|
||
sColheader = (new StringBuilder()).append("<font style=\"text-decoration:line-through\">").append(sColheader).append("</font>").toString();
|
||
int iColName = MDataBuilder.getColumnsIndex2("colname");
|
||
String sColName = mdata.getField(iColName).getValue();
|
||
if (sColName.toUpperCase().startsWith("V."))
|
||
sColName = sColName.substring(2);
|
||
int iColIndex = MDataBuilder.getColumnsIndex2("colindex");
|
||
int iUnit = MDataBuilder.getColumnsIndex2("colunit");
|
||
int iTips = MDataBuilder.getColumnsIndex2("coltips");
|
||
String sColIndex = mdata.getField(iColIndex).getValue();
|
||
if (sColspan.equals("2"))
|
||
iColspan = 2;
|
||
else if (sColspan.equals("10"))
|
||
iColspan = 10;
|
||
else if(sColspan.equals("3"))
|
||
iColspan=3;
|
||
else
|
||
iColspan = 1;
|
||
int iRequired = MDataBuilder.getColumnsIndex2("colrequired");
|
||
boolean bRequired = "1".equals(mdata.getField(iRequired).getValue());
|
||
String sInputHtml = "";
|
||
|
||
|
||
String ratioValue=getRatioHtml(sColName,mdata,values);
|
||
|
||
|
||
if (values != null)
|
||
sInputHtml = getInputHtml(i,values.get(sColName) != null ? values.get(sColName).toString() : "");
|
||
else
|
||
sInputHtml = getInputHtml(i, "");
|
||
|
||
if(!"".equals(ratioValue)) {//<2F><><EFBFBD><EFBFBD><EFBFBD>ֶε<D6B6><CEB5><EFBFBD>Ϊ<EFBFBD>ٷֱ<D9B7>
|
||
if(!isLast(i)) {
|
||
ratioValue = ratioValue.replaceAll("width:37px;", ";width:23%;");
|
||
sInputHtml = sInputHtml.replaceAll(";width:120px;", ";width:65%;");
|
||
} else {
|
||
ratioValue = ratioValue.replaceAll("width:37px;", ";width:35px;");
|
||
sInputHtml = sInputHtml.replaceAll(";width:120px;", ";width:100;");
|
||
}
|
||
}
|
||
|
||
if (iHorizonPosition == 0)
|
||
if (isLast(i))
|
||
iColspan = 2;
|
||
else if ((iColspan == 1 || iColspan == 0)&& (((MData) datas.get(i + 1)).getField(MDataBuilder.getColumnsIndex2("colspan")).getValue().equals("2") || ((MData) datas.get(i + 1)).getField(MDataBuilder.getColumnsIndex2("colspan")).getValue().equals("10")))
|
||
iColspan = 2;
|
||
if (iColspan == 1) { //<2F>Զ<EFBFBD><D4B6><EFBFBD>ȡ
|
||
if(col%iColCount==0){
|
||
sTr+="<tr>";
|
||
}
|
||
sBody = aMode[1];//<2F><>ȡtd<74><64>Ԫ<EFBFBD><D4AA>htmltdWidth
|
||
sBody=sBody.replaceAll("\\{RATIO\\}",ratioValue);
|
||
sBody=sBody.replaceAll("\\{SPANWIDTH\\}",(String)this.datawindow.getAttr("spanWidth"));
|
||
sBody=sBody.replaceAll("\\{TDWIDTH\\}",(int)100/iColCount+"");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{INDEX").append(iHorizonPosition).append("\\}").toString(), sColIndex);
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{NAME").append(iHorizonPosition).append("\\}").toString(), sColName+"tst");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{TITLE").append(iHorizonPosition).append("\\}").toString(), sColheader);
|
||
if (bRequired) {
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("<REQUIRED").append(iHorizonPosition).append("").toString(), "<span");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("</REQUIRED").append(iHorizonPosition).append(">").toString(), "</span>");
|
||
} else {
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("<REQUIRED").append(iHorizonPosition).append("[\\w\\W]+?>").toString(), "");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("</REQUIRED").append(iHorizonPosition).append(">").toString(), "");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("<DELETED").append(iHorizonPosition).append("[\\W\\w]+?</DELETED").append(iHorizonPosition).append(">").toString(), "");
|
||
}
|
||
int iStatus = getTrueStatus(mdata);
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{UNIT").append(iHorizonPosition).append("\\}").toString(),filterUnit(mdata.getField(iUnit).getValue(),iStatus));
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{TIPS").append(iHorizonPosition).append("\\}").toString(), mdata.getField(iTips).getValue());
|
||
sBody = Support.replace(sBody,(new StringBuilder()).append("{INPUT").append(iHorizonPosition).append("}").toString(),sInputHtml != null ? sInputHtml : "");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{SYS_CHECKBOX").append(iHorizonPosition).append("\\}").toString(), "");
|
||
sBody = appendBody(htDepend,sColName,sBody,(new StringBuilder()).append("\\{EXTEND").append(iHorizonPosition).append("\\}").toString(), values, iColIndex, iRequired,iColheader, iTips, iUnit);
|
||
if ((col+1)%iColCount!=0) {
|
||
sTr=sTr.replaceAll("\\{COLSPAN\\}","1");
|
||
sTr+=sBody;
|
||
} else {
|
||
sBody=sBody.replaceAll("\\{COLSPAN\\}","1");
|
||
if (iRowIndex % 2 != 0)
|
||
sBody = sBody.replaceAll("\\{EVEN\\}", "_even");
|
||
else
|
||
sBody = sBody.replaceAll("\\{EVEN\\}", "");
|
||
sTr=sTr.replaceAll("\\{COLSPAN\\}","1");
|
||
sLoop.append(sTr);
|
||
sLoop.append(sBody);
|
||
sLoop.append("</tr>");
|
||
sTr="";
|
||
iRowIndex++;
|
||
}
|
||
iHorizonPosition =0;
|
||
col++;
|
||
continue;
|
||
}
|
||
sBody = aMode[2];
|
||
if ("3".equals(sColspan)) {
|
||
if((col)%iColCount!=0){
|
||
sTr=sTr.replaceAll("\\{COLSPAN\\}",(iColCount+1-col%iColCount)+"");
|
||
sLoop.append(sTr);
|
||
sLoop.append("</tr>");
|
||
sTr="";
|
||
}
|
||
col=1;
|
||
sTr+="<tr>";
|
||
sBody = aMode[1];//<2F><>ȡtd<74><64>Ԫ<EFBFBD><D4AA>html
|
||
sBody=sBody.replaceAll("\\{RATIO\\}",ratioValue);
|
||
sBody=sBody.replaceAll("\\{SPANWIDTH\\}",(String)this.datawindow.getAttr("spanWidth"));
|
||
sBody=sBody.replaceAll("\\{TDWIDTH\\}",(int)100/iColCount+"");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{INDEX").append(iHorizonPosition).append("\\}").toString(), sColIndex);
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{NAME").append(iHorizonPosition).append("\\}").toString(), sColName+"tst");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{TITLE").append(iHorizonPosition).append("\\}").toString(), sColheader);
|
||
if (bRequired) {
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("<REQUIRED").append(iHorizonPosition).append("").toString(), "<span");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("</REQUIRED").append(iHorizonPosition).append(">").toString(), "</span>");
|
||
} else {
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("<REQUIRED").append(iHorizonPosition).append("[\\w\\W]+?>").toString(), "");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("</REQUIRED").append(iHorizonPosition).append(">").toString(), "");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("<DELETED").append(iHorizonPosition).append("[\\W\\w]+?</DELETED").append(iHorizonPosition).append(">").toString(), "");
|
||
}
|
||
int iStatus = getTrueStatus(mdata);
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{UNIT").append(iHorizonPosition).append("\\}").toString(),filterUnit(mdata.getField(iUnit).getValue(),iStatus));
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{TIPS").append(iHorizonPosition).append("\\}").toString(), mdata.getField(iTips).getValue());
|
||
sBody = Support.replace(sBody,(new StringBuilder()).append("{INPUT").append(iHorizonPosition).append("}").toString(),sInputHtml != null ? sInputHtml : "");
|
||
sBody = sBody.replaceAll((new StringBuilder()).append("\\{SYS_CHECKBOX").append(iHorizonPosition).append("\\}").toString(), "");
|
||
sBody = appendBody(htDepend,sColName,sBody,(new StringBuilder()).append("\\{EXTEND").append(iHorizonPosition).append("\\}").toString(), values, iColIndex, iRequired,iColheader, iTips, iUnit);
|
||
|
||
sTr+=sBody;
|
||
continue;
|
||
}
|
||
if ("10".equals(sColspan)) {
|
||
if((col)%iColCount!=0){
|
||
sTr=sTr.replaceAll("\\{COLSPAN\\}",(iColCount+1-col%iColCount)+"");
|
||
sLoop.append(sTr);
|
||
sLoop.append("</tr>");
|
||
sTr="";
|
||
}
|
||
col=0;
|
||
sBody = aMode[3];
|
||
sBody=sBody.replaceAll("\\{RATIO\\}",ratioValue);
|
||
String aBody2[] = sBody.split("<!--SUBLOOP-->");
|
||
ArrayList mdatas = (ArrayList) htDepend.get(sColName);
|
||
StringBuffer sbBody2 = new StringBuffer();
|
||
for (int j = 0; j < mdatas.size(); j++) {
|
||
String stemp = "";
|
||
sColName = ((MData) mdatas.get(j)).getField(iColName).getValue();
|
||
sColIndex = ((MData) datas.get(getIndexByColName(sColName))).getField(iColIndex).getValue();
|
||
stemp = aBody2[1].replaceAll("\\{INDEX\\}", sColIndex);
|
||
sBody=sBody.replaceAll("\\{SPANWIDTH\\}",(String)this.datawindow.getAttr("spanWidth"));
|
||
sBody=sBody.replaceAll("\\{TDWIDTH\\}",(int)100/iColCount+"");
|
||
stemp = stemp.replaceAll("\\{NAME\\}", sColName);
|
||
sColheader = ((MData) mdatas.get(j)).getField(iColheader).getValue();
|
||
if (!"1".equals(((MData) mdatas.get(j)).getField(MDataBuilder.getColumnsIndex2("colvisible")).getValue()))
|
||
sColheader = (new StringBuilder()).append("<font color=\"#CCCCCC\">").append(sColheader).append("</font>").toString();
|
||
if (!"1".equals(((MData) mdatas.get(j)).getField(MDataBuilder.getColumnsIndex2("isinuse")).getValue()))
|
||
sColheader = (new StringBuilder()).append("<font style=\"text-decoration:line-through\">").append(sColheader).append("</font>").toString();
|
||
stemp = stemp.replaceAll("\\{TITLE\\}", sColheader);
|
||
bRequired = "1".equals(((MData) mdatas.get(j)).getField(iRequired).getValue());
|
||
if (bRequired) {
|
||
stemp = stemp.replaceAll("<REQUIRED", "<span");
|
||
stemp = stemp.replaceAll("</REQUIRED>", "</span>");
|
||
} else {
|
||
stemp = stemp.replaceAll("<REQUIRED[\\w\\W]+?>", "");
|
||
stemp = stemp.replaceAll("</REQUIRED>", "");
|
||
stemp = stemp.replaceAll("<DELETED[\\W\\w]+?</DELETED>", "");
|
||
}
|
||
int iStatus = getTrueStatus((MData) mdatas.get(j));
|
||
stemp = stemp.replaceAll("\\{UNIT\\}",filterUnit(((MData) mdatas.get(j)).getField(iUnit).getValue(), iStatus));
|
||
stemp = stemp.replaceAll("\\{TIPS\\}", ((MData) mdatas.get(j)).getField(iTips).getValue());
|
||
if (values != null)
|
||
sInputHtml = getInputHtml((MData) mdatas.get(j),values.get(sColName) != null ? values.get(sColName).toString() : "");
|
||
else
|
||
sInputHtml = getInputHtml((MData) mdatas.get(j), "");
|
||
stemp = Support.replace(stemp, "{INPUT}",sInputHtml != null ? sInputHtml : "");
|
||
stemp = stemp.replaceAll("\\{SYS_CHECKBOX\\}", "");
|
||
stemp = stemp.replaceAll("\\{COLINDEX\\}",(new StringBuilder()).append(j).append("").toString());
|
||
sbBody2.append(stemp);
|
||
}
|
||
|
||
sBody = (new StringBuilder()).append(aBody2[0].replaceAll("\\{INDEX\\}",sColIndex)).append(sbBody2.toString()).append(aBody2[2]).toString();
|
||
iHorizonPosition = 0;
|
||
} else {
|
||
if((col)%iColCount==0){
|
||
sLoop.append("<tr>");
|
||
sBody=sBody.replaceAll("\\{COLSPAN\\}","4");
|
||
}else{
|
||
sBody=sBody.replaceAll("\\{COLSPAN\\}",(iColCount-col%iColCount)+"");
|
||
}
|
||
sBody=sBody.replaceAll("\\{RATIO\\}",ratioValue);
|
||
sBody=sBody.replaceAll("\\{SPANWIDTH\\}",(String)this.datawindow.getAttr("spanWidth"));
|
||
sBody=sBody.replaceAll("\\{TDWIDTH\\}",(int)100/iColCount+"");
|
||
sBody = sBody.replaceAll("\\{INDEX\\}", sColIndex);
|
||
sBody = sBody.replaceAll("\\{NAME\\}", sColName);
|
||
sBody = sBody.replaceAll("\\{TITLE\\}", sColheader);
|
||
if (bRequired) {
|
||
sBody = sBody.replaceAll("<REQUIRED", "<span");
|
||
sBody = sBody.replaceAll("</REQUIRED>", "</span>");
|
||
} else {
|
||
sBody = sBody.replaceAll("<REQUIRED[\\w\\W]+?>", "");
|
||
sBody = sBody.replaceAll("</REQUIRED>", "");
|
||
sBody = sBody.replaceAll("<DELETED[\\W\\w]+?</DELETED>", "");
|
||
}
|
||
int iStatus = getTrueStatus(mdata);
|
||
sBody = sBody.replaceAll("\\{UNIT\\}",filterUnit(mdata.getField(iUnit).getValue(),iStatus));
|
||
sBody = sBody.replaceAll("\\{TIPS\\}", mdata.getField(iTips).getValue());
|
||
sBody = Support.replace(sBody, "{INPUT}",sInputHtml != null ? sInputHtml : "");
|
||
sBody = sBody.replaceAll("\\{SYS_CHECKBOX\\}", "");
|
||
iHorizonPosition = 0;
|
||
sBody = appendBody(htDepend, sColName, sBody,"\\{EXTEND\\}", values, iColIndex, iRequired,iColheader, iTips, iUnit);
|
||
sBody+="</tr>";
|
||
sTr=sTr.replaceAll("\\{COLSPAN\\}","1");
|
||
sLoop.append(sTr);
|
||
sTr="";
|
||
col=0;
|
||
}
|
||
if (iRowIndex % 2 != 0)
|
||
sBody = sBody.replaceAll("\\{EVEN\\}", "_even");
|
||
else
|
||
sBody = sBody.replaceAll("\\{EVEN\\}", "");
|
||
sLoop.append(sBody);
|
||
iRowIndex++;
|
||
}
|
||
|
||
for (int i = 0; i < datas.size(); i++) {
|
||
MData mdata = (MData) datas.get(i);
|
||
int iColIndex = MDataBuilder.getColumnsIndex2("colIndex");
|
||
String sColIndex = mdata.getField(iColIndex).getValue();
|
||
int iColName = MDataBuilder.getColumnsIndex2("colname");
|
||
String sColName = mdata.getField(iColName).getValue();
|
||
int iColHeader = MDataBuilder.getColumnsIndex2("COLHEADER");
|
||
String sColHeader = WordConvertor.convertJava2Js(mdata.getField(iColHeader).getValue());
|
||
sbColindexNameMap.append((new StringBuilder()).append("\nDWColIndexNameMap[DWColIndexNameMap.length] = ['").append(sColIndex).append("','").append(sColName).append("','").append(sColHeader).append("'];").toString());
|
||
}
|
||
|
||
sLoop.append((new StringBuilder()).append("\n<script>").append(sbColindexNameMap.toString()).append("\n</script>").toString());
|
||
}
|
||
String sResult = (new StringBuilder()).append(aMode[0]).append(sLoop.toString()).append(aMode[4]).toString();
|
||
if (sDockId.equals(""))
|
||
sDockId = "@";
|
||
sResult = sResult.replaceAll("\\{GROUPID\\}", sDockId);
|
||
sResult = sResult.replaceAll("\\{RESOURCEPATH\\}",Const.getDWControlPath(webRootPath));
|
||
sResult = sResult.replaceAll("\\{ROOTPATH\\}", webRootPath);
|
||
return sResult;
|
||
}
|
||
|
||
private boolean isLast(int index) {
|
||
if (index == datas.size() - 1)
|
||
return true;
|
||
for (int i = index + 1; i < datas.size(); i++)
|
||
if (!((MData) datas.get(i))
|
||
.getField(MDataBuilder.getColumnsIndex2("colspan"))
|
||
.getValue().equals("-1"))
|
||
return false;
|
||
|
||
return true;
|
||
}
|
||
|
||
public String getRatioHtml(String colname,MData mdata,Hashtable values){
|
||
if(!(Boolean)this.datawindow.getAttr("showRatio")){
|
||
return "";
|
||
}
|
||
|
||
int iRatio=MDataBuilder.getColumnsIndex2("colfilterrefid");
|
||
String ratio=mdata.getField(iRatio).getValue();
|
||
int col=MDataBuilder.getColumnsIndex2("colname");
|
||
if(ratio.length()>0){
|
||
|
||
for(int y=0;y<this.hiddenDatas.size();y++){
|
||
if(((MData)this.hiddenDatas.get(y)).getField(col).getValue().equals(ratio)){
|
||
MData m=(MData)this.hiddenDatas.get(y);
|
||
int iColName = MDataBuilder.getColumnsIndex2("colname");
|
||
int iDefaultValue = MDataBuilder.getColumnsIndex2("coldefaultvalue");
|
||
String sColName = m.getField(iColName).getValue();
|
||
String value=values.get(sColName).toString();
|
||
if (value == null) value = "";
|
||
String sDefaultValue =m.getField(iDefaultValue).getValue();
|
||
if ((this.asObj.isNeedFillDefaultValue()) && (value.equals(""))) {
|
||
value = sDefaultValue;
|
||
}
|
||
int iColReadOnly = MDataBuilder.getColumnsIndex2("colreadonly");
|
||
int editStatus2 = this.editstatus;
|
||
if ((editStatus2 == -10) && (!"".equals(m.getField(iColReadOnly).getValue())))
|
||
editStatus2 = Integer.parseInt(m.getField(iColReadOnly).getValue()) + 1;
|
||
String input="";
|
||
if(value.length()>0){
|
||
value=NumberUtils.formatNumberDoubleTwo(value);
|
||
}
|
||
if(editStatus2==1){
|
||
input="<input type='text' id='"+ratio+"_0' name='"+ratio+"_0' onfocus='if(!isNaN(this.value) && toNumber(this.value)==0){setSelectText(this,0,this.value.length);}' onchange='getMoneyByRatio(this);' style='width:37px' value='"+value+"'/><font style='color:red;'>%</font>";
|
||
}else{
|
||
input="<input type='text' id='"+ratio+"_0' name='"+ratio+"_0' style='width:37px;background-color:#EBEBE4' class='info_text_readonly_color' onchange='getMoneyByRatio(this)' readonly='readonly' value='"+value+"'/><font style='color:red;'>%</font>";
|
||
}
|
||
return input;
|
||
}
|
||
}
|
||
|
||
|
||
return "";
|
||
}else{
|
||
return "";
|
||
}
|
||
}
|
||
|
||
|
||
protected String getInputHtml(int i, String value)
|
||
throws Exception
|
||
{
|
||
int iColname = MDataBuilder.getColumnsIndex2("colname");
|
||
int iColeditstyle = MDataBuilder.getColumnsIndex2("coleditstyle");
|
||
int iColeditsourcetype = MDataBuilder.getColumnsIndex2("coleditsourcetype");
|
||
int iColeditsource = MDataBuilder.getColumnsIndex2("coleditsource");
|
||
int iColhtmlstyle = MDataBuilder.getColumnsIndex2("colhtmlstyle");
|
||
int iColReadOnly = MDataBuilder.getColumnsIndex2("colreadonly");
|
||
int editStatus2 = this.editstatus;
|
||
if ((editStatus2 == -10) && (!"".equals(((MData)this.datas.get(i)).getField(iColReadOnly).getValue())))
|
||
editStatus2 = Integer.parseInt(((MData)this.datas.get(i)).getField(iColReadOnly).getValue()) + 1;
|
||
int iDefaultValue = MDataBuilder.getColumnsIndex2("coldefaultvalue");
|
||
int iColAlign = MDataBuilder.getColumnsIndex2("colalign");
|
||
if (value == null) value = "";
|
||
String sDefaultValue = ((MData)this.datas.get(i)).getField(iDefaultValue).getValue();
|
||
if ((this.asObj.isNeedFillDefaultValue()) && (value.equals(""))) {
|
||
value = sDefaultValue;
|
||
}
|
||
if (sDefaultValue == null) sDefaultValue = "";
|
||
this.htmlStyle = ((MData)this.datas.get(i)).getField(iColhtmlstyle).getValue().trim();
|
||
parseHtmlStyle(((MData)this.datas.get(i)).getField(iColeditstyle).getValue(), ((MData)this.datas.get(i)).getField(MDataBuilder.getColumnsIndex2("colunit")).getValue());
|
||
doEvents(((MData)this.datas.get(i)).getField(iColname).getValue());
|
||
|
||
BasicInput input = getInput(((MData)this.datas.get(i)).getField(iColname).getValue(), ((MData)this.datas.get(i)).getField(iColeditstyle).getValue(), ((MData)this.datas.get(i)).getField(iColeditsourcetype).getValue(), ((MData)this.datas.get(i)).getField(iColeditsource).getValue(), this.htmlStyle, editStatus2, value, ",", ((MData)this.datas.get(i)).getField(MDataBuilder.getColumnsIndex2("colcheckformat")).getValue(), ((MData)this.datas.get(i)).getField(MDataBuilder.getColumnsIndex2("collimit")).getValue(), getAlign(iColAlign, i), ((MData)this.datas.get(i)).getField(MDataBuilder.getColumnsIndex2("colinnerbtevent")).getValue());
|
||
|
||
if ((input instanceof ParentSelect)) {
|
||
return input.genCode() + ((ParentSelect)input).genValuesScript();
|
||
}
|
||
|
||
return input.genCode();
|
||
}
|
||
|
||
private void parseHtmlStyle(String inputtype, String unit)
|
||
throws Exception
|
||
{
|
||
String sHtmlStyle = this.htmlStyle;
|
||
String sPatton = "style=(\\{|\")[\\w\\W]+?(\\}|\")";
|
||
|
||
if (sHtmlStyle.matches(sPatton)) {
|
||
this.htmlStyle = StringMatch.getContent(sHtmlStyle, sPatton);
|
||
this.htmlStyle = this.htmlStyle.substring(7, this.htmlStyle.length() - 1);
|
||
} else {
|
||
this.htmlStyle = "";
|
||
}
|
||
|
||
if ((this.htmlStyle.toLowerCase().indexOf("width:") == -1) && (PublicFuns.strInArr(Const.getDefaultInputWidthExclude().split("\\,"), inputtype) == -1)) {
|
||
String sWidth =(String)this.datawindow.getAttr("inputWidth");
|
||
|
||
if (this.htmlStyle.endsWith(";"))
|
||
this.htmlStyle = (this.htmlStyle + "width:" + sWidth + "px");
|
||
else
|
||
this.htmlStyle = (this.htmlStyle + ";width:" + sWidth + "px");
|
||
}
|
||
}
|
||
|
||
private void doEvents(String colName) {
|
||
this.elseScript = "";
|
||
this.onChangeScript = "";
|
||
this.onKeyPressScript = "";
|
||
this.onClickScript = "";
|
||
ArrayList eventlist = this.asObj.getHtmlEvents(colName);
|
||
if (eventlist == null) return;
|
||
for (int i = 0; i < eventlist.size(); i++) {
|
||
ASHtmlEvent event = (ASHtmlEvent)eventlist.get(i);
|
||
String sEventName = event.getEventType();
|
||
String sEventParams = event.getEventParams();
|
||
if (sEventParams == null)
|
||
sEventParams = "()";
|
||
else {
|
||
sEventParams = "(" + sEventParams + ")";
|
||
}
|
||
if ((sEventName.equalsIgnoreCase("onchange")) || (sEventName.equalsIgnoreCase("change")))
|
||
this.onChangeScript = (event.getEventFunction() + sEventParams);
|
||
else if ((sEventName.equalsIgnoreCase("onkeypress")) || (sEventName.equalsIgnoreCase("keypress")))
|
||
this.onKeyPressScript = (event.getEventFunction() + sEventParams);
|
||
else if ((sEventName.equalsIgnoreCase("onclick")) || (sEventName.equalsIgnoreCase("click")))
|
||
this.onClickScript = (event.getEventFunction() + sEventParams);
|
||
else
|
||
this.elseScript = (this.elseScript + " " + sEventName + "=\"" + event.getEventFunction() + "" + sEventParams + "\"");
|
||
}
|
||
}
|
||
|
||
private String getAlign(int iColAlign, int i) {
|
||
String css[] = { "", "text-align:left;", "text-align:center;",
|
||
"text-align:right;" };
|
||
String sColAlign = ((MData) datas.get(i)).getField(iColAlign)
|
||
.getValue();
|
||
if (sColAlign == null || sColAlign.equals(""))
|
||
iColAlign = 0;
|
||
else
|
||
iColAlign = Integer.parseInt(sColAlign);
|
||
if (iColAlign >= css.length)
|
||
iColAlign = css.length - 1;
|
||
return css[iColAlign];
|
||
}
|
||
|
||
protected Hashtable getColDepand() {
|
||
Hashtable htDepend = new Hashtable();
|
||
String sLastColName = "";
|
||
for (int i = 0; i < datas.size(); i++) {
|
||
MData mdata = (MData) datas.get(i);
|
||
int iColName = MDataBuilder.getColumnsIndex2("colname");
|
||
String sColName = mdata.getField(iColName).getValue();
|
||
int iColspan = MDataBuilder.getColumnsIndex2("colspan");
|
||
String sColspan = mdata.getField(iColspan).getValue();
|
||
if ("-1".equals(sColspan)) {
|
||
ArrayList al = (ArrayList) htDepend.get(sLastColName);
|
||
al.add((MData) datas.get(i));
|
||
} else {
|
||
ArrayList al = new ArrayList();
|
||
al.add((MData) datas.get(i));
|
||
htDepend.put(sColName, al);
|
||
sLastColName = sColName;
|
||
}
|
||
}
|
||
|
||
return htDepend;
|
||
}
|
||
|
||
}
|