<?xml version="1.0" encoding="UTF-8"?>

<!--
    $Author:
    $Date: 2018/8/2
    $Revision: 1.0
    12.合同变更查询
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view template="default" package="leaf.ui.std">
        <a:link id="widget_con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="widget_con31_con_contract_info_link" url="${/request/@context_path}/modules/prj/PRJ506/virtual_contract_query.lview"/>
        <!--Beyond styles-->
        <link href="${/request/@context_path}/leafresource/hls/beyondChart/assets/css/beyond.min.css" rel="stylesheet" />
        <link href="${/request/@context_path}/leafresource/hls/beyondChart/assets/css/demo.min.css" rel="stylesheet" />
        <link href="${/request/@context_path}/leafresource/hls/beyondChart/assets/css/typicons.min.css" rel="stylesheet" />
        <link href="${/request/@context_path}/leafresource/hls/beyondChart/assets/css/animate.min.css" rel="stylesheet" />

        <!--Basic Scripts-->
        <script src="${/request/@context_path}/leafresource/hls/beyondChart/assets/js/skins.min.js"></script>
        <script src="${/request/@context_path}/leafresource/hls/beyondChart/assets/js/bootstrap.min.js"></script>
        <script src="${/request/@context_path}/leafresource/hls/beyondChart/assets/js/slimscroll/jquery.slimscroll.min.js"></script>
        <!--Beyond Scripts-->
        <script src="${/request/@context_path}/leafresource/hls/beyondChart/assets/js/beyond.min.js"></script>

        <!--Page Related Scripts-->
        <script src="${/request/@context_path}/leafresource/hls/beyondChart/assets/js/charts/morris/raphael-2.0.2.min.js"></script>
        <script src="${/request/@context_path}/leafresource/hls/beyondChart/assets/js/charts/morris/morris.js"></script>
        <script src="${/request/@context_path}/leafresource/hls/beyondChart/assets/js/charts/morris/morris-init.js"></script>
        <style>
            html,body{
            background-color:#eee;
            width:1170px;
            height:545px;
            margin: 0;
            padding: 0;
            }
            .widget_cont_chgreq{
            width:1170px;
            height:545px;
            position:relative;
            }
            .widget_cont_chgreq .left{
            width:270px;
            height:545px;
            background-color:#fff;
            float:left;
            }
            .widget_cont_chgreq .right{
            width:870px;
            height:545px;
            background-color:#fff;
            float:left;
            margin-left:30px;
            }
            .widget_cont_chgreq .hls-pagging-grid{
            width:870px;
            height:545px;
            }
            .widget_cont_chgreq .hls-pagging-grid .grid-title{
            border-bottom:4px solid #F57B69;
            height:45px;
            }
            .widget_cont_chgreq .hls-pagging-grid .grid-title img{
            width:20px;
            height:20px;
            position:relative;
            top:5px;
            }
            .widget_cont_chgreq .hls-pagging-grid .grid-title>span{
            font-family:"Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Microsoft Yahei", "Hiragino Sans GB", sans-serif;
            font-size:13px;
            line-height:45px;
            color:#000;
            text-size-adjust:100%;
            font-weight:bold;
            }
            .widget_cont_chgreq .clickable{
            cursor:pointer;
            }
            .widget_cont_chgreq .clearFloat{
            clear:both;
            height:0;
            line-height:0;
            font-size:0
            }
            .widget_cont_chgreq .queryList .listTitle{
            border-bottom:4px solid #00B3B3;
            font-size: 13px;
            height: 40px;
            line-height: 40px;
            padding: 0 10px;
            font-weight: 600;
            }
            .widget_cont_chgreq #chgTypePie{
            width:160px;
            height:160px;
            margin-left:50px;
            }
            .widget_cont_chgreq .queryList .listTitle .right-img{
            width: 20px;
            height: 20px;
            margin:10px 10px 0 0;
            float:right;
            }
            .widget_cont_chgreq .queryList .listBody{
            padding:0 10px;
            }
            .widget_cont_chgreq .queryList .listRow{
            padding:5px;
            border-bottom:1px solid rgb(229, 229, 229);
            }
            .widget_cont_chgreq .queryList .listRow p{
            color:#000;
            font-size:13px;
            font-weight:100;
            line-height:20px;
            margin:0;
            }
            .widget_cont_chgreq .queryList .listRow .chgTypePie{
            height:230px;
            }
            .widget_cont_chgreq .queryList .listRow .selectSpan{
            display: inline-block;
            width:72px;
            height:30px;
            line-height:30px;
            text-align: center;
            border: 1px solid #CCC;
            border-radius: 4px;
            font-size: 12px;
            margin:10px 2px;
            cursor: pointer;
            background-color:#fff;
            color:#000;
            }
            .widget_cont_chgreq .queryList .listRow .smallSpan{
            width:54px;
            margin:3px 2px;
            }
            .widget_cont_chgreq .queryList .listRow .selectedSpan{
            background-color:#00b3b3;
            color:#fff;
            }
            .widget_cont_chgreq .queryList .listRow .submitBtn{
            text-align:right
            }
            .widget_cont_chgreq .queryList .listRow .submitBtn span{
            display:inline-block;
            width:72px;
            height:30px;
            line-height:30px;
            text-align: center;
            background-color:#FA6A4D;
            color:#fff;
            border-radius: 4px;
            font-size: 12px;
            margin:10px 2px;
            cursor: pointer;
            }
        </style>
        <script><![CDATA[
        //查询条件数据结构
        var queryParam={
            "timeZone":"",
            "new":0,
            "approving":0,
            "reject":0,
            "approved":0,
            "cancel":0
        };
        jQuery(document).ready(function(){
            jQuery(".listBody").on('click',function(e){
                $this=jQuery(e.target);

                //时间跨度单选点击事件
                if($this.attr("class").indexOf('timeZone')>=0){
                    var allSpans=jQuery(".timeZone");
                    for(var i=0;i<allSpans.length;i++){
                        if(allSpans[i].id!=$this.attr("id")){
                            jQuery(allSpans[i]).removeClass("selectedSpan");
                        }
                    }
                    $this.toggleClass("selectedSpan");
                    if($this.attr("class").indexOf('selectedSpan')>=0){
                        queryParam.timeZone=$this.attr("id");
                    }else{
                        queryParam.timeZone="";
                    }
                }

                //合同类型多选点击事件
                if($this.attr("id")=='new'){
                    $this.toggleClass("selectedSpan");
                    if($this.attr("class").indexOf('selectedSpan')>=0){
                        queryParam.new=1;
                    }else{
                        queryParam.new=0;
                    }
                }
                if($this.attr("id")=='approving'){
                    $this.toggleClass("selectedSpan");
                    if($this.attr("class").indexOf('selectedSpan')>=0){
                        queryParam.approving=1;
                    }else{
                        queryParam.approving=0;
                    }
                }
                if($this.attr("id")=='reject'){
                    $this.toggleClass("selectedSpan");
                    if($this.attr("class").indexOf('selectedSpan')>=0){
                        queryParam.reject=1;
                    }else{
                        queryParam.reject=0;
                    }
                }
                if($this.attr("id")=='approved'){
                    $this.toggleClass("selectedSpan");
                    if($this.attr("class").indexOf('selectedSpan')>=0){
                        queryParam.approved=1;
                    }else{
                        queryParam.approved=0;
                    }
                }
                if($this.attr("id")=='cancel'){
                    $this.toggleClass("selectedSpan");
                    if($this.attr("class").indexOf('selectedSpan')>=0){
                        queryParam.cancel=1;
                    }else{
                        queryParam.cancel=0;
                    }
                }

                //查询按钮点击事件
                if($this.attr("id")=='submitBtn'){
                    $("cont_chgreq_ds").qpara=queryParam;
                    $("cont_chgreq_ds").query();
                }
            });

        });
        function go_cont_chgreq_query(){
            <!--top.mainJumpCode('CON732',true)-->
            location.href='/modules/cont/CON732/hls_ccr_modify_entrance.lview?layout_code=CON732&function_code=CON732';
        }
        function chgreq_info_btn_renderer(record,index){
            return "<img onclick='open_contract_win(\"" + record.ds.id+ "\",\""+record.id+"\")' style='cursor:pointer;width:15px;height:15px;display:inline-block;margin:0px;' src='${base.contextPath}/leafresource/images/widget/detail.png' alt='png'/>";
        }
        function open_contract_win(ds_id, record_id) {
            var record = $(ds_id).findById(record_id);
            var param = record.data;
            param['function_code'] = 'CON301';
            param['function_usage'] = 'QUERY';
            param['maintain_type'] = 'UPDATE';
            param['cond_para2'] = record.get('hn_industry_classification');
            param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';

            Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
            Leaf.request({
                url: $('widget_con_contract_get_layout_code_link_id').getUrl(),
                para: param,
                success: function(res) {
                    Leaf.Masker.unmask(Ext.getBody());
                    if (!res.result.layout_code) {
                        Leaf.showMessage('${l:PROMPT}', '${l:HLS.LAYOUT_CODE_IS_NULL}');
                        return;
                    }
                    param['layout_code'] = res.result.layout_code;
                    param['usage_type'] = res.result.usage_type;
                    var winid = 'hls_doc_get_layout_code_winid';
                    param['winid'] = winid;
                    param['calc_type'] = res.result.cond_para1;
                    var win;
                    win = new Leaf.Window({
                        id: winid,
                        params: param,
                        url: $('widget_con31_con_contract_info_link').getUrl(),
                        title: param['url_title'] + '(' + res.result.layout_code + ')',
                        fullScreen: true,
                        draggable: true
                    });
                    win.on('close', function() {
                        if (ds_id) {
                            $(ds_id).query();
                        }
                    });
                },
                failure: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                error: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                scope: this
            });
        }
        function chgreq_count_ds_loader(ds){
            var records=ds.data;
            var donutData=[];
            var colors=[];
            var typeInfo = [
                {
                    typeValue: "合同条款变更",
                    type: "CONTRACT_ALT",
                    color:"#E75B8D"
                },
                {
                    typeValue: "担保变更",
                    type: "GUATANTEE_ALT",
                    color:"#2EC3E8"
                },
                {
                    typeValue: "租赁物变更",
                    type: "LEASE_ALT",
                    color:"#A0D469"
                },
                {
                    typeValue: "承租人变更",
                    type: "LEASEES_ALT",
                    color:"#FA6A4D"
                },
                {
                    typeValue: "租金计划变更",
                    type: "RENT_PLAN_ALT",
                    color:"#FFCD55"
                }
            ];
            if(records!==null && records.length>0){
                records.forEach(function(i){
                    typeInfo.forEach(function(j){
                        if(i.data['ccr_type']==j.type){
                            j.value=i.data['ccr_type_count'];
                        }
                    });
                });
            }
            typeInfo.forEach(function(i){
                if(i.value==undefined){
                    i.value=0;
                }
                donutData.push({
                    label:i.typeValue,
                    value:i.value
                });
                colors.push(i.color);
            });
            console.log(typeInfo);
            Morris.Donut({
              element: 'chgTypePie',
              data:donutData,
              colors:colors
            });
        }
            ]]></script>
        <a:dataSets>
            <a:dataSet id="cont_chgreq_ds" autoQuery="true"  pageSize="9" model="cont.CON1003.cont_chgreq">
                <a:fields>
                    <a:field name="req_date"/>
                    <a:field name="ccr_type"/>
                    <a:field name="ccr_type_n"/>
                    <a:field name="req_status"/>
                    <a:field name="req_status_n"/>
                    <a:field name="change_req_id"/>
                    <a:field name="change_req_number"/>
                    <a:field name="contract_id"/>
                    <a:field name="contract_number"/>
                    <a:field name="contract_name"/>
                    <a:field name="bp_id"/>
                    <a:field name="bp_name"/>
                    <a:field name="bp_code"/>
                    <a:field name="hn_industry_classification"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="cont_chgreq_count_ds" autoQuery="true"  pageSize="9" model="cont.CON1003.cont_chgreq_count">
                <a:fields>
                    <a:field name="ccr_type"/>
                    <a:field name="ccr_type_n"/>
                    <a:field name="ccr_type_count"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="chgreq_count_ds_loader"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <div class="widget_cont_chgreq">
            <div class="left queryList">
                <div class="listTitle">
                    <img class="right-img clickable" onclick="go_cont_chgreq_query()" src="${/request/@context_path}/leafresource/images/widget/search_flag.png"/>
                    <span>变更情况查询</span>
                </div>
                <div class="listBody">
                    <div class="listRow">
                        <p class="">时间跨度</p>
                        <span id="7" class="selectSpan timeZone">1周内</span>
                        <span id="30" class="selectSpan timeZone">1个月内</span>
                        <span id="90" class="selectSpan timeZone">3个月内</span>
                    </div>
                    <div class="listRow">
                        <p class="">变更情况统计</p>
                        <div class="chgTypePie" id="chgTypePie">

                        </div>
                    </div>
                    <div class="listRow">
                        <p class="">变更状态</p>
                        <span id="new" class="selectSpan smallSpan">新建</span>
                        <span id="approving" class="selectSpan smallSpan">审批中</span>
                        <span id="reject" class="selectSpan smallSpan">审批拒绝</span>
                        <span id="approved" class="selectSpan smallSpan">审批通过</span>
                        <span id="cancel" class="selectSpan smallSpan">取消</span>
                        <div class="submitBtn"><span class="" id="submitBtn">查询</span></div>
                    </div>
                </div>
            </div>
            <div class="right">
                <a:hapGrid title="合同变更信息" bindTarget="cont_chgreq_ds" titleImg="/leafresource/images/widget/contract.png" canWheel="true">
                    <a:columns>
                        <a:column name="change_req_number" prompt="合同变更编号"/>
                        <a:column name="contract_name" prompt="合同名称"/>
                        <a:column name="ccr_type_n" prompt="变更类型"/>
                        <a:column name="req_date"  prompt="变更日期"/>
                        <a:column name="bp_name"  prompt="承租人"/>
                        <a:column template="chgreq_info_btn_renderer" prompt="明细"/>
                    </a:columns>
                </a:hapGrid>
            </div>
            <div class="clearFloat"> </div>
        </div>
        <a:screenBody style="display:none"> </a:screenBody>
    </a:view>
</a:screen>