<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: chenlingfeng
    $Date: 2017-10-24 上午9:43:45
    $Revision: 1.0
    $Purpose: 假期定义申请
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="hn1060_hn_calendar_rules_detail_link" url="${/request/@context_path}/modules/hn/HN1060/hn_calendar_rules.lview"/>
        <a:link id="hn1060_hn_calendar_rules_detail_readonly_link" url="${/request/@context_path}/modules/hn/HN1060/hn_calendar_rules_readonly.lview"/>
        <a:link id="hn1060_hn_calendar_rules_req_create_entrance_link" url="${/request/@context_path}/modules/hn/HN1060/hn_calendar_rules_req_create_entrance.lview"/>
        <a:link id="hn1060_fnd_calendar_rules_link" url="${/request/@context_path}/modules/hn/HN1060/fnd_calendar_rules.lview"/>
        <script type="text/javascript"><![CDATA[
            function hn1060_query() {
                $('hn1060_hn_calendar_rules_req_ds').query();
            }
            
            function hn1060_rule_query(id) {
                var record = $('hn1060_hn_calendar_rules_req_ds').findById(id);
                new Leaf.Window({
                    id: 'fnd_calendar_rules_window',
                    url: $('hn1060_fnd_calendar_rules_link').getUrl(),
                    params: {
                        calendar_id: record.get('calendar_id')
                    },
                    title: '${l:WORKFLOW_RULE}',
                    height: 500,
                    width: 650
                });
            }
            
            function hn1060_create() {
                var win = new Leaf.Window({
                    id: 'hn_calendar_rules_req_create_entrance_winid',
                    url: $('hn1060_hn_calendar_rules_req_create_entrance_link').getUrl(),
                    params: {
                        winid: 'hn_calendar_rules_req_create_entrance_winid'
                    },
                    title: '申请创建',
                    height: 300,
                    width: 400
                });
                win.on('close', function() {
                    hn1060_query();
                });
            }
            
            function hn1060_detail(id) {
                var record = $('hn1060_hn_calendar_rules_req_ds').findById(id);
                var url = $('hn1060_hn_calendar_rules_detail_readonly_link').getUrl();
                if (record.get('wfl_status') == 'NEW' || record.get('wfl_status') == 'APPROVAL_RETURNED') {
                    url = $('hn1060_hn_calendar_rules_detail_link').getUrl();
                }
                var win = new Leaf.Window({
                    id: 'hn1060_hn_calendar_rules_detail_winid',
                    url: url,
                    params: {
                        winid: 'hn1060_hn_calendar_rules_detail_winid',
                        calendar_id: record.get('calendar_id'),
                        request_id: record.get('request_id')
                    },
                    title: '申请详情',
                    fullScreen: true
                });
                win.on('close', function() {
                    hn1060_query();
                });
            }
            
            function hn1060_record_detail_renderer(value, record, name) {
                if (name == 'record_detail') {
                    return '<a href="javascript:hn1060_detail(' + record.id + ')">详细</a>';
                }
                if (name == 'rule_detail') {
                    return '<a href="javascript:hn1060_rule_query(' + record.id + ')">已生效规则</a>';
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hn1060_hn_calendar_rules_req_ds" autoPageSize="true" autoQuery="true" model="hn.HN1060.hn_calendar_rules_req" selectable="true"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="hn1060_query" text="HLS.QUERY"/>
                <a:gridButton click="hn1060_create" text="HLS.NEW"/>
                <a:gridButton bind="hn1060_hn_calendar_rules_req_grid" text="撤销申请" type="delete"/>
            </a:screenTopToolbar>
            <a:grid id="hn1060_hn_calendar_rules_req_grid" bindTarget="hn1060_hn_calendar_rules_req_ds" marginHeight="80" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="calendar_id_n" prompt="日历" width="150"/>
                    <a:column name="description" prompt="描述" width="250"/>
                    <a:column name="request_date" prompt="申请日期" renderer="Leaf.formatDate"/>
                    <a:column name="owner_user_id_n" prompt="申请人" width="150"/>
                    <a:column name="wfl_status_n" prompt="状态" width="150"/>
                    <a:column name="record_detail" align="center" prompt="详细" renderer="hn1060_record_detail_renderer" width="100"/>
                    <a:column name="rule_detail" align="center" prompt="已生效规则" renderer="hn1060_record_detail_renderer" width="100"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>