Sfoglia il codice sorgente

回退可选时间

liyg 2 anni fa
parent
commit
8a0de1bb3a
1 ha cambiato i file con 153 aggiunte e 123 eliminazioni
  1. 153 123
      src/views/statisticalReport/components/Ship_dynamic_table.vue

+ 153 - 123
src/views/statisticalReport/components/Ship_dynamic_table.vue

@@ -7,15 +7,14 @@
           v-model="endTime"
           @change="DateChange"
           type="datetime"
-          placeholder="选择截止时间"
-        >
+          placeholder="选择截止时间">
         </el-date-picker>
         <!-- <el-button type="primary" class="btn" @click="onclick">
           <i class="el-icon-search"></i>查询
         </el-button> -->
-        <el-button type="primary" class="btn" @click="reflush">
+        <!-- <el-button type="primary" class="btn" @click="reflush">
           <i class="el-icon-search"></i>刷新
-        </el-button>
+        </el-button> -->
         <el-button type="primary" class="btn" @click="getPdfs()">
           <i class="el-icon-download"></i>下载PDF
         </el-button>
@@ -23,7 +22,7 @@
           <i class="el-icon-download"></i>下载Excel
         </el-button>
       </div>
-      <table-item ref="ship" :tableData="tableData" :col="col" id="pdfDom">
+      <table-item ref="ship" v-bind.sync="option" id="pdfDom">
       </table-item>
     </div>
   </div>
