e58f825016485cebe8b56d16fc9c36ae.php 11.5 KB
<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:61:"E:\WWW\sos\public/../application/web\view\turn_prize\user.php";i:1603332577;}*/ ?>
<!DOCTYPE html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title>表单填写</title>
    <link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/easyui.css" />
    <link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/menu.css" />
    <link rel="stylesheet" type="text/css" href="/assets/common/css/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="/assets/web/css/jitnry.css" />
    <link rel="stylesheet" type="text/css" href="/assets/web/css/common_car.css" />
    <script type="text/javascript" src="/assets/common/js/jquery.min.1.9.4.js"></script>
    <script type="text/javascript" src="/assets/common/js/jquery.easyui.min.1.9.4.js"></script>
    <script type="text/javascript" src="/assets/common/js/jquery.cookie.1.4.1.js"></script>
    <!-- 插件调用 --->
    <script type="text/javascript" src="/assets/common/js/datagrid-detailview.js"></script>
    <script type="text/javascript" src="/assets/common/locale/easyui-lang-zh_CN.js"></script>
    <!-- 基础 JS 调用 -->
    <script type="text/javascript" src="/assets/web/js/src/easyui.base.js"></script>
    <script type="text/javascript" src="/assets/web/js/src/allCity.js"></script>
</head>
<body style="margin-bottom: 54px;">
<div class="easyui-layout" data-options="fit:true">
    <div data-options="split:true,region:'center',collapsible:true,footer:'#win_base_org_form_footer'"   id="saveBox" style="width:100%;">
        <table class="easyui-datagrid" title="中奖用户列表" id="dg"  style="width: 100%; height: 482px"
               data-options="rownumbers:true,singleSelect:true,pagination:true,url:'/products/Turn_prize/prize_user_list',method:'get',
                   onDblClickRow :function(rowIndex,rowData){
                        memnerid = rowData;
  				        showSelectedSurveryDataOnMap(rowData);
     				},toolbar:'#tb'">
            <thead>
            <tr>
                <th data-options="field:'uname',width:250,align:'center'">名称</th>
                <th data-options="field:'phone',width:200,align:'center'">电话</th>
<!--                <th data-options="field:'prizeName',width:250,align:'center'">奖品名称</th>-->
                <th data-options="field:'prizeName',width:150,align:'center',styler: function (value, row) {
                console.log(value)
                if(value =='双击查看'){
                    return 'color:red;background:url('icons/20200228/search.png')'
                }
           }" ><b>奖品名称</b></th>

                <th data-options="field:'source',width:200,align:'center'">部门</th>
                <th data-options="field:'addTime',width:300,align:'center'">中奖时间</th>
