提交 57c914ae 编写于 作者: xuhui961310148's avatar xuhui961310148

查看报表功能相关内容

上级 c89394ab
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"@riophae/vue-treeselect": "0.0.38",
"ag-grid-community": "^20.2.0",
"ag-grid-enterprise": "^20.2.0",
"ag-grid-vue": "^20.2.0",
"@fullcalendar/core": "^4.4.0", "@fullcalendar/core": "^4.4.0",
"@fullcalendar/daygrid": "^4.4.0", "@fullcalendar/daygrid": "^4.4.0",
"@fullcalendar/interaction": "^4.4.0", "@fullcalendar/interaction": "^4.4.0",
......
@import "../../../../node_modules/ag-grid-community/dist/styles/ag-grid.css";
@import "../../../../node_modules/ag-grid-community/dist/styles/ag-theme-balham.css";
@import "../../../../node_modules/ag-grid-community/dist/styles/ag-theme-dark.css";
@import "../../../../node_modules/ag-grid-community/dist/styles/ag-theme-fresh.css";
@import "../../../../node_modules/ag-grid-community/dist/styles/ag-theme-bootstrap.css";
@import "../../../../node_modules/ag-grid-community/dist/styles/ag-theme-blue.css";
@import "../../../../node_modules/ag-grid-community/dist/styles/ag-theme-balham-dark.css";
@import "../../../../node_modules/ag-grid-community/dist/styles/ag-theme-material.css";
.grid {
height: 100%;
overflow: auto;
.ag-theme-material {
height: calc(100% - 50px);
}
}
.ag-theme-material .ag-cell{
line-height: 40px;
}
.selectAndData {
display: flex;
padding: 10px 0;
> .vue-treeselect {
width: 14%;
> .vue-treeselect__control {
height: 40px;
}
}
> .el-select {
width: 9%;
}
}
label:hover{
white-space:normal;
}
.el-range-separator{
width: 30px !important;
}
.ivu-card-body{
overflow-y: hidden !important;
}
.dareport-bbzscustom-view{ .dareport-bbzscustom-view{
position: relative; position: relative;
} }
......
<template>
<div class="view-container decustomview dareport-bbzscustom-view">
<app-studioaction :viewTitle="$t(model.srfCaption)" viewName="dareportbbzscustomview"></app-studioaction>
<card class="view-card view-no-toolbar" :disHover="true" :padding="0" :bordered="false" >
<h6 style="text-align: center; padding: 5px">
{{ headname }}
</h6>
<div class="content-container">
<div class="selectAndData">
<Treeselect ref="orgid" v-model="treeValue" :options="treeOptions" placeholder="请选择单位或区域" ></Treeselect>
<el-select ref="cxfs" v-model="computedSelectVal" placeholder="请选择查询方式" >
<template v-if='options && options.length>0'>
<template v-for='(item) in options'>
<el-option :key="item.value" :value="item.value" :label="item.label" ></el-option>
</template>
</template>
</el-select>
<el-date-picker ref="time" v-model="dataValue" :type='type' range-separator='至' :start-placeholder='startPlaceholder' :end-placeholder='endPlaceholder'></el-date-picker>
<div class="toolbar" style="margin-left: auto">
<el-button @click="getReportData">搜索</el-button>
</div>
</div>
<div class="grid">
<ag-grid-vue
style="width: 100%; height: 95%"
class="ag-theme-balham"
:columnDefs="columnDefs"
:enableSorting="true"
:enableFilter="false"
:enableColResize="true"
:singleClickEdit="true"
:pagination="false"
rowSelection="multiple"
:localeText="localeText"
@onGridReady="onGridReady"
@onselectionChanged="selectionChanged"
@onrowDoubleClicked="rowDoubleClicked"
:rowData="items"
></ag-grid-vue>
</div>
</div>
</card>
</div>
</template>
<script lang='tsx'> <script lang='tsx'>
import { Component } from 'vue-property-decorator'; import { Component, Prop, Watch, Model } from 'vue-property-decorator';
import DAReportBBZSCustomViewBase from './dareport-bbzscustom-view-base.vue'; import DAReportBBZSCustomViewBase from './dareport-bbzscustom-view-base.vue';
import 'ag-grid-enterprise';
import Treeselect from '@riophae/vue-treeselect';
import { AgGridVue } from "ag-grid-vue";
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
@Component({ @Component({
components: { components: {
'ag-grid-vue':AgGridVue,
'Treeselect':Treeselect
}, },
beforeRouteEnter: (to: any, from: any, next: any) => { beforeRouteEnter: (to: any, from: any, next: any) => {
next((vm: any) => { next((vm: any) => {
...@@ -16,5 +67,345 @@ import DAReportBBZSCustomViewBase from './dareport-bbzscustom-view-base.vue'; ...@@ -16,5 +67,345 @@ import DAReportBBZSCustomViewBase from './dareport-bbzscustom-view-base.vue';
}) })
export default class DAReportBBZSCustomView extends DAReportBBZSCustomViewBase { export default class DAReportBBZSCustomView extends DAReportBBZSCustomViewBase {
/**
* 执行mounted后的逻辑
*
* @memberof DAReportBBZSCustomViewBase
*/
public afterMounted(){
const _this: any = this;
_this.engineInit();
if (_this.loadModel && _this.loadModel instanceof Function) {
_this.loadModel();
}
_this.getXQCodelist();
_this.getReportData();
}
/**
* 表头
*/
public columnDefs: any[] = [];
public headname: any = '';
/**
* select绑定值
*/
@Prop() public selectValue: any;
/**
* 计算绑定值
*/
set computedSelectVal(val: any) {
this.selectValue = val;
Object.assign(this.context,{dictcatalog:'CL_DST_REGION'});
this.viewparams
}
get computedSelectVal() {
return this.selectValue;
}
/**
* 选项值
*/
public options: any = [
{
value: 'year',
label: '按年查询',
},
{
value: 'month',
label: '按月查询',
},
{
value: 'day',
label: '按日查询',
}
];
/**
* data绑定值
*/
@Model('dataChange') dataValue: any;
/**
* 计算绑定值
*/
set computedDataVal(val: any) {
this.$emit('dataChange', val);
}
get computedDataVal() {
return this.dataValue;
}
/**
* 选择类型
*/
public type: any;
public startPlaceholder: any;
public endPlaceholder: any;
/**
* 监听selectValue
* @param newVal
* @param oldVal
*/
@Watch('selectValue')
onselectionchange(newVal: any, oldVal: any) {
if (newVal === 'year') {
this.type = 'year';
}
if (newVal === 'month') {
this.type = 'monthrange';
this.startPlaceholder = '开始月份';
this.endPlaceholder = '结束月份';
}
if (newVal === 'day') {
this.type = 'daterange';
this.startPlaceholder = '开始日期';
this.endPlaceholder = '结束日期';
}
}
/**
* 树项
*/
public treeOptions: any = [];
/**
* 树值
* @param $event
*/
@Model('treeChange') treeValue: any;
/**
* 计算绑定值
*/
set computedtreeVal(val: any) {
this.$emit('treeChange', val);
}
get computedtreeVal() {
return this.treeValue;
}
/**
* 获取辖区代码表
*/
public getXQCodelist(){
// 请求地址
const post: Promise<any> = this.$http.post("/ibizutil/getCodelist", { cid: "CL_DST_REGION"}, true);
post.then((response: any) => {
if (response && response.status == 200) {
this.treeOptions = response.data;
}
}).catch((response: any) => {
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
return;
}
const { data: _data } = response;
this.$Notice.error({ title: _data.title, desc: _data.message });
});
}
/**
* 请求数据
*/
public getReportData() {
const _this:any = this;
// 置空表格数据
this.columnDefs = [];
// 机构
const orgid: any = this.$refs.orgid;
let domin = orgid.value;
// 类型
const cxfs: any = this.$refs.cxfs;
let fs = cxfs.value;
// 时间
const time: any = this.$refs.time;
let timeAll = time.displayValue;
let startTime: any;
let endTime: any;
if (fs === "year") {
startTime = timeAll + '-01-01';
endTime = timeAll + '-12-31';
}
if (fs === "month") {
startTime = timeAll[0] + '-01';
endTime = timeAll[1] + '-31';
}
if (fs === "day") {
startTime = timeAll[0];
endTime = timeAll[1];
}
// 请求地址
debugger
const post: Promise<any> = this.$http.post('/ibizutil/reportdatas', { id: JSON.parse(this.viewdata).srfparentkey, domin: domin, startTime: startTime, endTime: endTime }, true);
post.then((response: any) => {
if (response && response.status == 200) {
this.headname = response.data.reportname;
let reportname = {
headerName: response.data.reportname,
field: '',//显示数据的字段名
filter: '',//过滤的类型
width: '',
cellStyle: { color: 'red' },//单元格样式
children: response.data.resportdata.headData,//子项
};
this.items = response.data.resportdata.erportdata[0];
this.columnDefs.push(reportname);
}
}).catch((response: any) => {
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
return;
}
const { data: _data } = response;
this.$Notice.error({ title: _data.title, desc: _data.message });
});
}
/**
* 表格对象
*
* @memberof Main
*/
public gridApi: any;
/**
* 列对象
*
*
* @memberof Main
*/
public columnApi: any;
/**
* 数据
*
* @type {any[]}
* @memberof Main
*/
public items: any = new Array();
/**
* 表格数据
*/
public localeText: any = {
page: "页",
more: "更多",
to: "到",
of: "of",
next: "下一页",
last: "上一页",
first: "首页",
previous: "上一页",
loadingOoo: "加载中...",
selectAll: "查询全部",
searchOoo: "查询...",
blanks: "空白",
filterOoo: "过滤...",
applyFilter: "daApplyFilter...",
equals: "相等",
notEqual: "不相等",
lessThan: "小于",
greaterThan: "大于",
lessThanOrEqual: "小于等于",
greaterThanOrEqual: "大于等于",
inRange: "范围",
contains: "包含",
notContains: "不包含",
startsWith: "开始于",
endsWith: "结束于",
group: "组",
columns: "列",
filters: "筛选",
rowGroupColumns: "laPivot Cols",
rowGroupColumnsEmptyMessage: "la drag cols to group",
valueColumns: "laValue Cols",
pivotMode: "laPivot-Mode",
groups: "laGroups",
values: "值",
pivots: "laPivots",
valueColumnsEmptyMessage: "la drag cols to aggregate",
pivotColumnsEmptyMessage: "la drag here to pivot",
toolPanelButton: "la tool panel",
noRowsToShow: "数据为空",
pinColumn: "laPin Column",
valueAggregation: "laValue Agg",
autosizeThiscolumn: "laAutosize Diz",
autosizeAllColumns: "laAutsoie em All",
groupBy: "排序",
ungroupBy: "不排序",
resetColumns: "重置列",
expandAll: "展开全部",
collapseAll: "关闭",
toolPanel: "工具面板",
export: "导出",
csvExport: "导出为CSV格式文件",
excelExport: "导出到Excel",
pinLeft: "laPin &lt;&lt;",
pinRight: "laPin &gt;&gt;",
noPin: "laDontPin &lt;&gt;",
sum: "总数",
min: "最小值",
max: "最大值",
none: "无",
count: "总",
average: "平均值",
copy: "复制",
copyWithHeaders: "携带表头复制",
ctrlC: "ctrl + C",
paste: "粘贴",
ctrlV: "ctrl + V"
};
/**
* 表格加载完成
*
* @returns void
* @memberof Main
*/
public onGridReady($event: any): void {
console.log($event);
this.gridApi = $event.api;
this.columnApi = $event.columnApi;
this.gridApi.sizeColumnsToFit();
}
/**
* 行选中变化
*
* @returns void
* @memberof Main
*/
public selectionChanged($event: any): void {
console.log(this.getSelections());
}
/**
* 获取选中数据
*
* @returns {any[]}
* @memberof Main
*/
public getSelections(): any[] {
return this.gridApi.getSelectedRows();
}
/**
* 行双击
*
* @returns void
* @memberof Main
*/
public rowDoubleClicked($event: any): void {
console.log($event.data);
}
} }
</script> </script>
\ No newline at end of file
...@@ -8,6 +8,8 @@ import AppFormJsonFieldSet from './components/app-form-json/app-form-json-field ...@@ -8,6 +8,8 @@ import AppFormJsonFieldSet from './components/app-form-json/app-form-json-field
import AppFormJsonDim from './components/app-form-json/app-form-json-dim.vue' import AppFormJsonDim from './components/app-form-json/app-form-json-dim.vue'
import AppFormJsonMetric from './components/app-form-json/app-form-json-metric.vue' import AppFormJsonMetric from './components/app-form-json/app-form-json-metric.vue'
import AppTreeselectRefreshview from './components/app-treeselect-refreshview/app-treeselect-refreshview.vue' import AppTreeselectRefreshview from './components/app-treeselect-refreshview/app-treeselect-refreshview.vue'
import {LicenseManager} from "ag-grid-enterprise";
LicenseManager.setLicenseKey("Shanghai_iBizSys_Information_Technology_Co_Ltd__MultiApp_1Devs14_January_2020__MTU3ODk2MDAwMDAwMA==f9f9222e95025fd3f9069f3db4bdd40d");
import 'jquery/dist/jquery.min.js' import 'jquery/dist/jquery.min.js'
import $ from 'jquery' import $ from 'jquery'
window["$"] = $ window["$"] = $
......
...@@ -892,6 +892,54 @@ public class DACoreService { ...@@ -892,6 +892,54 @@ public class DACoreService {
return new Timestamp(c.getTime().getTime()); return new Timestamp(c.getTime().getTime());
} }
/**
* 时间转换
* @param strTimp
* @return
*/
public static Timestamp getTimestamp(String strTimp) {
Timestamp timestamp = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormatTwo = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat simpleDateFormatCST = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
SimpleDateFormat simpleDateFormatGMT = new SimpleDateFormat("EEE MMM ddHH:mm:ss 'GMT' yyyy",Locale.US);
SimpleDateFormat simpleDateFormatUTC = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
try {
if(!StringUtils.isEmpty(strTimp) && !("null".equals(strTimp))) {
Date date = null;
if (strTimp.indexOf("CST") >= 0) {
date = simpleDateFormatCST.parse(strTimp);
timestamp = new Timestamp(date.getTime());
return timestamp;
}
if (strTimp.indexOf("GMT") >= 0) {
date = simpleDateFormatGMT.parse(strTimp);
timestamp = new Timestamp(date.getTime());
return timestamp;
}
if (strTimp.indexOf("UT") >= 0) {
date = simpleDateFormatUTC.parse(strTimp);
timestamp = new Timestamp(date.getTime());
return timestamp;
}
if (strTimp.length() == 19) {
date = simpleDateFormatTwo.parse(strTimp);
timestamp = new Timestamp(date.getTime());
return timestamp;
}
if(StringUtils.countOccurrencesOf("now", strTimp) != 0) {//strTimp等于now表示获取当前时间
date = new Date();
}else {
date = simpleDateFormat.parse(strTimp);
}
timestamp = new Timestamp(date.getTime());
}
} catch (Exception e) {
e.printStackTrace();
}
return timestamp;
}
public Timestamp getLastYear(Timestamp time) public Timestamp getLastYear(Timestamp time)
{ {
Date date=new Date(time.getTime()); Date date=new Date(time.getTime());
......
package cn.ibizlab.api.rest.extensions;
import cn.ibizlab.core.analysis.domain.DAReport;
import cn.ibizlab.core.analysis.service.impl.DAReportServiceImpl;
import cn.ibizlab.core.dict.domain.DictOption;
import cn.ibizlab.core.dict.service.impl.DictOptionServiceImpl;
import cn.ibizlab.core.extensions.service.DACoreService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.sql.Timestamp;
import java.util.List;
@Slf4j
@Api(tags = {"接口" })
@RestController("api-dagridcore")
@RequestMapping("")
public class DAGridCoreResource {
@Autowired
private DACoreService daCoreService;
@Autowired
@Lazy
private DAReportServiceImpl daReportService;
@Autowired
@Lazy
private DictOptionServiceImpl dictOptionService;
@RequestMapping(method = RequestMethod.POST, value = "/ibizutil/reportdatas")
public ResponseEntity<JSONObject> getReportdatas(@RequestBody JSONObject data) {
JSONObject responseJson = new JSONObject();
String id = data.getString("id");
String strLoadDimval = StringUtils.isEmpty(data.getString("domin")) ? "%" : data.getString("domin");
Timestamp strLoadStartTime = StringUtils.isEmpty(data.getString("startTime")) ? daCoreService.getDefaultStartTimestamp() :daCoreService.getTimestamp( data.getString("startTime"));
Timestamp strLoadEndTime = StringUtils.isEmpty(data.getString("endTime")) ? daCoreService.getDefaultEndTimestamp() : daCoreService.getTimestamp(data.getString("endTime"));
//获取表头及表单名称
DAReport daReport = daReportService.getById(id);
Object vmcfg = JSON.parse(daReport.getConfig());
String reportname = daReport.getReportName();
String strDict = "CL_DST_REGION";
if (daReport != null && !StringUtils.isEmpty(daReport.getDict())) {
strDict = daReport.getDict();
}
//获取表格数据
JSONObject jsonObject = daCoreService.getERPortData(daReport, strLoadDimval, strDict, strLoadStartTime, strLoadEndTime, "default");
responseJson.put("vmcfg",vmcfg);
responseJson.put("reportname",reportname);
responseJson.put("resportdata",jsonObject);
responseJson.put("dataDict", daReport.getDict());
return ResponseEntity.ok().body(responseJson);
}
@RequestMapping(method = RequestMethod.POST, value = "/ibizutil/getCodelist")
@Cacheable( value="getCodelist",key = "'getCodelist:'+#p0.getString(\"cid\")")
public ResponseEntity<JSONArray> getCodelist(@RequestBody JSONObject data) {
JSONArray result = new JSONArray();
String cid = data.getString("cid");
if (StringUtils.isEmpty(cid)){
log.error("未指定字典项过滤条件");
return ResponseEntity.ok().body(result);
}
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("cid",cid);
queryWrapper.orderByAsc("val");
List<DictOption> list = dictOptionService.list(queryWrapper);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = null;
for (DictOption entity: list) {
jsonObject = new JSONObject();
jsonObject.put("id",entity.getValue());
jsonObject.put("value",entity.getValue());
jsonObject.put("text",entity.getLabel());
jsonObject.put("label",entity.getLabel());
jsonObject.put("parentValue",entity.getParent());
jsonObject.put("disabled",entity.getDisabled());
jsonArray.add(jsonObject);
}
result = getTrees(jsonArray,"");
return ResponseEntity.ok().body(result);
}
/**
* 递归创建树结构数据
* @param jsonArray
* @param parentValue
* @return
*/
public JSONArray getTrees(JSONArray jsonArray, Object parentValue) {
JSONArray trees = new JSONArray();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String codeItemParentValue = jsonObject.getString("parentValue");
if (StringUtils.isEmpty(codeItemParentValue)) {
codeItemParentValue = "";
}
if (parentValue.equals(codeItemParentValue)) {
JSONArray childCodeItemArray = getTrees(jsonArray, jsonObject.getString("value"));
if (childCodeItemArray.size() > 0) {
jsonObject.put("children",childCodeItemArray);
}
trees.add(jsonObject);
}
}
return trees;
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册