<template>
  <!-- 内转汽运单价页面 -->
  <div class="salePlan">
    <div class="top">
      <el-input placeholder="请输入内容" v-model="input" clearable> </el-input>
      <el-button type="primary" class="btn" @click="onclick" :loading="loading">
        <i class="el-icon-search"></i>查询
      </el-button>
      <el-button type="primary" @click="btnclick(0)">
        <i class="el-icon-plus"></i>新增
      </el-button>
      <el-button type="primary" @click="exportData()"
        ><i class="el-icon-download"></i>导出(Excel)</el-button
      >
    </div>
    <div class="table">
      <el-tabs v-model="activeName">
        <!-- 正在启用 -->
        <el-tab-pane label="正在启用" name="first">
          <dilTable
            ref="excelDom"
            v-bind.sync="option"
            :loading="loading"
            :isKuang="isKuang"
            @func="func"
          >
            <el-table-column label="操作" width="120px" fixed="right">
              <template slot-scope="scope">
                <el-button type="text" @click="updatePriceMaterial(scope.row)">
                  修改价格物资
                </el-button>
              </template>
            </el-table-column>
          </dilTable>
        </el-tab-pane>
        <!-- 历史启用 -->
        <el-tab-pane label="历史启用" name="second">
          <dilTable
            v-bind.sync="option2"
            :loading="loading"
            :isKuang="isKuang"
            @func="func"
          >
          </dilTable>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>
<script>
export default {
  name: "TransportPrice",
  data() {
    return {
      activeName: "first",
      isKuang: false,
      loading: false,
      input: "",
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/ams/getInwardContractPrice?apiId=464&deleted=0"
      },
      option2: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/ams/getInwardContractPrice?apiId=464&deleted=1"
      },
      tableTitle: "汽运单价"
    };
  },
  methods: {
    updatePriceMaterial(row) {
      // 修改运价
      // console.log(row);
      // this.$router.push("/updateTransPrice/" +row);
      this.$router.push({ name: "updateTransPrice", query:{row:row||undefined}})
    },
    func() {
      this.loading = false;
      this.isKuang = false;
    },
    onclick() {
      this.loading = true;
      this.isKuang = true;
      if (this.input) {
        this.option.requestUrl =
          "/api/v1/ams/getInwardContractPrice?apiId=464&con=" + this.input;
      } else {
          this.option.requestUrl =
            "/api/v1/ams/getInwardContractPrice?apiId=464&deleted=0&i=" + new Date();
      }
    },
    btnclick() {
      this.$router.push("/inwardAddTransPrice");
    }
  }
};
</script>
<style lang="scss" scoped>
.salePlan {
  .top {
    margin-left: 20px;
    margin-top: 20px;
    .el-input {
      width: 20%;
      margin-right: 1.25rem;
    }
  }
  .table {
    margin-left: 20px;
    margin-top: 20px;
  }
}
</style>
