|
@@ -85,6 +85,36 @@
|
|
|
</el-form>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <!-- 自动报表CRON定时表达式 -->
|
|
|
+ <el-dialog
|
|
|
+ title="请输入定时任务表达式"
|
|
|
+ width="80%"
|
|
|
+ top="10vh"
|
|
|
+ center
|
|
|
+ :before-close="dialogClose"
|
|
|
+ :visible.sync="dialogAutoReportVisible"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :append-to-body="true">
|
|
|
+ <el-form label-width="80px">
|
|
|
+ <el-form-item label="表达式">
|
|
|
+ <el-input type="text" placeholder="请输入定时任务表达式" v-model="cronVal" maxlength="50"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <div>
|
|
|
+ <label>常用定时任务表达式例子</label>
|
|
|
+ <ul>
|
|
|
+ <li v-for="(item, i) in cronList" style="margin-bottom: 5px;">
|
|
|
+ <span class="cron-txt" @click="cronNodeEvent(item)">{{ item.value }}</span>
|
|
|
+ <span class="cron-txt-desc">{{ item.label }}</span>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ <el-form-item style="text-align: center;">
|
|
|
+ <el-button type="primary" @click="chooseCronEvent" style="margin-top: 20px;">确定</el-button>
|
|
|
+ <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<!-- 报表下载类型选择 -->
|
|
|
<el-dialog
|
|
|
title="选择下载类型"
|
|
@@ -120,12 +150,13 @@ import {
|
|
|
getAllTableTemplate, getChartData,
|
|
|
getDataModelById, getReportTableById, getTableData,
|
|
|
getTableTemplateById, saveReport, tableExchangeTypeById
|
|
|
-} from "@/api/datasource";
|
|
|
-import {insertEChart/*, exportExcel, packtable*/} from 'luckytool'
|
|
|
-import ExcelJS from 'exceljs'
|
|
|
+} from '@/api/datasource'
|
|
|
+import {insertEChart} from 'luckytool'
|
|
|
+// import {insertEChart, exportExcel, packtable} from 'luckytool'
|
|
|
+// import ExcelJS from 'exceljs'
|
|
|
import Print from 'print-js'
|
|
|
import {getUsername} from '@/utils/auth'
|
|
|
-import {exportExcel} from "@/utils/export";
|
|
|
+import {exportExcel} from '@/utils/export'
|
|
|
|
|
|
export default {
|
|
|
name: "index",
|
|
@@ -142,8 +173,12 @@ export default {
|
|
|
chooseMyReport: null,
|
|
|
dialogReportTemplateVisible: false,
|
|
|
dialogDownloadReportTypeVisible: false,
|
|
|
+ dialogAutoReportVisible: false,
|
|
|
downloadType: '1',
|
|
|
btnType: '',
|
|
|
+ cronVal: '',
|
|
|
+ cronList: [],
|
|
|
+ reportId: null,
|
|
|
reportTemplateList: [],
|
|
|
dataModelList: [],
|
|
|
chooseReportTemplate: null,
|
|
@@ -180,6 +215,7 @@ export default {
|
|
|
created() {
|
|
|
luckysheet.destroy()
|
|
|
this.loadReport()
|
|
|
+ this.initCronList()
|
|
|
},
|
|
|
methods: {
|
|
|
handleSizeChange(val) {
|
|
@@ -195,14 +231,64 @@ export default {
|
|
|
this.reportPage = 1
|
|
|
this.loadReport()
|
|
|
},
|
|
|
+ validCron(value) {
|
|
|
+ const cronParse = require('cron-parser')
|
|
|
+ try {
|
|
|
+ const interval = cronParse.parseExpression(value)
|
|
|
+ console.log('cronDate:', interval.next().toDate())
|
|
|
+ return true
|
|
|
+ } catch (e) {
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ chooseCronEvent() {
|
|
|
+ if (!this.cronVal) {
|
|
|
+ this.$message({
|
|
|
+ message: '请输入定时任务表达式!',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.validCron(this.cronVal)) {
|
|
|
+ this.$message({
|
|
|
+ message: '定时任务表达式格式不正确,请检查!',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const loading = showLoading(this, '请稍候···')
|
|
|
+ let params = {
|
|
|
+ 'id': this.reportId,
|
|
|
+ 'isAutoReport': '1',
|
|
|
+ 'cron': this.cronVal
|
|
|
+ }
|
|
|
+ tableExchangeTypeById(params).then(res => {
|
|
|
+ loading.close()
|
|
|
+ this.dialogClose()
|
|
|
+ this.loadReport()
|
|
|
+ }).catch((e) => {
|
|
|
+ loading.close()
|
|
|
+ this.$message({
|
|
|
+ message: '保存失败!',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
switchChangeEvent(val, data) {
|
|
|
if (val) {
|
|
|
- console.log(val)
|
|
|
+ this.dialogAutoReportVisible = true
|
|
|
+ this.reportId = data.id
|
|
|
+ getReportTableById(data.id).then(res => {
|
|
|
+ this.cronVal = res.data.cron
|
|
|
+ }).catch((e) => {
|
|
|
+ console.log(e)
|
|
|
+ })
|
|
|
+ return
|
|
|
}
|
|
|
const loading = showLoading(this, '请稍候···')
|
|
|
let params = {
|
|
|
'id': data.id,
|
|
|
- 'isAutoReport': val ? '1' : '0'
|
|
|
+ 'isAutoReport': '0'
|
|
|
}
|
|
|
tableExchangeTypeById(params).then(res => {
|
|
|
loading.close()
|
|
@@ -856,6 +942,21 @@ export default {
|
|
|
});
|
|
|
return objRowColumn;
|
|
|
},
|
|
|
+ cronNodeEvent(obj) {
|
|
|
+ this.cronVal = obj.value
|
|
|
+ },
|
|
|
+ initCronList() {
|
|
|
+ this.cronList = []
|
|
|
+ this.cronList.push({ value: '0/2 * * * * ?', label: '表示每2秒钟执行一次任务' })
|
|
|
+ this.cronList.push({ value: '0 0/2 * * * ?', label: '表示每2分钟执行一次任务' })
|
|
|
+ this.cronList.push({ value: '0 0 0/2 * * ?', label: '表示每2小时执行一次任务' })
|
|
|
+ this.cronList.push({ value: '0 15 10 * * ?', label: '表示在每天上午10点15分执行一次任务' })
|
|
|
+ this.cronList.push({ value: '0 0 10,14,16 * * ?', label: '表示在每天的上午10点、下午2点、下午4点分别执行一次任务' })
|
|
|
+ this.cronList.push({ value: '0 0/30 9-17 * * ?', label: '表示在每天的上午9点到下午5点的范围内每30分钟执行一次任务' })
|
|
|
+ this.cronList.push({ value: '0 0 12 ? * WED', label: '表示在每周星期三中午12点执行一次任务' })
|
|
|
+ this.cronList.push({ value: '0 0 2 1 * ?', label: '表示在每月的1日的凌晨2点执行一次任务' })
|
|
|
+ this.cronList.push({ value: '0 15 10 * * ? 2023', label: '表示在2023年每天上午10点15分执行一次任务' })
|
|
|
+ },
|
|
|
/** 取消保存报表 */
|
|
|
cancelSaveReport() {
|
|
|
luckysheet.destroy()
|
|
@@ -865,11 +966,14 @@ export default {
|
|
|
},
|
|
|
/** 弹出层关闭事件 */
|
|
|
dialogClose(done) {
|
|
|
+ this.cronVal = ''
|
|
|
+ this.reportId = null
|
|
|
if (typeof (done) === 'function') {
|
|
|
done()
|
|
|
} else {
|
|
|
this.dialogReportTemplateVisible = false
|
|
|
this.dialogDownloadReportTypeVisible = false
|
|
|
+ this.dialogAutoReportVisible = false
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -968,4 +1072,15 @@ export default {
|
|
|
line-height: 28px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.cron-txt {
|
|
|
+ color: blue;
|
|
|
+ margin-right: 20px;
|
|
|
+ cursor: pointer;
|
|
|
+ font-weight: bold;
|
|
|
+ font-size: 16px;
|
|
|
+}
|
|
|
+
|
|
|
+.cron-txt-desc {
|
|
|
+}
|
|
|
</style>
|