<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page isELIgnored="false"%>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>客户管理管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
            $("#cus_name").show();
            $("#cus_name").siblings().hide();
            //搜索框收放
            $('#moresee').click(function(){
                if($('#moresees').is(':visible'))
                {
                    $('#moresees').slideUp(0,resizeListWindow1);
                    $('#moresee i').removeClass("glyphicon glyphicon-menu-up").addClass("glyphicon glyphicon-menu-down");
                }else{
                    $('#moresees').slideDown(0,resizeListWindow1);
                    $('#moresee i').removeClass("glyphicon glyphicon-menu-down").addClass("glyphicon glyphicon-menu-up");
                }
            });
            laydate.render({
                elem: '#beginDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus', //响应事件。如果没有传入event，则按照默认的click
                type : 'date'
            });
            laydate.render({
                elem: '#endDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus', //响应事件。如果没有传入event，则按照默认的click
                type : 'date'
            });
		});
        function switchInput(obj){
            $("#"+obj).show();
            $("#"+obj).siblings().hide();
        }
        //打开对话框(查看)
        function openDialogNow(title,url,width,height){
            if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端，就使用自适应大小弹窗
                width='auto';
                height='auto';
            }else{//如果是PC端，根据用户设置的width和height显示。

            }
            top.layer.open({
                type: 2,
                area: [width, height],
                title: title,
                maxmin: true, //开启最大化最小化按钮
                content: url ,
                btn: ['关闭'],
                cancel: function(index){
                }
            });
        }
	</script>
	<script type="text/javascript">
        $(function () {
            function openNewWindowTab(url) {
                alert(url);
            }
        })
	</script>
	<style>
		body{
			background-color:transparent;
			filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#26FFFFFF, endColorstr=#26FFFFFF);
			color:#ffffff;
			background-color:rgba(255,255,255,0);
			height:100%;
		}
	</style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
	<sys:message content="${message}"/>
	<div class="layui-row">
		<div class="full-width fl">
			<div class="contentShadow layui-row" id="queryDiv">
				<form:form id="searchForm" modelAttribute="workClientInfo" action="${ctx}/workclientinfo/workClientInfo/list" method="post" class="form-inline">
					<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
					<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
					<%--<table:sortColumn id="orderBy" name="orderBy" value="${page.orderBy}" callback="sortOrRefresh();"/><!-- 支持排序 -->--%>
					<div class="commonQuery lw14">
						<div class="layui-item query athird">
							<label class="layui-form-label">客户名称：</label>
							<div class="layui-input-block">
								<form:input path="name" htmlEscape="false" maxlength="255"  class=" form-control layui-input"/>
							</div>
						</div>
                        <div class="layui-item query athird">
                            <label class="layui-form-label">地区：</label>
                            <div class="layui-input-block with-icon">
                                <sys:treeselect id="area" name="area.id" value="${workClientInfo.area.id}" labelName="area.name" labelValue="${workClientInfo.area.name}"
                                                title="区域" url="/sys/area/treeData" cssClass="form-control layui-input" allowClear="true" notAllowSelectParent="false"/>
                            </div>
                        </div>

						<div class="layui-item athird">
							<div class="input-group">
								<a href="#" id="moresee"><i class="glyphicon glyphicon-menu-down"></i></a>
								<button id="searchReset" class="fixed-btn searchReset fr" onclick="resetSearch()">重置</button>
								<button id="searchQuery" class="fixed-btn searchQuery fr" onclick="search()">查询</button>
							</div>
						</div>
						<div style="    clear:both;"></div>
					</div>
					<div id="moresees" style="clear:both;display:none;" class="lw14">
						<div class="layui-item query athird">
							<label class="layui-form-label">创建时间：</label>
							<div class="layui-input-block">
								<input id="beginDate" placeholder="开始时间" name="beginDate" type="text" readonly="readonly" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
									   value="<fmt:formatDate value="${workClientInfo.beginDate}" pattern="yyyy-MM-dd"/>"/>
								</input>
								<span class="group-sep">-</span>
								<input id="endDate" placeholder="结束时间" name="endDate" type="text" readonly="readonly" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
									   value="<fmt:formatDate value="${workClientInfo.endDate}" pattern="yyyy-MM-dd"/>"/>
								</input>
							</div>
						</div>
						
						<div class="layui-item query athird">
							<label class="layui-form-label">客户性质：</label>
							<div class="layui-input-block">
								<form:select path="companyType"  class="form-control simple-select">
									<form:option value="" label=""/>
									<form:options items="${fns:getMainDictList('company_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
								</form:select>
							</div>
						</div>
						<div class="layui-item query athird">
							<label class="layui-form-label">客户行业：</label>
							<div class="layui-input-block">
                                <form:select path="companyIndustry" class="form-control layui-input">
                                    <form:option value="" label=""/>
                                    <form:options items="${fns:getMainDictList('company_industry')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                </form:select>
							</div>
						</div>
						<div class="layui-item query athird">
							<label class="layui-form-label">客户类型：</label>
							<div class="layui-input-block">
                                <form:select path="clientType" class="form-control layui-input">
                                    <form:option value="" label=""/>
                               		<form:options items="${fns:getMainDictList('client_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                </form:select>
							</div>
						</div>
						<div class="layui-item query athird">
							<label class="layui-form-label">统一社会信用代码：</label>
							<div class="layui-input-block">
                                <form:input path="uscCode" htmlEscape="false"  class="form-control layui-input"/>
							</div>
						</div>
					</div>
				</form:form>
			</div>
		</div>

		<div class="full-width fl">
			<div class="contentShadow layui-form contentDetails">
				<div class="nav-btns">
					<%--此处按钮样式包括 nav-btn-add nav-btn-refresh nav-btn-import nav-btn-export nav-btn-query nav-btn-reset--%>
					<shiro:hasPermission name="workclientinfo:workClientInfo:add">
							<table:addRow url="${ctx}/workclientinfo/workClientInfo/form" title="客户管理"></table:addRow><!-- 增加按钮 -->
					</shiro:hasPermission>
					<shiro:hasPermission name="workclientinfo:workClientInfo:import">
						<table:importExcel url="${ctx}/workclientinfo/workClientInfo/import"></table:importExcel><!-- 导入按钮 -->
					</shiro:hasPermission>

					<shiro:hasPermission name="workclientinfo:workClientInfo:export">
						<table:exportExcel url="${ctx}/workclientinfo/workClientInfo/export"></table:exportExcel><!-- 导出按钮 -->
					</shiro:hasPermission>

					<table:importInfoErr url="${ctx}/workclientinfo/workClientInfo/importInfoErr" title="导入日志"></table:importInfoErr><!-- 导出按钮 -->

					<button class="nav-btn nav-btn-refresh" data-toggle="tooltip" data-placement="left" onclick="sortOrRefresh()" title="刷新"><i class="glyphicon glyphicon-repeat"></i>&nbsp;刷新</button>
					<div style="clear: both;"></div>
				</div>
				<table class="oa-table layui-table" id="contentTable"></table>

				<!-- 分页代码 -->
				<table:page page="${page}"></table:page>
				<div style="clear: both;"></div>
			</div>
		</div>
	</div>
	<div id="changewidth"></div>
