<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <LINK rel="Bookmark" href="/favicon.ico">
    <LINK rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <script type="text/javascript" src="lib/PIE_IE678.js"></script>
    <![endif]-->
    <link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath }/common/admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath }/common/admin/skin/default/skin.css" rel="stylesheet" type="text/css" id="skin" />
    <link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath }/common/admin/css/style.css" rel="stylesheet" type="text/css" />

    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>产品列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>
    商城管理 <span class="c-gray en">&gt;</span>代理商优惠价管理 <a
        class="btn btn-success radius r mr-20"
        style="line-height: 1.6em; margin-top: 3px"
        href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="pd-20">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="${pageContext.request.contextPath }/admin/agentTooth/_add_agent_config" class="btn btn-primary radius">
				<i class="Hui-iconfont">&#xe600;</i> 添加优惠价
			</a>
		</span>
        <form action="${pageContext.request.contextPath }/admin/agentTooth/select_agent_config_list" method="post" id="searchForm">
            <div class="text-c">
                <input type="text" class="input-text" style="width:200px" placeholder="请输入商户名称" value="" name="agentName">
                <input type="text" class="input-text" style="width:200px" placeholder="请输入电话号码" value="" name="agentName">
                <input type="text" class="input-text" style="width:200px" placeholder="请输入产品名称" value="" name="agentName">
                <input type="text" class="input-text" style="width:200px" placeholder="请输入产品颜色" value="" name="agentName">
                <button type="button" class="btn btn-success radius" id="searchButton" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
            </div>
        </form>
    </div>
    <form id="configform" >
        <table class="table table-border table-bordered table-bg" id="example">
            <thead>
            <tr>
                <th scope="col" colspan="11">赠品列表</th>
            </tr>
            <tr class="text-c">
                <th width="150">商户名称</th>
                <th width="100">产品名称</th>
                <th width="100">产品颜色</th>
                <th width="130">采购金额</th>
                <th width="90">状态</th>
                <th width="130">创建时间</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:if test="${! (empty configList) }">
            <c:forEach items="${configList }" var="config">
            <tr class="text-c">
                <input type="hidden" value="${config.configId }" name="configId">
                <td>${config.agentName }</td>
                <td>${config.productName }</td>
                <td>${config.colorName }</td>
                <td>${config.configAmount==null?"":config.configAmount/100 }</td>
                <td id="config_status">${config.configStatus==1?'启用':''}${config.configStatus==2?'停用':''}</td>
                <td><fmt:formatDate value="${config.configCreateTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td class="td-manage">
                    <input id="configStatus" type="hidden" value="${config.configStatus }">
                    <select id="goodstatus" name="" onchange="updateGiftState(this,${config.configId })">
                        <option value="1" ${config.configStatus==1?'selected':''}>正常</option>
                        <option value="2" ${config.configStatus==2?'selected':''}>停用</option>
                    </select>
                    <a onclick="config_edit('${pageContext.request.contextPath }/admin/agentTooth/_update_agent_config?configId=${config.configId }')"
                       title="编辑" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                </td>
                </c:forEach>
                </c:if>
            </tbody>
        </table>
        <div align="right" class="mt-10 mb-10 mr-10">
            <%@include file="/common/other/paper/pager.jsp"%>
        </div>
    </form>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/tips.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/js/page/jqPaginator.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/goods/js/utils.js"></script>
<script type="text/javascript">
    function updateGiftState(_this,id){
        var obj = $(_this);
        layer.confirm('确认要修改状态吗？',function(index){
                $.ajax({
                    url: '${pageContext.request.contextPath }/admin/agentTooth/update_agent_config_status',
                    type: "POST",
                    dataType: "json",
                    data: {configId : id,configStatus : obj.val()},
                    error:function(data){
                        layer.msg("修改失败</br>",{icon: 5,time:2000});
                    },
                    success:  function(data){
                        if (data.status) {
                            layer.msg("修改成功</br>",{icon: 1,time:2000});
                            var message = '';
                            switch (obj.val()) {
                                case "1":
                                    message = '启用';
                                    break;
                                case "2":
                                    message = '停用';
                                    break;
                            }
                            $('#config_status').html(message);
                        } else {
                            layer.msg("修改失败</br>",{icon: 5,time:2000});
                        }
                    }
                });
            }, function () {
                window.location.reload(location.href);
            }
        );

    }
    /**
     * 打开修改商品界面
     */
    function config_edit(url){
        window.location.href = url;
    }
</script>
</body>
</html>