<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>企业信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
		});
        /**
         * 签收任务
         */
        function claim(taskId) {
            $.get('${ctx}/act/task/claim' ,{taskId: taskId}, function(data) {
                if (data == 'true'){
                    top.$.jBox.tip('签收完成');
                    location = '${ctx}/sys/company/joinOnCompany/';
                }else{
                    top.$.jBox.tip('签收失败');
                }
            });
        }

        function openDialogre(title,url,width,height,target){

            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,
                skin: 'three-btns',
                maxmin: true, //开启最大化最小化按钮
                content: url ,
                btn: ['同意','驳回','关闭'],
                btn1: function(index, layero){
                    var body = top.layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    if(iframeWin.contentWindow.doSubmit(1) ){
                        //top.layer.close(index);//关闭对话框。
                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                    }
                },
                btn2:function(index,layero){
                    var body = top.layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    if(iframeWin.contentWindow.doSubmit(2) ){
                        // top.layer.close(index);//关闭对话框。
                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                    }
                    return false;
                },
                btn3: function(index){
                }
            });
        }
	</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">

				<shiro:hasPermission name="sys:company:companyList">
				<form:form id="searchForm" modelAttribute="companyinfo" action="${ctx}/sys/company/joinCompany" 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}"/>
					<input id="createBy" name="createBy" type="hidden" value="${fns:getUser().id}"/>
					<table:sortColumn id="orderBy" name="orderBy" value="${page.orderBy}" callback="sortOrRefresh();"/><!-- 支持排序 -->

					<div class="commonQuery">
						<div class="layui-item query athird">
							<label class="layui-form-label">用户名称：</label>
							<div class="layui-input-block">
								<form:input path="name" htmlEscape="false" maxlength="64" 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="office" name="office.id" value="${companyinfo.office.id}" labelName="office.name" labelValue="${companyinfo.office.name}"
												title="部门" url="/sys/office/treeDataAll?type=2" cssClass=" form-control input-sm" allowClear="true" notAllowSelectParent="true"/>
							</div>
						</div>

						<div class="layui-item athird fr">
							<div class="input-group">
								<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>
				</form:form>
				</shiro:hasPermission>
			</div>
		</div>
		<div class="full-width fl">
			<div class="contentShadow layui-form contentDetails">
				<div class="nav-btns">
					<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: [[
                // {checkbox: true, fixed: true},
                {field:'index',align:'center',  width:40,title: '序号'}
                ,{field:'name',align:'center', title: '公司名称', minWidth:150,templet:function(d){
                        return "<span title='"+ d.name +"'>" + d.name + "</span>";
                    }}
                ,{field:'date',align:'center', title: '创建时间', width:80}
                ,{field:'user',align:'center', title: '用户名称', width:80,templet:function(d){
                        return "<span title='"+ d.user +"'>" + d.user + "</span>";
                    }}
                ,{field:'office', align:'center',title: '所属部门', width:150,templet:function(d){
                        return "<span title='"+ d.office +"'>" + d.office + "</span>";
                    }}
                ,{field:'remarks', align:'center',title: '备注信息', minWidth:100,templet:function(d){
                        return "<span title='"+ d.remarks +"'>" + d.remarks + "</span>";
                    }}
                ,{field:'master', align:'center',title: '审批管理员',width:80,templet:function(d){
                        return "<span title='"+ d.master +"'>" + d.master + "</span>";
                    }}
                ,{field:'status',align:'center', title: '加入状态', width:80,templet:function(d){
                        return "<span title='"+ d.status +"'>" + d.status + "</span>";
                    }}
                ,{field:'op',align:'center',title:"操作",width:130,templet:function(d){
                        ////对操作进行初始化
                        var xml = "";
                        if(d.canview != undefined && d.canview == "1")
                            xml += "<a href=\"javascript:void(0)\" onclick=\"openDialogView('查看企业信息', '${ctx}/sys/company/companyinfoView?id="+ d.id + "&readAttr=disabled','95%','95%')\" class=\"op-btn op-btn-view\" ><i class=\"fa fa-search-plus\"></i> 查看</a>";
                        if(d.cancancel != undefined && d.cancancel == "1")
                            xml +="<a href=\"${ctx}/sys/company/deletes?id="+ d.id +"\" onclick=\"return confirmx('确认要退出企业吗？', this.href)\"   class=\"op-btn op-btn-delete\"><%--<i class=\"fa fa-trash\"></i>--%> 退出</a>";
                        if(d.candelete != undefined && d.candelete == "1")
                            xml +="<a href=\"${ctx}/sys/company/deletes?id=" + d.id + "\" onclick=\"return confirmx('确认要删除员工吗？', this.href)\"   class=\"op-btn op-btn-delete\"><i class=\"fa fa-trash\"></i> 删除</a>";
                        if(d.canedit != undefined && d.canedit == "1")
                            xml +="<a href=\"javascript:void(0)\" onclick=\"openDialogre('审核', '${ctx}/sys/company/applyOnCompany?id="+ d.id + "','95%','95%')\" class=\"op-btn op-btn-edit\" ><i class=\"fa fa-edit\"></i> 办理</a>";

                        return xml;
                    }}
            ]]
            ,data: [
                <c:if test="${ not empty page.list}">
                <c:forEach items="${page.list}" var="companyinfo" varStatus="index">
                <c:set var="status" value="${companyinfo.status }" />
                <c:if test="${index.index != 0}">,</c:if>
                {
                    "index":"${index.index+1}"
                    ,"id":"${companyinfo.id}"
                    ,"name":"${companyinfo.name}"
                    ,"date":"<fmt:formatDate value="${companyinfo.createDate}" pattern="yyyy-MM-dd"/>"
                    ,"user":"${companyinfo.name1}"
                    ,"office":"${companyinfo.office.name}"
                    ,"remarks":"${companyinfo.remarks}"
                    ,"master":"${companyinfo.masterName}"
                    ,"status":"${fns:getDictLabel(companyinfo.status, 'companyStatus', '')}"
					<shiro:hasPermission name="sys:company:view">,"canview":"1"</shiro:hasPermission>
                    <shiro:hasPermission name="sys:company:del">
					<c:if test="${companyinfo.status=='3' && fns:getUser().id eq companyinfo.userId}" >,"cancancel":"1"</c:if>
					<c:if test="${companyinfo.status=='3' && fns:getUser().id ne companyinfo.userId}" >,"candelete":"1"</c:if>
					</shiro:hasPermission>
					<c:if test="${not empty status && (status == 1 || status == 6) && gly}">,"canedit":"1"</c:if>
                }
                </c:forEach>
                </c:if>
            ]
            // ,even: true
            // ,height: 315
        });

    })

    resizeListTable();
</script>
<script>
    resizeListWindow1();
    $(window).resize(function(){
        resizeListWindow1();
    });
</script>
</body>
</html>