<table border="0" align="center" cellpadding="0" cellspacing="0" width="100%" id="mian"  ms-controller="purchases">
    <tbody>
        <tr>
            <td width="198" height="450" valign="top" id="tdleft" style="display: table-cell; ">
                <!--leftNav-->
                <div id="left">
                    <h2>采购管理</h2>
                    <ul>
                        <li class="selected"><a href="#/Product/Purchase" class="sellnewspaper">采购订单</a></li>
                        <li><a href="#/Product/PutStore" class="sellballoon">采购入库</a></li>
                        <li><a href="#/Product/PayPurchase" class="sellbriefcase">采购付款</a></li>
                        <li class="last"><a href="#/Product/ReturnedPurchase" class="selluserbriefcase">采购退货</a></li> 
                    </ul>
                </div>
                <!--End leftNav-->
            </td>
            <td valign="top" width="100%" id="right" class="addrightbg">
                <!--list-->
                 <div style="margin-bottom: 10px; display: block; ">
                <div style="display: block; ">
                <div class="boxtip" id="boxtip">
                    <h1>采购订单</h1>
                    <p>采购订单描述</p>
                    <a href="javascript:history.go(-1)" class="btn_back"></a>
                </div>
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="seacrhTable" id="seacrhTable">
                    <tbody> 
                        <tr>
                            <td width="460" class="searchico">
                                <div class="input-append" style="margin-bottom:10px;">
                                    <input type="text" class="span4"  ms-duplex="keyword" placeholder="输入订单名称或采购员进行快速检索">
                                    <button class="add-on ibtsearch" type="button" id="btnsel" ms-click="search" style="height: 28px; font-size: 12px; padding: 3px 12px;">
                                       {{lang.SearchBtn}} </button>
                                    <button class="add-on ibtsearch clearall" type="button"   ms-click="clear" style="height: 28px; font-size: 12px; padding: 3px 12px;">
                                        {{lang.ShowAllBtn}}</button>
                                </div>
                            </td>
                            <td class="fgray">
                                 <span style="float: left;">{{lang.SearchHistory}}</span><div class="hotlist">
                                    <span class="bindSearchHistory" ms-each-item="history">
                                        <a href="javascript:void(0)" ms-value="item" ms-click="historyClick">{{item}}&nbsp;&nbsp;</a>
                                    </span>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <table width="100%" border="0" cellspacing="0" cellpadding="0" id="seacrhField" class="seacrhField">
                    <tbody>
                        <tr class="quickword">
                            <td colspan="4">
                                <span id="purchasedate">采购时间：</span>
                                <div style="display: inline;">
                                    <a href="javascript:void(0)" ms-click="itemClick" class="selected" value="0" key="purchasedate">不限</a>
                                    <a href="javascript:void(0)" ms-click="itemClick" value="1" key="purchasedate">1个月以内</a>
                                    <a href="javascript:void(0)" ms-click="itemClick" value="3" key="purchasedate">3个月以内</a>
                                    <a href="javascript:void(0)" ms-click="itemClick" value="6" key="purchasedate">6个月以内</a>
                                    <a href="javascript:void(0)" ms-click="itemClick" value="9" key="purchasedate">9个月以内</a>
                                    <a href="javascript:void(0)" ms-click="itemClick" value="12" key="purchasedate">12个月以内</a>
                                    <a href="javascript:void(0)" ms-click="itemClick" value="24" key="purchasedate">24个月以内</a>
                                    <a href="javascript:void(0)" ms-click="itemClick" value="36" key="purchasedate">36个月以内</a>
                                </div>
                            </td>
                        </tr> 
                        <tr>
                           <td colspan="2" class="seabox"><span class="first">{{lang.CurrSearchCondition}}</span>
                                <div style="display: inline;" ms-with="showItem" >
                                    <span class="searchItem" ms-if="$val">{{$val}}<i><a href="javascript:void(0)"  ms-click="remove"></a></i></span>
                                 </div>
                                <span class="last" ms-if="has"><a href="javascript:void(0)" ms-click="clear">{{lang.ClearAll}}</a></span>
                            </td>
                        </tr>
                    </tbody>
                </table>
                </div>
                <!--<div class="boxTitlenob">
                    <h2>采购订单列表</h2>
                </div>-->
                <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tableList" id="tableList">
                    <thead>
                        <tr class="dobtn" style="background-color: rgba(0, 0, 0, 0);">
                            <td colspan="11" bgcolor="#FFFFFF">
                                <a ms-if="ADD" href="javascript:void(0)" class="doadd" ms-click="doadd" >{{lang.AddBtn}}</a>
                                <a ms-if="DELETE" href="javascript:void(0)" class="doalldel" ms-click="doalldel">{{lang.BtachDelBtn}}</a>
                            </td>
                        </tr>
                        <tr class="head" style="background-color: rgba(0, 0, 0, 0);">
                            <td width="3%" align="center">
                                <input type="checkbox" id="cbo_tableList" class="checkAll">
                            </td>
                            <td width="8%" align="center">编号
                            </td>
                            <td width="15%" align="center">订单名称
                            </td> 
                            <td width="10%" align="center">金额
                            </td>
                            <td width="15%" align="center">供应商
                            </td>
                            <td width="5%" align="center">采购员
                            </td>
                            <td width="10%" align="center">采购日期
                            </td>
                             <td width="5%" align="center">金额
                            </td>
                             <td width="5%" align="center">已付金额
                            </td>
                             <td width="5%" align="center">已退金额
                            </td>
                            <td width="6%" align="center">操作
                            </td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ms-repeat-item="purchaseList" style="background-color: rgb(255, 255, 255);">
                            <td align="center">
                                <input type="checkbox" name="checkbox" ms-duplex="item.Id">
                            </td>
                            <td align="left">1405160001
                            </td>
                            <td align="left">服务类
                            </td>
                            <td align="left">
                                <a href="javascript:void(0)">北京CRM</a>
                            </td>
                            <td align="center">执行中
                            </td>
                            <td align="right">125
                            </td>
                            <td align="left">老林代理
                            </td> 
                            <td align="center">100
                            </td>
                            <td align="center"><span style="color:#21d034;">99</span>
                            </td>
                            <td align="center"><span style="color:#ff0000;">1</span>
                            </td>
                            <td align="center">
                                <a href="javascript:void(0)" class="doview" ms-value="item.Id" ms-click="doview" ms-title="lang.ViewBtn"></a>
                                <a ms-if="item.EDIT" href="javascript:void(0)" class="doedit" ms-value="item.Id" ms-click="doedit" ms-title="lang.EditBtn"></a>
                                <a ms-if="!item.EDIT" href="javascript:void(0)" class="noedit"  ms-title="lang.EditBtn"></a>
                                <a ms-if="item.DELETE" href="javascript:void(0)" class="dodel" ms-value="item.Id" ms-attr-index="$index" ms-click="dodel" ms-title="lang.DelBtn"></a>
                                <a ms-if="!item.DELETE" href="javascript:void(0)" class="nodel"  ms-title="lang.DelBtn"></a>
                            </td>
                        </tr> </tbody>
                    <tfoot>
                        <tr style="background-color: rgba(0, 0, 0, 0);">
                           <td colspan="11" ms-widget='paging,upaing,purchasepaing'>
                           </td>
                       </tr>
                    </tfoot>
                </table>
                </div>
               <!--End list--> 
            </td>
        </tr>
    </tbody>
