Commit b8a6fba3 by jianshuqin

优化:组件功能

parent bc6e0cd2
...@@ -39,5 +39,10 @@ ...@@ -39,5 +39,10 @@
/// 行合并属性 /// 行合并属性
/// </summary> /// </summary>
public string RowSpanProp { get; set; } public string RowSpanProp { get; set; }
/// <summary>
/// 宽度
/// </summary>
public dynamic Width { get; set; }
} }
} }
\ No newline at end of file
...@@ -11,6 +11,7 @@ using System.Collections.Generic; ...@@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
namespace Bailun.DC.Services.Component namespace Bailun.DC.Services.Component
{ {
...@@ -260,6 +261,8 @@ namespace Bailun.DC.Services.Component ...@@ -260,6 +261,8 @@ namespace Bailun.DC.Services.Component
{ {
IWorkbook workbook = null; IWorkbook workbook = null;
MemoryStream ms = null; MemoryStream ms = null;
//日期格式化正则
Regex regex = new Regex("[y|Y|m|M|d|h|H|s|S]+");
try try
{ {
workbook = dataCount <= 65535 ? (IWorkbook)new HSSFWorkbook() : new SXSSFWorkbook(); workbook = dataCount <= 65535 ? (IWorkbook)new HSSFWorkbook() : new SXSSFWorkbook();
...@@ -276,12 +279,15 @@ namespace Bailun.DC.Services.Component ...@@ -276,12 +279,15 @@ namespace Bailun.DC.Services.Component
//设置字体大小 //设置字体大小
fontTitle.FontHeightInPoints = 12; fontTitle.FontHeightInPoints = 12;
//单元格样式 //单元格样式
ICellStyle styleTitle = workbook.CreateCellStyle();
ICellStyle alignmentstyle = workbook.CreateCellStyle();
alignmentstyle.VerticalAlignment = VerticalAlignment.Center;
alignmentstyle.Alignment = HorizontalAlignment.Center;
ICellStyle verticAlalignmentstyle = workbook.CreateCellStyle(); ICellStyle verticAlalignmentstyle = workbook.CreateCellStyle();
verticAlalignmentstyle.VerticalAlignment = VerticalAlignment.Center; verticAlalignmentstyle.VerticalAlignment = VerticalAlignment.Center;
verticAlalignmentstyle.BorderLeft = BorderStyle.Thin;
verticAlalignmentstyle.BorderTop = BorderStyle.Thin;
verticAlalignmentstyle.BorderBottom = BorderStyle.Thin;
verticAlalignmentstyle.BorderRight = BorderStyle.Thin;
ICellStyle alignmentstyle = workbook.CreateCellStyle();
alignmentstyle.CloneStyleFrom(verticAlalignmentstyle);
alignmentstyle.Alignment = HorizontalAlignment.Center;
//合并行属性值 //合并行属性值
IDictionary<string, (int, string)> rowSpanProp = new Dictionary<string, (int, string)>(); IDictionary<string, (int, string)> rowSpanProp = new Dictionary<string, (int, string)>();
//组头 //组头
...@@ -321,8 +327,19 @@ namespace Bailun.DC.Services.Component ...@@ -321,8 +327,19 @@ namespace Bailun.DC.Services.Component
listColumn.ForEach((l, col) => listColumn.ForEach((l, col) =>
{ {
var cell = headerRow.CreateCell(col); var cell = headerRow.CreateCell(col);
cell.CellStyle = styleTitle; cell.CellStyle = verticAlalignmentstyle;
cell.SetCellValue(l.Name); cell.SetCellValue(l.Name);
if (l.Width != null)
{
if (l.Width.ToString().ToLower() == "auto")
{
sheet.AutoSizeColumn(col);
}
else if (l.Width > 0)
{
sheet.SetColumnWidth(col, (int)((int)l.Width * 12 * 2.44));
}
}
}); });
for (int row = 0; row < excelMaxRowCount && reader.Read(); row++) for (int row = 0; row < excelMaxRowCount && reader.Read(); row++)
{ {
...@@ -338,22 +355,30 @@ namespace Bailun.DC.Services.Component ...@@ -338,22 +355,30 @@ namespace Bailun.DC.Services.Component
{ {
if (value.Equals("true", StringComparison.OrdinalIgnoreCase) || value == "1") if (value.Equals("true", StringComparison.OrdinalIgnoreCase) || value == "1")
{ {
value = "是"; cell.SetCellValue("是");
} }
else if (value.Equals("false", StringComparison.OrdinalIgnoreCase) || value == "0") else if (value.Equals("false", StringComparison.OrdinalIgnoreCase) || value == "0")
{ {
value = "否"; cell.SetCellValue("否");
} }
} }
else if (header.Format is string) else if (header.Format is string)
{ {
DateTime parseTime = DateTime.Now; DateTime parseTime = DateTime.Now;
if (DateTime.TryParse(value, out parseTime)) double parseDouble = default(double);
if ((new string[] { "money", "number" }).Contains(header.Format as string) && double.TryParse(value, out parseDouble))
{ {
value = parseTime.ToString(header.Format.Replace("hh", "HH")); cell.SetCellValue(parseDouble);
} }
else if (regex.IsMatch(header.Format as string) && DateTime.TryParse(value, out parseTime))
{
cell.SetCellValue(parseTime.ToString(header.Format.Replace("hh", "HH")));
}
}
else
{
cell.SetCellValue(value);
} }
cell.SetCellValue(value.ToString());
} }
else if (dataCount > 65535) else if (dataCount > 65535)
{ {
......
...@@ -188,7 +188,25 @@ ...@@ -188,7 +188,25 @@
<span class="text" v-bind:style="'color:' + item.color">{{item_value}}</span> <span class="text" v-bind:style="'color:' + item.color">{{item_value}}</span>
</template> </template>
<template v-else-if="item_value != null"> <template v-else-if="item_value != null">
{{ item.format ? (item_value.constructor === Boolean || item_value == 1 || item_value == 0 ? (item_value ? '是' : '否') :(new Date(item_value).format(item.format))) : item_value}} <template v-if="item.format">
<template v-if="item.format.constructor === Boolean && (item_value.constructor === Boolean || item_value == 1 || item_value == 0)">
{{ item_value ? '是' : '否' }}
</template>
<template v-else-if="item.format.constructor === String">
<template v-if="item.format == 'money'">
{{ item_value.toLocaleString() }}
</template>
<template v-else-if="item.format == 'number'">
{{ item_value }}
</template>
<template v-else-if="/[y|Y|m|M|d|h|H|s|S]+/.test(item.format)">
{{ new Date(item_value).format(item.format) }}
</template>
</template>
</template>
<template v-else>
{{ item_value }}
</template>
</template> </template>
</span> </span>
</script> </script>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
v-on:select-all="(selection)=> onRowClick()" v-on:select-all="(selection)=> onRowClick()"
v-on:row-click="onRowClick" v-on:row-click="onRowClick"
v-on:current-change="setting.selectRowMethod == 1 && onCurrentChange" v-on:current-change="setting.selectRowMethod == 1 && onCurrentChange"
v-bind:class="{search:setting.isShowColumnSearch}"> v-bind:class="{search:setting.isShowColumnSearch,group:setting.isGroupColumn}">
<el-table-column v-if="setting.selectRowMethod == 2" <el-table-column v-if="setting.selectRowMethod == 2"
header-align="center" header-align="center"
type="selection" type="selection"
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
height: calc(100% - 65px); height: calc(100% - 65px);
} }
.el-table-query .el-main .el-table.group .el-table__body-wrapper {
height: calc(100% - 67px);
}
#app, #app .el-container.is-vertical { #app, #app .el-container.is-vertical {
height: 100%; height: 100%;
} }
...@@ -78,3 +82,7 @@ ...@@ -78,3 +82,7 @@
border: 1px solid #ebeef5; border: 1px solid #ebeef5;
padding-right: 10px; padding-right: 10px;
} }
.el-table-query .el-main .el-table__header-wrapper .is-group tr:first-child {
height: 38px;
}
\ No newline at end of file
...@@ -106,7 +106,8 @@ ...@@ -106,7 +106,8 @@
//组表头 //组表头
if (that.setting.listColumn && that.setting.listColumn.length && that.setting.listColumn.findIndex(function (l) { return l.groupname }) > 0) { if (that.setting.listColumn && that.setting.listColumn.length && that.setting.listColumn.findIndex(function (l) { return l.groupname }) > 0) {
//保存原生列 //保存原生列
Vue.set(this, "olistColumn", that.setting.listColumn); Vue.set(that, "olistColumn", that.setting.listColumn);
Vue.set(that.setting, "isGroupColumn", true);
var listColumn = []; var listColumn = [];
that.setting.listColumn.forEach((l, i) => { that.setting.listColumn.forEach((l, i) => {
if (l.groupname) { if (l.groupname) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment