<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: chenlingfeng  
    $Date: 2016年11月18日13:10:00
    $Revision: 1.0  
    $Purpose: 付款先决条件变更维护
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="csh910_submit_condition_change_req_link" model="csh.CSH910N.csh_submit_condition_change_req" modelaction="execute"/>
        <a:link id="csh910_cancle_condition_change_req_link" model="csh.CSH910N.csh_cancel_condition_change_req" modelaction="execute"/>
        <a:link id="csh910_save_condition_change_req_link" model="csh.CSH910N.hn_con_payment_conditions_hd_for_query" modelaction="update"/>
        <a:link id="csh910_hn_payment_cond_change_req_back_turn_link" url="${/request/@context_path}/modules/csh/CSH910/csh_prerequisites_for_payment.lview"/>
        <a:link id="csh910n_hn_con_payment_condition_detail_link" url="${/request/@context_path}/modules/csh/CSH910N/hn_con_payment_condition_detail.lview"/>
        <script type="text/javascript"><![CDATA[
            function csh910_hn_payment_cond_change_req_maintain_query() {
                $('csh910_hn_payment_cond_change_req_after_change_result_ds').query();
            }
            
            function csh910_hn_payment_cond_change_req_close() {
                $('${/parameter/@winid}').close();
            }
            
            function csh910_hn_payment_cond_change_req_submit() {
                Leaf.showConfirm('${l:PROMPT}', '您确定要提交审批吗?', function() {
                    var record = $('csh910_hn_payment_cond_change_req_ds').getAt(0);
                    Leaf.request({
                        url: $('csh910_submit_condition_change_req_link').getUrl(),
                        para: {
                            header_id: record.get('header_id')
                        },
                        success: function(res) {
                            csh910_hn_payment_cond_change_req_close();
                        },
                        failure: function() {},
                        error: function() {},
                        scope: this
                    });
                });
                return;
            }
            
            function csh910_hn_payment_cond_change_req_cancle() {
                Leaf.showConfirm('${l:PROMPT}', '您确定撤销审批吗?', function() {
                    var record = $('csh910_hn_payment_cond_change_req_ds').getAt(0);
                    Leaf.request({
                        url: $('csh910_cancle_condition_change_req_link').getUrl(),
                        para: {
                            header_id: record.get('header_id')
                        },
                        success: function(res) {
                            csh910_hn_payment_cond_change_req_close();
                        },
                        failure: function() {},
                        error: function() {},
                        scope: this
                    });
                });
                return;
            }
            
            function csh910_hn_payment_cond_change_req_save() {
                var record = $('csh910_hn_payment_cond_change_req_maintain_query_ds').getAt(0);
                Leaf.request({
                    url: $('csh910_save_condition_change_req_link').getUrl(),
                    para: {
                        header_id: record.get('header_id'),
                        description: record.get('description')
                    },
                    success: function(res) {},
                    failure: function() {},
                    error: function() {},
                    scope: this
                });
            
            }
            
            function hn_hd_detail_renderer(value, record, name) {
                if (record.get('record_type') == 'PAYMENT_AMOUNT') {
                    return Leaf.formatMoney(value);
                }
                return value;
            }
            
            function open_conditions_detail(id) {
                var record = $('csh910_hn_payment_cond_change_req_after_change_result_ds').findById(id);
                var url = $('csh910n_hn_con_payment_condition_detail_link').getUrl();
                var win = new Leaf.Window({
                    id: 'csh900_con_payment_conditions_detail_win_id',
                    url: url,
                    params: {
                        before_hd_id: record.get('hd_id'),
                        after_hd_id: record.get('change_hd_id'),
                        line_id:record.get('line_id'),
                        edit_flag:'Y',
                        winid: 'csh900_con_payment_conditions_detail_win_id'
                    },
                    title: '付款先决条件变更',
                    fullScreen: true
                });
            }
            
            
            function change_conditions_detail(value, record, name) {
                return '<a href="javascript:open_conditions_detail(' + record.id + ')">' + '明细' + '</a>';
            
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="csh910_hn_payment_cond_change_req_ds" autoCreate="true">
                <a:fields>
                    <a:field name="header_id" defaultValue="${/parameter/@header_id}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="csh910_hn_payment_cond_change_req_maintain_query_ds" autoQuery="true" model="csh.CSH910N.hn_payment_cond_change_hd_for_query" queryDataSet="csh910_hn_payment_cond_change_req_ds">
                <a:fields>
                    <a:field name="change_req_number" readOnly="true"/>
                    <a:field name="req_date" datatype="date" readOnly="true"/>
                    <a:field name="bp_name" readOnly="true"/>
                    <a:field name="manager" readOnly="true"/>
                    <a:field name="project_number" readOnly="true"/>
                    <a:field name="project_name" readOnly="true"/>
                    <a:field name="description" required="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="csh910_hn_payment_cond_change_req_after_change_result_ds" autoQuery="true" model="csh.CSH910N.hn_con_payment_conditions_hd_for_query" queryDataSet="csh910_hn_payment_cond_change_req_ds" selectable="true"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="csh910_hn_payment_cond_change_req_close" text="关闭"/>
                <a:gridButton click="csh910_hn_payment_cond_change_req_save" text="保存"/>
                <a:gridButton click="csh910_hn_payment_cond_change_req_submit" text="提交审批"/>
                <a:gridButton click="csh910_hn_payment_cond_change_req_cancle" text="撤销变更"/>
            </a:screenTopToolbar>
            <a:form column="1" labelWidth="120" marginWidth="50" title="变更信息">
                <a:hBox>
                    <a:textField name="change_req_number" bindTarget="csh910_hn_payment_cond_change_req_maintain_query_ds" prompt="变更编号"/>
                    <a:textField name="req_date" bindTarget="csh910_hn_payment_cond_change_req_maintain_query_ds" prompt="变更日期" renderer="Leaf.formatDate"/>
                    <a:textField name="bp_name" bindTarget="csh910_hn_payment_cond_change_req_maintain_query_ds" prompt="承租人名称" width="335"/>
                </a:hBox>
                <a:hBox>
                    <a:textField name="manager" bindTarget="csh910_hn_payment_cond_change_req_maintain_query_ds" prompt="项目经理"/>
                    <a:textField name="project_number" bindTarget="csh910_hn_payment_cond_change_req_maintain_query_ds" prompt="支付表编号"/>
                    <a:textField name="project_name" bindTarget="csh910_hn_payment_cond_change_req_maintain_query_ds" prompt="支付表名称" width="335"/>
                </a:hBox>
                <a:hBox>
                    <a:textArea name="description" bindTarget="csh910_hn_payment_cond_change_req_maintain_query_ds" height="50" prompt="变更说明" width="800"/>
                </a:hBox>
            </a:form>
            <a:grid id="csh900_con_payment_conditions_detail_grid_id" bindTarget="csh910_hn_payment_cond_change_req_after_change_result_ds" marginHeight="180" marginWidth="50" navBar="true">
                <a:columns>
                    <a:column name="description" align="center" prompt="描述" width="120"/>
                    <a:column name="note" prompt="备注" width="200"/>
                    <a:column name="record_type_n" prompt="分类" width="250"/>
                    <a:column name="hd_detail" align="right" prompt="次级分组维度" renderer="hn_hd_detail_renderer" width="250"/>
                    <!--  <a:column name="bp_name" prompt="承租人名称" width="200"/> -->
                    <!--  <a:column name="project_name" prompt="项目名称" width="200"/> -->
                    <!--  <a:column name="employee_name" align="center" prompt="项目经理" width="80"/> -->
                    <a:column name="hd_id" align="center" prompt="变更明细" renderer="change_conditions_detail" width="80"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>