<template>
  <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">
      <my-process-viewer  key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
    </div>
    <div>
      <el-button @click="submit" type="primary" style="margin-right: 20px;">确定退仓</el-button>
      <el-button @click="$router.push('/order/order')">不，再考虑考虑</el-button>
    </div>
  </div>
</template>
<!--退仓-->
<script>
import {getOrder} from "@/api/ecw/order";
import {orderWarehouseInDelete} from "@/api/ecw/batchSingleApplication";
import {getProcessDefinitionBpmnXMLByKey} from "@/api/bpm/definition";

export default {
  name: "withdrawal",
  props:{
    orderId:String
  },
  data(){
    return {
      orderDetails:{},
      bpmnXML: null,
      bpmnControlForm: {
        prefix: "activiti"
      },
      params:{
        orderId:undefined,
        orderNo:undefined,
        reason:'',
      }
    }
  },
  created() {
    getOrder(this.orderId).then(r => this.orderDetails = r.data);
    getProcessDefinitionBpmnXMLByKey("retired_warehouse").then(response => {
      this.bpmnXML = response.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('退仓成功');
       }
      })
    }
  }
}
</script>

<style scoped>

</style>
