<table border="0" align="center" cellpadding="0" cellspacing="0" id="mian" ms-controller="marketingmaterialscouponuse">
    <tbody>
        <tr>
            <!--leftNav-->
            <td width="198" height="450" valign="top" id="tdleft">
                <div id="left" ms-widget="materialsGiftMenu">
                </div>
                <!--End leftNav-->
            </td>
            <td valign="top" id="right" class="addrightbg">
                <div class="boxtip" id="boxtip">
                    <h1>优惠劵领用</h1>
                    <p>列出优惠劵领用，方便平时的维护和管理</p>
                    <a href="javascript:history.go(-1)" class="btn_back"></a>
                </div>
                <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 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>
                <!--<div class="boxTitlenob">
                    <h2>优惠劵领用列表</h2>
                </div>-->
                <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tableList bottom10" id="tableList">
                    <thead>
                        <tr class="dobtn" style="background-color: rgb(255, 255, 255);">
                            <td colspan="9">
                                <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: rgb(250, 250, 250);">
                            <td width="3%" align="center">
                                <input type="checkbox" class="checkAll">
                            </td>
                            <td width="27%" align="center">优惠券
                            </td>
                            <td width="5%" align="center">数量
                            </td>
                            <td width="30%" align="center">对应客户
                            </td>
                            <td width="10%" align="center">领用人
                            </td>
                            <td width="15%" align="center">领用时间
                            </td>
                            <td width="10%" align="center">操作
                            </td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ms-repeat-item="materialscouponuseList" style="background-color: rgb(255, 255, 255);">
                            <td align="center">
                                <input type="checkbox" name="checkbox" ms-value="item.Id">
                            </td>
                            <td align="left">
                                <a ms-href="'#/Market/MaterialsCoupon/'+item.CouponId">{{item.CouponDisplay}}</a>
                            </td>
                            <td align="center">{{item.Num}}
                            </td>
                            <td align="left">
                                <a ms-href="'#/Customer/DetailCustomer/'+item.CustomerId">{{item.CustomerDisplay}}</a>
                            </td>
                            <td align="center">{{item.UserDisplay}}
                            </td>
                            <td align="center">{{item.UseTime}}
                            </td>
                            <td align="center">
                                <a href="javascript:void(0)" class="doview" ms-click="doview" ms-value="item.Id" ms-title="lang.ViewBtn"></a>
                                <a ms-if="item.EDIT" href="javascript:void(0)" class="doedit" ms-click="doedit" ms-value="item.Id" 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-click="dodel" ms-attr-index="$index" ms-value="item.Id" 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>
                            <td colspan="9" ms-widget='paging,upaing,materialscouponusepaing'></td>
                        </tr>
                    </tfoot>
                </table>
            </td>
        </tr>
    </tbody>
</table>