</table>

<!--新增和编辑-->
<noscript type="text/avalon" id="formTemplate">  
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="formTable">
            <tbody><tr>
                <td width="90">
                    订单名称：
                </td>
                <td width="500">  
                     <input type="text" ms-duplex="entity.ContractName"/>
                </td>
                <td width="90">
                    订单编号：
                </td>
                <td width="220">
                    <input type="text" ms-duplex="entity.ContractNum"/>
                </td>
            </tr>
            <tr>
                <td width="90">
                    采购员：
                </td>
                <td>
                     <input type="hidden" ms-duplex="entity.MySignPersion"/>
                     <input type="text" ms-duplex="entity.MySignPersionDisplay" readonly="readonly"/> 
                     <button type="button" class="myfbt" ms-widget="dropDownGroupPostUserTree,signpersionTree,signpersionOpts"><i class="iadduser"></i></button> 
                </td> 
                <td width="90">
                    采购日期：
                </td>
                <td colspan="3">
                      <input type="text" ms-duplex="entity.SignAContractDate" style="width: 125px" readonly="readonly" ms-widget="date,signacontractdateid,signacontractdateOpts" />
                      <span class="must">*</span>
                  </td>
            </tr>
            <tr>
                <td width="90">
                    供应商：
                </td>
                <td>
                    <input type="hidden" ms-duplex="entity.Customer" readonly="readonly"> 
                    <input type="hidden" ms-duplex="entity.CustomerSign" readonly="readonly"> 
                    <input type="text" ms-duplex="entity.CustomerDisplay" readonly="readonly">   
                    <input type="text" ms-duplex="entity.CustomerSignDisplay" style="width: 100px;" readonly="readonly">
                    <button id="btnSelectCustomerContact" class="myfbt" type="button" ms-widget='dropDownCustomerContactsTree,setParetCustomer,pCustomerOpts'>
                          <i class="customer"></i></button> 
                    <span class="must">*</span>
                </td> 
                <td width="90">
                    要求到货日期：
                </td>
                <td colspan="3"> 
                     <input type="hidden" ms-duplex="entity.StartDate"/>
                     <input type="text" ms-duplex="entity.EndDate" style="width: 125px" readonly="readonly" ms-widget="date,contractenddateid,contractenddateOpts"/>
                     <span class="must">*</span>
                </td>
            </tr>
        </tbody></table> 
         <div class="boxTitlenob top10 hasOfferPanel">
                        <h2>
                            <button class="btn btn-mini btn-danger btn_del_row" type="button" ms-click="productDel">
                            - 删除</button>
                        <button class="btn btn-mini btn-primary btn_add_row" type="button" ms-click="productAdd">
                            + 新增</button>产品明细  
                        </h2>
                    </div>
         <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tableList hasOfferPanel">
                        <thead>
                            <tr class="minhead" align="center">
                                <td width="3%">
                                    <input type="checkbox" ms-click="onChkAll">
                                </td>
                                <td width="3%">序号
                                </td>
                                <td width="30%">产品名称
                                </td>  
                                <td width="15%">规格/型号
                                </td>
                                <td width="8%">单位
                                </td>
                                <td width="8%">单价
                                </td>
                                <td width="8%">数量
                                </td>
                                <td width="8%">金额
                                </td> 
                            </tr>
                        </thead>
                        <tbody>
                            <tr ms-repeat-item="productList" align="center" style="background-color: rgb(255, 255, 255); " ms-live-click="onSetIndex">
                                <td align="center">
                                    <input type="checkbox" name="chkproduct" ms-value="item.Id" ms-attr-index="$index">
                                </td>
                                <td>
                                   {{($index+1)}}
                                </td>
                                <td> 
                                    <input type="text" ms-duplex="item.ProductName" readonly="readonly" style="width:160px;"/>
                                    <input type="hidden" ms-duplex="item.Product" />
                                    <button type="button" ms-attr-index="$index" class="myfbt" ms-widget="dropDownProduct,productListId,productListOpts"><i class="customer"></i></button>
                               </td>  
                                <td>
                                    <input type="text" ms-duplex="item.Standard" readonly="readonly" style="width:90%;"/>
                                </td>
                                <td>
                                    <input type="hidden" ms-duplex="item.Units" />
                                    <input type="text" ms-duplex="item.UnitsDisplay" style="width:60px;" readonly="readonly"/>
                                </td>
                                <td>
                                    <input type="text" ms-duplex="item.Price" style="width:60px;" ms-blur="onSumCost"/>
                                </td>
                                <td>
                                    <input type="text" ms-duplex="item.Num" style="width:60px;" ms-blur="onSumCost"/>
                                </td>
                                <td>
                                    <input type="text" ms-duplex="item.Money" readonly="readonly" style="width:60px;"/>
                                </td>
                            </tr> 
                        </tbody>
                        <tfoot class="productOfferTotal">
                            <tr style="background-color: rgb(255, 255, 255);">
                                <td colspan="7" align="right">订单金额：
                                </td>
                                <td colspan="1" align="center"><input type="text" style="width:60px;"/>
                                </td>
                            </tr> 
                        </tfoot>
     </table>
     <table width="100%" border="0" cellspacing="0" cellpadding="0" class="formTable top10">
            <tbody>  
            <tr>
                <td width="90">
                    备注：
                </td>
                <td colspan="3">
                      <input type="text" style="width:98%" ms-duplex="entity.Remark"/> 
                </td>
            </tr>
            <tr>
                <td width="90">
                    录入人：
                </td>
                <td width="500">
                    <input type="text" ms-value="entity.AddBy.FullName" readonly="readonly" style="width:100px;" />
                </td> 
                <td width="90">
                    录入时间：
                </td>
                <td width="220"> 
                     <input type="text" ms-value="entity.AddTime" readonly="readonly" style="width:100px;" /> 
                </td>
            </tr>
        </tbody></table> 