</div>
<script src="${ctxStatic}/layer-v2.3/layui/layui.all.js" charset="utf-8"></script>
<script>
    layui.use('table', function(){
        layui.table.render({
            limit:${ page.pageSize }
            ,elem: '#contentTable'
            ,page: false
            ,cols: [[
				{field:'index',align:'center', title: '序号',width:40}
				,{field:'clientName',align:'center', title: '客户名称',minWidth:200,templet:function(d){
                        var xml = "<a class=\"attention-info\" href=\"javascript:void(0);\" onclick=\"openDialogView('查看客户信息', '${ctx}/workclientinfo/workClientInfo/detail?id=" + d.id + "&wlId=" + d.linkman + "','95%','95%')\">" +
                            "<span title=" + d.clientName + ">" + d.clientName.substr(0,40) + "</span></a>";
                        return xml;
                    }}
				,{field:'number',align:'center', title: '客户编号',width:150}
                ,{field:'clientProperty',align:'center', title: '客户性质',width:150}
                ,{field:'trade',align:'center', title: '客户行业', width:150}
                ,{field:'area', align:'center',title: '所在地区',width:200}
                ,{field:'clientType', align:'center',title: '客户类型',minWidth:200,templet:function(d){
                        return "<span title='"+ d.clientType +"'>" + d.clientType + "</span>";
                    }}
                ,{field:'code', align:'center',title: '统一社会信用代码',minWidth:250,templet:function(d){
                        return "<span title='"+ d.code +"'>" + d.code + "</span>";
                    }}
                ,{field:'createDate',align:'center', title: '创建时间', width:85}
                ,{field:'op',align:'center',title:"操作",width:130,templet:function(d){
                        ////对操作进行初始化
                        var xml = "";

                        if(d.canedit != undefined && d.canedit == "1")
                            xml +="<a href=\"javascript:void(0)\" onclick=\"openDialog('修改客户信息', '${ctx}/workclientinfo/workClientInfo/form?id=" + d.id + "&param=1','95%','95%')\" class=\"op-btn op-btn-edit\" ><i class=\"fa fa-edit\"></i>修改</a>"

                        if(d.candelete != undefined && d.candelete == "1")
                            xml +="<a href=\"${ctx}/workclientinfo/workClientInfo/delete?id=" + d.id + "\" onclick=\"return confirmx('确认要删除该客户信息吗？', this.href)\"   class=\"op-btn op-btn-delete\"><i class=\"fa fa-trash\"></i> 删除</a>";
                        return xml;
                    }}
            ]]
            ,data: [
                <c:if test="${ not empty page.list}">
                <c:forEach items="${page.list}" var="workClientInfo" varStatus="index">
                <c:if test="${index.index != 0}">,</c:if>
                {
                    "index":"${index.index+1}"
                    ,"id":"${workClientInfo.id}"
                    ,"number":"${workClientInfo.number}"
					,"linkman":"${workClientInfo.workClientLinkman.id}"
                    ,"clientName":"${workClientInfo.name}"
                    ,"clientProperty":"${fns:getMainDictLabel(workClientInfo.companyType, 'company_type', '')}"
					,"trade":"${fns:getMainDictLabel(workClientInfo.companyIndustry, 'company_industry', '')}"
                    ,"area":"${workClientInfo.area.name}"
                    ,"clientType":"${fns:getMainDictLabels(workClientInfo.clientType,',','client_type', '')}"
                    ,"code":"${workClientInfo.uscCode}"
                    ,"createDate":"<fmt:formatDate value="${workClientInfo.createDate}" pattern="yyyy-MM-dd"/>"
                    <c:if test="${flag == '1' or fns:getUser().id == workClientInfo.createBy.id}">
                    <shiro:hasPermission name="workclientinfo:workClientInfo:edit">,"canedit":"1"</shiro:hasPermission>
					<shiro:hasPermission name="workclientinfo:workClientInfo:del">,"candelete":"1"</shiro:hasPermission>
                	</c:if>
                }
                </c:forEach>
                </c:if>
            ]
        });

    })

    resizeListTable();/*消除由于有竖向滚动条造成table出现横向滚动条*/
    $("a").on("click",addLinkVisied);
</script>

<script type="text/javascript">
    resizeListWindow1();
    $(window).resize(function(){
        resizeListWindow1();
    });
</script>
</body>

</html>

