//分派运单
<template>
	<div class="steel_inbound">
		<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>
		</div>
		<div class="table">
			<dilTable v-bind.sync="first">
				<el-table-column label="操作" fixed="right" width="120">
					<template slot-scope="scope">
						<el-button @click="handleBtnClick1() ,handleBtnClick2(scope)" type="primary" >
							下发
						</el-button>
					</template>
				</el-table-column>
			</dilTable>
			<el-drawer title="司机排班信息表" :visible.sync="drawer" :direction="direction" :before-close="handleClose"
				:modal="false" size="50%" style="margin-top: 6.625rem;">
				<dilTable v-bind.sync="second" v-model="table1" @radio-change="currentRadioChange"></dilTable>
				<div class="button-box">
					<el-button type="primary" @click="makeSure">确认</el-button>
					<el-button type="primary" @click="cancel">取消</el-button>
				</div>
			</el-drawer>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				inputText: "",
				drawer: false,
				direction: 'rtl',
				orderType:1,
				saleOrdermaterialId:0,
				personnelId:1,
				first: {
					// first请求数据的地址
					requestUrl: "api/v1/oms/getSaleOrderForCarrierList/1?apiId=168",

				},
				second: {
					requestUrl: "/api/v1/truckTms/omstruckorders/getCapacityForLeisure?apiId=186",
					selectionType: "radio",
					mapList: []
				},
				
			}
		},
		methods: {
			handleBtnClick1(){
				this.drawer=true
			},
			handleBtnClick2(scope){
				this.saleOrdermaterialId=scope.row.saleOrdermaterialId;
				console.log(this.saleOrdermaterialId)
			},			
			currentRadioChange(selection) {
				this.mapList = selection
			},
			makeSure(){
				console.log(this.saleOrdermaterialId)
				let map={
					orderType:this.orderType,
					personnelId:this.personnelId,
					saleOrdermaterialId:this.saleOrdermaterialId,
					capacityId:this.mapList.capacityId					
				}
				this.axios.post("http://192.168.0.107:8088/api/v1/truckTms/omstruckorders/addPurOrder",map)
				    .then((res) => {
						console.log(res)
				      if (res.data.code == 200) {
				        this.$message({
				          type: "success",
				          message: "下发成功!",
				        });     
				        this.$router.go(-1);
				      } else {
				        this.$message({
				          message: "下发失败",
				          type: "warning",
				        });
				      }
				})			
			},			
			handleClose(done) {
				this.$confirm('确认关闭？')
					.then(_ => {
						done();
					})
					.catch(_ => {});
			},
			onclick() {
				console.log("点击事件");
			}
		}
	}
</script>

<style lang="scss" scode>
.form-box{
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 5px;
  margin-bottom: 20px;
}
.button-box{
  display: flex;
  text-align: center;
  align-items: center;
  justify-content: center;
  margin-top: 0.3125rem;
  margin-bottom: 1.25rem;
}
	.steel_inbound {
		.sache {
			padding: 1.25rem 0.375rem;
			.el-input {
			width: 20%;
			margin-right: 1.25rem;
			}
		}
	}
	
</style>