<template>
    <el-dialog :title="title" visible :before-close="closeDialog" :close-on-click-modal="false">
      <el-form ref="form" :model="formData" :rules="rules" size="small" label-width="100px" >
        <el-form-item :label="$t('订单号')">
            {{order.orderNo}}
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('收货人')">
              {{info.consigneeName}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('收货人电话')">
             +{{info.consigneeCountryCode.replace(/\+/g, '')}} {{info.consigneePhone}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('总控货箱数')">
                {{order.sumNum}}
            </el-form-item>

          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('原放货箱数')">
                {{index == null ? order.releaseNum : info.pickNum}}
            </el-form-item>
          </el-col>
        </el-row>
        
        

        <el-form-item :label="$t('反复核原因')" prop="recurrentNuclearType">
            <dict-selector :type="DICT_TYPE.ECW_PICK_RECURRENT_NUCLEAR_TYPE" v-model="formData.recurrentNuclearType" form-type="radio" />
        </el-form-item>

        <el-form-item :label="$t('控货手机号')">
            <template v-if="index !== null">
                + {{info.countryCode}} {{info.phone}}
            </template>
            <template v-else>
              +{{order.cargoControlCountryCode}} {{order.cargoControlPhone}}
            </template>
           
        </el-form-item>
        <el-form-item :label="$t('手机验证码')" prop="code">
            <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>
    </el-dialog>
</template>
<script>
import WorkFlow from '@/components/WorkFlow'
import SendSmsCode from '@/views/ecw/order/components/SendSmsCode'
import {updateApply} from '@/api/ecw/orderCargoControl'
export default {
    props:{
        order: Object,
        index: Number
    },
    components: {WorkFlow, SendSmsCode},
    data(){
        return {
            show: false,
            ccIdArr:[],
            formData:{
                applyType: 8, //  放货反复核申请
                ccIds: ''
            },
            rules:{
                recurrentNuclearType: [{required: true, message: this.$t('请选择反复核原因')}],
                code: [{required: true, message: this.$t('请填写验证码')}]
            }
        }
    },
    computed:{
        title(){
            let t = this.$t('反复核')
            return t
        },
        info(){
            if(this.index !== null)
                return this.order.cargoControlPickBackVOList[this.index]
            return this.order
        }
    },
    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(){
            this.$refs.form.validate().then(res => {
                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>
