<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%@ include file="/WEB-INF/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link rel="stylesheet" href="${ctxwxsta}/css/public.css">
    <link rel="stylesheet" href="${ctxwxsta}/css/basic.css">
    <script src="${ctxwxsta}/js/flexible.js"></script>
    <script src="/static/weixin/common/layer_mobile/layer.js"></script>
    <link rel="stylesheet" href="/static/weixin/common/layer_mobile/need/right.css">
    <title>删除已分配产品</title>
</head>
<body id="contain">
<div class="contain">
    <div class="bai-head">
        <span>删除已分配产品</span>
        <a href="javascript:;" onclick="fanhui()" class="left">
            <img src="${ctxwxsta}/images/head-left.png"/>
        </a>
    </div>
    <input  type="hidden" name="companyId" value="${companyId}" id="companyId">
    <div id="wrapper">
        <div class="administer remove-wrapper" id="scroller">
            <ul class="optional-product" id="product-list">

            </ul>
            <div id="pullUp">
                <span class="pullUpLabel">上拉加载更多...</span>
            </div>
            <p id="ert"></p>
        </div>
    </div>
</div>

<div class="remove-product">
    <div class="que">
        <button id="remove-products" type="button" onclick="tijiao()" disabled>确认删除</button>
    </div>
</div>

<script src="${ctxwxsta}/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${ctxwxsta}/js/iscroll.js"></script>
<script type="text/javascript" src="${ctxwxsta}/js/basicTwo.js"></script>
<script type="text/javascript" src="${ctxwxsta}/js/removeAssigned.js"></script>
<script>
    var baseUrl = '${pageContext.request.contextPath }';
    $(document).ready(function(){
         getData(0);
    });
    $('#remove-products').click(function () {
        $('.select .select-wed').each(function () {
            if($(this).hasClass('on')){
                $(this).parents('li').remove();
                tijiao();
            }
        });
    });
    function  fanhui() {
        var newType='${newType}';
        var companyId =$("#companyId").val();
        if(newType){
            window.location.href="/weixin/product/distributionList/"+companyId+"?newType=1";
        }else{
            window.location.href="/weixin/product/distributionList/"+companyId;
        }
    }
    function tijiao() {
        var newType='${newType}';
        var parentName="";
        $(".select-wed.on").each(function () {
            parentName=parentName+$(this).attr('name')+",";
        })
        if(parentName!=""){
            parentName= parentName.substring(0,parentName.length-1);
        }
        var companyId =$("#companyId").val();
        $.ajax({
            type: 'POST',
            url: "/weixin/product/saveProductDelRelation",
            data:{productIds:parentName,companyId:companyId,type:1},
            dataType:"json",
            async: false,
            success: function(data){
                if(data.success){
                    if(newType){
                        window.location.href="/weixin/product/distributionList/"+companyId+"?newType=1";
                    }else{
                        window.location.href="/weixin/product/distributionList/"+companyId;
                    }

                }else{
                    layer.open({content:"操作失败！",btn: '我知道了'});
                }
            }
        });
    }
</script>
</body>
</html>