@@ -40,117 +39,121 @@ export default {
   },
   data() {
     return {
+      endTime:null,
+      option:{
+        endTime:null,
+        deadline:null,
+           // 树型结构表头数据
+        col: [
+          {
+            prop: 'materialType',
+            label: '矿种'
+          },
+          {
+            prop: 'pm',
+            label: '品名'
+          },
+          {
+            prop: 'portName',
+            label: '港口名称'
+          },
+          {
+            prop: 'tonnage',
+            label: '下游港口吨位'
+          },
+          {
+            label: '未到闸船舶',
+            children: [
+              {
+                prop: 'capacity1',
+                label: '船名'
+              },
+              {
+                prop: 'capacityNumber1',
+                label: '吨位'
+              },
+              {
+                prop: 'locationValue1',
+                label: '位置'
+              },
+              {
+                prop: 'outPortTime1',
+                label: '离港时间'
+              }
+            ]
+          },
+          {
+            label: '等闸船舶',
+            children: [
+              {
+                prop: 'capacity2',
+                label: '船名'
+              },
+              {
+                prop: 'capacityNumber2',
+                label: '吨位'
+              },
+              {
+                prop: 'locationValue2',
+                label: '位置'
+              },
+              {
+                prop: 'outPortTime2',
+                label: '离港时间'
+              }
+            ]
+          },
+          {
+            label: '已过闸船舶',
+            children: [
+              {
+                prop: 'capacity3',
+                label: '船名'
+              },
+              {
+                prop: 'capacityNumber3',
+                label: '吨位'
+              },
+              {
+                prop: 'locationValue3',
+                label: '位置'
+              },
+              {
+                prop: 'outPortTime3',
+                label: '离港时间'
+              }
+            ]
+          },
+          {
+            label: '到港待卸船舶',
+            children: [
+              {
+                prop: 'capacity4',
+                label: '船名'
+              },
+              {
+                prop: 'capacityNumber4',
+                label: '吨位'
+              },
+              {
+                prop: 'locationValue4',
+                label: '位置'
+              },
+              {
+                prop: 'outPortTime4',
+                label: '离港时间'
+              },
+              {
+                prop: 'dgsj',
+                label: '到港时间'
+              }
+            ]
+          }
+        ],
+        // 表格数据
+        tableData: [],
+      },
       htmlTitle: '船舶动态表',
-      // 树型结构表头数据
-      col: [
-        {
-          prop: 'materialType',
-          label: '矿种'
-        },
-        {
-          prop: 'pm',
-          label: '品名'
-        },
-        {
-          prop: 'portName',
-          label: '港口名称'
-        },
-        {
-          prop: 'tonnage',
-          label: '下游港口吨位'
-        },
-        {
-          label: '未到闸船舶',
-          children: [
-            {
-              prop: 'capacity1',
-              label: '船名'
-            },
-            {
-              prop: 'capacityNumber1',
-              label: '吨位'
-            },
-            {
-              prop: 'locationValue1',
-              label: '位置'
-            },
-            {
-              prop: 'outPortTime1',
-              label: '离港时间'
-            }
-          ]
-        },
-        {
-          label: '等闸船舶',
-          children: [
-            {
-              prop: 'capacity2',
-              label: '船名'
-            },
-            {
-              prop: 'capacityNumber2',
-              label: '吨位'
-            },
-            {
-              prop: 'locationValue2',
-              label: '位置'
-            },
-            {
-              prop: 'outPortTime2',
-              label: '离港时间'
-            }
-          ]
-        },
-        {
-          label: '已过闸船舶',
-          children: [
-            {
-              prop: 'capacity3',
-              label: '船名'
-            },
-            {
-              prop: 'capacityNumber3',
-              label: '吨位'
-            },
-            {
-              prop: 'locationValue3',
-              label: '位置'
-            },
-            {
-              prop: 'outPortTime3',
-              label: '离港时间'
-            }
-          ]
-        },
-        {
-          label: '到港待卸船舶',
-          children: [
-            {
-              prop: 'capacity4',
-              label: '船名'
-            },
-            {
-              prop: 'capacityNumber4',
-              label: '吨位'
-            },
-            {
-              prop: 'locationValue4',
-              label: '位置'
-            },
-            {
-              prop: 'outPortTime4',
-              label: '离港时间'
-            },
-            {
-              prop: 'dgsj',
-              label: '到港时间'
-            }
-          ]
-        }
-      ],
-      // 表格数据
-
-      tableData: [],
       input: '',
       //万州港库存信息
       stockString: null,
@@ -163,7 +166,7 @@ export default {
     }
   },
   created() {
-    this.initialDate()
+    this.initialDate();
   },
   mounted() {
     this.initialization()
@@ -177,15 +180,42 @@ export default {
     reflush() {
       this.$router.go(0)
     },
+    initialDate(){
+      let now=new Date();
+      now.setMinutes(0);
+      now.setSeconds(0);
+      if(now.getHours() >=8 && now.getHours() < 18){
+        now.setHours(8);
+      }else if(now.getHours() >= 18){
+        now.setHours(18)
+      }else if(now.getHours() < 8 ){
+        now = new Date(now.getTime()-1000*60*60*24);
+        now.setHours(18)
+      }
+      this.endTime=now;
+      this.DateChange();
+    },
+    DateChange(){
+      this.option.deadline=this.endTime.getFullYear()+'年'+(this.endTime.getMonth()+1)+'月'+this.endTime.getDate()+'日(数据截止于'+this.endTime.getHours()+':'+this.perfix(this.endTime.getMinutes())+')';
+      this.option.endTime=this.endTime.getTime();
+      this.onclick();
+    },
+    perfix(num){
+      let arr=new Array(2).fill('0');
+      return (arr.join()+num).slice(-2);
+    },
     onclick() {
+      let map={
+        oneDate:this.endTime.getTime()
+      }
       this.axios
-        .post('/api/v1/tms/selectAllShipDynamaics?con=' + this.input)
+        .post('/api/v1/tms/selectAllShipDynamaics?con=' + this.input,map)
         .then(res => {
           if (res.data.code == '200') {
-            this.tableData = res.data.data
+            this.option.tableData = res.data.data
             console.log('aaad' + res.data.data)
           } else if (res.data.data == '暂时没有船舶动态') {
-            this.tableData = []
+            this.option.tableData = []
           }
         })
     },
@@ -481,9 +511,9 @@ export default {
     initialization() {
       this.axios.post('/api/v1/tms/selectAllShipDynamaics').then(res => {
         if (res.data.code == '200') {
-          this.tableData = res.data.data
-          console.log('this.tableData:', this.tableData)
-          this.tableData.forEach(item => {
+          this.option.tableData = res.data.data
+          console.log('this.option.tableData:', this.option.tableData)
+          this.option.tableData.forEach(item => {
             try {
               item.tonnage = item.tonnage.toFixed(2)
             } catch (error) {}
@@ -521,7 +551,7 @@ export default {
               }
             } catch (error) {}
           })
-          console.log(this.tableData)
+          console.log(this.option.tableData)
         } else {
           this.$message({
             type: 'warning',