<!--新增或修改--->
<noscript type="text/avalon" id="formTemplateCouponUse">
    <div style="padding:10px;">
    <table cellspacing="0" cellpadding="0" width="100%" border="0" class="commontable">
        <tbody>
            <tr>
                <th width="80">优惠劵：
                </th>
                <td width="310" align="left">
                    <input ms-duplex="entity.CouponId" type="hidden">
                    <input ms-duplex="entity.CouponDisplay" type="text" readonly="readonly">
                    <button class="myfbt" ms-click="selectCoupon" type="button"><i class="customer"></i></button>
                    <span class="must">*</span>
                    <div ms-visible="couponPanel" class="dropdownPanel" style="width: 510px; display: none; position: absolute;" ms-mousedown="mousedownstop">
                        <div>
                            <div class="boxTitlenob" style="margin-left: 0;">
                                <h2>
                                    <span class="rseachbox">
                                        <input style="margin-bottom: 0px;" ms-duplex="couponKey" type="text">
                                        <button type="button" class="inputbt" ms-click="searchCoupon">
                                        </button>
                                    </span>
                                    <span style="float: right">
                                        <button type="button" ms-click="closeCouponPanel">{{lang.Close}}</button>
                                    </span>
                                </h2>
                            </div>
                            <div style="height: 200px; overflow: auto; background-color: rgb(255, 255, 255);">
                                <table width="100%" align="center" border="0" cellspacing="1" cellpadding="0" class="tableList">
                                    <thead>
                                        <tr class="head">
                                            <td width="10%" align="center">优惠劵编号</td>
                                            <td width="18%" align="center">优惠劵名称</td>
                                            <td width="20%" align="center">优惠方式</td>
                                            <td width="10%" align="center">库存量</td>
                                            <td width="10%" align="center">兑换积分</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ms-repeat-item="couponList" style="background-color: rgb(255, 255, 255); cursor: pointer;" ms-live-click="clickCoupon" ms-attr-key="item.Id" ms-attr-alt="item.CouponName" title="点击选择">
                                            <td align="center">{{item.CouponNumber}}
                                            </td>
                                            <td align="center">{{item.CouponName}}
                                            </td>
                                            <td align="center">
                                                <label>{{item.CouponTypeDisplay}}</label><label ms-if="item.CouponType+''=='1'">:{{item.CouponVal}}元</label><label ms-if="item.CouponType+''=='2'">:{{item.CouponRatio}}%</label>
                                            </td>
                                            <td align="center">{{item.Stock}}
                                            </td>
                                            <td align="center">{{item.Integral}}
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </td>
                <th width="80">数量：
                </th>
                <td align="left">
                    <input ms-duplex="entity.Num" type="text" style="width: 120px;"><span class="must">*</span>
                </td>
            </tr>
            <tr>
                <th>领用人：
                </th>
                <td align="left">
                    <input type="hidden" ms-duplex="entity.User_Id" />
                    <input type="text" ms-duplex="entity.UserDisplay" readonly="readonly" />
                    <button type="button" class="myfbt" ms-click="selectUser()"><i class="iadduser"></i></button>
                </td>
                <th>领用时间：
                </th>
                <td align="left">
                    <input type="text" ms-duplex="entity.UseTime" ms-widget="date,usertimeId,usertimeOpts" readonly="readonly" style="width: 120px;" />
                </td>
            </tr>
            <tr>
                <th align="left">对应客户：
                </th>
                <td>
                    <input type="hidden" ms-duplex="entity.CustomerId" />
                    <input ms-duplex="entity.CustomerDisplay" type="text" readonly="readonly">
                    <button ms-click="selectCustomer()" class="myfbt" type="button">
                        <i class="customer"></i>
                    </button>
                </td>
                <th>联系人：</th>
                <td>
                    <input type="hidden" ms-duplex="entity.ContactId" />
                    <input ms-duplex="entity.ContactDisplay" type="text" readonly="readonly" style="width: 120px;">
                    <span class="must">*</span>
                </td>
            </tr>
            <tr>
                <th>用途：
                </th>
                <td width="*" align="left" colspan="3">
                    <textarea ms-duplex="entity.UseOfConditions" rows="2" cols="20" style="height: 100px; width: 94%"></textarea>
                </td>
            </tr>
        </tbody>
    </table>

    </div>
</noscript>

<!--查看-->
<noscript type="text/avalon" id="viewTemplateCouponUse">
    <table width="98%" cellspacing="1" cellpadding="0" border="0" class="tablecInfo">
        <tbody>
            <tr>
                <td>优惠券：
                </td>
                <td height="25" width="*" align="left">{{entity.CouponDisplay}}
                </td>
                <td>数量：
                </td>
                <td height="25" width="*" align="left">{{entity.Num}}
                </td>
            </tr>
            <tr>
                <td width="100px">领用人：
                </td>
                <td height="25" width="35%" align="left">{{entity.UserDisplay}}
                </td>
                <td width="100px">领用时间：
                </td>
                <td height="25" align="left" width="35%">{{entity.UseTime | truncate(10,'')}}
                </td>
            </tr>
            <tr>
                <td width="120" align="left">对应客户：
                </td>
                <td>{{entity.CustomerDisplay}}
                </td>
                <td width="120" align="left">联系人：
                </td>
                <td>{{entity.ContactDisplay}} 
                </td>
            </tr>
            <tr>
                <td width="120">用途：
                </td>
                <td height="25" width="*" align="left" colspan="3">
                    <div style="height: 150px; overflow: auto;">{{entity.UseOfConditions}}</div>
                </td>
            </tr>
        </tbody>
    </table>
</noscript>
