<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:c="leaf.application.action" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="cont.CON632.con632_sys_user" rootPath="sys_user_path"/>
        <a:model-query fetchAll="true" model="cont.CON632.con_collection_tool_lv_query" rootPath="con_collection_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="execute_con_collection_tool_ln" model="cont.CON632.con_collection_tool_ln" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[
            function con_collection_ln_save() {
                $('con_collection_tool_ln_ds').submit();
            }
            
            function con_collection_ln_back() {
                $('con_collection_tool_ln_winid').close();
            }
            
            function con_collection_submitsuccess(ds) {
                var rejest_id = ds.data['0'].data.rejest_id;
                Leaf.request({
                    url: $('execute_con_collection_tool_ln').getUrl(),
                    para: {
                        collection_id: '${/parameter/@collection_id}',
                        rejest_id: rejest_id
                    },
                    success: function(rsc) {
                        Leaf.SideBar.show({
                            msg: '操作成功',
                            duration: 2000
                        });
                        $('con_collection_tool_ln_winid').close();
                    },
                    scope: this
                });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="con_collection_tool_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="collection_measures_n" defaultValue="${/model/con_collection_path/record/@collection_measures_n}" readOnly="true"/>
                    <a:field name="tool_number" defaultValue="${/model/con_collection_path/record/@tool_number}" readOnly="true"/>
                    <a:field name="create_time" defaultValue="${/model/con_collection_path/record/@create_time}" readOnly="true"/>
                    <a:field name="create_by" defaultValue="${/model/con_collection_path/record/@create_by}" readOnly="true"/>
                    <!-- <a:field name="user_name" readOnly="true"/>
                    <a:field name="time" readOnly="true"/> -->
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_collection_tool_ln_ds" autoCreate="true" model="cont.CON632.con_collection_tool_ln">
                <a:fields>
                    <a:field name="project_id" defaultValue="${/parameter/@project_id}"/>
                    <a:field name="contract_id" defaultValue="${/parameter/@contract_id}"/>
                    <a:field name="collection_id" defaultValue="${/parameter/@collection_id}"/>
                    <a:field name="rejest_note"/>
                    <a:field name="user_name" readOnly="true"/>
                    <a:field name="time" readOnly="true"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="con_collection_submitsuccess"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton id="con_collection_back_id" click="con_collection_ln_back" text="退出"/>
                <a:gridButton id="con_collection_save_id" click="con_collection_ln_save" text="提交"/>
            </a:screenTopToolbar>
            <a:form labelWidth="150" title="催收取消申请" width="800">
                <a:hBox>
                    <a:textField name="collection_measures_n" bindTarget="con_collection_tool_query_ds" prompt="催收工具"/>
                    <a:textField name="tool_number" bindTarget="con_collection_tool_query_ds" prompt="催收编码"/>
                    <a:textField name="create_time" bindTarget="con_collection_tool_query_ds" prompt="催收时间"/>
                </a:hBox>
                <a:hBox>
                    <a:textField name="create_by" bindTarget="con_collection_tool_query_ds" prompt="催收人员"/>
                    <a:textField name="user_name" bindTarget="con_collection_tool_ln_ds" prompt="操作者"/>
                    <a:dateTimePicker name="time" bindTarget="con_collection_tool_ln_ds" prompt="操作时间"/>
                </a:hBox>
                <a:hBox>
                    <a:textArea name="rejest_note" bindTarget="con_collection_tool_ln_ds" colspan="3" prompt="取消原因" width="620"/>
                </a:hBox>
            </a:form>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
            Ext.onReady(function() {
                if ('${/parameter/@load_date}' == 'Y') {
                    $('con_collection_tool_ln_ds').setQueryParameter('rejest_id', '${/parameter/@rejest_id}');
                    $('con_collection_tool_ln_ds').query();
                    var record_ln = $('con_collection_tool_ln_ds').getAt(0);

                    record_ln.getField('rejest_note').setRequired(false);
                    record_ln.getField('rejest_note').setReadOnly(true);
            
                    //按钮失效
                    $('con_collection_back_id').hide();
                    $('con_collection_save_id').hide();
                } else {
                    var myDate = new Date();
                    var record = $('con_collection_tool_ln_ds').getAt(0);
                    record.set('time', myDate);
                    record.set('user_name', '${/model/sys_user_path/record/@description}');
                }
            });
        ]]></script>
    </a:view>
</a:screen>
