<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-form layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <sfTags:pagePermission authFlag="SXGL_XMSX_DSH_T"
                                       html='<li class=""><a href="${ctx}/itemManagement/proj/waitDealItemPage">待审核</a></li>'/>
                <sfTags:pagePermission authFlag="SXGL_XMSX_DFP_T"
                                       html='<li class=""><a href="${ctx}/itemManagement/proj/waitDispatchItemPage">待分配</a></li>'/>
                <sfTags:pagePermission authFlag="SXGL_XMSX_YSH_T"
                                       html='<li class="layui-this"><a href="${ctx}/itemManagement/proj/endAuditItemPage">已审核</a></li>'/>
                <sfTags:pagePermission authFlag="SXGL_XMSX_SDSZ_T"
                                       html='<li><a href="${ctx}/itemManagement/proj/auditSettingPage">审单设置</a></li>'/>
                <sfTags:pagePermission authFlag="SXGL_XMSX_YXSDSZ_T"
                                       html='<li class=""><a href="${ctx}/itemManagement/proj/priorAuditSettingPage">优先审单设置</a></li>'/>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " type="reset" onclick="reset()">
                    <i class="layui-icon fs-12">&#xe9aa;</i>
                    重置
                </button>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10" id="searchBtn" lay-submit
                        lay-filter="LAY-user-back-search"><i class="layui-icon fs-12">&#xe615;</i>查询
                </button>
            </ul>
        </div>
        <form class="layui-card-body layuiadmin-card-header-auto" id="searchForm">
            <div class="layui-form-item">
                <div class="layui-col-md2 layui-col-sm2">
                    <label class="layui-form-label">申请类型：</label>
                    <div class="layui-input-block">
                        <select name="formKey">
                            <option value="">请选择</option>
                            <option value="91">设计审核</option>
                            <option value="92">档案审核</option>
                            <option value="93">安装验收</option>
                            <option value="94">并网验收</option>
                            <option value="95">勘测信息变更</option>
                            <option value="96">完工信息变更</option>
                            <option value="97">设计信息变更</option>
                            <option value="98">客户信息变更</option>
                            <option value="99">物料信息变更</option>
                            <option value="100">并网信息变更</option>
                        </select>
                    </div>
                </div>

                <div class="layui-col-md2 layui-col-sm2">
                    <label class="layui-form-label">资方：</label>
                    <div class="layui-input-block" >
                        <select name="partnerId" lay-search>
                            <option value="">请选择</option>
                            <c:forEach items="${partnerList}" var="partner">
                                <option value="${partner.columns.id}">${partner.columns.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>

                <div class="layui-col-md2 layui-col-sm2">
                    <label class="layui-form-label">代理商名称：</label>
                    <div class="layui-input-block" >
                        <select name="traderId" lay-search>
                            <option value="">请选择</option>
                            <c:forEach items="${traderList}" var="trader">
                                <option value="${trader.columns.id}">${trader.columns.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>

                <div class="layui-col-md2 layui-col-sm2">
                    <label class="layui-form-label">审核人员：</label>
                    <div class="layui-input-block" >
                        <select name="employeeUserId" lay-search>
                            <option value="">请选择</option>
                            <c:forEach items="${reviewMembers}" var="member">
                                <option value="${member.columns.user_id}">${member.columns.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>

                <div class="layui-col-md2 layui-col-sm2">
                    <label class="layui-form-label">电站编号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="entryNo" class="layui-input" id="entryNo">
                    </div>
                </div>

                <div class="layui-col-md2 layui-col-sm2">
                    <label class="layui-form-label">业主姓名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="tenantName" class="layui-input" id="tenantName">
                    </div>
                </div>
<%--                <div class="layui-col-md2 layui-col-sm2">--%>
<%--                    <label class="layui-form-label">流程标题：</label>--%>
<%--                    <div class="layui-input-block">--%>
<%--                        <input type="text" name="name" class="layui-input" id="name">--%>
<%--                    </div>--%>
<%--                </div>--%>

                <div class="layui-col-lg4 layui-col-sm4 layui-col-md4" >
                    <label class="layui-form-label">安装地址：</label>
                    <div class="inline-block" style="width: 18%">
                        <select name="province" lay-search lay-filter="province"  id="province">
                            <option value="">省</option>
                            <c:forEach items="${province}" var="pro">
                                <option value="${pro.columns.ProvinceName}"  title="${pro.columns.ProvinceID}">${pro.columns.ProvinceName}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="inline-block" style="width: 18%;">
                        <select name="city" id="city" lay-filter="city"
                                lay-search>
                            <option value="">市</option>

                        </select>
                    </div>
                    <div class="inline-block" style="width: 18%">
                        <select name="area" id="area" lay-search>
                            <option value="">县/区</option>

                        </select>
                    </div>
                </div>

                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">发起时间：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-xs5">
                            <input type="text" name="createTimeSta" id="createTimeSta" class="layui-input"  placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="createTimeEnd" id="createTimeEnd" class="layui-input"  placeholder="结束日期">
                        </div>
                    </div>
                </div>

                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">派单时间：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-xs5">
                            <input type="text" name="dispatchTimeSta" id="dispatchTimeSta" class="layui-input"  placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="dispatchTimeEnd" id="dispatchTimeEnd" class="layui-input"  placeholder="结束日期">
                        </div>
                    </div>
                </div>

                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">审核时间：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-xs5">
                            <input type="text" name="reviewTimeSta" id="reviewTimeSta" class="layui-input"  placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="reviewTimeEnd" id="reviewTimeEnd" class="layui-input"  placeholder="结束日期">
                        </div>
                    </div>
                </div>

            </div>
        </form>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" lay-skin="row" id="test" lay-filter="test"></table>
        </div>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
     <sfTags:pagePermission authFlag='SXGL_XMSX_YSH_DC_B' html='<button class="layui-btn layui-btn-sm" lay-event="export" id="exportBtn"><i
            class="layui-icon layui-icon-export"></i>导出
    </button>'/>
</script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/data.js"></script>
<script type="text/javascript">
    var saveMark = false;
    //初始数据
    var $form;
    var form;
    var upload;
    var $;
    var table;
    var laydate;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form','excel'], function(){
        $ = layui.$
            ,form = layui.form
            ,tableExt = layui.tableExt;
        laydate = layui.laydate;
        table = layui.table;

        //开始日期
        var insStart = laydate.render({
            elem: '#createTimeSta'
            ,type: 'date'
            ,done: function(value, date){
                //更新结束日期的最小日期
                insEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                insEnd.config.elem[0].focus();
            }
        });
        //结束日期
        var insEnd = laydate.render({
            elem: '#createTimeEnd'
            ,type: 'date'
            ,done: function(value, date){
                //更新开始日期的最大日期
                insStart.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        var dispStart = laydate.render({
            elem: '#dispatchTimeSta'
            ,type: 'date'
            ,done: function(value, date){
                //更新结束日期的最小日期
                dispEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                dispEnd.config.elem[0].focus();
            }
        });
        //结束日期
        var dispEnd = laydate.render({
            elem: '#dispatchTimeEnd'
            ,type: 'date'
            ,done: function(value, date){
                //更新开始日期的最大日期
                dispStart.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        var reviewTimeStart = laydate.render({
            elem: '#reviewTimeSta'
            ,type: 'date'
            ,done: function(value, date){
                //更新结束日期的最小日期
                reviewTimeEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                reviewTimeEnd.config.elem[0].focus();
            }
        });
        //结束日期
        var reviewTimeEnd = laydate.render({
            elem: '#reviewTimeEnd'
            ,type: 'date'
            ,done: function(value, date){
                //更新开始日期的最大日期
                reviewTimeStart.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        function reviewResult(d) {
            if(d.handle_result =='1'){
                return "审批通过";
            }else if(d.handle_result =='2'){
                return "审批驳回";
            }else if(d.handle_result =='3'){
                return "已查看";
            }else if(d.status=='3'){
                return "已撤回";
            }else{
                return "";
            }
        }

        function formatDuration(d) {
            let ret = ''
            if (d.task_duration === 0) {
                return '0分'
            }
            if (d.task_duration) {
                let minutes = d.task_duration;
                const days = Math.floor(minutes / 1440); // 1 day = 1440 minutes
                const remainingMinutes = minutes % 1440;
                const hours = Math.floor(remainingMinutes / 60);
                const minutesRemaining = remainingMinutes % 60;
                if (days) {
                    ret+=days+'天'
                }
                if (hours) {
                    ret+=hours+'时'
                }
                if (minutesRemaining) {
                    ret+=minutesRemaining+'分'
                }
            }
            return ret;
        }

        function formatDuration2(d) {
            let ret = ''
            if (d.dispatch_duration === 0) {
                return '0分'
            }
            if (d.dispatch_duration) {
                let minutes = d.dispatch_duration;
                const days = Math.floor(minutes / 1440); // 1 day = 1440 minutes
                const remainingMinutes = minutes % 1440;
                const hours = Math.floor(remainingMinutes / 60);
                const minutesRemaining = remainingMinutes % 60;
                if (days) {
                    ret+=days+'天'
                }
                if (hours) {
                    ret+=hours+'时'
                }
                if (minutesRemaining) {
                    ret+=minutesRemaining+'分'
                }
            }
            return ret;
        }

        tableExt.render({
            elem: '#test'
            , height: 'full-220'
            , id: 'test'
            , defaultToolbar: false
            , url: '${ctx}/itemManagement/proj/endDealItemList'
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            , page: true
            , toolbar:"#toolbarDemo"
            , method:"post"
            , limits: [20, 50, 100]
            , limit: 20
            , cols: [[
                {field: 'number', minWidth: 50, title: '序号', align: 'center', type: 'numbers', fixed: 'left'},
                // {type: 'checkbox', fixed: 'left', title: '选择'},
                , {field: 'id', title: '操作', minWidth : 100, align: 'center', fixed: 'left', templet:function(d){
                        return '<a class="layui-table-opt-link" lay-event="lookDetail">查看</a>';
                    }
                }
                , {field: 'assignee', title: '审核人', minWidth: 150, align: 'center',exportable:true }
                , {field: 'name', title: '流程标题', minWidth: 400, align: 'center',exportable:true ,
                    /* templet: function (d) {
                         return "<a href=\"#\" class=\"layui-table-link\" onclick=\"traderDetail('" + d.id + "')\">" + d.name + "</a>";
                     }*/
                }
                , {field: 'formKey', title: '申请类型', minWidth: 100, align: 'center', exportable:true,
                    templet: function (d) {
                        if (d.formKey === '01') {
                            return '代理商准入申请';
                        }else if(d.formKey ==='02'){
                            return '供应商准入申请';
                        }else if(d.formKey ==='03'){
                            return '保证金调整申请';
                        }else if(d.formKey ==='04'){
                            return '授信额调整申请';
                        }else if(d.formKey ==='05'){
                            return '质保金调整申请';
                        }else if(d.formKey ==='06'){
                            return '分包标准价申请';
                        }else if(d.formKey ==='07'){
                            return '结算额调整申请';
                        }else if(d.formKey ==='08'){
                            return '订单申请';
                        }else if(d.formKey ==='09'){
                            return '采购申请';
                        }else if(d.formKey ==='10'){
                            return '盘点单申请';
                        }else if(d.formKey ==='11'){
                            return '调拨单申请';
                        }else if(d.formKey ==='12'){
                            return '请款申请';
                        }else if(d.formKey ==='13'){
                            return '仓库申请';
                        }else if(d.formKey ==='14'){
                            return '零售价系数申请';
                        }else if(d.formKey ==='15'){
                            return '备货申请';
                        }else if(d.formKey ==='16'){
                            return '支架账户申请';
                        }else if(d.formKey ==='17'){
                            return '现金下单申请';
                        }else if(d.formKey ==='18'){
                            return '保证金额度申请';
                        }else if(d.formKey ==='91'){
                            return '设计审核';
                        }else if(d.formKey ==='92'){
                            return '档案审核';
                        }else if(d.formKey ==='93'){
                            return '安装验收';
                        }else if(d.formKey ==='94'){
                            return '并网验收';
                        }else if(d.formKey ==='95'){
                            return '勘测信息变更';
                        }else if(d.formKey ==='96'){
                            return '完工信息变更';
                        }else if(d.formKey ==='97'){
                            return '设计信息变更';
                        }else if(d.formKey ==='98'){
                            return '客户信息变更';
                        }else if(d.formKey ==='99'){
                            return '物料信息变更';
                        }else if(d.formKey ==='100'){
                            return '并网信息变更';
                        }
                    },
                    expFormat: function (d) {
                        if (d.formKey === '01') {
                            return '代理商准入申请';
                        }else if(d.formKey ==='02'){
                            return '供应商准入申请';
                        }else if(d.formKey ==='03'){
                            return '保证金调整申请';
                        }else if(d.formKey ==='04'){
                            return '授信额调整申请';
                        }else if(d.formKey ==='05'){
                            return '质保金调整申请';
                        }else if(d.formKey ==='06'){
                            return '分包标准价申请';
                        }else if(d.formKey ==='07'){
                            return '结算额调整申请';
                        }else if(d.formKey ==='08'){
                            return '订单申请';
                        }else if(d.formKey ==='09'){
                            return '采购申请';
                        }else if(d.formKey ==='10'){
                            return '盘点单申请';
                        }else if(d.formKey ==='11'){
                            return '调拨单申请';
                        }else if(d.formKey ==='12'){
                            return '请款申请';
                        }else if(d.formKey ==='13'){
                            return '仓库申请';
                        }else if(d.formKey ==='14'){
                            return '零售价系数申请';
                        }else if(d.formKey ==='15'){
                            return '备货申请';
                        }else if(d.formKey ==='16'){
                            return '支架账户申请';
                        }else if(d.formKey ==='17'){
                            return '现金下单申请';
                        }else if(d.formKey ==='18'){
                            return '保证金额度申请';
                        }else if(d.formKey ==='91'){
                            return '设计审核';
                        }else if(d.formKey ==='92'){
                            return '档案审核';
                        }else if(d.formKey ==='93'){
                            return '安装验收';
                        }else if(d.formKey ==='94'){
                            return '并网验收';
                        }else if(d.formKey ==='95'){
                            return '勘测信息变更';
                        }else if(d.formKey ==='96'){
                            return '完工信息变更';
                        }else if(d.formKey ==='97'){
                            return '设计信息变更';
                        }else if(d.formKey ==='98'){
                            return '客户信息变更';
                        }else if(d.formKey ==='99'){
                            return '物料信息变更';
                        }else if(d.formKey ==='100'){
                            return '并网信息变更';
                        }
                    }
                }
                , {field: 'partnerName', title: '资方', minWidth: 200, align: 'center',exportable:true }
                , {field: 'tenantName', title: '业主姓名', minWidth: 80, align: 'center',exportable:true }
                , {field: 'power_station_code', title: '电站编码', minWidth: 150, align: 'center',exportable:true }
                , {field: 'province', title: '安装地址-省', minWidth: 120, align: 'center',exportable:true }
                , {field: 'city', title: '安装地址-市', minWidth: 120, align: 'center',exportable:true }
                , {field: 'area', title: '安装地址-区/县', minWidth: 130, align: 'center',exportable:true }
                , {field: 'createName', title: '申请人', minWidth: 150, align: 'center',exportable:true }
                , {field: 'createTime', title: '发起时间', minWidth: 200, align: 'center',exportable:true }
                , {field: 'assignTime', title: '派单时间', minWidth: 200, align: 'center',exportable:true }
                , {field: 'endTime', title: '审核时间', minWidth: 200, align: 'center',exportable:true }
                ,{field: 'handle_result', title: '审核结果', minWidth: 150, align: 'center',exportable:true ,
                    templet: reviewResult,
                    expFormat: reviewResult
                }
                , {field: 'leader_name', title: '审核组长', minWidth: 150, align: 'center',exportable:true}
                , {field: 'task_duration', title: '任务时效', minWidth: 200, align: 'center',exportable:true, templet:formatDuration,expFormat:formatDuration }
                , {field: 'dispatch_duration', title: '审核时长', minWidth: 200, align: 'center',exportable:true,templet:formatDuration2,expFormat:formatDuration2 }
            ],
            ]
            ,exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '项目事项-已处理',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 10000,                    //当pageData为false生效
                fileName: '项目事项-已处理',
                where: function (){
                    return _serializeJson($("#searchForm"));
                },done: function(res, curr, count){
                    //得到数据总量
                    entrycount = count;
                }
            }
        });


        $('input').on('keydown', function(event){
            if(event.keyCode == 13){
                //执行相关操作
                console.log($('#name').val().trim())
                $("#searchBtn").click();
            }
        });

        //监听行单击事件
        // table.on('row(test)', function (obj) {
        //     var data = obj.data;
        //     var oldData = table.cache["test"];
        //     var checkCell = obj.tr.find(".layui-form-checkbox");
        //     var CHECKED;
        //
        // });

        //监听搜索
        form.on('submit(LAY-user-back-search)', function (data) {
            var field = data.field;
            //执行重载
            table.reload('test', {
                where: field,
                page: {
                    curr: 1
                }
            });
        });

        // var active = {
        //     reload: function(){
        //         reload();
        //     }
        // };

        table.on('tool(test)',function(obj){
            var data=obj.data;
            var applicationId=data.application_id;
            var formKey=data.formKey;
            var partnerId=data.partner_id;
            if(obj.event === 'lookDetail'){
                if(formKey =='01'){  //代理商准入申请
                    layer.open({
                        type: 2,
                        title: '查看',
                        content: '${ctx}/flowpath/traderApply/traderApplyDetail?id='+applicationId,
                        area: ['90%', '90%'],
                    });
                }else if(formKey =='02'){  //供应商准入申请
                    layer.open({
                        type: 2,
                        title: '查看',
                        content: '${ctx}/flowpath/supplySupplierApply/supplierApplyDetail?id='+applicationId,
                        area: ['80%', '90%'],
                    });
                }else if(formKey =='03'){  //保证金调整申请
                    layer.open({
                        title:'查看',
                        type: 2,
                        area: ["70%", "80%"],
                        content: '${ctx}/apply/bondAdjustment/bondAdjustmentApplyDetail?id='+applicationId
                    })
                }else if(formKey =='04'){   //授信额调整申请
                    layer.open({
                        title:'查看',
                        type: 2,
                        area: ["70%", "80%"],
                        content: '${ctx}/apply/distributionGoods/ApplyDistributionGoods?id='+applicationId
                    })
                }else if(formKey =='05'){   //质保金调整申请
                    layer.open({
                        title:'查看',
                        type: 2,
                        area: ["70%", "80%"],
                        content: '${ctx}/apply/warrantyDeposit/applyWarrantyDeposit?id='+applicationId
                    })
                }else if(formKey =='06'){   //分包标准价申请
                    layer.open({
                        title:'查看',
                        type: 2,
                        area: ["70%", "80%"],
                        content: '${ctx}/apply/standardPrice/standardPriceApplyDetailPage?id='+applicationId
                    })
                }else if(formKey =='07'){   //结算额调整申请
                    layer.open({
                        title:'查看',
                        type: 2,
                        area: ["70%", "80%"],
                        content: '${ctx}/apply/settlementAmount/settlementAmountApplyDetail?id='+applicationId
                    })
                }else if(formKey =='08'){  //赊销下单申请
                    layer.open({
                        type: 2,
                        title: "查看",
                        resize: false,
                        area: ['80%', '90%'],
                        content: '${ctx}/material/order/auditOderDetailPage?id=' + applicationId,
                    });
                }else if(formKey =='09'){   //采购申请
                    layer.open({
                        type: 2,
                        title: '查看',
                        content: '${ctx}/supplyOrder/purchaseAudit/auditPurchaseOrderPage?id=' + applicationId+'&from=detail',
                        area: ['80%', '90%'],
                    });
                }else if(formKey =='10'){   //盘点单申请
                    layer.open({
                        type: 2,
                        title: '查看',
                        content: '${ctx}/inventory/toInventoryOrderDetailForm?mode=view&id=' + applicationId,
                        area: ['80%', '80%']
                    });
                }else if(formKey =='11'){    //调拨单申请
                    layer.open({
                        type: 2,
                        title: '查看',
                        content: '${ctx}/allocation/examineAllocationOrderPage?from=look&id='+applicationId,
                        area: ['80%','80%']
                    });
                }else if(formKey =='12'){    //请款申请
                    layer.open({
                        title:'查看',
                        type: 2,
                        area: ["100%", "100%"],
                        content: '${ctx}/apply/outCash/cashOutDetailPage?id='+applicationId
                    })
                }else if(formKey =='13'){    //仓库申请
                    layer.open({
                        title:'查看',
                        type: 2,
                        area: ["70%", "80%"],
                        content: '${ctx}/apply/warehouseApply/warehouseApplyDetail?id='+applicationId
                    })
                }else if(formKey =='14'){    //零售价系数申请
                    layer.open({
                        title:'查看',
                        type: 2,
                        area: ["80%", "80%"],
                        content: '${ctx}/apply/priceCoefficient/priceCoefficientApplyDetail?id='+applicationId
                    })
                }else if(formKey =='15'){   //备货申请
                    layer.open({
                        type: 2,
                        title: '查看',
                        content: '${ctx}/fittingStockUp/fittingStockUpDetailPage?id=' + applicationId+'&from=detail',
                        area: ['80%', '90%']
                    });
                }else if(formKey =='17'){   //现金下单申请
                    layer.open({
                        type: 2,
                        title: "查看",
                        resize: false,
                        area: ['80%', '90%'],
                        content: '${ctx}/material/order/auditOderDetailPage?id=' + applicationId
                    });
                }else if(formKey =='18'){    //保证金额度申请
                    layer.open({
                        title:'查看',
                        type: 2,
                        area: ["70%", "80%"],
                        content: '${ctx}/apply/bondLimitApply/bondLimitApplyDetail?id='+applicationId
                    })
                }else if(formKey =='91'){    //设计审核
                    layer.open({
                        type: 2
                        , title: '电站详情'
                        , content: '${ctx}/customerEntry/entryDetail?entryId=' + applicationId
                        , area: ['100%', '100%']
                        , yes: function(index, layero){

                        }
                    });
                }else if(formKey =='92'){   //档案审核
                    layer.open({
                        type: 2
                        , title: '电站详情'
                        , content: '${ctx}/customerEntry/entryDetail?entryId=' + applicationId
                        , area: ['100%', '100%']
                        , yes: function(index, layero){

                        }
                    });
                }else if(formKey =='93'){   //安装验收
                    layer.open({
                        type: 2
                        , title: '电站详情'
                        , content: '${ctx}/customerEntry/entryDetail?entryId=' + applicationId
                        , area: ['100%', '100%']
                        , yes: function(index, layero){

                        }
                    });
                }else if(formKey =='94'){   //并网验收
                    layer.open({
                        type: 2
                        , title: '电站详情'
                        , content: '${ctx}/customerEntry/entryDetail?entryId=' + applicationId
                        , area: ['100%', '100%']
                        , yes: function(index, layero){

                        }
                    });
                }else if(formKey =='95'){   //勘测信息变更
                    layer.open({
                        type: 2
                        , title: '变更详情'
                        , content: '${ctx}/customer/entry/change/survey/toSurveyDetail/' + data.process_instance_id
                        , area: ['100%', '100%']
                        , yes: function(index, layero){

                        }
                    });
                }else if(formKey =='96'){   //完工信息变更
                    layer.open({
                        type: 2
                        , title: '变更详情'
                        , content: '${ctx}/completion/change/toComDetail/' + data.process_instance_id
                        , area: ['100%', '100%']
                        , yes: function(index, layero){

                        }
                    });
                }else if(formKey =='97'){   //设计信息变更
                    layer.open({
                        type: 2
                        , title: '变更详情'
                        , content: '${ctx}/entryChanges/designInfo/toChangeDetail/' + data.process_instance_id+'/'+partnerId
                        , area: ['100%', '100%']
                        , yes: function(index, layero){
                        }
                    });
                }else if(formKey =='98'){   //客户信息变更
                    layer.open({
                        title:'变更详情',
                        type: 2,
                        area: ["100%", "100%"],
                        content: '${ctx}/entryChanges/customerInformationChange/toChangeAudit?form=look&id='+data.process_instance_id
                    })
                }else if(formKey =='99'){   //物料信息变更
                    layer.open({
                        type: 2
                        , title: '变更详情'
                        , content: '${ctx}/entryChanges/materialInformationChange/materialDetail/' +data.process_instance_id
                        , area: ['100%', '100%']
                        , yes: function(index, layero){

                        }
                    });
                }else if(formKey =='100'){   //并网信息变更
                    layer.open({
                        type: 2
                        , title: '变更详情'
                        , content: '${ctx}/onGridInfo/change/toComDetail/' +data.process_instance_id
                        , area: ['100%', '100%']
                        , yes: function(index, layero){

                        }
                    });
                }

            }

        })

        form.on('select(province)', function (data) {
            var province = $(data.elem).find("option:selected").attr("title");
            provinceOrder(province);
        });
        form.on('select(city)', function (data) {
            var city = $(data.elem).find("option:selected").attr("title");
            cityOrder(city);

        });

        function searchOrder() {
            //执行重载
            table.reload('test', {
                where: function (){
                    return _serializeJson($("#searchForm"));
                }
            });
        }

        function provinceOrder(province) {
            $("#city").empty();
            $("#area").empty();
            if (isBlank(province)) {
                $("#city").append("<option value=''>市</option>");
                return "";
            }
            $.ajax({
                type: "POST",
                url: "${ctx}/main/redirect/getCitysByProId",
                data: {
                    province: province
                },
                success: function (result) {

                    if (result == "205") {
                        layer.msg("暂无数据!")
                        return
                    }
                    var html = " <option value=''>市</option>";
                    for (var i = 0; i < result.length; i++) {
                        var city = result[i];
                        html = html + '<option value="' + city.columns.CityName + '" title="' + city.columns.CityID + '">' + city.columns.CityName + '</option>';
                    }
                    $("#city").append(html);
                    form.render('select');
                }
            });

        }

        function cityOrder(city, arean) {
            $("#area").empty()
            if (isBlank(city)) {
                $("#area").append("<option value=''>区/县</option>");
                return "";
            }
            $.ajax({
                type: "POST",
                url: "${ctx}/main/redirect/getAreaByCityId",
                data: {
                    city: city
                },
                success: function (result) {
                    if (result == "205") {
                        layer.msg("暂无数据!")
                        return
                    }
                    var html = "<option value=''>区/县</option>";
                    for (var i = 0; i < result.length; i++) {
                        var area = result[i];
                        html = html + '<option value="' + area.columns.DistrictName + '" value="' + area.columns.DistrictId + '">' + area.columns.DistrictName + '</option>';
                    }
                    $("#area").append(html);
                    if (!isBlank(arean)) {
                        $("#area").val(arean)
                    }

                    form.render('select');
                }
            });

        }


    });


    function reload(){
        table.reload('test', {
            where: {
                name: $('#name').val().trim(),
                province:$("#province").val().trim(),
                telephone:$("#telephone").val().trim()
            }
        });
    }

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }

    function reset(){
        layui.form.render();
        $("#searchForm").find("select").val("");
        $("#searchForm").find("input").val("");
    }

</script>
</body>
</html>

