
<table border="0" align="center" cellpadding="0" cellspacing="0" id="mian" ms-controller="productlist">
    <tbody>
        <tr>
            <td width="198" height="450" valign="top" id="tdleft" ms-visible="!showOnlyList">
                <!--leftNav-->
                  <div id="left" ms-widget="leftMenu">
                </div>
                <!--End leftNav-->
            </td>
            <td valign="top" ms-attr-id="showOnlyList?'noright':'right'" class="">
                <div class="boxTitle top10 bottom10" ms-visible="!showOnlyList">
                    <h2>检索</h2>
                    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="seacrhTable" style="background: none;">
                        <tbody>
                            <tr>
                                <td width="460" class="searchico">
                                    <div class="input-append" style="margin-bottom: 10px;">
                                        <input id="keyInput" type="text" class="span4" ms-duplex="keyword" placeholder="请输入产品名称" ms-enter="search">
                                        <button class="add-on ibtsearch" type="button" style="height: 28px; font-size: 12px; padding: 3px 12px;" ms-click="search">搜索</button>
                                        <button class="add-on ibtsearch clearall" type="button" style="height: 28px; font-size: 12px; padding: 3px 12px;" ms-click="clearQuery">显示全部</button>
                                    </div>
                                </td>
                                <td class="fgray">{{lang.SearchHistory}}
                                   <span class="bindSearchHistory" ms-repeat-h='queryHistory'>
                                       <a href="javascript:void(0)" ms-click='addQuery(h.name,h.val,h.label)' ms-title='h.label'>{{h.label|truncate(10)}}</a>
                                   </span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" class="seacrhField">
                        <tbody>
                            <tr class="quickword" ms-repeat="queryData" ms-if-loop="$val.items">
                                <td colspan="2"><span>{{$val.label}}</span>
                                    <div style="display: inline;" ms-each-r='$val.items'>
                                        <a href="javascript:void(0)" ms-click='addQuery($key,r.val)' ms-class-1="selected:r.curr" ms-html='r.label'></a>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" class="seabox">
                                    <span class="first" ms-html='lang.CurrSearchCondition'></span>
                                    <div style="display: inline;float:left;" ms-repeat="queryData">
                                        <span class="searchItem" ms-if-loop='$val.valLabel'>{{$val.valLabel}}
                                        <i><a href="javascript:void(0)" ms-click='removeQuery($key)'></a></i>
                                        </span>
                                    </div>
                                    <span class="last" ms-visible='hasQuery' ms-click='clearQuery'><a href="javascript:void(0)" ms-html='lang.ClearAll'></a></span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tableList" id="tableList" style=" margin-bottom:10px;">
                    <tr class="dobtn">
                        <td colspan="10" bgcolor="#FFFFFF"><a href="javascript:void(0);" class="doadd" ms-click="doadd" ms-if="ADD">新增</a></td>
                    </tr>
                    <tr class="head" style="background-color: rgba(0, 0, 0, 0); "> 
                        <td width="3%" align="center">编号</td>     
                        <td width="20%" align="center">商品</td>
                        <td width="15%" align="center">别称</td> 
                        <td width="12%" align="center">归属合同</td>    
                        <td width="10%" align="center">产品单价</td>
                        <td width="10%" align="center">成交单价</td>
                        <td width="6%"  align="center">数量</td>
                        <td width="6%"  align="center">成交金额</td>
                        <td width="6%"  align="center">付款状态</td>
                        <td width="8%" align="center">操作</td>
                    </tr> 
                    <tr ms-repeat-item="entityList" ms-class-old="$index % 2" ms-class-even="!($index % 2)" ms-hover="hover" ms-class-endtime="!item.EndDate < new Date()">
                        <td align="center">
                            {{item.No}}
                        </td>
                        <td align="left">
                            <a href="javascript:void(0)" ms-click="doview(item.Id)" title="查看详情">{{item.ProductName|truncate(26)}}</a>
                            &nbsp;
                            <a ms-if="item.Product" href="javascript:void(0);" class="productbtn"  ms-click="viewProduct(item.Product)" title="查看产品"></a>
                        </td>
                        <td align="left">
                            {{item.ProductAlias}}
                        </td> 
                        <td align="center">
                           <a ms-click="contractdoview(item.Contract)" href="javascript:void(0);"> {{item.ContractNum}}</a> 
                        </td> 
                        <td align="right">
                            {{item.StandardPrice}}
                        </td>
                        <td align="right">
                            {{item.Price}}
                        </td>
                        <td align="right">
                            {{item.Num}}{{item.UnitDisplay}}
                        </td>
                        <td align="right">
                            {{item.Money}}
                        </td>
                        <td align="center">
                            {{item.ReturnAmount|payStateIcon(item.Money)|html}}
                        </td>
                        <td align="center">
                            <a href="javascript:void(0);" class="doview" title="详细"  ms-click="doview(item.Id)"></a>
                            <a href="javascript:void(0);" ms-if="item.EDIT" class="doedit" title="编辑" ms-click="doedit(item.Id)"></a>
                            <a href="javascript:void(0);" ms-if="!item.EDIT" title="非常抱歉，您没有编辑的权限"  class="noedit"></a>
                            <a href="javascript:void(0);" ms-if="ACCOUNTING" class="dopayment" title="收款" ms-click="doReceipts(item)"></a>
                            <a ms-if="item.DELETE" href="javascript:void(0)" class="dodel" ms-click="dodel" ms-value="item.Id" ms-attr-index="$index" ms-title="lang.DelBtn"></a>
                        </td>
                    </tr> 
                    <tr ms-if="grid1.gridmsg">
                        <td colspan="10" class="gridmsg">{{grid1.gridmsg|html}}</td>
                    </tr>
                    <tr>
                        <td colspan="7" align="right">
                            合计：
                        </td>
                        <td align="right">{{totalMoney}}</td>
                        <td align="right">{{totalReturnedMoney}}</td>
                        <td>&nbsp;</td> 
                    </tr>
                    <tr>
                        <td colspan="10" ms-widget='paging,upaing,userpaing'></td>
                    </tr> 
                </table>
            </td>
        </tr>
    </tbody>
