include /mixins/dic.mixin.pug

.uk-layui-form
    form.layui-form(action='/apps/contacts/update.html', method='post')
        input(type='hidden', name='id', value=contacts.id)
        input(type='hidden', name='ckindId', value=ckindId)
        input(type='hidden', name='wluid', value=contacts.wluid)
        input(type='hidden', name='wlusername', value=contacts.wlusername)
        input(type='hidden', name='wlcid', value=contacts.wlcid)
        input(type='hidden', name='wlcompany_name', value=contacts.wlcompany_name)
        input(type='hidden', name='wlsid', value=contacts.wlsid)
        input(type='hidden', name='wlsystem_name', value=contacts.wlsystem_name)
        input(type='hidden', name='shares', value='all')
        .layui-collapse
            .layui-colla-item
                h2.layui-colla-title 基本信息
                .layui-colla-content.layui-show
                    .layui-form-item
                        .layui-inline
                            label.layui-form-label 获得时间：
                            .layui-input-inline
                                input#getdate.layui-input(type='text', name='touchtime', value=(contacts.touchtime ? pugHelper.formatDate('yyyy-MM-dd', contacts.touchtime) : ""), readonly, lay-verify='date', autocomplete='off')
                                i.layui-icon(style='position: absolute;right: 3px;top: 6px;font-size: 25px;') 
                        .layui-inline
                            font(color='red') *（必填项）
                            |  (您得到此联系人的时间)
                        .layui-inline
                            label.layui-form-label(style='width:60px;line-height: 35px;') 类型：
                            .layui-input-inline(style='width:218px;margin-right:0px;padding-top:9px;')
                                if contacts.ckind && contacts.ckind != ''
                                    +sysDicSelect('com.dic.contacts.ckind', 'ckind', contacts.ckind, {
                                        'lay-ignore': true,
                                        'required': required,
                                        'lay-verify': 'required'
                                    })
                                else
                                    +sysDicSelect('com.dic.contacts.ckind', 'ckind', '', {'lay-ignore': true})
            .layui-colla-item
                h2.layui-colla-title 联系人信息
                .layui-colla-content.layui-show
                    .layui-form-item
                        .layui-inline
                            label.layui-form-label#cusname 联系人名称：
                            .layui-input-inline
                                input.layui-input(type='text', name='name', value= contacts.name, required, lay-verify='required', autocomplete='off')
                        .layui-inline
                            font(color='red') *（必填项）
                    .layui-form-item
                        .layui-inline
                            label.layui-form-label 性别：
                            .layui-input-inline
                                .layui-input-block(style='width:220px;')
                                    input(type="radio", name="gender", value="1", title="男", checked= (contacts && contacts.gender == '1'))
                                    input(type="radio", name="gender", value="0", title="女", checked= (contacts && contacts.gender == '0'))
                                    input(type="radio", name="gender", value="-1", title="未知", checked= (contacts.gender != '1' && contacts.gender != '0'))
                        .layui-inline.uckefu-inline
                            label.layui-form-label 生日：
                            .layui-input-inline
                                input#cusbirthday.layui-input(type='text', name='cusbirthday', value=contacts.cusbirthday, autocomplete='off')
                                i.layui-icon(style='position: absolute;right: 3px;top: 6px;font-size: 25px;') 
                    .layui-form-item
                        .layui-inline
                            label.layui-form-label 联系电话：
                            .layui-input-inline
                                input.layui-input(type='text', name='phone', value= contacts.phone, autocomplete='off')
                        .layui-inline.uckefu-inline
                            label.layui-form-label 手机号：
                            .layui-input-inline
                                input.layui-input(type='text', name='mobileno', value= contacts.mobileno, autocomplete='off')
                    .layui-form-item
                        .layui-inline
                            label.layui-form-label 城市：
                            .layui-input-inline(style='width: 80px;')
                                +sysDicSelect("com.dic.address.area", "province", contacts.province, {'lay-ignore': true}, "width:85px;")
                        .layui-inline
                            .layui-input-inline#contacts_city(style='width: 80px;')
                                +sysDicSelect(contacts.city + '.subdic', "city",contacts.city, {'lay-ignore': true}, "width:86px;")
                        .layui-inline.uckefu-inline
                            label.layui-form-label 电子邮件：
                            .layui-input-inline(style='margin-left:5px;')
                                input.layui-input(type='text', name='email', lay-verify='entemail', value= contacts.email, autocomplete='off')
                    .layui-form-item
                        .layui-inline
                            label.layui-form-label#contacts_skypeid(style='widht:80px;') skypeID:
                            .layui-input-inline
                                input.layui-input(type='text', name='skypeid', lay-verify='skypeid', autocomplete, value= contacts.skypeid)
                    .layui-form-item
                        .layui-inline
                            label.layui-form-label 联系人地址：
                            .layui-input-inline(style='width: 664px;')
                                input.layui-input(type='text', name='address', autocomplete='off', value= contacts.address)
                    .layui-form-item
                        .layui-inline
                            label.layui-form-label 联系人说明：
                            .layui-input-inline(style='width: 664px;')
                                textarea.layui-textarea(name='memo', placeholder='请输入内容', style='resize:none;') #{contacts.memo}
        .layui-form-button
            .layui-button-block
                button.layui-btn(lay-submit, lay-filter='formDemo') 立即提交
                button.layui-btn.layui-btn-original(type='reset') 重置
script.
    //Demo
    $('#province').change(function () {
        loadURL('/res/dic.html?id=' + $(this).val() + "&name=city&attr=lay-ignore&style=width:85px;", '#city');
    })

    layui.use('form', function () {
        var form = layui.form();
        form.render(); //更新全部
        form.verify({
            entemail: function (value) {
                if (value != "" && !new RegExp(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/).test(value)) {
                    return '请输入正确的电子邮箱地址';
                }
            },
            required: function (value) {
                if (value.length > 100) {
                    return '联系人名称不能超过100';
                }
            }
        });
    });

    layui.use('element', function () {
        var element = layui.element();
    });

    layui.use('laydate', function () {
        var laydate = layui.laydate;

        var date = {
            min: '1950-01-01 00:00:00',
            max: laydate.now(),
            istoday: false
        };

        document.getElementById('getdate').onclick = function () {
            date.elem = this;
            laydate(date);
        }

        document.getElementById('cusbirthday').onclick = function () {
            date.elem = this;
            laydate(date);
        }
    });

