// 运输路线
<template>
  <div class="steel_inbound">
    <div class="top">
      <!-- 框计算 -->
      <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="AddClick">
        <i class="el-icon-plus"></i>新增
      </el-button>
    </div>
    <div class="tab">
      <dilTable v-bind.sync="option">
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="mini"
              @click="transitRouteUpdata(scope.row.lineId)"
              >修改</el-button
            >
            <el-button
              size="mini"
              type="text"
              @click="transitRouteDelete(scope.row.lineId)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </dilTable>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 框计算的输入框的值
      inputText: "",
      // 表格渲染的表头及数据
      option: {
        requestUrl: "/api/v1/rms/getAllLineDesk?apiId=249",
      },
      countNumber: 0,
    };
  },
  methods: {
    initialization(lineId, num) {
      this.axios
        .post("/api/v1/rms/getCountNumber?lineId=" + lineId)
        .then((res) => {
          if (res.data.code == "200") {
            if (res.data.data > 0) {
              this.$message({
                showClose: true,
                message: "此路线已经和运输订单关联，不能进行修改！",
                type: "warning",
              });
            } else {
              if (num == 2) {
                this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                })
                  .then(() => {
                    this.axios
                      .post("/api/v1/rms/updateRmsLine", { lineId: lineId })
                      .then((res) => {
                        if ((res.data.code = "200")) {
                          this.$message({
                            type: "success",
                            message: "删除成功!",
                          });
                          this.$router.go(0);
                        }
                      });
                  })
                  .catch(() => {
                    this.$message({
                      type: "info",
                      message: "已取消删除",
                    });
                  });
              } else if (num == 1) {
                this.$router.push({
                  path: "/transitRouteAdd/" + lineId,
                });
              }
            }
          }
        });
    },
    // 框计算查询按钮
    onclick() {
      this.option.requestUrl =
        "/api/v1/rms/getAllLineDesk?apiId=249&con=" + this.inputText;
    },
    // 跳转新增运输路线页面
    AddClick() {
      this.$router.push({
        path: "/transitRouteAdd/0",
      });
    },
    //跳转修改界面
    transitRouteUpdata(lineId) {
      this.initialization(lineId, 1);
    },
    //删除本条运输路线
    transitRouteDelete(lineId) {
      this.initialization(lineId, 2);
    },
  },
};
</script>

<style lang="scss" scoped>
.transitRoute {
  .top {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    padding-left: 60px;
  }
}
</style>

<style lang="scss" scode>
.steel_inbound{
  .top{
    display: flex;
    width: 30%;
  }
}

</style>