老惯例,先前台页面

@using Model
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/_LayoutBase.cshtml";
    List<TType> types = ViewBag.TypeList;
    var l1 = types.Where(p => p.KParentId == 0 || p.KParentId == null).ToList();
    var l2 = types.Where(p => p.KParentId != 0 && p.KParentId != null).ToList();
    var newTypes = new List<TType>();
    foreach (var type in l1)
    {
        newTypes.Add(type);
        var types2 = l2.Where(p => p.KParentId == type.PTypeId).ToList();
        types2.ForEach(p => p.FName = "|--" + p.FName);
        newTypes.AddRange(types2);
    }
}
@section css{
    <link href="/Content/uploadify/uploadify.css" rel="stylesheet" />

    <link href="~/Content/product.css" rel="stylesheet" />
    <style>
        .datagrid-body .datagrid-editable {
            margin: 0px;
            padding: 0px;
        }

        .l-btn {
            margin-left: 0;
        }

        .datagrid-toolbar .l-btn .l-btn-icon-left .l-btn-text {
            margin: 1px 0px 1px 25px
        }

        .text-box {
            width: 36px;
            height: 32px;
            border: 1px solid #ccc;
            padding: 4px 10px;
        }

        .text-box-focus {
            border-color: #66afe9;
            box-shadow: 0 0 5px 0 #93cdf9;
        }

        .hour, .mintue {
            width: 100px;
            border: 1px solid #ccc;
        }

            .hour span, .mintue span {
                line-height: 1.5;
                margin: 0 4px;
                cursor: pointer;
            }

        .cancel {
            width: 30px;
            background-color: #fff;
            border: 1px solid #ccc;
            box-shadow: 0 0 5px 0 #f6f6f6;
            margin-right: 3px;
            cursor: pointer;
        }
        /*规格添加样式*/
        #specTitleTable, #specTD table {
            border: 1px solid #ccc;
            width: 730px;
        }

            #specTitleTable tr {
                height: 40px;
                padding: 0 5px;
            }

                #specTitleTable tr:nth-child(2n+1) {
                    background: #191717;
                }

                #specTitleTable tr td:first-child {
                    padding: 0 5px;
                    width: 60px;
                }

                #specTitleTable tr td .textbox {
                    margin: 2px;
                }

            #specTitleTable .abtn {
                padding: 0 2px;
            }

            #specTD table tr:first-child {
                background-color: #191717;
                height: 20px;
                text-align: center;
            }

            #specTD table tr td {
                padding: 4px 0;
            }

            #specTD table tr .spectext {
                height: 30px;
                border-radius: 2px;
            }
    </style>
}
<script src="~/umditor/umeditor.config.js"></script>
<script src="~/umditor/umeditor.min.js"></script>
<script src="~/umditor/lang/zh-cn/zh-cn.js"></script>
<link href="~/umditor/themes/default/css/umeditor.css" rel="stylesheet" />


<div class="easyui-panel" style="margin-bottom: 10px; padding: 5px;">
    <div class="width-100">
        <span>产品名称:</span>
        <input class="easyui-textbox" id="searchName">
        @*<span>门店名称:</span>
        <select class="easyui-combobox" name="storeId" style="width:100px;" id="storeId">
            <option value="0">全部</option>
            @foreach (var item in ViewBag.StoreList)
            {
                <option value="@item.PStoreId">@item.FName</option>
            }
        </select>*@
        <span>产品类型:</span>
        <select class="easyui-combobox" name="ProductType" style="width:150px;" id="ProductType">
            <option value="0">全部</option>
            <option value="1">普通</option>
            <option value="2">拼团</option>
            <option value="3">抢购</option>
            <option value="4">砍价</option>
        </select>
        <span>产品状态:</span>
        <select class="easyui-combobox" name="State" style="width:100px;" id="State">
            <option value="0">全部</option>
            <option value="1">上架</option>
            <option value="2">下架</option>
            @if (ViewBag.WxId == 3272)
            {
                <option value="3">待审核</option>
                <option value="4">审核不通过</option>
            }
        </select>
        @*<span>类型:</span>
        <select class="easyui-combobox" name="SelType" style="width:200px;" id="SelType">
            <option value="0">全部</option>
            @foreach (var item in newTypes)
            {
                <option value="@item.PTypeId">@item.FName</option>
            }

        </select>*@
        <span>管理员权限:</span>
        <input class="easyui-textbox" id="KStoreId1">
        <a href="#" class="easyui-linkbutton" id="search" data-options="iconCls:'icon-search',size:'middle'">查 询</a>
        <a href="#" class="easyui-linkbutton" id="reload" data-options="iconCls:'icon-reload',size:'middle'">清 空</a>
        <button type="button" class="easyui-linkbutton" id="btnImport" data-options="size:'middle'">导入商品数据</button>
        <button type="button" class="easyui-linkbutton" id="btnImportProImg" data-options="size:'middle'">导入商品图片</button>
    </div>
</div>

<table id="grid" class="easyui-datagrid"></table>

<!--详情-->
<div id="product" class="easyui-window" title="修改" data-options="iconCls:'icon-save',closed:true,fit:true,modal:true" style="width: 100%; height: 1070px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true" style="width: 100%;height: 1070px;overflow:auto;">
        <div style="padding: 2px;float:left;width: 100%;">
            <div style="float:left;width:730px">
                <form id="ff">
                    <table>
                        <tr>
                            <td>产品名称</td>
                            <td>
                                <input class="easyui-textbox" id="Name" style="width:150px;" name="Name" required="required" />

                                <input type="hidden" name="Store" value="@ViewBag.KStoreId" id="Store" />

                            </td>
                            <td>类型</td>
                            <td>
                                <select class="easyui-combobox" name="Type" style="width:150px;" id="Type" required="required">
                                    @foreach (var item in ViewBag.TypeList)
                                    {
                                        <option value="@item.PTypeId">@item.FName</option>
                                    }
                                </select>
                            </td>
                            @if (ViewBag.WxId == 3174)
                            {
                                <td>
                                    授课老师
                                </td>
                                <td>
                                    <select class="easyui-combobox" name="Tearcher" style="width:150px;" id="Tearcher">
                                        @foreach (var item in ViewBag.Teachers)
                                        {
                                            <option value="@item.PTeacherId">@item.FName</option>
                                        }
                                    </select>
                                </td>
                            }
                            else if (ViewBag.WxId == 3265)
                            {
                                <td>是否虚拟商品</td>
                                <td>
                                    <select class="easyui-combobox" name="IsPackage" style="width:150px" id="IsPackage">
                                        <option selected="selected" value="0"></option>
                                        <option value="1"></option>
                                    </select>
                                </td>
                            }
                            else
                            {
                                <td>是否套餐</td>
                                <td>
                                    <select class="easyui-combobox" name="IsPackage" style="width:150px" id="IsPackage">
                                        <option selected="selected" value="0">单件商品</option>
                                        <option value="1">套餐商品</option>
                                    </select>
                                </td>
                            }
                        </tr>
                        <tr>
                            <td>销量</td>
                            <td>
                                <input class="easyui-numberbox" type="text" id="OrderNum" style="width:150px;" name="OrderNum" />
                            </td>
                            <td>单位</td>
                            <td>
                                <input class="easyui-textbox" type="text" id="UnitName" style="width:150px;" name="UnitName" />
                            </td>
                            <td>排序</td>
                            <td>
                                <input class="easyui-numberbox" type="text" id="Sort" name="Sort" style="width:150px;" />
                            </td>
                        </tr>
                        <tr>
                            <td>产品类型</td>
                            <td>
                                <select class="easyui-combobox" name="ProductType" style="width:150px;" id="ProductType" required="required" editable="false">
                                    <option value="1">普通</option>
                                    <option value="3">抢购</option>

                                </select>
                            </td>
                            <td>开始时间</td>
                            <td>
                                <input class="easyui-datetimebox" type="text" id="BeginTime" name="BeginTime" style="width:150px;" />
                            </td>
                            <td>结束时间</td>
                            <td>
                                <input class="easyui-datetimebox" type="text" id="EndTime" name="EndTime" style="width:150px;" />
                            </td>
                        </tr>
                        <tr>
                            <td>简述</td>
                            <td>
                                <input class="easyui-textbox" type="text" id="Tag" name="Tag" style="width:150px;" />
                            </td>
                            <td>状态</td>
                            <td>
                                <select class="easyui-combobox" name="State" style="width:150px;" id="State">
                                    <option value="1">上架</option>
                                    <option value="2">下架</option>
                                </select>
                            </td>
                            @if (ViewBag.IsFreightTemplate)
                            {
                                <td>运费模板</td>
                                <td>
                                    <select class="easyui-combobox" name="FreightTemplateId" style="width:150px;" id="FreightTemplateId">
                                        @foreach (var item in ViewBag.Template)
                                        {
                                            <option value="@item.PTemplateNameId">@item.FName</option>
                                        }
                                    </select>
                                    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" style="width:75px;height:30px" id="setFreightTemplate">设置</a>
                                </td>
                            }

                        </tr>
                    <tr>
                        <td>重量</td>
                        <td>
                            <input class="easyui-numberbox" type="text" id="Weigth" style="width:120px;" name="Weigth" data-options="min:0,precision:2" />Kg
                        </td>
                        <td>可售时间</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="SaleTime" name="SaleTime" style="width:150px;" />
                        </td>
                        <td>最大购买量</td>
                        <td colspan="2">
                            <input class="easyui-textbox" type="text" id="MaxCount" name="MaxCount" style="width:120px;" />0=无限
                        </td>


                    </tr>
                    <tr>
                        <td>管理员权限</td>
                        <td>
                            <input class="easyui-numberbox" type="text" id="KStoreId" style="width:120px;" name="Weigth" data-options="min:0,precision:2" />
                        </td>
                    </tr>
                        @if (ViewBag.IsHidepProduct)
                        {
                            <tr>
                                <td>隐藏价格</td>
                                <td>
                                    <input type="checkbox" id="IsHide" name="IsHide" value="true" />
                                </td>
                            </tr>

                        }
                        <tr>
                            <td colspan="6">产品规格(最多可以添加三种规格名【如:颜色和尺码】,至少要添加一种规格名和规格值)</td>
                        </tr>
                        <tr>
                            <td colspan="6" id="specTitle">
                                <table id="specTitleTable" class="easyui-table" cellspacing="0">
                                    <tr>
                                        <td>规格名:</td>
                                        <td>
                                            <input type="text" class="easyui-textbox" name="SpecTitleName" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>规格值:</td>
                                        <td>
                                            <input type="text" class="easyui-textbox" name="SpecItemName" data-options="icons:[{iconCls:'icon-clear',handler: DelCellValue}]" />
                                            <a class="abtn" href="javascript:void(0)" onclick="AddCellValue(this,1)">添加规格值</a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <a class="easyui-linkbutton" id="AddSpecName" href="javascript:void(0)" onclick="AddTitleRow(this,2)">添加规格项目</a>
                                            <a class="easyui-linkbutton" href="javascript:void(0)" onclick="submitSpecName()">确定</a>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" id="specTD">
                                <p>规格明细(更改或者删除原有的规格会导致原数据删除并无法复原,请慎重更改和删除)</p>
                                <table>
                                    <tr>
                                        @if (ViewBag.WxId == 3168)
                                        {
                                            <td><input class="easyui-textbox" type="text" id="FSpecName" name="FSpecName" style="width:80px" value="招生对象" disabled /></td>
                                            <td><input class="easyui-textbox" type="text" id="FSpecName2" name="FSpecName2" style="width:80px" value="招生人数" disabled /></td>
                                            <td><input class="easyui-textbox" type="text" id="FSpecName3" name="FSpecName3" style="width:80px" value="上课时间" disabled /></td>
                                        }
                                        else
                                        {
                                            <td><input class="easyui-textbox" type="text" id="FSpecName" name="FSpecName" style="width:80px" readonly /></td>
                                            <td><input class="easyui-textbox" type="text" id="FSpecName2" name="FSpecName2" style="width:80px" readonly /></td>
                                            <td><input class="easyui-textbox" type="text" id="FSpecName3" name="FSpecName3" style="width:80px" readonly /></td>
                                        }
                                        <td>最新价格</td>
                                        <td>原价</td>
                                        @if (ViewBag.IsMember)
                                        {
                                            <td>会员价</td>
                                        }
                                        <td>库存</td>
                                        <td>货号</td>
                                    </tr>
                                </table>
                                @*<a href="javascript:AddRow()" class="aStyle">添加规格</a>*@
                                <div style="margin-top:5px;">
                                    <span>批量设置:</span>
                                    <a class="abtn easyui-linkbutton" href="javascript:void(0)" onclick="openModal(1)">最新价格</a>
                                    <a class="abtn easyui-linkbutton" href="javascript:void(0)" onclick="openModal(2)">库存</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">产品宣传图:</td>
                            <td colspan="2">
                                <input type="radio" name="certType" checked="checked" value="1" /><label>上传到主图</label>
                                <input type="radio" name="certType" value="2" /><label>上传到详情图</label>
                            </td>
                            <td colspan="2">
                                <div id="fileQueue"></div>
                                <input type="file" multiple="multiple" name="uploadify" id="uploadify" onchange="imgUpload(0)" /><br />
                                建议上传尺寸:800*800
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6">
                                <ul class="imgList" id="picList">
                                    @for (int j = 1; j <= 6; j++)
                                    {
                                        <li data-index="@(j)">
                                            <div class="operate">
                                                <i class="toleft">左移</i> <i class="toright">右移</i> <i class="del">删除</i>
                                            </div>
                                            <div>
                                                <img id="picUrl_@(j)" data-value="" src="" />
                                                <input id="image_@(j)" type="hidden" name="iamge" value="" />
                                            </div>
                                        </li>
                                    }
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6">产品详情图:</td>
                        </tr>

                        @for (int i = 1; i <= 17; i++)
                        {
                            <tr id="mtr_@i" hidden="hidden">
                                <td colspan="6">
                                    <ul class="imgList2" runat="server">
                                        @for (int j = 1; j <= 6; j++)
                                        {
                                            if (((i - 1) * 6 + j) <= 100)
                                            {
                                                <li data-index="@((i - 1) * 6 + j)">
                                                    <div class="operate">
                                                        <i class="toleft">左移</i> <i class="toright">右移</i> <i class="del">删除</i>
                                                    </div>
                                                    <div>
                                                        <img id="mpicUrl_@((i - 1) * 6 + j)" data-value="" src="" />
                                                        <input id="mimage_@((i - 1) * 6 + j)" type="hidden" name="miamge" value="" />
                                                    </div>
                                                </li>
                                            }
                                        }
                                    </ul>
                                </td>
                            </tr>
                        }
                        <tr>
                            <td colspan="6" style="text-align:center;">
                                <script id="editor" name="editor" type="text/plain" style="width:780px;height:400px;">
                                </script>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" style="text-align:center;">
                                <a class="easyui-linkbutton" id="btnOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                                <a class="easyui-linkbutton" id="btnCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                            </td>
                        </tr>
                    </table>
                    <input type="hidden" id="delPSpecIds" name="delPSpecIds" />
                    <input type="hidden" id="productId" name="productId" />
                    <input type="hidden" id="copyId" name="copyId" />
                </form>
            </div>

        </div>
        <div style="padding: 2px;" hidden="hidden">

        </div>
    </div>
</div>
<!--规格列表-->
<div id="productSpec" class="easyui-window" title="规格列表" data-options="iconCls:'icon-save',closed:true" style="width: 480px; height: 470px;">
    <div class="easyui-layout" data-options="fit:true" style="overflow-y:scroll;height: 400px;">
        <div>
            <table id="gridSpec" class="easyui-datagrid"></table>
        </div>
    </div>
</div>
<!--规格修改-->
<div id="productSpecWindow" class="easyui-window" title="修改" data-options="iconCls:'icon-save',closed:true" style="width: 520px; height: 250px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <div style="padding: 10px;">
            <form id="specForm">
                <table>
                    <tr>
                        <td>规格名称</td>
                        <td>
                            <input class="easyui-textbox" id="SpecName" name="SpecName" />
                        </td>
                        <td>库存</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="SpecStock" name="SpecStock" />
                        </td>

                    </tr>
                    <tr>
                        <td>原价</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="SpecOldPrice" name="SpecOldPrice" />
                        </td>
                        <td>最新价格</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="SpecPrice" name="SpecPrice" />
                        </td>
                    </tr>
                    <tr>
                        <td>条形码</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="barCode" name="barCode" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6" style="text-align:center;">
                            <a class="easyui-linkbutton" id="btnSpecOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                            <a class="easyui-linkbutton" id="btnSpecCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                        </td>
                    </tr>
                </table>
                <input type="hidden" id="specId" name="specId" />
                <input type="hidden" id="prodId" name="prodId" />
            </form>
        </div>
    </div>
</div>
<!--拼团管理-->
<div id="productGroupSpec" class="easyui-window" title="拼团管理" data-options="iconCls:'icon-save',closed:true" style="width: 500px; height: 350px;">
    <div class="easyui-layout" data-options="fit:true">
        <form id="GroupForm">
            <table style="width:100%;">
                <tr>
                    <td>拼团人数</td>
                    <td>
                        <input class="easyui-textbox" id="GroupCount" name="GroupCount" required="required" />
                    </td>

                </tr>
                <tr>
                    <td>开始时间</td>
                    <td>
                        <input class="easyui-datebox" type="text" id="BeginTime" name="BeginTime" />
                    </td>
                    <td>结束时间</td>
                    <td>
                        <input class="easyui-datebox" type="text" id="EndTime" name="EndTime" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <table id="gridGroupSpec" class="easyui-datagrid"></table>
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="text-align:center;padding:10px 0;">
                        <a class="easyui-linkbutton" id="btnGroupOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                        <a class="easyui-linkbutton" id="btnGroupCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                    </td>
                </tr>
            </table>
            <input type="hidden" id="groupProdId" name="groupProdId" />
        </form>
    </div>
</div>
<!--砍价管理-->
<div id="productBargainSpec" class="easyui-window" title="砍价管理" data-options="iconCls:'icon-save',closed:true" style="width: 450px; height: 420px;">
    <div class="easyui-layout" data-options="fit:true">
        <form id="BargainForm">
            <table style="width:100%;">
                <tr>
                    <td>砍价区间</td>
                    <td>
                        <input class="easyui-textbox" id="MinPrice" name="MinPrice" />
                    </td>
                    <td>-</td>
                    <td>
                        <input class="easyui-textbox" id="MaxPrice" name="MaxPrice" />
                    </td>
                </tr>
                <tr>
                    <td>开始时间</td>
                    <td>
                        <input class="easyui-datebox" type="text" id="BeginTime" name="BeginTime" />
                    </td>
                    <td>结束时间</td>
                    <td>
                        <input class="easyui-datebox" type="text" id="EndTime" name="EndTime" />
                    </td>
                </tr>
                <tr>
                    <td>当天砍价数</td>
                    <td>
                        <input class="easyui-textbox" type="text" id="BargainCount" name="BargainCount" />
                    </td>

                </tr>
                <tr>
                    <td colspan="4">
                        <table id="gridBargainSpec" class="easyui-datagrid"></table>
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="text-align:center;padding:10px 0;">
                        <a class="easyui-linkbutton" id="btnBargainOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                        <a class="easyui-linkbutton" id="btnBargainCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                    </td>
                </tr>
            </table>
            <input type="hidden" id="bargainProdId" name="bargainProdId" />
        </form>
    </div>