</table>

<!--新增-->
<noscript id="formTemplate">
    <table width="100%" cellspacing="0" cellpadding="0" border="0" class="commontable">
        <tbody>
            <tr>
                <th style="width:90px;">客户：</th>
                <td style="width:300px;">
                    <input type="text" readonly="readonly" ms-duplex="entity.CustomerName">
                    <button ms-if="!showOnlyList" class="myfbt" type="button" ms-click="selectCustomer"><i class="customer"></i></button>
                </td>
                <th style="width:100px;">归属合同订单：</th>
                <td>
                    <input type="text" readonly="readonly" ms-duplex="entity.ContractNum">
                    <button class="myfbt" type="button" ms-click="selectContract"><i class="customer"></i></button>
                </td>
            </tr>
            <tr>
                <th>商品：</th>
                <td>
                    <input type="text" ms-duplex="entity.ProductName" readonly="readonly" />
                    <button class="myfbt" type="button" ms-click="onSelectProuct" ><i class="customer"></i></button>
                </td>
                <th>品牌：</th>
                <td><input type="text" readonly="readonly" ms-duplex="entity.BrandName"  /></td>
            </tr>
            <tr>
                <th>商品别称：</th>
                <td>
                    <input type="text" ms-duplex="entity.ProductAlias" />
                </td>
                <th>规格/型号：</th>
                <td><input type="text" ms-duplex="entity.Standard" /></td>
            </tr>
            <tr>
                <th>产品单价：</th>
                <td><div class="input-append">
                    <input type="text" style="width:80px;" ms-duplex="entity.StandardPrice" /><span class="add-on">元</span></div>
                </td>
                <th><label> <input type="checkbox" ms-duplex-radio="entity.HasServiceTimeLimit" /> 服务期限：</label> </th>
                <td>
                    <input type="text" style="width:80px;" ms-duplex="entity.StartDate" ms-readonly="!entity.HasServiceTimeLimit" ms-widget='date,startDate,startDateOpts' />
                    <span style="margin-left:-10px;">至</span>
                    <input type="text" style="width:80px;" ms-duplex="entity.EndDate" ms-readonly="!entity.HasServiceTimeLimit" ms-widget='date,endDate,endDateOpts' />
                </td>
            </tr>
            <tr>
                <th>成交单价：</th>
                <td><div class="input-append">
                    <input type="text" style="width:80px;" ms-duplex="entity.Price"  ms-class-1="redbg:entity.Price<entity.LowestPrice" ms-title="entity.PriceTitle" /><span class="add-on">元</span></div>
                </td>
                <th><label> <input type="checkbox" ms-duplex-radio="entity.HasSerialNumber" /> 产品序列号：</label></th>
                <td><input type="text" ms-duplex="entity.SerialNumber" ms-readonly="!entity.HasSerialNumber" /></td>
            </tr>
            <tr>
                <th>数量：</th>
                <td>
                    <input type="text" style="width:80px;" ms-duplex="entity.Num" />
                    <select ms-duplex="entity.Unit"   style="width:80px;" >
                        <option ms-repeat-item="unitsData" ms-value ="item.Id">{{item.Data}}</option>
                    </select>
                </td>
                <th> <label> <input type="checkbox" ms-duplex-radio="entity.HasAccountPwd" /> 账号/密码：</label></th>
                <td>
                    <input type="text" style="width:100px;" ms-duplex="entity.UserName" ms-readonly="!entity.HasAccountPwd" /> / <input type="text" style="width:100px;" ms-duplex="entity.PassWord" ms-readonly="!entity.HasAccountPwd" />
                </td>
            </tr>
            <tr>
                <th>合计金额：</th>
                <td><div class="input-append">
                    <input type="text" style="width:80px;" ms-duplex="entity.Money" /><span class="add-on">元</span>
                    </div>
                </td>
                <th><label><input type="checkbox" ms-duplex-radio="entity.IsUseLimit" /> 用户数限制：</label></th>
                <td><input type="text" style="width:80px;" ms-duplex="entity.UseLimitOfNum"  ms-readonly="!entity.IsUseLimit" /></td>
            </tr>
            <tr>
                <th>要求票据：</th>
                <td>
                    <select style="width: 110px;" ms-duplex="entity.NoteType">
                        <option value="">请选择</option>
                        <option ms-repeat-b="billtypes" ms-value="b.Id">{{b.Data}}</option>
                    </select>
                </td>
                <th>归属业务员：</th>
                <td>
                    <input type="text" ms-duplex="entity.BelongToDisplay" readonly="readonly" style="width: 80px;" />
                    <button type="button" class="myfbt" ms-click="selectBelongTo()"><i class="iadduser"></i></button>
                </td>
            </tr>
            <tr ms-if="PRODUCTSTOCKTPRICE">
                <th>提成基准价：</th>
                <td><div class="input-append">
                    <input type="text" style="width:80px;" ms-duplex="entity.RoyaltyPrice" /><span class="add-on">元</span>
                    </div>
                </td>
                <th>提成金额：</th>
                <td>
                    <div class="input-append">
                    <input type="text" style="width:80px;" ms-duplex="entity.RoyaltyMoney" /><span class="add-on">元</span>
                    </div>
                </td>
            </tr>
            <tr>
                <th>补充说明：</th>
                <td colspan="3">
                    <textarea rows="4" style="width:94%;" ms-duplex="entity.Remark"></textarea>
                </td>
            </tr>
            <tr>
                <th>付款状态：</th>
                <td>
                    {{setContractDetailState(entity.PayState)}}
                    {{entity.ReturnAmount|payStateIcon(entity.Money)|html}}
                </td>
                <th>累计已付：</th>
                <td>{{entity.ReturnAmount}}</td>
            </tr>
            <tr>
                <th>录入人：</th>
                <td><input type="text" readonly="readonly" ms-duplex="entity.AddByName" style="width:120px;"/></td>
                <th>录入时间：</th>
                <td><input type="text" readonly="readonly" ms-duplex="entity.AddTime" ms-widget='date,addTime,addTimeOpts' style="width:120px;"/></td>
            </tr>
        </tbody>
    </table>
