|
发表于 2020-5-2 22:15:01
|
显示全部楼层
Xsl格试:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--全局变量-->
<xsl:variable name = "Columns" select = "/MonthBankRollPlanOfDepartReport/SchemaInfo/Columns" /><!--列的格式-->
<xsl:variable name = "Rows" select = "/MonthBankRollPlanOfDepartReport/SchemaInfo/Rows" /><!--行的格式-->
<xsl:variable name = "ColumnInfo" select = "/MonthBankRollPlanOfDepartReport/Data/ColumnInfo" /><!--数据列信息-->
<xsl:variable name = "DataInfo" select = "/MonthBankRollPlanOfDepartReport/Data/DataInfo" /><!--数据信息-->
<xsl:variable name = "ShowMonthColumn" select = "/MonthBankRollPlanOfDepartReport/Data/ColumnInfo/ColumnDetail[starts-with(@ColumnName, 'A')]" /><!--显示月的列-->
<xsl:variable name = "UnitColumnName" select = "/MonthBankRollPlanOfDepartReport/SchemaInfo/Columns/Titles/TitleDetail/ColumnDetail[@IsUnit = 'true']/@ColumnName" /><!--合并列名称-->
<xsl:variable name = "RowColorColumnName" select = "$Rows/RowColors/@ColumnName" /><!--行颜色列名-->
<!--模版-->
<!--得到月份列标题-->
<xsl:template name = "GetMonthTitle" >
<xsl:param name = "TitleIndex" /><!--标题索引-->
<xsl:variable name = "ColumnName" select = "$ShowMonthColumn[$TitleIndex]/@ColumnName" />
<xsl:value-of select = "substring($ColumnName, 2, 4)" /><xsl:value-of select = "'年'" /><xsl:value-of select = "substring($ColumnName, 6)" /><xsl:value-of select = "'月'" />
</xsl:template>
<!--得到标题-->
<xsl:template name = "GetTitle">
<tr align = "center">
<!--指定格式标题-->
<xsl:for-each select = "$Columns/Titles/TitleDetail">
<td width = "{./@width}px" >
<xsl:choose>
<xsl:when test = "./@IsFixed = 'true'">
<xsl:attribute name = "style">
<xsl:value-of select = "'background-color:#BED8FD;border-right:1px solid #cccccc;border-top:1px solid #cccccc;position:relative;left:expression(this.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.scrollLeft)'" />
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name = "style">
<xsl:value-of select = "'border-right:1px solid #cccccc;border-top:1px solid #cccccc;'" />
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<!--标题名称-->
<xsl:value-of select = "./@TitleName" />
</td>
</xsl:for-each>
<!--月份标题-->
<xsl:for-each select = "$ShowMonthColumn" >
<td width = "{$Columns/Titles/DefaultTitle/@width}px" style = "border-right:1px solid #cccccc;border-top:1px solid #cccccc;">
<xsl:call-template name = "GetMonthTitle">
<xsl:with-param name = "TitleIndex" select = "position()" />
</xsl:call-template>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<!--得到导航的列名-->
<xsl:template name = "GetRowLinksColumnName">
<xsl:param name = "DataDetail" /><!--行的详细信息-->
<xsl:for-each select = "$Rows/RowLinks/RowDetail" >
<xsl:variable name = "RowDetail" select = "." />
<xsl:if test = "$DataDetail/FieldDetail[@Name = $RowDetail/@ColumnName]/@Value = $RowDetail/@ColumnValue" >
<xsl:value-of select = "$RowDetail/@ColumnName" />
</xsl:if>
</xsl:for-each>
</xsl:template>
<!--得到显示的数据-->
<xsl:template name = "GetShowValue">
<xsl:param name = "ColumnName" />
<xsl:param name = "ShowValue" />
<xsl:param name = "Position" />
<xsl:variable name = "DataDetail" select = "$DataInfo/DataDetail[$Position]" />
<xsl:variable name = "RowLinksColumnName" ><!--导航列名-->
<xsl:call-template name = "GetRowLinksColumnName" >
<xsl:with-param name = "DataDetail" select = "$DataDetail" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name = "RowLinksValue" select = "$DataDetail/FieldDetail[@Name = $RowLinksColumnName]/@Value" />
<!--得到超链接类型-->
<xsl:variable name = "LinkType">
<xsl:choose>
<xsl:when test = "count($Rows/RowLinks/RowDetail[@ColumnValue = $RowLinksValue ] ) > 0 and not(contains($DataDetail/FieldDetail[@Name = 'SysExpenseItemName']/@Value, '小计') )" >
<xsl:value-of select = "$Rows/RowLinks/RowDetail[@ColumnValue = $RowLinksValue ]/@LinkType" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select = "-1" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test = "number($ShowValue) " ><!--数字-->
<xsl:choose>
<xsl:when test = "$ColumnName = 'Total'">
<xsl:value-of select = "format-number($ShowValue, '#,###.00')" />
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test = "number($ShowValue) != 0 ">
<xsl:choose>
<xsl:when test = "$LinkType != -1 ">
<a href="#" onclick="GetDataList('{$DataDetail/FieldDetail[@Name = 'CompanyID']/@Value}', '{$DataDetail/FieldDetail[@Name = 'SysExpenseItemID']/@Value}', '{$ColumnName}', '{$DataDetail/FieldDetail[@Name = 'DepartIDs']/@Value}', '{$LinkType}');">
<xsl:value-of select = "format-number($ShowValue, '#,###.00')" />
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select = "format-number($ShowValue, '#,###.00')" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select = "format-number($ShowValue, '#,###.00')" />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test = "$LinkType = 1 and $ShowValue != '0'" ><!--导航的费项-->
<a href="#" onclick="GetSysExpenseItemList('{$DataDetail/FieldDetail[@Name = 'CompanyID']/@Value}', '{$DataDetail/FieldDetail[@Name = 'SysExpenseItemID']/@Value}', '{$DataDetail/FieldDetail[@Name = 'DepartIDs']/@Value}');">
<xsl:value-of select = "$ShowValue" />
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select = "$ShowValue" />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
|
|