<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layuiAdmin 后台管理员</title>
  <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" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
</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="CWGL_CZMX_CZMX_T" html='<a href="${ctx}/order/orderCollections/headList"><li class="layui-this">二维码收款记录</li></a>'/>
              <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 action="" id="searchForm">
        <div class="layui-card-body layuiadmin-card-header-auto" >
          <div class="layui-form-item">
              <div class="layui-col-lg2 layui-col-sm3">
                  <label class="layui-form-label">服务商名称：</label>
                  <div class="layui-input-block">
                      <select name="siteId" lay-search>
                          <option value="">请选择</option>
                          <c:forEach var="site" items="${siteList}">
                              <option value="${site.columns.id}">${site.columns.name}</option>
                          </c:forEach>
                      </select>
                  </div>
              </div>
              <div class="layui-col-lg2 layui-col-sm3">
                  <label class="layui-form-label">服务工程师：</label>
                  <div class="layui-input-block">
                      <input type="text" name="employeName" class="layui-input" id="employeName" >
                  </div>
              </div>
              <div class="layui-col-lg2 layui-col-sm3">
                  <label class="layui-form-label">收款方式：</label>
                  <div class="layui-input-block">
                      <select name="paymentType">
                          <option value="">请选择</option>
                          <option value="0">支付宝</option>
                          <option value="1">微信</option>
                          <option value="2">其他</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="startTime" class="layui-input" id="startTime" placeholder="开始日期" readonly>
                      </div>
                      <div class="layui-col-xs2 text-c lh-30">
                          —
                      </div>
                      <div class="layui-col-xs5">
                          <input type="text" name="endTime" class="layui-input" id="endTime" placeholder="结束日期" readonly>
                      </div>
                  </div>
              </div>
             <%-- <div class="layui-inline">
                  <button class="layui-btn layuiadmin-btn-admin layui-btn-sm" lay-submit lay-filter="LAY-user-back-search">查询</button>
                  <button type="reset" onclick="reset()" class="layui-btn-sm layui-btn layuiadmin-btn-admin">重置</button>
              </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>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                  <%--  <sfTags:pagePermission authFlag="CWGL_CZMX_CZMX_ADD_B" html='<button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-1"></i>新增</button>'/>--%>
                    <sfTags:pagePermission authFlag="CWGL_CZMX_CZMX_DC_B" html='<button id="exportBtn" class="layui-btn layui-btn-sm" lay-event="export"><i class="layui-icon layui-icon-export"></i>导出</button>'/>
                </div>
            </script>
        </div>
    </div>
</div>
<div id="lookImg" class="hide">
    <div class="w-500 h-500 lookImg">
        <img src="../../img1/banner004.jpg" width="80%" height="80%" />
    </div>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
        }).use(['index', 'tableExt', 'form','layer','laydate'], function() {
        $ = layui.$;
        tableExt = layui.tableExt;
       table = tableExt.getLayTable();
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;

        //开始日期
        var insStart = laydate.render({
            elem: '#startTime'
            ,done: function(value, date){
                //更新结束日期的最小日期
                insEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });

                //自动弹出结束日期的选择器
                insEnd.config.elem[0].focus();
            }
        });

        //结束日期
        var insEnd = laydate.render({
            elem: '#endTime'
            ,done: function(value, date){
                //更新开始日期的最大日期
                insStart.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        tableExt.render({
            elem: '#test'
            , height: 'full-250'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/order/orderCollections/orderCollectionsList'
            , cols: [[
                {type: 'numbers', fixed:'left', title:'序号'}
                , {field: 'order_number', title: '工单编号', fixed:'left', width: 200, sort: false, align: 'center', exportable: true}
                //, {field: 'service_measures', title: '服务措施', width: 100, sort: false, align: 'center', exportable: true}
                , {field: 'payment_amount', title: '收款金额', width: 100, sort: false, align: 'center', exportable: true}
                , {field: 'imgs', title: '收款凭证', width:100, sort: false, align: 'center', templet:function(d){
                    var imgs = d.imgs;
                    return '<span class="imgShowLook" imghref="'+imgs+'" style="color:#D9B589;cursor:pointer;"><img src="${commonStaticImgPath}'+imgs+'" alt="" style="width:25px;height:25px;" ></span>';
                }
                }
                , {field: 'site_name', title: '服务商名称', width: 200, sort: false, align: 'center', exportable: true}
                , {field: 'employe_name', title: '服务工程师', width: 150, sort: false, align: 'center', exportable: true}
                , {field: 'payment_type', title: '收款方式',width: 100, sort: false, align: 'center', exportable: true,templet:function(d){
                    if(d.payment_type=='0'){
                        return "支付宝"
                    }else if(d.payment_type=='1'){
                        return "微信"
                    }else{
                        return "其他"
                    }
                }  , expFormat: function (d) {
                    if(d.payment_type=='0'){
                        return "支付宝"
                    }else if(d.payment_type=='1'){
                        return "微信"
                    }else{
                        return "其他"
                    }
                }}
                , {field: 'create_time', title: '收款时间',width: 200, sort: false, align: 'center', exportable: true}
                , {field: 'power_station_name', title: '电站名称',width: 200, sort: false, align: 'center', exportable: true}
                , {field: 'customer_name', title: '用户姓名',width: 120, sort: false, align: 'center', exportable: true}
                , {field: 'customer_mobile', title: '联系方式',width: 120, sort: false, align: 'center', exportable: true}
                , {field: 'customer_address', title: '用户地址',width: 300, sort: false, align: 'center', exportable: true}
            ]],	done : function(res) {
                $(".imgShowLook").click(function() {
                    var href = $(this).attr("imghref");
                    $("#lookImg").find("img").attr("src", '${commonStaticImgPath}' + href);

                    layer.open({
                        type : 1,
                        title : '查看图片',
                        area : [ '500px', '543px' ],
                        shadeClose:true,
                        content : $('#lookImg')
                    })
                })
            }
            ,exportOpt: {
                ele: '#exportBtn',                   //导出的Dom元素
                headerTitle: '二维码收款记录',             //excel表格的标题
                pageData: false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 10000,                    //当pageData为false生效
                fileName: '二维码收款记录',
                where: function () {                 //当pageData为false时生效，过滤的条件
                    return _serializeJson(layui.$("#searchForm"), layui.$);
                }
            }
        });

        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'add':
                    layer.open({
                        type: 2
                        ,title: '新增'
                        ,content: '${ctx}/yangguang/financial/toAddRechargePage'
                        ,area: ['530px', '430px']
                        ,btn: ['确定', '取消']
                        ,yes: function(index, layero){
                            var iframeWindow = window['layui-layer-iframe'+ index]
                                ,submitID = 'sureSubmit'
                                ,submit = layero.find('iframe').contents().find('#'+ submitID);

                            //监听提交
                            iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                                var field = data.field; //获取提交的字段
                                addRechargeData(field,index);
                            });
                            submit.trigger('click');
                        },
                        success : function(layero) {
                            layero.find('.layui-layer-btn').css('text-align', 'center');
                            layero.find('.layui-layer-btn').find(".layui-layer-btn0").css("background-color","#009688");
                        }
                    });
                    break;
            };
        });

        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;

            //执行重载
            table.reload('test', {
                where: field,
                page: {
                    curr: 1
                }
            });
        });

    });

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


    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }
</script>
</body>
</html>