</div>
<!--设置分佣-->
<div id="productCommission" class="easyui-window" title="设置分佣" data-options="iconCls:'icon-save',closed:true,fit:true" style="overflow:auto">
    <div class="easyui-layout" data-options="fit:true" style="overflow:auto">
        @*<form id="CommissionForm">
                @if (ViewBag.WxId == 2122)
                {
                    <table id="gridGroupCommissionBSB" class="easyui-datagrid"></table>
                }
                else
                {
                    <table id="gridGroupCommission" class="easyui-datagrid"></table>
                }
                <table width="100%">
                    <tr>
                        <td></td>
                        <td width="200">
                            @if (ViewBag.WxId == 2122)
                            {
                                <a class="easyui-linkbutton" id="btnCommissionBSBOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                            }
                            else
                            {
                                <a class="easyui-linkbutton" id="btnCommissionOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                            }

                            <a class="easyui-linkbutton" id="btnCommissionCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                        </td>
                        <td></td>

                    </tr>
                </table>

                <input type="hidden" id="commissionProdId" name="commissionProdId" />
            </form>*@
        @if (ViewBag.WxId == 2122)
        {
            <form id="CommissionFormBSB">
                <table id="gridGroupCommissionBSB" class="easyui-datagrid"></table>
                <table width="100%">
                    <tr>
                        <td></td>
                        <td width="200">
                            <a class="easyui-linkbutton" id="btnCommissionBSBOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                            <a class="easyui-linkbutton" id="btnCommissionCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                        </td>
                        <td></td>

                    </tr>
                </table>

                <input type="hidden" id="commissionProdId" name="commissionProdId" />
            </form>
        }
        else
        {
            <form id="CommissionForm">
                <table id="gridGroupCommission" class="easyui-datagrid"></table>
                <table width="100%">
                    <tr>
                        <td></td>
                        <td width="200">
                            <a class="easyui-linkbutton" id="btnCommissionOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                            <a class="easyui-linkbutton" id="btnCommissionCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                        </td>
                        <td></td>
                    </tr>
                </table>

                <input type="hidden" id="commissionProdId" name="commissionProdId" />
            </form>
        }
    </div>
</div>
<!--设置所有产品分佣-->
<div id="AllCommission" class="easyui-window" title="设置所有产品分佣" data-options="iconCls:'icon-save',closed:true" style="width: 477px; height: 177px;">
    <div class="easyui-layout" data-options="fit:true">
        <form id="AllCommissionForm">
            <table>
                <tr>
                    <td>一级分佣:</td>
                    <td>
                        <input class="easyui-numberbox" id="OneCommission" name="OneCommission" data-options="min:0,precision:2" style="width:100px" />例如:设置0.01即把一级分佣设置为产品价格乘以0.01的值
                    </td>

                </tr>
                <tr>
                    <td>二级分佣:</td>
                    <td>
                        <input class="easyui-numberbox" id="TwoCommission" name="TwoCommission" data-options="min:0,precision:2" style="width:100px" />例如:设置0.01即把二级分佣设置为产品价格乘以0.01的值
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="text-align:center;">
                        <a class="easyui-linkbutton" id="btnAllCommissionOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                        <a class="easyui-linkbutton" id="btnAllCommissionCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<!--设置积分-->
<div id="productIntegral" class="easyui-window" title="设置积分" data-options="iconCls:'icon-save',closed:true,fit:true">
    <div class="easyui-layout" data-options="fit:true">
        <form id="IntegralForm">
            <table id="gridGroupIntegral" class="easyui-datagrid"></table>
            <table width="100%">
                <tr>
                    <td></td>
                    <td width="200">
                        <a class="easyui-linkbutton" id="btnIntegralOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                        <a class="easyui-linkbutton" id="btnIntegralCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                    </td>
                    <td></td>

                </tr>
            </table>

            <input type="hidden" id="IntegralProdId" name="IntegralProdId" />
        </form>
    </div>
</div>
<!--添加评价-->
<div id="userEvaluate" class="easyui-window" title="添加评价" data-options="iconCls:'icon-save',closed:true" style="width: 410px; height: 225px;">
    <div class="easyui-layout" data-options="fit:true">
        <form id="UserEvaluateForm">
            <table>
                <tr>
                    <td>规格</td>
                    <td>
                        <select class="easyui-combobox" style="width:150px;" required="required" id="prodSpec" name="prodSpec"></select>
                    </td>
                    <td>用户ID</td>
                    <td>
                        <input class="easyui-textbox" id="userNo" name="userNo" required="required" />
                    </td>
                </tr>
                <tr>
                    <td>等级</td>
                    <td>
                        <select id="level" name="level" class="easyui-combobox" style="width:150px;">
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5" selected="selected">5</option>
                        </select>
                    </td>
                    <td>时间</td>
                    <td>
                        <input class="easyui-datetimebox" type="text" id="time" name="time" required="required" />

                    </td>

                </tr>
                <tr>
                    <td>内容</td>
                    <td colspan="3">
                        <input class="easyui-textbox" style="width:370px;" id="userEvaluateContent" name="userEvaluateContent" required="required" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="text-align:center;">
                        <a class="easyui-linkbutton" id="btnUserEvaluateOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                        <a class="easyui-linkbutton" id="btnUserEvaluateCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                    </td>
                </tr>
            </table>
            <input type="hidden" id="userEvaluateProdId" name="userEvaluateProdId" />
        </form>
    </div>
</div>
<!--自定点-->
<div id="productSince" class="easyui-window" title="自定点列表" data-options="iconCls:'icon-save',closed:true" style="width: 480px; height: 470px;">
    <div class="easyui-layout" data-options="fit:true">
        <div>
            <table id="gridSince" class="easyui-datagrid"></table>
        </div>
    </div>
</div>
<!--复制产品-->
<div id="copyProduct" class="easyui-window" title="复制产品" data-options="iconCls:'icon-save',closed:true" style="width: 320px; height: 230px;">
    <div class="easyui-layout" data-options="fit:true" style="padding: 10px;">
        <p>
            复制产品:<input class="easyui-textbox" type="text" id="CopyProductName" name="CopyProductName" disabled="disabled" />
        </p>
        <p>
            门店信息:<select class="easyui-combobox" name="CopyStore" style="width:150px;" id="CopyStore">
                @foreach (var item in ViewBag.StoreList)
                {
                    <option value="@item.PStoreId">@item.FName</option>
                }
            </select>
        </p>
        <p>
            门店类型:<select class="easyui-combobox" name="CopyType" style="width:150px;" id="CopyType"></select>
        </p>
        <p style="text-align:center;">
            <a class="easyui-linkbutton" id="btnCopyOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
            <a class="easyui-linkbutton" id="btnCopyCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
        </p>
    </div>
</div>
<!--区域-->
<div id="productSinceWindow" class="easyui-window" title="修改" data-options="iconCls:'icon-save',closed:true" style="width: 520px; height: 170px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <div style="padding: 10px;">
            <form id="SinceForm">
                <table>
                    <tr>
                        <td>省份</td>
                        <td>
                            <select class="easyui-combobox" style="width: 173px;" id="areaName" data-options="required:true,editable:false">
                                <option value="北京市">北京市</option>
                                <option value="上海市">上海市</option>
                                <option value="天津市">天津市</option>
                                <option value="重庆">重庆市</option>
                                <option value="河北省">河北省</option>
                                <option value="山西省">山西省</option>
                                <option value="辽宁省">辽宁省</option>
                                <option value="吉林省">吉林省</option>
                                <option value="黑龙江省">黑龙江省</option>
                                <option value="江苏省">江苏省</option>
                                <option value="浙江省">浙江省</option>
                                <option value="安徽省">安徽省</option>
                                <option value="福建省">福建省</option>
                                <option value="江西省">江西省</option>
                                <option value="山东省">山东省</option>
                                <option value="河南省">河南省</option>
                                <option value="湖北省">湖北省</option>
                                <option value="湖南省">湖南省</option>
                                <option value="广东省">广东省</option>
                                <option value="海南省">海南省</option>
                                <option value="四川省">四川省</option>
                                <option value="贵州省">贵州省</option>
                                <option value="云南省">云南省</option>
                                <option value="陕西省 ">陕西省</option>
                                <option value="甘肃省">甘肃省</option>
                                <option value="青海省">青海省</option>
                                <option value="台湾省">台湾省</option>
                                <option value="香港特别行政区">香港特别行政区</option>
                                <option value="澳门特别行政区">澳门特别行政区</option>
                                <option value="西藏自治区">西藏自治区</option>
                                <option value="广西壮族自治区">广西壮族自治区</option>
                                <option value="内蒙古自治区">内蒙古自治区</option>
                                <option value="宁夏回族自治区">宁夏回族自治区</option>
                                <option value="新疆维吾尔自治区">新疆维吾尔自治区</option>
                            </select>
                            @*<input class="easyui-textbox" id="areaName" name="areaName" />*@
                        </td>
                        <td>库存</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="amount" name="amount" />
                        </td>
                    </tr>
                    <tr>
                        <td>地址</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="address" name="address" />
                        </td>
                        <td>电话</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="phone" name="phone" />
                        </td>
                    </tr>

                    <tr>
                        <td colspan="6" style="text-align:center;">
                            <a class="easyui-linkbutton" id="btnSinceOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                            <a class="easyui-linkbutton" id="btnSinceCancle" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                        </td>
                    </tr>
                </table>
                <input type="hidden" id="sinceId" name="sinceId" />
                <input type="hidden" id="oldAreaName" name="sinceId" />
                <input type="hidden" id="prodSinceId" name="prodSinceId" />
            </form>
        </div>
    </div>
</div>
<!--导入商品信息-->
<div id="importProductWindow" class="easyui-window" title="导入商品信息" data-options="iconCls:'icon-save',closed:true" style="width: 520px; height: 200px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <div style="padding: 10px;">
            <form id="importProudctForm" enctype="multipart/form-data">
                <table>
                    <tr>
                        <td>选择门店:</td>
                        <td>
                            <select class="easyui-combobox" id="impStore" style="width:250px">
                                @foreach (var item in ViewBag.StoreList)
                                {
                                    <option value="@item.PStoreId">@item.FName</option>
                                }
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>选择 Excel(.xls 或 .xlsx) 文件:</td>
                        <td> <input type="file" id="importProductFile" name="importProductFile" /> </td>
                    </tr>
                    <tr>
                        <td>商品信息导入 Excel 模板</td>
                        <td colspan="3">
                            <a href="/Content/商品导入模板.xls">下载</a>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align:center;">
                            <a class="easyui-linkbutton" id="btnImportProductOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                            <a class="easyui-linkbutton" id="btnImportProductCancel" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<!--导入商品图片-->
<div id="importProImgWindow" class="easyui-window" title="导入商品图片" data-options="iconCls:'icon-save',closed:true" style="width: 520px; height: 200px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <div style="padding: 10px;">
            <form id="importProImgForm" enctype="multipart/form-data">
                <table>
                    <tr style="margin-bottom:10px">
                        <td>选择门店:</td>
                        <td>
                            <select class="easyui-combobox" id="impStore2" name="impStore2" style="width:250px">
                                @foreach (var item in ViewBag.StoreList)
                                {
                                    <option value="@item.PStoreId">@item.FName</option>
                                }
                            </select>
                        </td>
                    </tr>
                    <tr style="margin-bottom:10px">
                        <td>选择 Zip 文件:</td>
                        <td><input type="file" id="importProImgFile" name="importProImgFile" /></td>
                    </tr>
                    <tr style="margin-bottom:10px">
                        <td>商品图片导入规则</td>
                        <td colspan="3">
                            <a href="/Content/商品图片上传规则.zip">下载</a>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align:center;">
                            <a class="easyui-linkbutton" id="btnImportProImgOk" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                            <a class="easyui-linkbutton" id="btnImportProImgCancel" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<!--批量修改类型-->
<div id="changesTypeWindow" class="easyui-window" title="批量修改类型" data-options="iconCls:'icon-save',closed:true" style="width:520px;height:300px;padding:5px;">
    <div class="easyui-layout">
        <div>待设置类型的产品:</div>
        <div style="width:100%;height:152px;overflow-y:scroll;margin:5px 0;">
            <table id="PName" class="datagrid-btable" border="1" style="border-color:#f6f6f6;width:100%;height:100%;"></table>
        </div>
        <span>类型:</span>
        <select class="easyui-combobox" name="PType" id="PType" style="width:80%;">
            <option value="0">全部</option>
            @foreach (var item in newTypes)
            {
                <option value="@item.PTypeId">@item.FName</option>
            }
        </select>
        <input type="hidden" id="ids" />
        <div style="text-align:center;margin:5px 0;">
            <a class="easyui-linkbutton" id="btnSubmit" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
            <a class="easyui-linkbutton" id="btnCancel" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
        </div>
    </div>
</div>
<!--批量设置时间-->
<div id="ChangesSaleTimeWindow" class="easyui-window" title="批量设置时间" data-options="iconCls:'icon-save',closed:true" style="width:520px;height:480px;padding:5px;">
    <div class="easyui-layout">
        <div>待设置可售时间的产品:</div>
        <div style="width:100%;height:152px;overflow-y:scroll;margin:5px 0;">
            <table id="TName" class="datagrid-btable" border="1" style="border-color:#f6f6f6;width:100%;height:100%;"></table>
        </div>
        <div class="tab">
            <input type="radio" name="radiotimes" class="times radio" value="0" checked />时间不限
            <input type="radio" name="radiotimes" class="times" value="1" />可售时间点
            <input type="radio" name="radiotimes" class="times" value="2" />抢购时间范围
        </div>
        <div class="definedTime" style="margin:5px 0;display:none;">
            <table>
                <tr><td style="width:95px;"><span>开始时间点</span></td><td><span>结束时间点</span></tr>
                <tr>
                    <td style="width:95px;">
                        <input class="text-box" type="text" value="00" id="startHour" readonly />
                        :
                        <input class="text-box" type="text" value="00" id="startMinute" readonly />
                    </td>
                    <td>
                        <input class="text-box" type="text" value="23" id="endHour" readonly />
                        :
                        <input class="text-box" type="text" value="59" id="endMinute" readonly />
                    </td>
                </tr>
            </table>
            <div class="hour" style="display:none;">
                <span>00</span><span>01</span><span>02</span><span>03</span>
                <br />
                <span>04</span><span>05</span><span>06</span><span>07</span>
                <br />
                <span>08</span><span>09</span><span>10</span><span>11</span>
                <br />
                <span>12</span><span>13</span><span>14</span><span>15</span>
                <br />
                <span>16</span><span>17</span><span>18</span><span>19</span>
                <br />
                <span>20</span><span>21</span><span>22</span><span>23</span>
                <div style="text-align:right;margin:4px 0;">
                    <button class="cancel">取 消</button>
                </div>
            </div>
            <div class="mintue" style="display:none;">
                <span>00</span><span>05</span><span>10</span><span>15</span>
                <br />
                <span>20</span><span>25</span><span>30</span><span>35</span>
                <br />
                <span>40</span><span>45</span><span>50</span><span>55</span>
                <div style="text-align:right;margin:4px 0;">
                    <button class="cancel">取 消</button>
                </div>
            </div>
        </div>
        <div class="definedDateTime" style="margin:5px 0;display:none;">
            <table>
                <tr><td><span>开始时间</span></td><td><span>结束时间</span></tr>
                <tr>
                    <td>
                        <input class="easyui-datetimebox" value="@ViewBag.StartTime" id="datetime">
                    </td>
                    <td>
                        <input class="easyui-datetimebox" value="@ViewBag.EndTime" id="endtime">
                    </td>
                </tr>
            </table>
        </div>
        <input type="hidden" id="Pids" />
        <div style="text-align:center;margin:5px 0;">
            <a class="easyui-linkbutton" id="btnTimeSubmit" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
            <a class="easyui-linkbutton" id="btnTimeCancel" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
        </div>
    </div>
</div>
<!--上传视频-->
<div id="uploadVideo" class="easyui-window" title="上传视频" data-options="iconCls:'icon-save',closed:true" style="width:520px;height:450px;padding:5px;">
    <div class="easyui-layout">
        <table>
            <tr id="aa1">
                <td>
                    上传视频
                </td>
                <td>
                    <div style="margin-top:20px;text-align:left;">
                        <span>请上传:</span>
                        <span style='color:blue;'>(只支持,'mp4')</span>
                    </div>
                    <div style="margin-top:10px;">
                        <form action="" name="" enctype="multipart/form-data">
                            <input type="file" name="file_upload" id="file_upload" onchange="uploadVideo(this,'probar','player',0)" />
                        </form>
                    </div>
                    <div id="progress" style="width:200px;margin-bottom:10px;">
                        进度条:<span class="bar" id="probar"></span>
                    </div>
                    <!-- 预览框: -->
                    <div class="preview">
                        <video controls="controls" width="400" height="200" id="player" style="display:none;">
                            <source id="source" src="" type="video/mp4" />
                        </video>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="hidden" id="Proids" />
                    <div style="text-align:center;margin:5px 0;">
                        <a class="easyui-linkbutton" id="btnVideoSubmit" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
                        <a class="easyui-linkbutton" id="btnViddeoCancel" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<!--视频列表-->
<div id="VideoList" class="easyui-window" title="视频列表" data-options="iconCls:'icon-save',closed:true,fit:true" style="width:520px;height:450px;padding:5px;">
    <div class="easyui-layout">
        <div class="easyui-panel" style="margin-bottom: 10px; padding: 5px;">
            <span>课程:</span>
            <span id="ProName"></span>
        </div>
        <table id="videoGrid" class="easyui-datagrid"></table>
        <input type="hidden" id="courserId" />
    </div>
</div>
<!--产品列表-->
<div id="productList" class="easyui-window" title="产品列表" data-options="iconCls:'icon-save',closed:true,fit:true" style="width: 1200px; height: 800px;">
    <div class="easyui-layout" data-options="fit:true">
        <div style="padding: 10px;">
            <table id="productGrid" class="easyui-datagrid"></table>
        </div>
        <div data-options="region:'south',border:false" style="text-align: center; padding: 5px 0 0;">
            <a class="easyui-linkbutton" id="btnYes" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width: 80px">确 定</a>
            <a class="easyui-linkbutton" id="btnNO" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width: 80px">取 消</a>
        </div>
    </div>
</div>
<!--课程-->
<div id="productVideoWindow" class="easyui-window" title="新增" data-options="iconCls:'icon-save',closed:true" style="width: 420px; height: 470px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <div style="padding: 10px;">
            <form id="VideoForm">
                <div class="width-100">
                    <div class="width-20">课程名称</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FName" name="FName" style="width:100%;" />
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">时间</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FTimeCount" name="FTimeCount" />
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">上级名称</div>
                    <div class="width-80">
                        <select class="easyui-combobox" style="width: 173px;margin-bottom:5px" id="parentVideo" name="parentVideo" data-options="required:true,editable:false"></select>
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">排序</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FOrder1" name="FOrder" />
                        <span style="color:red;">*按章节顺序排列</span>
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">课程地址</div>
                    <div class="width-80">
                        <div class="btuttonDiv">
                            <input type="radio" name="btnradio" value="0" />课程视频上传
                            <input type="radio" name="btnradio" value="1" />自定义课程视频链接
                        </div>
                        <div class="upload_video">
                            <div style="text-align:left;">
                                <span>请上传:</span>
                                <span style='color:blue;'>(只支持,'mp4')</span>
                            </div>
                            <div style="margin-top:10px;">
                                <input type="file" name="curriCulum" id="curriCulum" onchange="uploadVideo(this, 'probar1', 'player1', 1)" />
                            </div>
                            <div id="progress" style="width:200px;margin-bottom:10px;">
                                <span class="bar" id="probar1"></span>
                            </div>
                            <video style="display:none" controls="controls" width="200" height="200" id="player1" oncanplaythrough="myFunction(this)">
                                <source src="" type="video/mp4">
                            </video>
                        </div>
                        <div class="defined_links">
                            <input type="hidden" id="hiddensrc" name="hiddensrc" />
                        </div>
                    </div>
                </div>
                <div data-options="region:'south',border:false" style="text-align: center; padding: 5px 0 0;">
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:Submitvideo(1)" style="width: 80px">确 定</a>
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:cancelVideo(1)" style="width: 80px">取 消</a>
                </div>
                <input type="hidden" id="videoId" name="videoId" />
                <input type="hidden" id="Proid" name="Proid" />
                <input type="hidden" id="typeId" name="typeId" />
            </form>
        </div>
    </div>
</div>
<!--课程讲义-->
<div id="productFileWindow" class="easyui-window" title="新增" data-options="iconCls:'icon-save',closed:true" style="width: 420px; height: 470px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <div style="padding: 10px;">
            <form id="FileForm">
                <div class="width-100">
                    <div class="width-20">讲义名称</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FName" name="FName" style="width:100%;" />
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">上级名称</div>
                    <div class="width-80">
                        <select class="easyui-combobox" style="width: 173px;margin-bottom:5px" id="parentVideo" name="parentVideo" data-options="required:true,editable:false"></select>
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">排序</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FOrder2" name="FOrder" data-options="min:0,precision:0" />
                        <span style="color:red;">*按章节顺序排列</span>
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">讲义地址</div>
                    <div class="width-80">
                        <div style="text-align:left;">
                            <span>请上传:</span>
                            <span style='color:blue;'>(只支持,'pdf')</span>
                        </div>
                        <div style="margin-top:10px;">
                            <input type="file" name="uploadFile" id="uploadFile" onchange="uploadFiles(this)" />
                        </div>
                    </div>
                </div>
                <div data-options="region:'south',border:false" style="text-align: center; padding: 5px 0 0;">
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:Submitvideo(2)" style="width: 80px">确 定</a>
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:cancelVideo(2)" style="width: 80px">取 消</a>
                </div>
                <input type="hidden" id="videoId" name="videoId" />
                <input type="hidden" id="Proid" name="Proid" />
                <input type="hidden" id="hiddensrc" name="hiddensrc" />
                <input type="hidden" id="typeId" name="typeId" />
            </form>
        </div>
    </div>
</div>
<!--课程题库-->
<div id="productLinksWindow" class="easyui-window" title="新增" data-options="iconCls:'icon-save',closed:true" style="width: 420px; height: 470px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <div style="padding: 10px;">
            <form id="LinksForm">
                <div class="width-100">
                    <div class="width-20">题库名称</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FName" name="FName" style="width:100%;" />
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">上级名称</div>
                    <div class="width-80">
                        <select class="easyui-combobox" style="width: 173px;margin-bottom:5px" id="parentVideo" name="parentVideo" data-options="required:true,editable:false"></select>
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">排序</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FOrder3" name="FOrder" />
                        <span style="color:red;">*按章节顺序排列</span>
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">题库链接</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="hiddensrc" name="hiddensrc" style="width:100%;" />
                        <span style="color:red;">* pages/answerInfo/index?id=6cee6880bd&questionMenu=幼儿《综合素质》-章节练习-教育观</span>
                    </div>
                </div>
                <div data-options="region:'south',border:false" style="text-align: center; padding: 5px 0 0;">
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:Submitvideo(3)" style="width: 80px">确 定</a>
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:cancelVideo(3)" style="width: 80px">取 消</a>
                </div>
                <input type="hidden" id="videoId" name="videoId" />
                <input type="hidden" id="Proid" name="Proid" />
                <input type="hidden" id="typeId" name="typeId" />
            </form>
        </div>
    </div>
</div>
<!--课程章节-->
<div id="productOnLinksWindow" class="easyui-window" title="新增" data-options="iconCls:'icon-save',closed:true" style="width: 420px; height: 300px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <div style="padding: 10px;">
            <form id="OnLinksForm">
                <div class="width-100">
                    <div class="width-20">章节名称:</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FName" name="FName" style="width:100%;" required />
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">直播链接:</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FLinks" name="FLinks" style="width:100%;" required />
                    </div>
                </div>
                <div class="width-100">
                    <div class="width-20">开始时间:</div>
                    <div class="width-80">
                        <input class="easyui-textbox" id="FTime" name="FTime" style="width:100%;" required />
                        <span style="color:red;">*例如:2019-04-25 10:30(采用24小时)</span>
                    </div>
                </div>
                <div data-options="region:'south',border:false" style="text-align: center; padding: 5px 0 0;">
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:SubmitLinks()" style="width: 80px">确 定</a>
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:cancelVideo(4)" style="width: 80px">取 消</a>
                </div>
                <input type="hidden" id="Proid" name="Proid" />
            </form>
        </div>
    </div>
</div>
<!--批量设置-->
<div class="easyui-window" id="OpenModal" title="设置" data-options="iconCls:'icon-save',closed:true" style="width: 200px; height: 150px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <div class="width-100">
            <span>价格:</span>
            <input type="number" class="easyui-textbox" id="price" style="width:100px;" />
        </div>
        <div class="width-100">
            <span>库存:</span>
            <input type="number" class="easyui-textbox" id="stock" style="width:100px;" />
        </div>
        <div class="width-100">
            <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="submitPrice()">确 定</a>
        </div>
        <input type="hidden" id="setType" value="1" />
    </div>
</div>
<!--满减设置-->
<div class="easyui-window" id="OpenConfig" title="满减设置" data-options="iconCls:'icon-save',closed:true" style="width: 450px; height: 250px; padding: 5px;">
    <div class="easyui-layout" data-options="fit:true">
        <form id="promotion">
            <div class="width-100">
                <span>满减数量:</span>
                <input type="number" class="easyui-textbox" id="num" name="num" style="width:150px;" required />
            </div>
            <div class="width-100">
                <span>优惠价格:</span>
                <input type="number" class="easyui-textbox" id="price" name="price" style="width:150px;" required />
            </div>
            <div class="width-100">
                <span>有效时间:</span>
                <input type="text" class="easyui-datetimebox" name="beginTime" style="width:150px;" />
                <span></span>
                <input type="text" class="easyui-datetimebox" name="endTime" style="width:150px;" />
            </div>
            <div class="width-100" style="text-align: center; padding: 5px 0 0;">
                <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:Submit()">确 定</a>
                <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:Cancel()">取 消</a>
            </div>
            <input type="hidden" name="typeId" value="1" />
            <input type="hidden" name="productId" value="0" />
            <input type="hidden" name="storeId" value="0" />
            <input type="hidden" name="PId" value="0" />
        </form>
    </div>
</div>
<input type="hidden" id="imagePath" value="@ViewBag.iamgePath" />
@*<input type="hidden" id="hiddenStoreId" value="@ViewBag.StoreId" />*@
<input type="hidden" id="WxId" value="@ViewBag.WxId" />

<input type="hidden" id="isGroup" value="@ViewBag.IsGroup" />

<input type="hidden" id="isBargain" value="@ViewBag.IsBargain" />
<input type="hidden" id="isCommission" value="@ViewBag.IsCommission" />
<input type="hidden" id="isShow" value="@ViewBag.IsShow" />
<input type="hidden" id="isIntegral" value="@ViewBag.IsIntegral" />
<input type="hidden" id="isSince" value="@ViewBag.IsSince" />
<input type="hidden" id="isMember" value="@ViewBag.IsMember" />
<input type="hidden" id="isImportProduct" value="@ViewBag.IsImportProduct" />
<input type="hidden" id="storeid" value="@ViewBag.KStoreId" />

<input type="hidden" id="buttons" value="@ViewBag.buttons" />
@*<input type="hidden" id="count" value="42" />*@
<input type="hidden" id="count" value="100" />
@section javascript{
    <script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>
    @*<script src="//cdn.bootcss.com/axios/0.18.0/axios.js"></script>*@
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="//unpkg.com/vod-js-sdk-v6"></script>@*视频上传云点播SDK*@
    <script src="/Content/uploadify/jquery.uploadify.min.js?v=1"></script>
    <script src="~/Content/javascript/LZYVideo.js"></script>
    @*<script src="~/Content/javascript/product.js?v=7"></script>*@
    <script src="~/Content/javascript/CHWLProduct.js"></script>

    <script>
        $("#storeId").combobox({
            onChange: function () {
                $("#SelType").combobox({
                    url: '/Type/GetProductTypeByStoreId?storeId=' + $("#storeId").combobox('getValue'),
                    valueField: 'PTypeId',
                    textField: 'FName',
                    loadFilter: function (data) {
                        var l1 = [];
                        var l2 = [];
                        var newData = [];
                        data.forEach(function (i) {
                            if (i.KParentId == 0) {
                                l1.push(i);
                            } else {
                                l2.push(i);
                            }
                        });
                        l1.forEach(function (i) {
                            newData.push(i);
                            l2.forEach(function (m) {
                                if (i.PTypeId == m.KParentId) {
                                    m.FName = "|--" + m.FName;
                                    newData.push(m);
                                }
                            });
                        });
                        newData.unshift({ PTypeId: 0, FName: "全部" });
                        return newData;
                    },
                    onLoadSuccess: function () {
                        $("#SelType").combobox("setValue", 0);
                    }
                });
            },

        })
        $("#setFreightTemplate").click(function () {
            window.parent.addTab('运费模板管理', '/FreightTemplate/Index?rel=1046', 'icon icon-nav', 999);
        });

        //单选切换
        $("#ChangesSaleTimeWindow input[type='radio']").click(function () {
            $(this).attr("checked", true);
            $(this).addClass("radio");
            $(this).siblings().removeClass("radio");
            $(this).siblings().removeAttr("checked");
            if ($(this).val() == 2) {
                $(".definedDateTime").show();
                $(".definedTime").hide();
            } else if ($(this).val() == 1) {
                $(".definedDateTime").hide();
                $(".definedTime").show();
                $(".hour").hide();
                $(".mintue").hide();
                $("input[type='text']").removeClass("text-box-focus");
            } else {
                $(".definedDateTime").hide();
                $(".definedTime").hide();
            }
        });
        $("#startHour").click(function () {
            $(".hour").css({ "margin-left": 0 });
            $(".hour").show();
            $(".mintue").hide();
            $("input[type='text']").removeClass("text-box-focus");
            $(this).addClass("text-box-focus");
        })
        $("#startMinute").click(function () {
            $(".mintue").css({ "margin-left": 0 });
            $(".mintue").show();
            $(".hour").hide();
            $("input[type='text']").removeClass("text-box-focus");
            $(this).addClass("text-box-focus");
        })
        $("#endHour").click(function () {
            $(".hour").css({ "margin-left": "95px" });
            $(".hour").show();
            $(".mintue").hide();
            $("input[type='text']").removeClass("text-box-focus");
            $(this).addClass("text-box-focus");
        })
        $("#endMinute").click(function () {
            $(".mintue").css({ "margin-left": "95px" });
            $(".mintue").show();
            $(".hour").hide();
            $("input[type='text']").removeClass("text-box-focus");
            $(this).addClass("text-box-focus");
        })
        $(".cancel").click(function () {
            $(".hour").hide();
            $(".mintue").hide();
            $("input[type='text']").removeClass("text-box-focus");
        })
        $(".hour span").click(function () {
            if ($(".text-box-focus").length > 0) {
                $(".text-box-focus").val($(this).text());
            }
            $(".hour").hide();
            $("input[type='text']").removeClass("text-box-focus");
        })
        $(".mintue span").click(function () {
            if ($(".text-box-focus").length > 0) {
                $(".text-box-focus").val($(this).text());
            }
            $(".mintue").hide();
            $("input[type='text']").removeClass("text-box-focus");
        })
        //规格值添加
        function AddCellValue(id, index) {
            if (index == 1)
                $(id).before(`<input type="text" class="easyui-textbox" name="SpecItemName" data-options="icons:[{iconCls:'icon-clear',handler: DelCellValue}]" />`);
            else
                $(id).before(`<input type="text" class="easyui-textbox" name="SpecItemName" data-options="icons:[{iconCls:'icon-clear',handler: DelCellValue}]" />`);
            $.parser.parse($(id).parent());
        }
        //规格值删除
        function DelCellValue(e) {
            if ($(e.data.target).parent().find("input[name='SpecItemName']").length == 1) {
                msgShow("系统提示", "请保留一项填写", "warning");
                return;
            }
            $(e.data.target).next().remove();
            $(e.data.target).remove();
        }
        //规格项目添加
        function AddTitleRow(id) {
            if ($("input[name='SpecTitleName']").length >= 3) {
                msgShow("系统提示", "规格数目已达上限!", "warning");
                return;
            }
            var str = `<tr>
                                <td>规格名:</td>
                                <td>
                                    <input type="text" class ="easyui-textbox" name="SpecTitleName" />
                                    <a class ="easyui-linkbutton" href="javascript:void(0)" onclick="DelTitleRow(this)">删除规格项目</a>
                                </td>
                            </tr>
                            <tr>
                                <td>规格值:</td>
                                <td>
                                    <input type="text" class ="easyui-textbox" name="SpecItemName" data-options="icons:[{iconCls:'icon-clear',handler: DelCellValue}]"/>
                                    <a class ="abtn" href="javascript:void(0)" onclick="AddCellValue(this)">添加规格值</a>
                                </td>
                            </tr>`;
            $(id).closest('tr').before(str);
            $.parser.parse($(id).closest('tr').siblings());
            $(id).attr('onclick', "AddTitleRow(this)");
        }
        //规格项目删除
        function DelTitleRow(id) {
            $(id).closest('tr').next().remove();
            $(id).closest('tr').remove();
        }
        //确定
        function submitSpecName() {
            var specTitleName = $("#specTitleTable input[name='SpecTitleName']");
            //判断规格名有无填写
            var isFalg = false;
            $.each(specTitleName, function (index, item) {
                if (isEmpty($(item).val())) {
                    isFalg = true;
                }
            });
            if (isFalg) {
                msgShow("系统提示", "值不能为空,请确保每一项都有填写", "warning");
                return;
            }
            $("#FSpecName").textbox('setValue', $(specTitleName).eq(0).val());
            $("#FSpecName2").textbox('setValue', $(specTitleName).eq(1).val());
            $("#FSpecName3").textbox('setValue', $(specTitleName).eq(2).val());
            // 添加子规格
            var specItemName1 = $(specTitleName).eq(0).closest('tr').next().find("input[name='SpecItemName']");
            var specItemName2 = $(specTitleName).eq(1).closest('tr').next().find("input[name='SpecItemName']");
            var specItemName3 = $(specTitleName).eq(2).closest('tr').next().find("input[name='SpecItemName']");
            var oldvalue1 = $("#specTD table input[name='SpecName']");
            //循环规格值
            var new_arr1 = [];
            $.each(specItemName1, function (Itemindex, itemInfo) {
                if ($(itemInfo).val() != "") {
                    new_arr1.push($(itemInfo).val());
                } else {
                    isFalg = true;
                }
            });
            if (isFalg) {
                msgShow("系统提示", "值不能为空,请确保每一项都有填写", "warning");
                return;
            }
            var new_arr2 = [];
            $.each(specItemName2, function (Itemindex, itemInfo) {
                if ($(itemInfo).val() != "") {
                    new_arr2.push($(itemInfo).val());
                } else {
                    isFalg = true;
                }
            });
            if (isFalg) {
                msgShow("系统提示", "值不能为空,请确保每一项都有填写", "warning");
                return;
            }
            var new_arr3 = [];
            $.each(specItemName3, function (Itemindex, itemInfo) {
                if ($(itemInfo).val() != "") {
                    new_arr3.push($(itemInfo).val());
                } else {
                    isFalg = true;
                }
            });
            if (isFalg) {
                msgShow("系统提示", "值不能为空,请确保每一项都有填写", "warning");
                return;
            }
            //第一个规格
            var old_arr1 = [];//旧值数组
            $.each(oldvalue1, function (oIndex, oitem) {
                old_arr1.push($(oitem).val());
            });
            //判断第一个规格要新增的数据
            if (old_arr1.length > 0) {
                //查找第一个规格新增的数据
                var new_arrys = new_arr1.filter(function (n) {
                    return old_arr1.indexOf(n) == -1
                });
                $.each(new_arrys, function (nindex, nitem) {
                    if (new_arr2.length > 0) {
                        $.each(new_arr2, function (yIndex, yitem) {
                            if (new_arr3.length > 0) {
                                $.each(new_arr3, function (oIndex, oitem) {
                                    setAllValue(nitem, yitem, oitem, 0);
                                });
                            } else {
                                setAllValue(nitem, yitem, '', 0);
                            }
                        });
                    } else {
                        setAllValue(nitem, '', '', 0);
                    }
                })
                //查找第一个规格要删除的数据
                var old_arrys = old_arr1.filter(function (n) {
                    return new_arr1.indexOf(n) == -1
                });
                $.each(old_arrys, function (nindex, nitem) {
                    $.each(oldvalue1, function (oIndex, oitem) {
                        if (nitem == $(oitem).val()) {
                            var oId = $(oitem).closest('tr').find("input[name='ProductSpecId']").val();
                            if (parseInt(oId) > 0) {
                                var ids = $("#delPSpecIds").val();
                                if (ids.indexOf(',' + oId) < 0) {
                                    ids += ',' + oId;
                                    $("#delPSpecIds").val(ids);
                                }
                            }
                            $(oitem).closest('tr').remove();
                        }
                    });
                })
                var oldvalue2s = $("#specTD table input[name='SpecName2']");
                //查找第一个规格相同数据
                var new_arrys1 = new_arr1.filter(function (n) {
                    return old_arr1.indexOf(n) != -1
                });
                var old_arry2 = [];
                var old_arry3 = [];
                //判断第二个规格的数据
                if (new_arr2.length > 0) {
                    $.each(new_arrys1, function (nindex, nitem) {
                        $.each(new_arr2, function (yIndex, yitem) {
                            var isAdd = true;
                            var prevItem = null;
                            //判断第三个规格的数据
                            if (new_arr3.length > 0) {
                                $.each(new_arr3, function (tindex, titem) {
                                    var isTAdd = true;
                                    //第一个循环
                                    $.each(oldvalue1, function (oIndex, oitem) {
                                        if (nitem == $(oitem).val()) {
                                            //第二个规格旧值
                                            var oldvalue2 = $(oitem).closest('tr').find("input[name='SpecName2']").val();
                                            if (oldvalue2 == "") { $(oitem).closest('tr').find("input[name='SpecName2']").val(yitem); isAdd = false; }//新旧一样则返回false
                                            else if (yitem == oldvalue2) {
                                                //第三个规格旧值
                                                var oldvalue3 = $(oitem).closest('tr').find("input[name='SpecName3']").val();
                                                if (oldvalue3 == "") { $(oitem).closest('tr').find("input[name='SpecName3']").val(titem); isTAdd = false; }
                                                else if (titem == oldvalue3) { isTAdd = false; }
                                                else { old_arry3.push(oldvalue3); }
                                                isAdd = false;
                                            }
                                            else { old_arry2.push(oldvalue2); }
                                            prevItem = oitem;
                                        }
                                    });
                                    //第三个规格是否新增
                                    if (isTAdd) {
                                        $(prevItem).closest('tr').after(setNextValue(nitem, yitem, titem, 0));
                                    }
                                });
                            }
                            else {
                                $.each(oldvalue1, function (oIndex, oitem) {
                                    if (nitem == $(oitem).val()) {
                                        //第二个规格旧值
                                        var oldvalue2 = $(oitem).closest('tr').find("input[name='SpecName2']").val();
                                        if (oldvalue2 == "") {
                                            $(oitem).closest('tr').find("input[name='SpecName2']").val(yitem);
                                            isAdd = false;
                                        }
                                        else if (yitem == oldvalue2) {
                                            $(oitem).closest('tr').find("input[name='SpecName3']").val("");
                                            if (oIndex != oldvalue1.length - 1) {
                                                var oldvalue22 = $(oitem).closest('tr').next().find("input[name='SpecName2']").val();
                                                var oldvalue11 = $(oitem).closest('tr').next().find("input[name='SpecName']").val();
                                                if ($(oitem).val() == oldvalue11 && oldvalue2 == oldvalue22) {
                                                    {
                                                        var nextId = $(oitem).closest('tr').next().find("input[name='ProductSpecId']").val();
                                                        if (parseInt(nextId) > 0) {
                                                            var ids = $("#delPSpecIds").val() + ',' + nextId;
                                                            if (ids.indexOf(',' + nextId) < 0) {
                                                                ids += ',' + nextId;
                                                                $("#delPSpecIds").val(ids);
                                                            }
                                                        }
                                                        $(oitem).closest('tr').next().remove();
                                                    }
                                                }
                                            }
                                            isAdd = false;
                                        }//新旧一样则返回false
                                        else { old_arry2.push(oldvalue2); }
                                        prevItem = oitem;
                                    }
                                });
                                //第二个规格是否新增
                                if (isAdd) {
                                    $(prevItem).closest('tr').after(setNextValue(nitem, yitem, '', 0));
                                }
                            }
                        });

                    });
                }
                else {
                    $.each(oldvalue1, function (oIndex, oitem) {
                        $(oitem).closest('tr').find("input[name='SpecName2']").val("");
                        $(oitem).closest('tr').find("input[name='SpecName3']").val("");
                        if (oIndex != oldvalue1.length - 1) {
                            var nIndex = oIndex + 1;
                            var oldvalue11 = $(oldvalue1).eq(nIndex).val();
                            if ($(oitem).val() == oldvalue11) {
                                var nextId = $(oldvalue1).eq(nIndex).closest('tr').find("input[name='ProductSpecId']").val();
                                if (parseInt(nextId) > 0) {
                                    var ids = $("#delPSpecIds").val() + ',' + nextId;
                                    if (ids.indexOf(',' + nextId) < 0) {
                                        ids += ',' + nextId;
                                        $("#delPSpecIds").val(ids);
                                    }
                                }
                                $(oldvalue1).eq(nIndex).closest('tr').remove();
                            }
                        }
                    })
                }
                //查询第二个规格要删除的数据
                var new_arry2 = [];
                var new_arry2 = old_arry2.filter(function (n) {
                    return new_arr2.indexOf(n) == -1
                });
                //查询第三个规格要删除的数据
                var new_arry3 = [];
                var new_arry3 = old_arry3.filter(function (n) {
                    return new_arr3.indexOf(n) == -1
                });
                if (new_arry2.length > 0) {
                    $.each(oldvalue1, function (oIndex, oitem) {
                        var oldvalue2 = $(oitem).closest('tr').find("input[name='SpecName2']").val();
                        if ($.inArray(oldvalue2, new_arry2) != -1) {
                            var oId = $(oitem).closest('tr').find("input[name='ProductSpecId']").val();
                            if (parseInt(oId) > 0) {
                                var ids = $("#delPSpecIds").val();
                                if (ids.indexOf(',' + oId) < 0) {
                                    ids += ',' + oId;
                                    $("#delPSpecIds").val(ids);
                                }
                            }
                            $(oitem).closest('tr').remove();
                        }
                        if (new_arry3.length > 0) {
                            var oldvalue3 = $(oitem).closest('tr').find("input[name='SpecName3']").val();
                            if ($.inArray(oldvalue3, new_arry3) != -1) {
                                var oId = $(oitem).closest('tr').find("input[name='ProductSpecId']").val();
                                if (parseInt(oId) > 0) {
                                    var ids = $("#delPSpecIds").val();
                                    if (ids.indexOf(',' + oId) < 0) {
                                        ids += ',' + oId;
                                        $("#delPSpecIds").val(ids);
                                    }
                                }
                                $(oitem).closest('tr').remove();
                            }
                        }
                    });
                } else {
                    if (new_arry3.length > 0) {
                        $.each(oldvalue1, function (oIndex, oitem) {
                            var oldvalue3 = $(oitem).closest('tr').find("input[name='SpecName3']").val();
                            if ($.inArray(oldvalue3, new_arry3) != -1) {
                                var oId = $(oitem).closest('tr').find("input[name='ProductSpecId']").val();
                                if (parseInt(oId) > 0) {
                                    var ids = $("#delPSpecIds").val();
                                    if (ids.indexOf(',' + oId) < 0) {
                                        ids += ',' + oId;
                                        $("#delPSpecIds").val(ids);
                                    }
                                }
                                $(oitem).closest('tr').remove();
                            }
                        });
                    }
                }
            }
            else {
                //无旧值则全部新增
                $.each(new_arr1, function (nindex, nitem) {
                    if (new_arr2.length > 0) {
                        $.each(new_arr2, function (yIndex, yitem) {
                            if (new_arr3.length > 0) {
                                $.each(new_arr3, function (oIndex, oitem) {
                                    setAllValue(nitem, yitem, oitem, 0);
                                });
                            } else {
                                setAllValue(nitem, yitem, '', 0);
                            }
                        });
                    } else {
                        setAllValue(nitem, '', '', 0);
                    }
                });
            }
        }
        function setAllValue(first, second, third, id) {
            var str = '<tr class="spectr">';
            str += '<td><input type="hidden" name="ProductSpecId" value="' + id + '" /><input required="required" class="spectext" type="text" name="SpecName" value="' + first + '" readonly/></td>';
            str += '<td><input class="spectext" type="text" name="SpecName2" value="' + second + '"  readonly/></td>';
            str += '<td><input class="spectext" type="text" name="SpecName3" value="' + third + '"  readonly/></td>';
            str += '<td><input class="spectext" type="text" name="SpecPrice" value=""  /></td>';
            str += '<td><input class="spectext" type="text" name="SpecOldPrice" value=""  /></td>';
            if ($("#isMember").val() == "value") {
                str += '<td><input class="spectext"  type="text" name="VipPrice" value="" /></td>';
            }
            str += '<td><input class="spectext" type="text" name="SpecStock" value=""/></td>';
            str += '<td><input class="spectext" type="text" name="SpecBarCode" value="" /></td>';
            str += '</tr>';
            $("#specTD table").append(str);
        }
        function setNextValue(first, second, third, id) {
            var str = '<tr class="spectr">';
            str += '<td><input type="hidden" name="ProductSpecId" value="' + id + '" /><input required="required" class="spectext" type="text" name="SpecName" value="' + first + '" readonly/></td>';
            str += '<td><input class="spectext" type="text" name="SpecName2" value="' + second + '"  readonly/></td>';
            str += '<td><input class="spectext" type="text" name="SpecName3" value="' + third + '"  readonly/></td>';
            str += '<td><input class="spectext" type="text" name="SpecPrice" value=""  /></td>';
            str += '<td><input class="spectext" type="text" name="SpecOldPrice" value=""  /></td>';
            if ($("#isMember").val() == "value") {
                str += '<td><input class="spectext"  type="text" name="VipPrice" value="" /></td>';
            }
            str += '<td><input class="spectext" type="text" name="SpecStock" value=""/></td>';
            str += '<td><input class="spectext" type="text" name="SpecBarCode" value="" /></td>';
            str += '</tr>';
            return str;
        }
        //判断是否为空
        function isEmpty(data) {
            var dataType = typeof (data);//typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined";
            switch (dataType) {
                case "number"://数字
                    return false;
                    break;
                case "string"://字符串
                    if (data == "") {//为空
                        return true;
                    } else {
                        return false;
                    }
                    break;
                case "boolean"://布尔值
                    return data;
                    break;
                case "object"://对象
                    if (!data && typeof (data) != "undefined" && data != 0) {//为null
                        return true;
                    } else {
                        for (var key in data) {//非空对象
                            return false;
                        }
                        return true;
                    }
                    break;
                case "function"://函数
                    return false;
                    break;
                case "undefined"://undefined
                    return true;
                    break;
            }
        }
        //价格,库存
        function openModal(type) {
            $("#price").textbox('setValue', 0);
            $("#stock").textbox('setValue', 0);
            $("#setType").val(type);
            if (type == 1) {
                $("#stock").parent().hide();
                $("#price").parent().show();
            } else {
                $("#price").parent().hide();
                $("#stock").parent().show();
            }
            $("#OpenModal").window("open");
        }
        function submitPrice() {
            if ($("#setType").val() == 1)
                $("input[name='SpecPrice']").val($("#price").textbox('getValue'));
            else
                $("input[name='SpecStock']").val($("#stock").textbox('getValue'));
            $("#OpenModal").window("close");
        }
        //满减设置
        function setPromotion(type) {
            if (type == 1) {
                var row = $('#grid').datagrid('getChecked');
                if (row.length == 1) {
                    $("#promotion").form('load', {
                        num: 0,
                        price: 0,
                        beginTime: '',
                        endTime: '',
                        typeId: type,
                        productId: row[0].PProductId,
                        storeId: row[0].KStoreId,
                        PId: 0
                    });
                    $.ajax({
                        url: '/Product/GetPromotionByProId',
                        type: 'post',
                        data: { productId: row[0].PProductId },
                        success(res) {
                            console.log(res);
                            var data = eval('(' + res + ')');
                            if (data.ok) {
                                if (data.data != null) {
                                    $("#promotion").form('load', {
                                        num: data.data.FNum,
                                        price: data.data.FPrice,
                                        beginTime: data.data.FBeginTime,
                                        endTime: data.data.FEndTime,
                                        PId: data.data.PPromotionId
                                    });
                                }
                            }
                        }
                    });
                    $("#OpenConfig").window("open");
                } else { msgShow("系统提示", "请选择一条设置满减的产品!", "warning"); }
            } else {
                $.messager.confirm('系统提示', "确定要设置全部产品的满减,设置成功后之前商品设置的全部无效?", function (r) {
                    if (r) {
                        $("#promotion").form('load', {
                            num: 0,
                            price: 0,
                            beginTime: '',
                            endTime: '',
                            typeId: type,
                            productId: 0,
                            storeId: $("#storeid").val(),
                            PId: 0
                        });
                        $("#OpenConfig").window("open");
                    }
                });
            }
        }
        function Cancel() {
            $("#OpenConfig").window("close");
        }
        function Submit() {
            var flag = $("#promotion").form('validate');
            if (!flag) {
                msgShow("系统提示", "请输入所有必填项!", "warning");
                return;
            }
            var reg1 = /^\d*\.{0,1}\d{0,1}\d$/;
            var reg2 = /^\d+$/;
            if (!reg2.test($("#promotion input[name='num'").val())) {
                msgShow("系统提示", "满减数量只能输入非负整数", "warning");
                return;
            }
            if (!reg1.test($("#promotion input[name='price'").val())) {
                msgShow("系统提示", "优惠价格只能输入非负整数以及小数点后两位", "warning");
                return;
            }
            if ($("#promotion input[name='beginTime'").val() != "" || $("#promotion input[name='endTime']").val() != "") {
                if ($("input[name='beginTime'").val() > $("input[name='endTime']").val()) {
                    $.messager.alert('操作失败', '结束时间要大于开始时间!', "warning");
                    return;
                }

            }
            $.ajax({
                type: "POST",
                url: "/Product/SavePromotion",
                data: $("#promotion").serialize(),// 你的formid
                async: false,
                success: function (data) {
                    var data = eval("(" + data + ")");
                    if (data.ok) {
                        msgShow("系统提示", "设置成功!", "info");
                        $("#OpenConfig").window("close");
                        $("#grid").datagrid("reload");
                    } else {
                        msgShow("系统提示", data.msg, "warning");
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                        parent.location.reload();
                    });
                }
            })
        }
    </script>

}

然后是封装出的前端js代码

//var tool = [{
//    id: 'btnAdd',
//    text: '添加',
//    iconCls: 'icon-add',
//    handler: function () {
//        EditBind(0);
//    }
//}, '-', {
//    id: 'btnEdit',
//    text: '修改',
//    iconCls: 'icon-edit',
//    handler: function () {
//        EditBind(1);
//    }
//}, '-', {
//    id: 'btnDelete',
//    text: '删除',
//    iconCls: 'icon-remove',
//    handler: function () {
//        BatchOperation(0);
//    }
//}, '-', {
//    id: 'btnReload',
//    text: '上架',
//    iconCls: 'icon-edit',
//    handler: function () {
//        BatchOperation(1);
//    }
//}, '-', {
//    id: 'btnReload',
//    text: '下架',
//    iconCls: 'icon-edit',
//    handler: function () {
//        //实现刷新栏目中的数据
//        BatchOperation(2);
//    }
//}, '-', {
//    id: 'btnReload',
//    text: '复制产品',
//    iconCls: 'icon-ok',
//    handler: function () {
//        //实现刷新栏目中的数据
//        //$('#copyProduct').panel({ iconCls: "icon-edit" });
//        //$('#copyProduct').window('open');
//        EditBind(2);
//    }
//}, '-', {
//    id: 'btnGroup',
//    text: '设置拼团',
//    iconCls: 'icon-ok',
//    handler: function () {
//        //实现刷新栏目中的数据
//        AddGroup();
//    }
//}, '-', {
//    id: 'btnBargain',
//    text: '设置砍价',
//    iconCls: 'icon-ok',
//    handler: function () {
//        //实现刷新栏目中的数据
//        AddBargain();
//    }
//}, '-', {
//    id: 'btnCommission',
//    text: '设置分佣',
//    iconCls: 'icon-ok',
//    handler: function () {
//        //实现刷新栏目中的数据
//        AddCommission();
//    }
//}, '-', {
//    id: 'btnAllCommission',
//    text: '设置所有产品分佣',
//    iconCls: 'icon-ok',
//    handler: function () {
//        //实现刷新栏目中的数据
//        SetAllCommission();
//    }
//}, '-', {
//    id: 'btnIntegral',
//    text: '设置积分',
//    iconCls: 'icon-ok',
//    handler: function () {
//        //实现刷新栏目中的数据
//        AddIntegral();
//    }
//}, '-', {
//    id: 'btnCommission',
//    text: '添加评价',
//    iconCls: 'icon-ok',
//    handler: function () {
//        //实现刷新栏目中的数据
//        UserEvaluate();
//    }
//},
////'-', {
////    id: 'btnSince',
////    text: '添加自提点',
////    iconCls: 'icon-ok',
////    handler: function () {
////        //实现刷新栏目中的数据
////        AddSince();
////    }
////},
// '-', {
//     id: 'btnReload',
//     text: '刷新',
//     iconCls: 'icon-reload',
//     handler: function () {
//         //实现刷新栏目中的数据
//         $("#grid").datagrid("reload");
//     }
// }, '-', {
//     id: 'btnExcel',
//     text: '导出Excel',
//     iconCls: 'icon-save',
//     handler: function () {
//         var productName = $("#searchName").textbox("getValue");
//         var storeId = $("#storeId").combobox("getValue");
//         var productType = $("#ProductType").combobox("getValue");
//         var typeId = $("#SelType").combobox("getValue");
//         var state = $("#State").combobox("getValue");
//         open("/Product/ImportExcel?productName=" + productName + "&storeId=" + storeId + "&productType=" + productType + "&typeId=" + typeId + "&state=" + state);
//     }
// }];
function BatchOperation(state) {
    var rows = $('#grid').datagrid('getSelections');
    console.log(rows);
    if (rows) {
        var msg = "确定删除选中产品记录,删除后将无法修复!";
        if (state == 1)
            msg = "确定上架选中产品信息?";
        if (state == 2)
            msg = "确定下架选中产品信息?";
        var ids = "";

        for (var i = 0; i < rows.length; i++) {
            if (state == 1 || state == 2) {
                if (rows[i].FState == 3 || rows[i].FState == 4) {
                    msgShow("系统提示", "操作失败,包含审核不通过或者待审核的产品!", "warning");
                    return;
                }
            }
            ids += rows[i].PProductId + ",";
        }
        ids = ids.length > 0 ? ids.substring(0, ids.length - 1) : "0";
        $.messager.confirm('产品操作', msg, function (r) {
            if (r) {

                var posturl = "/Product/UpdateProductState";
                var pars = {};
                pars["ids"] = ids;
                pars["state"] = state;
                $.ajax({
                    cache: true,
                    type: "POST",
                    url: posturl,
                    data: pars,// 你的formid
                    async: false,
                    error: function (request) {
                    },
                    success: function (data) {

                        if (data == 1) {
                            msgShow("系统提示", "操作成功!", "info");
                            $("#grid").datagrid("reload");
                            $('#grid').datagrid('clearSelections');
                        } else {
                            msgShow("系统提示", "操作失败,超过最大上架数!", "info");
                        }
                    }
                });
            }
        });
    }
}

function reload() {
    $("#grid").datagrid("reload");
}

function EditBind(operate) {
    if (wxId == 3272 && $("#isShow").val() == "0") {
        $.messager.confirm('系统提示', '新增/更改产品信息后,需平台审核后才能上架展示,请谨慎修改', function (r) {
            if (r) {
                EditProduct(operate);
            }
        });
    } else {
        EditProduct(operate)
    }
}
//初始化规格项目
function InitSpecName() {
    var specTitleName = $("#specTitleTable input[name='SpecTitleName']");
    var specItemList = $(specTitleName).eq(0).closest('tr').next().find("input[name='SpecItemName']");
    $.each(specItemList, function (index, item) {
        if (index != 0) {
            $(item).parent().prev().remove();
            $(item).parent().remove();
        }
    })
    if ($(specTitleName).eq(1).length > 0) {
        $(specTitleName).eq(1).closest('tr').next().remove();
        $(specTitleName).eq(1).closest('tr').remove();
    }
    if ($(specTitleName).eq(2).length > 0) {
        $(specTitleName).eq(2).closest('tr').next().remove();
        $(specTitleName).eq(2).closest('tr').remove();
    }
    if ($("#WxId").val() == '3168') {
        $("#specTitleTable input[name='SpecTitleName']").eq(0).parent().prev().textbox('setValue', '招生对象');
        var str = `<tr>
                        <td>规格名:</td>
                        <td>
                            <input type="text" class ="easyui-textbox" name="SpecTitleName" value="招生人数"/>
                            <a class ="easyui-linkbutton" href="javascript:void(0)" onclick="DelTitleRow(this)">删除规格项目</a>
                        </td>
                    </tr>
                    <tr>
                        <td>规格值:</td>
                        <td>
                            <input type="text" class ="easyui-textbox" name="SpecItemName" data-options="icons:[{iconCls:'icon-clear',handler: DelCellValue}]"/>
                            <a class ="abtn" href="javascript:void(0)" onclick="AddCellValue(this)">添加规格值</a>
                        </td>
                    </tr>
                    <tr>
                        <td>规格名:</td>
                        <td>
                            <input type="text" class ="easyui-textbox" name="SpecTitleName" value="上课时间"/>
                            <a class ="easyui-linkbutton" href="javascript:void(0)" onclick="DelTitleRow(this)">删除规格项目</a>
                        </td>
                    </tr>
                    <tr>
                        <td>规格值:</td>
                        <td>
                            <input type="text" class ="easyui-textbox" name="SpecItemName" data-options="icons:[{iconCls:'icon-clear',handler: DelCellValue}]"/>
                            <a class ="abtn" href="javascript:void(0)" onclick="AddCellValue(this)">添加规格值</a>
                        </td>
                    </tr>`;
        $.parser.parse($("#specTitleTable"));
    }
}
function EditProduct(operate) {
    $("#mtr_1").show();
    if (operate == 0) {
        $("#ff").form('load', {
            ProductType: "",
            OrderNum: 0,
            Name: "",
            OldPrice: "",
            Price: "",
            Freight: "",
            Sort: "",
            OrderNum: "",
            BeginTime: "",
            EndTime: "",
            State: 1,
            Type: 0,
            UnitName: "",
            MaxCount: 0,
            SaleTime: "",
            Weigth: "",
            Tag: "",
            FSpecName: "",
            FSpecName2: "",
            FSpecName3: "",
            SpecTitleName: "",
            SpecItemName: ""
        });
        if ($("#WxId").val() == '3168') {
            $("#ff").form('load', {
                FSpecName: "招生对象",
                FSpecName2: "招生人数",
                FSpecName3: "上课时间"
            })
        }
        $("#productId").val(0);

        var storeId = $("#storeid").val();

        $("#Type").combobox({
            url: '/Type/GetProductTypeByStoreId?storeId=' + storeId,
            valueField: 'PTypeId',
            textField: 'FName',
            loadFilter: function (data) {
                var l1 = [];
                var l2 = [];
                var newData = [];
                data.forEach(function (i) {
                    if (i.KParentId == 0 || i.KParentId == null) {
                        l1.push(i);
                    } else {
                        l2.push(i);
                    }
                });
                l1.forEach(function (i) {
                    newData.push(i);
                    l2.forEach(function (m) {
                        if (i.PTypeId == m.KParentId) {
                            m.FName = "|--" + m.FName;
                            newData.push(m);
                        }
                    });
                });
                //newData.unshift({ PTypeId: 0, FName: "全部" });
                return newData;
            },
            onLoadSuccess: function (data) {
                if (data.length > 0) {
                    $("#Type").combobox("setValue", data[0].PTypeId);
                }
            }
        });

        UM.getEditor('editor', {
            toolbar: [
                'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
                'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
                '| justifyleft justifycenter justifyright justifyjustify |',
                'link unlink | emotion image | map',
                '| horizontal print preview fullscreen', 'drafts', 'formula'
            ]
        }).setContent("", false);
        for (var i = 0; i < 6; i++) {
            $("#picUrl_" + (i + 1)).attr("src", "");
            $("#image_" + (i + 1)).val("");
        }
        for (var i = 0; i < $("#count").val(); i++) {
            $("#mpicUrl_" + (i + 1)).attr("src", "");
            $("#mimage_" + (i + 1)).val("");
            if (i > 5) {
                $("#mtr_" + (i / 6 + 1)).hide();
            }
        }
        //初始化规格明细
        $("#specTD table .spectr").remove();
        InitSpecName();
        // AddRow();
        $('#product').panel({ title: "新增" });
        $('#product').panel({ iconCls: "icon-add" });
        $('#product').window('open');
    }
    else if (operate == 1 || operate == 2) {
        var row = $('#grid').datagrid('getSelected');
        if (row) {

            $("#ff").form('load', {
                Name: row.FName,
                OldPrice: row.FOldPrice,
                Price: row.FPrice,
                Freight: row.FFreight,
                Sort: row.FSort,
                ProductType: row.FProductType,
                OrderNum: row.FOrderNum,
                BeginTime: row.FBeginTime != null ? row.FBeginTime.replace("T", " ") : "",
                EndTime: row.FEndTime != null ? row.FEndTime.replace("T", " ") : "",
                State: row.FState != 2 ? 1 : 2,
                Store: row.KStoreId,
                Type: row.KTypeId,
                UnitName: row.FUnitName,
                MaxCount: row.FMaxCount,
                SaleTime: row.FSaleTime,
                Weigth: row.FWeigth,
                IsHide: row.FIsHide,
                //HomeTemplateId: row.KHomeTemplateId,
                PrintSetId: row.KPrintSetId,
                Tag: row.FTag,
                FSpecName: row.FSpecName,
                FSpecName2: row.FSpecName2,
                FSpecName3: row.FSpecName3
            });
            if ($("#FreightTemplateId").length > 0) {
                $("#ff").form('load', {
                    FreightTemplateId: row.KTemplateNameId,
                })
            }
            if ($("#WxId").val() == '3168') {
                $("#ff").form('load', {
                    FSpecName: "招生对象",
                    FSpecName2: "招生人数",
                    FSpecName3: "上课时间"
                })
            }

            if (row != null) {
                $("#Type").combobox({
                    url: '/Type/GetProductTypeByStoreId?storeId=' + row.KStoreId,
                    valueField: 'PTypeId',
                    textField: 'FName'
                });

                $("#Type").combobox("setValue", row.KTypeId);
                $("#IsPackage").combobox("setValue", row.FIsPackage);
            }
            if (row.FContent == null)
                UM.getEditor('editor', {
                    toolbar: [
                        'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
                        'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
                        '| justifyleft justifycenter justifyright justifyjustify |',
                        'link unlink | emotion image | map',
                        '| horizontal print preview fullscreen', 'drafts', 'formula'
                    ]
                }).setContent("", false);
            else
                UM.getEditor('editor', {
                    toolbar: [
                        'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
                        'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
                        '| justifyleft justifycenter justifyright justifyjustify |',
                        'link unlink | emotion image | map',
                        '| horizontal print preview fullscreen', 'drafts', 'formula'
                    ]
                }).setContent(row.FContent, false);
            if (operate == "1") {
                $("#productId").val(row.PProductId);
                $("#copyId").val(0);

            }
            else {
                $("#productId").val(0);
                $("#copyId").val(row.PProductId);
            }
            for (var i = 0; i < 6; i++) {
                $("#picUrl_" + (i + 1)).attr("src", "");
                $("#image_" + (i + 1)).val("");
            }
            for (var i = 0; i < $("#count").val(); i++) {
                $("#mpicUrl_" + (i + 1)).attr("src", "");
                $("#mimage_" + (i + 1)).val("");
                if (i > 5) {
                    $("#mtr_" + (i / 6 + 1)).hide();
                }
            }
            //初始化
            InitSpecName();
            $.ajax({
                url: '/Product/GetMainSpecList',
                type: 'Post',
                data: { productId: row.PProductId },
                async: false,
                success(result) {
                    var data = eval('(' + result + ')');
                    $("#specTitleTable input[name='SpecTitleName']").eq(0).parent().prev().textbox('setValue', row.FSpecName);
                    var specItemList = $("#specTitleTable input[name='SpecTitleName']").eq(0).closest('tr').next().find("input[name='SpecItemName']");
                    $.each(data.SpecName, function (index, item) {
                        if (index == 0) {
                            $(specItemList).parent().prev().textbox('setValue', item);
                        } else {
                            $(specItemList).parent().after(`<input type="text" class="easyui-textbox" name="SpecItemName" data-options="icons:[{iconCls:'icon-clear',handler: DelCellValue}]" value="${item}" />`);
                            $.parser.parse($(specItemList).closest('td'));
                        }
                    });
                    if (data.SpecName2.length > 0 && row.FSpecName2 != "" && row.FSpecName2 != null) {
                        var str = `<tr>
                            <td>规格名:</td>
                            <td>
                                <input type="text" class ="easyui-textbox" name="SpecTitleName" value="${row.FSpecName2}"/>
                                <a class ="easyui-linkbutton" href="javascript:void(0)" onclick="DelTitleRow(this)">删除规格项目</a>
                            </td>
                        </tr>
                        <tr><td>规格值:</td><td>`;
                        $.each(data.SpecName2, function (index, item) {
                            str += `<input type="text" class ="easyui-textbox" name="SpecItemName" data-options="icons:[{iconCls:'icon-clear',handler: DelCellValue}]" value="${item}"/>`;
                        });
                        str += `<a class ="abtn" href="javascript:void(0)" onclick="AddCellValue(this)">添加规格值</a></td></tr>`;

                        if (data.SpecName3.length > 0 && row.FSpecName3 != "" && row.FSpecName3 != null) {
                            str += `<tr>
                            <td>规格名:</td>
                            <td>
                                <input type="text" class ="easyui-textbox" name="SpecTitleName" value="${row.FSpecName3}"/>
                                <a class ="easyui-linkbutton" href="javascript:void(0)" onclick="DelTitleRow(this)">删除规格项目</a>
                            </td>
                        </tr>
                        <tr><td>规格值:</td><td>`;
                            $.each(data.SpecName3, function (index, item) {
                                str += `<input type="text" class ="easyui-textbox" name="SpecItemName" data-options="icons:[{iconCls:'icon-clear',handler: DelCellValue}]" value="${item}"/>`;
                            });
                            str += `<a class ="abtn" href="javascript:void(0)" onclick="AddCellValue(this)">添加规格值</a></td></tr>`;
                        }
                        $("#specTitleTable input[name='SpecTitleName']").closest('tr').next().after(str);
                        $.parser.parse($("#specTitleTable"));
                    }
                }
            })

            var imagePath = $("#imagePath").val();

            var url = "/Product/GetImageList/" + row.PProductId;
            $.ajax({
                cache: true,
                type: "get",
                url: url,
                async: false,
                error: function (request) {
                },
                success: function (data) {

                    //产品图片列表
                    var jsonObj = eval('(' + data + ')');
                    $.each(jsonObj, function (index, item) {
                        if (item) {
                            if (item.FType == 1) {
                                $("#picUrl_" + item.FOrder).attr("src", "/images/wxid_" + $("#WxId").val() + "/ProductImage/" + item.FImageUrl);
                                $("#image_" + item.FOrder).val(item.FImageUrl);
                            } else {

                                $("#mpicUrl_" + item.FOrder).attr("src", "/images/wxid_" + $("#WxId").val() + "/ProductImage/" + item.FImageUrl);
                                $("#mimage_" + item.FOrder).val(item.FImageUrl);
                                $("#mtr_" + (parseInt(item.FOrder / 6) + 1)).show();
                            }
                        }
                    });
                }
            });

            url = "/Product/GetProductSpecList?productId=" + row.PProductId;
            $.ajax({
                cache: true,
                type: "get",
                url: url,
                async: false,
                error: function (request) {
                },
                success: function (data) {
                    $("#specTD table .spectr").remove();
                    //产品图片列表
                    var jsonObj = eval('(' + data + ')');

                    $.each(jsonObj.rows, function (index, item) {

                        var str = '<tr class="spectr" id="spectr' + index + '">';
                        var spec = item.FSpecName == null ? "" : item.FSpecName;
                        var specName2 = item.FSpecName2 == null ? "" : item.FSpecName2;
                        var specName3 = item.FSpecName3 == null ? "" : item.FSpecName3;
                        var price = item.FPrice == null ? "" : item.FPrice;
                        var oldPrice = item.FOldPrice == null ? "" : item.FOldPrice;
                        var stock = item.FStock == null ? "" : item.FStock;
                        var barCode = item.FBarCode == null ? "" : item.FBarCode;
                        var vipPrice = item.FVipPrice == null ? "" : item.FVipPrice;
                        var str = '<tr class="spectr">';
                        str += '<td><input type="hidden" name="ProductSpecId" value="' + item.PProductSpecId + '" /><input required="required" class="spectext" type="text" name="SpecName" value="' + spec + '" readonly/></td>';
                        str += '<td><input class="spectext" type="text" name="SpecName2" value="' + specName2 + '"  readonly/></td>';
                        str += '<td><input class="spectext" type="text" name="SpecName3" value="' + specName3 + '"  readonly/></td>';
                        str += '<td><input class="spectext" type="text" name="SpecPrice" value="' + price + '"  /></td>';
                        str += '<td><input class="spectext" type="text" name="SpecOldPrice" value="' + oldPrice + '"  /></td>';
                        if ($("#isMember").val() == "value") {
                            str += '<td><input class="spectext"  type="text" name="VipPrice" value="' + vipPrice + '" /></td>';
                        }
                        str += '<td><input class="spectext" type="text" name="SpecStock" value="' + stock + '"/></td>';
                        str += '<td><input class="spectext" type="text" name="SpecBarCode" value="' + barCode + '" /></td>';
                        str += '</tr>';
                        //str += '<td><input class="spectext"  required="required" type="text" id="FSpecName' + index + '" name="SpecName" value="' + spec + '" /></td>';
                        //str += '<td><input class="spectext" type="text" id="FSpecNameTwo' + index + '" name="SpecName2" value="' + specName2 + '" /></td>';
                        //str += '<td><input class="spectext" type="text" id="FSpecNameThree' + index + '" name="SpecName3" value="' + specName3 + '" /></td>';
                        //str += '<td><input class="spectext"  required="required" type="text" id="FPrice' + index + '"  name="SpecPrice" value="' + price + '" /></td>';
                        //str += '<td><input class="spectext"  required="required" type="text" id="FOldPrice' + index + '" name="SpecOldPrice" value="' + oldPrice + '"  /></td>';

                        //if ($("#isMember").val() == "value")
                        //    str += '<td><input class="spectext"  type="text" id="FVipPrice' + index + '" name="VipPrice" value="' + vipPrice + '" /></td>';

                        //str += '<td><input class="spectext"  required="required" type="text" id="FStock' + index + '" name="SpecStock" value="' + stock + '" /></td>';
                        //str += '<td><input class="spectext" type="text" id="FBarCode' + index + '"  name="SpecBarCode" value="' + barCode + '"  /></td>';
                        //str += '<td><a class="aStyle" href="javascript:deleteRow(' + index + ');">删除</a><input type="hidden" id="PProductSpecId' + index + '" name="ProductSpecId" value="' + item.PProductSpecId + '" /></td>';
                        //str += '</tr>';
                        //var html = $("#specTD table").html() + str;
                        $("#specTD table").append(str);
                    });

                }
            });
            var msg = operate == "1" ? "修改" : "复制产品";
            $('#product').panel({ title: msg });
            $('#product').panel({ iconCls: "icon-edit" });
            $('#product').window('open');
        } else {
            msgShow("系统提示", "请选择要修改的产品!", "warning");
        }
    }
}
function AddRow() {

    var index = Date.parse(new Date());
    var str = '<tr class="spectr" id="spectr' + index + '">';
    str += '<td><input  required="required" class="spectext" type="text" id="FSpecName' + index + '" name="SpecName" value=""  /></td>';
    str += '<td><input class="spectext" type="text" id="FSpecNameTwo' + index + '"  name="SpecName2" value=""  /></td>';
    str += '<td><input class="spectext" type="text" id="FSpecNameThree' + index + '"  name="SpecName3" value=""  /></td>';
    str += '<td><input class="spectext" type="text" id="FPrice' + index + '" name="SpecPrice" value=""  /></td>';
    str += '<td><input class="spectext" type="text" id="FOldPrice' + index + '" name="SpecOldPrice" value=""  /></td>';
    if ($("#isMember").val() == "value")
        str += '<td><input class="spectext"  type="text" id="FVipPrice' + index + '" name="VipPrice" value="" /></td>';

    str += '<td><input class="spectext" type="text" id="FStock' + index + '" name="SpecStock" value=""/></td>';
    str += '<td><input class="spectext" type="text" id="FBarCode' + index + '" name="SpecBarCode" value="" /></td>';
    str += '<td><a class="aStyle" href="javascript:deleteRow(' + index + ')">删除</a><input type="hidden" id="PProductSpecId' + index + '" name="ProductSpecId" value="0" /></td>';
    str += '</tr>';

    $("#specTD table").append(str);
}
function deleteRow(index) {
    if ($("#PProductSpecId" + index).val() > 0) {
        if (confirm("确定删除该产品规格记录,删除后将无法修复!")) {
            var copyId = $("#copyId").val();
            if (copyId && copyId != "0") {//如果是复制,直接移除规格
                $("#spectr" + index).remove();
                return;
            }
            var posturl = "/Product/DeleteProductSpec";
            var pars = {};
            pars["id"] = $("#PProductSpecId" + index).val();
            $.ajax({
                cache: true,
                type: "POST",
                url: posturl,
                data: pars,// 你的formid
                async: false,
                error: function (request) {
                },
                success: function (data) {
                    msgShow("系统提示", "删除成功!", "info");
                    $("#spectr" + index).remove();
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                        parent.location.reload();
                    });

                }
            });
        }
    } else {
        $("#spectr" + index).remove();
    }


}

