@model Micro.Wanter.Model.Salary
@{
    ViewBag.Title = "Edit";
    Layout = null;
}
<link href="~/Scripts/Plugin/kindeditor-4.1.10/themes/default/default.css" rel="stylesheet" />
<link href="~/Scripts/Plugin/layui-v2.2.5/layui/css/layui.css" rel="stylesheet" />
<link href="~/Scripts/Plugin/layui-v2.2.5/layui/css/modules/laydate/default/laydate.css" rel="stylesheet" />
<form class="layui-form layui-form-pane" id="modifyForm" >
    <input type="hidden" value="@Model.id" name="id" />
    <input type="hidden" value="@Model.UserId" name="UserId" />
    <input type="hidden" value="@Model.CreateTime.ToString("yyyy-MM-dd")" name="CreateTime" />
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">应发工资</label>
            <div class="layui-input-inline">
                <input type="text" name="TotalSalary" lay-verify="required|number" autocomplete="off" class="layui-input" value="@Model.TotalSalary">
            </div>
            <label class="layui-form-label">实发工资</label>
            <div class="layui-input-inline">
                <input type="text" name="FinalSalary" lay-verify="required|number" autocomplete="off" class="layui-input" value="@Model.FinalSalary">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">扣款合计</label>
            <div class="layui-input-inline">
                <input type="text" name="DeductedSalary" lay-verify="required|number" autocomplete="off" class="layui-input" value="@Model.DeductedSalary">
            </div>
            <label class="layui-form-label">请假扣款</label>
            <div class="layui-input-inline">
                <input type="text" name="LeaveSalary" lay-verify="required|number" autocomplete="off" class="layui-input" value="@Model.LeaveSalary">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">公积金</label>
            <div class="layui-input-inline">
                <input type="text" name="AccumulationFund" lay-verify="required|number" autocomplete="off" class="layui-input" value="@Model.AccumulationFund">
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">日期</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="SalaryTime" name="SalaryTime" placeholder="yyyy-MM-dd" lay-verify="required|date" value="@Model.SalaryTime.ToString("yyyy-MM-dd")">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">所在公司</label>
        <div class="layui-input-block">
            <input type="text" name="Company" lay-verify="required" autocomplete="off" placeholder="请输入公司名称" class="layui-input" value="@Model.Company">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea  id="Summary" style="width:99%;">@Html.Raw(Model.Summary)</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block text-center">
            <button class="layui-btn" lay-submit="" lay-filter="demo1" id="sumitBtn">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/Plugin/kindeditor-4.1.10/kindeditor-min.js"></script>
<script src="~/Scripts/Plugin/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script src="~/Scripts/Plugin/layui-v2.2.5/layui/lay/modules/laydate.js"></script>
<script src="~/Scripts/Plugin/layui-v2.2.5/layui/layui.js"></script>
<script src="~/Scripts/Plugin/layui-v2.2.5/layui/lay/modules/laydate.js"></script>

<script type="text/javascript">
    var form;
    var editIndex;
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[id="Summary"]', {
            resizeType: 0,
            allowFileManager: true, //是否可以浏览上传文件
            allowUpload: true,
            height: '350px',
            fileManagerJson: '../../Scripts/Plugin/kindeditor-4.1.10/attached/UploadImage.ashx',      //浏览文件方法
            uploadJson: '../../Scripts/Plugin/kindeditor-4.1.10/attached/upload_json.ashx',//上传文件方法  //注意这两个路径
            items: ["source", "|", "undo", "redo", "|", "preview", "print", "template", "code", "cut", "copy", "paste", "plainpaste", "wordpaste", "|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "insertorderedlist", "insertunorderedlist", "indent", "outdent", "subscript", "superscript", "clearhtml", "quickformat", "selectall", "|", "fullscreen", "/", "formatblock", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline", "strikethrough", "lineheight", "removeformat", "|", "image", "multiimage", "flash", "media", "insertfile", "table", "hr", "emoticons", "baidumap", "pagebreak", "anchor", "link", "unlink", "|", "about"],
        });
    });

    window.onload = function () {
        layui.use(['form'], function () {
            form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
            form.render();
        });
    }

    document.getElementById('sumitBtn').onclick = function () {
        $.ajax({
            type: "post",
            url: "/Salary/Edit",
            data: $('#modifyForm').serialize()+"&Summary="+editor.html(),
            success: function (data) {
                if (data.result == true) {
                    layer.msg('修改成功');
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                } else {
                    layer.msg('修改异常!');
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.msg(XMLHttpRequest.status);
                layer.msg(XMLHttpRequest.readyState);
                layer.msg(textStatus);
            }
        });
    }

    laydate.render({
        elem: '#SalaryTime'
    });

</script>
