index.php 10.1 KB
<?php

use app\ht\helpers\CssFiles;
use app\ht\widgets\LinkPager;
use yii\helpers\Url;


$this->title =  "设置收信息工程师";
$this->params['breadcrumbs'][] = '系统管理';
$this->params['breadcrumbs'][] = $this->title;

CssFiles::register($this, 'exts/base/1.0.0/ui/switch/switch-1.0.0.css');
CssFiles::register($this, 'exts/base/1.0.0/ui/select2/select2-1.0.0.css');
CssFiles::register($this, 'exts/base/1.0.0/ui/select2/select2-bootstrap-1.0.0.css');

?>



<form action="<?php echo Url::toRoute(['/system/administrators/do-add']); ?>" name="customerForm" id="customerForm" method="post">
    <div class="panel panel-default">
        <div class="panel-body">
            <table  class="panel-box-tb">
                <tbody>
                <tr>
                    <td class="text-right" style="width: 10%">
                        <b>可接收信息工程师:</b>
                    </td>
                    <td style="width: 75%">
                        <input type="hidden" value="0" id="engineer_id" name="engineer_id" />
                        <input class="form-control" id="engineer" name="engineer" placeholder="请录入工程师手机或名称" autocomplete="off" />
                    </td>
                    <td  style="width: 15%">
                        <button type="submit" class="btn btn-primary" id="save">添加</button>&nbsp;&nbsp;&nbsp;&nbsp;
                        <a class="btn btn-default" href="<?php echo Url::toRoute('/system/administrators/index'); ?>">重&nbsp;&nbsp;&nbsp;&nbsp;置</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</form>
<form action="<?php echo Url::toRoute(['/system/administrators/index']); ?>" name="customerForm" id="customerForm" method="get">
    <div class="panel panel-default">
        <div class="panel-body">
            <table  class="panel-box-tb">
                <tbody>
                    <tr>
                        <td class="text-right" style="width: 10%">
                            <b>工程师姓名:</b>
                        </td>
                        <td>
                            <input class="form-control" id="engineerName" name="engineerName" value="<?=$gets["engineerName"]?>" placeholder="请录入工程师名称"/>
                        </td>
                        <td class="text-right" style="width: 10%">
                            <b>手机号码:</b>
                        </td>
                        <td>
                            <input class="form-control" id="engineerPhone" name="engineerPhone" value="<?=$gets["engineerPhone"]?>" placeholder="请录入工程师手机"/>
                        </td>
                        <td>
                            <button type="submit" class="btn btn-primary" id="search">查询</button>&nbsp;&nbsp;&nbsp;&nbsp;
                            <a class="btn btn-default" href="<?php echo Url::toRoute('/system/administrators/index'); ?>">重&nbsp;&nbsp;&nbsp;&nbsp;置</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</form>
<div class="panel panel-default">
    <div  class="panel-body">
        <?php if (!empty($dataList)) : ?>
            <div class="table-responsive">
                <table class="table table-striped table-bordered"  id="brand-table">
                    <thead>
                    <tr>
                        <th style="width:5%;"  class="text-center align-middle hqy-row-select">ID</th>
                        <th style="width:10%;">工程师信息</th>
                        <th style="width:15%;">是否接收订单通知</th>
                        <th style="width:15%;">是否可以分享订单</th>
                        <th style="width:15%;">是否可以接收客服通知</th>
                        <th style="width:15%;">是否可以接收营销活动通知</th>
                        <th style="width:10%;">添加时间</th>
                        <th style="width:15%;">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($dataList as $data) : ?>
                        <tr>
                            <td class="itemcls" data="<?= $data['id'] ?>"><?= $data['id'] ?></td>
                            <td >
                                昵称:<?= $data['nickname'] ?> <br/>
                                真实姓名:<?= $data['realname'] ?> <br/>
                                手机号码:<?= $data['phone'] ?> <br/>
                            </td>
                            <td>
                                <input type="checkbox" class="switch notify_check_open" data-on-text="是"  data-off-text="否" <?php if ($data['is_order_notify'] == 0) echo 'checked' ?> data-id="<?= $data['id'] ?>" />
                            </td>
                            <td >
                                <input type="checkbox"class="switch share_check_open" data-on-text="是"  data-off-text="否" <?php if ($data['is_order_share'] == 0) echo 'checked' ?>  data-id="<?= $data['id'] ?>"/>
                            </td>
                            <td >
                                 <input type="checkbox" class="switch cs_check_open" data-on-text="是"  data-off-text="否" <?php if ($data['is_cs_notify'] == 0) echo 'checked' ?>  data-id="<?= $data['id'] ?>"/>
                            </td>
                            <td >
                                <input type="checkbox" class="switch activity_check_open" data-on-text="是"  data-off-text="否" <?php if ($data['is_activity_notify'] == 0) echo 'checked' ?>  data-id="<?= $data['id'] ?>"/>
                            </td>
                            <td >
                                <?= date('Y-m-d H:i:s', $data['created_at']) ?>
                            </td>
                            <td class="row_<?= $data['id'] ?>">
                                <form action="<?php echo Url::toRoute(['/system/administrators/delete']); ?>" name="MyForm<?= $data['id'] ?>" id="MyForm<?= $data['id'] ?>" method="get">
                                    <input type="hidden" id="id" name="id" value="<?= $data['id'] ?>"/>
                                    <button type="submit" class="btn btn-primary" id="delete">删除</button>
                                </form>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        <?php else : ?>
            <p class="text-center">
                没有找到数据
            </p>
        <?php endif; ?>
    </div>

    <div class="panel-footer">
        <div class="hqy-panel-pager">
            <?= LinkPager::widget([
                'pagination' => $pages,
            ]); ?>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
