<template>
    <a-modal title="编辑" :visible="childShow" @ok="editOk " @cancel="editCancel" :width=500
        :body-style="{width:200}">
        <a-row style="display: flex; align-items: center; margin-bottom: 10px;">
            <a-col span="4" style="text-align: right;"><span style="color: tomato; ">*</span>姓名:</a-col>
            <a-col span="1"></a-col>
            <a-col span="18">
                <a-input placeholder="请输入姓名" :key="666" v-model="editParamChild.name"></a-input>
            </a-col>
        </a-row>
        <a-row style="display: flex; align-items: center; margin-bottom: 10px;">
            <a-col span="4" style="text-align: right;">性别:</a-col>
            <a-col span="1"></a-col>
            <a-col span="18">
                <a-radio-group v-model="editParamChild.sex" placeholder="请选择机构类型">
                    <a-radio value="1">
                      男
                    </a-radio>
                    <a-radio value="2">
                      女
                    </a-radio>
                    <a-radio value=null>
                      未知
                    </a-radio>
                  </a-radio-group>
            </a-col>
        </a-row>
        <a-row style="display: flex; align-items: center; margin-bottom: 10px;">
            <a-col span="4" style="text-align: right;">年龄:</a-col>
            <a-col span="1"></a-col>
            <a-col span="8">
                <a-input :disabled="true" :value="age"></a-input>
            </a-col>
            <a-col span="1"></a-col>
            <a-col span="9">
                <a-date-picker placeholder="生日" valueFormat="YYYY-MM-DD" v-model="editParamChild.birthday" @change="handleDateChange" />
            </a-col>
        </a-row>
        <a-row style="display: flex; align-items: center; margin-bottom: 10px;">
            <a-col span="4" style="text-align: right;">家长:</a-col>
            <a-col span="1"></a-col>
            <a-col span="18">
                <a-input placeholder="请输入姓名" v-model="editParamChild.parents"></a-input>
            </a-col>
        </a-row>
        <a-row style="display: flex; align-items: center; margin-bottom: 10px;">
            <a-col span="4" style="text-align: right;"><span style="color: tomato;">*</span>联系方式:</a-col>
            <a-col span="1"></a-col>
            <a-col span="18">
                <a-input placeholder="请输入姓名" v-model="editParamChild.phone"></a-input>
            </a-col>
        </a-row>
        <a-row style="display: flex; align-items:flex-start; margin-bottom: 10px;">
            <a-col span="4" style="text-align: right;">备注:</a-col>
            <a-col span="1"></a-col>
            <a-col span="18">
                <a-textarea v-model="editParamChild.remarks" rows="4" placeholder="请输入跟进内容" />
            </a-col>
        </a-row>
    </a-modal>
</template>
<script>

import { postAction } from '@/api/manage'
import { getAge } from '../../../../utils/util';
export default {
    name: 'CustomerBusinessEdit',
    data() {
        return {
            editParamChild:{},
            age: 0,
        }
    },
    props: ['childShow', 'para'],
    watch: {
        immediate: true,
        childShow: {
            handler() {
                this.editParamChild = JSON.parse(JSON.stringify(this.para));
                if(this.editParamChild.birthday !== null && this.editParamChild.birthday !== "" && this.editParamChild.birthday !== undefined) {
                    this.age = getAge(this.editParamChild.birthday);
                }
            },
        }
    },
    methods: {
        editOk() {
            postAction("/customer/customerBusiness/edit", this.editParamChild).then((res) => {
          if(res.success) {
            this.$message.success('编辑成功');
            this.invalidVisiable = false;
            this.$emit('childReturn',false);
          }
        });
        },
        editCancel() {
            this.$emit('childReturn',false);
        },
        handleDateChange() {
            this.age = getAge(this.editParamChild.birthday);
        }
    }
}
</script>
  