Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DataCenter_Core2.1_20190520
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bltdc
DataCenter_Core2.1_20190520
Commits
e2144134
Commit
e2144134
authored
May 27, 2022
by
jianshuqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化:组件功能
parent
b8a6fba3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
5 deletions
+36
-5
ColumnDTO.cs
Bailun.DC.Models/Component/DTO/ColumnDTO.cs
+11
-0
BaseService.cs
Bailun.DC.Services/Component/BaseService.cs
+23
-3
Control.cshtml
Bailun.DC.Web/Areas/Component/Views/Form/Control.cshtml
+2
-2
No files found.
Bailun.DC.Models/Component/DTO/ColumnDTO.cs
View file @
e2144134
...
@@ -44,5 +44,15 @@
...
@@ -44,5 +44,15 @@
/// 宽度
/// 宽度
/// </summary>
/// </summary>
public
dynamic
Width
{
get
;
set
;
}
public
dynamic
Width
{
get
;
set
;
}
/// <summary>
/// 精度
/// </summary>
public
int
?
Precision
{
get
;
set
;
}
/// <summary>
/// 样式
/// </summary>
public
dynamic
Style
{
get
;
set
;
}
}
}
}
}
\ No newline at end of file
Bailun.DC.Services/Component/BaseService.cs
View file @
e2144134
...
@@ -274,6 +274,8 @@ namespace Bailun.DC.Services.Component
...
@@ -274,6 +274,8 @@ namespace Bailun.DC.Services.Component
IRow
headerRow
=
sheet
.
CreateRow
(
0
);
IRow
headerRow
=
sheet
.
CreateRow
(
0
);
//新建一个字体样式对象
//新建一个字体样式对象
IFont
fontTitle
=
workbook
.
CreateFont
();
IFont
fontTitle
=
workbook
.
CreateFont
();
//创建CellStyle与DataFormat并加载格式样式
IDataFormat
dataformat
=
workbook
.
CreateDataFormat
();
//设置字体加粗样式
//设置字体加粗样式
fontTitle
.
IsBold
=
true
;
fontTitle
.
IsBold
=
true
;
//设置字体大小
//设置字体大小
...
@@ -290,7 +292,7 @@ namespace Bailun.DC.Services.Component
...
@@ -290,7 +292,7 @@ namespace Bailun.DC.Services.Component
alignmentstyle
.
Alignment
=
HorizontalAlignment
.
Center
;
alignmentstyle
.
Alignment
=
HorizontalAlignment
.
Center
;
//合并行属性值
//合并行属性值
IDictionary
<
string
,
(
int
,
string
)>
rowSpanProp
=
new
Dictionary
<
string
,
(
int
,
string
)>();
IDictionary
<
string
,
(
int
,
string
)>
rowSpanProp
=
new
Dictionary
<
string
,
(
int
,
string
)>();
//组
头
//组
标题
bool
hasGroup
=
false
;
bool
hasGroup
=
false
;
if
(
listColumn
.
Any
(
l
=>
!
string
.
IsNullOrWhiteSpace
(
l
.
GroupName
)))
if
(
listColumn
.
Any
(
l
=>
!
string
.
IsNullOrWhiteSpace
(
l
.
GroupName
)))
{
{
...
@@ -323,12 +325,30 @@ namespace Bailun.DC.Services.Component
...
@@ -323,12 +325,30 @@ namespace Bailun.DC.Services.Component
});
});
headerRow
=
sheet
.
CreateRow
(
1
);
headerRow
=
sheet
.
CreateRow
(
1
);
}
}
//列
头
//列
标题
listColumn
.
ForEach
((
l
,
col
)
=>
listColumn
.
ForEach
((
l
,
col
)
=>
{
{
var
cell
=
headerRow
.
CreateCell
(
col
);
var
cell
=
headerRow
.
CreateCell
(
col
);
//设置列格式化
if
((
new
string
[]
{
"money"
,
"number"
}).
Contains
(
l
.
Format
as
string
))
{
if
(
l
.
Precision
>
0
)
{
//单元格样式
ICellStyle
dataFormatStyle
=
workbook
.
CreateCellStyle
();
dataFormatStyle
.
CloneStyleFrom
(
verticAlalignmentstyle
);
dataFormatStyle
.
DataFormat
=
dataformat
.
GetFormat
(
$"
{(
l
.
Format
==
"money"
?
"#,##"
:
string
.
Empty
)}
0.
{
"0"
.
PadLeft
(
l
.
Precision
.
Value
,
'0'
)}
"
);
l
.
Style
=
dataFormatStyle
;
}
else
{
l
.
Style
=
verticAlalignmentstyle
;
}
}
cell
.
CellStyle
=
verticAlalignmentstyle
;
cell
.
CellStyle
=
verticAlalignmentstyle
;
//设置列标题
cell
.
SetCellValue
(
l
.
Name
);
cell
.
SetCellValue
(
l
.
Name
);
//设置列宽
if
(
l
.
Width
!=
null
)
if
(
l
.
Width
!=
null
)
{
{
if
(
l
.
Width
.
ToString
().
ToLower
()
==
"auto"
)
if
(
l
.
Width
.
ToString
().
ToLower
()
==
"auto"
)
...
@@ -348,7 +368,7 @@ namespace Bailun.DC.Services.Component
...
@@ -348,7 +368,7 @@ namespace Bailun.DC.Services.Component
{
{
string
value
=
reader
[
header
.
Prop
]?.
ToString
();
string
value
=
reader
[
header
.
Prop
]?.
ToString
();
ICell
cell
=
dataRow
.
CreateCell
(
col
);
ICell
cell
=
dataRow
.
CreateCell
(
col
);
cell
.
CellStyle
=
verticAlalignmentstyle
;
cell
.
CellStyle
=
header
.
Style
as
ICellStyle
??
verticAlalignmentstyle
;
if
(!
string
.
IsNullOrWhiteSpace
(
value
))
if
(!
string
.
IsNullOrWhiteSpace
(
value
))
{
{
if
(
header
.
Format
is
bool
&&
header
.
Format
==
true
)
if
(
header
.
Format
is
bool
&&
header
.
Format
==
true
)
...
...
Bailun.DC.Web/Areas/Component/Views/Form/Control.cshtml
View file @
e2144134
...
@@ -194,10 +194,10 @@
...
@@ -194,10 +194,10 @@
</template>
</template>
<template v-else-if="item.format.constructor === String">
<template v-else-if="item.format.constructor === String">
<template v-if="item.format == 'money'">
<template v-if="item.format == 'money'">
{{
item_value.toLocaleString(
) }}
{{
(item.precision && item.precision > 0 ? parseFloat(Math.round(item_value*Math.pow(10, item.precision))/Math.pow(10, 2).toFixed(item.precision)) : item_value).toLocaleString('zh',{minimumFractionDigits: item.precision}
) }}
</template>
</template>
<template v-else-if="item.format == 'number'">
<template v-else-if="item.format == 'number'">
{{ item_value }}
{{ item
.precision && item.precision > 0 ? Math.round(item_value*Math.pow(10, item.precision))/Math.pow(10, 2).toFixed(item.precision) : item
_value }}
</template>
</template>
<template v-else-if="/[y|Y|m|M|d|h|H|s|S]+/.test(item.format)">
<template v-else-if="/[y|Y|m|M|d|h|H|s|S]+/.test(item.format)">
{{ new Date(item_value).format(item.format) }}
{{ new Date(item_value).format(item.format) }}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment