liuyg
2021-07-16 f5641fd76ef90a66599e8ce121f3acfd97d779e8
src/views/parcel/parcel.vue
@@ -1,6 +1,7 @@
<template>
  <basic-container>
    <avue-crud :option="option"
    <avue-crud
      :option="option"
               :table-loading="loading"
               :data="data"
               :page="page"
@@ -20,8 +21,8 @@
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad">
      @on-load="onLoad"
    >
      <!-- <template slot-scope="{ type, size, row }" slot="menu">
        <el-button
@@ -56,21 +57,24 @@
        </template>
      <template slot="menuLeft">
          <el-button type="warning"
        <el-button
          type="warning"
                      size="small"
                      plain
                      icon="el-icon-download"
                      @click="handleExport">导出
          @click="handleExport"
          >导出
          </el-button>
          <el-button type="warning"
        <el-button
          type="warning"
                      size="small"
                      plain
                      icon="el-icon-pie-chart"
                      @click="handleExportStatis">导出报表
          @click="handleExportStatis"
          >导出报表
          </el-button>
        </template>
    </avue-crud>
    <template>
      <div>
@@ -78,20 +82,20 @@
              class="img"
              v-if="showViewer"
              :on-close="closeViewer"
              :url-list="['data:image/png;base64,'+imgUrl]" />
          :url-list="['data:image/png;base64,' + imgUrl]"
        />
      </div>
    </template>
  </basic-container>
</template>
<script>
  import {getList,exportParcelStatis, getParcelPic} from "@/api/parcel/parcel";
  import {mapGetters} from "vuex";
  import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
