<template>
  <!-- 二程船水运费 -->
  <div class="contract_price">
    <div class="sache">
      <el-input placeholder="请输入内容" v-model="inputText" clearable>
      </el-input>
      <el-button type="primary" class="btn" @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
      <el-button type="primary" class="btn" @click="toInsert">
        <i class="el-icon-plus"></i>新增
      </el-button>
    </div>
    <div class="table">
      <mergeRowTable v-bind.sync="options">
        <el-table-column fixed="right" label="操作" width="100">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="update(scope)">
              修改
            </el-button>
            <el-button type="text" size="mini" @click="deleteOne(scope)">
              删除
            </el-button>
            <el-button
              @click="toPhotoClick(scope.row.resultId)"
              type="text"
              size="small"
            >
              水运单图片
            </el-button>
          </template>
        </el-table-column>
      </mergeRowTable>
    </div>
    <vxe-modal width="549px" height="731px" v-model="isShow" show-footer>
      <div class="demo-image__preview">
        <el-image
          style=" height:731px;text-align:center"
          :src="src"
          :preview-src-list="srcList"
        >
        </el-image>
      </div>
    </vxe-modal>
  </div>
</template>

<script>
export default {
  data() {
    return {
      inputText: "",
      isShow: false,
      options: {
        // first请求数据的地址
        requestUrl: "/api/v1/bms/selectPortFeeSecondList?apiId=506&feeType=3",
        comparison:"resultForeignShipName",
        columnIndexs:[0,1,2,3]
      }
    };
  },
  methods: {
    getRequestUrl() {
      this.options.requestUrl =
        "/api/v1/bms/selectPortFeeSecondList?apiId=506&feeType=3&i=" +
        new Date();
    },
    //查询
    onclick() {
      this.options.requestUrl =
        "/api/v1/bms/selectPortFeeSecondList?apiId=506&feeType=3&con=" +
        this.inputText;
    },
    //新增
    toInsert() {
      this.$router.push("/addThreeSectionFee");
    },
    update(scope) {
      console.log(scope.row.resultId);
      this.$router.push("/editThreeSectionFee/" + scope.row.resultId);
    },
    showCarrier(scope) {
      console.log(scope.row.resultId);
      this.$router.push("/showTwoSectionFee/" + scope.row.resultId);
    },
    deleteOne(scope) {
      this.$confirm("是否删除", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true
      })
        .then(() => {
          let map = {
            resultId: scope.row.resultId
          };
          this.axios
            .post(
              "/api/v1/bms/deletePortHandlingFeeSecond/" + scope.row.resultId
            )
            .then(res => {
              if (res.data.code == 200) {
                this.$message({
                  type: "success",
                  message: "删除成功!"
                });
                this.getRequestUrl();
              } else {
                this.$message({
                  message: "删除失败",
                  type: "warning"
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "删除操作已取消!"
          });
        });
    },
    toPhotoClick(resultId) {
      this.axios
        .post("/api/v1/bms/downloadBmsshipOrder?resultId=" + resultId)
        .then(res => {
          console.log("res", res.data.data);
          this.srcList = [];
          this.src = res.data.data;
          this.isShow = true;
          this.srcList.push(res.data.data);
        });
    }
  }
};
</script>

<style lang="scss" scode>
.contract_price {
  .sache {
    padding: 1.25rem 0.375rem;
    .el-input {
      width: 20%;
      margin-right: 1.25rem;
    }
  }
}
</style>
