<!--
	The ID "widget-grid" will start to initialize all widgets below 
	You do not need to use widgets if you dont want to. Simply remove 
	the <section></section> and you can use wells or panels instead 
	-->

<!-- widget grid -->
<section id="widget-grid" class="">

	<!-- row -->
	<div class="row">

		<!-- NEW WIDGET START -->
		<article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">

			<!-- Widget ID (each widget will need uniqu e ID)-->
			<div class="jarviswidget" id="wid-id-4">
				<!-- widget options:
                usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

                data-widget-colorbutton="false"
                data-widget-editbutton="false"
                data-widget-togglebutton="false"
                data-widget-deletebutton="false"
                data-widget-fullscreenbutton="false"
                data-widget-custombutton="false"
                data-widget-collapsed="true"
                data-widget-sortable="false"

                -->
				<header>
					<span class="widget-icon"> <i class="fa fa-table"></i> </span>
					<h2>合同列表</h2>
				</header>
				<!-- widget div-->
				<div>
					<!-- widget edit box -->
					<div class="jarviswidget-editbox">
						<!-- This area used as dropdown edit box -->
					</div>
					<!-- end widget edit box -->
					<!-- widget content -->
					<div class="widget-body no-padding">
						<div class="dt-toolbar">
							<div class="col-xs-11 col-sm-10">
								<div class="dataTables_filter">
									<label>
										<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
										<input type="search" placeholder="合同编号/名称" data-ng-keyup="getContractList()" ng-model="queryParam.keyword" class="form-control" aria-controls="dt_basic"></label>
								</div>
							</div>
							<div class="col-xs-1 col-sm-2">
								<button class="btn btn-primary" type="button" ui-sref ="contract_create">
									<i class="fa fa-plus"></i>
									新增
								</button>
							</div>
						</div>
						<div class="table-responsive">
							<table class="table table-striped table-condensed table-hover smart-form has-tickbox">
								<thead>
								<tr>
									<th>
										<label class="checkbox">
											<input type="checkbox" name="checkbox-inline">
											<i></i>
										</label>
									</th>
                                    <th width="120">合同编号</th>
                                    <th width="120">合同名称</th>
									<th width="120">签约单位</th>
                                    <th width="120">有效日期</th>
                                    <th width="120">作废</th>
									<th width="80">操作</th>
								</tr>
								</thead>
								<tbody>
								<tr ng-repeat="contract in contractList"  ng-if="contractList.length > 0" ng-mouseenter="show=true" ng-mouseleave="show=false">
									<td>
										<label class="checkbox">
											<input type="checkbox" name="checkbox-inline">
											<i></i>
										</label>
									</td>
                                    <td ng-bind="contract.contractCode"></td>
                                    <td ng-bind="contract.contractName"></td>
                                    <td ng-bind="contract.companyName"></td>
                                    <td>{{contract.beginTime | date: 'yyyy-MM-dd'}} 至 {{contract.endTime | date: 'yyyy-MM-dd'}}</td>
                                    <td><span ng-if="contract.isDel == 0">否</span><span ng-if="contract.isDel == 1">是</span></td>
                                    <td>
                                        <div ng-show="show">
                                            <a ng-show="show" href="javascript:void(0);" data-ng-click="viewContract($index)" title="查看：{{contract.contractName}}">
                                                <span class="fa fa-eye"></span>
                                            </a>
                                            <span> | </span>
                                            <a href="javascript:void(0);" ui-sref="contract_update({id:contract.id})" title="编辑：{{contract.contractName}}">
                                                <span class="fa fa-pencil"></span>
                                            </a>
                                            <span> | </span>
                                            <a href="javascript:void(0);" ng-show="contract.isDel == 0" data-ng-click="removeContract($index)" title="作废：{{contract.contractName}}">
                                                <span class="glyphicon glyphicon-remove-circle"></span>
                                            </a>
                                        </div>
                                    </td>
								</tr>
								<tr ng-if="contractList == null || contractList.length == 0">
									<td colspan="3">
										<div>暂无消息数据</div>
									</td>
								</tr>
								</tbody>
							</table>
						</div>
						<div class="dt-toolbar-footer">
							<div class="col-xs-12 col-sm-12">
								<ug-pagination page-info="pageInfoSetting" ></ug-pagination>
							</div>
						</div>
					</div>
					<!-- end widget content -->
				</div>
				<!-- end widget div -->
			</div>
			<!-- end widget -->

		</article>
		<!-- WIDGET END -->

	</div>

	<!-- end row -->

</section>
<!-- end widget grid -->


<script type="text/ng-template" id="viewContractDetail.html">
    <div class="modal-header">
        <h3 class="modal-title">合同</h3>
    </div>
    <div class="modal-body">
        <div class="widget-body">

            <form class="form-horizontal">
                <div class="form-group">
                    <div class="col-md-12">
                        <label class="control-label col-md-2">合同编号：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="contract.contractCode"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">合同名称：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="contract.contractName"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">签约单位：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="contract.companyName"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">起始日期：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="contract.beginTime  | date: 'yyyy-MM-dd'"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">截止日期：</label>
                        <div class="col-md-4">
                            <label class="control-label" ng-bind="contract.endTime  | date: 'yyyy-MM-dd'"></label>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <label class="control-label col-md-2">已优惠产品：</label>
                        <div class="table-responsive col-md-10" style="padding-top: 10px;">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>产品编号</th>
                                    <th>名称</th>
                                    <th class="text-align-right">单价</th>
                                    <th class="text-align-right">优惠方式</th>
                                    <th class="text-align-right">折扣</th>
                                    <th class="text-align-right">优惠后金额</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="choseItem in choseItemList">
                                    <td>{{choseItem.itemCode}}</td>
                                    <td>{{choseItem.itemName}}</td>
                                    <td class="text-align-right">{{choseItem.sellPrice | number:2}}</td>
                                    <td class="text-align-right">{{choseItem.contractTypeName}}</td>
                                    <td class="text-align-right">{{choseItem.discountText}}</td>
                                    <td class="text-align-right"  ng-class="{'vaild':choseItem.contractValue > choseItem.sellPrice}" >{{choseItem.contractValue | number:2}}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-warning" ng-click="cancel()">关闭</button>
    </div>
</script>