@model Angel.Models.AdminUser
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_LayoutForm.cshtml";
}

<style type="text/css">
    .fr {
        float: right;
    }

    .img-headshot {
        width: 90px;
        height: 90px;
        position: absolute;
        top: -30px;
        border: medium none;
        border-radius: 50%;
        cursor: pointer;
    }
</style>
<form class="layui-form layui-form-pane angel-form" lay-filter="formTest">

    <input data-val="true"  id="ManageID" name="ManageID" type="hidden" value="0" />
    <div class="layui-form-item">
        <label class="layui-form-label">管理员</label>
        <div class="layui-input-block">
            <input type="text" name="ManageName" placeholder="账号" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" name="ManagePwd" placeholder="密码" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>

  
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use(["form", "laydate", "angelLayer", "angelUtils", "upload", "layer"], function () {
        let form = layui.form;
        let laydate = layui.laydate;
        let angelLayer = layui.angelLayer;
        let angelUtils = layui.angelUtils;
        let upload = layui.upload;
        let layer = layui.layer;
        let $ = layui.$;

        //给表单赋值
        form.val("formTest", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
            "ManageName": "@Model.ManageName",
            "ManagePwd": "@Model.ManagePwd",
            "ManageID": "@Model.ManageID",
        });
        form.render(); //更新全部
        form.on("submit(add)", function (data) {
           // debugger;
          //  console.log(dasta.field);
            angelUtils.ajax("api/amanagerapi/postedit", "post", data.field, true).done(function (response) {
                angelLayer.greenTickMsg(response.message, function () {
                    parent.location.reload(); // 父页面刷新
                    parent.layer.close(parent.layer.getFrameIndex(window.name));//先得到当前iframe层的索引 再执行关闭
                });
            }).fail(function (error) {
                console.log(error)
            });
            return false;
        });
    });
</script>