function imgUpload(index) {
    var file = $("#uploadify")[0];
    var typeVal = $("input[name='certType']:checked").val();
    if (typeVal == 1) {
        if ($("#image_6").val() != "") {
            alert("已经超过6张图片");
            $('#uploadify').val('');
            return;
        }
    }
    else {
        if ($("#mimage_" + $("#count").val()).val() != "" && $("#mimage_" + $("#count").val()).val() != undefined) {
            alert("已经超过" + $("#count").val() + "张图片");
            $('#uploadify').val('');
            return;
        }
    }
    var formData = new FormData();
    formData.append("Filedata", file.files[index]);
    $.ajax({
        type: 'POST',
        url: "/product/uploadhandler",
        data: formData,
        dataType: 'json',
        contentType: false,
        processData: false,
        beforeSend: function () {
            if (typeVal == 1) {
                if ($("#image_6").val() != "") {
                    alert("已经超过6张图片");
                    return;
                }
            }
            else {
                if ($("#mimage_" + $("#count").val()).val() != "" && $("#mimage_" + $("#count").val()).val() != undefined) {
                    alert("已经超过" + $("#count").val() + "张图片");
                    return;
                }
            }
            ajaxLoading();
        },
        success: function (e) {
            ajaxLoadEnd();
            if (e.isSuccess) {
                var val = typeVal == 1 ? "" : "m";
                for (var idx = 1; idx <= $("#count").val(); idx++) {
                    if ($("#" + val + "image_" + idx).val() == "") {
                        $("#" + val + "picUrl_" + idx).attr("src",
                            "/images/wxid_" + $("#WxId").val() + "/ProductImage/" + e.data);
                        $("#" + val + "image_" + idx).val(e.data);

                        if (val == "m") {
                            $("#mtr_" + (idx / 6 + 1)).show();
                        }
                        break;
                    }
                }
                index++;
                if (index + 1 <= file.files.length) {
                    imgUpload(index);
                } else {
                    $('#uploadify').val('');
                }
            } else {
                msgShow("系统提示", e.msg, "warning");
            }
        }
    });
}

function ChangesType() {
    var rows = $('#grid').datagrid('getSelections');
    if (rows.length > 0) {
        var ids = [];
        var name = [];
        $.each(rows, function (index, item) {
            ids.push(item.PProductId);
            name.push(item.FName);
        })
        var html = "";
        $("#PName").html("");
        for (var i = 0; i < name.length; i += 5) {
            html += "<tr class=\'datagrid-row\'><td class=\'datagrid-cell\'>" + name[i] + "</td>";
            if (i + 1 < name.length)
                html += "<td class=\'datagrid-cell\'>" + name[i + 1] + "</td>";
            else {
                html += "<td class=\'datagrid-cell\'></td>";
            }
            if (i + 2 < name.length)
                html += "<td class=\'datagrid-cell\'>" + name[i + 2] + "</td>";
            else {
                html += "<td class=\'datagrid-cell\'></td>";
            }
            if (i + 3 < name.length)
                html += "<td class=\'datagrid-cell\'>" + name[i + 3] + "</td>";
            else {
                html += "<td class=\'datagrid-cell\'></td>";
            }
            if (i + 4 < name.length)
                html += "<td class=\'datagrid-cell\'>" + name[i + 4] + "</td>";
            else {
                html += "<td class=\'datagrid-cell\'></td>";
            }
            html += "</tr>";
        }
        $("#PName").append(html);
        $("#ids").val(ids.join(','));
        $("#changesTypeWindow").window('open');

    } else {
        msgShow("系统提示", "请选择要修改类型的产品!", "warning");
    }
}
function ChangesSaleTime() {
    var rows = $('#grid').datagrid('getSelections');
    if (rows.length > 0) {
        var ids = [];
        var name = [];
        $.each(rows, function (index, item) {
            ids.push(item.PProductId);
            name.push(item.FName);
        })
        var html = "";
        $("#TName").html("");
        for (var i = 0; i < name.length; i += 5) {
            html += "<tr class=\'datagrid-row\'><td class=\'datagrid-cell\'>" + name[i] + "</td>";
            if (i + 1 < name.length)
                html += "<td class=\'datagrid-cell\'>" + name[i + 1] + "</td>";
            else {
                html += "<td class=\'datagrid-cell\'></td>";
            }
            if (i + 2 < name.length)
                html += "<td class=\'datagrid-cell\'>" + name[i + 2] + "</td>";
            else {
                html += "<td class=\'datagrid-cell\'></td>";
            }
            if (i + 3 < name.length)
                html += "<td class=\'datagrid-cell\'>" + name[i + 3] + "</td>";
            else {
                html += "<td class=\'datagrid-cell\'></td>";
            }
            if (i + 4 < name.length)
                html += "<td class=\'datagrid-cell\'>" + name[i + 4] + "</td>";
            else {
                html += "<td class=\'datagrid-cell\'></td>";
            }
            html += "</tr>";
        }
        $("#TName").append(html);
        $("#Pids").val(ids.join(','));
        $(".times").eq(0).prop("checked", true);
        $(".times").eq(0).addClass("radio");
        $("#ChangesSaleTimeWindow").window('open');

    } else {
        msgShow("系统提示", "请选择要修改可售时间的产品!", "warning");
    }
}

function UploadVideo(type) {
    var row = $('#grid').datagrid('getSelections');
    if (row.length > 0) {
        if (row.length > 1) {
            let msg = "只能选择一个产品上传视频!";
            if (type == 2) {
                msg = "只能选择一个产品上传讲义!";
            } else if (type == 3) {
                msg = "只能选择一个产品进行题库管理!";
            }
            msgShow("系统提示", msg, "warning");
            return;
        }
        if (type == 0) {
            $.ajax({
                type: "POST",
                url: '/product/GetProVideo',
                data: { Proid: row[0].PProductId },
                success: res => {
                    console.log(res)
                    if (res != "") {
                        $("#player").show();
                        $("#player").attr('src', res);
                    } else {
                        $("#player").hide();
                    }
                }
            })
            $("#Proids").val(row[0].PProductId)
            $("#uploadVideo").window('open');
        }
        else {
            VideoInit('/product/GetVideoList', row, type);
        }
    } else {
        let errmsg = "请选择要上传视频的产品!";
        if (type == 2) {
            errmsg = "请选择要上传讲义的产品!";
        } else if (type == 3) {
            errmsg = "请选择要进行题库管理的产品!";
        }
        msgShow("系统提示", errmsg, "warning");
    }
}
function getTop(id, type) {
    var name = "#VideoForm #parentVideo";
    if (type == 2) {
        name = "#FileForm #parentVideo";
    } else if (type == 3) {
        name = "#LinksForm #parentVideo";
    }

    $(name).combobox({
        url: '/Product/GetTop?id=' + id + "&type=" + type,
        valueField: 'PProductImageId',
        textField: 'FName'
    });
}

function VideoInit(url, row, type) {
    var secondcol = '时间';
    var secondfild = 'FTimeCount';
    var title = "视频列表";
    if (type == 2) {
        secondcol = '是否已上传(pdf文件)';
        secondfild = 'FImageUrl';
        title = "讲义列表";
    } else if (type == 3) {
        secondcol = '题库链接';
        secondfild = 'FImageUrl';
        title = "题库列表";
    }
    var params = { Proid: row[0].PProductId, Type: type };
    $('#videoGrid').treegrid({
        url: url,
        idField: 'PProductImageId',
        treeField: 'FName',
        loadMsg: '数据加载中请稍后……',
        height: GetHeight() - 45,
        queryParams: params,
        columns: [[
            { title: '名称', field: 'FName', width: 250, sortable: false },
            {
                title: secondcol,
                field: secondfild,
                width: 140,
                sortable: false,
                formatter: function (value, row, index) {
                    if (type == 2) {
                        return value != null && value != "" ? "已上传" : ""
                    } else {
                        return value;
                    }
                },
            },
        ]],
        toolbar: [{
            id: 'btnAdd',
            text: '添加',
            iconCls: 'icon-add',
            handler: function () {
                SendWindow(0, type);
            }
        }, '-', {
            id: 'btnEdit',
            text: '修改',
            iconCls: 'icon-edit',
            handler: function () {
                SendWindow(1, type);
            }
        }, '-', {
            id: 'btnDelete',
            text: '删除',
            iconCls: 'icon-remove',
            handler: function () {
                DeleteVideo();
            }
        }, '-', {
            id: 'btnReload',
            text: '刷新',
            iconCls: 'icon-reload',
            handler: function () {
                //实现刷新栏目中的数据
                $("#videoGrid").treegrid("reload");
            }
        }],
        onDblClickRow: function (rowIndex, rowData) {
            SendWindow(1, type);
        },
        onLoadSuccess: function (row, data) {
            if (data.total == 0) {
                //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                $("#VideoList .datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
            }
            //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
            else {
                $("#videoGrid").treegrid('collapseAll');
                $(".divNone").remove();
                $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
            }
        }
    });
    $("#ProName").text("").text(row[0].FName);
    $("#courserId").val(row[0].PProductId);
    $("#VideoList").panel({ title: title });
    $("#VideoList").window('open');
    //$("#videoGrid").datagrid({   //定位到Table标签,Table标签的ID是grid
    //    url: url,   //指向后台的Action来获取当前用户的信息的Json格式的数据
    //    //title: '教师管理',
    //    iconCls: 'icon-view',
    //    //height: function () { return document.body.clientHeight },//自动高度
    //    height: GetHeight()-45,
    //    width: function () { return document.body.clientWidth * 0.9 },//自动宽度
    //    nowrap: true,
    //    loadMsg: "正在加载数据中...",
    //    //autoRowHeight: false,
    //    striped: true,
    //    collapsible: true,
    //    pagination: true,
    //    pageSize: 20,
    //    pageList: [20, 50, 100, 200],
    //    rownumbers: true,
    //    //sortName: 'Seq',    //根据某个字段给easyUI排序
    //    sortOrder: 'asc',
    //    remoteSort: false,
    //    singleSelect: true,
    //    idField: 'PProductImageId',
    //    queryParams: params,  //异步查询的参数
    //    columns: [[
    //        { title: '名称', field: 'FName', width: 250, sortable: false },
    //        { title: '时长', field: 'FTimeCount', width: 120, sortable: false },
    //    ]],
    //    toolbar: [{
    //        id: 'btnAdd',
    //        text: '添加',
    //        iconCls: 'icon-add',
    //        handler: function () {
    //            SendWindow(0);
    //        }
    //    }, '-', {
    //        id: 'btnEdit',
    //        text: '修改',
    //        iconCls: 'icon-edit',
    //        handler: function () {
    //            SendWindow(1);
    //        }
    //    }, '-', {
    //        id: 'btnDelete',
    //        text: '删除',
    //        iconCls: 'icon-remove',
    //        handler: function () {
    //            DeleteVideo();
    //        }
    //    }, '-', {
    //        id: 'btnReload',
    //        text: '刷新',
    //        iconCls: 'icon-reload',
    //        handler: function () {
    //            //实现刷新栏目中的数据
    //            $("#videoGrid").datagrid("reload");
    //        }
    //    }],
    //    onDblClickRow: function (rowIndex, rowData) {
    //        SendWindow(1);
    //    },
    //    onLoadSuccess: function (data) {
    //        if (data.total == 0) {
    //            //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
    //            $("#VideoList .datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
    //            //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
    //            $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
    //        }
    //            //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
    //        else {
    //            $("#VideoList .divNone").remove();
    //            $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
    //        }
    //    }
    //})
}
function SendWindow(type, category) {
    getTop($("#courserId").val(), category);
    if (category == 1) {
        if (type == 0) {
            //新增
            $("#VideoForm").form("load", {
                FName: "",
                FTimeCount: "",
                FOrder: "",
                videoId: 0,
                Proid: $("#courserId").val(),
                hiddensrc: "",
                parentVideo: 0,
                typeId: category
            })
            $("#curriCulum").removeAttr("style");
            $("#curriCulum").parent().find("span").remove(".content");
            $("#VideoForm input[name='btnradio']").removeAttr("checked");
            $("#VideoForm input[name='btnradio']").eq(0).prop("checked", true);
            $(".defined_links").html("").append('<input type="hidden" id="hiddensrc" name="hiddensrc" />');
            $(".upload_video").show();
            $("#player1").attr('src', '');
            $('#productVideoWindow').panel({ title: "新增" });
        }
        else {
            //修改
            var row = $("#videoGrid").datagrid("getSelected");
            if (row) {
                $("#VideoForm").form("load", {
                    FName: row.FName,
                    FTimeCount: row.FTimeCount,
                    FOrder: row.FOrder,
                    videoId: row.PProductImageId,
                    Proid: $("#courserId").val(),
                    parentVideo: row._parentId != undefined ? row._parentId : 0,
                    typeId: category
                })
                if (row.FImageUrl != "" && row.FImageUrl != null) {
                    $("#VideoForm input[name='btnradio']").removeAttr("checked");
                    if (row.FImageUrl.indexOf("https://1253305012.vod2.myqcloud.com/") >= 0) {
                        $("#VideoForm input[name='btnradio']").eq(0).prop("checked", true);
                        $(".defined_links").html("").append('<input type="hidden" id="hiddensrc" name="hiddensrc" />');
                        $(".upload_video").show();
                        $("#curriCulum").css({ "width": "68px" });
                        if ($("#curriCulum").parent().children(".content").length <= 0)
                            $("#curriCulum").parent().append("<span class=\'content\'>已上传</span>");
                    } else {
                        $("#VideoForm input[name='btnradio']").eq(1).prop("checked", true);
                        $(".defined_links").html("").append('<input class="easyui-textbox width-70" id="hiddensrc" name="hiddensrc" /><div style="color:red;">*链接必须是https协议,只支持mp4格式</div>');
                        $(".upload_video").hide();
                        $.parser.parse($(".defined_links"));
                        $("#VideoForm").form('load', { hiddensrc: row.FImageUrl });
                    }
                }
                $("#player1").attr('src', row.FImageUrl);
                $('#productVideoWindow').panel({ title: "修改" });
            } else {
                msgShow("系统提示", "请选择要更改的课程信息!", "warning");
                return;
            }
        }
        $("#productVideoWindow").window("open");
    } else if (category == 2) {
        if (type == 0) {
            //新增
            $("#FileForm").form("load", {
                FName: "",
                FOrder: "",
                videoId: 0,
                Proid: $("#courserId").val(),
                hiddensrc: "",
                parentVideo: 0,
                typeId: category
            });
            $("#uploadFile").removeAttr("style");
            $("#uploadFile").parent().find("span").remove(".content");
            $('#productFileWindow').panel({ title: "新增" });
        }
        else {
            //修改
            var row = $("#videoGrid").datagrid("getSelected");
            if (row) {
                $("#FileForm").form("load", {
                    FName: row.FName,
                    FOrder: row.FOrder,
                    videoId: row.PProductImageId,
                    Proid: $("#courserId").val(),
                    parentVideo: row._parentId != undefined ? row._parentId : 0,
                    typeId: category
                })
                if (row.FImageUrl != "" && row.FImageUrl != null) {
                    $("#uploadFile").css({ "width": "68px" });
                    if ($("#uploadFile").parent().children(".content").length <= 0)
                        $("#uploadFile").parent().append("<span class=\'content\'>已上传</span>");
                }
                $('#productFileWindow').panel({ title: "修改" });
            } else {
                msgShow("系统提示", "请选择要更改的讲义信息!", "warning");
                return;
            }
        }
        $("#productFileWindow").window("open");
    } else if (category == 3) {
        if (type == 0) {
            //新增
            $("#LinksForm").form("load", {
                FName: "",
                FOrder: "",
                videoId: 0,
                Proid: $("#courserId").val(),
                hiddensrc: "",
                parentVideo: 0,
                typeId: category
            })
            $('#productLinksWindow').panel({ title: "新增" });
        }
        else {
            //修改
            var row = $("#videoGrid").datagrid("getSelected");
            if (row) {
                $("#LinksForm").form("load", {
                    FName: row.FName,
                    FOrder: row.FOrder,
                    videoId: row.PProductImageId,
                    Proid: $("#courserId").val(),
                    parentVideo: row._parentId != undefined ? row._parentId : 0,
                    typeId: category,
                    hiddensrc: row.FImageUrl
                })
                $('#productLinksWindow').panel({ title: "修改" });
            } else {
                msgShow("系统提示", "请选择要更改的题库信息!", "warning");
                return;
            }
        }
        $("#productLinksWindow").window("open");
    }
}
function cancelVideo(type) {
    if (type == 1)
        $("#productVideoWindow").window("close");
    else if (type == 2)
        $("#productFileWindow").window("close");
    else if (type == 3)
        $("#productLinksWindow").window("close");
    else if (type == 4)
        $("#productOnLinksWindow").window('close');
}
function Submitvideo(type) {
    var flag = $("#VideoForm").form('validate');
    if (type == 2) {
        flag = $("#FileForm").form('validate');
    }
    else if (type == 3)
        flag = $("#LinksForm").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入所有必填项!", "warning");
        return;
    }
    if (type == 1) {
        var reg = /^\d+$/;
        if (!reg.test($("#FOrder1").textbox('getValue'))) {
            msgShow("系统提示", "排序框只能输入数字", "warning");
            return;
        }
        if ($("#VideoForm input:radio[name='btnradio']:checked").val() == 1) {
            if ($("#VideoForm #hiddensrc").textbox('getValue') != "") {
                var reg = /.+\.mp4/i;
                if (!reg.test($("#VideoForm #hiddensrc").textbox('getValue'))) {
                    msgShow("系统提示", "请填写包含mp4格式的视频链接", "warning");
                    return;
                }
                var urlreg1 = /^https|http+:\/\/[^\s]*.mp4$/;
                if (!urlreg1.test($("#VideoForm #hiddensrc").textbox('getValue'))) {
                    msgShow("系统提示", "请填写https协议的视频链接", "warning");
                    return;
                }
            }
        }
    }
    var params = $("#VideoForm").serialize();
    if (type == 2) {
        console.log($("#FOrder2").textbox("getValue"))
        var reg1 = /^\d+$/;
        if (!reg1.test($("#FOrder2").textbox('getValue'))) {
            msgShow("系统提示", "排序框只能输入数字", "warning");
            return;
        }
        params = $("#FileForm").serialize();
        console.log(params)
    }
    else if (type == 3) {
        var reg2 = /^\d+$/;
        if (!reg2.test($("#FOrder3").textbox('getValue'))) {
            msgShow("系统提示", "排序框只能输入数字", "warning");
            return;
        }
        params = $("#LinksForm").serialize();
    }
    $.ajax({
        type: "POST",
        url: "/Product/SaveVideo",
        data: params,// 你的formid
        async: false,
        success: function (data) {
            var data = eval("(" + data + ")");
            if (data.stauts == 1) {
                msgShow("系统提示", "保存成功!", "info");
                if (type == 1) {
                    $("#VideoForm #hiddensrc").val("");
                    $("#productVideoWindow").window("close");
                } else if (type == 2) {
                    $("#FileForm #hiddensrc").val("");
                    $("#productFileWindow").window("close");
                } else if (type == 3) {
                    $("#LinksForm #hiddensrc").val("");
                    $("#productLinksWindow").window("close");
                }
                $("#videoGrid").treegrid("reload");
            } else {
                msgShow("系统提示", data.msg, "warning");
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                parent.location.reload();
            });
        }
    })
}
function DeleteVideo() {
    var row = $("#videoGrid").datagrid("getSelected");
    if (row) {
        $.messager.confirm('删除', "确定删除选中的信息,删除后将无法修复!", function (r) {
            if (r) {
                $.ajax({
                    url: "/Product/DeleteVideo",
                    data: { id: row.PProductImageId },
                    type: "POST",
                    success: function (data) {
                        if (data) {
                            msgShow("系统提示", "删除成功!", "info");
                            $("#videoGrid").treegrid("reload");
                        } else {
                            msgShow("系统提示", "删除失败!", "warning");
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                            parent.location.reload();
                        });

                    }
                })
            }
        })
    } else {
        msgShow("系统提示", "请选择要删除的教师信息!", "warning");
        return;
    }
}
function uploadFiles(file) {
    $("#uploadFile").removeAttr("style");
    $("#uploadFile").parent().find("span").remove(".content");
    var formData = new FormData();
    formData.append("Filedata", file.files[0]);
    if (file.files[0].size > 1024 * 1024 * 10) {
        msgShow("系统提示", "文件不超过10M!", "warning");
        return;
    }
    $.ajax({
        type: 'POST',
        url: "/Video/UploadFilePdf",
        data: formData,
        dataType: 'json',
        contentType: false,
        processData: false,
        success: function (data) {
            if (data != "false") {
                $("#FileForm #hiddensrc").val(data);
            } else {
                msgShow("系统提示", "上传失败,请检查上传的格式是否正确!", "warning");
            }
        }
    });
}
//单个视频
$("#btnViddeoCancel").click(function () {
    $("#uploadVideo").window('close');
    $("#grid").datagrid("reload");
})
$("#btnVideoSubmit").click(function () {
    var videourl = $("#player").attr("src");
    if (videourl != "" || videourl != undefined) {
        if (videourl.indexOf("https") < 0)
            videourl = videourl.replace("http", "https");
        $.ajax({
            type: "POST",
            url: '/product/SaveProVideo',
            data: { Proid: $("#Proids").val(), videourl: videourl },
            success: res => {
                if (res) {
                    msgShow("系统提示", "操作成功!", "Info");
                }
                $("#uploadVideo").window('close');
                $("#grid").datagrid("reload");
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.alert('登录超时',
                    '操作失败,请重新登录!',
                    "error",
                    function (r) {
                        parent.location.reload();
                    });
            }
        })
    }
})
//onlinks
function getOnlinks() {
    var row = $('#grid').datagrid('getChecked');
    if (row && row.length == 1) {
        $("#OnLinksForm").form('load', {
            FLinks: '',
            FName: '',
            FTime: '',
            Proid: row[0].PProductId
        });
        $("#productOnLinksWindow").window('open');
    } else {
        msgShow("系统提示", "请选择一个要直播的课程!", "warning");
    }
}
function SubmitLinks() {
    var flag = $("#OnLinksForm").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入必填项!", "warning");
        return;
    }
    $.ajax({
        type: "POST",
        url: "/Product/SaveLinks",
        data: $("#OnLinksForm").serialize(),// 你的formid
        async: false,
        success: function (data) {
            var data = eval("(" + data + ")");
            if (data.stauts == 1) {
                msgShow("系统提示", "保存成功!", "info");
                $("#productOnLinksWindow").window("close");
            } else {
                msgShow("系统提示", "保存失败", "warning");
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                parent.location.reload();
            });
        }
    })
}

var queryData = {};
$(function () {
    var isUpload = false;
    var wxId = $("#WxId").val();
    var storeid = $("#storeid").val();
    if (wxId == 42) { //塘朗街
        $(".imgList li img,.imgList2 li img").on("error", function () {
            $(this).attr("src", "/Content/images/tlnoproduct.jpg");
        });
    } else {
        $(".imgList li img,.imgList2 li img").on("error", function () {
            $(this).attr("src", "/Content/images/noproduct.png");
        });
    }
    //图片操作
    $(".imgList li").hover(function () {
        $(this).addClass("li-hover");
    }, function () {
        $(this).removeClass("li-hover");
    });

    $(".imgList2 li").hover(function () {
        $(this).addClass("li-hover");
    }, function () {
        $(this).removeClass("li-hover");
    });

    $(".imgList").delegate('.toleft', 'click', function () {
        var current = $(this).parents("li").data("index");
        if (current == 1) return;
        else {
            var prev = parseInt(current) - 1;
            var currentValue = $("#image_" + current).val()
            var currentSrc = $("#picUrl_" + current).attr("src");
            var prevValue = $("#image_" + prev).val();
            var prevSrc = $("#picUrl_" + prev).attr("src");
            if (currentValue == "" || prevValue == "") return;

            $("#image_" + current).val(prevValue);
            $("#picUrl_" + current).attr("src", prevSrc == "" ? "" : prevSrc);
            $("#image_" + prev).val(currentValue);
            $("#picUrl_" + prev).attr("src", currentSrc == "" ? "" : currentSrc);
        }
    });

    $(".imgList").delegate('.toright', 'click', function () {
        var current = $(this).parents("li").data("index");
        if (current == 6) return;
        else {
            var next = parseInt(current) + 1;
            var currentValue = $("#image_" + current).val();
            var currentSrc = $("#picUrl_" + current).attr("src");
            var nextValue = $("#image_" + next).val()
            var nextSrc = $("#picUrl_" + next).attr("src");
            if (currentValue == "" || nextValue == "") return;

            $("#image_" + current).val(nextValue);
            $("#picUrl_" + current).attr("src", nextSrc == "" ? "" : nextSrc);
            $("#image_" + next).val(currentValue);
            $("#picUrl_" + next).attr("src", currentSrc == "" ? "" : currentSrc);
        }
    });



    $(".imgList").delegate('.del', 'click', function () {
        var current = $(this).parents("li").data("index");
        var currentValue = $("#image_" + current).val();
        var url = "/product/DeleteImage?fileName=" + currentValue;
        $.ajax({
            cache: false,
            type: "get",
            url: url,
            async: false,
            success: function (data) {
                //删除
                for (var i = current; i <= 6; i++) {
                    if (i == 6) {
                        $("#image_" + i).val("");
                        $("#picUrl_" + i).attr("src", "");
                    } else {
                        var nextValue = $("#image_" + (i + 1)).val()
                        var nextSrc = $("#picUrl_" + (i + 1)).attr("src");
                        $("#image_" + i).val(nextValue);
                        $("#picUrl_" + i).attr("src", nextSrc == "" ? "" : nextSrc);
                    }
                }
            },
            error: function (request) {

            }
        });
    });

    $(".imgList2").delegate('.toleft', 'click', function () {
        var current = $(this).parents("li").data("index");
        if (current == 1) return;
        else {
            var prev = parseInt(current) - 1;
            var currentValue = $("#mimage_" + current).val()
            var currentSrc = $("#mpicUrl_" + current).attr("src");
            var prevValue = $("#mimage_" + prev).val();
            var prevSrc = $("#mpicUrl_" + prev).attr("src");
            if (currentValue == "" || prevValue == "") return;

            $("#mimage_" + current).val(prevValue);
            $("#mpicUrl_" + current).attr("src", prevSrc == "" ? "" : prevSrc);
            $("#mimage_" + prev).val(currentValue);
            $("#mpicUrl_" + prev).attr("src", currentSrc == "" ? "" : currentSrc);
        }
    });

    $(".imgList2").delegate('.toright', 'click', function () {
        var current = $(this).parents("li").data("index");
        if (current == $("#count").val()) return;
        else {
            var next = parseInt(current) + 1;
            var currentValue = $("#mimage_" + current).val();
            var currentSrc = $("#mpicUrl_" + current).attr("src");
            var nextValue = $("#mimage_" + next).val();
            var nextSrc = $("#mpicUrl_" + next).attr("src");
            if (currentValue == "" || nextValue == "") return;

            $("#mimage_" + current).val(nextValue);
            $("#mpicUrl_" + current).attr("src", nextSrc == "" ? "" : nextSrc);
            $("#mimage_" + next).val(currentValue);
            $("#mpicUrl_" + next).attr("src", currentSrc == "" ? "" : currentSrc);
        }
    });

    $(".imgList2").delegate('.del', 'click', function () {

        var current = $(this).parents("li").data("index");
        var currentValue = $("#mimage_" + current).val();

        var url = "/product/DeleteImage?fileName=" + currentValue;
        $.ajax({
            cache: false,
            type: "get",
            url: url,
            async: false,
            success: function (data) {

                //删除
                for (var i = current; i <= $("#count").val(); i++) {
                    if (i == $("#count").val()) {
                        $("#mimage_" + i).val("");
                        $("#mpicUrl_" + i).attr("src", "");
                    } else {
                        var nextValue = $("#mimage_" + (i + 1)).val()
                        var nextSrc = $("#mpicUrl_" + (i + 1)).attr("src");
                        $("#mimage_" + i).val(nextValue);
                        $("#mpicUrl_" + i).attr("src", nextSrc == "" ? "" : nextSrc);
                    }

                    if ($("#mimage_" + i).val() == "") {
                        $("#mtr_" + i / 6 + 1).hide();
                    }
                }
            },
            error: function (request) {
                alert(request);
            }
        });
    });


    queryData["productName"] = "";
    InitGrid();

    $("#search").click(function search() {
        queryData["productName"] = $("#searchName").textbox("getValue");
        queryData["KStoreId1"] = $("#KStoreId1").textbox("getValue");
        queryData["storeId"] = "8557";//$("#storeId").val();
        queryData["productType"] = $("#ProductType").combobox("getValue");
        //queryData["typeId"] = $("#SelType").combobox("getValue");
        queryData["state"] = $("#State").combobox("getValue");
        InitGrid();
    });

    $("#reload").click(function () {
        $("#searchName").textbox("setValue", '');
        $("#storeId").combobox("setValue", 0);
        $("#ProductType").combobox("setValue", 0);
        $("#Type").combobox("setValue", 0);
        $("#SelType").combobox('setValue', 0);
        $("#State").combobox("setValue", 0);
    });

    function InitGrid() {
        $('#grid').datagrid({   //定位到Table标签,Table标签的ID是grid
            url: '/product/GetCHWLProductList',
                //'GetProductList1?kstoreid=' + storeid,   //指向后台的Action来获取当前用户的信息的Json格式的数据
            iconCls: 'icon-view',
            //height: function () { return document.body.clientHeight },//自动高度
            height: document.body.clientHeight * 0.9 - ($("#searchName").closest("div")[0].offsetHeight - 44),
            width: function () { return document.body.clientWidth * 0.9 },//自动宽度
            nowrap: true,
            loadMsg: "正在加载数据中...",
            autoRowHeight: false,
            striped: true,
            collapsible: true,
            pagination: true,
            pageSize: 20,
            pageList: [20, 50, 100, 200],
            rownumbers: true,
            //sortName: 'Seq',    //根据某个字段给easyUI排序
            sortOrder: 'asc',
            remoteSort: false,
            singleSelect: false,
            idField: 'PProductId',
            queryParams: queryData,  //异步查询的参数
            columns: [[
                { title: '', field: 'ck', checkbox: true, sortable: false },
                { title: '产品Id', field: 'PProductId', width: 70, sortable: false },
                { title: '产品名称', field: 'FName', width: 120, sortable: false },
                { title: '门店', field: 'StoreName', width: 100, sortable: false },
                { title: '类型', field: 'TypeName', width: 120, sortable: false },
                { title: '原价', field: 'FOldPrice', width: 60, sortable: false },
                { title: '最新价格', field: 'FPrice', width: 80, sortable: false },
                { title: '重量', field: 'FWeigth', width: 60, sortable: false },
                { title: '运费', field: 'FFreight', width: 60, sortable: false },
                { title: '排序', field: 'FSort', width: 60, sortable: false },
                { title: '拼团人数', field: 'FGroupCount', width: 80, sortable: false },
                { title: '开始时间', field: 'FBeginTime', width: 100, sortable: false, formatter: formatDatebox },
                { title: '结束时间', field: 'FEndTime', width: 100, sortable: false, formatter: formatDatebox },
                {
                    title: '产品状态', field: 'FState', width: 100, sortable: false,
                    formatter: function (value, row, index) {
                        switch (value) {
                            case 1: return "上架"; break;
                            case 2: return "下架"; break;
                            case 3: return "待平台审核"; break;
                            case 4: return "审核不通过"; break;
                        }
                        return value;
                    }
                },
                {
                    title: '产品类型', field: 'FProductType', width: 80, sortable: false, hidden: false,
                    formatter: function (value, row, index) {
                        var name = row.FCommissionPrice > 0 ? ",分佣" : "";
                        switch (value) {
                            case 1: return "普通" + name; break;
                            case 2: return "拼团" + name; break;
                            case 3: return "抢购" + name; break;
                            case 4: return "砍价" + name; break;
                        }
                        return value;
                    }
                },
                { title: '满减优惠价格', field: 'promotionPrice', width: 100, sortable: false, hidden: wxId == 3293 ? false : true },
                { title: '满减数量', field: 'FNum', width: 100, sortable: false, hidden: wxId == 3293 ? false : true },
                { title: '满减开始时间', field: 'promotionTime1', width: 100, formatter: formatDateTime, sortable: false, hidden: wxId == 3293 ? false : true },
                { title: '满减结束时间', field: 'promotionTime2', width: 100, formatter: formatDateTime, sortable: false, hidden: wxId == 3293 ? false : true },
                {
                    title: '同步', field: 'FIsMain', width: 60, sortable: false, hidden: false,
                    formatter: function (value, row, index) {
                        if (value)
                            return "是";
                        else
                            return "否";
                    }
                },
                { title: '管理员权限', field: 'KStoreId', width: 120, sortable: false },
            ]],
            toolbar: toolsBind($("#buttons").val()),
            onDblClickRow: function (rowIndex, rowData) {
                $('#grid').datagrid('uncheckAll');
                $('#grid').datagrid('checkRow', rowIndex);
                EditBind(1);
            },
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                    $(".datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                    //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
                }
                //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
                else {
                    $(".divNone").remove();
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
                }

                //if ($("#isGroup").val() == false) {
                //    $("div.datagrid-toolbar [id ='btnGroup']").eq(0).hide();
                //    $("div.datagrid-toolbar [id ='btnOK']").eq(0).hide();
                //}
                //if ($("#isBargain").val() == false) {
                //    $("div.datagrid-toolbar [id ='btnBargain']").eq(0).hide();
                //}
                //if ($("#isCommission").val() == false) {
                //    $("div.datagrid-toolbar [id ='btnCommission']").eq(0).hide();
                //}
                //if ($("#isIntegral").val() == false) {
                //    $("div.datagrid-toolbar [id ='btnIntegral']").eq(0).hide();
                //}
                if ($("#isSince").val() == false) {
                    $("div.datagrid-toolbar [id ='btnSince']").eq(0).hide();
                }
                if ($("#isMember").val() == false) {
                    $("div.datagrid-toolbar [id ='btnMemberPrice']").eq(0).hide();
                }
                if ($("#isImportProduct").val() == false) {
                    $("div.datagrid-toolbar [id ='btnExcel']").eq(0).hide();
                }
            }
        })
    };

    $("#btnOk").click(function () {
        if (isUpload) {
            msgShow("系统提示", "图片还没上传完成!", "warning");
            return;
        }
        var flag = $("#ff").form('validate');
        if (!flag) {
            msgShow("系统提示", "请输入所有必填项!", "warning");
            return;
        }
        else {
            if ($("#image_1").val() == "") {
                msgShow("系统提示", "请上传图片!", "warning");
                return;
            }
            else {
                var specstock = $("#ff input[name='SpecStock']");
                if (specstock.length > 0) {
                    $.each(specstock, function (index, item) {
                        if ($(item).val() != "") {
                            if (!/^\d+$/.test($(item).val())) {
                                msgShow("系统提示", "库存框只能输入数字", "warning");
                                return;
                            }
                        }
                    })
                }
                var pars = $('#ff').serialize();

                var posturl = "/Product/SaveCHWLProduct";
                $.ajax({
                    cache: true,
                    type: "POST",
                    url: posturl,
                    data: pars,// 你的formid
                    async: false,
                    error: function (request) {
                    },
                    beforeSend: function () {
                        ajaxLoading();
                    },
                    success: function (data) {
                        ajaxLoadEnd();
                        var item = eval('(' + data + ')');
                        if (item.isSuccess) {
                            msgShow("系统提示", "保存成功!", "info");
                            $("#product").window("close");
                            $("#grid").datagrid("reload");

                            $("#grid").datagrid("clearChecked");
                            $("#grid").datagrid("clearSelections");
                        } else {
                            msgShow("系统提示", item.msg, "warning");
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                            parent.location.reload();
                        });

                    }
                });
            }
        }
    });

    $("#btnCancle").click(function () {
        $("#product").window("close");
    });

    //$('#Store').combobox({
    //    onSelect: function (newValue, oldValue) {
    //        var id = newValue.value;

    //        if (id > 0) {
    //            $("#Type").combobox({
    //                url: '/Type/GetProductTypeByStoreId?storeId=' + id,
    //                valueField: 'PTypeId',
    //                textField: 'FName',
    //                //loadFilter: function (data) {
    //                //    var l1 = [];
    //                //    var l2 = [];
    //                //    var newData = [];
    //                //    data.forEach(function (i) {
    //                //        if (i.KParentId == 0) {
    //                //            l1.push(i);
    //                //        } else {
    //                //            l2.push(i);
    //                //        }
    //                //    });
    //                //    l1.forEach(function (i) {
    //                //        newData.push(i);
    //                //        l2.forEach(function (m) {
    //                //            if (i.PTypeId == m.KParentId) {
    //                //                m.FName = "|--" + m.FName;
    //                //                newData.push(m);
    //                //            }
    //                //        });
    //                //    });
    //                //    newData.unshift({ PTypeId: 0, FName: "全部" });
    //                //    return newData;
    //                //},
    //            });
    //            //$("#HomeTemplateId").combobox({
    //            //    url: '/HomeTemplate/GetHomeTemplateByStoreId?storeId=' + id,
    //            //    valueField: 'PHomeTemplateId',
    //            //    textField: 'FName'
    //            //});
    //            $("#PrintSetId").combobox({
    //                url: '/Product/GetpPrintSetByStoreId?storeId=' + id,
    //                valueField: 'PPrintSetId',
    //                textField: 'FName'
    //            });
    //        }
    //    }
    //});

    $("#btnImport").click(function () {
        $("#importProductWindow").window('open');
    });
    $("#btnImportProImg").click(function () {
        $("#importProImgWindow").window('open');
    });
    $("#btnImportProductOk").click(function () {
        var file = $("#importProductFile")[0];
        if (!file) {
            msgShow("系统提示", "请选择要上传的 Excel 文件!", "warning");
            return;
        }
        var formData = new FormData();
        formData.append("StoreId", $("#impStore").combobox('getValue'));
        formData.append("file", file.files[0]);
        $.ajax({
            cache: false,
            type: "post",
            processData: false,
            contentType: false,
            data: formData,
            url: "/Product/ImportExcel",
            //url: "/Product/ImportExcelForXHLG",
            beforeSend: ajaxLoading,
            success: function (data) {
                ajaxLoadEnd();
                if (data.Status == 1) {
                    msgShow("系统提示", "上传成功!", "info");
                    $("#importProductForm")[0].reset();
                    $("#importProductWindow").window('close');
                } else {
                    msgShow("系统提示", data.Msg, "warning");
                }
            },
            error: function (request) {
                msgShow("系统提示", "服务器端异常!", "warning");
            }
        });
    });
    $("#btnImportProductCancel").click(function () {
        $("#importProductWindow").window('close');
        $("#importProductForm")[0].reset();
    });
    $("#btnImportProImgOk").click(function () {
        var file = $("#importProImgFile")[0];
        if (!file) {
            msgShow("系统提示", "请选择要上传的压缩文件!", "warning");
            return;
        }
        var formData = new FormData();
        formData.append("StoreId", $("#impStore2").combobox('getValue'));
        formData.append("file", file.files[0]);
        $.ajax({
            cache: false,
            type: "post",
            processData: false,
            contentType: false,
            data: formData,
            url: "/Product/ImportImage",
            beforeSend: ajaxLoading,
            success: function (data) {
                ajaxLoadEnd();
                if (data.Status == 1) {
                    msgShow("系统提示", data.Msg, "info");
                    $("#importProImgForm")[0].reset();
                    $("#importProImgWindow").window('close');
                } else {
                    msgShow("系统提示", data.Msg, "warning");
                }
            },
            error: function (request) {
                msgShow("系统提示", "服务器端异常!", "warning");
            }
        });
    });
    $("#btnImportProImgCancel").click(function () {
        $("#importProImgWindow").window('close');
        $("#importProImgForm")[0].reset();
    });
    $("#btnCancel").click(function () { $("#changesTypeWindow").window('close'); });
    $("#btnSubmit").click(function () {
        var typeid = $("#PType").combobox("getValue");
        if (typeid == 0) {
            msgShow("系统提示", "请选择类型!", "warning");
            return;
        }
        $.ajax({
            type: "post",
            url: "/Product/SaveType",
            async: false,
            datatype: "json",
            data: { ids: $("#ids").val(), typeid: typeid },
            success: function (data) {
                if (data) {
                    $('#changesTypeWindow').window('close');
                    $("#grid").datagrid("reload");
                } else {
                    msgShow("系统提示", "修改类型失败!", "warning");
                }
            },
            error: function (xmlhttprequest, textstatus, errorthrown) {
                $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                    parent.location.reload();
                });

            }
        })
    })

    $("#btnTimeCancel").click(function () {
        $("#ChangesSaleTimeWindow input[type='radio']").removeClass("radio");
        $("#ChangesSaleTimeWindow input[type='radio']").removeAttr("checked");
        $(".definedDateTime").hide();
        $(".definedTime").hide();
        $(".hour").hide();
        $(".mintue").hide();
        $("input[type='text']").removeClass("text-box-focus");
        $("#ChangesSaleTimeWindow").window('close');
    })
    $("#btnTimeSubmit").click(function () {
        var type = $(".radio").val();
        var start = null;
        var end = null;
        if (type == 1) {
            var startHour = $("#startHour").val();
            var startMinute = $("#startMinute").val();
            var endHour = $("#endHour").val();
            var endMinute = $("#endMinute").val();
            start = startHour + ":" + startMinute;
            end = endHour + ":" + endMinute;
        } else if (type == 2) {
            start = $("#datetime").datetimebox("getValue");
            end = $("#endtime").datetimebox("getValue");
            if (start == "" || end == "") {
                msgShow("系统提示", "时间不能为空", "warning");
                return;
            }
        }
        $.ajax({
            type: "post",
            url: "/Product/SaveSaleTime",
            async: false,
            datatype: "json",
            data: { ids: $("#Pids").val(), type: type, start: start, end: end },
            success: function (data) {
                if (data) {
                    $('#ChangesSaleTimeWindow').window('close');
                    $("#grid").datagrid("reload");
                } else {
                    msgShow("系统提示", "修改类型失败!", "warning");
                }
            },
            error: function (xmlhttprequest, textstatus, errorthrown) {
                $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                    parent.location.reload();
                });

            }
        })
        $("#ChangesSaleTimeWindow input[type='radio']").removeClass("radio");
        $("#ChangesSaleTimeWindow input[type='radio']").removeAttr("checked");
        $(".definedDateTime").hide();
        $(".definedTime").hide();
        $(".hour").hide();
        $(".mintue").hide();
        $("input[type='text']").removeClass("text-box-focus");
    })

    //切换
    $("#VideoForm input[name='btnradio']").eq(1).click(function () {
        $(".defined_links").html("").append('<input class="easyui-textbox width-70" id="hiddensrc" name="hiddensrc" /><div style="color:red;">*链接必须是https协议,只支持mp4格式</div>');
        $(".upload_video").hide();
        $.parser.parse($(".defined_links"));
        $("#VideoForm").form('load', { hiddensrc: $("#player1").attr("src") });
    });
    $("#VideoForm input[name='btnradio']").eq(0).click(function () {
        $(".defined_links").html("").append('<input type="hidden" id="hiddensrc" name="hiddensrc" />');
        if ($("#player1").attr("src").indexOf("https://1253305012.vod2.myqcloud.com/") < 0) {
            $("#curriCulum").removeAttr("style");
            $("#curriCulum").parent().find("span").remove(".content");
        } else {
            $("#hiddensrc").val($("#player1").attr("src"));
        }
        $(".upload_video").show();
    });
});

function ajaxLoading() {
    $("<div class=\"datagrid-mask\"></div>").css({ display: "block", width: "100%", height: $(window).height(), "z-index": 9999 }).appendTo("body");
    $("<div class=\"datagrid-mask-msg\"></div>").html("正在处理中,请稍候...").appendTo("body").css({ display: "block", left: ($(document.body).outerWidth(true) - 190) / 2, top: ($(window).height() - 45) / 2, "z-index": 9999, height: 22 });
}
function ajaxLoadEnd() {
    $(".datagrid-mask").remove();
    $(".datagrid-mask-msg").remove();
}

function AddSpec() {
    var SpecTool = [{
        id: 'btnAdd',
        text: '添加',
        iconCls: 'icon-add',
        handler: function () {
            SendSpecWindow("add");
        }
    }, '-', {
        id: 'btnEdit',
        text: '修改',
        iconCls: 'icon-edit',
        handler: function () {
            SendSpecWindow("edit");
        }
    }, '-', {
        id: 'btnDelete',
        text: '删除',
        iconCls: 'icon-remove',
        handler: function () {
            var row = $('#gridSpec').datagrid('getSelected');

            if (row) {
                if (confirm("确定删除该产品规格记录,删除后将无法修复!")) {
                    var copyId = $("#copyId").val();
                    if (copyId) { //复制商品的删除规格
                        alert("删除");
                    } else {
                        var posturl = "/Product/DeleteProductSpec";
                        var pars = {};
                        pars["id"] = row.PProductSpecId;

                        $.ajax({
                            cache: true,
                            type: "POST",
                            url: posturl,
                            data: pars,// 你的formid
                            async: false,
                            error: function (request) {
                            },
                            success: function (data) {
                                msgShow("系统提示", "删除成功!", "info");
                                $("#gridSpec").datagrid("reload");

                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                                    parent.location.reload();
                                });

                            }
                        });
                    }
                }
            }
        }
    }, '-', {
        id: 'btnReload',
        text: '刷新',
        iconCls: 'icon-reload',
        handler: function () {
            //实现刷新栏目中的数据
            $("#gridSpec").datagrid("reload");
        }
    }];

    var row = $('#grid').datagrid('getSelected');
    if (row) {

        var query = {};
        query["productId"] = row.PProductId;
        $('#gridSpec').datagrid({   //定位到Table标签,Table标签的ID是grid
            url: '/product/GetProductSpecList',   //指向后台的Action来获取当前用户的信息的Json格式的数据
            title: '',
            iconCls: 'icon-view',
            height: 650,
            width: function () { return document.body.clientWidth },//自动宽度
            nowrap: true,
            loadMsg: "正在加载数据中...",
            autoRowHeight: false,
            striped: false,
            collapsible: false,
            pagination: true,
            pageSize: 20,
            pageList: [20, 50, 100, 200],
            rownumbers: true,
            sortOrder: 'asc',
            remoteSort: false,
            singleSelect: true,
            idField: 'PProductSpecId',
            queryParams: query,  //异步查询的参数
            columns: [[
                { title: '规格名称', field: 'FSpecName', width: 120, sortable: false },
                { title: '最新价格', field: 'FPrice', width: 120, sortable: false },
                { title: '原价', field: 'FOldPrice', width: 120, sortable: false },
                { title: '库存', field: 'FStock', width: 120, sortable: false },
            ]],
            toolbar: SpecTool,
            onDblClickRow: function (rowIndex, rowData) {
                $('#gridSpec').datagrid('uncheckAll');
                $('#gridSpec').datagrid('checkRow', rowIndex);
                SendSpecWindow("edit");
            },
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                    $(".datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                    //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
                }
                //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
                else {
                    $(".divNone").remove();
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
                }
            }
        })
        $('#productSpec').panel({ iconCls: "icon-save" });
        $('#productSpec').window('open');
    }


}

//添加自定点
function AddSince() {
    var SpecTool = [{
        id: 'btnAdd',
        text: '添加',
        iconCls: 'icon-add',
        handler: function () {
            SendSinceWindow("add");
        }
    }, '-', {
        id: 'btnEdit',
        text: '修改',
        iconCls: 'icon-edit',
        handler: function () {
            SendSinceWindow("edit");
        }
    }, '-', {
        id: 'btnDelete',
        text: '删除',
        iconCls: 'icon-remove',
        handler: function () {
            var row = $('#gridSince').datagrid('getSelected');

            if (row) {
                if (confirm("确定删除该产品规格记录,删除后将无法修复!")) {

                    var posturl = "/Product/DeleteProductSince";
                    var pars = {};
                    pars["id"] = row.PProductAreaId;

                    $.ajax({
                        cache: true,
                        type: "POST",
                        url: posturl,
                        data: pars,// 你的formid
                        async: false,
                        error: function (request) {
                        },
                        success: function (data) {
                            msgShow("系统提示", "删除成功!", "info");
                            $("#gridSince").datagrid("reload");

                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                                parent.location.reload();
                            });

                        }
                    });
                }
            }
        }
    }, '-', {
        id: 'btnReload',
        text: '刷新',
        iconCls: 'icon-reload',
        handler: function () {
            //实现刷新栏目中的数据
            $("#gridSince").datagrid("reload");
        }
    }];

    var row = $('#grid').datagrid('getSelected');
    if (row) {

        var query = {};
        query["productId"] = row.PProductId;
        $('#gridSince').datagrid({   //定位到Table标签,Table标签的ID是grid
            url: '/product/GetProductSinceList',   //指向后台的Action来获取当前用户的信息的Json格式的数据
            title: '',
            iconCls: 'icon-view',
            height: 650,
            width: function () { return document.body.clientWidth },//自动宽度
            nowrap: true,
            loadMsg: "正在加载数据中...",
            autoRowHeight: false,
            striped: false,
            collapsible: false,
            pagination: true,
            pageSize: 20,
            pageList: [20, 50, 100, 200],
            rownumbers: true,
            sortOrder: 'asc',
            remoteSort: false,
            singleSelect: true,
            idField: 'PProductAreaId',
            queryParams: query,  //异步查询的参数
            columns: [[
                { title: '省份', field: 'FAreaName', width: 120, sortable: false },
                { title: '库存', field: 'FAmount', width: 120, sortable: false },
                { title: '地址', field: 'FAddress', width: 120, sortable: false },
                { title: '电话', field: 'FPhone', width: 120, sortable: false },
            ]],
            toolbar: SpecTool,
            onDblClickRow: function (rowIndex, rowData) {
                $('#gridSince').datagrid('uncheckAll');
                $('#gridSince').datagrid('checkRow', rowIndex);
                SendSinceWindow("edit");
            },
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                    $(".datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                    //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
                }
                //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
                else {
                    $(".divNone").remove();
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
                }
            }
        })
        $('#productSince').panel({ iconCls: "icon-save" });
        $('#productSince').window('open');
    }


}

function SendSinceWindow(operate) {
    var row = $('#grid').datagrid('getSelected');
    $("#prodSinceId").val(row.PProductId);

    if (operate == "add") {
        $("#SinceForm").form('load', {
            //areaName: "",
            amount: "",
            address: "",
            phone: "",
        });
        $("#sinceId").val(0);
        $("#oldAreaName").val("");
        $("#areaName").combobox("setValue", "");
        $('#productSinceWindow').panel({ title: "新增" });
        $('#productSinceWindow').panel({ iconCls: "icon-add" });
        $('#productSinceWindow').window('open');
    } else if (operate == "edit") {
        var row = $('#gridSince').datagrid('getSelected');
        if (row) {

            $("#SinceForm").form('load', {
                //areaName: row.PAreaId,
                amount: row.FAmount,
                address: row.FAddress,
                phone: row.FPhone,
            });
            //$("#areaName").combobox("setValue", row.PAreaId);
            $("#areaName").combobox("setValue", row.FAreaName);
            $("#sinceId").val(row.PProductAreaId);
            $("#oldAreaName").val(row.FAreaName);
            $('#productSinceWindow').panel({ title: "修改" });
            $('#productSinceWindow').panel({ iconCls: "icon-edit" });
            $('#productSinceWindow').window('open');
        } else {
            msgShow("系统提示", "请选择要修改的产品!", "warning");
        }
    }
}

//自定点
$("#btnSinceOk").click(function () {

    var flag = $("#SinceForm").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入所有必填项!", "warning");
        return;
    }
    else {

        //var pars = $('#SinceForm').serialize();
        var pars = {};
        pars["areaName"] = $('#areaName').combobox('getText');
        pars["amount"] = $("#amount").textbox("getValue");
        pars["address"] = $("#address").textbox("getValue");
        pars["phone"] = $("#phone").textbox("getValue");
        pars["sinceId"] = $("#sinceId").val();
        pars["oldAreaName"] = $("#oldAreaName").val();
        pars["prodSinceId"] = $("#prodSinceId").val();
        var posturl = "/Product/SaveProductSince";
        $.ajax({
            cache: true,
            type: "POST",
            url: posturl,
            data: pars,// 你的formid
            async: false,
            error: function (request) {
            },
            success: function (data) {
                var item = eval('(' + data + ')');
                if (item.isSuccess) {
                    msgShow("系统提示", "保存成功!", "info");
                    $("#productSinceWindow").window("close");
                    $("#gridSince").datagrid("reload");
                } else {
                    msgShow("系统提示", item.msg, "warning");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                    parent.location.reload();
                });

            }
        });
    }
});

$("#btnSinceCancle").click(function () {
    $("#productSinceWindow").window("close");
});

//添加规格
function SendSpecWindow(operate) {
    var row = $('#grid').datagrid('getSelected');
    $("#prodId").val(row.PProductId);

    if (operate == "add") {
        $("#specForm").form('load', {
            SpecName: "",
            SpecStock: "",
            SpecOldPrice: "",
            SpecPrice: "",
            barCode: ""
        });

        $("#specId").val(0);

        $('#productSpecWindow').panel({ title: "新增" });
        $('#productSpecWindow').panel({ iconCls: "icon-add" });
        $('#productSpecWindow').window('open');
    } else if (operate == "edit") {
        var row = $('#gridSpec').datagrid('getSelected');
        if (row) {

            $("#specForm").form('load', {
                SpecName: row.FSpecName,
                SpecStock: row.FStock,
                SpecOldPrice: row.FOldPrice,
                SpecPrice: row.FPrice,
                barCode: row.FBarCode
            });
            $("#specId").val(row.PProductSpecId);

            $('#productSpecWindow').panel({ title: "修改" });
            $('#productSpecWindow').panel({ iconCls: "icon-edit" });
            $('#productSpecWindow').window('open');
        } else {
            msgShow("系统提示", "请选择要修改的产品!", "warning");
        }
    }
}

$("#btnSpecOk").click(function () {

    var flag = $("#specForm").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入所有必填项!", "warning");
        return;
    }
    else {

        var pars = $('#specForm').serialize();
        var posturl = "/Product/SaveProductSpec";
        $.ajax({
            cache: true,
            type: "POST",
            url: posturl,
            data: pars,// 你的formid
            async: false,
            error: function (request) {
            },
            success: function (data) {
                var item = eval('(' + data + ')');
                if (item.isSuccess) {
                    msgShow("系统提示", "保存成功!", "info");
                    $("#productSpecWindow").window("close");
                    $("#gridSpec").datagrid("reload");
                } else {
                    msgShow("系统提示", item.msg, "warning");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                    parent.location.reload();
                });

            }
        });
    }
});

$("#btnSpecCancle").click(function () {
    $("#productSpecWindow").window("close");
});



var editRow = undefined;
function AddGroup() {
    var SpecTool = [{
        id: 'btnReload',
        text: '刷新',
        iconCls: 'icon-reload',
        handler: function () {
            //实现刷新栏目中的数据
            $("#gridGroupSpec").datagrid("reload");
        }
    }];
    editRow = undefined;
    var row = $('#grid').datagrid('getSelected');

    if (row) {

        $("#GroupForm").form('load', {
            GroupCount: row.FGroupCount,
            BeginTime: row.FBeginTime,
            EndTime: row.FEndTime,
        });
        $("#groupProdId").val(row.PProductId);
        var query = {};
        query["productId"] = row.PProductId;
        $('#gridGroupSpec').datagrid({   //定位到Table标签,Table标签的ID是grid
            url: '/product/GetProductSpecList',   //指向后台的Action来获取当前用户的信息的Json格式的数据
            title: '',
            iconCls: 'icon-view',
            height: function () { return document.body.clientHeight },//自动高度
            width: function () { return document.body.clientWidth },//自动宽度
            loadMsg: "正在加载数据中...",
            pagination: true,
            pageSize: 20,
            pageList: [20, 50, 100, 200],
            rownumbers: true,
            //sortName: 'Seq',    //根据某个字段给easyUI排序
            sortOrder: 'asc',
            remoteSort: false,
            singleSelect: true,
            idField: 'PProductSpecId',
            queryParams: query,  //异步查询的参数
            columns: [[
                { title: '规格名称', field: 'FSpecName', width: 80, sortable: false },
                { title: '最新价格', field: 'FPrice', width: 80, sortable: false },
                { title: '原价', field: 'FOldPrice', width: 60, sortable: false },
                { title: '库存', field: 'FStock', width: 60, sortable: false },
                { title: '拼团价格', field: 'FGroupPrice', width: 80, sortable: false, editor: 'textbox' },
                { title: '团长价格', field: 'FGroupTopPrice', width: 80, sortable: false, editor: 'textbox' },
            ]],
            toolbar: SpecTool,
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                    $(".datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                    //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
                }
                //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
                else {
                    $(".divNone").remove();
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
                }
            },
            onClickRow: function (rowIndex, rowData) {
                if (editRow != undefined) {
                    $('#gridGroupSpec').datagrid("endEdit", editRow);
                }
                if (editRow == undefined) {
                    $('#gridGroupSpec').datagrid("beginEdit", rowIndex);
                    editRow = rowIndex;
                }

            },

            onAfterEdit: function (index, row) {
                console.log(index);
                editRow = undefined;
            },

        })
        $('#productGroupSpec').panel({ iconCls: "icon-save" });
        $('#productGroupSpec').window('open');
    }
}

$("#btnGroupOk").click(function () {
    if (editRow != undefined) {
        $('#gridGroupSpec').datagrid("endEdit", editRow);
    }
    var flag = $("#GroupForm").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入所有必填项!", "warning");
        return;
    }
    else {

        var rows = $('#gridGroupSpec').datagrid('getRows');
        var groupPrice = "";
        var check = true;
        $(rows).each(function (index, row) {
            if (row.FGroupPrice == null) {
                check = false;
            }
            groupPrice += row.PProductSpecId + "-" + row.FGroupPrice + "-" + row.FGroupTopPrice + ",";
        })
        if (check) {
            groupPrice = groupPrice.length > 0 ? groupPrice.substring(0, groupPrice.length - 1) : "";

            var pars = $('#GroupForm').serialize();
            var posturl = "/Product/SaveProductSpecGroup?groupPrice=" + groupPrice;
            $.ajax({
                cache: true,
                type: "POST",
                url: posturl,
                data: pars,// 你的formid
                async: false,
                error: function (request) {
                },
                success: function (data) {
                    var item = eval('(' + data + ')');
                    if (item.isSuccess) {
                        msgShow("系统提示", "保存成功!", "info");
                        $("#productGroupSpec").window("close");
                        $("#grid").datagrid("reload");
                    } else {
                        msgShow("系统提示", item.msg, "warning");
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                        parent.location.reload();
                    });

                }
            });
        } else {
            msgShow("系统提示", "请输入所有规格的拼团价和团长价!", "warning");
        }
    }
});

$("#btnGroupCancle").click(function () {
    $("#productGroupSpec").window("close");
});


function AddBargain() {
    editRow = undefined;
    var SpecTool = [{
        id: 'btnReload',
        text: '刷新',
        iconCls: 'icon-reload',
        handler: function () {
            //实现刷新栏目中的数据
            $("#gridBargainSpec").datagrid("reload");
        }
    }];

    var row = $('#grid').datagrid('getSelected');

    if (row) {

        $("#BargainForm").form('load', {
            MinPrice: row.FMinPrice,
            MaxPrice: row.FMaxPrice,
            BeginTime: row.FBeginTime,
            EndTime: row.FEndTime,
            BargainCount: row.FBargainCount
        });
        $("#bargainProdId").val(row.PProductId);
        var query = {};
        query["productId"] = row.PProductId;
        $('#gridBargainSpec').datagrid({   //定位到Table标签,Table标签的ID是grid
            url: '/product/GetProductSpecList',   //指向后台的Action来获取当前用户的信息的Json格式的数据
            title: '',
            iconCls: 'icon-view',
            height: function () { return document.body.clientHeight },//自动高度
            width: function () { return document.body.clientWidth },//自动宽度
            loadMsg: "正在加载数据中...",
            pagination: true,
            pageSize: 20,
            pageList: [20, 50, 100, 200],
            rownumbers: true,
            //sortName: 'Seq',    //根据某个字段给easyUI排序
            sortOrder: 'asc',
            remoteSort: false,
            singleSelect: true,
            idField: 'PProductSpecId',
            queryParams: query,  //异步查询的参数
            columns: [[
                { title: '规格名称', field: 'FSpecName', width: 80, sortable: false },
                { title: '最新价格', field: 'FPrice', width: 80, sortable: false },
                { title: '原价', field: 'FOldPrice', width: 60, sortable: false },
                { title: '库存', field: 'FStock', width: 60, sortable: false },
                { title: '最低价格', field: 'FBargainPrice', width: 80, sortable: false, editor: 'textbox' },
            ]],
            toolbar: SpecTool,
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                    $(".datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                    //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
                }
                //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
                else {
                    $(".divNone").remove();
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
                }
            },
            onClickRow: function (rowIndex, rowData) {
                if (editRow != undefined) {
                    $('#gridBargainSpec').datagrid("endEdit", editRow);
                }
                if (editRow == undefined) {
                    $('#gridBargainSpec').datagrid("beginEdit", rowIndex);
                    editRow = rowIndex;
                }
            },
            onAfterEdit: function (index, row) {
                console.log(index);
                editRow = undefined;
            },

        })
        $('#productBargainSpec').panel({ iconCls: "icon-save" });
        $('#productBargainSpec').window('open');
    }
}


$("#btnBargainOk").click(function () {
    if (editRow != undefined) {
        $('#gridBargainSpec').datagrid("endEdit", editRow);
    }
    var flag = $("#BargainForm").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入所有必填项!", "warning");
        return;
    }
    else {

        var rows = $('#gridBargainSpec').datagrid('getRows');
        var groupPrice = "";
        var check = true;
        $(rows).each(function (index, row) {
            if (row.FBargainPrice == null) {
                check = false;
            }
            groupPrice += row.PProductSpecId + "-" + row.FBargainPrice + ",";
        })
        if (check) {
            groupPrice = groupPrice.length > 0 ? groupPrice.substring(0, groupPrice.length - 1) : "";

            var pars = $('#BargainForm').serialize();
            var posturl = "/Product/SaveProductSpecBargain?groupPrice=" + groupPrice;
            $.ajax({
                cache: true,
                type: "POST",
                url: posturl,
                data: pars,// 你的formid
                async: false,
                error: function (request) {
                },
                success: function (data) {
                    var item = eval('(' + data + ')');
                    if (item.isSuccess) {
                        msgShow("系统提示", "保存成功!", "info");
                        $("#productBargainSpec").window("close");
                        $("#grid").datagrid("reload");
                    } else {
                        msgShow("系统提示", item.msg, "warning");
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                        parent.location.reload();
                    });

                }
            });
        } else {
            msgShow("系统提示", "请输入所有规格的拼团价!", "warning");
        }
    }
});

$("#btnBargainCancle").click(function () {

    $("#productBargainSpec").window("close");
});

//积分
function AddIntegral() {
    var SpecTool = [{
        id: 'btnReload',
        text: '刷新',
        iconCls: 'icon-reload',
        handler: function () {
            //实现刷新栏目中的数据
            $("#gridGroupIntegral").datagrid("reload");
        }
    }];
    editRow = undefined;
    var row = $('#grid').datagrid('getSelected');

    if (row) {

        $("#IntegralProdId").val(row.PProductId);
        var query = {};
        query["productId"] = row.PProductId;
        $('#gridGroupIntegral').datagrid({   //定位到Table标签,Table标签的ID是grid
            url: '/product/GetproductIntegralList',   //指向后台的Action来获取当前用户的信息的Json格式的数据
            title: '',
            iconCls: 'icon-view',
            height: GetHeight() - 48,//自动高度
            width: function () { return document.body.clientWidth },//自动宽度
            loadMsg: "正在加载数据中...",
            pagination: true,
            pageSize: 20,
            pageList: [20, 50, 100, 200],
            rownumbers: true,
            //sortName: 'Seq',    //根据某个字段给easyUI排序
            sortOrder: 'asc',
            remoteSort: false,
            singleSelect: true,
            idField: 'PProductSpecId',
            queryParams: query,  //异步查询的参数
            columns: [[
                { title: '规格名称1', field: 'FSpecName', width: 80, sortable: false },
                { title: '规格名称2', field: 'FSpecName2', width: 80, sortable: false },
                { title: '规格名称3', field: 'FSpecName3', width: 80, sortable: false },
                { title: '最新价格', field: 'FPrice', width: 80, sortable: false },
                { title: '原价', field: 'FOldPrice', width: 60, sortable: false },
                { title: '库存', field: 'FStock', width: 60, sortable: false },
                { title: '积分', field: 'FIntegral', width: 80, sortable: false, editor: 'textbox' },
                { title: '赠送积分', field: 'FGiveIntegral', width: 80, sortable: false, editor: 'textbox' },
            ]],
            toolbar: SpecTool,
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                    $(".datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                    //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
                }
                //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
                else {
                    $(".divNone").remove();
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
                }
            },
            onClickRow: function (rowIndex, rowData) {
                if (editRow != undefined) {
                    $('#gridGroupIntegral').datagrid("endEdit", editRow);
                }
                if (editRow == undefined) {
                    $('#gridGroupIntegral').datagrid("beginEdit", rowIndex);
                    editRow = rowIndex;
                }

            },

            onAfterEdit: function (index, row) {
                console.log(index);
                editRow = undefined;
            },

        })
        $('#productIntegral').panel({ iconCls: "icon-save" });
        $('#productIntegral').window('open');
    }
}

$("#btnIntegralOk").click(function () {
    if (editRow != undefined) {
        $('#gridGroupIntegral').datagrid("endEdit", editRow);
    }
    var flag = $("#IntegralForm").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入所有必填项!", "warning");
        return;
    }
    else {

        var rows = $('#gridGroupIntegral').datagrid('getRows');
        var groupPrice = "";
        var check = true;
        $(rows).each(function (index, row) {

            groupPrice += row.PProductSpecId + "-" + row.FIntegral + "-" + row.FGiveIntegral + ",";
        })
        if (check) {
            groupPrice = groupPrice.length > 0 ? groupPrice.substring(0, groupPrice.length - 1) : "";

            var pars = {};
            pars["IntegralProdId"] = $("#IntegralProdId").val();
            var posturl = "/Product/SaveProductIntegral?groupPrice=" + groupPrice;
            $.ajax({
                cache: true,
                type: "POST",
                url: posturl,
                data: pars,// 你的formid
                async: false,
                error: function (request) {
                },
                success: function (data) {
                    var item = eval('(' + data + ')');
                    if (item.isSuccess) {
                        msgShow("系统提示", "保存成功!", "info");
                        $("#productIntegral").window("close");
                        $("#grid").datagrid("reload");
                    } else {
                        msgShow("系统提示", item.msg, "warning");
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                        parent.location.reload();
                    });

                }
            });
        } else {
            msgShow("系统提示", "请输入所有规格的拼团价和团长价!", "warning");
        }
    }
});

$("#btnIntegralCancle").click(function () {
    $("#productIntegral").window("close");
});
//分拥
function AddCommission() {
    var SpecTool = [{
        id: 'btnReload',
        text: '刷新',
        iconCls: 'icon-reload',
        handler: function () {
            //实现刷新栏目中的数据
            $("#gridGroupCommission").datagrid("reload");
        }
    }];
    editRow = undefined;
    var row = $('#grid').datagrid('getSelected');

    if (row) {

        $("#commissionProdId").val(row.PProductId);
        var query = {};
        query["productId"] = row.PProductId;
        $('#gridGroupCommission').datagrid({   //定位到Table标签,Table标签的ID是grid
            url: '/product/GetproductCommissionList',   //指向后台的Action来获取当前用户的信息的Json格式的数据
            title: '',
            iconCls: 'icon-view',
            height: function () { return document.body.clientHeight },//自动高度
            width: function () { return document.body.clientWidth },//自动宽度
            loadMsg: "正在加载数据中...",
            pagination: true,
            pageSize: 20,
            pageList: [20, 50, 100, 200],
            rownumbers: true,
            //sortName: 'Seq',    //根据某个字段给easyUI排序
            sortOrder: 'asc',
            remoteSort: false,
            singleSelect: true,
            idField: 'PProductSpecId',
            queryParams: query,  //异步查询的参数
            columns: [[
                { title: '规格名称', field: 'FSpecName', width: 80, sortable: false },
                { title: '最新价格', field: 'FPrice', width: 80, sortable: false },
                { title: '原价', field: 'FOldPrice', width: 60, sortable: false },
                { title: '会员价', field: 'FVipPrice', width: 60, sortable: false },
                { title: '库存', field: 'FStock', width: 60, sortable: false },
                { title: '一级分拥', field: 'FCommissionPrice', width: 80, sortable: false, editor: 'textbox' },
                { title: '二级分拥', field: 'FTwoCommissionPrice', width: 80, sortable: false, editor: 'textbox' },
                { title: '一级Vip分拥', field: 'FVipCommissionPrice', width: 80, sortable: false, editor: 'textbox' },
                { title: '二级Vip分拥', field: 'FTwoVipCommissionPrice', width: 80, sortable: false, editor: 'textbox' },
            ]],
            toolbar: SpecTool,
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                    $(".datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                    //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
                }
                //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
                else {
                    $(".divNone").remove();
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
                }
            },
            onClickRow: function (rowIndex, rowData) {
                if (editRow != undefined) {
                    $('#gridGroupCommission').datagrid("endEdit", editRow);
                }
                if (editRow == undefined) {
                    $('#gridGroupCommission').datagrid("beginEdit", rowIndex);
                    editRow = rowIndex;
                }

            },

            onAfterEdit: function (index, row) {
                console.log(index);
                editRow = undefined;
            },

        })

        $('#gridGroupCommissionBSB').datagrid({   //定位到Table标签,Table标签的ID是grid
            url: '/product/GetproductCommissionList',   //指向后台的Action来获取当前用户的信息的Json格式的数据
            title: '',
            iconCls: 'icon-view',
            height: function () { return document.body.clientHeight },//自动高度
            width: function () { return document.body.clientWidth },//自动宽度
            loadMsg: "正在加载数据中...",
            pagination: true,
            pageSize: 20,
            pageList: [20, 50, 100, 200],
            rownumbers: true,
            //sortName: 'Seq',    //根据某个字段给easyUI排序
            sortOrder: 'asc',
            remoteSort: false,
            singleSelect: true,
            idField: 'PProductSpecId',
            queryParams: query,  //异步查询的参数
            columns: [[
                { title: '规格名称', field: 'FSpecName', width: 120, sortable: false },
                { title: '最新价格', field: 'FPrice', width: 80, sortable: false },
                { title: '原价', field: 'FOldPrice', width: 60, sortable: false },
                { title: '会员价', field: 'FVipPrice', width: 60, sortable: false },
                { title: '库存', field: 'FStock', width: 60, sortable: false },
                { title: '一级分拥', field: 'FCommissionPrice', width: 80, sortable: false, editor: 'textbox' },
                { title: '二级分拥', field: 'FTwoCommissionPrice', width: 80, sortable: false, editor: 'textbox' },
                { title: '三级分拥', field: 'FThreeCommissionPrice', width: 80, sortable: false, editor: 'textbox' },
            ]],
            toolbar: SpecTool,
            onLoadSuccess: function (data) {
                if (data.total == 0) {
                    //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                    $(".datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                    //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
                }
                //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
                else {
                    $(".divNone").remove();
                    $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
                }
            },
            onClickRow: function (rowIndex, rowData) {
                if (editRow != undefined) {
                    $('#gridGroupCommissionBSB').datagrid("endEdit", editRow);
                }
                if (editRow == undefined) {
                    $('#gridGroupCommissionBSB').datagrid("beginEdit", rowIndex);
                    editRow = rowIndex;
                }
            },

            onAfterEdit: function (index, row) {
                console.log(index);
                editRow = undefined;
            },

        })

        $('#productCommission').panel({ iconCls: "icon-save" });
        $('#productCommission').window('open');
    }
}
//设置所以产品分佣
function SetAllCommission() {
    $("#AllCommission").window("open");
    $("#AllCommission").window("center");
}
$("#btnAllCommissionOk").click(function () {
    var pars = {};
    pars["OneCommission"] = $("#OneCommission").val();
    pars["TwoCommission"] = $("#TwoCommission").val();
    if (pars["OneCommission"] == "" && pars["TwoCommission"] == "") {
        msgShow("系统提示", "您还没有设置分佣比例!", "warning");
        return;
    }
    var posturl = "/Product/SetALLCommission";
    $.ajax({
        cache: true,
        type: "POST",
        url: posturl,
        data: pars,// 你的formid
        async: false,
        error: function (request) {
        },
        success: function (data) {
            if (data == "1") {
                msgShow("系统提示", "保存成功!", "info");
                $("#AllCommission").window("close");
                $("#grid").datagrid("reload");
            } else {
                msgShow("系统提示", "保存失败!", "warning");
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                parent.location.reload();
            });

        }
    });
});
$("#btnAllCommissionCancle").click(function () {
    $("#AllCommission").window("close");
});
$("#btnCommissionOk").click(function () {
    if (editRow != undefined) {
        $('#gridGroupCommission').datagrid("endEdit", editRow);
    }
    var flag = $("#CommissionForm").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入所有必填项!", "warning");
        return;
    }
    else {

        var rows = $('#gridGroupCommission').datagrid('getRows');
        var groupPrice = "";
        var check = true;
        $(rows).each(function (index, row) {

            groupPrice += row.PProductSpecId + "-" + row.FCommissionPrice + "-" + row.FTwoCommissionPrice + "-" + row.FVipCommissionPrice + "-" + row.FTwoVipCommissionPrice + ",";
        })
        if (check) {
            groupPrice = groupPrice.length > 0 ? groupPrice.substring(0, groupPrice.length - 1) : "";

            var pars = {};
            pars["commissionProdId"] = $("#commissionProdId").val();
            var posturl = "/Product/SaveProductCommission?groupPrice=" + groupPrice;
            $.ajax({
                cache: true,
                type: "POST",
                url: posturl,
                data: pars,// 你的formid
                async: false,
                error: function (request) {
                },
                success: function (data) {
                    var item = eval('(' + data + ')');
                    if (item.isSuccess) {
                        msgShow("系统提示", "保存成功!", "info");
                        $("#productCommission").window("close");
                        $("#grid").datagrid("reload");
                    } else {
                        msgShow("系统提示", item.msg, "warning");
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                        parent.location.reload();
                    });

                }
            });
        } else {
            msgShow("系统提示", "请输入所有规格的拼团价和团长价!", "warning");
        }
    }
});


$("#btnCommissionBSBOk").click(function () {
    if (editRow != undefined) {
        $('#gridGroupCommissionBSB').datagrid("endEdit", editRow);
    }
    var flag = $("#CommissionFormBSB").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入所有必填项!", "warning");
        return;
    }
    else {

        var rows = $('#gridGroupCommissionBSB').datagrid('getRows');
        var groupPrice = "";
        var check = true;
        $(rows).each(function (index, row) {

            groupPrice += row.PProductSpecId + "-" + row.FCommissionPrice + "-" + row.FTwoCommissionPrice + "-" + row.FThreeCommissionPrice + ",";
        })
        if (check) {
            groupPrice = groupPrice.length > 0 ? groupPrice.substring(0, groupPrice.length - 1) : "";

            var pars = {};
            pars["commissionProdId"] = $("#commissionProdId").val();
            var posturl = "/Product/SaveProductThreeCommission?groupPrice=" + groupPrice;
            $.ajax({
                cache: true,
                type: "POST",
                url: posturl,
                data: pars,// 你的formid
                async: false,
                error: function (request) {
                },
                success: function (data) {
                    var item = eval('(' + data + ')');
                    if (item.isSuccess) {
                        msgShow("系统提示", "保存成功!", "info");
                        $("#productCommission").window("close");
                        $("#grid").datagrid("reload");
                    } else {
                        msgShow("系统提示", item.msg, "warning");
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                        parent.location.reload();
                    });

                }
            });
        } else {
            msgShow("系统提示", "请输入所有规格的拼团价和团长价!", "warning");
        }
    }
});

$("#btnCommissionCancle").click(function () {
    $("#productCommission").window("close");
});

function UserEvaluate() {
    if (wxId == 3272 && $("#isShow").val() == "0") {
        $.messager.confirm('系统提示', '手动新增产品评论后,需平台审核后才能展示,请谨慎添加', function (r) {
            if (r) {
                EditEvaluate();
            }
        });
    } else {
        EditEvaluate();
    }
}
function EditEvaluate() {
    var row = $('#grid').datagrid('getSelected');
    if (row) {

        var query = {};
        query["productId"] = row.PProductId;
        var posturl = "/Product/GetProdSpecList?productId=" + row.PProductId;

        $('#prodSpec').combobox({
            url: posturl,
            data: query,
            valueField: 'PProductSpecId',
            textField: 'FSpecName',
            panelWidth: 150,
            panelHeight: 'auto'
        });

        $("#UserEvaluateForm").form('load', {
            userNo: "",
            userEvaluateContent: "",
            time: ""
        });
        $("#userEvaluateProdId").val(row.PProductId);

        $('#userEvaluate').panel({ iconCls: "icon-save" });
        $('#userEvaluate').window('open');
    }
}


$("#btnUserEvaluateOk").click(function () {

    var flag = $("#UserEvaluateForm").form('validate');
    if (!flag) {
        msgShow("系统提示", "请输入所有必填项!", "warning");
        return;
    }
    else {

        var pars = $('#UserEvaluateForm').serialize();
        var posturl = "/Product/SaveUserEvaluate";
        $.ajax({
            cache: true,
            type: "POST",
            url: posturl,
            data: pars,// 你的formid
            async: false,
            error: function (request) {
            },
            success: function (data) {
                var item = eval('(' + data + ')');
                if (item.isSuccess) {
                    msgShow("系统提示", "保存成功!", "info");
                    $("#userEvaluate").window("close");
                    $("#grid").datagrid("reload");
                } else {
                    msgShow("系统提示", "保存失败,请查看用户id是否正确", "warning");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                    parent.location.reload();
                });

            }
        });

    }
});

$("#btnUserEvaluateCancle").click(function () {
    $("#userEvaluate").window("close");
});


function GetTopNav() {
    $("#areaName").combobox({
        url: '/Product/GetProvince',
        valueField: 'PAreaId',
        textField: 'FName'
    });
}


function AddProductBind() {
    var rows = $('#grid').datagrid('getChecked');
    if (rows.length == 0) {
        msgShow("系统提示", "请选择一个产品信息!", "info");
        return;
    }
    if (rows.length > 1) {
        msgShow("系统提示", "请确保只选择一个产品信息!", "info");
        return;
    }
    if (rows[0].FIsPackage != 1) {
        msgShow("系统提示", "该商品不是套餐商品!", "info");
        return;
    }
    var queryData = {};
    $("#productList").window('open');
    $('#productGrid').datagrid('clearSelections');
    queryData["productId"] = rows[0].PProductId;
    queryData["storeId"] = rows[0].KStoreId;

    editRow = undefined;
    $("#productGrid").datagrid({   //定位到Table标签,Table标签的ID是grid
        url: "/Product/GetStoreProductSpec",   //指向后台的Action来获取当前用户的信息的Json格式的数据
        title: '产品列表',
        iconCls: 'icon-view',
        height: 600,
        width: function () { return document.body.clientWidth },//自动宽度
        nowrap: true,
        loadMsg: "正在加载数据中...",
        autoRowHeight: false,
        striped: true,
        collapsible: true,
        pagination: true,
        pageSize: 20,
        pageList: [20, 50, 100, 200],
        rownumbers: true,
        sortOrder: 'asc',
        remoteSort: false,
        singleSelect: false,
        queryParams: queryData,  //异步查询的参数
        idField: 'PProductSpecId',
        columns: [[
            { title: '', field: 'ck', checkbox: true, sortable: false },
            { title: '产品Id', field: 'KProductId', width: 80, sortable: false },
            { title: '产品规格Id', field: 'PProductSpecId', width: 80, sortable: false },
            { title: '产品名称', field: 'FName', width: 120, sortable: false },
            { title: '类型', field: 'TypeName', width: 120, sortable: false },
            { title: '规格名称1', field: 'FSpecName', width: 80, sortable: false },
            { title: '规格名称2', field: 'FSpecName2', width: 80, sortable: false },
            { title: '规格名称3', field: 'FSpecName3', width: 80, sortable: false },
            { title: '最新价格', field: 'FPrice', width: 80, sortable: false },
            { title: '排序', field: 'FSort', width: 80, sortable: false },
            {
                title: '产品状态', field: 'FState', width: 100, sortable: false,
                formatter: function (value, row, index) {
                    switch (value) {
                        case 1: return "上架"; break;
                        case 2: return "下架"; break;
                    }
                    return value;
                }
            },
            {
                title: '产品类型', field: 'FProductType', width: 60, sortable: false, hidden: false,
                formatter: function (value, row, index) {
                    var name = row.FCommissionPrice > 0 ? ",分佣" : "";
                    switch (value) {
                        case 1: return "普通" + name; break;
                        case 2: return "拼团" + name; break;
                        case 3: return "抢购" + name; break;
                        case 4: return "砍价" + name; break;
                    }
                    return value;
                }
            },
            { title: '数量', field: 'Count', width: 80, sortable: false, editor: 'textbox' }
        ]],
        onDblClickRow: function (rowIndex, rowData) {

        },
        onLoadSuccess: function (data) {
            if (data.total == 0) {
                //添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
                $(".datagrid-view2 .datagrid-body").append("<div class='divNone'><i></i><span>没有符合条件的数据</span></div>");
                //隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
                $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').hide();
            }
            //如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
            else {
                $(".divNone").remove();
                $(this).closest('div.datagrid-wrap').find('div.datagrid-pager').show();
            }

            if (data) {
                $.each(data.rows, function (index, item) {
                    if (item.IsHide) {
                        $('#productGrid').datagrid('checkRow', index);
                    }
                });
            }

        },
        onClickRow: function (rowIndex, rowData) {
            if (editRow != undefined) {
                $('#productGrid').datagrid("endEdit", editRow);
            }
            if (editRow == undefined) {
                $('#productGrid').datagrid("beginEdit", rowIndex);
                editRow = rowIndex;
            }
        },

        onAfterEdit: function (index, row) {
            editRow = undefined;
        },
    })
}

