<template>
    <el-dialog :title="title" visible :before-close="closeDialog" :close-on-click-modal="false">
      <el-form v-if="agreement"  ref="elForm" :model="formData" size="small" label-width="100px" >
        <el-form-item :label="$t('订单号')" prop="field101">
            {{order.orderNo}}
        </el-form-item>

        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('收货人')" prop="field104">
              {{info.consigneeName}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('收货人电话')" prop="field103">
             +{{info.consigneeCountryCode}} {{info.consigneePhone}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item :label="$t('总控货箱数')" prop="field105">
            {{order.sumNum}}
        </el-form-item>

        <el-form-item :label="$t('原放货箱数')" prop="field106">
            {{info.pickNum}}
        </el-form-item>

        <el-form-item :label="$t('现放货箱数')" prop="field106">
            <el-input v-model="formData.currentPickNum" placeholder=""></el-input>
        </el-form-item>

         <el-form-item :label="$t('备注')" prop="field106">
            <el-input v-model="formData.remarks" placeholder=""></el-input>
        </el-form-item>

         <el-form-item :label="$t('控货手机号')" prop="field106">
            +{{info.countryCode}} {{info.phone}}
        </el-form-item>
        <el-form-item :label="$t('手机验证码')" prop="field106">
            <el-input v-model="formData.code" placeholder="" style="width: 100px; margin-right:10px"></el-input>
            <send-sms-code :order-id="order.orderId" :scene="5" />
        </el-form-item>
        <div class="title">{{$t('审批流程')}}</div>
        <work-flow xmlkey="release_goods" v-model="ccIdArr"  />
        <el-form-item label="">
            <el-button type="primary" @click="submit">{{$t('提交申请')}}</el-button>
            <el-button @click="closeDialog">{{$t('关闭')}}</el-button>
        </el-form-item>
      </el-form>

      <div v-else>
          <need-know keyname="control" />
          <div style="margin-top:30px">
              <el-button type="primary" @click="agreement=true">{{$t('我同意')}}</el-button>
              <el-button @click="closeDialog">{{$t('关闭')}}</el-button>
          </div>
      </div>
    </el-dialog>
</template>
<script>
import WorkFlow from '@/components/WorkFlow'
import NeedKnow from '@/components/NeedKnow'
import SendSmsCode from '@/views/ecw/order/components/SendSmsCode'
import {updateApply} from '@/api/ecw/orderCargoControl'
export default {
    props:{
        orderId: [String, Number],
        order: Object,
        index: Number
    },
    components: {NeedKnow, WorkFlow, SendSmsCode},
    data(){
        return {
            show: false,
            ccIdArr:[],
            formData:{
                applyType: 7, // 放货修改
                ccIds: ''
            },
            agreement: false, // 是否同意协议
        }
    },
    computed:{
        title(){
            let t = this.$t('放货修改')
            return t
        },
        info(){
            return this.order.cargoControlPickBackVOList[this.index]
        }
    },
    watch:{
        ccIdArr(val){
            this.$set(this.formData, 'ccIds', val.join(','))
        }
    },
    created(){
        this.show = true
        /* this.loadData() */
    },
    methods:{
        /* loadData(){

        }, */
        closeDialog(){
            this.show = false
            this.$emit('close');
        },
        submit(){
            let data = Object.assign({}, this.formData, {
                cargoControlPickId: this.info.id,
                
                orderId: this.order.orderId,
                orderNo: this.order.orderNo
            })
            updateApply(data).then(res => {
                this.$message.success(this.$t('修改成功'))
                this.show = false
                this.$emit('success')
            })
        }

    }
}
</script>
<style lang="scss" scoped>
.title{
  font-size:16px;
  margin:20px 0;
  display:flex;
  align-items:center;
  &:before{
    content: '';
    width:5px;
    height: 15px;
    background:#666;
    margin-right:10px;
  }
}
</style>
