// 制定发运计划
<template>
	<div class="steel_inbound">
		<div class="sache">
			<el-input placeholder="请输入内容" v-model="inputText" clearable>
			</el-input>
			<el-button type="primary" class="btn">
				<i class="el-icon-search"></i>查询
			</el-button>
			<el-button type="primary" class="btn" @click="Issue" v-if="activeName == 'second'">
				<i class="el-icon-download"></i>下发
			</el-button>
		</div>
		<template>
			<div>
				<el-tabs v-model="activeName" @tab-click="handleClick">
					<el-tab-pane label="未下发" name="second">
						<dilTable v-bind.sync="second" @selection-change="selectionChange">
						</dilTable>
					</el-tab-pane>
					<el-tab-pane label="已下发" name="third">
						<dilTable v-bind.sync="third">
						</dilTable>
					</el-tab-pane>
				</el-tabs>
			</div>
		</template>
	</div>
</template>
<script>
	export default {
		data() {
			return {
				inputText: "",
				second: {
					// second请求数据的地址
					requestUrl: "/api/v1/ams/getRailOffsetDayplan?apiId=183&dayplanReceiveStatus=0",
					selectionType: "select",
					mapList: [],
				},
				third: {
					// second请求数据的地址
					requestUrl: "/api/v1/ams/getRailOffsetDayplan?apiId=183&dayplanReceiveStatus=1",
				},
				activeName: "second",
			}
		},
		methods: {
			receiver(scope){
				this.$confirm("是否接收", "提示", {
						confirmButtonText: "确定",
						cancelButtonText: "取消",
						type: "warning",
						center: true,
					})
					.then(() => {
						this.$axios
							.post("/api/v1/ams/receiveRequirement/" + scope.row.requirementId)
							.then((res) => {
								this.$router.go(0);
								if (res.data.code == 200) {
									this.$message({
										type: "success",
										message: "接收成功!",
									});
									
									
								} else {
									this.$message({
										message: "接收失败",
										type: "warning",
									});
								}
							});
					})
					.catch(() => {
						this.$message({
							type: "info",
							message: "接收操作已取消!",
						});
					});
			},
			selectionChange(selection) {
				this.second.mapList = selection
			},
			toInsert() {
				this.$router.push("/addPlan");
			},
			updatePlan(scope) {
				this.$router.push("/updatePlan/" + scope.row.planId)
			},
			deletePlan(scope) {
				this.$confirm("是否删除", "提示", {
						confirmButtonText: "确定",
						cancelButtonText: "取消",
						type: "warning",
						center: true,
					})
					.then(() => {
						this.$axios
							.post("/api/v1/ams//deleteTruckPlan/" + scope.row.planId)
							.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: "删除操作已取消!",
						});
					});
			},
			Issue() {
				console.log(this.second.mapList)
				this.$confirm("是否下发", "提示", {
						confirmButtonText: "确定",
						cancelButtonText: "取消",
						type: "warning",
						center: true,
					})
					.then(() => {
						this.$axios
							.post("/api/v1/ams/issueRailOffsetDayplan", this.second.mapList)
							.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: "取消下发!",
						});
					});
			},

    // },
    receiver(scope) {
      this.$confirm("是否接收", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.$axios
            .post("/api/v1/ams/receiveRequirement/" + scope.row.requirementId)
            .then((res) => {
              this.$router.go(0);
              if (res.data.code == 200) {
                this.$message({
                  type: "success",
                  message: "接收成功!",
                });
              } else {
                this.$message({
                  message: "接收失败",
                  type: "warning",
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "接收操作已取消!",
          });
        });
    },
    selectionChange(selection) {
      this.second.mapList = selection;
    },
    deletePlan(scope) {
      this.$confirm("是否删除", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.$axios
            .post("/api/v1/ams//deleteTruckPlan/" + scope.row.planId)
            .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: "删除操作已取消!",
          });
        });
    },
    Issue() {
      console.log(this.second.mapList);
      this.$confirm("是否下发", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.$axios
            .post("/api/v1/ams/issueRailOffsetDayplan", this.second.mapList)
            .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">
.steel_inbound {
  .sache {
    height: 5rem;
    display: flex;
    align-items: center;
    padding-left: 1.875rem;
  }
}
</style>
