<template>
    <a-modal title="延期处理" :visible="childShow" @ok="delayOk " @cancel="delayCancel" :width=500
        :body-style="{width:200}">
        <a-row>
            <a-col span="4"><span style="color: tomato;">*</span>延期:</a-col>
            <a-col span="20">
                <a-date-picker showTime valueFormat="YYYY-MM-DD HH:mm:ss" :disabledDate="disabledDate"
                    v-model="delayParam.delayDate" />
            </a-col>
        </a-row>
        <a-row style="margin-top:20px">
            <a-col span="4">无效原因:</a-col>
            <a-col span="20">
                <a-textarea type="textarea" v-model="delayParam.remarks" :rows="5" />
            </a-col>
        </a-row>
    </a-modal>
</template>
<script>

import { postAction } from '@/api/manage'
import moment from 'moment'
import store from '@/store'
export default {
    name: 'CustomerBusinessDelay',
    data() {
        return {
            delayParam: {},
        }
    },
    props: ['childShow', 'para'],
    watch: {
        immediate: true,
        childShow: {
            handler() {
                this.delayParam = this.para;
            },
        }
    },
    methods: {
        disabledDate(current) {
            return current < moment().subtract(1,'day');// 当前时间之前的所有日期都禁用
        },
        delayOk() {
            if (this.delayParam.delayDate === null || this.delayParam.delayDate === "" || this.delayParam.delayDate === undefined) {
                this.$message.warn('请选择延期日期');
                return
            } else {
                this.delayParam.status = '3';
                this.delayParam.delayNum = Number(this.delayParam.delayNum) + 1;
                this.delayParam.createBy = store.getters.userInfo.id;
                postAction("/customer/customerBusiness/edit", this.delayParam).then((res) => {
                    if (res.success) {
                        this.$message.success('编辑成功');
                        this.$emit('childReturn',false);
                    }
                });
            }
        },
        delayCancel() {
            this.$emit('childReturn',false);
        },
    }
}
</script>
  