<?php include_once(mvc::$cfg['PATH_TPL'].'public/headBase2.php');?>
<div class="layui-card">
    <div class="layui-card-body">
        <div style="padding:0 10px 10px 0;" style="width: 1000px;">
            <form class="layui-form">
                <div class="layui-inline w180">
					<a href="<?php echo mvc::$cfg['ADMIN_URI'];?>shop/shopSyncSet" style="color:#fff;" class="layui-btn layui-btn-normal" target="_blank"><i class="layui-icon">&#xe608;</i>添加配置</a>
                </div>
                <div class="layui-inline w300">
                    <label class="layui-form-label">关键字</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" type="text" name="keyword" class="layui-input" value="<?php echo $Params['keyword'];?>" placeholder="请输入店铺ID\源店铺名称\目标店铺名称">
                    </div>
                </div>

                <div class="layui-inline">
                    <button class="layui-btn act-btn" type="submit">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </form>
        </div>
        <table class="layui-table YpTable" style="width: 50%">
            <thead class="Filter Sortable">
				<tr>
					<th width="50">操作</th>
					<th width="100" class="Sort"><span>源店铺</span></th>
                    <th width="100" class="Sort"><span>目标店铺</span></th>
					<th width="50" class="Sort"><span>配置时间</span></th>
					<th width="50" class="Sort"><span>最后执行时间</span></th>
				</tr>
				<tr>
					<td></td>
					<td><input type="text" class="FilterTxt layui-input"></td>
					<td><input type="text" class="FilterTxt layui-input"></td>
					<td><input type="text" class="FilterTxt layui-input"></td>
					<td><input type="text" class="FilterTxt layui-input"></td>
				</tr>
            </thead>
            <tbody>
            <?php if(!empty($syncList)){ ?>
                <?php foreach($syncList as $k => $v ){ ?>
                    <tr>
                        <td>
                            <a class="layui-btn layui-btn-normal layui-btn-xs" href="<?php echo mvc::$cfg['ADMIN_URI'];?>shop/shopSyncSet?sss_shop_id_from=<?php echo $v['sss_shop_id_from'];?>&sss_shop_id_to=<?php echo $v['sss_shop_id_to'];?>" target="_blank">编辑</a>
                            <button class="layui-btn layui-btn-xs" onclick="syncDel(<?php echo $v['sss_shop_id_from'] ?>,<?php echo $v['sss_shop_id_to'] ?>)">删除</button>
                        </td>
                        
                        <td>
                           
                            <?php echo $v['shop_name_from'].'('.$v['sss_shop_id_from'].')';?>
                        </td>
                        <td>
                            <?php echo $v['shop_name_to'].'('.$v['sss_shop_id_to'].')';?>
                        </td>
        
                        <td>
                            <?php echo $v['sss_etime']?date('Y-m-d H:i:s', $v['sss_etime']):''; ?>
                        </td>
                        <td>
                            <?php echo $v['sss_runtime']?date('Y-m-d H:i:s', $v['sss_runtime']):''; ?>
                        </td>
                    </tr>
                <?php }?>
            <?php }else{ ?>
                <tr>
                    <td colspan="8" style="text-align:center;">无相关数据</td>
                </tr>
            <?php }?>
            </tbody>
        </table>
        <?php echo $Page;?>
    </div>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'].'public/footBase.php');?>
<script>
    layui.use(['table', 'form'], function(){
        var table = layui.table,form = layui.form;
    
    });

    function syncDel(from,to) {
        layer.confirm('确定删除吗？', function(index) {
            $.ajax({
                url:ADMIN_URI + 'shop/delShopSync?isAjax=1&sss_shop_id_from=' + from +'&sss_shop_id_to='+to,
                dataType: "json",
                success: function (res) {
                    if (res.status) {
                        layer.msg('操作成功', {icon: 1, time:1000}, function(){
                            window.location.reload();
                        });
                    } else {
                        layer.msg('删除失败', {icon: 5, time:1000}, function () {
                              window.location.reload();
                        });
                    }
                }
            });
        });
    }
</script>