</noscript>
<!--新增END-->

<!-- 选择产品 -->
<noscript type="text/avalon" id="ProductListTemp">
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
            <td width="203" height="390" valign="top">
                <table width="96%" border="0" cellpadding="0" cellspacing="0" class="seacrhTable" style="background: none;">
                     <tr>
                        <td valign="top">
                            <div class="boxTitle" style="overflow-y: auto; height: 420px;">
                                <h2>产品分类</h2>
                                 <ul class='ztree' ms-widget="productCategoryTree,pctree,pCategoryTreeOpts"></ul>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
            <td valign="top" style="padding-left:3px; width:800px;">
                <div class="boxTitlenob">
                    <h2>
                        产品列表<span class="rseachbox">
                            <input  ms-duplex="productKey" placeholder="输入产品关键字"  type="text" style="margin-bottom: 0px; font-size:9px; color: #989898;" />
                            <button class="inputbt" type="button"  ms-click="onSearchProduct">
                            </button>
                        </span>
                    </h2>
                </div>
                    <table width="" border="0" cellspacing="1" cellpadding="0" class="tableList productlist" style="width:100%;">
                        <thead>
                            <tr class="head">
                                <td width="3%" align="center">
                                    选择
                                </td>
                                <td width="30%" align="left">
                                    产品名称
                                </td>
                                <td width="20%" align="left">
                                    规格/型号
                                </td>
                                <td width="10%" align="left">
                                    品 牌
                                </td>                                
                                <td width="5%" align="right">
                                    库存量
                                </td>
                                <td width="10%" align="right">
                                    标准价
                                </td>
                                <td width="10%" ms-if="entity.Customer" align="right">
                                    特供价
                                </td>
                                <td ms-if="entity.Customer" align="right">
                                    级别价
                                </td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr ms-repeat-item="productList" title="点击选择产品" ms-click="onSetProductIndex" ms-dblclick="selectedProduct(item)"  ms-class-1="productdown:item.State==2" style="cursor:pointer;">
                                <td>
                                    <input type="radio" name="rdoproduct"/>
                                </td>
                                <td align="left">
                                    {{item.Name|truncate(20,'.')}}
                                </td>
                                 <td align="left">
                                    {{item.Standard}}
                                </td>
                                <td align="left">
                                    {{item.Brand.Name}}
                                </td>
                                <td align="right">
                                    {{item.CurrentStockNum}}
                                </td>
                                <td align="right">
                                    {{item.GeneralCustomerPrice}}
                                </td>
                                <td ms-if="entity.Customer" align="right">
                                    {{item.SpecialPrice}}
                                </td>
                                <td ms-if="entity.Customer"  align="right">
                                    {{item.GradePrice}}
                                </td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr> 
                                <td ms-attr-colspan="entity.Customer?8:6"  ms-widget='paging,productupaing,productpaing'></td>
                            </tr> 
                        </tfoot>
                    </table>
            </td>
        </tr>
    </table>
