<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>编辑</title>
    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<form class="layui-form" action="" lay-filter="formDemo">
    <div class="layui-tab layui-tab-card">
        <ul class="layui-tab-title">
            <li>付款信息</li>
            <li class="layui-this">审核</li>
        </ul>
        <div class="layui-tab-content">
            <!-- 付款信息开始 -->
            <div class="layui-tab-item" style="min-height: 550px">
                <form class="layui-form" action="" lay-filter="formDemo" style="transform: none">
                    <div class="layui-form layuimini-form" style="padding-bottom: 100px">
                       <!-- <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 10%">费用申请</label>
                            <div class="layui-input-inline" style="width: 80%">
                                <input type="text" id="fysqmc" name="fysqmc" class="layui-input" th:value="${payapproval.fysqmc}"
                                       readonly>
                            </div>
                        </div>-->
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 10%">任务书</label>
                            <div class="layui-input-inline" style="width: 80%">
                                <input type="text" id="rwsmc" name="rwsmc" class="layui-input" th:value="${payapproval.rwsmc}" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 10%">合同</label>
                            <div class="layui-input-inline" style="width: 30%">
                                <input type="text" id="htmc" name="htmc" class="layui-input" th:value="${payapproval.htmc}" readonly>
                            </div>
                            <label class="layui-form-label" style="width: 15%">合同金额(万元)</label>
                            <div class="layui-input-inline" style="width: 30%">
                                <input type="number" id="htje" name="htje" class="layui-input" th:value="${payapproval.htje}" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 10%">付款计划</label>
                            <div class="layui-input-inline" style="width: 30%">
                                <input type="text" id="fkjhmc" name="fkjhmc" class="layui-input" th:value="${payapproval.fkjhmc}+' / '+${payapproval.zfje}"
                                       readonly>
                            </div>
                            <label class="layui-form-label" style="width: 15%; ">本次付款金额(万元)</label>
                            <div class="layui-input-inline" style="width: 30%">
                                <input type="number" id="bcfkje" name="bcfkje" class="layui-input" th:value="${payapproval.bcfkje}"
                                       readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 10%">合同文件</label>
                            <div class="layuimini-container" style="width: 80%;margin-left: 11.8%">
                                <input type="hidden" id="htwj" name="htwj" class="layui-input" th:value="${payapproval.htwj}">
                                <table class="layui-hide" id="currentTableId1" name="currentTableId1"
                                       lay-filter="currentTableFilter1"></table>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 10%">验收资料</label>
                            <div class="layuimini-container" style="width: 80%; margin-left: 11.8%">
                                <input type="hidden" id="yszl" name="yszl" class="layui-input" th:value="${payapproval.yszl}">
                                <table class="layui-hide" id="currentTableId2" name="currentTableId2"
                                       lay-filter="currentTableFilter2"></table>
                            </div>
                        </div>

                        <!-- 右侧悬浮按钮 -->
                        <div class="right-bottom-btn">
                            <button type="button" class="layui-btn" lay-filter="cancleBtn1">
                                <i class="layui-icon layui-icon-list"></i>合同文件预览
                            </button>
                            <button type="button" class="layui-btn" lay-filter="cancleBtn2">
                                <i class="layui-icon layui-icon-list"></i>验收资料预览
                            </button>
                            <button type="button" class="layui-btn" lay-filter="cancleBtn">
                                <i class="layui-icon layui-icon-close"></i>关闭
                            </button>
                        </div>
                    </div>
                </form>
            </div>
            <!-- 付款信息结束 -->
            <!-- 审核开始 -->
            <div class="layui-tab-item layui-show" style="min-height: 550px">
                <form class="layui-form" action="" lay-filter="formDemo">
                    <div class="layui-form layuimini-form" style="margin-right: -10px">
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 95px">付款申请</label>
                            <div class="layui-input-inline" style="width: 840px">
                                <input type="hidden" id="id" name="id" class="layui-input" th:value="${approveInfo.id}">
                                <input type="hidden" id="xmid" name="xmid" class="layui-input" th:value="${approveInfo.xmid}">
                                <input type="hidden" id="tablename" name="tablename" class="layui-input"
                                       th:value="${approveInfo.tablename}">
                                <input type="text" id="xm" name="xm" class="layui-input" readonly th:value="${approveInfo.xm}">
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 95px">状态</label>
                            <div class="layui-input-inline" style="width: 600px">
                                <input type="hidden" id="spzt" name="spzt" class="layui-input" th:value="${approveInfo.zt}">
                                <input type="text" id="zt" name="zt" class="layui-input" readonly th:value="${approveInfo.zt}">
                            </div>
                            <div class="layui-input-inline" style="width: 230px">
                                <input type="hidden" id="htje" name="htje" class="layui-input" readonly>
                                <input type="text" value="付款申请" class="layui-input" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 95px">审批操作</label>
                            <div class="layui-input-inline" style="width: 840px">
                                <select id="spcz" name="spcz" class="layui-input" lay-filter="spcz">
                                    <option value="审批通过">审批通过</option>
                                    <option value="返回修改">返回修改</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 95px">评语及意见</label>
                            <div class="layui-input-inline" style="width: 840px" id="jyDiv1">
                                <textarea class="layui-textarea" th:text="同意。" style="width: 840px;height: 100px"></textarea>
                            </div>
                            <div class="layui-input-inline" style="width: 840px; display: none" id="jyDiv2">
                                <textarea id="yj" name="yj" class="layui-textarea" style="width: 840px;height: 100px"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 95px">选择常用语</label>
                            <div class="layui-input-inline" style="width: 750px">
                                <select name="xmlx" id="xmlx" lay-filter="xmlx">
                                    <option value="">-- 请选择 --</option>
                                    <!--<option th:each="cyyList:${cyyList}" th:text="${cyyList.cyy}"
                                            th:value="${cyyList. id}"></option>-->
                                </select>
                            </div>
                            <button type="button" class="layui-btn" lay-filter="cyySaveBtn" style="width: 80px">常用语</button>
                        </div>
                        <!--        <div class="layui-form-item layui-inline" style="width: 100%">-->
                        <!--            <label class="layui-form-label" style="width: 95px">选择常用语</label>-->
                        <!--            <div class="layui-input-inline" style="width: 750px">-->
                        <!--                <input type="text" id="cyy" name="cyy" class="layui-input" readonly>-->
                        <!--            </div>-->
                        <!--            <button type="button" class="layui-btn" lay-filter="cyySaveBtn" style="width: 80px">常用语</button>-->
                        <!--        </div>-->
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 95px">提交人</label>
                            <div class="layui-input-inline" style="width: 370px">
                                <input type="hidden" id="tjr" name="tjr" class="layui-input" th:value="${approveInfo.tjr}">
                                <input type="text" id="tjrxm" name="tjrxm" class="layui-input" readonly th:value="${approveInfo.tjrxm}">
                            </div>
                            <label class="layui-form-label" style="width: 80px">提交时间</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="text" id="tjsj" name="tjsj" class="layui-input" readonly th:value="${approveInfo.tjsj}">
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 95px">审核人</label>
                            <div class="layui-input-inline" style="width: 370px">
                                <input type="hidden" id="userId" name="userId" class="layui-input" th:value="${userInfo.userId}">
                                <input type="hidden" id="shr" name="shr" class="layui-input" th:value="${approveInfo.shr}">
                                <input type="text" id="shrxm" name="shrxm" class="layui-input" th:value="${approveInfo.shrxm}" readonly>
                            </div>
                            <label class="layui-form-label" style="width: 80px">审核时间</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="text" id="shsj" name="shsj" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%" id="spczDiv">
                            <label class="layui-form-label" style="width: 95px">“审批”操作岗位</label>
                            <div class="layui-input-inline" style="width: 370px">
                                <input type="hidden" id="sjshgw" name="sjshgw" class="layui-input" th:value="${postInfo.postId}">
                                <input type="text" id="sjshgwmc" name="sjshgwmc" th:value="${postInfo.postName}" class="layui-input"
                                       readonly>
                            </div>
                            <label class="layui-form-label" style="width: 80px">“审批”操作人</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="hidden" id="sjshr" name="sjshr" class="layui-input">
                                <input type="text" id="sjshrxm" name="sjshrxm" class="layui-input" readonly>
                            </div>
                        </div>
                        <!--        <div class="layui-form-item layui-inline" style="width: 100%">-->
                        <!--            <label class="layui-form-label" style="width: 95px">当前岗位人员</label>-->
                        <!--            <div class="layui-input-inline" style="width: 370px">-->
                        <!--                <input type="hidden" id="dqgw" name="dqgw" class="layui-input" th:value="${userInfo.userId}">-->
                        <!--                <input type="text" id="dqgwxm" name="dqgwxm" class="layui-input" th:value="${userInfo.name}" readonly>-->
                        <!--            </div>-->
                        <!--        </div>-->

                        <!-- 右侧悬浮按钮 -->
                        <div class="right-bottom-btn">
 <!--                           <button type="button" class="layui-btn" lay-filter="viewFksqBtn">
                                <i class="layui-icon layui-icon-file"></i>查看付款申请
                            </button>-->
                            <button type="button" class="layui-btn" lay-filter="viewSplistBtn">
                                <i class="layui-icon layui-icon-file"></i>审批列表
                            </button>
                            <button type="button" class="layui-btn" lay-submit lay-filter="saveBtn">
                                <i class="layui-icon layui-icon-ok"></i>提交
                            </button>
                            <button class="layui-btn" lay-filter="cancleBtn">
                                <i class="layui-icon layui-icon-close"></i>取消
                            </button>
                        </div>
                    </div>
                </form>
            </div>
            <!-- 审核结束 -->
        </div>
    </div>
