<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei  
    $Date: 2016-5-6 下午3:07:19  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="prj810_prj_project_create_con_link" model="prj.PRJ810.prj_project_create_con" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
            function contract_screen_quit(){
                $('${/parameter/@winid}').close();
            }
            
            function create_contract_button(){
                var create_con_ds=$('contract_choose_division_ds');
                if(create_con_ds.validate()){
                    var record=create_con_ds.getAt(0);
                   Leaf.showConfirm('${l:HLS.PROMPT}', '确认创建'+record.get('division_desc')+'合同吗?', function() {
                     Leaf.Masker.mask($('${/parameter/@winid}').wrap, '正在执行');
                    Leaf.request({
                        url: $('prj810_prj_project_create_con_link').getUrl(),
                        para: {
                            project_id: '${/parameter/@project_id}',
                            division:record.get('division'),
                            contract_number:record.get('contract_number')
                        },
                        success: function() {
                             Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
                             $('${/parameter/@winid}').close();
                        } ,
                        failure: function() {
	                         Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
	                    },
	                    error: function() {
	                        Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
	                    },
                        scope: this
                    });
                });
                }
            }
            
             function contract_number_time(record, name, value) {
                        var reg = /[\u4e00-\u9fa5]/;
                        if (!reg.test(value)) {
                            return true;
                        }
                        return '合同编号不能包含汉字';
                    }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="projectQueryScreen_divisionDs" autoQuery="true" loadData="true" model="prj.PRJ810.hls_division_for_lov" queryUrl="${/request/@context_path}/autocrud/prj.PRJ810.hls_division_for_lov/query?document_type=${/parameter/@document_type}"/>
            <a:dataSet id="contract_choose_division_ds" autoCreate="true">
                <a:fields>
                    <a:field name="division_desc" displayField="description" options="projectQueryScreen_divisionDs" required="true" returnField="division" valueField="division"/>
                    <a:field name="division" required="true"/>
                    <a:field name="contract_number" required="true" validator="contract_number_time"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <!-- <a:screenTitle/> -->
                <a:gridButton click="contract_screen_quit" text="HLS.EXIT"/>
                <a:gridButton click="create_contract_button" text="创建合同"/>
            </a:screenTopToolbar>
            <a:form title="项目创建合同" width="300">
                <a:comboBox name="division_desc" bindTarget="contract_choose_division_ds" prompt="产品线"/>
                <a:textField name="contract_number" bindTarget="contract_choose_division_ds" prompt="合同编号" typeCase="UPPER"/>
            </a:form>
        </a:screenBody>
    </a:view>
</a:screen>