</noscript>

<noscript id="viewTemplate">
    <table width="100%" cellspacing="1" cellpadding="0" border="0" class="tablecInfo">
        <tbody>
            <tr style="background-color:#fff;">
                <td style="width:100px;">客户：</td>
                <td style="width:300px;">
                    <a href="javascript:void(0)" class="blue" ms-click="gotoview(entity.Customer)" title="点击查看客户详情">{{entity.CustomerName}}</a>
                </td>
                <td style="width:100px;">归属合同订单：</td>
                <td>
                    <a href="javascript:void(0)" class="blue" ms-click="contractdoview(entity.Contract)" title="点击查看合同详情">{{entity.ContractName}}</a>
                </td>
            </tr>
            <tr style="background-color: #fff; ">
                <td class="tRed">商品：</td>
                <td>
                    {{entity.ProductName}}
                    <a ms-if="entity.Product" href="javascript:void(0);" class="productbtn" ms-click="viewProduct(entity.Product)" title="查看产品">&nbsp;</a>
                </td>
                <td>品牌：</td>
                <td>{{entity.BrandDisplay}}</td>
            </tr>
            <tr style="background-color: #fff; ">
                <td>商品别称：</td>
                <td>{{entity.ProductAlias}}</td>
                <td>规格/型号：</td>
                <td>{{entity.Standard}}</td>
            </tr>
            <tr style="background-color: #fff; ">
                <td>产品单价：</td>
                <td>{{entity.StandardPrice}} 元</td>
                <td> 服务期限：</td>
                <td>{{entity.StartDate}} - {{entity.EndDate}}</td>
            </tr>
            <tr style="background-color: #fff; ">
                <td>成交单价：</td>
                <td>{{entity.Price}} 元</td>
                <td>产品序列号：</td>
                <td>{{entity.SerialNumber}}</td>
            </tr>
            <tr style="background-color: #fff; ">
                <td>数量：</td>
                <td>{{entity.Num}}</td>
                <td>账号/密码：</td>
                <td>{{entity.UserName}} / {{entity.PassWord}}</td>
            </tr>
            <tr style="background-color: #fff; ">
                <td class="tRed">成交金额：</td>
                <td><span style="font-size:18px;font-weight:800;">{{entity.Money}}元</span></td>
                <td>用户数限制：</td>
                <td>{{entity.UseLimitOfNum}}</td>
            </tr>
            <tr style="background-color: #fff; ">
                <td>付款状态：</td>
                <td>{{setContractDetailState(entity.PayState)}}</td>
                <td>累计已付：</td>
                <td>{{entity.ReturnAmount}}</td>
            </tr>
            <tr style="background-color: #fff; ">
                <td>补充说明：</td>
                <td colspan="3" style="vertical-align:top;height:100px;">{{entity.Remark}}</td>
            </tr>
            <tr style="background-color: #fff; ">
                <td>录入人：</td>
                <td>{{entity.AddByName}}</td>
                <td>录入时间：</td>
                <td>{{entity.AddTime}}</td>
            </tr>
        </tbody>
    </table>
