<template>
  <!-- 展示万州港港存库库存列表 -->
  <div class="homeworkPath">
    <div class="top">
      <el-input
        v-model="input"
        placeholder="请输入物资名称或者外轮船名"
        style="width: 260px"
        clearable
      ></el-input>
      <el-button type="primary" class="btn" @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
      <div class="totalNumber" style="margin-left:10px">
      <span
        style="
          color: IndianRed;
          font-family: FANGSONG;
          font-size: 15px;
          font-weight: bold;
        "
        >万州港合计吨位</span
      >
      <el-input
        v-model="totalNumber"
        :disabled="true"
        style="width: 120px"
      ></el-input>
      <el-button style="margin-left: 12px" type="primary" @click="exportData()"
        ><i class="el-icon-download"></i>导出Excel</el-button
      >
      <el-button type="primary" @click="refresh">
        <i class="el-icon-refresh"></i>
      </el-button>
      </div>
    </div>
    
    <!-- <span
      class="el-input"
      style="
        color: red;
        margin-left: 45%;
        font-family: FANGSONG;
        font-size: 20px;
        font-weight: bold;
      "
      >万州港实时库存详情</span
    > -->
    <mergeRowTable
      ref="excelDom"
      v-bind.sync="option"
      :isHeigth="isHeigth"
      :shiyHeigth="shiyHeigth"
      @func="func"
      :pageSize="pageSize"
    >
    </mergeRowTable>
  </div>
</template>

<script>
export default {
  name: "homeworkPath",
  data() {
    return {
      tableTitle: "万州港港存库物资明细报表",
      shiyHeigth: 130,
      isHeigth: true,
      input: null,
      text: null,
      pageSize: 1000,
      state: "",
      //合计净重
      totalNumber: 0,
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/wmsh/getLoadPortStockList?apiId=158",
        comparison:"materialName",
        columnIndexs:[0,1,2,3]
      },
      option2: {
        requestUrl: "/api/v1/wmsh/getLoadPortStockByMaterialName?apiId=493",
      },
    };
  },
  created() {
    this.option.requestUrl =
      "/api/v1/wmsh/getLoadPortStockList?apiId=158&i=" + new Date();
  },
  methods: {
    func(res) {
      console.log("aaa" + res);
      var resultActualInstallations = 0;
      res.list.forEach((e) => {
        resultActualInstallations = resultActualInstallations + e.gmTonnage;
      });
      this.totalNumber = resultActualInstallations.toFixed(2) + " 吨";
    },
    // 点击查询查看
    onclick() {
      this.option.requestUrl =
        "/api/v1/wmsh/getLoadPortStockList?apiId=158&i=" +
        new Date() +
        "&con=" +
        this.input;
    },
    onclick1() {
      this.option2.requestUrl =
        "/api/v1/wmsh/getLoadPortStockByMaterialName?apiId=493&i=" +
        new Date() +
        "&con=" +
        this.text;
    },
    refresh() {
      this.$router.go(0);
    },
  },
};
</script>
<style lang='scss' scoped>
.homeworkPath {
  .top {
    padding: 1.25rem 0.375rem;
    display: flex;
    .my-autocomplete {
      width: 20%;
      margin-right: 40rpx;
    }
  }
}
</style>