<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="renderer" content="webkit">
    <!-- 移动设备 viewport -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <jsp:include page="../../common.jsp"/>
    <script type="text/javascript">
        require("js/deviceMerchantBuy/deviceMerchantBuyList.js");
    </script>

    <style>
        .layui-table th {
            text-align: center;
        }

        .layui-dropdown {
            min-width: 0px !important;
        }

        /*.layui-dropdown-item*/
        .layui-dropdown-item .layui-menu {background-color: #fff; border: none;}
        .layui-dropdown-item .layui-menu li{
            color: #fff;
            padding: 0;
        }

        .layui-menu {
            margin: 5px;
        }

        .layui-menu li, .layui-menu-body-title a {
            padding: 0;
        }

        .layui-menu-body-title a {
            display: block;
            margin: 0 !important;
            color: rgba(255,255,255,.8);
        }
    </style>
</head>
<body>
<div class="row animated fadeInRight" style="margin: 0;">
    <div class="wrapper wrapper-content mt5 right-content ml5 mr5">
        <div class="toolbar-panel bdd">
            <div class="toolbar-box">
                <div class="toolbar-head clearfix lgraybg pt5 pb10 pl10 bdbd">
                    <!-- 顶部按钮 -->
                    <div class="fl">
                        查询条件
                    </div>
                    <div class="tools fr">
                        <a href="javascript:void(0);" class="collapse dblock f14 dgray mr5">
                            <i class="fa-2x fa fa-angle-double-up"></i>
                        </a>
                    </div>

                </div>
            </div>

            <!--搜索条件 -->
            <div class="toolbar-body">
                <form class="layui-form" action="" style="margin-top: 10px" id="form1">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="userId" placeholder="请输入用户ID" id="userId" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">商户简称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="alias" placeholder="请输入商户简称" id="alias" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">订单号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="orderNo" placeholder="请输入订单号" id="orderNo" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">商品名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" placeholder="请输入商品名称" id="name" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">订单金额</label>
                            <div class="layui-input-inline">
                                <input type="number" name="orderAmt" placeholder="请输入订单金额" id="orderAmt" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">联系人</label>
                            <div class="layui-input-inline">
                                <input type="text" name="linkName" placeholder="请输入联系人" id="linkName" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">联系人手机</label>
                            <div class="layui-input-inline">
                                <input type="text" name="linkPhone" placeholder="请输入手机" id="queryLinkPhone" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">开始日期</label>
                            <div class="layui-input-inline">
                                <input type="text" placeholder="开始日期" id="date1" name="startTime" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">结束日期</label>
                            <div class="layui-input-inline">
                                <input type="text" placeholder="结束日期" id="date2" name="endTime" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>


                        <%--<div class="layui-inline">
                            <label class="layui-form-label">商户订单号</label>
                            <div class="layui-input-inline">
                                <input type="text" placeholder="请输入名称" id="transNo" class="layui-input">
                            </div>
                        </div>--%>

                        <div class="layui-inline">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-inline">
                                <select class="form-control f12 w180 textc" name="status" id="status">
                                    <option value="">请选择</option>
                                    <option value="0">待付款</option>
                                    <option value="1">已付款</option>
                                    <option value="2">已退款</option>
                                    <!--<option value="3">退款失败</option>
                                    <option value="4">支付失败</option> -->
                                </select>
                            </div>
                        </div>
                    </div>

                    <%--<div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">开始日期</label>
                            <div class="layui-input-inline">
                                <input type="text" placeholder="订单创建时间" id="date1" name="startTime" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">结束日期</label>
                            <div class="layui-input-inline">
                                <input type="text" placeholder="订单创建时间" id="date2" name="endTime" class="layui-input">
                            </div>
                        </div>
                    </div>--%>
                </form>
            </div>
        </div>
    </div>
    <div class="mb50 mt10">
        <div class="whitebg pl10 pr10">
            <table class="layui-hide" id="deviceMerchantBuyList" lay-filter="deviceMerchantBuyList"></table>
        </div>
    </div>
</div>
</body>

<script id="dealStatus" type="text/html">
    {{# if (d.status == '0') { }}
    <div style="color: red">待付款</div>
    {{# } else if (d.status == '1') { }}
    <div style="color: green;">已付款</div>
    {{# } else if (d.status == '2') { }}
    <div style="color: blue">已退款</div>
    {{# } else if (d.status == '3') { }}
    <div style="color: red;">退款失败</div>
    {{# } else if (d.status == '4') { }}
    <div style="color: red;">支付失败</div>
    {{# } }}
</script>

<script id="lineBar" type="text/html">
    <a class="layui-btn layui-btn-xs" lay-event="more">操作 <i class="layui-icon layui-icon-down"></i></a>
<%--{{# if (d.actStatus == '2') { }}--%>
<%--<a href="javascript:void(0);" lay-event="updateExpress"--%>
<%--   class="layui-btn layui-btn-radius layui-btn-xs fa fa-edit ops_more f12">快递单号</a>--%>
<%--<a href="javascript:void(0);" lay-event="showDevice"--%>
<%--         class="layui-btn layui-btn-xs layui-btn-radius fa fa-edit ops_more f12">详&emsp;&emsp;情</a>--%>
<%--<a href="javascript:void(0);" lay-event="initDeleteDevice"--%>
<%--        class="layui-btn layui-btn-radius layui-btn-xs layui-btn-danger fa fa-remove ops_more f12">删&emsp;&emsp;除</a>--%>
<%--{{# } else { }}--%>
<%--<a href="javascript:void(0);" lay-event="updateExpress"--%>
<%--   class="layui-btn layui-btn-radius layui-btn-xs fa fa-edit ops_more f12">快递单号</a>--%>
<%--<a href="javascript:void(0);" lay-event="updateQrCode"--%>
<%--        class="layui-btn layui-btn-radius layui-btn-xs fa fa-edit ops_more f12">设备编号</a>--%>
<%-- <a href="javascript:void(0);" lay-event="showDevice"--%>
<%--         class="layui-btn layui-btn-xs layui-btn-radius fa fa-edit ops_more f12">详&emsp;&emsp;情</a>--%>
<%--<a href="javascript:void(0);" lay-event="initDeleteDevice"--%>
<%--        class="layui-btn layui-btn-xs layui-btn-radius layui-btn-danger fa fa-remove ops_more f12">删&emsp;&emsp;除</a>--%>
<%--{{# } }}--%>
</script>

<script id="toolbarMenu1" type="text/html">
    <a href="javascript:void(0);" lay-event="updateExpress"
       class="layui-btn layui-btn-radius layui-btn-xs fa fa-edit ops_more f12">快递单号</a>
    </br> <a href="javascript:void(0);" lay-event="showDevice"
             class="layui-btn layui-btn-xs layui-btn-radius fa fa-edit ops_more f12">详&emsp;&emsp;情</a>
    </br><a href="javascript:void(0);" lay-event="initDeleteDevice"
            class="layui-btn layui-btn-radius layui-btn-xs layui-btn-danger fa fa-remove ops_more f12">删&emsp;&emsp;除</a>
</script>

<script id="toolbarMenu2" type="text/html">
    <a href="javascript:void(0);" lay-event="updateExpress"
       class="layui-btn layui-btn-radius layui-btn-xs fa fa-edit ops_more f12">快递单号</a>
    </br><a href="javascript:void(0);" lay-event="updateQrCode"
            class="layui-btn layui-btn-radius layui-btn-xs fa fa-edit ops_more f12">设备编号</a>
    </br> <a href="javascript:void(0);" lay-event="showDevice"
             class="layui-btn layui-btn-xs layui-btn-radius fa fa-edit ops_more f12">详&emsp;&emsp;情</a>
    </br><a href="javascript:void(0);" lay-event="initDeleteDevice"
            class="layui-btn layui-btn-xs layui-btn-radius layui-btn-danger fa fa-remove ops_more f12">删&emsp;&emsp;除</a>
</script>

<script id="actStatus" type="text/html">
    {{# if (d.actStatus == '2') { }}
    <div style="color: green">已激活</div>
    {{# } else { }}
    <div style="color: red">未激活</div>
    {{# } }}
</script>

<script type="text/template" id="setDeviceNo">
    <form class="layui-form" id="form2" style="margin-top: 2rem;">
        <input name="id" id="id" hidden>
        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">设备类型</label>
            <div class="layui-input-block">
                <select class="layui-select" name="groupNo" id="groupNo" lay-verify="required">
                    <option value="">请选择</option>
                    <c:forEach items="${deviceGroupDict}" var="device">
                        <option value="${device.value}">${device.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">设备编号</label>
            <div class="layui-input-block">
                <input type="text" name="snNo" id="snNo" placeholder="设备编号" autocomplete="off" class="layui-input">
            </div>
        </div>
    </form>
</script>

<script type="text/template" id="showDeviceDetail">

    <form class="layui-form" id="form3" style="width: 90%;">
        <div class="layui-form-item">
            <blockquote class="layui-elem-quote">订单信息</blockquote>
        </div>
        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">购买数量</label>
            <div class="layui-input-block">
                <input type="text" name="quantity" id="quantity" readonly placeholder="购买数量" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">订单金额</label>
            <div class="layui-input-block">
                <input type="text" name="orderAmount" id="orderAmount" readonly placeholder="订单金额" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">订单状态</label>
            <div class="layui-input-block">
                <input type="text" name="status" id="orderStatus" readonly placeholder="订单状态" autocomplete="off" class="layui-input layui-hide">
                <input type="text" name="statusDesc" id="statusDesc" readonly placeholder="订单状态" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <blockquote class="layui-elem-quote">收货信息</blockquote>
        </div>
        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">收货信息</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" id="addressComposite" readonly name="addressComposite"></textarea>
            </div>
        </div>

        <input class="layui-hide" name="id"/>

        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">收货人</label>
            <div class="layui-input-block">
                <input class="layui-input" name="linkName"/>
            </div>
        </div>

        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input class="layui-input" id="linkPhone" name="linkPhone" />
            </div>
        </div>

        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">省市区</label>
            <div class="layui-input-block">
                <input class="layui-input" id="provinces" name="provinces" />
            </div>
        </div>

        <div class="layui-form-item" style="width: 350px;">
            <label class="layui-form-label">详细地址</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" id="address" name="address"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">保存收货信息</button>
            </div>
        </div>
    </form>
</script>

<script id="toolBar" type="text/html">
    <a class="layui-btn layui-btn-sm fa fa-search f13" href="javascript:void(0);"
       onclick="queryDeviceMerchantBuy()"><span>搜索</span></a>
    <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" lay-event="print"><i class="layui-icon layui-icon-print"></i>打印圆通单号</button>
    <!-- <a class="layui-btn fa fa-plus f13 add" href="javascript:void(0);" onclick="initAddDeviceMerchantBuy()"><span>添加</span></a>
    <a class="layui-btn fa fa-edit f13" href="javascript:void(0);" onclick="initEditDeviceMerchantBuy()"><span>编辑</span></a>
    <a class="layui-btn fa fa-remove f13 delete" href="javascript:void(0);" onclick="initBatchDeleteDeviceMerchantBuy()"><span>删除</span></a> -->
</script>

<script type="text/javascript">
    var layer;
    var form;
    var table;
    var laydate;
    var dropdown;
    //form表单样式
    layui.use(['table', 'layer', 'form', 'dropdown'], function () {
        layer = layui.layer;
        form = layui.form;
        table = layui.table;
        laydate = layui.laydate;
        dropdown = layui.dropdown;
        form.render();

        form.on('submit(formDemo)', function(data){
            $.ajax({
                url: ctx + '/deviceMerchantBuy/update',
                type: 'post',
                contentType: "application/json",
                data: JSON.stringify(data.field),
                success: function(ret) {
                    if (ret.code == 200) {
                        layer.closeAll();
                        layer.msg(ret.message);
                        let params = serialize($('#form1'));
                        table.reload('deviceMerchantBuyList', {
                            where: params
                        });
                    }else{
                        layer.msg(ret.message);
                    }
                }
            });
            return false;
        });

        //执行一个 table 实例
        table.render({
            elem: '#deviceMerchantBuyList'
            , id: 'deviceMerchantBuyList'
            , url: ctx + '/deviceMerchantBuy/queryDeviceMerchantBuyByPage' //数据接口
            , autoSort: false
            , where: {
                alias: $("#alias").val(),
                orderNo: $('#orderNo').val(),
                transNo: $('#transNo').val(),
                status: $('#status').val(),
                startTime: $('#date1').val(),
                endTime: $('#date2').val(),
                userId: $('#userId').val()
            }
            , response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                , countName: 'count' //数据总数的字段名称，默认：count
                , dataName: 'data' //默数据列表的字段名称，认：data
                , statusCode: 200
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.records //解析数据列表
                };
            }
            , request: {
                pageName: 'current' //页码的参数名称，默认：page
                , limitName: 'size' //每页数据量的参数名，默认：limit
            }
            , title: 'app首页菜单表'
            , page: true //开启分页
            , toolbar: '#toolBar' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            , defaultToolbar: ['filter']
            , cols: [[ //表头
                {type: 'numbers'}
                , {type: 'checkbox'}
                /*   , {type: 'checkbox'}*/
                /* , {field: 'id', title: 'id'}*/
                , {field: 'userId', title: '用户ID', width: 90}
                , {field: 'orderNo', title: '订单号', width: 150}
                , {field: 'name', title: '商品名称', width: 150}
                , {field: 'deviceType', title: '商品类型/尺寸', width: 120}
                , {field: 'orderAmount', title: '订单金额', width: 90}
                , {field: 'quantity', title: '购买数量', width: 90}
                , {field: 'alias', title: '商户简称', width: 90}
                , {field: 'linkName', title: '联系人', width: 90}
                , {field: 'linkPhone', title: '联系人手机', width: 120}
                , {field: 'venderModel', title: '机具编码', width: 90}
                , {field: 'payName', title: '支付方式', width: 90}
                /* , {field: 'createDt', title: '创建时间'}*/
                , {field: 'transDt', title: '支付时间', width: 160}
                , {field: 'expressNo', title: '快递单号', width: 150}
                , {field: 'snNo', title: '设备编号', width: 150}
                , {field: 'actStatus', title: '激活状态', width: 90, templet: '#actStatus'}
                , {field: 'status', title: '状态', width: 90, templet: '#dealStatus'}
                , {fixed: 'right', title: '操作', minWidth: 90, align: 'center', toolbar: '#lineBar'}
            ]]
        });

        table.on('toolbar(deviceMerchantBuyList)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            if(checkStatus.data.length == 0){
                return layer.msg("最少选中一行数据！");
            }
            if(obj.event === "print"){
                let data = checkStatus.data;
                let ids = "";
                $.each(data,function (index,event){
                    ids += event.id + ",";
                })
                ids = ids.substring(0,ids.length -1);
                var loading = layer.load(1, {shade: [0.1, '#000']});
                $.ajax({
                    url: ctx + '/deviceMerchantBuy/printYtOrder',
                    type: "post",
                    dataType: "json",
                    data: {
                        "ids": ids,
                    },
                    success: function (result) {
                        layer.close(loading);
                        let index = layer.alert(result.message,{icon:result.code == 200 ? 1: 2},function (){
                            layer.close(index);
                            var params= serialize($('#form1'));
                            table.reload('deviceMerchantBuyList', {
                                where: params
                            });
                        })
                    }
                })

            }
        });

        //监听行工具事件
        table.on('tool(deviceMerchantBuyList)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var d = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            var that = this;
            if (layEvent === 'updateExpress') {
                updateExpressNo(d.id);
            } else if (layEvent === 'updateQrCode') {
                updateQrCodeNo(d.id);
            } else if (layEvent === 'showDevice') {
                showDeviceMerchantBuyDetails(d);
            } else if (layEvent === 'initDeleteDevice') {
                initDeleteDeviceMerchantBuy(d.id);
            } else if (layEvent === 'more') {
                if (d.actStatus == '2') {
                    dropdown.render({
                        elem: that
                        , show: true //外部事件触发即显示
                        , data: [{
                            title: 'menu item 1'
                            , templet: '<a href="javascript:void(0);" onclick="updateExpressNo(' + d.id + ')" class="layui-btn layui-btn-radius layui-btn-xs fa fa-edit ops_more f12">快递单号</a>'
                        }, {
                            title: 'menu item 1'
                            , templet: '<a href="javascript:void(0);" onclick="showDeviceMerchantBuyDetails(' + d + ')"  class="layui-btn layui-btn-xs layui-btn-radius fa fa-edit ops_more f12">详情</a>'
                        }, {
                            title: 'menu item 1'
                            , templet: '<a href="javascript:void(0);" onclick="initDeleteDeviceMerchantBuy(' + d.id + ')" class="layui-btn layui-btn-radius layui-btn-xs layui-btn-danger fa fa-remove ops_more f12">删除</a>'
                        }]
                        , className: 'layui-dropdown-item'
                    });
                } else {
                    let data = [{
                        id: 'updateExpressNo'
                        // onclick="updateExpressNo(' + d.id + ')"
                        , templet: '<a href="javascript:void(0);" class="layui-btn layui-btn-radius layui-btn-xs fa fa-edit ops_more f12">快递单号</a>'
                    }, {
                        id: 'updateQrCodeNo'
                        // onclick="updateQrCodeNo(' + d.id + ')"
                        , templet: '<a href="javascript:void(0);"  class="layui-btn layui-btn-xs layui-btn-radius fa fa-edit ops_more f12">设备编号</a>'
                    }, {
                        id: 'showDeviceDetail'
                        // onclick="showDeviceMerchantBuyDetails(' + d + ')"
                        , templet: '<a href="javascript:void(0);"  class="layui-btn layui-btn-xs layui-btn-radius fa fa-edit ops_more f12">详情</a>'
                    }];
                    // if(d.status == 1){
                    //     data.push({id: 'updateStatus', templet: '<a href="javascript:void(0);"  class="layui-btn layui-btn-xs layui-btn-radius fa fa-gratipay ops_more f12">设为退款</a>'})
                    // }
                    data.push({id: 'deleteDevice', templet: '<a href="javascript:void(0);"  class="layui-btn layui-btn-radius layui-btn-xs layui-btn-danger fa fa-remove ops_more f12">删除</a>'})
                    dropdown.render({
                        elem: that
                        , show: true //外部事件触发即显示
                        , data:data
                        , className: 'layui-dropdown-item'
                        , click:function (data,othis){
                            if(data.id === "updateExpressNo"){
                                updateExpressNo(d.id);
                            }else if(data.id === "updateQrCodeNo"){
                                updateQrCodeNo(d.id);
                            }else if(data.id === "showDeviceDetail"){
                                showDeviceMerchantBuyDetails(d);
                            }
                            // else if(data.id === "updateStatus"){
                            //     updateBuyOrderStatus(obj,"2");
                            // }
                            else{
                                initDeleteDeviceMerchantBuy(d.id);
                            }
                        }
                    });
                }
            }
        });

        function updateBuyOrderStatus(obj,status){
            let index = layer.load(1, {shade: [0.1, '#000']});
            $.ajax({
                url: ctx + '/deviceMerchantBuy/saveDeviceMerchantBuy',
                type: "post",
                dataType: "json",
                data: {
                    "status": status,
                    "id": obj.data.id,
                },
                success: function (result) {
                    layer.close(index);
                    if (result.resultCode == 1) {
                        obj.update({
                            status:2
                        })
                        layer.msg(result.resultMessage, {icon: 1});
                    } else {
                        layer.msg(result.resultMessage, {icon: 2});
                    }
                }
            })
        }
    });

    function updateQrCodeNo(id) {
        //var htmlStr = '<div class="layui-form-item" style="margin: 10px;"><label class="layui-form-label">二维码编号</label><div class="layui-input-block"><input id="qrNo" placeholder="请输入二维码编号" maxlength="10" style="width:130px" class="layui-input"></div></div>';
        layer.open({
            type: 1,
            title: '填充设备编号',
            area: ['450px', '350px'],
            shade: 0.3,
            maxmin: true,
            content: $("#setDeviceNo").html(),
            btn: ['确定', '取消'],
            yes: function () {
                var groupNo = $("#groupNo").val();
                if (!groupNo) {
                    layer.msg("设备类型不能为空!", {icon: 2});
                    return;
                }
                var snNo = $("#snNo").val();
                if (!snNo) {
                    layer.msg("设备编号不能为空!", {icon: 2});
                    return;
                }
                updateSnNo(id, groupNo, snNo);
            }
            , success: function () {
                form.render('select');
            }
        })
    }

    function updateSnNo(id, groupNo, snNo) {
        $.ajax({
            url: ctx + '/deviceMerchantBuy/updateSnNo',
            type: "post",
            dataType: "json",
            data: {
                "groupNo": groupNo,
                "snNo": snNo,
                "id": id,
            },
            success: function (result) {
                if (result.code == 200) {
                    layer.msg(result.message, {icon: 1});
                    queryDeviceMerchantBuy(pageIndex);
                    layer.closeAll();
                } else {
                    layer.msg(result.message, {icon: 2});
                }
            }
        })
    }

    //查询
    function queryDeviceMerchantBuy() {
        table.reload('deviceMerchantBuyList', {
            page: {
                curr: 1
            }
            , where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                alias: $("#alias").val(),
                orderNo: $('#orderNo').val(),
                transNo: $('#transNo').val(),
                status: $('#status').val(),
                startTime: $('#date1').val(),
                endTime: $('#date2').val(),
                userId: $('#userId').val(),
                name: $('#name').val(),
                orderAmount: $('#orderAmt').val(),
                linkName: $('#linkName').val(),
                linkPhone: $("#queryLinkPhone").val()
            }
        });
    }
</script>
</html>