</form>




<script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
<script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
<script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
<script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
<script th:src="@{/js/lay-config.js}" charset="utf-8"></script>

<script type="text/javascript" th:inline="javascript">
    function getInit() {
        var userId = document.getElementById('userId').value;
        //初始化常用语
        $.ajax({
            type: "get",
            url: AjaxUtil.ctx + "prjProject/init_cyy/" + userId,
            async: true,
            success: function (data) {
                var cyyList = [];
                for (var item in data) {
                    cyyList.push(data[item]);
                }

                for (var i = 0; i < cyyList.length; i++) {
                    $("#xmlx").append("<option value = '" + cyyList[i].id + "'>" + cyyList[i].cyy + "</option>");
                    //重新渲染
                    layui.form.render("select");
                }
            }
        })
    }
    var travelExpense = [];//差旅费
    var updateflag = 0;//更新标志
    AjaxUtil.ctx = /*[[@{/}]]*/'';
    layui.use(['form','table','treeTable','layCascader', 'tableSelect', 'laydate', 'element'], function () {
        var form = layui.form,
            table = layui.table,
            layer = layui.layer,
            laydate = layui.laydate,
            tableSelect = layui.tableSelect,
            element = layui.element;
        // 基本信息

        // 用于存放表格数据
        var dataHtwj = new Array();
        if ([[${payapproval.htwj}]] != null && [[${payapproval.htwj}]] != "") {
            dataHtwj = eval('(' + [[${payapproval.htwj}]] + ')');
        }
        //合同文件
        var currTable1 = table.render({
            elem: '#currentTableId1',
            data: dataHtwj,
            cols: [
                [
                    {type: 'numbers', align: 'center',width: '7%',title: '序号'},
                    {field: 'wjm', title: '文件名', width: '60%'},
                    {field: 'scrq', title: '上传日期', width: '15%', align: 'center'},
                    {field: 'sm', title: '说明',width: '20%'}
                ]
            ],
            autoSort: false,
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'grid',
            done: function (res, curr, count) { // done为数据渲染完的回调
            }
        });
        //双击（合同文件）
        table.on('rowDouble(currentTableFilter1)', function (obj) {
            // window.open(obj.data.Url);
            // 创建一个对象
            var data = {
                'id': [[${payapproval.ht}]]
                ,'type':'ht'
            }
            AjaxUtil.post({
                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
                contentType:"application/json",// 传输文件类型
                data: JSON.stringify(data), // 传输数据类型
                success: function (res) {

                    if (res.code === 0){
                        //你的代码
                        layer.tab({
                            area: ['100%', '100%'],
                            tab: res.data,
                            maxmin: true,
                            shadeClose: true,
                            success: function (index, layero) {//打开tab后的执行的内容
                                //你的代码
                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%;background-color: #f0f0f0; overflow-x: scroll;overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
                                $("div>span").attr("style", "width:20px; padding: 5px; display: inline-block;");
                            }
                        })

                    }else {

                        layer.msg(res.message,{icon: 3});
                        return false;
                    }

                },
                fail:function (res) {
                    layer.close(index);// 关闭页面
                    layer.msg(res.message,{icon:3});
                },
                error:function (error) {
                    layer.close(index);
                    layer.msg('服务器异常！请联系管理员!',{icon:3})

                }
            })
        });
        // 用于存放表格数据
        var dataYszl = new Array();
        if ([[${payapproval.yszl}]] != null && [[${payapproval.yszl}]] != "") {
            dataYszl = eval('(' + [[${payapproval.yszl}]] + ')');
        }
        //验收资料
        var currTable2 = table.render({
            elem: '#currentTableId2',
            data: dataYszl,
            cols: [
                [
                    {type: 'numbers', align: 'center',width: '7%',title: '序号'},
                    {field: 'wjm', title: '文件名', width: '60%'},
                    {field: 'scrq', title: '上传日期', width: '15%', align: 'center'},
                    {field: 'sm', title: '说明',width: '20%'}
                ]
            ],
            autoSort: false,
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'grid',
            done: function (res, curr, count) { // done为数据渲染完的回调
            }
        });
        // 批量查看合同文件
        $("button[lay-filter='cancleBtn1']").click(function () {
            // 创建一个对象
            var data = {
                'id': [[${payapproval.ht}]]
                ,'type':'ht'
            }
            AjaxUtil.post({
                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
                contentType:"application/json",// 传输文件类型
                data: JSON.stringify(data), // 传输数据类型
                success: function (res) {

                    if (res.code === 0){
                        //你的代码
                        layer.tab({
                            area: ['100%', '100%'],
                            tab: res.data,
                            maxmin: true,
                            shadeClose: true,
                            success: function (index, layero) {//打开tab后的执行的内容
                                //你的代码
                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%;background-color: #f0f0f0; overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
                                $("div>span").attr("style", "width:10px; display: inline-block;");
                            }
                        })

                    }else {

                        layer.msg(res.message,{icon: 3});
                        return false;
                    }

                },
                fail:function (res) {
                    layer.close(index);// 关闭页面
                    layer.msg(res.message,{icon:3});
                },
                error:function (error) {
                    layer.close(index);
                    layer.msg('服务器异常！请联系管理员!',{icon:3})

                }
            })

        });
        // 批量查看验收资料
        $("button[lay-filter='cancleBtn2']").click(function () {
            var data = {
                'id':[[${payapproval.ht}]]
                ,'type':'ys'
            }
            AjaxUtil.post({
                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
                contentType: "application/json", // 传输文件类型 韦 json 类型
                data:JSON.stringify(data), // 传输数据类型 为 Json类型
                success: function (res) {
                    console.log(res);
                    if (res.code === 0){
                        layer.tab({
                            area: ['100%', '100%'],
                            tab: res.data,
                            maxmin: true,
                            shadeClose: true,
                            success: function (index, layero) {//打开tab后的执行的内容
                                //你的代码
                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%;background-color: #f0f0f0; overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
                                $("div>span").attr("style", "width:10px;  display: inline-block;");
                            }
                        })
                    }else {
                        layer.msg(res.message,{icon: 3});
                        return false;
                    }
                },
                fail: function (res) {
                    layer.close(index);
                    layer.msg(res.message,{icon : 3});

                },
                error: function (error) {
                    layer.close(index);
                    layer.msg('服务器异常！请联系管理员');

                }
            })

        })

        //双击（验收资料）
        table.on('rowDouble(currentTableFilter2)', function (obj) {
            var data = {
                'id':[[${payapproval.ht}]]
                ,'type':'ys'
            }
            AjaxUtil.post({
                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
                contentType: "application/json", // 传输文件类型 韦 json 类型
                data:JSON.stringify(data), // 传输数据类型 为 Json类型
                success: function (res) {
                    console.log(res);
                    if (res.code === 0){
                        layer.tab({
                            area: ['100%', '100%'],
                            tab: res.data,
                            maxmin: true,
                            shadeClose: true,
                            success: function (index, layero) {//打开tab后的执行的内容
                                //你的代码
                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%;background-color: #f0f0f0; overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
                                $("div>span").attr("style", "width:10px;  display: inline-block;");
                            }
                        })
                    }else {
                        layer.msg(res.message,{icon: 3});
                        return false;
                    }
                },
                fail: function (res) {
                    layer.close(index);
                    layer.msg(res.message,{icon : 3});

                },
                error: function (error) {
                    layer.close(index);
                    layer.msg('服务器异常！请联系管理员');

                }
            })
        });
        // 监听取消按钮
        $("button[lay-filter='cancleBtn']").click(function () {
            var iframeIndex = parent.layer.getFrameIndex(window.name);
            parent.layer.close(iframeIndex);
        });
        // 基本结束


        var xmApproval = parent.getXmApproval();
        $("#htje").val(xmApproval.htje);

        //提交时间
        laydate.render({
            elem: '#shsj',
            type: 'datetime',
            value: new Date()
        });

        element.render('checkbox');
        form.on('select(spcz)', function (data) {
            if (data.value == "审批通过") {
                document.getElementById('jyDiv1').style.display = 'block';
                document.getElementById('jyDiv2').style.display = 'none';
                document.getElementById('spczDiv').style.display = 'block';
            } else {
                document.getElementById('jyDiv1').style.display = 'none';
                document.getElementById('jyDiv2').style.display = 'block';
                document.getElementById('spczDiv').style.display = 'none';
            }
        });

        //初始化
        getInit();
        //gst ccy 监听常用语按钮
        $("button[lay-filter='cyySaveBtn']").click(function () {
            parent.layer.open({
                title: '查看常用',
                type: 2,
                shade: 0.3,
                maxmin: true,
                shadeClose: true,
                area: ['1080px', layerheight + 'px'],
                // content: AjaxUtil.ctx + '/prjProject/forCyy/' + $("#userId").val(),
                content: AjaxUtil.ctx + 'prjProject/forCyyy',
                end: function (index) {
                    $("#xmlx").empty();
                    $("#xmlx").append("<option>[无]</option>");
                    getInit();
                }
            });
        });

        //“审批”操作人
        var postId = $("#sjshgw").val();
        if (postId != "") {
            tableSelect.render({
                elem: '#sjshrxm',
                checkedKey: 'userId',
                searchKey: 'name',
                searchPlaceholder: '搜索姓名',
                table: {
                    url: AjaxUtil.ctx + 'sysUserPost/postUserlist/' + postId,
                    cols: [
                        [
                            {type: "radio", fixed: 'left'},
                            {type: 'numbers', align: 'center'},
                            {field: 'name', width: '40%', title: '姓名', align: 'left'},
                            {field: 'account', title: '账号', align: 'left'}
                        ]
                    ]
                },
                done: function (elem, data) {
                    var NEWJSON = [];
                    var NEWJSON1 = [];
                    layui.each(data.data, function (index, item) {
                        NEWJSON.push(item.name);
                        NEWJSON1.push(item.userId);
                    })
                    elem.val(NEWJSON.join(","));
                    $("#sjshr").val(NEWJSON1.join(","));
                }
            });
        }

        // 自动填充审批操作人gst
        var postId = $("#sjshgw").val();
        if (postId !== "") {
            AjaxUtil.get({
                url: AjaxUtil.ctx + 'sysUserPost/postUserlist/' + postId,
                success: function (res) {
                    var users = res.data;
                    var userIds = [];
                    var userNames = [];

                    /* for (var i = 0 ; i <users.length; i++) {
                    if (i==0) {
                    userIds.push(users[i].userId);
                    userNames.push(users[i].name);
                    }
                    break;
                    }


                    */
                    userIds.push(users[0].userId);
                    userNames.push(users[0].name);

                    $("#sjshr").val(userIds.join(","));
                    $("#sjshrxm").val(userNames.join(","));
                },
                error: function (error) {
                }
            });
        }

        // 监听查看付款申请按钮
        $("button[lay-filter='viewFksqBtn']").click(function () {
            var index = parent.layer.open({
                title: '查看付款申请',
                type: 2,
                shade: 0.3,
                maxmin: true,
                shadeClose: true,
                area: ['950px', '750px'],
                content: AjaxUtil.ctx + "staPayapproval/forView/" + xmApproval.xmid,
                end: function () {
                    layer.close(index);
                }
            });
        });

        // 监听审批列表按钮
        $("button[lay-filter='viewSplistBtn']").click(function () {
            parent.layer.open({
                title: '审批列表',
                type: 2,
                shade: 0.3,
                maxmin: true,
                shadeClose: true,
                area: ['1300px', '750px'],
                content: AjaxUtil.ctx + 'staPayapproval/forApproveList',
                end: function (index) {
                    layer.close(index);
                }
            });
        });

        // 监听提交按钮
        form.on('submit(saveBtn)', function (data) {
            var zt = $("#zt").val();
            var shr = $("#shr").val();
            var userId = $("#userId").val();
            if (userId != shr)
                Message.error("您不是指定的审核人！", 1500);
            else if (zt == '数据不匹配')
                Message.error("数据不匹配，请联系管理员处理！", 1500);
            else {
                var spcz = $("#spcz").val();
                if (spcz === '审批通过') {
                    var sjshrxm = $("#sjshrxm").val();
                    if (sjshrxm == '') {
                        Message.error('“审批”操作人不能为空', 1000);
                        return false;
                    }
                }

                //基本信息
                layer.load(0, {shade: 0.1});
                AjaxUtil.post({
                    url: AjaxUtil.ctx + "prjApproverecord/doUpdateApproveFksq",
                    data: data.field,
                    success: function (res) {
                        //更新审批状态
                        var project = {
                            "id": xmApproval.xmid,
                            "spzt": ''
                        }
                        var zt = $("#zt").val();
                        if (spcz == '返回修改')
                            project.spzt = '未提交(返回)';
                        else if (zt == '科技项目管理专责2审批')
                            project.spzt = '科技部部门主任审批';
                        else if (zt === '科技部部门主任审批')
                            project.spzt = '审批结束';

                        layer.load(0, {shade: 0.1});
                        AjaxUtil.post({
                            url: AjaxUtil.ctx + "staPayapproval/updateSpzt",
                            contentType: "application/json",
                            data: JSON.stringify(project),
                            success: function (res) {
                                parent.setUpdateFlag();

                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(iframeIndex);
                            },
                            error: function (error) {
                            }
                        });
                    },
                    error: function (error) {
                    }
                });
            }
        });

        // 监听取消按钮
        $("button[lay-filter='cancleBtn']").click(function () {
            var iframeIndex = parent.layer.getFrameIndex(window.name);
            parent.layer.close(iframeIndex);
        });
    });


    function setTravelExpense(expense) {
        travelExpense = expense;
    }

    function getTravelExpense() {
        return travelExpense;
    }

    function setUpdateFlag() {
        updateflag = 1;
    }
</script>
</body>
</html>