<script type="text/javascript" src="<?=Url::toRoute('/exts/base/1.0.0/ui/typeahead/bootstrap3-typeahead.min.js')?>" ></script>
<script>
    var searchItemUrl = "<?=Url::toRoute('/system/administrators/search-engineer')?>";
    seajs.use("base/1.0.0/ui/switch/switch-1.0.0",function  () {
        $(".switch").bootstrapSwitch(
            {
                onSwitchChange: function (event, state) {
                   var className = event.target.className;
                   var dataId = event.target.attributes["data-id"].value;
                    //监听switch change事件,可以根据状态把相应的业务逻辑代码写在这里
                    /*if (state == true) {
                        $("#state").html('switch turn no')
                    } else {
                        $("#state").html('switch turn off')
                    }*/
                    if (className == "switch notify_check_open") {
                        window.location.href = "<?php echo Url::toRoute(['/system/administrators/enable-order-notify']); ?>" + "?id=" + dataId;
                    } else if (className == "switch share_check_open") {
                        window.location.href = "<?php echo Url::toRoute(['/system/administrators/enable-order-share']); ?>" + "?id=" + dataId;
                    } else if (className == "switch cs_check_open") {
                        window.location.href = "<?php echo Url::toRoute(['/system/administrators/enable-cs-notify']); ?>" + "?id=" + dataId;
                    } else if (className == "switch activity_check_open") {
                        window.location.href = "<?php echo Url::toRoute(['/system/administrators/enable-activity-notify']); ?>" + "?id=" + dataId;
                    }
                }
            }
        );
        $(".switch").bootstrapSwitch('toggleState', true);
    });

    // 表单提交验证
    seajs.use("base/1.0.0/unit/validate/custom-1.0.0",function  () {
        var validator = $("#customerForm").validate({
        });
    });
    $(document).ready(function () {
        $('#engineer').typeahead({
            minLength: 1,
            items:25,
            source: function(query, process) {

                var parameter = $.csrf({query: query});
                $.post(searchItemUrl, parameter, function (res) {
                    var data = [];
                    var iList = res.list;
                    for(i in iList){
                        var tItem = iList[i];
                        data.push(JSON.stringify(tItem));
                    }
                    process(data);
                },'json');
            },
            highlighter: function(item) {
                var itemObject = JSON.parse(item);
                var title = itemObject.name + "(" + itemObject.nickname + ")" + itemObject.phone;
                return  title ;
            },

            updater: function(item) {
                var itemObject = JSON.parse(item);
                var title = itemObject.name + "(" + itemObject.nickname + ")" + itemObject.phone;
                $('#engineer_id').val(itemObject.id);
                return title;
            }
        });
        $('#engineer').change(function(){
            var currV = $(this).val();
            if ('' == $.trim(currV)){
                $('#engineer_id').val(0);
            }
        })
    });
</script>