|
@@ -49,17 +49,17 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
align="center"
|
|
|
- label="报表状态"
|
|
|
- prop="isAutoReport"
|
|
|
+ label="报表类型"
|
|
|
+ prop="reportTableType"
|
|
|
width="350">
|
|
|
<template slot-scope="scope">
|
|
|
<el-tag v-if="scope.row.userId != uid" type="success" style="margin-right: 5px;">被分享</el-tag>
|
|
|
<el-tag v-if="uid == scope.row.userId && scope.row.userGroupList && scope.row.userGroupList.length > 0"
|
|
|
type="warning" style="margin-right: 5px;">已分享
|
|
|
</el-tag>
|
|
|
- <el-tag v-if="scope.row.isAutoReport == 0" style="margin-right: 5px;">手动报表</el-tag>
|
|
|
- <el-tag v-if="scope.row.isAutoReport == 1" style="margin-right: 5px;">自动报表</el-tag>
|
|
|
- <el-tag v-if="scope.row.isAutoReport == 3" style="margin-right: 5px;">事件驱动报表</el-tag>
|
|
|
+ <el-tag v-if="scope.row.reportTableType == 0" style="margin-right: 5px;">手动报表</el-tag>
|
|
|
+ <el-tag v-if="scope.row.reportTableType == 1" style="margin-right: 5px;">自动报表</el-tag>
|
|
|
+ <el-tag v-if="scope.row.reportTableType == 2" style="margin-right: 5px;">事件驱动报表</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<!-- <el-table-column-->
|
|
@@ -169,7 +169,7 @@
|
|
|
<!-- 新增报表 -->
|
|
|
<el-dialog
|
|
|
title="新增报表"
|
|
|
- width="50%"
|
|
|
+ width="600px"
|
|
|
top="10vh"
|
|
|
center
|
|
|
v-dialog-drag
|
|
@@ -179,8 +179,18 @@
|
|
|
:close-on-click-modal="false"
|
|
|
:append-to-body="true">
|
|
|
<el-form ref="reportForm" :model="reportForm" :rules="reportRules" label-width="80px">
|
|
|
- <el-form-item label="报表模板" prop="reportTemplate">
|
|
|
- <el-select v-model="reportForm.reportTemplate" filterable placeholder="请选择报表模板" style="width: 100%;">
|
|
|
+ <el-form-item label='报表名称' prop="reportTableName">
|
|
|
+ <el-input placeholder="请输入报表名称" v-model="reportForm.reportTableName" maxlength="20"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="报表类型" prop="reportTableType">
|
|
|
+ <el-radio-group v-model="reportForm.reportTableType" @input="changeReportType">
|
|
|
+ <el-radio label="0">手动报表</el-radio>
|
|
|
+ <el-radio label="1">自动报表</el-radio>
|
|
|
+ <el-radio label="2">事件驱动报表</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="报表模板" prop="tableTemplateId">
|
|
|
+ <el-select v-model="reportForm.tableTemplateId" filterable placeholder="请选择报表模板" style="width: 100%;">
|
|
|
<el-option
|
|
|
v-for="item in reportTemplateList"
|
|
|
:key="item.id"
|
|
@@ -189,48 +199,15 @@
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="取值方式" prop="reportValueFormat">
|
|
|
- <el-radio v-model="reportForm.reportValueFormat" label="0">时段数据</el-radio>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label='取值模式' prop="valueCondition">
|
|
|
- <el-select v-model="reportForm.valueCondition" placeholder="请选择报表取值模式" style="width: 100%;">
|
|
|
- <el-option
|
|
|
- v-for="dict in valueConditionList"
|
|
|
- :key="dict.value"
|
|
|
- :label="dict.key"
|
|
|
- :value="dict.value"
|
|
|
- ></el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="报表类型" prop="isAutoReport">
|
|
|
- <el-select v-model="reportForm.isAutoReport" filterable placeholder="请选择报表类型" style="width: 100%;">
|
|
|
- <el-option
|
|
|
- v-for="item in reportOptions_"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="数据时间" prop="reportDate">
|
|
|
- <el-date-picker
|
|
|
- v-model="reportForm.reportDate" :editable="false" :clearable="false"
|
|
|
- style="width: 100%;"
|
|
|
- type="datetimerange"
|
|
|
- :picker-options="{
|
|
|
- format: 'yyyy-MM-dd HH:mm:ss'
|
|
|
- }"
|
|
|
- value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
- range-separator="至"
|
|
|
- start-placeholder="开始日期"
|
|
|
- end-placeholder="结束日期">
|
|
|
- </el-date-picker>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item style="text-align: center;">
|
|
|
- <el-button type="primary" @click="chooseReportEvent" style="margin-top: 20px;">确定</el-button>
|
|
|
- <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
|
|
|
+ <el-form-item label="运行时间" prop="cronLabel" v-if="reportForm.reportTableType == 1">
|
|
|
+ <el-input placeholder="请设置运行时间" v-model="reportForm.cronLabel" style="width: calc(100% - 105px);" readonly></el-input>
|
|
|
+ <el-button size="mini" style="float: right;width: 100px;line-height: 20px;">设置运行时间</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
+ <span slot='footer'>
|
|
|
+ <el-button type="primary" @click="chooseReportEvent" style="margin-top: 20px;">确定</el-button>
|
|
|
+ <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
|
|
|
+ </span>
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- 用户组选择 -->
|
|
@@ -607,28 +584,15 @@ export default {
|
|
|
chooseIsAutoReport: null,
|
|
|
delFlag: 0,
|
|
|
reportForm: {
|
|
|
- reportTemplate: null,
|
|
|
- reportValueFormat: '0', // 时间取值格式0时,1日,2月
|
|
|
- isAutoReport: 0,
|
|
|
- valueCondition: null, // 报表取值条件:0平均值 1最大值 2最小值 3瞬时值
|
|
|
- reportDate: [getNowFormatDate('yyyy-MM-dd') + ' 09:00:00',
|
|
|
- getNowFormatDate('yyyy-MM-dd') + ' 18:00:00']
|
|
|
+ reportTableName: '',
|
|
|
+ reportTableType: null,
|
|
|
+ tableTemplateId: null,
|
|
|
+ reportTableData: '',
|
|
|
+ cronLabel: '',
|
|
|
+ cron: ''
|
|
|
},
|
|
|
searchValue: null,
|
|
|
searchTxt: '',
|
|
|
- valueConditionList: [{
|
|
|
- 'key': '平均值',
|
|
|
- 'value': '0'
|
|
|
- }, {
|
|
|
- 'key': '最大值',
|
|
|
- 'value': '1'
|
|
|
- }, {
|
|
|
- 'key': '最小值',
|
|
|
- 'value': '2'
|
|
|
- }, {
|
|
|
- 'key': '瞬时值',
|
|
|
- 'value': '3'
|
|
|
- }],
|
|
|
reportOptions: [{
|
|
|
label: '所有报表',
|
|
|
value: -1
|
|
@@ -642,13 +606,6 @@ export default {
|
|
|
label: '事件驱动报表',
|
|
|
value: 3
|
|
|
}],
|
|
|
- reportOptions_: [{
|
|
|
- label: '手动报表',
|
|
|
- value: 0
|
|
|
- }, {
|
|
|
- label: '事件驱动报表',
|
|
|
- value: 3
|
|
|
- }],
|
|
|
groupUserData: [],
|
|
|
reportHistoryData: [],
|
|
|
reportHistoryTotal: 0,
|
|
@@ -659,20 +616,14 @@ export default {
|
|
|
reportLimit: 10,
|
|
|
reportDataList: [],
|
|
|
reportRules: {
|
|
|
- reportTemplate: [
|
|
|
- {required: true, message: '请选择报表模板', trigger: 'change'}
|
|
|
- ],
|
|
|
- reportValueFormat: [
|
|
|
- {required: true, message: '请选择取值方式', trigger: 'change'}
|
|
|
+ reportTableName: [
|
|
|
+ {required: true, message: '请输入报表名称', trigger: 'blur'}
|
|
|
],
|
|
|
- valueCondition: [
|
|
|
- { required: true, message: '请选择报表取值模式', trigger: 'blur' }
|
|
|
- ],
|
|
|
- isAutoReport: [
|
|
|
+ reportTableType: [
|
|
|
{required: true, message: '请选择报表类型', trigger: 'change'}
|
|
|
],
|
|
|
- reportDate: [
|
|
|
- {required: true, message: '请选择数据时间'}
|
|
|
+ tableTemplateId: [
|
|
|
+ {required: true, message: '请选择报表模板', trigger: 'change'}
|
|
|
]
|
|
|
},
|
|
|
luckysheetOption: {
|
|
@@ -964,18 +915,22 @@ export default {
|
|
|
},
|
|
|
resetReportFormVal() {
|
|
|
this.reportForm = {
|
|
|
- reportTemplate: null,
|
|
|
- reportValueFormat: '0', // 时间取值格式0时,1日,2月
|
|
|
- isAutoReport: 0,
|
|
|
- valueCondition: null, // 报表取值条件:0平均值 1最大值 2最小值 3瞬时值
|
|
|
- reportDate: [getNowFormatDate('yyyy-MM-dd') + ' 09:00:00',
|
|
|
- getNowFormatDate('yyyy-MM-dd') + ' 18:00:00']
|
|
|
+ reportTableName: '',
|
|
|
+ reportTableType: null,
|
|
|
+ tableTemplateId: null,
|
|
|
+ reportTableData: '',
|
|
|
+ cronLabel: '',
|
|
|
+ cron: ''
|
|
|
}
|
|
|
},
|
|
|
+ /** 报表类型更改事件 */
|
|
|
+ changeReportType() {
|
|
|
+ this.reportForm.tableTemplateId = null
|
|
|
+ this.getAllReportTemplate(this.reportForm.reportTableType)
|
|
|
+ },
|
|
|
/** 新增报表 */
|
|
|
addReportEvent() {
|
|
|
this.resetReportFormVal()
|
|
|
- this.getAllReportTemplate()
|
|
|
this.dialogReportTemplateVisible = true
|
|
|
},
|
|
|
/** 刷新报表 */
|
|
@@ -988,25 +943,14 @@ export default {
|
|
|
this.$refs['reportForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
const loading = showLoading(this, '数据加载中,请稍候···')
|
|
|
- getTableTemplateById(this.reportForm.reportTemplate).then(res => {
|
|
|
+ getTableTemplateById(this.reportForm.tableTemplateId).then(res => {
|
|
|
if (!res.data) {
|
|
|
loading.close()
|
|
|
showAlertMsgWin(this, null, '选择的报表模板不存在!')
|
|
|
return
|
|
|
}
|
|
|
- this.showMainView = true
|
|
|
let luckyData = JSON.parse(res.data.templateData)
|
|
|
- this.chooseReportTemplateId = res.data.id
|
|
|
- this.chooseIsAutoReport = this.reportForm.isAutoReport
|
|
|
- this.chooseReportTemplate = luckyData
|
|
|
- this.drawLuckyExcel(luckyData, () => {
|
|
|
- loading.close()
|
|
|
- this.dialogReportTemplateVisible = false
|
|
|
- this.breadcrumbList = ['新增报表']
|
|
|
- setTimeout(() => {
|
|
|
- this.btnType = 'add'
|
|
|
- }, 100)
|
|
|
- })
|
|
|
+ this.saveReportInfo(loading, luckyData)
|
|
|
}).catch((e) => {
|
|
|
loading.close()
|
|
|
showAlertWin(this, null, e)
|
|
@@ -1266,13 +1210,16 @@ export default {
|
|
|
}, 200)
|
|
|
})
|
|
|
},
|
|
|
- /** 查询所有报表信息 */
|
|
|
- getAllReportTemplate() {
|
|
|
+ /** 查询所有报表模板信息 */
|
|
|
+ getAllReportTemplate(templateType) {
|
|
|
const loading = showLoading(this, '数据加载中,请稍候···')
|
|
|
let params = {
|
|
|
'page': 1,
|
|
|
'limit': 1000
|
|
|
}
|
|
|
+ if (templateType != null) {
|
|
|
+ params.templateType = templateType
|
|
|
+ }
|
|
|
getAllTableTemplate(params).then(res => {
|
|
|
loading.close()
|
|
|
if (!res.data) {
|
|
@@ -1789,48 +1736,20 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
/** 保存报表信息 */
|
|
|
- saveReportInfo() {
|
|
|
- showPromptWin(this, '保存', '请输入报表名称', '', (val) => {
|
|
|
- if (!val) {
|
|
|
- return '报表名称不能为空'
|
|
|
- }
|
|
|
- if (val.length > 20) {
|
|
|
- return '报表名称必须在20字以内'
|
|
|
- }
|
|
|
- }, (value) => {
|
|
|
- if (!this.chooseReportTemplate) {
|
|
|
- showAlertMsgWin(this, null, '请重新选择报表模板!')
|
|
|
- return
|
|
|
- }
|
|
|
- const loading = showLoading(this, '保存中,请稍候···')
|
|
|
- let excelData = this.chooseReportTemplate.data[0].data
|
|
|
- let excelTable = this.chooseReportTemplate.tables
|
|
|
- excelTable.forEach(table => {
|
|
|
- table.field.forEach(field => {
|
|
|
- luckysheet.setCellValue(field.r, field.c, field.name)
|
|
|
- })
|
|
|
- })
|
|
|
- this.withDateData(excelData)
|
|
|
- // this.convertChart(this.chooseReportTemplate)
|
|
|
- let data = {
|
|
|
- 'tableTemplateId': this.chooseReportTemplateId,
|
|
|
- 'reportTableName': value,
|
|
|
- 'reportValueFormat': this.reportForm.reportValueFormat,
|
|
|
- 'valueCondition': this.reportForm.valueCondition,
|
|
|
- 'isAutoReport': this.chooseIsAutoReport,
|
|
|
- 'reportTableData': JSON.stringify(this.chooseReportTemplate)
|
|
|
- }
|
|
|
- saveReport(data).then(res => {
|
|
|
- loading.close()
|
|
|
- let msg = res.data ? '保存成功!' : '保存失败!'
|
|
|
- showAlertMsgWin(this, null, msg)
|
|
|
- this.showMainView = false
|
|
|
- this.loadReport()
|
|
|
- this.cancelSaveReport()
|
|
|
- }).catch((e) => {
|
|
|
- loading.close()
|
|
|
- showAlertWin(this, null, e)
|
|
|
- })
|
|
|
+ saveReportInfo(loading, dataInfo) {
|
|
|
+ if (!loading) loading = showLoading(this, '数据加载中,请稍候···')
|
|
|
+ this.reportForm.reportTableData = JSON.stringify(dataInfo)
|
|
|
+ saveReport(this.reportForm).then(res => {
|
|
|
+ loading.close()
|
|
|
+ let msg = res.data ? '保存成功!' : '保存失败!'
|
|
|
+ showAlertMsgWin(this, null, msg)
|
|
|
+ this.showMainView = false
|
|
|
+ this.dialogReportTemplateVisible = false
|
|
|
+ this.loadReport()
|
|
|
+ this.cancelSaveReport()
|
|
|
+ }).catch((e) => {
|
|
|
+ loading.close()
|
|
|
+ showAlertWin(this, null, e)
|
|
|
})
|
|
|
},
|
|
|
/** 更新报表信息 */
|