浏览代码

我的报表添加修改

FinalYu 2 年之前
父节点
当前提交
1eacdd588e

+ 15 - 0
chuanyi_client2/src/api/datasource.js

@@ -471,6 +471,21 @@ export function delReportTableById(id) {
 }
 
 /**
+ * 修改报表名称
+ * @param params
+ * @returns {AxiosPromise}
+ */
+export function updateTableNameById(params) {
+    return request({
+        url: '/reportTable/updateTableNameById?id=' + params.id + '&reportTableName=' + params.reportTableName,
+        headers: {
+            isToken: true
+        },
+        method: 'post'
+    })
+}
+
+/**
  * 根据ID获取报表基础信息
  * @param id
  * @returns {AxiosPromise}

+ 71 - 6
chuanyi_client2/src/views/my_report/index.vue

@@ -12,6 +12,8 @@
     </el-select>
     <el-button v-if="btnType != 'show'" type="primary" class="cy-nav-btn" icon="el-icon-circle-plus-outline"
                size="mini" @click="addReportEvent">新增</el-button>
+    <el-button v-if="btnType != 'show'" type="success" class="cy-nav-btn" icon="el-icon-refresh"
+               size="mini" @click="refreshReportEvent">刷新</el-button>
     <el-divider></el-divider>
     <div class="cy-main">
       <div class="cy-main-left" v-if="!showMainView">
@@ -19,8 +21,11 @@
           <ul v-if="reportDataList.length > 0">
             <li v-for="item in reportDataList">
               <i v-if="uid == item.userId" class="el-icon-delete"
-                 style="float: right; margin-top: -10px; margin-right: -10px; cursor: pointer;"
+                 style="float: right; cursor: pointer;"
                  @click="removeReportItem(item)"></i>
+              <i v-if="uid == item.userId" class="el-icon-edit"
+                 style="float: right; cursor: pointer; margin-right: 10px; margin-left: 10px;"
+                 @click="editReportItem(item)"></i>
               <div class="cy-item-name" @click="handleReportNodeClick(item)" :title="item.reportTableName">{{ item.reportTableName }}</div>
               <div style="display: flex; float: left; cursor: pointer;"
                    @click="setUserGroupEvent(item)" v-if="uid == item.userId">
@@ -34,7 +39,18 @@
                 <el-switch v-else :value="item.isAutoReport == '1'" active-color="#13ce66"
                            @change="switchChangeEvent($event, item)" :disabled="uid != item.userId"></el-switch>
               </div>
-              <div class="cy-list-item">{{ item.createTime }}</div>
+              <div class="cy-list-item">
+                <div style="display: inline-block;" title="定时任务表达式">
+                  <template v-if="item.cron">
+                    <i class="el-icon-bell"></i>
+                    <span style="margin-left: 5px;">{{ item.cron }}</span>
+                  </template>
+                </div>
+                <div title="创建时间">
+                  <i class="el-icon-alarm-clock"></i>
+                  <span style="margin-left: 5px;">{{ item.createTime }}</span>
+                </div>
+              </div>
             </li>
           </ul>
           <el-empty v-else description="暂无数据"></el-empty>
@@ -188,7 +204,7 @@ import {
   getAllReportTable,
   getAllTableTemplate, getChartData,
   getDataModelById, getReportTableById, getTableData,
-  getTableTemplateById, saveReport, tableAssignUserById, tableExchangeTypeById
+  getTableTemplateById, saveReport, tableAssignUserById, tableExchangeTypeById, updateTableNameById
 } from '@/api/datasource'
 import {insertEChart} from 'luckytool'
 // import {insertEChart, exportExcel, packtable} from 'luckytool'
@@ -360,6 +376,11 @@ export default {
       this.getAllReportTemplate()
       this.dialogReportTemplateVisible = true
     },
+    /** 刷新报表 */
+    refreshReportEvent() {
+      this.reportPage = 1
+      this.loadReport()
+    },
     /** 模版报表选择 */
     chooseReportEvent() {
       this.$refs['reportForm'].validate((valid) => {
@@ -862,6 +883,50 @@ export default {
         })
       })
     },
+    /** 修改报表信息 */
+    editReportItem(data) {
+      this.$prompt('请输入报表名称', '保存', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        inputValue: data.reportTableName,
+        customClass: 'close_confirm',
+        closeOnClickModal: false,
+        inputValidator: (val) => {
+          if (!val || !val.trim()) {
+            return '报表名称不能为空'
+          }
+          if (val.length > 20) {
+            return '报表名称必须在20字以内'
+          }
+        }
+      }).then(({value}) => {
+        const loading = showLoading(this, '修改中,请稍候···')
+        let params = {
+          'id': data.id,
+          'reportTableName': value
+        }
+        updateTableNameById(params).then(res => {
+          loading.close()
+          let msg = res.data ? '修改成功!' : '修改失败!'
+          let msgType = res.data ? 'success' : 'warning'
+          this.$message({
+            message: msg,
+            type: msgType
+          })
+          this.reportPage = 1
+          this.loadReport()
+        }).catch((e) => {
+          loading.close()
+          this.$alert(e, '操作失败!', {
+            confirmButtonText: '确定',
+            callback: action => {
+            }
+          })
+        })
+      }).catch((e) => {
+        console.log(e)
+      })
+    },
     /** 报表移除 */
     removeReportItem(data) {
       this.$confirm('您确定要删除该报表吗?', '温馨提示', {
@@ -1149,7 +1214,6 @@ export default {
       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() {
@@ -1233,7 +1297,7 @@ export default {
           width: 23%;
           margin: 10px 1%;
           border-radius: 8px;
-          height: 90px;
+          height: 110px;
           padding: 15px;
           color: #ffffff;
 
@@ -1254,7 +1318,8 @@ export default {
             font-size: 12px;
             color: #f6f6f6;
             width: 100%;
-            display: flex;
+            //display: flex;
+            margin-top: 40px;
           }
         }
       }

+ 6 - 3
chuanyi_client2/src/views/report_template/index.vue

@@ -565,7 +565,8 @@ export default {
             _this.insertEChartTool(_this.toolChart[i].info, false)
           }
         } else {
-          luckysheet.create(_this.luckysheetOption)
+          let option = JSON.parse(JSON.stringify(_this.luckysheetOption))
+          luckysheet.create(option)
         }
         _this.autoSaveReportInfo()
       }
@@ -605,10 +606,11 @@ export default {
         }
       }).then(({ value }) => {
         const loading = showLoading(this, '保存中,请稍候···')
+        let option = JSON.parse(JSON.stringify(this.luckysheetOption))
         let result = {
           'charts': this.toolChart,
           'tables': this.toolTable,
-          'option': this.luckysheetOption,
+          'option': option,
           'data': JSON.parse(this.getLuckysheetConfig())
         }
         let data = {
@@ -664,8 +666,9 @@ export default {
       localStorage.removeItem(this.reportTemplateItem)
       this.toolChart = []
       this.toolTable = []
+      let option = JSON.parse(JSON.stringify(this.luckysheetOption))
       luckysheet.destroy()
-      luckysheet.create(this.luckysheetOption)
+      luckysheet.create(option)
     },
     /** 保存数据格式转换 */
     getLuckysheetConfig() {