<!--                <th data-options="field:'id',width:150,formatter:formatOper,align:'center'">操作</th>-->
                <th data-options="field:'num',width:150,align:'center',formatter:function(value,row,index){
                   if (value == 1) {
                       return '<a onclick=showUser(\''+row.id+'\')>删除</a>';
                   }else{
                        return '<a onclick=showUser1(\''+row.id+'\')>删除</a>';
                   }}" ><b>操作</b></th>
            </tr>
            </thead>
        </table>
        <div id="tb" style="padding:5px;height:auto;">
            <div>
                部门:
                <input class="easyui-combobox" style="width:125px" name="materialname" id="materialname"
                       data-options="valueField:'id',
                                            textField:'text',
                                            data:
                                        [{ 'id':'',
                                            'text':'全部' ,
                                            selected:true
                                        },{
                                            'id':'department1',
                                            'text':'区部一'
                                        },{
                                            'id':'department2',
                                            'text':'区部二'
                                        }] ,panelHeight:'auto',onChange:function(){getweight();}
                            "/>
                Date From: <input class="easyui-datebox"  id='start' name='start' style="width:180px">
                To: <input class="easyui-datebox" id='end' name='end' style="width:180px">
                Phone: <input class="easyui-numberbox" type="text" id='phone' name='phone'>
                Name: <input class="easyui-textbox" type="text" id='uname' name='uname'>
                <a href="#" class="easyui-linkbutton" id="search_btn" iconCls="icon-search">搜索</a>
                <a id="derive_btn" href="/products/Turn_prize/to_excel"  class="easyui-linkbutton" style="height:28px" data-options="iconCls:'icon-undo'">导出</a>
            </div>
        </div>
        <div class="easyui-layout" style="width:100%;height:272px;">
            <div data-options="region:'center',title:'奖品详情',split:true" style="height:500px;">
                <table id="double-click"></table>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    //设置操作按钮
    function formatOper(val, row, index) {
        return '<a href="javascript:void(0)" onclick="showUser(' + val + ')">删除</a>';
    }

    function showUser1(row) {
        $.messager.alert('Warning','请双击后在列表中删除');
    }
        //删
    function showUser(row){
        //请双击后在列表中删除
        if(confirm("确实要删除?")){
            var result = {
                id:row
            }
            $.ajax({
                url:'/products/Turn_prize/del_user',
                type: "post",
                data: result,
                success: function (data) {
                    console.log(data);
                    $('#dg').datagrid('reload');
                    $('#double-click').datagrid('reload');
                    $.messager.alert("提示", data.msg);
                },
                error:function(data){
                    console.log(data)
                }
            })
        }
    }

    //下拉框搜索
    function getweight(){
        var source=$('#materialname').combobox('getValue');
        var start = $("#start").val();
        var end = $("#end").val();
        var phone = $("#phone").val();
        var name = $("#uname").val();
        if(phone.length>0){
            if(phone.length!=11){
                $.messager.alert('检索手机号','手机号格式错误,请重新输入');
                return false;
            }
        }
        var result = {
            source,
            start,
            end,
            phone,
            name
        }
        init_datagrid('/products/Turn_prize/prize_user_list', result);
    }
    //时间搜索
    //搜索按钮
    $('#search_btn').bind('click', function() {

        var _data = $('#dg').data('datagrid'); // 拿到datagrid初始化的数据缓存
        if(_data && _data.options){
            _data.options.pageNumber = 1; // 修改缓存
        }
        $.data($('#dg')[0], 'datagrid', _data); // 把修改写回去


        var source=$('#materialname').combobox('getValue');
        var start = $("#start").val();
        var end = $("#end").val();
        var phone = $("#phone").val();
        var name = $("#uname").val();
        if(phone.length>0){
            if(phone.length!=11){
                $.messager.alert('检索手机号','手机号格式错误,请重新输入');
                return false;
            }
        }
        var result = {
            source,
            start,
            end,
            phone,
            name
        }
        //console.log(result);return false;
        init_datagrid('/products/Turn_prize/prize_user_list', result);
    });

    function init_datagrid(data_url, res) {

        //表头字段
        var arr_columns = dg_columns();
        $("#dg").datagrid({
            rownumbers:true,
            singleSelect:true,
            pagination:true,
            url:data_url,
            queryParams: res,
            method:'post',
            columns: [arr_columns],
            loadMsg: '正在加载数据',
            emptyMsg: '列表为空',
        });
    }
    function dg_columns() {
        var arr = new Array();
        arr.push({
            field: 'uname',
            title: '名称',
            width: 250,
            align: 'center'
        });
        arr.push({
            field: 'phone',
            title: '电话',
            width: 200,
            align: 'center'
        });

        arr.push({
            field: 'prizeName', title: '奖品名称', width: 150, align: 'center', styler: function (value, row) {
            if (value == '双击查看') {
                return 'color:red;'
            }
        }
        });

        // arr.push({
        //     field: 'prizeName',
        //     title: '奖品名称',
        //     width: 250,
        //     align: 'center'
        // });
        arr.push({
            field: 'source',
            title: '部门',
            width: 200,
            align: 'center'
        });
        arr.push({
            field: 'addTime',
            title: '中奖时间',
            width: 300,
            align: 'center'
        });
        arr.push({
            field: 'id',
            formatter:formatOper,
            title: '操作',
            width: 150,
            align: 'center'
        });
        // console.log(arr)
        return arr;
    }
    //添加
    $('#name_add_but').linkbutton({
        onClick: function () {
            addFile();
        }
    });
    function addFile(){
        var id='';
        if(confirm("确实要重置抽奖次数?")){
            $.ajax({
                url:'/products/Turn_prize/prize_reset',
                type: "POST",
                data: id,
                contentType: false,
                processData: false,
                success: function (data) {
                    console.log(data);
                    $.messager.alert("提示", data.msg);

                },
                error:function(data){
                    console.log(data)
                }
            })
        }else {
            alert("已经取消了操作");
        }
    }

    //双击事件
    var showSelectedSurveryDataOnMap=function(rowData){
        if(rowData.num > 1){
            var id=rowData.member_id;
            var page=0;
            var res = {
                id,
                page
            }
            $('#double-click').datagrid({
                url:'/products/Turn_prize/prize_user_list',
                queryParams: res,
                fit:true,

                collapsible:true,
                iconCls:'kbi-icon-record',
                singleSelect:true,
                border:false,
                rownumbers:true,
                columns:[[
                    {field:'uname',title:'姓名',width:250,align:'center'},
                    {field:'phone',title:'电话',width:200,align:'center'},
                    {field:'prizeName',title:'奖品名称',width:250,align:'center'},
                    {field:'source',title:'部门',width:200,align:'center'},
                    {field:'addTime',title:'中奖时间',width:300,align:'center'},
                    {field:'id', formatter:formatOper, title: '操作',width: 150,align: 'center'},
                ] ],

            });
        }
    }


</script>
</html>