import ElImageViewer from "element-ui/packages/image/src/image-viewer";
  export default {
    name:'index',
  name: "index",
    components: { ElImageViewer },
    data() {
      return {
@@ -100,42 +104,42 @@
        search:{},
        showViewer: false, // 显示查看器
        activeClass: 0,
        imgUrl:'',
      imgUrl: "",
        loading: true,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        total: 0,
        },
        selectionList: [],
        option: {
          menu:false,
          height:'auto',
        height: "auto",
          calcHeight: 54,
          tip: false,
          searchShow: true,
          searchMenuSpan: 6,
          border: false,
          stripe:true,
        //stripe:true,
          index: true,
          viewBtn: true,
          selection: true,
          labelWidth:120,
          menuWidth:220,
          dialogClickModal: false,
          headerAlign: 'center',
          align: 'center',
        headerAlign: "center",
        align: "center",
          tree:true,
          column: [
            {
              label: '坐标',
              prop: 'test',
            label: "坐标",
            prop: "test",
              hide: true,
              span: 50,
              component: "avueMap",
              clickChild: (obj) => {
                this.form.jd = obj.latitude
                this.form.wd = obj.longitude
              this.form.jd = obj.latitude;
              this.form.wd = obj.longitude;
              },
            },
            {
@@ -149,7 +153,7 @@
            {
              label: "包裹图片KEY",
              prop: "imgUrl",
              hide:true
            hide: true,
            },
            // {
            //   label: '包裹图片',
@@ -188,9 +192,9 @@
                {
                  required: true,
                  message: "请输入时间",
                  trigger: "blur"
                }
              ]
                trigger: "blur",
              },
            ],
            },
            {
              label: "是否违禁",
@@ -198,13 +202,13 @@
              dicData: [
                {
                  label: "是",
                  value: 1
                value: 1,
                },
                {
                  label: "否",
                  value: 0
                value: 0,
                },
              ]
            ],
            },
            {
              label: "是否违禁",
@@ -218,21 +222,21 @@
              dicData: [
                {
                  label: "是",
                  value: "contraband"
                value: "contraband",
                },
                {
                  label: "否",
                  value: "normal"
                value: "normal",
                },
              ]
            ],
            },
            {
              label: "违禁包裹物品",
              prop: "decisioDiagramResultDetails",
            }
          ]
        },
        data: []
        ],
      },
      data: [],
      };
    },
    computed: {
@@ -242,16 +246,16 @@
          addBtn: this.vaildData(null, false),
          viewBtn: this.vaildData(null, false),
          delBtn: this.vaildData(null, false),
          editBtn: this.vaildData(null, false)
        editBtn: this.vaildData(null, false),
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
      this.selectionList.forEach((ele) => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    },
    },
    methods: {
      beforeOpen(done, type) {
@@ -275,9 +279,9 @@
      },
      rowClick(row){
        var that=this;
        getParcelPic(row.imgUrl).then(res => {
      getParcelPic(row.imgUrl).then((res) => {
            that.imgUrl = res.data.data.imgBase64;
            this.showViewer = true
        this.showViewer = true;
          });
      },
      selectionChange(list) {
@@ -297,45 +301,64 @@
        this.onLoad(this.page, this.query);
      },
      getStartTime(){
           if (this.$route.query.startTime != undefined && this.$route.query.startTime != null && this.$route.query.startTime != "" ) {
             return this.$route.query.startTime
      if (
        this.$route.query.startTime != undefined &&
        this.$route.query.startTime != null &&
        this.$route.query.startTime != ""
      ) {
        return this.$route.query.startTime;
           }
           // 当前时间
          var date = new Date();
          //年
          var Y = date.getFullYear();
          //月
          var M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
      var M =
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1;
          //日
          var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
           return Y + "-" + M + "-" + D+ " 00:00:00";
      },
      getEndTime(){
           if (this.$route.query.endTime != undefined && this.$route.query.endTime != null && this.$route.query.endTime != "" ) {
             return this.$route.query.endTime
      if (
        this.$route.query.endTime != undefined &&
        this.$route.query.endTime != null &&
        this.$route.query.endTime != ""
      ) {
        return this.$route.query.endTime;
           }
            // 当前时间
            var date = new Date();
            //年
            var Y = date.getFullYear();
            //月
            var M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
      var M =
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1;
            //日
            var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            return Y + "-" + M + "-" + D+ " 23:59:59";
      },
      getIsKindParams(){
        if(this.$route.query.decisioDiagramResult && this.$route.query!='' && this.$route.query!=null && this.$route.query!=undefined){
      if (
        this.$route.query.decisioDiagramResult &&
        this.$route.query != "" &&
        this.$route.query != null &&
        this.$route.query != undefined
      ) {
          //回显
          return this.$route.query.decisioDiagramResult
        return this.$route.query.decisioDiagramResult;
        }
      },
      //给行加颜色
      rowStyle({row, column, rowIndex}){
         if(row.mechineMark==1){
           return {
             color:"#fe1515"
           }
          color: "#fe1515",
        };
         }
      },
      getParcelData(e) {
@@ -349,33 +372,42 @@
        if(e==0){
          params = {
            startTime:this.showToDay(today)+ " 00:00:00",
            endTime:this.showToDay(today)+ " 23:59:59"
          endTime: this.showToDay(today) + " 23:59:59",
          };
          //修改搜索框中的值
          this.search.dateTime=[this.showToDay(today)+ " 00:00:00",this.showToDay(today)+ " 23:59:59"]
        this.search.dateTime = [
          this.showToDay(today) + " 00:00:00",
          this.showToDay(today) + " 23:59:59",
        ];
        }
        if(e==1){
          params = {
            startTime:this.showWeekFirstDay(today)+ " 00:00:00",
            endTime:this.showToDay(today)+ " 23:59:59"
          endTime: this.showToDay(today) + " 23:59:59",
          };
          //修改搜索框中的值
          this.search.dateTime=[this.showWeekFirstDay(today)+ " 00:00:00",this.showToDay(today)+ " 23:59:59"]
        this.search.dateTime = [
          this.showWeekFirstDay(today) + " 00:00:00",
          this.showToDay(today) + " 23:59:59",
        ];
        }
        if(e==2){
          params = {
            startTime:this.showMonthFirstDay(today)+ " 00:00:00",
            endTime:this.showToDay(today)+ " 23:59:59"
          endTime: this.showToDay(today) + " 23:59:59",
          };
          //修改搜索框中的值
          this.search.dateTime=[this.showMonthFirstDay(today)+ " 00:00:00",this.showToDay(today)+ " 23:59:59"]
        this.search.dateTime = [
          this.showMonthFirstDay(today) + " 00:00:00",
          this.showToDay(today) + " 23:59:59",
        ];
        }
        if(this.search.decisioDiagramResult){
          params= {
            ... params,
            decisioDiagramResult:this.search.decisioDiagramResult
          }
          decisioDiagramResult: this.search.decisioDiagramResult,
        };
        }
        this.query = params;
        this.page.currentPage = 1;
@@ -410,31 +442,56 @@
      //本月第一天
      showMonthFirstDay(Nowdate){
        var MonthFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth(),1);
      var MonthFirstDay = new Date(
        Nowdate.getFullYear(),
        Nowdate.getMonth(),
        1
      );
        var M=Number(MonthFirstDay.getMonth())+1;
        if(M<10){
          M="0"+M;
        }
        return MonthFirstDay.getFullYear()+"-"+M+"-"+"0"+MonthFirstDay.getDate();
      return (
        MonthFirstDay.getFullYear() +
        "-" +
        M +
        "-" +
        "0" +
        MonthFirstDay.getDate()
      );
      },
      //数据导出
      handleExport() {
        this.$confirm("是否导出包裹数据?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        type: "warning",
        }).then(() => {
          window.open(`/api/parcel/parcel/export-parcel?startTime=${this.$route.query.startTime}&endTime=${this.$route.query.endTime}&decisioDiagramResult=${this.$route.query.decisioDiagramResult}`);
        window.open(
          `/api/parcel/parcel/export-parcel?startTime=${this.$route.query.startTime}&endTime=${this.$route.query.endTime}&decisioDiagramResult=${this.$route.query.decisioDiagramResult}`
        );
        });
      },
      //数据报表导出
      handleExportStatis() {
          let startTime = this.$route.query.startTime==undefined? '':this.$route.query.startTime;
          let endTime = this.$route.query.endTime==undefined? '':this.$route.query.endTime;
          let decisioDiagramResult = this.$route.query.decisioDiagramResult==undefined? '':this.$route.query.decisioDiagramResult;
          let timeDesc = this.$route.query.timeDesc==undefined? '':this.$route.query.timeDesc;
      let startTime =
        this.$route.query.startTime == undefined
          ? ""
          : this.$route.query.startTime;
      let endTime =
        this.$route.query.endTime == undefined ? "" : this.$route.query.endTime;
      let decisioDiagramResult =
        this.$route.query.decisioDiagramResult == undefined
          ? ""
          : this.$route.query.decisioDiagramResult;
      let timeDesc =
        this.$route.query.timeDesc == undefined
          ? ""
          : this.$route.query.timeDesc;
          //window.open(`http://localhost:8108/ureport/excel?_u=blade-parcel.statis.ureport.xml&startTime=${startTime}&endTime=${endTime}&decisioDiagramResult=${decisioDiagramResult}&timeDesc=${timeDesc}`);
          window.open(`https://web.byisf.com/api/blade-report/ureport/preview?_u=blade-parcel.statis.ureport.xml&startTime=${startTime}&endTime=${endTime}&decisioDiagramResult=${decisioDiagramResult}&timeDesc=${timeDesc}`);
      window.open(
        `https://web.byisf.com/api/blade-report/ureport/preview?_u=blade-parcel.statis.ureport.xml&startTime=${startTime}&endTime=${endTime}&decisioDiagramResult=${decisioDiagramResult}&timeDesc=${timeDesc}`
      );
      },
      onLoad(page, params={}) {
        const { dateTime } = this.query;
@@ -442,28 +499,41 @@
          ...params,
        };
        if (this.$route.query.decisioDiagramResult && this.$route.query!='' && this.$route.query!=null && this.$route.query!=undefined ) {
            if (this.$route.query.startTime != undefined && this.$route.query.startTime != null && this.$route.query.startTime != "" ) {
      if (
        this.$route.query.decisioDiagramResult &&
        this.$route.query != "" &&
        this.$route.query != null &&
        this.$route.query != undefined
      ) {
        if (
          this.$route.query.startTime != undefined &&
          this.$route.query.startTime != null &&
          this.$route.query.startTime != ""
        ) {
              this.page.currentPage = 1;
              params = {
                startTime:this.$route.query.startTime,
                endTime:this.$route.query.endTime,
                decisioDiagramResult:this.$route.query.decisioDiagramResult
              }
            decisioDiagramResult: this.$route.query.decisioDiagramResult,
          };
            } else {
              this.page.currentPage = 1;
              params = {
                decisioDiagramResult:this.$route.query.decisioDiagramResult
            decisioDiagramResult: this.$route.query.decisioDiagramResult,
              };
            }
            this.activeClass=4;
        }else{
            if (this.$route.query.startTime != undefined && this.$route.query.startTime != null && this.$route.query.startTime != "" ) {
        if (
          this.$route.query.startTime != undefined &&
          this.$route.query.startTime != null &&
          this.$route.query.startTime != ""
        ) {
              this.page.currentPage = 1;
              params = {
                startTime:this.$route.query.startTime,
                endTime:this.$route.query.endTime
              }
            endTime: this.$route.query.endTime,
          };
              this.activeClass=4;
            }
@@ -474,13 +544,16 @@
              //年
              var Y = date.getFullYear();
              //月
              var M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
          var M =
            date.getMonth() + 1 < 10
              ? "0" + (date.getMonth() + 1)
              : date.getMonth() + 1;
              //日
              var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
              params = {
                startTime:Y + "-" + M + "-" + D + " 00:00:00",
                endTime:Y +"-" +M +"-" + D +  " 23:59:59"
              }
            endTime: Y + "-" + M + "-" + D + " 23:59:59",
          };
            }
        }
@@ -497,10 +570,9 @@
            ...params,
            ...this.query,
          };
        }
        this.loading = true;
        getList(page.currentPage, page.pageSize,values).then(res => {
      getList(page.currentPage, page.pageSize, values).then((res) => {
          const data = res.data.data;
          this.page.total = data.totalSize;
          this.data = data.data;
@@ -510,9 +582,9 @@
      },
      // 关闭查看器
      closeViewer() {
        this.showViewer = false
      }
    }
      this.showViewer = false;
    },
  },
  };
</script>
<style lang="scss">