<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.document_category=&apos;CONTRACT&apos;" fetchAll="true" model="basic.hls_document_type_for_lov" rootPath="con505_document_type_path"/>
        <a:model-query fetchAll="true" model="cont.CON301.con_contract_business_type_list" rootPath="con505_business_type_list"/>
        <a:model-query defaultWhereClause="(exists(select 1 from hls_lease_org_assign ha where ha.unit_id=t1.unit_id))" fetchAll="true" model="basic.exp_org_unit_manager_lov" rootPath="con505_exp_org_unit_manager_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con_contract_query_link_id" url="${/request/@context_path}/modules/cont/CON504/con_contract_query.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_contract_distribute_back_link_id" model="cont.CON505.con_contract_distribute_back" modelaction="execute"/>
        <a:link id="car_modify_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_maintain.lview"/>
        <a:link id="car_modify_mananger_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_maintain_manager.lview"/>
        <a:link id="prj_project_query_link_id" url="${/request/@context_path}/modules/prj/PRJ500/prj_project_create_tree.lview"/>
        <script type="text/javascript"><![CDATA[
            function con505_con_contract_detail(record_id, ds_id) {
                var record = $('con505_contract_result_ds').findById(record_id);
                var param = record.data;
                 var maintain_type = 'QUERY';
               
                    param['function_usage'] = 'QUERY';
                    param['maintain_type'] = maintain_type;
                    param['document_type'] = record.get('prj_document_type');
                    param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                param['document_id'] = record.get('project_id');
                if (record.get('prj_document_type') == 'CARLS') {
                    param['function_code'] = 'PRJ502D';
                   
                    
                    if (record.get('lease_channel') == '02') {
                        hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'car_modify_mananger_link', 'projectQueryScreen_mainDs');
                    } else {
                        hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'car_modify_link', 'projectQueryScreen_mainDs');
                    }
            
                }else if(record.get('prj_document_type') == 'PRJ'){
                    param['function_code'] = 'PRJ600Q';
                    hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'prj_project_query_link_id', 'projectQueryScreen_mainDs');
                }
            }
            
            function con505_con_contract_confirm() {
                var current_record = $('con505_contract_result_ds').getSelected()[0];
                var param = current_record.data;
                param['document_id'] = current_record.get('contract_id');
                con505_param_set_value(param);
            }
            
            function con505_param_set_value(param) {
                param['function_code'] = 'CON504';
                param['function_usage'] = 'MODIFY';
                param['maintain_type'] = 'READONLY';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                param['winid'] = 'con_contract_query_window';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_query_link_id');
            }
            
            
            function con505_con_contract_return() {
                history.go(-1);
            }
            
            function con505_con_contract_query() {
                $('con505_contract_result_ds').query();
            }
            
            function con505_con_contract_reset() {
                $('con505_contract_query_ds').reset();
            }
            
            function con505_contract_query_ds_onUpdate(ds, record, name, value, oldvalue) {
                if (name == 'lease_start_date_from') {
                    if (!Leaf.isEmpty(value) && Leaf.isEmpty(record.get('lease_start_date_to'))) {
                        record.set('lease_start_date_to', value);
                    }
                }
            }
            
            function project_detail_vender(value, record, name, config_record) {
                return '<a href="javascript:con505_con_contract_detail(' + record.id + ')">' + value + '</a>';
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON505"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <a:dataSet id="con505_employee_name_of_manager_ds">
                <a:datas dataSource="/model/con505_exp_org_unit_manager_path"/>
            </a:dataSet>
            <a:dataSet id="con505_unit_name_ds" loadData="true" model="basic.exp_org_unit_name_lov"/>
            <a:dataSet id="con505_lease_organization_name_ds" loadData="true" model="basic.hls_lease_organization_for_lov"/>
            <a:dataSet id="con505_division_name_ds" loadData="true" model="basic.hls_division_for_lov"/>
            <a:dataSet id="con505_lease_channel_name_ds" loadData="true" model="basic.hls_lease_channel_for_lov"/>
            <a:dataSet id="con505_yes_or_no_ds" lookupCode="YES_NO"/>
            <a:dataSet id="con505_document_type_name_ds">
                <a:datas dataSource="/model/con505_document_type_path"/>
            </a:dataSet>
            <a:dataSet id="con505_business_type_ds">
                <a:datas dataSource="/model/con505_business_type_list"/>
            </a:dataSet>
            <a:dataSet id="con505_contract_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="bp_code" autoComplete="true" lovGridHeight="350" lovHeight="500" lovLabelWidth="100" lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="550" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code"/>
                            <a:map from="bp_id" to="bp_id_tenant"/>
                            <a:map from="bp_name" to="bp_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id_tenant"/>
                    <a:field name="project_number" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="prj.PRJ501.prj_project_for_lov" lovWidth="500" title="HLS.PROJECT_NUMBER">
                        <a:mapping>
                            <a:map from="project_number" to="project_number"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="project_employee_name" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="basic.hls_exp_employees_for_lov?sales_flag=Y" lovWidth="500" title="HLS.SALES_EMPLOYEE">
                        <a:mapping>
                            <a:map from="name" to="project_employee_name"/>
                            <a:map from="employee_id" to="employee_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_number" autoComplete="true" autoCompleteField="contract_number" lovGridHeight="300" lovHeight="450" lovService="cont.CON500.con_contract_number_lov" lovWidth="500" title="HLS.CONTRACT_NUMBER">
                        <a:mapping>
                            <a:map from="contract_number" to="contract_number"/>
                            <a:map from="contract_name" to="contract_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="owner_user_id_n" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="basic.sys_user_for_lov" lovWidth="500" title="员工">
                        <a:mapping>
                            <a:map from="user_id" to="owner_user_id"/>
                            <a:map from="description" to="owner_user_id_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="con_content_confirm_status_des" defaultValue="否" displayField="code_value_name" options="con505_yes_or_no_ds" returnField="con_content_confirm_status" valueField="code_value"/>
                    <a:field name="con_content_confirm_status" defaultValue="N"/>
                    <a:field name="employee_id"/>
                    <a:field name="employee_name_of_manager" displayField="mgr_employee_name" options="con505_employee_name_of_manager_ds" returnField="employee_id_of_manager" valueField="mgr_employee_id"/>
                    <a:field name="unit_name" displayField="unit_name" options="con505_unit_name_ds" returnField="unit_id" valueField="unit_id"/>
                    <a:field name="lease_organization_name" displayField="description" options="con505_lease_organization_name_ds" returnField="lease_organization" valueField="lease_organization"/>
                    <a:field name="division_desc" displayField="description" options="con505_division_name_ds" returnField="division" valueField="division"/>
                    <a:field name="lease_channel_desc" displayField="description" options="con505_lease_channel_name_ds" returnField="lease_channel" valueField="lease_channel"/>
                    <a:field name="document_type_desc" displayField="description" options="con505_document_type_name_ds" returnField="document_type" valueField="document_type"/>
                    <a:field name="business_type_desc" displayField="business_type_desc" options="con505_business_type_ds" returnField="business_type" valueField="business_type"/>
                    <a:field name="contract_ref_content_flag" defaultValue="Y"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="con505_contract_query_ds_onUpdate"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="con505_contract_result_ds" autoPageSize="true" autoQuery="true" model="cont.CON500.con_contract_v_for_confirm" queryDataSet="con505_contract_query_ds" queryUrl="${/request/@context_path}/autocrud/cont.CON500.con_contract_v_for_confirm/query" selectable="true" selectionModel="single">
                <a:events>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="con505_con_contract_return" text="HLS.RETURN"/>
                <a:gridButton click="con505_con_contract_query" text="HLS.QUERY"/>
                <a:gridButton click="con505_con_contract_reset" text="HLS.RESET"/>
                <!-- <a:gridButton click="con505_con_contract_content_print" text="CON505.CON_CONTENT_PRINT"/> -->
                <a:gridButton click="con505_con_contract_confirm" text="合同文本确认"/>
            </a:screenTopToolbar>
            <a:form column="4" labelSeparator=" " labelWidth="100" marginWidth="30" title="CON301.CONTRACT_QUERY">
                <a:lov name="contract_number" bindTarget="con505_contract_query_ds" prompt="HLS.CONTRACT_NUMBER"/>
                <a:textField name="contract_name" bindTarget="con505_contract_query_ds" prompt="HLS.CONTRACT_NAME"/>
                <a:lov name="project_number" bindTarget="con505_contract_query_ds" prompt="HLS.PROJECT_NUMBER"/>
                <a:comboBox name="unit_name" bindTarget="con505_contract_query_ds" prompt="供应商"/>
                <a:lov name="bp_code" bindTarget="con505_contract_query_ds" prompt="HLS.TENANT_CODE"/>
                <a:textField name="bp_name" bindTarget="con505_contract_query_ds" prompt="HLS.TENANT_NAME"/>
                <a:lov name="owner_user_id_n" bindTarget="con505_contract_query_ds" prompt="金融经理"/>
                <a:comboBox name="lease_organization_name" bindTarget="con505_contract_query_ds" prompt="HLS.LEASE_ORGANIZATION"/>
                <!-- <a:datePicker name="lease_start_date_from" bindTarget="con505_contract_query_ds" prompt="HLS.LEASE_START_DATE_FROM"/> -->
                <!-- <a:datePicker name="lease_start_date_to" bindTarget="con505_contract_query_ds" prompt="HLS.LEASE_START_DATE_TO"/> -->
                <a:comboBox name="division_desc" bindTarget="con505_contract_query_ds" prompt="HLS.DIVISION_NAME"/>
                <a:comboBox name="lease_channel_desc" bindTarget="con505_contract_query_ds" prompt="HLS.LEASE_CHANNEL_NAME"/>
                <a:comboBox name="con_content_confirm_status_des" bindTarget="con505_contract_query_ds" prompt="文本确认状态"/>
            </a:form>
            <a:grid id="con501_con_contract_grid_ds" bindTarget="con505_contract_result_ds" marginHeight="265" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="contract_number" lock="true" prompt="HLS.CONTRACT_NUMBER" width="120"/>
                    <a:column name="contract_name" prompt="HLS.CONTRACT_NAME" width="150"/>
                    <!-- <a:column name="lease_start_date" prompt="HLS.LEASE_START_DATE" renderer="Leaf.formatDate" width="80"/> -->
                    <a:column name="project_number" prompt="申请编号" renderer="project_detail_vender"/>
                    <a:column name="unit_name" prompt="供应商"/>
                    <a:column name="bp_name" prompt="HLS.TENANT_NAME" width="150"/>
                    <!--      <a:column name="project_name" prompt="HLS.PROJECT_NAME" width="150"/> -->
                    <a:column name="owner_user_id_n" prompt="金融经理" width="70"/>
                    <a:column name="employee_name" prompt="融资区域经理" width="100"/>
                    <a:column name="lease_organization_desc" prompt="HLS.LEASE_ORGANIZATION"/>
                    <a:column name="division_desc" prompt="HLS.DIVISION_NAME" width="70"/>
                    <a:column name="lease_channel_desc" prompt="HLS.LEASE_CHANNEL_NAME" width="70"/>
                    <a:column name="document_type_desc" prompt="HLS.CONTRACT_TYPE" width="90"/>
                    <!-- <a:column name="other_tmpt_clause_desc" prompt="合同模板条件（其它）" width="90"/> -->
                    <a:column name="contract_status_desc" prompt="HLS.CONTRACT_STATUS" width="60"/>
                    <a:column name="con_content_confirm_status_des" align="center" prompt="文本确认状态" width="100"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
