<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">
      <dilTable v-bind.sync="options">
        <el-table-column fixed="right" label="操作" width="180">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="add(scope)" style="margin:10px">
              复制新增
            </el-button>
            <el-button type="text" size="small" @click="update(scope)" style="margin:10px">
              修改
            </el-button>
            <el-button type="text" size="mini" @click="deleteOne(scope)" style="margin:10px">
              删除
            </el-button>
          </template>
        </el-table-column>
      </dilTable>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      inputText: "",
      options: {
        // first请求数据的地址
        requestUrl: "/api/v1/rms/selectbmsshipContractPriceList?apiId=500",
      },
    };
  },
  methods: {
    //查询
    onclick() {
      this.options.requestUrl =
        "/api/v1/rms/selectbmsshipContractPriceList?apiId=500&con=" + this.inputText;
    },
    //新增
    toInsert() {
      this.$router.push("/addContractPrice");
    },
    update(scope) {
      console.log(scope.row.resultId);
      this.$router.push("/editContractPrice/" + scope.row.resultId);
    },
    //复制新增
    add(scope) {
      console.log(scope.row);
      this.$router.push("/addContractPrice?contractNo="+scope.row.contractNo
      +"&portId="+scope.row.portId
      +"&unitPrice="+scope.row.unitPrice
      +"&startTime="+scope.row.startTime
      +"&endTime="+scope.row.endTime);
    },
    showCarrier(scope) {
      console.log(scope.row.resultId);
      this.$router.push("/showContractPrice/" + 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/rms/deleteBmsshipContractPrice",map)
            .then((res) => {
              if (res.data.code == 200) {
                this.$message({
                  type: "success",
                  message: "删除成功!",
                });
                this.$router.go(0);
              } else {
                this.$message({
                  message: "删除失败",
                  type: "warning",
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "删除操作已取消!",
          });
        });
    },
  },
};
</script>

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