</noscript>

<!---选择合同业务--->
<noscript id="ContractListTemplate">
    <div class="tabContent2">
        <div class="boxTitlenob">
            <h2>合同订单
         <span class="rseachbox">
             <input ms-duplex="contractKey" placeholder="输入合同名称快速检索" type="text" style="margin-bottom: 3px; font-size: 9px; color: #989898;" />
             <button class="inputbt" type="button" ms-click="cgrid.doSearch">
             </button>
         </span>
            </h2>
        </div>
        <table border="0" cellspacing="1" cellpadding="0" class="tableList productlist" style="width: 100%;">
            <tr class="minhead" align="center">
                <td width="3%">选择</td>
                <td width="10%" align="center">合同编号</td>
                <td width="15%" align="center">合同名称</td>
                <td width="8%" align="center">合同金额</td>
                <td width="8%" align="center">签约日期</td>
                <td width="15%" align="center">合同期限范围</td>
            </tr>
            <tr ms-repeat-item="selContactList" ms-click="selectedContract($index)" style="cursor: pointer;">
                <td align="center">
                    <input name="selectContract" type="radio" ms-attr-index="$index"></td>
                <td align="center">{{item.ContractNum}}</td>
                <td align="center">{{item.ContractName|truncate(18,'...')}}</td>
                <td align="center">{{item.Amount?item.Amount:0}}</td>
                <td align="center">{{item.SignAContractDate|truncate(10,'')}}</td>
                <td align="center">{{item.StartDate|truncate(10,'')}} 至 {{item.EndDate|truncate(10,'')}}</td>
            </tr>
            <tr style="background: #F5F5F7;" ms-if="selContactList.length==0">
                <td colspan="6">抱歉！暂无合同信息</td>
            </tr>
        </table>
    </div>
</noscript>
