<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>企业信息管理-查看供应商</title>
    <link rel="stylesheet" type="text/css" href="/css/external/fileUploadBase.css">
    <style>
        .btn-info:active,
        .btn-info:focus {
            background-color: #fff;
        }

        li.notcompanyli:hover {
            color: #333 !important;
        }

        .base-extend .newTabAddUpdateBox .enter .viewDetailWord {
            width: 0.35rem;
            text-align: center;
            top: 0.08rem;
            color: #333 !important;
            cursor: pointer;
            font-style: normal;
        }

        .error option, select.error {
            color: #333 !important;
        }

        .editLastRecord, .saveLastRecord {
            line-height: 0.2rem;
        }

    </style>
</head>
<body>
<div class="base-extend">
    <div class="addHeader">
        <ol class="breadcrumb" style="margin-top:0;">
            <i class="icon-chevron-sign-left newBackBtn"></i>
            <li>企业信息管理</li>
            <li>查看</li>
        </ol>
    </div>
    <div class="detailContentBox">

        <form class="form-horizontal" autocomplete="off">
            <div class="newTabAddUpdateBox" style="padding-top: 0;top: 0.6rem!important;bottom: 0rem">
                <input type="hidden" name="basicId" th:value="${detail?.id}">
                <div class="row">
                    <table>
                        <tr>
                            <td colspan="4">
                                <span class="detailContentBox-tabletitle">贸易综合平台账号</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">供应商名称：</td>
                            <td width="85%" style="background:#fff;" th:text="${detail?.enterpriseName}"></td>
                            <input type="hidden" name="socialCreditCode" th:value="${detail.socialCreditCode}">
                        </tr>
                        <tr>
                            <td width="15%">供应商账号：</td>
                            <td width="75%" class="enter">
                                <input type="text" name="account" maxlength="50" class="form-control" th:value="${detail?.account}" readonly>
                            </td>
                            <td width="10%" style="padding-top:0;padding-bottom:0;background-color: #fff;">
                                <div id="updateAccount" class="btn btn-default btn-white btn-info colorbtn" style="height:0.31rem;line-height:0.31rem;margin:0;">修改</div>
                                <div id="saveAccount" class="btn btn-default btn-white btn-info colorbtn" style="height:0.31rem;line-height:0.31rem;margin:0;display: none">保存</div>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">账号密码：</td>
                            <td width="75%" class="enter">
                                <input type="text" name="password" class="form-control" value="******" readonly>
                            </td>
                            <td width="10%" style="padding-top:0;padding-bottom:0;background-color: #fff;">
                                <div id="resetPwd" class="btn btn-default btn-white btn-info colorbtn" style="height:0.31rem;line-height:0.31rem;margin:0;">重置</div>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">认证链接：</td>
                            <td width="75%" class="enter" style="border-bottom: 1px solid #E8F0F3;">
                                <textarea class="form-control" style="resize:none;" name="authUrl" rows="4" readonly
                                          maxlength="5000" th:text="${detail?.shortAuthUrl}"></textarea>
                            </td>
                            <td width="10%" style="padding-top:0;padding-bottom:0;background-color: #fff;">
                                <div id="copyUrl" class="btn btn-default btn-white btn-info colorbtn" style="height:0.31rem;line-height:0.31rem;margin:0;">复制</div>
                            </td>
                        </tr>
                    </table>
                </div>

            </div>

        </form>

    </div>
</div>

</body>
<script>
    $(function () {

        //修改账号
        $("#updateAccount").click(function () {
            $("[name=account]").removeAttr('readOnly');
            $(this).hide();
            $("#saveAccount").show();
        })

        //保存账号
        $("#saveAccount").click(function () {
            if($("[name=account]").val() == '') {
                new $.zui.Messager('请输入账号', {
                    type: 'danger'
                }).show();
                return false;
            }
            $.ajax({
                url:'/customer/modifyAccount',
                type:'get',
                data:{
                    'id': $("[name=basicId]").val(),
                    'account':$('[name=account]').val(),
                    'supplier': 1
                },
                success:function(data){
                    if(data.success) {
                        new $.zui.Messager('保存成功', {
                            type: 'success'
                        }).show();
                        $("#saveAccount").hide();
                        $("#updateAccount").show();
                        $("[name=account]").attr('readOnly','readOnly');
                    }

                },
                error:function(status){
                    new $.zui.Messager('保存供应商账号时出错:'+status, {
                        type: 'danger'
                    }).show();
                }
            });
        })
        $("#resetPwd").click(function () {
            bootbox.confirm({
                title : '重置密码',
                message : '<div style="text-align:left;font-size:0.12rem">是否重置密码？</div>',
                size : 'small',
                buttons : {
                    cancel : {
                        label : '取消',
                        className:'btn-white btn-info'
                    },
                    confirm : {
                        label : '确定',
                        className:'btn-white btn-info colorbtn'
                    }
                },
                callback:function(result){
                    if (result) {
                        $.ajax({
                            url:'/customer/modifyPassword',
                            type:'get',
                            data:{
                                'id': $("[name=basicId]").val(),
                                'supplier': 1
                            },
                            success:function(data){
                                if( data.success ){
                                    new $.zui.Messager('重置成功。初始密码：a123456', {
                                        type: 'success'
                                    }).show();
                                    //$("[name=password]").val(data.data)
                                }else{
                                    new $.zui.Messager('重置请求失败:'+data.msg, {
                                        type: 'danger'
                                    }).show();
                                }
                            },
                            error:function(status){
                                new $.zui.Messager('重置时发生错误:'+status, {
                                    type: 'danger'
                                }).show();
                            }
                        })
                    };
                }
            })
        })
        $('#copyUrl').click(function () {
            $('[name=authUrl]').select();
            if(document.execCommand('copy')) {
                document.execCommand('copy');
                new $.zui.Messager('复制成功。', {
                    type: 'success'
                }).show();
            }
        })

        $(".newBackBtn").click(function () {
            $(".yk_rightcontent").load('/customer/listPage');
        })

    })

</script>
</html>