$(function () {
    $("#btnYes").click(function () {
        var row = $("#grid").datagrid("getSelected");
        if (row) {
            var productId = row.PProductId;
            var nodes = $('#productGrid').datagrid('getSelections');
            var ids = [];
            $.each(nodes, function (index, item) {
                ids.push(item.PProductSpecId + '_' + item.Count);
            });
            var url = "/Product/SavePackageProductDetail";
            var pars = {};
            pars["ids"] = ids.join(',');
            pars["productId"] = productId;
            $.ajax({
                type: "post",
                url: url,
                async: false,
                dataType: "json",
                data: pars,
                success: function (data) {
                    if (data) {
                        $('#productList').window('close');
                        $("#productGrid").datagrid("load");
                        msgShow("系统提示", "保存成功!", "warning");
                    } else {
                        msgShow("系统提示", "保存失败!", "warning");
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('登录超时', '操作失败,请重新登录!', "error", function (r) {
                        parent.location.reload();
                    });

                }
            });
        }

    });
    $("#btnNO").click(function () {
        $('#productList').window('close');
    });
})

然后是后端C#代码

public ActionResult CHWLList()
        {
            //获取当前用户
            TManager manager = Session["UserInfo"] as TManager;
            //拿到商店Id 
            string obj = "8557";//Request.QueryString["kstoreid"];
            //前端ViewBag.WxId是manager.KWxConfigId
            ViewBag.WxId = manager.KWxConfigId;
            //todo:前端ViewBag.KStoreId是请求过来的kstoreid,如果我简单粗暴就在这里改
            ViewBag.KStoreId = obj;
            using (YXXEntities entity = new YXXEntities())
            {
                //var types = entity.TType.Where(p => p.KWxConfigId == manager.KWxConfigId && p.FState == 1);
                //todo:我把这个改成显示全部先
                var types = entity.TType.Where(p => p.KWxConfigId > 0 && p.FState == 1);
                //todo:我把这个改成显示全部先 这个FStoreType随意表里只有两个字段等于2
                //var StoreList = entity.TStore.Where(p => p.KWxConfigId == manager.KWxConfigId && p.FState != 0 && p.FStoreType != 2);
                var StoreList = entity.TStore.Where(p => p.KWxConfigId > 0 && p.FState != 0);
                //todo:我把这个改成显示全部先 这个查商户类型
                //var clienteleType = entity.TClienteleType.Where(p => p.KWxConfigId == manager.KWxConfigId && p.FState == 0);
                var clienteleType = entity.TClienteleType.Where(p => p.KWxConfigId > 0);
                if (CurrentStoreUserInfo != null)
                {
                    //StoreList = StoreList.Where(p => p.PStoreId == CurrentStoreUserInfo.PStoreId);
                    StoreList = StoreList.Where(p => p.PStoreId >0);
                    //types = types.Where(p => p.KStoreId == CurrentStoreUserInfo.PStoreId);
                    types = types.Where(p => p.KStoreId >0);
                }
                else
                {
                    if (!string.IsNullOrEmpty(obj))
                    {
                        int pstoreid = int.Parse(obj);
                        //todo:我把它改成全部显示
                        types = types.Where(p => p.KStoreId >0);
                    }
                }
                ViewBag.TypeList = types.ToList();
                ViewBag.ClienteleType = clienteleType.ToList();
                List<TStore> stList = StoreList.OrderByDescending(p => p.FIsMain).ToList();
                ViewBag.StoreList = stList;
                if (CurrentStoreUserInfo != null)
                    ViewBag.KStoreId = stList[0].PStoreId;
                #region 设置按钮,被我绕过验证了
                //自提点管理
                //确定是否任何元素都满足条件
                //ViewBag.IsSince = entity.TManagerNav.Any(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 2057);
                ViewBag.IsSince = entity.TManagerNav.Any(p => p.KManagerID > 0);
                //会员管理
                //ViewBag.IsMember = entity.TManagerNav.Any(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 4082);
                ViewBag.IsMember = entity.TManagerNav.Any(p => p.KManagerID > 0);
                //是否隐藏
                //ViewBag.IsHidepProduct = entity.TManagerNav.Any(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 4091);
                ViewBag.IsHidepProduct = entity.TManagerNav.Any(p => p.KManagerID > 0);
                //导出产品权限
                //ViewBag.IsImportProduct = entity.TManagerNav.Any(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 4102);
                ViewBag.IsImportProduct = entity.TManagerNav.Any(p => p.KManagerID > 0);
                //运费模板
                //ViewBag.IsFreightTemplate = entity.TManagerNav.Any(p => p.KManagerID == manager.PManagerID && (p.KNavigationID == 1046 || p.KNavigationID == 4170));
                ViewBag.IsFreightTemplate = entity.TManagerNav.Any(p => p.KManagerID > 0);
                //ViewBag.Template = entity.TTemplateName.Where(p => p.KWxConfigId == manager.KWxConfigId).ToList();
                ViewBag.Template = entity.TTemplateName.Where(p => p.KWxConfigId == manager.KWxConfigId).ToList();

                //设置按钮,被我绕过验证了= =。。。。
                int rel = Convert.ToInt32(Request.QueryString["rel"]);
                var buttons = BannerController.GetButtonCode(CurrentUserInfo.PManagerID, rel, CurrentStoreUserInfo);
                //营销(判断当前登录用户是否为门店用户)
                if (CurrentStoreUserInfo != null)
                {

                    //ViewBag.HomeTemplate = entity.THomeTemplate.Where(p => p.KWxConfigId == CurrentStoreUserInfo.KWxConfigId && p.KStoreId == CurrentStoreUserInfo.PStoreId && p.FState == 1);
                    //ViewBag.PrintSet = entity.TPrintSet.Where(p => p.KWxConfigId == CurrentStoreUserInfo.KWxConfigId && p.KStoreId == CurrentStoreUserInfo.PStoreId && p.FState == 1);
                    if (entity.TStoreNav.FirstOrDefault(p => p.KStoreId == CurrentStoreUserInfo.PStoreId && p.KNavigationID == 4143) != null) { buttons += ",btngroup"; }
                    if (entity.TStoreNav.FirstOrDefault(p => p.KStoreId == CurrentStoreUserInfo.PStoreId && p.KNavigationID == 4144) != null) { buttons += ",btnbargain"; }
                    if (entity.TStoreNav.FirstOrDefault(p => p.KStoreId == CurrentStoreUserInfo.PStoreId && p.KNavigationID == 4147) != null) { buttons += ",btncommission"; }
                    if (entity.TStoreNav.FirstOrDefault(p => p.KStoreId == CurrentStoreUserInfo.PStoreId && p.KNavigationID == 4148) != null) { buttons += ",setintegral"; }
                    if (entity.TStoreNav.FirstOrDefault(p => p.KStoreId == CurrentStoreUserInfo.PStoreId && p.KNavigationID == 4150) != null) { buttons += ",btnallcommission"; }
                    if (entity.TStoreNav.FirstOrDefault(p => p.KStoreId == CurrentStoreUserInfo.PStoreId && p.KNavigationID == 5326) != null) { buttons += ",promotion,allpromotion"; }
                }
                else
                {
                    if (entity.TManagerNav.FirstOrDefault(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 4143) != null) { buttons += ",btngroup"; }
                    if (entity.TManagerNav.FirstOrDefault(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 4144) != null) { buttons += ",btnbargain"; }
                    if (entity.TManagerNav.FirstOrDefault(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 4147) != null) { buttons += ",btncommission"; }
                    if (entity.TManagerNav.FirstOrDefault(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 4148) != null) { buttons += ",setintegral"; }
                    if (entity.TManagerNav.FirstOrDefault(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 4150) != null) { buttons += ",btnallcommission"; }
                    if (entity.TManagerNav.FirstOrDefault(p => p.KManagerID == manager.PManagerID && p.KNavigationID == 5326) != null) { buttons += ",promotion,allpromotion"; }
                }
                ViewBag.buttons = "add,edit,delete,reload";
                ViewBag.StartTime = DateTime.Today.ToString("yyyy-MM-dd") + " 00:00";
                ViewBag.EndTime = DateTime.Today.ToString("yyyy-MM-dd") + " 23:59"; 
                #endregion
            }

            return View();
        }

        //包括了查询功能的初始化表格
        //todo:这里还有一个查询的逻辑有问题,具体是:查询必须要选择产品类型?先解决添加和修改吧
        public ActionResult GetCHWLProductList()
        {
            using (YXXEntities entity=new YXXEntities())
            {
                var pageindex = int.Parse(Request.Form["page"]);
                var pagesize = int.Parse(Request.Form["rows"]);
                var FName = Request.Form["productName"];
                var productType = Convert.ToInt32(Request.Form["productType"]);
                int state = Convert.ToInt32(Request.Form["state"]);

                int KStoreId1 = Convert.ToInt32(Request.Form["KStoreId1"]);
                int count = 0;
                List<TProduct> CHWLProducts=new List<TProduct>();
                CHWLProducts = entity.TProduct.Where(p => p.FState ==1).OrderBy(p => p.PProductId)
                    .Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
                if (!string.IsNullOrEmpty(FName))
                {
                    CHWLProducts = CHWLProducts.Where(p => p.FName.Contains(FName)).ToList();
                }
                if (productType!=0)
                {
                    CHWLProducts = CHWLProducts.Where(p => p.FProductType== productType).ToList();
                }
                //if (state!=0)
                //{
                //    CHWLProducts = CHWLProducts.Where(p => p.FState == state).ToList();
                //}

                if (!string.IsNullOrEmpty(Request.Form["KStoreId1"]))
                {
                    CHWLProducts = CHWLProducts.Where(p => p.KStoreId == KStoreId1).ToList();
                }

                count = entity.TProduct.Count(p => p.PProductId > 0);

                var jsonMap=new Dictionary<string,object>();
                jsonMap.Add("total",count);
                jsonMap.Add("rows", CHWLProducts);
                return Content(JsonConvert.SerializeObject(jsonMap));
            }
        }

        [ValidateInput(false)]
        public ActionResult SaveCHWLProduct(string editor)
        {
            TManager manager = Session["UserInfo"] as TManager;
            NameValueCollection postPars = Request.Form;
            JsonReturn result = new JsonReturn();
            try
            {
                bool check = true;
                //判断上架和待审核的产品数量是否超过限制
                if (Convert.ToInt32(postPars["State"]) == 1)
                {
                    check = CheckProductCount(manager, 1);
                }
                if (check)
                {
                    var productId = int.Parse(postPars["productId"] == "" ? "0" : postPars["productId"]);
                    using (YXXEntities entity = new YXXEntities())
                    {

                        var Name = postPars["Name"];
                        var typeId = Convert.ToInt32(postPars["Type"]);//产品类型
                        var storeId = Convert.ToInt32(postPars["Store"]);//门店Id
                        var OldPrice = postPars["OldPrice"];
                        var Price = postPars["Price"];
                        var Freight = postPars["Freight"];
                        var Sort = postPars["Sort"];
                        var ProductType = postPars["ProductType"];
                        var GroupCount = postPars["GroupCount"];
                        var imageList = postPars["iamge"];
                        var mimageList = postPars["miamge"];
                        var Weigth = postPars["Weigth"];
                        var IsHide = postPars["IsHide"];
                        var SaleTime = postPars["SaleTime"];
                        int? teacherId = null;
                        if (manager.KWxConfigId == 3174)
                        {
                            teacherId = Convert.ToInt32(postPars["Tearcher"]);
                        }

                        int copyId;
                        int.TryParse(postPars["copyId"], out copyId);
                        var copyWxId = 0;
                        #region 复制产品主信息
                        if (copyId > 0)
                        {
                            var type = entity.TType.SingleOrDefault(p => p.PTypeId == typeId);
                            if (type.KWxConfigId != manager.KWxConfigId)
                            {
                                var oldtype = entity.TType.SingleOrDefault(p =>
                                 p.FName == type.FName && p.KWxConfigId == manager.KWxConfigId);
                                if (oldtype == null)
                                {
                                    var newType = new TType()
                                    {
                                        FIsShow = true,
                                        FType = 1,
                                        FName = type.FName,
                                        KWxConfigId = manager.KWxConfigId,
                                        FState = 1,
                                        KStoreId = storeId
                                    };
                                    entity.TType.Add(newType);
                                    entity.SaveChanges();
                                    typeId = newType.PTypeId;
                                }
                                else
                                {
                                    typeId = oldtype.PTypeId;
                                }
                            }
                        }
                        #endregion
                        TProduct product = entity.TProduct.FirstOrDefault(p => p.PProductId == productId);
                        #region 新增产品
                        if (product == null)
                        {
                            product = new TProduct() { KWxConfigId = manager.KWxConfigId, FIsMain = true };
                            if (copyId > 0)
                            {
                                TProduct copyProduct = entity.TProduct.FirstOrDefault(p => p.PProductId == copyId);
                                copyWxId = Convert.ToInt32(copyProduct.KWxConfigId);
                                product = new TProduct
                                {
                                    KWxConfigId = manager.KWxConfigId,//copyProduct.KWxConfigId,
                                    FUnitName = copyProduct.FUnitName,
                                    FBargainCount = copyProduct.FBargainCount,
                                    FCode = copyProduct.FCode,
                                    FBeginTime = copyProduct.FBeginTime,
                                    FCommissionPrice = copyProduct.FCommissionPrice,
                                    FContent = copyProduct.FContent,
                                    FEndTime = copyProduct.FEndTime,
                                    FFreight = copyProduct.FFreight,
                                    FGiveIntegral = copyProduct.FGiveIntegral,
                                    FGroupCount = copyProduct.FGroupCount,
                                    FImgUrl = copyProduct.FImgUrl,
                                    FIntegral = copyProduct.FIntegral,
                                    FIsMain = copyProduct.FIsMain,
                                    FMaxCount = copyProduct.FMaxCount,
                                    FMaxPrice = copyProduct.FMaxPrice,
                                    FMinCount = copyProduct.FMinCount,
                                    FMinPrice = copyProduct.FMinPrice,
                                    FName = copyProduct.FName,
                                    FOldPrice = copyProduct.FOldPrice,
                                    FOrderNum = copyProduct.FOrderNum,
                                    FPrice = copyProduct.FPrice,
                                    FProductType = copyProduct.FProductType,
                                    FSort = copyProduct.FSort,
                                    FSpecName = copyProduct.FSpecName,
                                    FSpecName2 = copyProduct.FSpecName2,
                                    FSpecName3 = copyProduct.FSpecName3,
                                    FState = copyProduct.FState,
                                    FTag = copyProduct.FTag,
                                    FTwoCommissionPrice = copyProduct.FTwoCommissionPrice,
                                    FTwoVipCommissionPrice = copyProduct.FTwoVipCommissionPrice,
                                    FVipCommissionPrice = copyProduct.FVipCommissionPrice,
                                    FWeigth = copyProduct.FWeigth,
                                    KFreightTemplateId = copyProduct.KFreightTemplateId,
                                    KHomeTemplateId = copyProduct.KHomeTemplateId,
                                    KJoinStoreId = copyProduct.KJoinStoreId,
                                    KMainProductId = copyProduct.KMainProductId,
                                    KPrintSetId = copyProduct.KPrintSetId,
                                    KStoreId = copyProduct.KStoreId,//在这里
                                    KTemplateNameId = copyProduct.KTemplateNameId,
                                    KTypeId = copyProduct.KTypeId,
                                    PProductId = copyProduct.PProductId,
                                    FSaleTime = copyProduct.FSaleTime,
                                    KTeachrtId = teacherId
                                };

                            }
                        }
                        #endregion
                        //产品属性
                        product.FName = Name;
                        //product.FOldPrice = Convert.ToDecimal(OldPrice);
                        //product.FPrice = Convert.ToDecimal(Price);
                        product.KTypeId = typeId;
                        product.KTeachrtId = teacherId;
                        product.FFreight = Convert.ToDecimal(Freight);
                        if (!string.IsNullOrEmpty(postPars["ProductType"]))
                            product.FProductType = Convert.ToInt32(postPars["ProductType"]);
                        else
                            product.FProductType = 1;
                        product.FState = Convert.ToByte(postPars["State"]);
                        product.FContent = editor;
                        product.FUnitName = Convert.ToString(postPars["UnitName"]);
                        product.FTag = Convert.ToString(postPars["Tag"]);
                        if (!string.IsNullOrEmpty(postPars["BeginTime"]))
                            product.FBeginTime = Convert.ToDateTime(postPars["BeginTime"]);
                        if (!string.IsNullOrEmpty(postPars["EndTime"]))
                            product.FEndTime = Convert.ToDateTime(postPars["EndTime"]);
                        if (!string.IsNullOrEmpty(postPars["Sort"]))
                        {
                            product.FSort = Convert.ToInt32(postPars["Sort"]);
                        }
                        else
                        {
                            product.FSort = 1;
                        }
                        if (!string.IsNullOrEmpty(postPars["OrderNum"]))
                            product.FOrderNum = Convert.ToInt32(postPars["OrderNum"]);
                        if (!string.IsNullOrEmpty(postPars["Store"]))
                            product.KStoreId = Convert.ToInt32(postPars["Store"]);
                        if (!string.IsNullOrEmpty(postPars["MaxCount"]))
                            product.FMaxCount = Convert.ToInt32(postPars["MaxCount"]);
                        if (!string.IsNullOrEmpty(postPars["FreightTemplateId"]))
                            product.KTemplateNameId = Convert.ToInt32(postPars["FreightTemplateId"]);
                        //if (!string.IsNullOrEmpty(postPars["HomeTemplateId"]))
                        //    product.KHomeTemplateId = Convert.ToInt32(postPars["HomeTemplateId"]);
                        if (!string.IsNullOrEmpty(postPars["PrintSetId"]))
                            product.KPrintSetId = Convert.ToInt32(postPars["PrintSetId"]);
                        if (!string.IsNullOrEmpty(postPars["Weigth"]))
                            product.FWeigth = Convert.ToDecimal(postPars["Weigth"]);
                        if (!string.IsNullOrEmpty(postPars["SaleTime"]))
                            product.FSaleTime = Convert.ToString(postPars["SaleTime"]);
                        else
                            product.FSaleTime = "";

                        if (!string.IsNullOrEmpty(postPars["IsHide"]))
                        {
                            product.FIsHide = Convert.ToBoolean(postPars["IsHide"]);
                        }
                        else
                        {
                            product.FIsHide = false;
                        }

                        product.FIsPackage = postPars["IsPackage"] == "1" ? true : false;

                        product.FSpecName = postPars["FSpecName"];

                        product.FSpecName2 = postPars["FSpecName2"];

                        product.FSpecName3 = postPars["FSpecName3"];


                        //产品规格
                        if (string.IsNullOrEmpty(postPars["SpecName"]))
                        {
                            result.isSuccess = false;
                            result.msg = "操作失败,请添加规格!";
                            return Content(JsonConvert.SerializeObject(result));
                        }


                        var specNameList = postPars["SpecName"].Split(',');
                        var specName2List = postPars["SpecName2"].Split(',');
                        var specName3List = postPars["SpecName3"].Split(',');
                        var specPriceList = postPars["SpecPrice"].Split(',');
                        var specOldPriceList = postPars["SpecOldPrice"].Split(',');
                        var specStockList = postPars["SpecStock"].Split(',');
                        var specBarCodeList = postPars["SpecBarCode"].Split(',');
                        var productSpecList = postPars["ProductSpecId"].Split(',');

                        List<TProductSpec> prodSpecList = new List<TProductSpec>();
                        for (int i = 0; i < productSpecList.Length; i++)
                        {
                            int specId = Convert.ToInt32(productSpecList[i]);
                            TProductSpec productSpec = new TProductSpec();
                            if (specId > 0 && copyId == 0)//不是复制
                            {
                                productSpec = entity.TProductSpec.FirstOrDefault(p => p.PProductSpecId == specId);
                            }
                            productSpec.FState = 1;
                            productSpec.FPrice = UnitConvert.GetDecimal(Convert.ToString(specPriceList[i]));
                            productSpec.FOldPrice = UnitConvert.GetDecimal(Convert.ToString(specOldPriceList[i]));
                            productSpec.FStock = UnitConvert.GetInt(Convert.ToString(specStockList[i]));
                            productSpec.FBarCode = Convert.ToString(specBarCodeList[i]);
                            productSpec.FSpecName = Convert.ToString(specNameList[i]).Trim();
                            productSpec.FSpecName2 = Convert.ToString(specName2List[i]).Trim();
                            productSpec.FSpecName3 = Convert.ToString(specName3List[i]).Trim();
                            if (!string.IsNullOrEmpty(postPars["VipPrice"]))
                            {
                                var vipPrice = postPars["VipPrice"].Split(',');
                                productSpec.FVipPrice = UnitConvert.GetDecimal(vipPrice[i]);
                            }
                            prodSpecList.Add(productSpec);
                        }
                        if (prodSpecList.Count > 0)
                        {
                            product.FPrice = Convert.ToDecimal(prodSpecList.Min(p => p.FPrice));
                            product.FOldPrice = Convert.ToDecimal(prodSpecList.Min(p => p.FOldPrice));
                        }
                        #region 更改被删除和被更改的规格
                        if (copyId == 0 && !string.IsNullOrEmpty(postPars["delPSpecIds"]))
                        {
                            var delSpecListIds = postPars["delPSpecIds"].Split(',').Where(p => !string.IsNullOrEmpty(p)).ToList();
                            if (delSpecListIds.Count > 0)
                            {
                                var delSpecList = entity.TProductSpec.Where(p => delSpecListIds.Contains(p.PProductSpecId.ToString())).ToList();
                                if (delSpecList.Count > 0)
                                {
                                    delSpecList.ForEach(p =>
                                    {
                                        p.FState = 0;
                                    });
                                }
                            }
                        }
                        #endregion
                        if (manager.KWxConfigId == 3293)
                        {
                            ConfigHelper.SetBaiduAIAccessToken(manager.KWxConfigId.Value, 2);
                        }
                        #region 产品图片
                        List<TProductImage> productImageList = new List<TProductImage>();
                        TProductImage productImage = null;
                        string[] filesName = imageList.Split(',').Where(n => !string.IsNullOrWhiteSpace(n)).ToArray();//产品主图
                        for (int i = 0; i < filesName.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(filesName[i]))
                            {
                                filesName[i] = filesName[i].Replace("/", "\\");
                                string uploadPath = Server.MapPath(GlobalInfo.ProductImage + "\\wxid_" + manager.KWxConfigId + "\\ProductImage\\");
                                var contsign = "";
                                #region 麦维商城宣传图存入百度云商品库
                                if (manager.KWxConfigId == 3293)
                                {
                                    var brief = "";
                                    if (System.IO.File.Exists(uploadPath + filesName[i]))
                                    {
                                        //查询图片是否新增的
                                        var ImageName = filesName[i];
                                        var imageInfo = entity.TProductImage.AsNoTracking().FirstOrDefault(p => p.FType == 1 && p.FImageUrl == ImageName);
                                        brief = product.FName;
                                        //复制/修改
                                        if (imageInfo != null)
                                        {
                                            //更新所有相同图片的信息
                                            //List<TProductImage> imgList = entity.TProductImage.Where(p => p.FType == 1 && p.FImageUrl == ImageName).ToList();
                                            //查询同一图片签名的图片信息
                                            List<TProductImage> imgList = new List<TProductImage>();
                                            //图片签名不为空则更新商品图片库
                                            if (!string.IsNullOrEmpty(imageInfo.FContSign))
                                            {
                                                contsign = imageInfo.FContSign;
                                                imgList = entity.TProductImage.AsNoTracking().Where(p => p.FContSign == contsign && p.KProductId != productId).ToList();
                                                var productIds = imgList.Select(p => p.KProductId).Distinct().ToList();
                                                //查询同一账号下的产品
                                                string[] productNames = entity.TProduct.AsNoTracking().Where(p => productIds.Contains(p.PProductId) && p.KWxConfigId == manager.KWxConfigId && p.FState == 1).Select(p => p.FName).ToArray();
                                                //为空则说明是未更新图片信息
                                                if (productNames.Length > 0)
                                                {
                                                    if (!productNames.Contains(brief))
                                                        brief = string.Join(";", productNames) + ";" + product.FName;
                                                }
                                                //若是复制的产品并判断图片是否为新增,则更新百度云的商品图片库
                                                Common.BaiduAI.BaiduAPI.UpdateProduct(brief, "", imageInfo.FContSign);
                                            }
                                            else
                                            {
                                                string base64 = GetFileBase64(filesName[i], manager.KWxConfigId.Value);
                                                contsign = Common.BaiduAI.BaiduAPI.AddProduct(brief, base64);
                                                if (contsign != "")
                                                {
                                                    imgList = entity.TProductImage.AsNoTracking().Where(p => p.FContSign == contsign && p.KProductId != productId).Distinct().ToList();
                                                    if (imgList.Count > 0)
                                                    {
                                                        var productIds = imgList.Select(p => p.KProductId).Distinct().ToList();
                                                        //查询同一账号下的产品
                                                        string[] productNames = entity.TProduct.AsNoTracking().Where(p => productIds.Contains(p.PProductId) && p.KWxConfigId == manager.KWxConfigId && p.FState == 1).Select(p => p.FName).ToArray();
                                                        //更新图片信息
                                                        if (productNames.Length > 0)
                                                        {
                                                            if (!productNames.Contains(brief))
                                                                brief = string.Join(";", productNames) + ";" + brief;
                                                            Common.BaiduAI.BaiduAPI.UpdateProduct(brief, "", contsign);
                                                        }
                                                    }
                                                }
                                            }
                                            //imgList.ForEach(item => item.FName = brief);
                                        }
                                        else
                                        {
                                            string base64 = GetFileBase64(filesName[i], manager.KWxConfigId.Value);
                                            contsign = Common.BaiduAI.BaiduAPI.AddProduct(brief, base64);
                                            if (contsign != "")
                                            {
                                                //查询是否有相同图片
                                                var imgList = entity.TProductImage.AsNoTracking().Where(p => p.FContSign == contsign).ToList();
                                                if (imgList.Count > 0)
                                                {
                                                    var productIds = imgList.Select(p => p.KProductId).Distinct().ToList();
                                                    //查询同一账号下的产品
                                                    string[] productNames = entity.TProduct.AsNoTracking().Where(p => productIds.Contains(p.PProductId) && p.KWxConfigId == manager.KWxConfigId && p.FState == 1).Select(p => p.FName).ToArray();
                                                    //更新图片信息
                                                    if (productNames.Length > 0)
                                                    {
                                                        if (!productNames.Contains(brief))
                                                            brief = string.Join(";", productNames) + ";" + brief;
                                                        Common.BaiduAI.BaiduAPI.UpdateProduct(brief, "", contsign);
                                                        //imgList.ForEach(item => item.FName = brief);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                #endregion
                                if (copyId > 0 && !System.IO.File.Exists(uploadPath + filesName[i]))
                                {
                                    if (!Directory.Exists(uploadPath))
                                    {
                                        Directory.CreateDirectory(uploadPath);
                                    }
                                    if (filesName[i].Contains("\\"))
                                    {
                                        var DirectoryName = filesName[i].Replace("\\", "/");
                                        var pass = DirectoryName.Substring(0, DirectoryName.IndexOf("/"));
                                        if (!Directory.Exists(uploadPath + pass))
                                        {
                                            Directory.CreateDirectory(uploadPath + pass);
                                        }
                                    }
                                    System.IO.File.Copy(Server.MapPath(GlobalInfo.ProductImage + "\\wxid_" + copyWxId + "\\ProductImage\\" + filesName[i]), uploadPath + filesName[i]);
                                }
                                if (i == 0)
                                {
                                    string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(0, 1000) + filesName[i].Substring(filesName[i].IndexOf('.'));
                                    if (System.IO.File.Exists(uploadPath + filesName[i]))
                                    {
                                        Image img = Image.FromFile(uploadPath + filesName[i]);
                                        Bitmap map = new Bitmap(img);
                                        if (img != null)
                                        {
                                            XCXCodeHelper.GetPicThumbnail(map, uploadPath + fileName, img.Height, img.Width, 50);
                                            product.FImgUrl = fileName;
                                        }
                                        else
                                        {
                                            product.FImgUrl = filesName[i];
                                        }
                                    }
                                }
                                productImage = new TProductImage()
                                {
                                    FImageUrl = filesName[i].Replace("\\", "/"),
                                    KProductId = productId,
                                    FOrder = i + 1,
                                    FType = 1,
                                    FContSign = contsign ?? null
                                };

                                productImageList.Add(productImage);
                            }
                        }
                        #endregion
                        #region 产品详情图
                        string[] filesName2 = mimageList.Split(',').Where(n => !string.IsNullOrWhiteSpace(n)).ToArray();
                        for (int i = 0; i < filesName2.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(filesName2[i]))
                            {
                                filesName2[i] = filesName2[i].Replace("/", "\\");
                                string uploadPath = Server.MapPath(GlobalInfo.ProductImage + "\\wxid_" + manager.KWxConfigId + "\\ProductImage\\");
                                var contsign = "";
                                #region 麦维商城详情图存入百度云商品库
                                if (manager.KWxConfigId == 3293)
                                {
                                    var brief = "";
                                    if (System.IO.File.Exists(uploadPath + filesName2[i]))
                                    {
                                        //查询图片是否新增的
                                        var ImageName = filesName2[i];
                                        var imageInfo = entity.TProductImage.AsNoTracking().FirstOrDefault(p => p.FType == 2 && p.FImageUrl == ImageName);
                                        brief = product.FName;
                                        //复制/修改
                                        if (imageInfo != null)
                                        {
                                            //查询同一图片签名的图片信息
                                            List<TProductImage> imgList = new List<TProductImage>();
                                            //图片签名不为空则更新商品图片库
                                            if (!string.IsNullOrEmpty(imageInfo.FContSign))
                                            {
                                                contsign = imageInfo.FContSign;
                                                imgList = entity.TProductImage.AsNoTracking().Where(p => p.FContSign == contsign && p.KProductId != productId).ToList();
                                                var productIds = imgList.Select(p => p.KProductId).Distinct().ToList();
                                                //查询同一账号下的产品
                                                string[] productNames = entity.TProduct.AsNoTracking().Where(p => productIds.Contains(p.PProductId) && p.KWxConfigId == manager.KWxConfigId && p.FState == 1).Select(p => p.FName).ToArray();
                                                //为空则说明是未更新图片信息
                                                if (productNames.Length > 0)
                                                {
                                                    if (!productNames.Contains(brief))
                                                        brief = string.Join(";", productNames) + ";" + product.FName;
                                                }
                                                //若是复制的产品并判断图片是否为新增,则更新百度云的商品图片库
                                                Common.BaiduAI.BaiduAPI.UpdateProduct(brief, "", imageInfo.FContSign);
                                            }
                                            else
                                            {
                                                string base64 = GetFileBase64(filesName2[i], manager.KWxConfigId.Value);
                                                contsign = Common.BaiduAI.BaiduAPI.AddProduct(brief, base64);
                                                if (contsign != "")
                                                {
                                                    imgList = entity.TProductImage.AsNoTracking().Where(p => p.FContSign == contsign && p.KProductId != productId).ToList();
                                                    if (imgList.Count > 0)
                                                    {
                                                        var productIds = imgList.Select(p => p.KProductId).Distinct().ToList();
                                                        //查询同一账号下的产品
                                                        string[] productNames = entity.TProduct.AsNoTracking().Where(p => productIds.Contains(p.PProductId) && p.KWxConfigId == manager.KWxConfigId && p.FState == 1).Select(p => p.FName).ToArray();
                                                        //更新图片信息
                                                        if (productNames.Length > 0)
                                                        {
                                                            if (!productNames.Contains(brief))
                                                                brief = string.Join(";", productNames) + ";" + brief;
                                                            Common.BaiduAI.BaiduAPI.UpdateProduct(brief, "", contsign);
                                                        }
                                                    }
                                                }
                                            }
                                            //imgList.ForEach(item => item.FName = brief);
                                        }
                                        else
                                        {
                                            string base64 = GetFileBase64(filesName2[i], manager.KWxConfigId.Value);
                                            contsign = Common.BaiduAI.BaiduAPI.AddProduct(brief, base64);
                                            if (contsign != "")
                                            {
                                                //查询是否有相同图片
                                                var imgList = entity.TProductImage.AsNoTracking().Where(p => p.FContSign == contsign).ToList();
                                                if (imgList.Count > 0)
                                                {
                                                    var productIds = imgList.Select(p => p.KProductId).Distinct().ToList();
                                                    //查询同一账号下的产品
                                                    string[] productNames = entity.TProduct.AsNoTracking().Where(p => productIds.Contains(p.PProductId) && p.KWxConfigId == manager.KWxConfigId && p.FState == 1).Select(p => p.FName).ToArray();
                                                    //更新图片信息
                                                    if (productNames.Length > 0)
                                                    {
                                                        if (!productNames.Contains(brief))
                                                            brief = string.Join(";", productNames) + ";" + brief;
                                                        Common.BaiduAI.BaiduAPI.UpdateProduct(brief, "", contsign);
                                                        imgList.ForEach(item => item.FName = brief);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                #endregion
                                if (copyId > 0 && !System.IO.File.Exists(uploadPath + filesName2[i]))
                                {
                                    if (!Directory.Exists(uploadPath))
                                    {
                                        Directory.CreateDirectory(uploadPath);
                                    }
                                    if (filesName2[i].Contains("\\"))
                                    {
                                        var DirectoryName = filesName2[i].Replace("\\", "/");
                                        var pass = DirectoryName.Substring(0, DirectoryName.IndexOf("/"));
                                        if (!Directory.Exists(uploadPath + pass))
                                        {
                                            Directory.CreateDirectory(uploadPath + pass);
                                        }
                                    }
                                    System.IO.File.Copy(Server.MapPath(GlobalInfo.ProductImage + "\\wxid_" + copyWxId + "\\ProductImage\\" + filesName2[i]), uploadPath + filesName2[i]);
                                }
                                productImage = new TProductImage()
                                {
                                    FImageUrl = filesName2[i].Replace("\\", "/"),
                                    KProductId = productId,
                                    FOrder = i + 1,
                                    FType = 2,
                                    FContSign = contsign ?? null
                                };
                                productImageList.Add(productImage);
                            }
                        }
                        #endregion

                        #region 日报社操作审核判断
                        int step = 2;//默认操作为2:修改
                        if (manager.KWxConfigId == 3272 && GetIsCheck() > 0 && CurrentStoreUserInfo != null)
                        {
                            product.FState = 3;//门店操作新增或修复,变更待审核
                        }
                        #endregion
                        if (productId > 0)
                        {
                            step = 1;
                            //判断如果该产品属于主店,则将复制的产品设置成未同步
                            TStore store = entity.TStore.FirstOrDefault(p => p.PStoreId == product.KStoreId);
                            if (store != null && store.FIsMain != true)
                            {
                                List<TProduct> plist = entity.TProduct.Where(p => p.KMainProductId == productId).ToList();
                                plist.ForEach(p => p.FIsMain = false);
                                foreach (var item in plist)
                                {
                                    entity.Entry(item).State = System.Data.Entity.EntityState.Modified;
                                    entity.SaveChanges();
                                }
                            }
                            entity.Entry(product).State = System.Data.Entity.EntityState.Modified;
                        }
                        else
                            entity.TProduct.Add(product);

                        int Isresult = entity.SaveChanges();
                        productId = product.PProductId;

                        //if (copyId > 0)
                        //{
                        //    List<TProductSpec> productSpecList = entity.TProductSpec.Where(p => p.KProductId == copyId && p.FState == 1).ToList();
                        //    productSpecList.ForEach(p => p.KProductId = productId);
                        //    entity.TProductSpec.AddRange(productSpecList);
                        //}
                        //移除之前的图片
                        entity.TProductImage.RemoveRange(entity.TProductImage.Where(p => p.KProductId == productId && (p.FType == 1 || p.FType == 2)));
                        productImageList.ForEach(p => p.KProductId = productId);
                        //添加图片
                        entity.TProductImage.AddRange(productImageList);

                        entity.SaveChanges();
                        prodSpecList.ForEach(p => p.KProductId = productId);

                        //添加规格
                        //if (copyId > 0)
                        //{

                        //    foreach (var item in prodSpecList.Where(p => p.PProductSpecId > 0))
                        //    {
                        //        entity.TProductSpec.Add(item);
                        //        entity.SaveChanges();
                        //    }
                        //}
                        //else
                        //{

                        //    foreach (var item in prodSpecList.Where(p => p.PProductSpecId > 0))
                        //    {
                        //        entity.Entry(item).State = System.Data.Entity.EntityState.Modified;
                        //        entity.SaveChanges();
                        //    }
                        //}
                        foreach (var item in prodSpecList.Where(p => p.PProductSpecId > 0))
                        {
                            entity.Entry(item).State = System.Data.Entity.EntityState.Modified;
                            entity.SaveChanges();
                        }

                        entity.TProductSpec.AddRange(prodSpecList.Where(p => p.PProductSpecId == 0));
                        entity.SaveChanges();

                        if (manager.KWxConfigId == 3272 && GetIsCheck() > 0 && Isresult > 0)
                        {
                            int StoreId = CurrentStoreUserInfo != null ? CurrentStoreUserInfo.PStoreId : 0;
                            string remark = step == 1 ? "添加了产品信息" : "修改了产品信息";
                            AddOperationLog(manager.KWxConfigId.Value, productId, step, StoreId, 1, 5, remark, entity);
                        }
                    }
                    result.isSuccess = true;
                }
                else
                {
                    result.isSuccess = false;
                    result.msg = "操作失败,超过最大上架量!";
                }

            }
            catch (Exception ex)
            {
                result.isSuccess = false;
                result.msg = ex.Message;
            }
            return Content(Newtonsoft.Json.JsonConvert.SerializeObject(result));

        }