Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
功
功能演示系统
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
示例
功能演示系统
提交
c18b1a00
提交
c18b1a00
编写于
12月 04, 2020
作者:
ibizdev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ShineKOT 发布系统代码 [后台服务,演示应用]
上级
649a1f1c
变更
14
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
1868 行增加
和
6 行删除
+1868
-6
ibizappview_en_US.ts
...c/locale/lanres/entities/ibizappview/ibizappview_en_US.ts
+3
-0
ibizappview_zh_CN.ts
...c/locale/lanres/entities/ibizappview/ibizappview_zh_CN.ts
+3
-0
app-portal-view-db-dashboard-base.vue
...l-view-db-dashboard/app-portal-view-db-dashboard-base.vue
+4
-4
app-portal-view-db-dashboard.vue
...portal-view-db-dashboard/app-portal-view-db-dashboard.vue
+2
-2
view-chart-chart-base.vue
...ts/ibizappview/view-chart-chart/view-chart-chart-base.vue
+1237
-0
view-chart-chart-model.ts
...ts/ibizappview/view-chart-chart/view-chart-chart-model.ts
+36
-0
view-chart-chart-service.ts
.../ibizappview/view-chart-chart/view-chart-chart-service.ts
+72
-0
view-chart-chart.less
...idgets/ibizappview/view-chart-chart/view-chart-chart.less
+15
-0
view-chart-chart.vue
...widgets/ibizappview/view-chart-chart/view-chart-chart.vue
+14
-0
view-chart-portlet-base.vue
...bizappview/view-chart-portlet/view-chart-portlet-base.vue
+336
-0
view-chart-portlet-model.ts
...bizappview/view-chart-portlet/view-chart-portlet-model.ts
+55
-0
view-chart-portlet-service.ts
...zappview/view-chart-portlet/view-chart-portlet-service.ts
+11
-0
view-chart-portlet.less
...ts/ibizappview/view-chart-portlet/view-chart-portlet.less
+63
-0
view-chart-portlet.vue
...ets/ibizappview/view-chart-portlet/view-chart-portlet.vue
+17
-0
未找到文件。
app_Web/src/locale/lanres/entities/ibizappview/ibizappview_en_US.ts
浏览文件 @
c18b1a00
...
...
@@ -67,6 +67,9 @@ export default {
uiactions
:
{
},
},
viewchart_chart
:
{
nodata
:
""
,
},
default_searchform
:
{
details
:
{
formpage1
:
"常规条件"
,
...
...
app_Web/src/locale/lanres/entities/ibizappview/ibizappview_zh_CN.ts
浏览文件 @
c18b1a00
...
...
@@ -66,6 +66,9 @@ export default {
uiactions
:
{
},
},
viewchart_chart
:
{
nodata
:
""
,
},
default_searchform
:
{
details
:
{
formpage1
:
"常规条件"
,
...
...
app_Web/src/widgets/app/app-portal-view-db-dashboard/app-portal-view-db-dashboard-base.vue
浏览文件 @
c18b1a00
...
...
@@ -71,16 +71,16 @@
<i-col
:md=
"
{ span: 24, offset: 0 }" :lg="{ span: 12, offset: 0 }">
<card
class=
"portlet-card custom-card"
:bordered=
"false"
dis-hover
:padding=
"10"
>
<span>
<view
_db_
rawitem5
<view
_db_
sysportlet2
:viewState=
"viewState"
:viewparams=
"viewparams"
:context=
"context"
:height=
"400"
:width=
"0"
name=
"db_
rawitem5
"
ref=
'db_
rawitem5
'
name=
"db_
sysportlet2
"
ref=
'db_
sysportlet2
'
@
closeview=
"closeView($event)"
>
</view
_db_
rawitem5
>
</view
_db_
sysportlet2
>
</span>
</card>
</i-col>
...
...
app_Web/src/widgets/app/app-portal-view-db-dashboard/app-portal-view-db-dashboard.vue
浏览文件 @
c18b1a00
...
...
@@ -2,10 +2,10 @@
import
{
Component
}
from
'vue-property-decorator'
;
import
AppPortalView_dbBase
from
'./app-portal-view-db-dashboard-base.vue'
;
import
view_db_rawitem1
from
'@widgets/app/db-rawitem1-portlet/db-rawitem1-portlet.vue'
;
import
view_db_sysportlet2
from
'@widgets/ibizappview/view-chart-portlet/view-chart-portlet.vue'
;
import
view_db_sysportlet1
from
'@widgets/ibizappview/app-view-list-portlet/app-view-list-portlet.vue'
;
import
view_db_rawitem7
from
'@widgets/app/db-rawitem7-portlet/db-rawitem7-portlet.vue'
;
import
view_db_rawitem4
from
'@widgets/app/db-rawitem4-portlet/db-rawitem4-portlet.vue'
;
import
view_db_rawitem5
from
'@widgets/app/db-rawitem5-portlet/db-rawitem5-portlet.vue'
;
import
view_db_rawitem2
from
'@widgets/app/db-rawitem2-portlet/db-rawitem2-portlet.vue'
;
import
view_db_rawitem3
from
'@widgets/app/db-rawitem3-portlet/db-rawitem3-portlet.vue'
;
...
...
@@ -13,10 +13,10 @@ import view_db_rawitem3 from '@widgets/app/db-rawitem3-portlet/db-rawitem3-portl
@
Component
({
components
:
{
view_db_rawitem1
,
view_db_sysportlet2
,
view_db_sysportlet1
,
view_db_rawitem7
,
view_db_rawitem4
,
view_db_rawitem5
,
view_db_rawitem2
,
view_db_rawitem3
,
...
...
app_Web/src/widgets/ibizappview/view-chart-chart/view-chart-chart-base.vue
0 → 100644
浏览文件 @
c18b1a00
<
template
>
<div
class=
"app-data-chart"
>
<div
v-show=
"isNoData"
class=
"chart-no-data"
><i
class=
"el-icon-data-analysis"
></i>
{{
$t
(
'entities.ibizappview.viewchart_chart.nodata'
)
}}
</div>
<div
v-show=
"!isNoData"
class=
"app-charts"
:id=
"chartId"
style=
"height: 300px;padding: 6px 0;"
></div>
</div>
</
template
>
<
script
lang=
'tsx'
>
import
{
Vue
,
Component
,
Prop
,
Provide
,
Emit
,
Watch
,
Model
,
Inject
}
from
'vue-property-decorator'
;
import
{
CreateElement
}
from
'vue'
;
import
{
Subject
,
Subscription
}
from
'rxjs'
;
import
{
ControlInterface
}
from
'@/interface/control'
;
import
{
UIActionTool
,
Util
,
ViewTool
}
from
'@/utils'
;
import
NavDataService
from
'@/service/app/navdata-service'
;
import
AppCenterService
from
"@service/app/app-center-service"
;
import
IBIZAPPVIEWService
from
'@/service/ibizappview/ibizappview-service'
;
import
ViewChartService
from
'./view-chart-chart-service'
;
import
IBIZAPPVIEWUIService
from
'@/uiservice/ibizappview/ibizappview-ui-service'
;
import
echarts
from
'echarts'
;
import
moment
from
"moment"
;
import
CodeListService
from
"@/codelist/codelist-service"
;
import
{
ChartDataSetField
,
ChartLineSeries
,
ChartFunnelSeries
,
ChartPieSeries
,
ChartBarSeries
,
ChartRadarSeries
}
from
'@/model/chart-detail'
;
@
Component
({
components
:
{
}
})
export
default
class
ViewChartBase
extends
Vue
implements
ControlInterface
{
/**
* 名称
*
* @type {string}
* @memberof ViewChartBase
*/
@
Prop
()
public
name
?:
string
;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof ViewChartBase
*/
@
Prop
()
public
viewState
!
:
Subject
<
ViewState
>
;
/**
* 应用上下文
*
* @type {*}
* @memberof ViewChartBase
*/
@
Prop
()
public
context
!
:
any
;
/**
* 视图参数
*
* @type {*}
* @memberof ViewChartBase
*/
@
Prop
()
public
viewparams
!
:
any
;
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof ViewChartBase
*/
public
viewStateEvent
:
Subscription
|
undefined
;
/**
* 获取部件类型
*
* @returns {string}
* @memberof ViewChartBase
*/
public
getControlType
():
string
{
return
'CHART'
}
/**
* 建构部件服务对象
*
* @type {ViewChartService}
* @memberof ViewChartBase
*/
public
service
:
ViewChartService
=
new
ViewChartService
({
$store
:
this
.
$store
});
/**
* 实体服务对象
*
* @type {IBIZAPPVIEWService}
* @memberof ViewChartBase
*/
public
appEntityService
:
IBIZAPPVIEWService
=
new
IBIZAPPVIEWService
({
$store
:
this
.
$store
});
/**
* 转化数据
*
* @param {any} args
* @memberof ViewChartBase
*/
public
transformData
(
args
:
any
)
{
let
_this
:
any
=
this
;
if
(
_this
.
service
&&
_this
.
service
.
handleRequestData
instanceof
Function
&&
_this
.
service
.
handleRequestData
(
'transform'
,
_this
.
context
,
args
)){
return
_this
.
service
.
handleRequestData
(
'transform'
,
_this
.
context
,
args
)[
'data'
];
}
}
/**
* 关闭视图
*
* @param {any} args
* @memberof ViewChartBase
*/
public
closeView
(
args
:
any
):
void
{
let
_this
:
any
=
this
;
_this
.
$emit
(
'closeview'
,
[
args
]);
}
/**
* 计数器刷新
*
* @memberof ViewChartBase
*/
public
counterRefresh
(){
const
_this
:
any
=
this
;
if
(
_this
.
counterServiceArray
&&
_this
.
counterServiceArray
.
length
>
0
){
_this
.
counterServiceArray
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
refreshData
&&
item
.
refreshData
instanceof
Function
){
item
.
refreshData
();
}
})
}
}
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof ViewChartBase
*/
public
getDatas
():
any
[]
{
return
[];
}
/**
* 获取单项树
*
* @returns {*}
* @memberof ViewChartBase
*/
public
getData
():
any
{
return
null
;
}
/**
* 显示处理提示
*
* @type {boolean}
* @memberof ViewChartBase
*/
@
Prop
({
default
:
true
})
public
showBusyIndicator
!
:
boolean
;
/**
* 部件行为--fetch
*
* @type {string}
* @memberof ViewChartBase
*/
@
Prop
()
public
fetchAction
!
:
string
;
/**
* Vue声明周期(组件初始化完毕)
*
* @memberof ViewChartBase
*/
public
created
()
{
this
.
afterCreated
();
}
/**
* 执行created后的逻辑
*
* @memberof ViewChartBase
*/
public
afterCreated
(){
if
(
this
.
viewState
)
{
this
.
viewStateEvent
=
this
.
viewState
.
subscribe
(({
tag
,
action
,
data
})
=>
{
if
(
!
Object
.
is
(
tag
,
this
.
name
))
{
return
;
}
if
(
Object
.
is
(
'load'
,
action
))
{
this
.
load
(
data
);
}
if
(
Object
.
is
(
'refresh'
,
action
))
{
this
.
refresh
(
data
);
}
});
}
}
/**
* vue 生命周期
*
* @memberof ViewChartBase
*/
public
destroyed
()
{
this
.
afterDestroy
();
}
/**
* 执行destroyed后的逻辑
*
* @memberof ViewChartBase
*/
public
afterDestroy
()
{
if
(
this
.
viewStateEvent
)
{
this
.
viewStateEvent
.
unsubscribe
();
}
}
/**
* 是否无数据
*
* @public
* @type {boolean}
* @memberof Db_sysportlet2_chartBase
*/
public
isNoData
:
boolean
=
false
;
/**
* 图表div绑定的id
*
* @type {}
* @memberof Db_sysportlet2_chartBase
*/
public
chartId
:
string
=
this
.
$util
.
createUUID
();
/**
* echarts图表对象
*
* @type {}
* @memberof Db_sysportlet2_chartBase
*/
public
myChart
:
any
;
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof Db_sysportlet2_chartBase
*/
public
codeListService
:
CodeListService
=
new
CodeListService
({
$store
:
this
.
$store
});
/**
* 序列模型
*
* @type {}
* @memberof Db_sysportlet2_chartBase
*/
public
seriesModel
:
any
=
{
viewbarchart
:
new
ChartBarSeries
({
name
:
'viewbarchart'
,
categorField
:
'ibizappviewtype'
,
categorCodeList
:{
type
:
'STATIC'
,
tag
:
'AppViewType'
,
emptycode
:
'empty'
,
emptytext
:
'未定义'
},
valueField
:
'amount'
,
seriesValues
:[],
seriesIndex
:
0
,
data
:[],
seriesMap
:{},
dataSetFields
:[
{
name
:
"ibizappviewtype"
,
codelist
:{
type
:
"STATIC"
,
tag
:
"AppViewType"
,
emptycode
:
'empty'
,
emptytext
:
'未定义'
},
isGroupField
:
true
,
groupMode
:
""
},
{
name
:
"amount"
,
codelist
:
null
,
isGroupField
:
false
,
groupMode
:
""
}
],
ecxObject
:{
label
:{
show
:
true
,
position
:
'inside'
},
labelLine
:{
length
:
10
,
lineStyle
:
{
width
:
1
,
type
:
'solid'
}
},
itemStyle
:{
borderColor
:
'#fff'
,
borderWidth
:
1
},
emphasis
:{
label
:
{
fontSize
:
20
}
}
},
ecObject
:{
},
seriesTemp
:{
type
:
'bar'
,
},
baseOption
:{
},
seriesLayoutBy
:
"column"
})
};
/**
* 图表自定义参数集合
*
* @memberof Db_sysportlet2_chartBase
*/
public
chartUserParams
:
any
=
{
};
/**
* 图表基础动态模型
*
* @memberof Db_sysportlet2_chartBase
*/
public
chartBaseOPtion
:
any
=
{};
/**
* 图表绘制最终参数
*
* @memberof Db_sysportlet2_chartBase
*/
public
chartRenderOption
:
any
=
{};
/**
* 初始化图表所需参数
*
* @type {}
* @memberof Db_sysportlet2_chartBase
*/
public
chartOption
:
any
=
{
title
:{
show
:
false
,
text
:
'视图图表'
,
subtext
:
''
},
legend
:{
show
:
true
},
grid
:[
{
}
],
xAxis
:
[
{
gridIndex
:
0
,
position
:
"bottom"
,
type
:
'value'
,
name
:
'视图类型'
,
}
],
yAxis
:[
{
gridIndex
:
0
,
position
:
"top"
,
type
:
'value'
,
name
:
'数量'
,
}
],
tooltip
:{
show
:
true
},
dataset
:[],
series
:[
{
id
:
'viewbarchart'
,
name
:
''
,
type
:
'bar'
,
xAxisIndex
:
0
,
yAxisIndex
:
0
,
datasetIndex
:
0
,
encode
:
{
x
:
[
'amount'
],
y
:
[
'amount'
]
}}
]
};
/**
* 刷新
*
* @param {*} [args={}]
* @memberof Db_sysportlet2_chartBase
*/
public
refresh
(
args
?:
any
)
{
this
.
load
(
args
);
}
/**
* 获取图表数据
*
* @returns {*}
* @memberof Db_sysportlet2_chartBase
*/
public
load
(
opt
?:
any
)
{
let
_this
=
this
;
const
arg
:
any
=
{
...
opt
};
const
parentdata
:
any
=
{};
this
.
$emit
(
'beforeload'
,
parentdata
);
Object
.
assign
(
arg
,
parentdata
);
let
tempViewParams
:
any
=
parentdata
.
viewparams
?
parentdata
.
viewparams
:{};
Object
.
assign
(
tempViewParams
,
JSON
.
parse
(
JSON
.
stringify
(
this
.
viewparams
)));
Object
.
assign
(
arg
,{
viewparams
:
tempViewParams
});
Object
.
assign
(
arg
,{
page
:
0
,
size
:
1000
});
this
.
service
.
search
(
this
.
fetchAction
,
JSON
.
parse
(
JSON
.
stringify
(
this
.
context
)),
arg
,
this
.
showBusyIndicator
).
then
((
res
)
=>
{
if
(
res
)
{
this
.
transformToBasicChartSetData
(
res
.
data
,(
codelist
:
any
)
=>
{
_this
.
drawCharts
(
codelist
)});
}
}).
catch
((
error
)
=>
{
console
.
error
(
error
);
});
}
/**
* 绘制图表
*
* @returns {*}
* @memberof Db_sysportlet2_chartBase
*/
public
drawCharts
(
codelist
:
any
){
if
(
!
this
.
myChart
){
let
element
:
any
=
document
.
getElementById
(
this
.
chartId
);
this
.
myChart
=
echarts
.
init
(
element
);
}
let
_chartOption
=
this
.
handleChartOPtion
(
codelist
);
this
.
chartRenderOption
=
{...
_chartOption
};
this
.
myChart
.
setOption
(
_chartOption
);
this
.
myChart
.
resize
();
}
/**
* 处理图表参数
*
* @memberof Db_sysportlet2_chartBase
*/
public
handleChartOPtion
(
allcodelist
:
any
){
let
_chartOption
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
chartOption
));
if
(
Object
.
keys
(
this
.
seriesModel
).
length
>
0
){
let
tempDataSourceMap
:
Map
<
string
,
any
>
=
new
Map
();
for
(
let
i
=
0
;
i
<
Object
.
keys
(
this
.
seriesModel
).
length
;
i
++
){
Object
.
values
(
this
.
seriesModel
).
forEach
((
seriesvalue
:
any
)
=>
{
if
(
seriesvalue
.
seriesIndex
===
i
){
tempDataSourceMap
.
set
(
seriesvalue
.
name
,
seriesvalue
.
data
);
}
})
}
if
(
tempDataSourceMap
.
size
>
0
){
tempDataSourceMap
.
forEach
((
item
:
any
)
=>
{
_chartOption
.
dataset
.
push
({
'source'
:
item
});
})
}
Object
.
keys
(
this
.
seriesModel
).
forEach
((
seriesName
:
string
)
=>
{
if
(
_chartOption
&&
_chartOption
.
series
.
length
>
0
){
_chartOption
.
series
.
forEach
((
item
:
any
)
=>
{
if
(
this
.
seriesModel
[
seriesName
].
ecxObject
&&
Object
.
is
(
seriesName
,
item
.
id
)){
item
=
Util
.
deepObjectMerge
(
item
,
this
.
seriesModel
[
seriesName
].
ecxObject
);
}
if
(
this
.
seriesModel
[
seriesName
].
baseOption
&&
Object
.
keys
(
this
.
seriesModel
[
seriesName
].
baseOption
).
length
>
0
&&
Object
.
is
(
seriesName
,
item
.
id
)){
item
=
Util
.
deepObjectMerge
(
item
,
this
.
seriesModel
[
seriesName
].
baseOption
);
}
if
(
this
.
seriesModel
[
seriesName
].
ecObject
&&
Object
.
is
(
seriesName
,
item
.
id
)){
item
=
Util
.
deepObjectMerge
(
item
,
this
.
seriesModel
[
seriesName
].
ecObject
);
}
})
}
//设置多序列
let
tempSeries
:
any
=
this
.
seriesModel
[
seriesName
];
// 非雷达图
if
(
tempSeries
&&
tempSeries
.
seriesIdField
&&
tempSeries
.
seriesValues
.
length
>
0
&&
!
Object
.
is
(
tempSeries
.
type
,
'radar'
)){
const
returnIndex
:
number
=
_chartOption
.
series
.
findIndex
((
item
:
any
)
=>
{
return
Object
.
is
(
item
.
id
,
seriesName
);
})
_chartOption
.
series
.
splice
(
returnIndex
,
1
);
let
tempSeriesArray
:
Array
<
any
>
=
[];
tempSeries
.
seriesValues
.
forEach
((
seriesvalueItem
:
any
)
=>
{
let
tempSeriesTemp
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
tempSeries
.
seriesTemp
));
Object
.
assign
(
tempSeriesTemp
,{
name
:
tempSeries
.
seriesMap
[
seriesvalueItem
],
datasetIndex
:
tempSeries
.
seriesIndex
,
encode
:{
x
:
tempSeries
.
categorField
,
y
:
`
${
seriesvalueItem
}
`
}});
_chartOption
.
series
.
push
(
tempSeriesTemp
);
})
}
})
}
if
(
Object
.
keys
(
this
.
chartBaseOPtion
).
length
>
0
){
Object
.
assign
(
_chartOption
,
this
.
chartBaseOPtion
);
}
if
(
Object
.
keys
(
this
.
chartUserParams
).
length
>
0
){
Object
.
assign
(
_chartOption
,
this
.
chartUserParams
);
}
return
_chartOption
;
}
/**
* 实体数据集转化为图表数据集
*
* 1.获取图表所有代码表值
* 2.查询集合映射图表数据集
* 3.补全图表数据集
* 4.图表数据集分组求和
* 5.排序图表数据集
*
* @param {*} data 实体数据集
* @param {Function} callback 回调
* @memberof Db_sysportlet2_chartBase
*/
public
async
transformToBasicChartSetData
(
data
:
any
,
callback
:
Function
){
if
(
!
data
||
!
Array
.
isArray
(
data
)
||
data
.
length
===
0
){
this
.
isNoData
=
true
;
return
;
}
this
.
isNoData
=
false
;
//获取代码表值
let
allCodeList
:
any
=
await
this
.
getChartAllCodeList
();
if
(
Object
.
values
(
this
.
seriesModel
).
length
>
0
){
Object
.
values
(
this
.
seriesModel
).
forEach
((
singleSeries
:
any
,
index
:
number
)
=>
{
// 值属性为srfcount设置{srfcount:1}到data
let
valueField
=
singleSeries
.
dataSetFields
.
find
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
singleSeries
.
valueField
;
});
if
(
valueField
&&
valueField
.
name
&&
Object
.
is
(
valueField
.
name
,
"srfcount"
)){
data
.
forEach
((
singleData
:
any
)
=>
{
Object
.
assign
(
singleData
,{
srfcount
:
1
});
})
}
// 分组属性
let
groupField
=
singleSeries
.
dataSetFields
.
find
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
singleSeries
.
categorField
;
});
let
tempChartSetData
:
Array
<
any
>
=
[];
let
tempSeriesValues
:
Map
<
string
,
any
>
=
new
Map
();
data
.
forEach
((
item
:
any
)
=>
{
let
tempChartSetDataItem
:
any
=
{};
// 序列属性不存在
if
(
!
singleSeries
.
seriesIdField
){
Object
.
assign
(
tempChartSetDataItem
,{
name
:
singleSeries
.
name
});
if
(
singleSeries
.
dataSetFields
&&
singleSeries
.
dataSetFields
.
length
>
0
){
singleSeries
.
dataSetFields
.
forEach
((
singleDataSetField
:
any
)
=>
{
this
.
handleSingleDataSetField
(
item
,
singleDataSetField
,
allCodeList
,
tempChartSetDataItem
,
groupField
);
})
}
}
else
{
// 序列属性存在时
// 序列代码表存在时,翻译tempSeriesValues的键值对
if
(
singleSeries
.
seriesCodeList
){
const
seriesCodeList
:
Map
<
string
,
any
>
=
allCodeList
.
get
(
singleSeries
.
seriesCodeList
.
tag
);
let
tempSeriesValueItem
=
tempSeriesValues
.
get
(
seriesCodeList
.
get
(
item
[
singleSeries
.
seriesIdField
]));
if
(
!
tempSeriesValueItem
){
tempSeriesValues
.
set
(
seriesCodeList
.
get
(
item
[
singleSeries
.
seriesIdField
]),
seriesCodeList
.
get
(
item
[
singleSeries
.
seriesIdField
]));
}
}
else
{
let
tempSeriesValueItem
=
tempSeriesValues
.
get
(
item
[
singleSeries
.
seriesIdField
]);
if
(
!
tempSeriesValueItem
){
tempSeriesValues
.
set
(
item
[
singleSeries
.
seriesIdField
],
item
[
singleSeries
.
seriesNameField
]);
}
}
Object
.
assign
(
tempChartSetDataItem
,{
name
:
item
[
singleSeries
.
seriesIdField
]});
if
(
singleSeries
.
dataSetFields
&&
singleSeries
.
dataSetFields
.
length
>
0
){
singleSeries
.
dataSetFields
.
forEach
((
singleDataSetField
:
any
)
=>
{
this
.
handleSingleDataSetField
(
item
,
singleDataSetField
,
allCodeList
,
tempChartSetDataItem
,
groupField
);
})
}
}
tempChartSetData
.
push
(
tempChartSetDataItem
);
})
// 补全数据集合
this
.
completeDataSet
(
tempChartSetData
,
singleSeries
,
allCodeList
);
// 序列代码表存在时,补全序列
if
(
singleSeries
.
seriesCodeList
){
const
seriesCodeList
:
Map
<
string
,
any
>
=
allCodeList
.
get
(
singleSeries
.
seriesCodeList
.
tag
);
tempSeriesValues
=
new
Map
();
seriesCodeList
.
forEach
((
item
:
any
)
=>
{
tempSeriesValues
.
set
(
item
,
item
);
})
}
singleSeries
.
seriesValues
=
[...
tempSeriesValues
.
keys
()];
let
tempSeriesMapObj
:
any
=
{};
tempSeriesValues
.
forEach
((
value
:
any
,
key
:
any
)
=>
{
tempSeriesMapObj
[
key
]
=
value
;
})
singleSeries
.
seriesMap
=
tempSeriesMapObj
;
let
callbackFunction
:
any
=
(
index
===
(
Object
.
values
(
this
.
seriesModel
).
length
-
1
))?
callback
:
null
;
this
.
transformToChartSeriesDataSet
(
tempChartSetData
,
singleSeries
,
callbackFunction
,
allCodeList
);
})
}
}
/**
* 构建图表序列数据集合
*
* 1.分组求和
* 2.排序求和数组
*
* @param {Array<any>} data 传入数据
* @param {Array<any>} item 单个序列
* @param {Array<any>} callback 回调
* @param {*} allCodeList 所有代码表
*
* @memberof Db_sysportlet2_chartBase
*/
public
transformToChartSeriesDataSet
(
data
:
any
,
item
:
any
,
callback
:
Function
,
allCodeList
:
any
):
any
{
if
(
item
.
seriesIdField
){
// 多序列
let
groupField
=
item
.
dataSetFields
.
filter
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
item
.
categorField
;
});
let
tempGroupField
:
Array
<
any
>
=
groupField
.
map
((
item
:
any
)
=>
{
return
item
.
name
;
});
let
seriesField
=
item
.
dataSetFields
.
filter
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
item
.
seriesIdField
;
});
let
tempSeriesField
:
Array
<
any
>
=
seriesField
.
map
((
item
:
any
)
=>
{
return
item
.
name
;
});
let
valueField
=
item
.
dataSetFields
.
filter
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
item
.
valueField
;
});
let
tempValueField
:
Array
<
any
>
=
valueField
.
map
((
item
:
any
)
=>
{
return
item
.
name
;
});
item
.
data
=
this
.
groupAndAdd
(
tempGroupField
,
tempSeriesField
,
tempValueField
,
data
,
item
,
groupField
,
allCodeList
);
}
else
{
//单序列
let
groupField
=
item
.
dataSetFields
.
filter
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
item
.
categorField
;
});
let
tempGroupField
:
Array
<
any
>
=
groupField
.
map
((
item
:
any
)
=>
{
return
item
.
name
;
})
let
valueField
=
item
.
dataSetFields
.
filter
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
item
.
valueField
;
});
let
tempValueField
:
Array
<
any
>
=
valueField
.
map
((
item
:
any
)
=>
{
return
item
.
name
;
})
item
.
data
=
this
.
groupAndAdd
(
tempGroupField
,[],
tempValueField
,
data
,
item
,
groupField
,
allCodeList
);
}
if
(
callback
&&
callback
instanceof
Function
){
callback
(
allCodeList
);
}
}
/**
* 分组和求和
* @param {Array<any>} groupField 分组属性
* @param {Array<any>} groupField 值属性
* @param {Array<any>} data 传入数据
* @param {*} groupFieldModel 分组属性模型
* @param {*} allCodeList 所有代码表
*
* @memberof Db_sysportlet2_chartBase
*/
public
groupAndAdd
(
groupField
:
Array
<
any
>
,
seriesField
:
Array
<
any
>
,
valueField
:
Array
<
any
>
,
data
:
any
,
item
:
any
,
groupFieldModel
:
any
,
allCodeList
:
any
){
let
tempMap
:
Map
<
string
,
any
>
=
new
Map
();
let
groupMode
:
string
=
groupFieldModel
[
0
].
groupMode
;
let
groupKeyStr
:
string
=
""
;
data
.
forEach
((
item
:
any
)
=>
{
let
tempGroupField
:
string
=
groupField
[
0
];
groupKeyStr
=
item
[
tempGroupField
];
let
tempMapItem
:
any
=
tempMap
.
get
(
groupKeyStr
);
if
(
tempMapItem
){
tempMapItem
.
push
(
item
);
tempMap
.
set
(
groupKeyStr
,
tempMapItem
);
}
else
{
tempMap
.
set
(
groupKeyStr
,[
item
]);
}
})
// 处理多序列
if
(
seriesField
.
length
>
0
&&
tempMap
.
size
>
0
){
let
tempSeriesField
:
string
=
seriesField
[
0
];
tempMap
.
forEach
((
item
:
any
,
key
:
string
)
=>
{
let
tempItemMap
:
Map
<
string
,
any
>
=
new
Map
();
item
.
forEach
((
singleItem
:
any
)
=>
{
let
seriesValueArray
:
any
=
tempItemMap
.
get
(
singleItem
[
tempSeriesField
]);
if
(
seriesValueArray
){
seriesValueArray
.
push
(
singleItem
);
tempItemMap
.
set
(
singleItem
[
tempSeriesField
],
seriesValueArray
);
}
else
{
tempItemMap
.
set
(
singleItem
[
tempSeriesField
],[
singleItem
]);
}
})
tempMap
.
set
(
key
,
tempItemMap
);
});
}
let
returnArray
:
Array
<
any
>
=
[];
if
(
seriesField
.
length
==
0
){
//单序列
tempMap
.
forEach
((
tempItem
:
any
)
=>
{
if
(
tempItem
.
length
>
0
){
let
curObject
:
any
=
{};
let
valueResult
:
number
=
0
;
let
categorResult
:
any
;
tempItem
.
forEach
((
singleItem
:
any
)
=>
{
categorResult
=
singleItem
[
groupField
[
0
]];
valueResult
+=
singleItem
[
valueField
[
0
]];
})
Object
.
defineProperty
(
curObject
,
groupField
[
0
],
{
value
:
categorResult
,
writable
:
true
,
enumerable
:
true
,
configurable
:
true
});
Object
.
defineProperty
(
curObject
,
valueField
[
0
],
{
value
:
valueResult
,
writable
:
true
,
enumerable
:
true
,
configurable
:
true
});
returnArray
.
push
(
curObject
);
}
})
}
else
{
// 多序列
let
seriesValuesArray
:
Array
<
any
>
=
item
.
seriesValues
;
tempMap
.
forEach
((
groupItem
:
any
,
groupKey
:
string
)
=>
{
//求和
let
curObject
:
any
=
{};
Object
.
defineProperty
(
curObject
,
groupField
[
0
],
{
value
:
groupKey
,
writable
:
true
,
enumerable
:
true
,
configurable
:
true
});
seriesValuesArray
.
forEach
((
seriesValueItem
:
any
)
=>
{
Object
.
defineProperty
(
curObject
,
seriesValueItem
,
{
value
:
0
,
writable
:
true
,
enumerable
:
true
,
configurable
:
true
});
});
groupItem
.
forEach
((
seriesItem
:
any
,
seriesKey
:
string
)
=>
{
let
seriesNum
:
number
=
0
;
seriesItem
.
forEach
((
dataItem
:
any
)
=>
{
seriesNum
+=
dataItem
[
valueField
[
0
]];
})
curObject
[
seriesKey
]
=
seriesNum
;
})
returnArray
.
push
(
curObject
);
})
}
// 补全空白分类
if
(
returnArray
.
length
>
0
){
let
emptyText
=
(
groupFieldModel
[
0
]
&&
groupFieldModel
[
0
].
codeList
)?
groupFieldModel
[
0
].
codeList
.
emptytext
:(
this
.
$t
(
'app.chart.undefined'
)
as
string
);
returnArray
.
forEach
((
item
:
any
)
=>
{
if
(
!
item
[
groupField
[
0
]]){
item
[
groupField
[
0
]]
=
emptyText
;
}
})
}
returnArray
=
this
.
sortReturnArray
(
returnArray
,
groupFieldModel
,
allCodeList
);
// 雷达图数据格式处理
if
(
Object
.
is
(
item
.
type
,
'radar'
)
&&
returnArray
.
length
>
0
){
let
tempReturnArray
:
Array
<
any
>
=
[];
let
seriesValues
:
Array
<
any
>
=
item
.
seriesValues
;
if
(
seriesValues
&&
seriesValues
.
length
>
0
){
seriesValues
.
forEach
((
singleSeriesName
:
any
)
=>
{
let
singleSeriesObj
:
any
=
{};
returnArray
.
forEach
((
item
:
any
)
=>
{
Object
.
assign
(
singleSeriesObj
,{[
item
[
groupField
[
0
]]]:
item
[
singleSeriesName
]});
})
Object
.
assign
(
singleSeriesObj
,{
type
:
singleSeriesName
});
tempReturnArray
.
push
(
singleSeriesObj
);
})
}
returnArray
=
tempReturnArray
;
}
console
.
log
(
JSON
.
stringify
(
returnArray
));
return
returnArray
;
}
/**
* 排序数组
*
* @param {Array<any>} arr 传入数组
* @param {*} groupField 分组属性
* @param {*} allCodeList 所有代码表
*
* @memberof Db_sysportlet2_chartBase
*/
public
sortReturnArray
(
arr
:
Array
<
any
>
,
groupField
:
any
,
allCodeList
:
any
){
let
returnArray
:
Array
<
any
>
=
[];
// todo
// 分组属性有代码表的情况(最后执行)
if
(
groupField
[
0
].
codelist
){
let
curCodeList
:
Map
<
number
,
any
>
=
allCodeList
.
get
(
groupField
[
0
].
codelist
.
tag
);
curCodeList
.
forEach
((
codelist
:
any
)
=>
{
arr
.
forEach
((
item
:
any
)
=>
{
if
(
Object
.
is
(
item
[
groupField
[
0
].
name
],
codelist
)){
returnArray
.
push
(
item
);
item
.
hasused
=
true
;
}
})
})
arr
.
forEach
((
item
:
any
,
index
:
number
)
=>
{
if
(
!
item
.
hasused
){
returnArray
.
push
(
item
);
}
})
returnArray
.
forEach
((
item
:
any
)
=>
{
delete
item
.
hasused
;
})
}
else
{
// 分组为年份
if
(
Object
.
is
(
groupField
[
0
].
groupMode
,
"YEAR"
)){
returnArray
=
arr
.
sort
((
a
:
any
,
b
:
any
)
=>
{
return
Number
(
a
[
groupField
[
0
].
name
])
-
Number
(
b
[
groupField
[
0
].
name
]);
});
}
else
if
(
Object
.
is
(
groupField
[
0
].
groupMode
,
"QUARTER"
)){
returnArray
=
this
.
handleSortGroupData
(
arr
,
groupField
,(
this
.
$t
(
'app.chart.quarter'
)
as
string
));
}
else
if
(
Object
.
is
(
groupField
[
0
].
groupMode
,
"MONTH"
)){
returnArray
=
this
.
handleSortGroupData
(
arr
,
groupField
,(
this
.
$t
(
'app.calendar.month'
)
as
string
));
}
else
if
(
Object
.
is
(
groupField
[
0
].
groupMode
,
"YEARWEEK"
)){
returnArray
=
this
.
handleSortGroupData
(
arr
,
groupField
,(
this
.
$t
(
'app.calendar.week'
)
as
string
));
}
else
if
(
Object
.
is
(
groupField
[
0
].
groupMode
,
"DAY"
)){
returnArray
=
arr
.
sort
((
a
:
any
,
b
:
any
)
=>
{
return
moment
(
a
[
groupField
[
0
].
name
]).
unix
()
-
moment
(
b
[
groupField
[
0
].
name
]).
unix
();
});
}
else
{
let
groupFieldName
:
string
=
groupField
[
0
].
name
;
let
isConvert
:
boolean
=
true
;
arr
.
forEach
((
item
:
any
)
=>
{
if
(
isNaN
(
item
[
groupFieldName
])){
isConvert
=
false
;
}
})
if
(
isConvert
){
returnArray
=
arr
.
sort
((
a
:
any
,
b
:
any
)
=>
{
return
a
[
groupFieldName
]
-
b
[
groupFieldName
];
});
}
else
{
returnArray
=
arr
;
}
}
}
return
returnArray
;
}
/**
* 排序分组模式下的数据
*
* @param {Array<any>} arr 传入数据
* @param {Array<any>} groupField 分组属性
* @param {Array<any>} label label标签
*
* @memberof Db_sysportlet2_chartBase
*/
public
handleSortGroupData
(
arr
:
Array
<
any
>
,
groupField
:
any
,
label
:
string
){
arr
.
forEach
((
item
:
any
)
=>
{
let
sortFieldValue
:
Array
<
any
>
=
item
[
groupField
[
0
].
name
].
split
(
"-"
);
Object
.
assign
(
item
,{
sortField
:
Number
(
sortFieldValue
[
0
])
*
10000
+
Number
(
sortFieldValue
[
1
])});
/**
* @judgment 分组为月份时,月份+1 start
* @author mos
* @date 2020.07.20
*/
if
(
Object
.
is
(
label
,
"月"
))
{
item
[
groupField
[
0
].
name
]
=
sortFieldValue
[
0
]
+
(
this
.
$t
(
'app.chart.year'
)
as
string
)
+
(
Number
(
sortFieldValue
[
1
])
+
1
)
+
label
;
}
else
{
item
[
groupField
[
0
].
name
]
=
sortFieldValue
[
0
]
+
(
this
.
$t
(
'app.chart.year'
)
as
string
)
+
sortFieldValue
[
1
]
+
label
;
}
// @judgment 分组为月份时,月份+1 end
})
arr
.
sort
((
a
:
any
,
b
:
any
)
=>
{
return
Number
(
a
.
sortField
)
-
Number
(
b
.
sortField
);
});
arr
.
forEach
((
item
:
any
)
=>
{
delete
item
.
sortField
;
})
return
arr
;
}
/**
* 补全数据集
*
* @param {Array<any>} data 传入数据
* @param {Array<any>} item 单个序列
* @param {Array<any>} allCodeList 所有的代码表
*
* @memberof Db_sysportlet2_chartBase
*/
public
completeDataSet
(
data
:
any
,
item
:
any
,
allCodeList
:
any
){
// 分组属性
let
groupField
=
item
.
dataSetFields
.
find
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
item
.
categorField
;
});
if
(
Object
.
is
(
groupField
.
groupMode
,
""
)){
return
;
}
//分组模式为代码表(补值)
if
(
Object
.
is
(
groupField
.
groupMode
,
'CODELIST'
)){
this
.
completeCodeList
(
data
,
item
,
allCodeList
);
}
//分组模式为年/季度/月份(最大值,最小值,分组,补值)
if
(
Object
.
is
(
groupField
.
groupMode
,
"YEAR"
)
||
Object
.
is
(
groupField
.
groupMode
,
"QUARTER"
)
||
Object
.
is
(
groupField
.
groupMode
,
"MONTH"
)
||
Object
.
is
(
groupField
.
groupMode
,
"YEARWEEK"
)
||
Object
.
is
(
groupField
.
groupMode
,
"DAY"
)){
this
.
handleTimeData
(
data
,
item
,
allCodeList
,
groupField
);
}
}
/**
* 获取最大值最小值
*
* @param {Array<any>} tempTimeArray 传入数据
*
* @memberof Db_sysportlet2_chartBase
*/
public
getRangeData
(
tempTimeArray
:
Array
<
any
>
){
tempTimeArray
.
forEach
((
item
:
any
)
=>
{
let
tempParams
:
Array
<
any
>
=
item
.
_i
.
split
(
"-"
);
item
.
sortField
=
Number
(
tempParams
[
0
]
+
tempParams
[
1
]);
})
tempTimeArray
.
sort
((
a
:
any
,
b
:
any
)
=>
{
return
Number
(
a
.
sortField
)
-
Number
(
b
.
sortField
);
});
tempTimeArray
.
forEach
((
item
:
any
)
=>
{
delete
item
.
sortField
;
})
return
tempTimeArray
;
}
/**
* 补全时间类型数据集
*
* @param {Array<any>} data 传入数据
* @param {Array<any>} item 单个序列
* @param {Array<any>} allCodeList 所有的代码表
* @param {Array<any>} groupField 分组属性
*
* @memberof Db_sysportlet2_chartBase
*/
public
handleTimeData
(
data
:
any
,
item
:
any
,
allCodeList
:
any
,
groupField
:
any
){
let
valueField
=
item
.
dataSetFields
.
find
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
item
.
valueField
;
});
let
groupMode
:
string
=
groupField
.
groupMode
;
// 排序数据,找到最大值、最小值
let
tempTimeArray
:
Array
<
any
>
=
[];
if
(
data
&&
data
.
length
>
0
){
data
.
forEach
((
dataItem
:
any
)
=>
{
// 判断时间类型是否为空,为空不处理
if
(
dataItem
[
groupField
.
name
]){
tempTimeArray
.
push
(
moment
(
dataItem
[
groupField
.
name
]));
}
})
}
let
maxTime
:
any
;
let
minTime
:
any
;
if
(
Object
.
is
(
groupMode
,
"YEAR"
)
||
Object
.
is
(
groupMode
,
"DAY"
)){
maxTime
=
moment
.
max
(
tempTimeArray
);
minTime
=
moment
.
min
(
tempTimeArray
);
}
if
(
Object
.
is
(
groupMode
,
"QUARTER"
)){
tempTimeArray
=
this
.
getRangeData
(
tempTimeArray
);
minTime
=
moment
().
year
((
tempTimeArray
[
0
].
_i
.
split
(
"-"
))[
0
]).
quarters
((
tempTimeArray
[
0
].
_i
.
split
(
"-"
))[
1
]);
maxTime
=
moment
().
year
((
tempTimeArray
[
tempTimeArray
.
length
-
1
].
_i
.
split
(
"-"
))[
0
]).
quarters
((
tempTimeArray
[
tempTimeArray
.
length
-
1
].
_i
.
split
(
"-"
))[
1
]);
}
if
(
Object
.
is
(
groupMode
,
"MONTH"
)){
tempTimeArray
=
this
.
getRangeData
(
tempTimeArray
);
minTime
=
moment
().
year
((
tempTimeArray
[
0
].
_i
.
split
(
"-"
))[
0
]).
month
((
tempTimeArray
[
0
].
_i
.
split
(
"-"
))[
1
]);
maxTime
=
moment
().
year
((
tempTimeArray
[
tempTimeArray
.
length
-
1
].
_i
.
split
(
"-"
))[
0
]).
month
((
tempTimeArray
[
tempTimeArray
.
length
-
1
].
_i
.
split
(
"-"
))[
1
]);
}
if
(
Object
.
is
(
groupMode
,
"YEARWEEK"
)){
tempTimeArray
=
this
.
getRangeData
(
tempTimeArray
);
minTime
=
moment
().
year
((
tempTimeArray
[
0
].
_i
.
split
(
"-"
))[
0
]).
week
((
tempTimeArray
[
0
].
_i
.
split
(
"-"
))[
1
]);
maxTime
=
moment
().
year
((
tempTimeArray
[
tempTimeArray
.
length
-
1
].
_i
.
split
(
"-"
))[
0
]).
week
((
tempTimeArray
[
tempTimeArray
.
length
-
1
].
_i
.
split
(
"-"
))[
1
]);
}
let
timeFragmentArray
:
Array
<
any
>
=
[];
let
tempGrounpData
:
Map
<
string
,
any
>
=
new
Map
();
// 时间分段
//groupMode为"YEAR"
if
(
Object
.
is
(
groupMode
,
"YEAR"
)){
let
curTime
:
any
=
minTime
;
while
(
curTime
){
if
(
curTime
.
isSameOrBefore
(
maxTime
)){
let
tempcurTime
:
any
=
curTime
.
clone
();
timeFragmentArray
.
push
(
tempcurTime
.
year
().
toString
());
curTime
=
tempcurTime
.
clone
().
add
(
1
,
'years'
);
}
else
{
curTime
=
null
;
}
}
}
//groupMode为"QUARTER"
if
(
Object
.
is
(
groupMode
,
"QUARTER"
)){
let
curTime
:
any
=
minTime
;
while
(
curTime
){
if
(
curTime
.
isSameOrBefore
(
maxTime
)){
let
tempcurTime
:
any
=
curTime
.
clone
();
timeFragmentArray
.
push
(
tempcurTime
.
year
().
toString
()
+
"-"
+
tempcurTime
.
quarter
().
toString
());
curTime
=
tempcurTime
.
clone
().
add
(
1
,
'quarters'
);
}
else
{
curTime
=
null
;
}
}
}
//groupMode为"MONTH"
if
(
Object
.
is
(
groupMode
,
"MONTH"
)){
let
curTime
:
any
=
minTime
;
while
(
curTime
){
if
(
curTime
.
isSameOrBefore
(
maxTime
)){
let
tempcurTime
:
any
=
curTime
.
clone
();
timeFragmentArray
.
push
(
tempcurTime
.
year
().
toString
()
+
"-"
+
tempcurTime
.
month
().
toString
());
curTime
=
tempcurTime
.
clone
().
add
(
1
,
'months'
);
}
else
{
curTime
=
null
;
}
}
}
//groupMode为"YEARWEEK"
if
(
Object
.
is
(
groupMode
,
"YEARWEEK"
)){
let
curTime
:
any
=
minTime
;
while
(
curTime
){
if
(
curTime
.
isSameOrBefore
(
maxTime
)){
let
tempcurTime
:
any
=
curTime
.
clone
();
timeFragmentArray
.
push
(
tempcurTime
.
year
().
toString
()
+
"-"
+
tempcurTime
.
week
().
toString
());
curTime
=
tempcurTime
.
clone
().
add
(
1
,
'weeks'
);
}
else
{
curTime
=
null
;
}
}
}
//groupMode为"DAY"
if
(
Object
.
is
(
groupMode
,
"DAY"
)){
let
curTime
:
any
=
minTime
;
while
(
curTime
){
if
(
curTime
.
isSameOrBefore
(
maxTime
)){
let
tempcurTime
:
any
=
curTime
.
clone
();
timeFragmentArray
.
push
(
tempcurTime
.
format
(
'YYYY-MM-DD'
));
curTime
=
tempcurTime
.
clone
().
add
(
1
,
'days'
);
}
else
{
curTime
=
null
;
}
}
}
data
.
forEach
((
item
:
any
)
=>
{
let
tempKeyStr
:
string
=
item
[
groupField
.
name
];
let
tempGrounpItem
:
any
=
tempGrounpData
.
get
(
tempKeyStr
);
if
(
!
tempGrounpItem
){
tempGrounpData
.
set
(
tempKeyStr
,
item
);
}
})
timeFragmentArray
.
forEach
((
timeFragment
:
any
)
=>
{
if
(
!
tempGrounpData
.
get
(
timeFragment
)){
let
copyTemp
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
data
[
0
]));
let
curObj
:
any
=
{};
curObj
[
groupField
.
name
]
=
timeFragment
;
curObj
[
valueField
.
name
]
=
0
;
Object
.
assign
(
copyTemp
,
curObj
);
data
.
push
(
copyTemp
);
}
})
}
/**
* 补全代码表
*
* @param {Array<any>} data 传入数据
* @param {Array<any>} item 单个序列
* @param {Array<any>} allCodeList 所有的代码表
*
* @memberof Db_sysportlet2_chartBase
*/
public
completeCodeList
(
data
:
any
,
item
:
any
,
allCodeList
:
any
){
let
groupField
=
item
.
dataSetFields
.
find
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
item
.
categorField
;
});
if
(
!
groupField
.
codelist
){
return
;
}
let
valueField
=
item
.
dataSetFields
.
find
((
datasetField
:
any
)
=>
{
return
datasetField
.
name
===
item
.
valueField
;
});
let
curCodeList
:
Map
<
number
,
any
>
=
allCodeList
.
get
(
groupField
.
codelist
.
tag
);
// 对分类实现分组
let
tempGrounpData
:
Map
<
string
,
any
>
=
new
Map
();
data
.
forEach
((
item
:
any
)
=>
{
let
tempGrounpItem
:
any
=
tempGrounpData
.
get
(
item
[
groupField
.
name
+
'_srfvalue'
]);
if
(
!
tempGrounpItem
){
tempGrounpData
.
set
(
item
[
groupField
.
name
+
'_srfvalue'
],
item
);
}
})
if
(
curCodeList
.
size
!==
tempGrounpData
.
size
){
curCodeList
.
forEach
((
text
:
any
,
value
:
any
)
=>
{
if
(
!
tempGrounpData
.
get
(
value
)){
let
copyTemp
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
data
[
0
]));
let
curObj
:
any
=
{};
curObj
[
groupField
.
name
+
'_srfvalue'
]
=
value
;
curObj
[
groupField
.
name
]
=
text
;
curObj
[
valueField
.
name
]
=
0
;
Object
.
assign
(
copyTemp
,
curObj
);
data
.
push
(
copyTemp
);
}
})
}
}
/**
* 处理单个属性
*
* @param {*} input 输入值
* @param {*} field 属性值
* @param {*} allCodeList 所有代码表
* @param {*} result 结果值
*
* @memberof Db_sysportlet2_chartBase
*/
public
handleSingleDataSetField
(
input
:
any
,
field
:
any
,
allCodeList
:
any
,
result
:
any
,
groupField
:
any
){
let
tempFieldObj
:
any
=
{};
//存在代码表的情况(自动转化值)
if
(
field
.
codelist
){
//获取代码表
let
curCodeList
:
Map
<
number
,
any
>
=
allCodeList
.
get
(
field
.
codelist
.
tag
);
tempFieldObj
[
field
.
name
]
=
curCodeList
.
get
(
input
[
field
.
name
]);
tempFieldObj
[
field
.
name
+
'_srfvalue'
]
=
input
[
field
.
name
];
}
else
{
// 不存在代码表的情况
if
(
groupField
&&
Object
.
is
(
groupField
.
name
,
field
.
name
)){
if
(
Object
.
is
(
groupField
.
groupMode
,
"YEAR"
)
){
tempFieldObj
[
field
.
name
]
=
moment
(
input
[
field
.
name
]).
year
().
toString
();
}
else
if
(
Object
.
is
(
groupField
.
groupMode
,
"QUARTER"
)
){
tempFieldObj
[
field
.
name
]
=
moment
(
input
[
field
.
name
]).
year
().
toString
()
+
"-"
+
moment
(
input
[
field
.
name
]).
quarters
().
toString
();
}
else
if
(
Object
.
is
(
groupField
.
groupMode
,
"MONTH"
)
){
tempFieldObj
[
field
.
name
]
=
moment
(
input
[
field
.
name
]).
year
().
toString
()
+
"-"
+
moment
(
input
[
field
.
name
]).
month
().
toString
();
}
else
if
(
Object
.
is
(
groupField
.
groupMode
,
"YEARWEEK"
)
){
tempFieldObj
[
field
.
name
]
=
moment
(
input
[
field
.
name
]).
year
().
toString
()
+
"-"
+
moment
(
input
[
field
.
name
]).
week
().
toString
();
}
else
if
(
Object
.
is
(
groupField
.
groupMode
,
"DAY"
)
){
tempFieldObj
[
field
.
name
]
=
moment
(
input
[
field
.
name
]).
format
(
"YYYY-MM-DD"
);
}
else
{
tempFieldObj
[
field
.
name
]
=
input
[
field
.
name
];
}
}
else
{
tempFieldObj
[
field
.
name
]
=
input
[
field
.
name
]
}
}
Object
.
assign
(
result
,
tempFieldObj
);
}
/**
* 获取图表所需代码表
*
* @memberof Db_sysportlet2_chartBase
*/
public
getChartAllCodeList
():
Promise
<
any
>
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
let
codeListMap
:
Map
<
string
,
any
>
=
new
Map
();
if
(
Object
.
values
(
this
.
seriesModel
).
length
>
0
){
let
tempFlag
:
boolean
=
true
;
Object
.
values
(
this
.
seriesModel
).
forEach
((
singleSeries
:
any
)
=>
{
if
(
singleSeries
.
dataSetFields
&&
singleSeries
.
dataSetFields
.
length
>
0
){
let
promiseArray
:
Array
<
any
>
=
[];
let
promiseKeyArray
:
Array
<
any
>
=
[];
singleSeries
.
dataSetFields
.
forEach
((
singleDataSetField
:
any
,
index
:
any
)
=>
{
if
(
singleDataSetField
.
codelist
){
tempFlag
=
false
;
if
(
!
codeListMap
.
get
(
singleDataSetField
.
codelist
.
tag
)){
promiseArray
.
push
(
this
.
getCodeList
(
singleDataSetField
.
codelist
));
promiseKeyArray
.
push
(
singleDataSetField
.
codelist
.
tag
);
Promise
.
all
(
promiseArray
).
then
((
result
:
any
)
=>
{
if
(
result
&&
result
.
length
>
0
){
result
.
forEach
((
codeList
:
any
)
=>
{
let
tempCodeListMap
:
Map
<
number
,
any
>
=
new
Map
();
if
(
codeList
.
length
>
0
){
codeList
.
forEach
((
codeListItem
:
any
)
=>
{
tempCodeListMap
.
set
(
codeListItem
.
value
,
codeListItem
.
text
);
})
}
codeListMap
.
set
(
singleDataSetField
.
codelist
.
tag
,
tempCodeListMap
);
})
resolve
(
codeListMap
);
}
})
}
}
})
}
})
if
(
tempFlag
){
resolve
(
codeListMap
);}
}
else
{
resolve
(
codeListMap
);
}
})
}
/**
* 获取代码表
*
* @returns {Promise<any>}
* @memberof Db_sysportlet2_chartBase
*/
public
getCodeList
(
codeListObject
:
any
):
Promise
<
any
>
{
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
if
(
codeListObject
.
tag
&&
Object
.
is
(
codeListObject
.
type
,
"STATIC"
)){
const
codelist
=
this
.
$store
.
getters
.
getCodeList
(
codeListObject
.
tag
);
if
(
codelist
)
{
resolve
([...
JSON
.
parse
(
JSON
.
stringify
(
codelist
.
items
))]);
}
else
{
console
.
log
(
`----
${
codeListObject
.
tag
}
----代码表不存在`
);
}
}
else
if
(
codeListObject
.
tag
&&
Object
.
is
(
codeListObject
.
type
,
"DYNAMIC"
)){
this
.
codeListService
.
getItems
(
codeListObject
.
tag
).
then
((
res
:
any
)
=>
{
resolve
(
res
);
}).
catch
((
error
:
any
)
=>
{
console
.
log
(
`----
${
codeListObject
.
tag
}
----代码表不存在`
);
});
}
})
}
}
</
script
>
<
style
lang=
'less'
>
@import './view-chart-chart.less';
</
style
>
\ No newline at end of file
app_Web/src/widgets/ibizappview/view-chart-chart/view-chart-chart-model.ts
0 → 100644
浏览文件 @
c18b1a00
/**
* ViewChart 部件模型
*
* @export
* @class ViewChartModel
*/
export
default
class
ViewChartModel
{
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof ViewChartDb_sysportlet2_chartMode
*/
public
getDataItems
():
any
[]
{
return
[
{
name
:
'size'
,
prop
:
'size'
},
{
name
:
'query'
,
prop
:
'query'
},
{
name
:
'page'
,
prop
:
'page'
},
{
name
:
'sort'
,
prop
:
'sort'
}
]
}
}
\ No newline at end of file
app_Web/src/widgets/ibizappview/view-chart-chart/view-chart-chart-service.ts
0 → 100644
浏览文件 @
c18b1a00
import
{
Http
,
Util
,
Errorlog
}
from
'@/utils'
;
import
ControlService
from
'@/widgets/control-service'
;
import
IBIZAPPVIEWService
from
'@/service/ibizappview/ibizappview-service'
;
import
ViewChartModel
from
'./view-chart-chart-model'
;
/**
* ViewChart 部件服务对象
*
* @export
* @class ViewChartService
*/
export
default
class
ViewChartService
extends
ControlService
{
/**
* 应用视图服务对象
*
* @type {IBIZAPPVIEWService}
* @memberof ViewChartService
*/
public
appEntityService
:
IBIZAPPVIEWService
=
new
IBIZAPPVIEWService
({
$store
:
this
.
getStore
()
});
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof ViewChartService
*/
public
setTempMode
(){
this
.
isTempMode
=
false
;
}
/**
* Creates an instance of ViewChartService.
*
* @param {*} [opts={}]
* @memberof ViewChartService
*/
constructor
(
opts
:
any
=
{})
{
super
(
opts
);
this
.
model
=
new
ViewChartModel
();
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof ViewChartService
*/
@
Errorlog
public
search
(
action
:
string
,
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
const
{
data
:
Data
,
context
:
Context
}
=
this
.
handleRequestData
(
action
,
context
,
data
,
true
);
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
const
_appEntityService
:
any
=
this
.
appEntityService
;
let
result
:
Promise
<
any
>
;
if
(
_appEntityService
[
action
]
&&
_appEntityService
[
action
]
instanceof
Function
)
{
result
=
_appEntityService
[
action
](
Context
,
Data
,
isloading
);
}
else
{
result
=
_appEntityService
.
FetchDefault
(
Context
,
Data
,
isloading
);
}
result
.
then
((
response
)
=>
{
resolve
(
response
);
}).
catch
(
response
=>
{
reject
(
response
);
});
});
}
}
\ No newline at end of file
app_Web/src/widgets/ibizappview/view-chart-chart/view-chart-chart.less
0 → 100644
浏览文件 @
c18b1a00
// this is less
.app-data-chart {
width: 100%;
height: 100%;
.chart-no-data{
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
i{
margin-right: 5px;
}
}
}
\ No newline at end of file
app_Web/src/widgets/ibizappview/view-chart-chart/view-chart-chart.vue
0 → 100644
浏览文件 @
c18b1a00
<
script
lang=
'tsx'
>
import
{
Component
}
from
'vue-property-decorator'
;
import
ViewChartBase
from
'./view-chart-chart-base.vue'
;
@
Component
({
components
:
{
}
})
export
default
class
ViewChart
extends
ViewChartBase
{
}
</
script
>
\ No newline at end of file
app_Web/src/widgets/ibizappview/view-chart-portlet/view-chart-portlet-base.vue
0 → 100644
浏览文件 @
c18b1a00
<
template
>
<div
class=
'portlet view-chart '
:style=
"
{'height': isAdaptiveSize ? 'calc(100% - 16px)' : getHeight,}">
<p
class=
'portlet-title'
>
<span>
视图图表
</span>
</p>
<el-divider
class=
"divider"
></el-divider>
<div
class=
"portlet-with-title"
>
<!-- 测试 -->
<view
_db_sysportlet2_chart
:viewState=
"viewState"
:viewparams=
"viewparams"
:context=
"context"
fetchAction=
"FetchDefault"
:showBusyIndicator=
"true"
name=
"db_sysportlet2_chart"
ref=
'db_sysportlet2_chart'
@
closeview=
"closeView($event)"
>
</view
_db_sysportlet2_chart
>
</div>
</div>
</
template
>
<
script
lang=
'tsx'
>
import
{
Vue
,
Component
,
Prop
,
Provide
,
Emit
,
Watch
,
Model
,
Inject
}
from
'vue-property-decorator'
;
import
{
CreateElement
}
from
'vue'
;
import
{
Subject
,
Subscription
}
from
'rxjs'
;
import
{
ControlInterface
}
from
'@/interface/control'
;
import
{
UIActionTool
,
Util
,
ViewTool
}
from
'@/utils'
;
import
NavDataService
from
'@/service/app/navdata-service'
;
import
IBIZAPPVIEWService
from
'@/service/ibizappview/ibizappview-service'
;
import
ViewChartService
from
'./view-chart-portlet-service'
;
import
IBIZAPPVIEWUIService
from
'@/uiservice/ibizappview/ibizappview-ui-service'
;
import
UIService
from
'@/uiservice/ui-service'
;
import
{
Environment
}
from
'@/environments/environment'
;
@
Component
({
components
:
{
}
})
export
default
class
IBIZAPPVIEWViewChartBase
extends
Vue
implements
ControlInterface
{
/**
* 名称
*
* @type {string}
* @memberof ViewChartBase
*/
@
Prop
()
public
name
?:
string
;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof ViewChartBase
*/
@
Prop
()
public
viewState
!
:
Subject
<
ViewState
>
;
/**
* 应用上下文
*
* @type {*}
* @memberof ViewChartBase
*/
@
Prop
()
public
context
!
:
any
;
/**
* 视图参数
*
* @type {*}
* @memberof ViewChartBase
*/
@
Prop
()
public
viewparams
!
:
any
;
/**
* 视图状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof ViewChartBase
*/
public
viewStateEvent
:
Subscription
|
undefined
;
/**
* 获取部件类型
*
* @returns {string}
* @memberof ViewChartBase
*/
public
getControlType
():
string
{
return
'PORTLET'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof ViewChartBase
*/
public
counterServiceArray
:
Array
<
any
>
=
[];
/**
* 建构部件服务对象
*
* @type {ViewChartService}
* @memberof ViewChartBase
*/
public
service
:
ViewChartService
=
new
ViewChartService
({
$store
:
this
.
$store
});
/**
* 实体服务对象
*
* @type {IBIZAPPVIEWService}
* @memberof ViewChartBase
*/
public
appEntityService
:
IBIZAPPVIEWService
=
new
IBIZAPPVIEWService
({
$store
:
this
.
$store
});
/**
* 界面UI服务对象
*
* @type {IBIZAPPVIEWUIService}
* @memberof ViewChartBase
*/
public
appUIService
:
IBIZAPPVIEWUIService
=
new
IBIZAPPVIEWUIService
(
this
.
$store
);
/**
* 关闭视图
*
* @param {any} args
* @memberof ViewChartBase
*/
public
closeView
(
args
:
any
):
void
{
let
_this
:
any
=
this
;
_this
.
$emit
(
'closeview'
,
[
args
]);
}
/**
* 计数器刷新
*
* @memberof ViewChartBase
*/
public
counterRefresh
(){
const
_this
:
any
=
this
;
if
(
_this
.
counterServiceArray
&&
_this
.
counterServiceArray
.
length
>
0
){
_this
.
counterServiceArray
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
refreshData
&&
item
.
refreshData
instanceof
Function
){
item
.
refreshData
();
}
})
}
}
/**
* 长度
*
* @type {number}
* @memberof ViewChartBase
*/
@
Prop
()
public
height
?:
number
;
/**
* 宽度
*
* @type {number}
* @memberof ViewChartBase
*/
@
Prop
()
public
width
?:
number
;
/**
* 门户部件类型
*
* @type {number}
* @memberof ViewChartBase
*/
public
portletType
:
string
=
'chart'
;
/**
* 视图默认使用
*
* @type {string}
* @memberof ViewChartBase
*/
@
Inject
({
from
:
'navModel'
,
default
:
'tab'
})
public
navModel
!
:
string
;
/**
* 界面行为模型数据
*
* @memberof ViewChartBase
*/
public
uiactionModel
:
any
=
{
}
/**
* 是否自适应大小
*
* @returns {boolean}
* @memberof ViewChartBase
*/
@
Prop
({
default
:
false
})
public
isAdaptiveSize
!
:
boolean
;
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof ViewChartBase
*/
public
getDatas
():
any
[]
{
return
[];
}
/**
* 获取单项树
*
* @returns {*}
* @memberof ViewChartBase
*/
public
getData
():
any
{
return
{};
}
/**
* 获取高度
*
* @returns {any[]}
* @memberof ViewChartBase
*/
get
getHeight
(){
if
(
!
this
.
$util
.
isEmpty
(
this
.
height
)
&&
!
this
.
$util
.
isNumberNaN
(
this
.
height
)){
if
(
this
.
height
==
0
){
return
'auto'
;
}
else
{
return
this
.
height
+
'px'
;
}
}
else
{
return
'400px'
;
}
}
/**
* 刷新
*
* @memberof ViewChartBase
*/
public
refresh
(
args
?:
any
)
{
this
.
viewState
.
next
({
tag
:
'db_sysportlet2_chart'
,
action
:
'refresh'
,
data
:
args
});
}
/**
* vue 生命周期
*
* @memberof ViewChartBase
*/
public
created
()
{
this
.
afterCreated
();
}
/**
* 执行created后的逻辑
*
* @memberof ViewChartBase
*/
public
afterCreated
(){
if
(
this
.
viewState
)
{
this
.
viewStateEvent
=
this
.
viewState
.
subscribe
(({
tag
,
action
,
data
})
=>
{
if
(
Object
.
is
(
tag
,
"all-portlet"
)
&&
Object
.
is
(
action
,
'loadmodel'
)){
this
.
calcUIActionAuthState
(
data
);
}
if
(
!
Object
.
is
(
tag
,
this
.
name
))
{
return
;
}
const
refs
:
any
=
this
.
$refs
;
Object
.
keys
(
refs
).
forEach
((
_name
:
string
)
=>
{
this
.
viewState
.
next
({
tag
:
_name
,
action
:
action
,
data
:
data
});
});
});
}
}
/**
* vue 生命周期
*
* @memberof ViewChartBase
*/
public
destroyed
()
{
this
.
afterDestroy
();
}
/**
* 执行destroyed后的逻辑
*
* @memberof ViewChartBase
*/
public
afterDestroy
()
{
if
(
this
.
viewStateEvent
)
{
this
.
viewStateEvent
.
unsubscribe
();
}
}
/**
* 计算界面行为权限
*
* @memberof ViewChartBase
*/
public
calcUIActionAuthState
(
data
:
any
=
{})
{
// 如果是操作栏,不计算权限
if
(
this
.
portletType
&&
Object
.
is
(
'actionbar'
,
this
.
portletType
))
{
return
;
}
let
_this
:
any
=
this
;
let
uiservice
:
any
=
_this
.
appUIService
?
_this
.
appUIService
:
new
UIService
(
_this
.
$store
);
if
(
_this
.
uiactionModel
){
ViewTool
.
calcActionItemAuthState
(
data
,
_this
.
uiactionModel
,
uiservice
);
}
}
}
</
script
>
<
style
lang=
'less'
>
@import './view-chart-portlet.less';
</
style
>
app_Web/src/widgets/ibizappview/view-chart-portlet/view-chart-portlet-model.ts
0 → 100644
浏览文件 @
c18b1a00
/**
* ViewChart 部件模型
*
* @export
* @class ViewChartModel
*/
export
default
class
ViewChartModel
{
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof ViewChartModel
*/
public
getDataItems
():
any
[]
{
return
[
{
name
:
'createman'
,
},
{
name
:
'createdate'
,
},
{
name
:
'ibizappviewname'
,
},
{
name
:
'ibizappview'
,
prop
:
'ibizappviewid'
,
},
{
name
:
'updateman'
,
},
{
name
:
'updatedate'
,
},
{
name
:
'ibizappviewtype'
,
},
{
name
:
'documentaddress'
,
},
{
name
:
'instanceaddress'
,
},
{
name
:
'viewdescription'
,
},
{
name
:
'amount'
,
},
]
}
}
app_Web/src/widgets/ibizappview/view-chart-portlet/view-chart-portlet-service.ts
0 → 100644
浏览文件 @
c18b1a00
import
{
Http
}
from
'@/utils'
;
import
ControlService
from
'@/widgets/control-service'
;
/**
* ViewChart 部件服务对象
*
* @export
* @class ViewChartService
*/
export
default
class
ViewChartService
extends
ControlService
{
}
app_Web/src/widgets/ibizappview/view-chart-portlet/view-chart-portlet.less
0 → 100644
浏览文件 @
c18b1a00
// this is less
.portlet{
height: 100%;
width: 100%;
> .portlet-title{
padding: 14px 16px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
height: 52px;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
justify-content: space-between;
width:100%;
line-height: 22px;
font-size: 16px;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #304265;
font-weight: 600;
i{
margin-right: 5px;
}
>.portlet-action{
margin-left: 12px;
font-size: 14px;
>a{
padding: 6px;
}
}
}
> .divider {
margin: 0px 0px 11px 0px;
}
> .portlet-with-title{
width:100%;
height:calc(100% - 58px);
overflow:auto;
padding:0px 12px;
}
> .portlet-without-title{
width:100%;
height:100%;
overflow:auto;
padding:0px 12px;
}
.app-charts{
height: 100%!important;
}
.toolbar-container {
button{
margin: 6px 0px 4px 16px;
}
.ivu-badge{
.ivu-badge-count{
top: 0;
}
}
}
}
app_Web/src/widgets/ibizappview/view-chart-portlet/view-chart-portlet.vue
0 → 100644
浏览文件 @
c18b1a00
<
script
lang=
'tsx'
>
import
{
Component
}
from
'vue-property-decorator'
;
import
IBIZAPPVIEWViewChartBase
from
'./view-chart-portlet-base.vue'
;
import
view_db_sysportlet2_chart
from
'@widgets/ibizappview/view-chart-chart/view-chart-chart.vue'
;
@
Component
({
components
:
{
view_db_sysportlet2_chart
,
}
})
export
default
class
IBIZAPPVIEWViewChart
extends
IBIZAPPVIEWViewChartBase
{
}
</
script
>
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录