</noscript>
<!--查看-->
<noscript type="text/avalon" id="viewTemplate"> 
        <table width="100%"  border="0" cellspacing="1" cellpadding="0" class="tablecInfo">
            <tbody><tr>
                <td width="100">
                    {{lang.BelongToCampaign}}：
                </td>
                <td width="300">
                    {{entity.MarketingCampaignDisplay}}
                </td>
                <td width="100">
                    {{lang.BelongToActivity}}：
                </td>
                <td width="300">
                    {{entity.MarketActivityDisplay}}
                </td>
            </tr> <tr>
                <td width="100">
                    {{lang.ProbeFeedbackPerson}}：
                </td>
                <td width="300">
                     {{entity.ProbeFeedbackPersonDisplay}}
                </td>
                <td width="100">
                    {{lang.ProbeType}}：
                </td>
                <td width="300">
                    {{entity.ProbeTypeDisplay}}
                </td>
            </tr>
            <tr>
                <td width="90">
                    {{lang.Theme}}：
                </td>
                <td colspan="3">
                    {{entity.Title}}
                </td>
            </tr>
            <tr>
                <td width="90">
                    {{lang.ShareTo}}：
                </td>
                <td colspan="3">
                    {{entity.ShareToDisplay}}
                </td>
            </tr>
            <tr>
                <td width="90">
                    {{lang.ProbeAndVerdict}}：
                </td>
                <td colspan="3">
                    {{entity.ProbeDescribe}}
                </td>
            </tr>
            <tr>
                <td width="90">
                    {{lang.ProbeAttachment}}：
                </td>
                <td colspan="3"> 
                     {{entity.Files}}
                </td>
            </tr>
            <tr>
                    <td>
                        {{lang.AddByDisplay}}
                    </td>
                    <td> 
                        {{entity.AddBy.FullName}}
                    </td>
                    <td>
                        {{lang.AddTime}}
                    </td>
                    <td>
                        {{entity.AddTime|truncate(10,'')}}
                    </td>
                </tr>
            </tbody></table>  
</noscript>
