index.php 7.47 KB
<?php
use yii\helpers\Url;
use app\ht\widgets\LinkPager;
use common\helpers\ImageManager;
use domain\shop\ShopItemStatus;

$this->title = '厂商管理';
$this->params['breadcrumbs'][] =  $this->title;
?>
<style>
    .table > tbody > tr > td
    {
        border: white 0px solid;
        border-top: solid 1px #fff;
        border-bottom: 1px solid #fff;
    }
    .table{
        margin-bottom: 0px!important;
    }
</style>
<div class="panel panel-default">
    <div class="panel-body">
        <form action="" method="get" id="search-form" class="filter-form">
            <table width="100%" class="table">
                <tbody>
                <tr >
                    <td width="10%" class="text-right">厂商名称:</td>
                    <td width="20%" class="text-left"><input type="text" placeholder="厂商关键字" autocomplete="off" class="form-control" name="name" id="name" value="<?php if (!empty($gets['name'])){ echo $gets['name']; } ?>"></td>
                    <td width="10%" class="text-right">联系电话:</td>
                    <td width="20%" class="text-left"><input type="text" placeholder="联系电话键字" autocomplete="off" class="form-control" name="phone" id="phone" value="<?php if (!empty($gets['phone'])){ echo $gets['phone']; } ?>"></td>
                    <td width="10%" class="text-right">账号:</td>
                    <td width="20%" class="text-left"><input type="text" placeholder="输入登录账号" autocomplete="off" class="form-control" name="loginName" id="loginName" value="<?php if (!empty($gets['loginName'])){ echo $gets['loginName']; } ?>"></td>
                </tr>
                <tr >
                    <td width="10%" class="text-right">厂商添加开始时间:</td>
                    <td width="20%" class="text-left"><input type="date" class="form-control" name="creatTime" value="<?php if (!empty($gets['creatTime'])){ echo $gets['creatTime']; } ?>"></td>
                    <td width="10%" class="text-right">厂商添加结束时间:</td>
                    <td width="20%" class="text-left"><input type="date" class="form-control" name="endTime" value="<?php if (!empty($gets['endTime'])){ echo $gets['endTime']; } ?>"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr class="search">
                    <td colspan="6"  class="text-center">
                        <button type="submit" class="btn btn-primary btncls" id="search"><i class="glyphicon glyphicon-search"></i> 查 询  </button>
                        <a class="btn btn-default btncls" href="<?=Url::toRoute(["/manufacturer/manufacturer/index"])?>">重&nbsp;&nbsp;&nbsp;&nbsp;置</a>
                        <a class="btn btn-default" style="float: right;" href="javascript:void(0)" id="btn-export"> 导出数据 </a>&nbsp;&nbsp;
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>

<div class="panel panel-default">
    <div  class="panel-body">
        <div style="margin-bottom: 15px;text-align: right;">
            <a href="<?=Url::toRoute("/manufacturer/manufacturer/create")?>" class="btn btn-success"> + 创建厂商</a>
        </div>
        <table class="table table-striped table-bordered"  id="brand-table">
            <thead>
            <tr>
                <th width="10%">厂商名称</th>
                <th width="10%">编号</th>
                <th width="10%">联系电话</th>
                <th width="10%">账号</th>
                <th width="10%">密码</th>
                <th width="10%">注册时间</th>
                <th width="20%">操作</th>
            </tr>
            </thead>

            <tbody>
            <?php if ($listdata) { ?>
                <?php foreach ($listdata as $item) : ?>
                    <tr>
                        <td style="padding:12px;"><?= (isset($item["name"]) ? $item["name"] : "") ?></td>
                        <td style="padding:12px;"><?= (isset($item["manufacture_no"]) ? $item["manufacture_no"] : "") ?></td>
                        <td style="padding:12px;"><?= (isset($item["phone"]) ? $item["phone"] : "") ?></td>
                        <td style="padding:12px;"><?= (isset($item["username"]) ? $item["username"] : "") ?></td>
                        <td style="padding:12px;"><?= (isset($item["cutpassword"]) ? $item["cutpassword"] : "******") ?></td>
                        <td style="padding:12px;"><?= date("Y-m-d H:i:s", $item['created_at'])?></td>
                        <td style="padding:12px;">
                            <button class="btn btn-danger btn-sm btn_del" aid="<?=$item['id'] ?>">删除</button>&nbsp;|&nbsp;
                            <a class="btn btn-info btn-sm btn_auth_success" href="<?=Url::toRoute(["/manufacturer/manufacturer/edit", "mid" => $item['id']])?>" aid="<?=$item['id'] ?>">编辑</a>  &nbsp;|&nbsp;
                            <a class="btn btn-success btn-sm btn_auth_fail" href="<?=Url::toRoute(["/manufacturer/manufacturer/edit", "mid" => $item['id']])?>" aid="<?=$item['id'] ?>">查看</a>
                        </td>
                    </tr>
                <?php endforeach; ?>
            <?php } else { ?>
            <tr>
                <td colspan="6">
                    <center>暂无记录</center>
                </td>
            </tr>
            <?php } ?>
            </tbody>
        </table>
    </div>

    <div class="panel-footer">
        <div class="hqy-panel-pager">
            <?= LinkPager::widget([
                'pagination' => $pages,
            ]); ?>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
<script>
    window.queryParams = function(params) {
        $("#search-form").find('input[name]').each(function () {
            var val = $(this).val();
            var name = $(this).attr('name');
            if(val){
                params[name] = val;
            }
        });
        return params;
    }
    $(document).ready(function () {
        $(".btn_del").bind("click",function () {
            if (confirm("确定要删除该厂商吗?对应厂商的登录账号也会一并删除,请谨慎操作")){
                var data_id = $.trim($(this).attr("aid"));
                if (data_id == null || data_id == ""){
                    alert("丢失参数,暂时无法删除,请刷新后再试");
                    return false;
                }
                var thiz = $(this);
                $.ajax({
                    type: "post",
                    url: "do-del",
                    dataType:"json",
                    data: $.csrf({"data_id":data_id}),
                    success:function(msg){
                        alert(msg['msg']);
                        if (msg['status'] == 1){
                            thiz.parents("tr").remove();
                        }else{
                            //提示确认失败
                        }
                    },
                    error:function(msg){
                        //提示确认失败
                    }
                });
            }
        });
        $('#btn-export').click(function(e){
            var params = {};
            window.queryParams(params);

            $strQuery = "?";
            if (params) {
                for (var p in params) {
                    $strQuery += p + "=" + params[p] + "&";
                }
            }
            $strQuery = $strQuery.substring(0, $strQuery.length-1);
            window.location.href = "export" + $strQuery;
            return false;
        })
    });
</script>