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

<!--
    $Author:
    $Date: 2018/8/2
    $Revision: 1.0
    5.PRJ INFO信息
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view template="default" package="leaf.ui.std">
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="pageLink_nanshan_all_layout" url="${/request/@context_path}/modules/nanshan_all_layout.lview"/>
        <style>
            html,body{
            background-color:#eee;
            width:870px;
            height:355px;
            margin: 0;
            padding: 0;
            color:#758697;
            }
            .widget_prj_info{
            width:870px;
            height:355px;
            background-color:#fff;
            position:relative;
            }
            .widget_prj_info .hls-pagging-grid{
            width:870px;
            }
            .widget_prj_info .hls-pagging-grid .grid-title{
            border-bottom:4px solid #F57B69;
            height:45px;
            }
            .widget_prj_info .hls-pagging-grid .grid-title>img{
            width:20px;
            height:20px;
            position:relative;
            top:5px;
            }
            .widget_prj_info .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;
            }
        </style>
        <script><![CDATA[
        function prj_id_name_renderer(record,index){
            var html='<p style="width:150px;max-height:16px;">'+record.data['chance_number']+'</p>';
            html+='<p style="color:#9f9f9f;width:150px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;">'+record.data['project_name']+'</p>';
            return html;
        }
        function prj_status_renderer(record,index){
            var statusInfo = {
                "NEW":"#2EC3E8",
                "APPROVING":"#FFCD55",
                "CANCEL":"#14A9CC",
                "CLOSED":"#E75B8D",
                "APPROVED_RETURN":"#E75B8D",
                "REJECTED":"#FA6A4D",
                "PRJ_CREATED":"#A0D469"
            };
            var str='';
            str+='<span style="width:85px;height: 20px;line-height: 20px; border-radius: 2px;max-height:32px;text-align:center;color:#fff;display:inline-block;overflow:hidden;background: '+statusInfo[record.data['chance_status']]+'">';
            str+=record.data['chance_status_n']+'</span>';
            return str;
        }
        function prj_detail_renderer(record,index){
            return "<img onclick='chanceMaintainDs_grid_update(\"" + 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 chanceMaintainDs_grid_update(ds_id,record_id) {
            var record = $(ds_id).findById(record_id);
            var param = record.data;
            var maintain_type;
            var function_code;
            var url_title;
            if (param['chance_status'] == 'APPROVED_RETURN' || param['chance_status'] == 'NEW') {
                maintain_type = 'UPDATE';
                function_code = 'PRJ401';
                url_title	= '立项维护';
            } else {
                maintain_type = 'QUERY';
                function_code = 'PRJ401Q';
                url_title	= '立项查询';
            }
            param['function_code'] = function_code;
            param['document_id'] = param['chance_id'];
            param['maintain_type'] = maintain_type;
            param['cond_para2'] = param['hn_industry_classification'];
            param['url_title'] = url_title;
            param['save_path'] = 'CHANCE_REPROT_PATH';
            var list_ds='chanceMaintainDs';

            Leaf.Masker.mask(Ext.getBody(), '正在执行...');
            Leaf.request({
                url: $('con_contract_get_layout_code_link_id').getUrl(),
                para: param,
                success: function(res) {
                    Leaf.Masker.unmask(Ext.getBody());
                    console.log(res);
                    if (!res.result.layout_code) {
                        Leaf.showMessage('提示', '没有取到布局代码,请核查选择数据!');
                        return;
                    }
                    param['layout_code'] = res.result.layout_code;
                    param['usage_type'] = res.result.usage_type;
                    param['winid'] = 'hls_doc_get_layout_code_winid';
                    param['calc_type'] = res.result.cond_para1;
                    var win = new Leaf.Window({
                        id: 'hls_doc_get_layout_code_winid',
                        params: param,
                        url: $('pageLink_nanshan_all_layout').getUrl(),
                        title: param['url_title'] + '(' + res.result.layout_code + ')',
                        fullScreen: true,
                        draggable: true
                    });
                    win.on('close', function() {
                        if (pre_winid && pre_win_close_flag === 'Y') {
                            $(pre_winid).close();
                        }
                        if (list_ds) {
                            $(list_ds).query();
                        }
                        if (function_name) {
                            window[function_name]();
                        }

                    });
                },
                failure: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                error: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                scope: this
            });
        }
        function prj_search_handler(){
            <!--top.mainJumpCode('PRJ401',true);-->
            location.href='/modules/prj/PRJ401/prj_chance_update_entrance.lview?layout_code=CHANCE_MODIFY&function_code=PRJ401';
        }
        function prj_add_handler(){
            <!--top.mainJumpCode('PRJ401',true);-->
            location.href='/modules/prj/PRJ401/prj_chance_update_entrance.lview?layout_code=CHANCE_MODIFY&function_code=PRJ401';
        }
            ]]></script>
        <a:dataSets>
            <a:dataSet id="prj_info_ds" autoQuery="true"  pageSize="5" model="prj.PRJ1101.prj_info">
                <a:fields>
                    <a:field name="chance_id"/>
                    <a:field name="chance_number"/>
                    <a:field name="project_name"/>
                    <a:field name="bp_name"/>
                    <a:field name="division_n"/>
                    <a:field name="document_type_n"/>
                    <a:field name="chance_status"/>
                    <a:field name="chance_status_n"/>
                    <a:field name="hn_industry_classification"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <div class="widget_prj_info">
            <a:hapGrid id="prj_info" title="项目信息" bindTarget="prj_info_ds" titleImg="/leafresource/images/widget/vat-inf-5.png" canWheel="true">
                <a:toolBar>
                    <a:button icon="/leafresource/images/widget/search_flag.png" click="prj_search_handler"/>
                    <a:button icon="/leafresource/images/widget/add.png" click="prj_add_handler"/>
                    <!--<a:button type="search" click="click3" width="150px" placeholder="请输入合同编号"/>-->
                </a:toolBar>
                <a:columns>
                    <a:column template="prj_id_name_renderer" prompt="项目编号/项目名称"/>
                    <a:column name="bp_name" prompt="承租人" />
                    <a:column name="division_n"  prompt="产品线"/>
                    <a:column name="document_type_n"  prompt="项目类型"/>
                    <a:column template="prj_status_renderer" prompt="项目状态"/>
                    <a:column template="prj_detail_renderer"  prompt="明细"/>
                </a:columns>
            </a:hapGrid>
        </div>
        <a:screenBody style="display:none"> </a:screenBody>
    </a:view>
</a:screen>