<template>

  <el-dialog
    :visible.sync="dialogVisible"
    :before-close="()=>{
      $parent.show = false;
    }"
    width="80%">
    <div style="padding: 0 20px">
      <h1>申请退仓-{{orderDetails.orderNo}}</h1>
      <el-divider></el-divider>
      <el-form label-width="150px">
        <el-form-item label="退仓原因">
          <el-input v-model="params.reason" style="width:500px" type="textarea"></el-input>
        </el-form-item>
      </el-form>
      <el-divider></el-divider>
      <h2>审批流程</h2>
      <div style="padding: 20px">
        <work-flow xmlkey="retired_warehouse" v-model="params.copyUserId"  />
      </div>
      <div>
        <el-button @click="submit" type="primary" style="margin-right: 20px;">确定退仓</el-button>
        <el-button @click="$parent.show = false;">不，再考虑考虑</el-button>
      </div>
    </div>
  </el-dialog>
</template>
<!--退仓-->
<script>
import {getOrder} from "@/api/ecw/order";
import {orderWarehouseInDelete} from "@/api/ecw/batchSingleApplication";
import workFlow from "@/components/WorkFlow";

export default {
  name: "withdrawal",
  props:{
    orderId:Number,
    dialogVisible:Boolean
  },
  components:{
    workFlow
  },
  data(){
    return {
      orderDetails:{},
      params:{
        orderId:undefined,
        orderNo:undefined,
        reason:'',
        copyUserId:[]
      },
    }
  },
  created() {
    getOrder(this.orderId).then(r => this.orderDetails = r.data);
  },
  methods:{
    submit(){
      this.params.orderId =  this.orderDetails.orderId;
      this.params.orderNo =this.orderDetails.orderNo;
      orderWarehouseInDelete(this.params).then(r => {
       if(r.code === 0){
         this.$message.success('退仓成功');
         this.params = {}
         this.$parent.show = false
       }
      })
    }
  }
}
</script>

<style scoped>

</style>
