Ver código fonte

处理日期数据

FinalYu 2 anos atrás
pai
commit
462c5a78ca

+ 28 - 5
chuanyi_client2/src/views/my_report/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="cqcy-content" style="margin: 0;height: calc(100% - 70px);">
     <breadcrumb-view :breadcrumbList="breadcrumbList" :show-index="false"></breadcrumb-view>
-    <el-select v-if="btnType != 'show'" class="cy-nav-sx" v-model="searchValue" placeholder="筛选报表"
+    <el-select v-if="btnType != 'show' && btnType != 'add'" class="cy-nav-sx" v-model="searchValue" placeholder="筛选报表"
                @change="changeReportTypeEvent">
       <el-option
           v-for="item in reportOptions"
@@ -10,9 +10,9 @@
           :value="item.value">
       </el-option>
     </el-select>
-    <el-button v-if="btnType != 'show'" type="primary" class="cy-nav-btn" icon="el-icon-circle-plus-outline"
+    <el-button v-if="btnType != 'show' && btnType != 'add'" 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"
+    <el-button v-if="btnType != 'show' && btnType != 'add'" type="success" class="cy-nav-btn" icon="el-icon-refresh"
                size="mini" @click="refreshReportEvent">刷新</el-button>
     <el-divider></el-divider>
     <div class="cy-main">
@@ -406,6 +406,7 @@ export default {
               this.btnType = 'add'
               this.$refs.reportForm.resetFields()
               this.dialogReportTemplateVisible = false
+              this.breadcrumbList = ['新增报表']
             })
           }).catch((e) => {
             loading.close()
@@ -518,19 +519,19 @@ export default {
       })
     },
     drawBaseInfo() {
+      let currDate = getNowFormatDate('date')
+      let currDateTime = getNowFormatDate('')
       let option = luckysheet.getAllSheets()[0]
       option.celldata.map(item => {
         if (item.v.v) {
           item.v.v = String(item.v.v).trim();
           if (item.v.v.match(/\${([^}]+)}/g)) { // 替换${xxx}内部数据
-            let currDate = getNowFormatDate('date')
             if (item.v.v.indexOf('${currDate}') > -1) {
               let val = item.v.v
               val = val.replace('${currDate}', currDate)
               luckysheet.setCellValue(item.r, item.c, val)
             }
             if (item.v.v.indexOf('${currDateTime}') > -1) {
-              let currDateTime = getNowFormatDate('')
               let val = item.v.v
               val = val.replace('${currDateTime}', currDateTime)
               luckysheet.setCellValue(item.r, item.c, val)
@@ -1075,6 +1076,26 @@ export default {
         })
       }
     },
+    /** 处理日期显示数字问题 */
+    withDateData(excelData) {
+      if (!excelData) {
+        return
+      }
+      excelData.map((item) => {
+        if (item) {
+          item.map((ll) => {
+            if (ll) {
+              ll.m = ll.m,
+              ll.v = ll.m,
+              ll.ct = {
+                fa: "@",
+                t: "s",
+              }
+            }
+          })
+        }
+      })
+    },
     /** 保存报表信息 */
     saveReportInfo() {
       this.$prompt('请输入报表名称', '保存', {
@@ -1099,6 +1120,8 @@ export default {
           return
         }
         const loading = showLoading(this, '保存中,请稍候···')
+        let excelData = this.chooseReportTemplate.data[0].data
+        this.withDateData(excelData)
         this.convertChart()
         let data = {
           'reportTableName': value,

+ 1 - 0
chuanyi_client2/src/views/report_template/index.vue

@@ -665,6 +665,7 @@ export default {
       this.templateId = null
       this.templateName = ''
       this.clearReportTemplate()
+      this.$emit('refreshReportTemplateData', true)
     },
     /** 取消报表内容 */
     clearReportTemplate() {