<div ms-controller="financialaffairsbill">
    <table border="0" align="center" cellpadding="0" cellspacing="0" id="nobgmian">
        <tbody>
            <tr ms-visible="action=='list'">
                <td valign="top">
                    <div class="boxTitle">
                        <h2>票据检索</h2>
                        <div style="padding-left: 20px;">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="seacrhTable" id="seacrhTable">
                                <tbody>
                                    <tr>
                                        <td width="440" 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;">
                                                    搜索
                                                </button>
                                                <button class="add-on ibtsearch clearall" type="button" ms-click="clear" style="height: 28px; font-size: 12px; padding: 3px 12px;">
                                                    显示全部</button>
                                            </div>
                                        </td>
                                        <td class="fgray">
                                            <span style="float: left;">历史搜索</span><div class="hotlist">
                                                <span class="bindSearchHistory" ms-repeat-item="history">
                                                    <a href="javascript:void(0)" ms-value="item" ms-click="historyClick">{{item}}</a>
                                                </span>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <table width="100%" border="0" cellspacing="0" cellpadding="0" id="Table1" class="seacrhField">
                                <tbody>
                                    <tr class="quickword">
                                        <td>
                                            <span id="billtype">票据类型</span>
                                            <div style="display: inline;">
                                                <a href="javascript:void(0)" class="selected" ms-click="itemClick" value="0" key="billtype">不限</a>
                                                <a href="javascript:void(0)" ms-repeat-item="billTypeData" ms-click="itemClick" ms-value="item.Id" key="billtype">{{item.Data}}</a>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="seabox"><span class="first">筛选条件：</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">全部清除</a></span>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <!--<div class="boxTitlenob" style="margin-top: 10px;"><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">新增</a>
                                    <a ms-if="DELETE" href="javascript:void(0)" class="doalldel" ms-click="doalldel">批量删除</a>
                                </td>
                            </tr>
                            <tr class="head" style="background-color: rgba(0, 0, 0, 0);">
                                <td width="3%" align="center">
                                    <input type="checkbox" class="checkAll"></td>
                                <td width="6%" align="center">类型</td>
                                <td width="6%" align="center">编号</td>
                                <td width="6%" align="center">票据金额</td>
                                <td width="6%" align="center">实收金额</td>
                                <td width="6%" align="center">是否回款</td>
                                <td width="10%" align="center">对应合同订单</td>
                                <td width="10%" align="center">往来客户</td>
                                <td width="10%" align="center">备注说明</td>
                                <td width="8%" align="center">开票时间</td>
                                <td width="10%" align="center">操作</td>
                            </tr>
                        </thead>
                        <tbody ms-repeat-item="billList">
                            <tr style="background-color: rgb(255, 255, 255);">
                                <td align="center">
                                    <input type="checkbox" name="checkbox" ms-value="item.Id">
                                </td>
                                <td align="center">{{item.BillTypeDisplay}}</td>
                                <td align="center"><a href="javascript:void(0)" ms-click="doview" ms-value="item.Id">{{item.BillCode}}</a></td>
                                <td align="center">{{item.Amount1}}
                                </td>
                                <td align="center">{{item.Amount2}}
                                </td>
                                <td align="center"><span ms-if="item.IsPay" style="color: green;">已回款</span><span ms-if="!item.IsPay" style="color: red;">未回款</span></td>
                                <td align="center"><a ms-href="'#/Market/Contract/'+item.Contract+'/view'">{{item.ContractNum}}</a></td>
                                <td align="left"><a ms-href="'#/Customer/DetailCustomer/'+item.CustomId">{{item.CustomName | truncate(20,'...')}}</a></td>
                                <td align="left">{{item.Project}}</td>
                                <td align="center">{{item.CreateDate}}</td>
                                <td align="center">
                                    <a href="javascript:void(0)" class="doview" ms-click="doview" ms-value="item.Id" title="查看详细"></a>
                                    <a ms-if="item.EDIT" href="javascript:void(0)" class="doedit" ms-click="doedit" ms-value="item.Id" title="编辑"></a>
                                    <a ms-if="!item.EDIT" href="javascript:void(0)" class="noedit" title="非常抱歉，您没有编辑的权限"></a>
                                    <a ms-if="item.DELETE" href="javascript:void(0)" class="dodel" ms-click="dodel" ms-attr-index="$index" ms-value="item.Id" title="删除"></a>
                                    <a ms-if="!item.DELETE" href="javascript:void(0)" class="nodel" title="非常抱歉，您没有删除的权限"></a>
                                </td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr style="background: #fff;">
                                <td colspan="3" align="right">合计：</td>
                                <td colspan="8">
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr style="background: #fff;">
                                            <td align="center" width="9%">{{TotalAmount1}}</td>
                                            <td align="center" width="9%">{{TotalAmount2}}</td>
                                            <td align="center" colspan="6" width="82%">&nbsp;</td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr style="background-color: rgba(0, 0, 0, 0);">
                                <td colspan="11" ms-widget='paging,upaing,billpaing'></td>
                            </tr>
                        </tfoot>
                    </table>
                </td>
            </tr>
        </tbody>
    </table>


    <!----新增和编辑---->
    <noscript id="formTemplate">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="formTable">
            <tbody>
                <tr>
                    <td>合同订单：</td>
                    <td>
                        <input type="text" readonly="readonly" ms-duplex="entity.ContractNum">
                        <button class="myfbt" type="button" ms-click="selectContract"><i class="customer"></i></button>
                    </td>
                    <td>对应收款：</td>
                    <td>
                        <input type="hidden" ms-duplex="entity.IsReceipts" />
                        <input type="text" readonly="readonly" ms-duplex="entity.ReceiptsBillDisplay">
                        <button class="myfbt" type="button" ms-click="selectReceipts"><i class="customer"></i></button>
                    </td>
                </tr>
                <tr>
                    <td width="80">票据类型：
                    </td>
                    <td width="360">
                        <select ms-duplex="entity.BillType">
                            <option ms-repeat-item="billTypeData" ms-value="item.Id">{{item.Data}}</option>
                        </select>
                        <span class="must">*</span>
                    </td>
                    <td width="80">票据编号：
                    </td>
                    <td>
                        <input placeholder="请输入真实票据编号" type="text" ms-duplex="entity.BillCode"><span class="must">*</span>
                    </td>
                </tr>
                <tr>
                    <td>票据金额： </td>
                    <td>
                        <div class="input-append">
                            <input type="text" ms-duplex="entity.Amount1" style="width: 80px" onblur="amount2.value=this.value">
                            <span class="add-on">元</span>
                        </div>
                        <span class="helptip"><a href="#" data-toggle="tooltip" data-placement="top" title="开票中票面所填金额">&nbsp;&nbsp; </a></span>
                    </td>
                    <td>实收金额：</td>
                    <td>
                        <div class="input-append">
                            <input type="text" ms-duplex="entity.Amount2" style="width: 80px" id="amount2">
                            <span class="add-on">元</span>
                        </div>
                        <span class="helptip"><a href="#" data-toggle="tooltip" data-placement="top" title="财务实际入账金额">&nbsp;&nbsp; </a></span>
                    </td>
                </tr>
                <tr>
                    <td width="70">备注说明：
                    </td>
                    <td colspan="3">
                        <input type="text" ms-duplex="entity.Project" style="width: 646px;">
                    </td>
                </tr>
                <tr>
                    <td width="70">是否回款：
                    </td>
                    <td colspan="3">
                        <label>
                            <input type="radio" name="IsPay" ms-duplex-text="entity.IsPay" value="false" /><span style="color: red;">未回款</span>&nbsp;</label>
                        <label>
                            <input type="radio" name="IsPay" ms-duplex-text="entity.IsPay" value="true" /><span style="color: green;">已回款</span></label>
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="padding-top: 10px;">
                        <label>
                            <input type="checkbox" ms-duplex-radio="entity.IsBillProject" />填写票据明细</label>
                    </td>
                </tr>
                <tr ms-visible="entity.IsBillProject">
                    <td colspan="4">
                        <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tableList hasOfferPanel" style="margin-bottom: 10px;">
                            <tr class="minhead" align="center" style="background-color: rgba(0, 0, 0, 0);">
                                <td width="20%" align="center">货品或劳务等项目名称
                                </td>
                                <td width="8%" align="center">规格型号
                                </td>
                                <td width="8%" align="center">单位
                                </td>
                                <td width="8%" align="center">单价
                                </td>
                                <td width="8%" align="center">数量
                                </td>
                                <td width="8%" align="center">金额
                                </td>
                                <td width="8%" align="center">税率
                                </td>
                                <td width="8%" align="center">税额
                                </td>
                                <td width="2%" align="center">操作</td>
                            </tr>
                            <tr ms-repeat-item="billProjectList" align="center" style="background-color: rgb(255, 255, 255);">
                                <td>
                                    <input type="text" ms-duplex="item.PrejectName" style="width: 120px;">
                                </td>
                                <td>
                                    <input type="text" ms-duplex="item.Standard" style="width: 100px;">
                                </td>
                                <td>
                                    <select ms-duplex="item.Unit" style="width: 50px;">
                                        <option ms-repeat-dict="unitData" ms-value="dict.Id">{{dict.Data}}</option>
                                    </select>
                                </td>
                                <td>
                                    <input type="text" ms-duplex="item.Price" ms-blur="setAmt" style="width: 60px;">
                                </td>
                                <td>
                                    <input type="text" ms-duplex="item.Number" ms-blur="setAmt" style="width: 60px;">
                                </td>
                                <td>
                                    <input type="text" ms-duplex="item.Amount" style="width: 60px;">
                                </td>
                                <td>
                                    <div class="input-append">
                                        <input type="text" ms-duplex="item.TaxRate" ms-blur="setAmt" style="width: 30px;">
                                        <span class="add-on">%</span>
                                    </div>
                                </td>
                                <td>
                                    <input type="text" ms-duplex="item.TaxAmt" style="width: 60px;">
                                </td>
                                <td>
                                    <a href="javascript:void(0)" class="dodel" ms-attr-index="$index" ms-click="doBillProjectDel" title="删除"></a>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="9"><a href="javascript:void(0)" ms-click="doBillProjectAdd">&nbsp;+&nbsp;新增一行</a></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>客户名称：
                    </td>
                    <td>
                        <input type="text" ms-duplex="entity.CustomName">
                        <button id="Button1" class="myfbt" type="button" ms-click='selectCustomer()'>
                            <i class="customer"></i>
                        </button>
                    </td>
                    <td>联系人：
                    </td>
                    <td>
                        <input type="text" ms-duplex="entity.CustomMan" style="width: 100px">
                        <select style="width: 100px" ms-change="customerContactsChange">
                            <option value="">请选择</option>
                            <option ms-repeat-con="customerContactData" ms-value="con.Id">{{con.Name}}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>客户电话：</td>
                    <td>
                        <input type="text" ms-duplex="entity.Telphone">
                    </td>
                    <td>客户地址：
                    </td>
                    <td>
                        <input type="text" ms-duplex="entity.Address">
                    </td>
                </tr>
                <tr>
                    <td>开票人：
                    </td>
                    <td>
                        <input type="text" ms-duplex="entity.Creator" style="width: 120px">
                        <span class="must">*</span>
                    </td>
                    <td>开票时间：
                    </td>
                    <td>
                        <input type="text" ms-duplex="entity.CreateDate" ms-widget="date,createdateId,createdateOpts" readonly="readonly" style="width: 109px"><span class="must">*</span>
                    </td>
                </tr>
            </tbody>
        </table>
    </noscript>

    <!----查看---->
    <noscript id="viewTemplate">
        <table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#D2D2D2" class="tablecInfo">
            <tr>
                <td>合同订单：</td>
                <td>{{entity.ContractNum}} 
                </td>
                <td>对应收款单：</td>
                <td>{{entity.ReceiptsBillDisplay}}
                </td>
            </tr>
            <tr>
                <td width="90">票据类型：
                </td>
                <td width="350">{{entity.BillTypeDisplay}}
                </td>
                <td width="90">票据编号：
                </td>
                <td width="350">{{entity.BillCode}}
                </td>
            </tr>
            <tr>
                <td>票据金额： </td>
                <td>{{entity.Amount1}}元
                </td>
                <td>实收金额：</td>
                <td>{{entity.Amount2}}元
                </td>
            </tr>
            <tr>
                <td>备注说明：
                </td>
                <td colspan="3">{{entity.Project}}
                </td>
            </tr>
            <tr>
                <td>是否回款：
                </td>
                <td colspan="3">{{entity.IsPay?'已回款':'未回款'}}
                </td>
            </tr>
            <tr ms-visible="entity.IsBillProject">
                <td colspan="4" style="padding: 0;">
                    <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tableList hasOfferPanel">
                        <tr class="minhead" align="center" style="background-color: rgba(0, 0, 0, 0);">
                            <td width="20%" align="center">货品或劳务等项目名称
                            </td>
                            <td width="8%" align="center">规格型号
                            </td>
                            <td width="8%" align="center">单位
                            </td>
                            <td width="8%" align="center">单价
                            </td>
                            <td width="8%" align="center">数量
                            </td>
                            <td width="8%" align="center">金额
                            </td>
                            <td width="8%" align="center">税率
                            </td>
                            <td width="8%" align="center">税额
                            </td>
                        </tr>
                        <tr ms-repeat-item="billProjectList" align="center" style="background-color: rgb(255, 255, 255);">
                            <td>{{item.PrejectName | truncate(20,'...')}}
                            </td>
                            <td>{{item.Standard}}
                            </td>
                            <td>{{item.UnitsDisplay}}
                            </td>
                            <td>{{item.Price}}
                            </td>
                            <td>{{item.Number}}
                            </td>
                            <td>{{item.Amount}}
                            </td>
                            <td>{{item.TaxRate}}% 
                            </td>
                            <td>{{item.TaxAmt}}
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>客户名称：
                </td>
                <td>{{entity.CustomName}}
                </td>
                <td>联系人：
                </td>
                <td>{{entity.CustomMan}}
                </td>
            </tr>
            <tr>
                <td>客户电话：</td>
                <td>{{entity.Telphone}}
                </td>
                <td>客户地址：
                </td>
                <td>{{entity.Address}}
                </td>
            </tr>
            <tr>
                <td>开票人：
                </td>
                <td>{{entity.Creator}}
                </td>
                <td>开票时间：
                </td>
                <td>{{entity.CreateDate}}
                </td>
            </tr>
        </table>
    </noscript>

    <!---选择合同业务明细--->
    <noscript id="ContractListTemplate">
        <div style="height: 400px; overflow-y: scroll; margin: 0 10px;">
            <div class="boxTitlenob">
                <h2>合同订单
         <span class="rseachbox">
             <input placeholder="输入合同名称快速检索" type="text" style="margin-bottom: 3px; font-size: 9px; color: #989898;" />
             <button class="inputbt" type="button">
             </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="selContractList" ms-live-click="selectedContract" ms-live-dblclick="setContractVal" ms-attr-contractid="item.Id" 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="right">{{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="selContractList.length==0">
                    <td colspan="6">抱歉！暂无合同信息</td>
                </tr>
            </table>
        </div>
    </noscript>


    <!---选择收款单--->
    <noscript id="ReceiptsListTemplate">
        <div>
            <ul class="tabWarp">
                <li ms-class-hover="rbtab=='tab1'" ms-class-normal="rbtab!='tab1'" val="tab1" ms-click="rbtabChange">收款单</li>
                <li ms-class-hover="rbtab=='tab2'" ms-class-normal="rbtab!='tab2'" val="tab2" ms-click="rbtabChange">收款明细</li>
            </ul>
        </div>
        <div class="tabContent" ms-visible="rbtab=='tab1'">
            <div style="height: 400px; overflow-y: scroll;">
                <table border="0" cellspacing="1" cellpadding="0" class="tableList productlist">
                    <tr class="minhead" align="center">
                        <td width="4%">选择</td>
                        <td width="10%" align="center">收款单号</td>
                        <td width="10%" align="center">合同订单</td>
                        <td width="10%" align="center">收款金额</td>
                        <td width="10%" align="center">业务员</td>
                        <td width="8%" align="center">收款人</td>
                        <td width="8%" align="center">收款时间</td>
                    </tr>
                    <tr ms-repeat-item="selReceiptsList" ms-live-click="selectedReceipts" ms-live-dblclick="setReceiptsVal" style="cursor: pointer;">
                        <td align="center">
                            <input type="radio" name="selectReceipts" ms-value="item.Id" ms-attr-index="$index"></td>
                        <td align="center">{{item.No}}</td>
                        <td align="center">{{item.ContractNum}}</td>
                        <td align="center">{{item.Amount}}</td>
                        <td align="center">{{item.Salesman}}</td>
                        <td align="center">{{item.Receiptman}}</td>
                        <td align="center">{{item.Receiptdate}}</td>
                    </tr>
                    <tr style="background: #F5F5F7;" ms-if="selReceiptsList.length==0">
                        <td colspan="7">抱歉！暂无收款单信息</td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="tabContent" ms-visible="rbtab=='tab2'">
            <div style="height: 400px; overflow-y: scroll;">
                <table border="0" cellspacing="1" cellpadding="0" class="tableList productlist" style="width: 760px;">
                    <tr class="minhead" align="center">
                        <td width="5%">选择</td>
                        <td width="5%">编号</td>
                        <td width="20%" align="center">产品名称</td>
                        <td width="15%" align="center">产品别称</td>
                        <td width="10%" align="center">规格/型号</td>
                        <td width="6%" align="center">成交单价</td>
                        <td width="7%" align="center">数量</td>
                        <td width="6%" align="center">单位</td>
                        <td width="8%" align="center">金额</td>
                    </tr>
                    <tr ms-repeat-product="selProductList" ms-live-click="selectedReceipts" ms-live-dblclick="setReceiptsVal" style="cursor: pointer;" ms-attr-val="product.PayState" ms-title="product.PayState==2?'已付清':''">
                        <td style="text-align: center;">
                            <input type="radio" ms-value="product.Id" name="selectProduct" ms-attr-index="$index">
                        </td>
                        <td style="text-align: center;">{{product.No}}</td>
                        <td>{{product.ProductDisplay|truncate(20,'...')}}</td>
                        <td>{{product.ProductAlias}}</td>
                        <td>{{product.ProductStandard}}</td>
                        <td style="text-align: center;">{{product.ProductPrice}}</td>
                        <td style="text-align: center;">{{product.ProductNum}}</td>
                        <td style="text-align: center;">{{product.UnitsDisplay}}</td>
                        <td style="text-align: right;">{{product.Amount}}元</td>
                    </tr>
                    <tr style="background: #F5F5F7;" ms-if="selProductList.length==0">
                        <td colspan="9">抱歉！暂无收款明细信息</td>
                    </tr>
                </table>
            </div>
        </div>
    </noscript>

</div>
