<#assign base=request.contextPath />
<#import "../common/defaultLayout.ftl" as defaultLayout>

<@defaultLayout.layout>
    <link rel="stylesheet" href="../assets/css/amazeui.switch.css"/>
<style type="text/css">
    .huanhang{
    // 表格自动换行
    table-layout:fixed;
        word-break:break-all
    }
    .focus{
    // 表格自动换行
    table-layout:fixed;
        word-break:break-all
    }
    /*固定表头的列表*/
    .fixed-list {
        flex: 1 1 auto;
        overflow: hidden;
    }
    .fixed-list table {
        display: block;
        width: 100%;
        max-height: 100%;
        border-spacing: 0px;
        border-collapse: collapse;
        border: none;
        overflow-y: hidden;
        overflow-x: auto;
        margin: 0;
    }

    .fixed-list.is-vertical-scroll table tbody {
        max-height: calc(100% - 71px);
    }
    .fixed-list table>thead>tr>th {
        height: 40px;
        text-align: center;
        vertical-align: middle;
    }
    .fixed-list table td {
        height: 55px;
        text-align: center;
    }
    .fixed-list table tbody {
        display: block;
        width: 100%;
        max-height: calc(100% - 45px);
        overflow-y: scroll;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .fixed-list table tr {
        table-layout: fixed;
        display: table;
    }
    .fixed-list table thead tr {
        width: calc(100% - 18px);
        border-top: 1px solid #ddd;
        border-bottom: none;
    }
    .fixed-list table tbody tr {
        width: 100%;
    }

</style>
    <div class="admin-content">
        <div class="am-cf am-padding" style="padding:1rem 1.6rem 1.6rem 1rem;margin:0px;">
            <!--  padding:1px 2px 3px 4px;上、右、下,和左   -->
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">商务应用</strong> /
                <small>空间管理明细数据</small>
            </div>
        </div>
        <div class="am-g">
            <div class="am-u-sm-12">
                <form class="am-form" id="listForm" action="${base}/project/list" method="POST">
                    <input type="hidden" id="keywords" name="keywords" value='${keywords!""}'/>
                    <input type="hidden" id="pageNumber" name="pageNumber" value='${pageNumber!}'/>
                    <input type="hidden" id="certainty" name="certainty" value='${certainty!""}'/>
                    <style>
                        .flex-row {
                            display: -webkit-box;
                            display: -webkit-flex;
                            display: flex;
                            display: -ms-flex;
                        }
                        .search-table {
                            position: relative;
                            width: 100%;
                            padding: 6px 0 0;
                            border: 1px solid #d8d8d8;
                            border-radius: 4px;
                        }
                        .search-table input {
                            border-color: #e6e6e6!important;
                        }
                        .search-table .st-row {
                            position: relative;
                            width: 100%;
                            justify-content: flex-start;
                            /*align-items: center;*/
                            padding: 0 6px 6px;
                            margin-bottom: 6px;
                            border-bottom: 1px solid #d8d8d8;
                        }
                        .search-table .tools-row {
                            position: relative;
                            width: 100%;
                            justify-content: flex-end;
                            padding-right: 6px;
                            margin-bottom: 6px;
                        }
                        .tools-row button {
                            margin-left: 12px;
                        }
                        /* 默认5等分，一行5个 */
                        .st-row .st-col {
                            position: relative;
                            flex: 0 0 18%;
                            margin-right: 2%;
                        }
                        /* 4等分，一行4个 */
                        .st-col.st-col-4 {
                            flex: 0 0 22%;
                            margin-right: 3%;
                        }
                        /* 3等分，一行3个 */
                        .st-col.st-col-3 {
                            flex: 0 0 31%;
                            margin-right: 2.3%;
                        }
                        /* 2等分，一行2个 */
                        .st-col.st-col-2 {
                            flex: 0 0 48%;
                            margin-right: 2%;
                        }
                        .st-col.hidden {
                            display: none;
                        }
                        .st-col .st-col-title {
                            font-size: 14px;
                            color: #333;
                            margin-bottom: 6px;
                            white-space: nowrap;
                            font-weight: bold;
                        }
                        .st-col .st-col-field {
                            align-items: center;
                        }
                        .st-col .mid-connect {
                            margin: 0 4px;
                        }
                        .expand-section {
                            display: block;
                        }
                        .expand-section.fold {
                            display: none;
                        }
                    </style>
                    <div class="search-table">
                        <!-- 第一行 -->
                        <div class="flex-row st-row">
                            <div class="st-col">
                                <div class="st-col-title">项目名称</div>
                                <div class="st-col-field">
                                    <input type="text" id="name" class="am-form-field am-input-sm" value="${name!}"/>
                                </div>
                            </div>
                            <div class="st-col">
                                <div class="st-col-title">项目类型</div>
                                <div class="st-col-field">
                                    <select data-am-selected="{btnSize: 'sm',btnWidth: '100%',maxHeight: 500,searchBox: 1}" id="type" name="type">
                                        <option value="-1">全部</option>
                                        <option value="1" <#if type?? && type='1'>selected</#if>>工程集成类</option>
                                        <option value="2" <#if type?? && type='2'>selected</#if>>设备集成类</option>
                                    </select>
                                </div>
                            </div>
                            <div class="st-col">
                                <div class="st-col-title">客户名称</div>
                                <div class="st-col-field">
                                    <input type="text" id="customer" class="am-form-field am-input-sm" value="${customer!}"/>
                                </div>
                            </div>
                            <div class="st-col">
                                <div class="st-col-title">最终用户名称</div>
                                <div class="st-col-field">
                                    <input type="text" id="terminalCustomer" class="am-form-field am-input-sm" value="${terminalCustomer!}"/>
                                </div>
                            </div>
                        </div>
                        <!-- 扩展区域 -->
                        <div class="expand-section <#if extend!'1' == '1'> fold</#if>">
                            <!-- 第二行 -->
                            <div class="flex-row st-row">
                                <div class="st-col">
                                    <div class="st-col-title">项目负责人</div>
                                    <div class="st-col-field">
                                        <input type="text" id="principal" class="am-form-field am-input-sm" value="${principal!}"/>
                                    </div>
                                </div>
                                <div class="st-col">
                                    <div class="st-col-title">审核状态</div>
                                    <div class="st-col-field">
                                        <select data-am-selected="{btnSize: 'sm',btnWidth: '100%',maxHeight: 500,searchBox: 1}" id="approveStatus" name="approveStatus">
                                            <option value="-1">全部</option>
                                            <option value="0" <#if approveStatus?? && approveStatus='0'>selected</#if>>草稿</option>
                                            <option value="1" <#if approveStatus?? && approveStatus='1'>selected</#if>>待审核</option>
                                            <option value="2" <#if approveStatus?? && approveStatus='2'>selected</#if>>审核通过</option>
                                            <option value="3" <#if approveStatus?? && approveStatus='3'>selected</#if>>审核不通过</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="st-col">
                                    <div class="st-col-title">是否二次合作</div>
                                    <div class="st-col-field">
                                        <select data-am-selected="{btnSize: 'sm',btnWidth: '100%',maxHeight: 500}" id="isSecond" name="isSecond">
                                            <option value="-1">全部</option>
                                            <option value="1" <#if isSecond?? && isSecond='1'>selected</#if>>是</option>
                                            <option value="2" <#if isSecond?? && isSecond='2'>selected</#if>>否</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="st-col">
                                    <div class="st-col-title">项目解决方案</div>
                                    <div class="st-col-field">
                                        <select data-am-selected="{btnSize: 'sm',btnWidth: '100%',maxHeight: 500}" id="resolvePlan" name="resolvePlan">
                                            <option value="-1">全部</option>
                                            <option value="1" <#if resolvePlan?? && resolvePlan='1'>selected</#if>>公共服务(智慧交通、雪亮工程、治安防控体系等)</option>
                                            <option value="2" <#if resolvePlan?? && resolvePlan='2'>selected</#if>>泛行业(智慧园区、智慧医疗、智慧工地等)</option>
                                            <option value="3" <#if resolvePlan?? && resolvePlan='3'>selected</#if>>其他生态</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <!-- 第三行 -->
                            <div class="flex-row st-row">
                                <div class="st-col st-col-4">
                                    <div class="st-col-title">项目周期</div>
                                    <div class="flex-row st-col-field">
                                        <div class="am-form-icon">
                                            <i class="am-icon-calendar"></i>
                                            <input type="text" class="am-form-field am-input-sm" id="startDate"
                                                   value="${startDate!}" placeholder="开始日期" autocomplete="off" data-am-datepicker>
                                        </div>
                                        <div class="mid-connect">至</div>
                                        <div class="am-form-icon">
                                            <i class="am-icon-calendar"></i>
                                            <input type="text" class="am-form-field am-input-sm" id="endDate"
                                                   value="${endDate!}" placeholder="结束日期" autocomplete="off" data-am-datepicker>
                                        </div>
                                    </div>
                                </div>
                                <div class="st-col st-col-4">
                                    <div class="st-col-title">预计合同签订时间</div>
                                    <div class="flex-row st-col-field">
                                        <div class="am-form-icon">
                                            <i class="am-icon-calendar"></i>
                                            <input type="text" class="am-form-field am-input-sm" id="contractStartTime"
                                                   value="${contractStartTime!}" placeholder="开始日期" autocomplete="off" data-am-datepicker>
                                        </div>
                                        <div class="mid-connect">至</div>
                                        <div class="am-form-icon">
                                            <i class="am-icon-calendar"></i>
                                            <input type="text" class="am-form-field am-input-sm" id="contractEndTime"
                                                   value="${contractEndTime!}" placeholder="结束日期" autocomplete="off" data-am-datepicker>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="flex-row tools-row">
                            <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary"
                                    id="extend" value="${extend!}">扩展筛选项
                            </button>
                            <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary"
                                    id="submit-btn">搜索
                            </button>
                            <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary"
                                    id="submit-btn-export">导出
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div class="am-g fixed-list is-vertical-scroll">
            <div class="am-u-sm-12">
                <div class="list-content">
                    <style>
                        td {
                            word-break: break-all;
                        }
                    </style>
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead style="display:block;">
                        <tr class="am-text-nowrap">
                            <th class="table-title" width="60px">序号</th>
                            <th class="table-title" width="120px">项目编号</th>
                            <th class="table-title" width="40%">项目名称</th>
                            <th class="table-title">项目类型</th>
                            <th class="table-title">项目阶段</th>
                            <th class="table-title">项目合同金额</th>
                            <th class="table-title">项目创建者</th>
                            <th class="table-title">审核人</th>

                            <#--<th class="table-title">合作类型</th>-->
                            <#--<th class="table-title">垫资模式</th>-->
                           <#-- <th class="table-title">华智产品金额</th>-->
                           <#-- <th class="table-title">华三产品金额</th>-->
                            <#--<th class="table-title">汇智产品金额</th>-->
                           <#-- <th class="table-title">其他产品金额</th>-->
                            <#--<th class="table-title">项目把握度</th>-->
                            <#--<th class="table-title">项目计划招标时间</th>-->
                            <#--<th class="table-title">预计合同签订时间</th>-->
                            <#--<th class="table-title">计收计划</th>-->
                            <#--<th class="table-title">项目毛利</th>-->
                            <#--<th class="table-title">合同金额</th>-->
                            <#--<th class="table-title">项目解决方案</th>-->
                            <#--<th class="table-title">具体解决方案</th>-->
                            <#--<th class="table-title">是否二次签单</th>-->
                            <#--<th class="table-title">最终用户名称</th>-->
                            <#--<th class="table-title">客户名称</th>-->
                            <#--<th class="table-title">紫光汇智直接投标/集成商转签</th>-->
                            <#--<th class="table-title">负责人</th>-->
                            <#--<th class="table-title">备注</th>-->
                        </tr>
                        </thead>
                        <tbody style="display:block;">
                        <#list pager.list as list>
                            <tr>
                                <#--序号-->
                                <td width="60px">${list.tempId!}</td>
                                <#--项目编号-->
                                <td class="huanhang" width="120px">${list.projectNo!}</td>
                                <#--项目名称-->
<#--                            <td class="huanhang" width="480px"><a style="cursor: pointer;text-decoration:none" onclick="approve(${list.id})">${list.name!}</a></td>-->
                                <td class="huanhang" width="40%"><a style="cursor: pointer;text-decoration:none" onclick="approve(${list.id})">${list.name!}</a></td>
                                <#--项目类型-->
                                <td>${list.typeDesc!}</td>
                                <#--项目阶段-->
                                <td>
                                    <#if list.stage??>
                                        <#if list.stage==0>S0-概算立项
                                        <#elseif list.stage==1>S1-项目调研
                                        <#elseif list.stage==2>S2-方案设计
                                        <#elseif list.stage==3>S3-预算评估
                                        <#elseif list.stage==4>S4-招标期
                                        <#elseif list.stage==5>S5-合同期
                                        <#elseif list.stage==6>S6-交付期
                                        <#elseif list.stage==7>S7-结算期
                                        <#elseif list.stage==8>S8-决算期
                                        <#elseif list.stage==9>L-项目丢失
                                        </#if>
                                    <#else>
                                    </#if>
                                </td>
                                <#--项目合同金额-->
                                <td>${Utils.format(list.contractAmount, "0.00")}</td>
                                <#--项目创建者-->
                                <td>${list.creatorName!}</td>
                                <#--审核人-->
                                <td>${list.approveName!}</td>

                               <#-- 合作类型-->
                               <#-- <td>
                                    ${'找后端要字段'!}
                                </td>-->
                                <#--垫资模式-->
                                <#--<td>${list.underwrittenModeStr!}</td>-->
                                <#--华智产品金额-->
                                <#--<td>${list.huazhiRound!}</td>-->
                                <#--华三产品金额-->
                                <#--<td>${list.huasanRound!}</td>-->
                                <#--汇智产品金额-->
                                <#--<td>${list.huizhiRound!}</td>-->
                                <#--其他产品金额-->
                                <#--<td>${list.ziguangRound!}</td>-->
<#--                                <td>${Utils.format(list.huazhiProductAmount, "0.00")}</td>-->
<#--                                <td>${Utils.format(list.huasanProductAmount, "0.00")}</td>-->
<#--                                <td>${Utils.format(list.huizhiProductAmount, "0.00")}</td>-->
<#--                                <td>${Utils.format(list.ziguangOtherAmount, "0.00")}</td>-->
                                <#--项目把握度-->
                                <#--<td>${list.certaintyStr!}</td>-->
                                <#--项目计划招标时间-->
                                <#--<td>${(list.bidsTime?string("yyyy-MM-dd"))!}</td>-->
                                <#--预计合同签订时间-->
                                <#--<td>${(list.contractTime?string("yyyy-MM-dd"))!}</td>-->
                                <#--计收计划-->
                                <#--<td>${list.calculationCollection!}</td>-->
                                <#--项目毛利-->
                                <#--<td>${list.grossProfitRound!}</td>-->
                                <#--合同金额-->
                                <#--<td>${list.contractRound!}</td>-->
<#--                                <td>${Utils.format(list.grossProfit, "0.00")}</td>-->
<#--                                <td>${Utils.format(list.contractAmount, "0.00")}</td>-->
                                <#--项目解决方案-->
                                <#--<td>${list.resolvePlanStr!}</td>-->
                                <#--具体解决方案-->
                               <#-- <td>${list.mainContractResolvePlan!}</td>-->
                                <#--是否二次签单-->
                                <#--<td>${list.isSecondStr!}</td>-->
                                <#--最终用户名称-->
                                <#--<td>${list.terminalCustomer!}</td>-->
                                <#--客户名称-->
                                <#--<td>${list.customer!}</td>-->
                                <#--紫光汇智直接投标/集成商转签-->
                                <#--<td>${list.signTypeStr!}</td>-->
                                <#--负责人-->
                               <#-- <td>${list.principal!}</td>-->
                                <#--备注-->
                                <#--<td>${list.remark!}</td>-->
                            </tr>
                        </#list>
                        </tbody>
                    </table>
                </div>


            </div>
        </div>

        <!--选项卡（tabs）end-->
        <div class="am-margin">
            <button type="button" class="am-btn am-btn-warning am-btn-xs" onclick="javascript:history.go(-1);">返回上一级</button>
        </div>

        <footer class="admin-content-footer">
            <div class="am-cf">
                <!-- 分页 -->
                <#if (pager.list)?exists && (pager.list?size>0) >
                    <div class="am-fr">
                        <#include "../common/space_pager.ftl">
                    </div>
                <#else>
                    <div class="am-kai" align="center">
                        <h3>没有找到任何记录!</h3>
                    </div>
                </#if>
            </div>
        </footer>
    </div>

</@defaultLayout.layout>
<script type="text/javascript" src="../modal/js/modal.js"></script>
<script src="../assets/js/amazeui.switch.js"></script>
<script src="${base}/assets/js/project_common.js"></script>
<script type="text/javascript">
    var approve = function (id) {
        var pageNumber = $("#pageNumber").val();
        var keywords = $("#keywords").val();
        keywords = keywords.replace(/\{/g, '%7b').replace(/\}/g, '%7d');
        console.log("keywords: " + keywords);
        location.href = '${base}/project/approve?listFrom=list&type=1&id=' + id + '&pageNumber=' + pageNumber + '&keywords=' + keywords;
    };

    $(function () {
        $("#extend").on("click", function () {
            var extend = $("#extend").val();
            if (extend === '0') {
                // $(".extendCondition").hide();
                $('.expand-section').hide()
                $("#extend").val(1);
                $("#extend").text("扩展筛选项");
            } else {
                // $(".extendCondition").show();
                $('.expand-section').show();
                $("#extend").val(0);
                $("#extend").text("隐藏筛选项");
            }
        });

        $("#submit-btn").on("click", function () {
            $("#pageNumber").val(1);
            setKeywords();
            $("#listForm").attr("action","${base}/space/list");
            $("#listForm").submit();
        });

        $("#submit-btn-export").on("click", function () {
            setKeywords();
            $("#listForm").attr("action","${base}/space/export");
            $("#listForm").submit();
        });

        function setKeywords() {
            var keywordsObj = {};
            var extend = $("#extend").val();
            keywordsObj.extend = extend;
            if ($("#name").val())
                keywordsObj.name = $("#name").val();
            if ($("#type").val())
                keywordsObj.type = $("#type").val();
            if ($("#customer").val())
                keywordsObj.customer = $("#customer").val();
            if ($("#terminalCustomer").val())
                keywordsObj.terminalCustomer = $("#terminalCustomer").val();
            if ($("#principal").val())
                keywordsObj.principal = $("#principal").val();
            if ($("#approveStatus").val())
                keywordsObj.approveStatus = $("#approveStatus").val();
            if ($("#isSecond").val())
                keywordsObj.isSecond = $("#isSecond").val();
            if ($("#signType").val())
                keywordsObj.signType = $("#signType").val();
            if ($("#resolvePlan").val())
                keywordsObj.resolvePlan = $("#resolvePlan").val();
            if ($("#startDate").val())
                keywordsObj.startDate = $("#startDate").val();
            if ($("#endDate").val())
                keywordsObj.endDate = $("#endDate").val();
            if ($("#contractStartTime").val())
                keywordsObj.contractStartTime = $("#contractStartTime").val();
            if ($("#contractEndTime").val())
                keywordsObj.contractEndTime = $("#contractEndTime").val();
            var keywords = "";
            if (!$.isEmptyObject(keywordsObj)) {
                keywords = JSON.stringify(keywordsObj);
            }
            console.log("keywords = " + keywords);

            $("#keywords").val(keywords);
        }
    });

</script>
