<template>
    <Modal v-model="modals"  scrollable title="请输入发货快递单号"  class="order_box" :closable="false">
        <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="100" @submit.native.prevent>
			<FormItem label="快递单号：" prop="express_num">
			    <Input v-model="formValidate.express_num" type="text" placeholder="快递单号" style="width: 100%" />
			</FormItem>
            <FormItem label="备注：" prop="remark">
                <Input v-model="formValidate.remark" maxlength="200" show-word-limit type="textarea" placeholder="订单备注" style="width: 100%" />
            </FormItem>
        </Form>
        <div slot="footer">
            <Button  type="primary"  @click="putRemark('formValidate')">提交</Button>
            <Button   @click="cancel('formValidate')">取消</Button>
        </div>
    </Modal>
</template>

<script>
    import {SystemOrderFahuo} from "../../../../api/system/order";

    export default {
        name: 'orderFahuo',
        data () {
            return {
                formValidate: {
                    remark: '',
					express_num:'',
                },
                modals: false,
                ruleValidate: {
					express_num: [
					    { required: true, message: '请输入快递单号', trigger: 'blur' }
					],
                }
            }
        },
        props: {
            orderId: Number
        },
        methods: {
            cancel (name) {
                this.modals = false;
                this.$refs[name].resetFields();
            },
            putRemark (name) {
                let data = {
                    id: this.orderId,
                    ...this.formValidate
                }
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        SystemOrderFahuo(data)
                            .then(res => {
                                if(res.code == 200) {
                                    this.$Message.success(res.msg);
                                    this.modals = false;
                                    this.$refs[name].resetFields();
                                    this.$emit('submitFail')
                                } else {
                                    this.$Message.error(res.msg);
                                }
                        }).catch(res => {
                            this.$Message.error(res.msg);
                        })
                    } else {
                        this.$Message.warning('请输入快递单号');
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>
