<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true">
    <a:init-procedure>
        <a:model-query model="basic.sys_session_info" rootPath="con202_session_info"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con202_clause_templet_link" url="${/request/@context_path}/modules/cont/CON202/con_clause_templet_line.lview"/>
        <a:link id="con_basic_clause_detail_id" url="${/request/@context_path}/modules/cont/CON202/con_basic_clause_detail.lview"/>
        <a:link id="doc_basic_clause_detail_id" url="${/request/@context_path}/modules/cont/CON202/doc_basic_clause_detail.lview"/>
        <script type="text/javascript"><![CDATA[
            function con202_clause_templet_query() {
                $('con202_clause_templet_result_ds').query();
            }
            
            function con202_clause_templet_submit() {
            
               }
            
            function windowopen_templet_line(id) {
                var record = $('con202_clause_templet_result_ds').findById(id);
                var templet_id = record.get('templet_id');
                var templet_usage = record.get('templet_usage');
                var language = record.get('language');
                new Leaf.Window({
                    id: 'con202_clause_templet_window',
                    url: $('con202_clause_templet_link').getUrl() + '?templet_id=' + templet_id + '&templet_usage=' + templet_usage + '&language=' + language,
                    params: null,
                    title: '${l:CON202.CON_CLAUSE_TEMPLET_ASSIGN}',
                    fullScreen: true
                });
            }
            
            function con202_clause_templet_grid_render(value, record, name) {
                if (name == 'company_short_name') {
                    return '${/model/con202_session_info/record/@company_short_name}';
                } else if (name == 'con202_edit') {
                    if (!record.isNew) {
                        return '<a href="javascript:windowopen_templet_line(\'' + record.id + '\');">${l:CON202.EDIT}</a>';
                    }
                    return '';
                }
            }
            
            function con202_clause_templet_functionTreeGrid_editor(record, name) {
                if (record.isNew) {
                    return 'con202_clause_templet_grid_cb';
                }
                return '';
            }
            
            function where_clause_detail(record_id, tmpt_id, tmpt_code, tmpt_desc, templet_usage) {
                var url;
                if (templet_usage == 'REG_SETTLE') {
                    url = $('doc_basic_clause_detail_id').getUrl();
                } else {
                    url = $('con_basic_clause_detail_id').getUrl();
                }
            
                new Leaf.Window({
                    id: 'where_clause_detail_win',
                    url: url,
                    params: {
                        tmpt_id: tmpt_id,
                        tmpt_code: tmpt_code,
                        tmpt_desc: tmpt_desc
                    },
                    width: 1150,
                    height: 430
                });
            }
            
            function where_caluse_renderer(value, record, name) { //
                var record_id = record.id;
                var tmpt_id = record.get('templet_id');
                var tmpt_code = record.get('templet_code');
                var tmpt_desc = record.get('description');
                var templet_usage = record.get('templet_usage');
            
                if (!record.isNew) {
                    return '<a href="javascript:where_clause_detail(' + record_id + ',\'' + tmpt_id + '\',\'' + tmpt_code + '\',\'' + tmpt_desc + '\',\'' + templet_usage + '\')">文本打印条件</a>';
                }
            }
            
            function edit_function(record, name) {
                if (record.isNew) {
                    if (name == 'templet_code') {
                        return 'con202_clause_templet_grid_tf';
                    }
                }
                return '';
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="con202_clause_templet_tmplet_usage_ds" lookupCode="CON_TMPLET_USAGE"/>
            <a:dataSet id="con202_clause_templet_approval_status_ds" lookupCode="CON_TERMS_APPROVE_STATUS"/>
            <a:dataSet id="con202_clause_templet_enabled_status_ds" lookupCode="ENABLED_STATUS"/>
            <a:dataSet id="con202_clause_templet_con_language_ds" lookupCode="CON_LANGUAGE"/>
            <a:dataSet id="con202_clause_templet_query_ds">
                <a:fields>
                    <a:field name="templet_code"/>
                    <a:field name="description"/>
                    <a:field name="templet_usage_name" displayField="code_value_name" options="con202_clause_templet_tmplet_usage_ds" returnField="templet_usage" valueField="code_value"/>
                    <a:field name="approval_status_name" displayField="code_value_name" options="con202_clause_templet_approval_status_ds" returnField="approval_status" valueField="code_value"/>
                    <a:field name="enabled_flag_des" displayField="code_value_name" options="con202_clause_templet_enabled_status_ds" returnField="enabled_flag" valueField="code_value"/>
                    <a:field name="ele_content_flag_des" displayField="code_value_name" options="con202_clause_templet_enabled_status_ds" returnField="ele_content_flag" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con202_clause_templet_result_ds" autoPageSize="true" autoQuery="true" model="cont.CON202.con_clause_templet" queryDataSet="con202_clause_templet_query_ds" selectable="true">
                <a:fields>
                    <a:field name="templet_code" required="true"/>
                    <a:field name="description" required="true"/>
                    <a:field name="templet_usage" required="true"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="ele_content_flag" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="language" defaultValue="CHINESE"/>
                    <a:field name="templet_usage_name" displayField="code_value_name" options="con202_clause_templet_tmplet_usage_ds" required="true" returnField="templet_usage" valueField="code_value"/>
                    <a:field name="language_name" displayField="code_value_name" options="con202_clause_templet_con_language_ds" required="true" returnField="language" valueField="code_value"/>
                    <a:field name="approval_status" defaultValue="APPROVED"/>
                    <a:field name="tax_type_rate" lovHeight="500" lovService="cont.CON202.fnd_tax_type_codes" lovWidth="500" title="税率">
                        <a:mapping>
                            <a:map from="tax_type_rate" to="tax_type_rate"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="approval_status_name" defaultValue="${l:CON202.UNAPPROVED}"/>
                    <a:field name="doc_plugin_flag" checkedValue="Y" uncheckedValue="N"/>
                    <a:field name="doc_template_id_des" lovHeight="500" lovService="cont.CON202.hls_doc_file_templet_for_lov" lovWidth="500" title="文件模板">
                        <a:mapping>
                            <a:map from="templet_id" to="doc_template_id"/>
                            <a:map from="templet_name" to="doc_template_id_des"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="con202_clause_templet_query" text="HLS.QUERY"/>
                <a:gridButton bind="con202_clause_templet_functionTreeGrid" type="add"/>
                <a:gridButton bind="con202_clause_templet_functionTreeGrid" type="clear"/>
                <a:gridButton bind="con202_clause_templet_functionTreeGrid" type="save"/>
            </a:screenTopToolbar>
            <a:form labelSeparator=" " row="1">
                <a:textField name="templet_code" bindTarget="con202_clause_templet_query_ds" prompt="CON202.CON_CLAUSE_TEMPLET.TEMPLET_CODE"/>
                <a:textField name="description" bindTarget="con202_clause_templet_query_ds" prompt="CON202.CON_CLAUSE_TEMPLET.DESCRIPTION"/>
                <a:comboBox name="templet_usage_name" bindTarget="con202_clause_templet_query_ds" prompt="CON202.CON_CLAUSE_TEMPLET.TEMPLET_USAGE"/>
                <a:comboBox name="approval_status_name" bindTarget="con202_clause_templet_query_ds" prompt="CON202.CON_CLAUSE_TEMPLET.APPROVAL_STATUS_NAME"/>
                <a:comboBox name="enabled_flag_des" bindTarget="con202_clause_templet_query_ds" prompt="CON202.CON_CLAUSE_TEMPLET.ENABLED_FLAG_DES"/>
                <a:comboBox name="ele_content_flag_des" bindTarget="con202_clause_templet_query_ds" prompt="电子签约合同文本"/>
            </a:form>
            <a:grid id="con202_clause_templet_functionTreeGrid" bindTarget="con202_clause_templet_result_ds" marginHeight="130" marginWidth="50" navBar="true" width="800">
                <a:columns>
                    <a:column name="company_short_name" prompt="CON202.CON_CLAUSE_TEMPLET.COMPANY_SHORT_NAME" renderer="con202_clause_templet_grid_render" width="150"/>
                    <a:column name="templet_code" editorFunction="edit_function" prompt="CON202.CON_CLAUSE_TEMPLET.TEMPLET_CODE" width="250"/>
                    <a:column name="description" editor="con202_clause_templet_grid_tf" prompt="CON202.CON_CLAUSE_TEMPLET.DESCRIPTION" width="130"/>
                    <a:column name="templet_usage_name" editor="con202_clause_templet_grid_cb" prompt="CON202.CON_CLAUSE_TEMPLET.TEMPLET_USAGE" width="120"/>
                    <a:column name="approval_status_name" prompt="CON202.CON_CLAUSE_TEMPLET.APPROVAL_STATUS_NAME" width="80"/>
                    <a:column name="print_num" align="right" editor="con202_clause_templet_grid_nf" prompt="打印份数" width="50"/>
                    <a:column name="con202_edit" prompt="CON202.EDIT" renderer="con202_clause_templet_grid_render" width="60"/>
                    <a:column name="enabled_flag" editor="con202_clause_templet_grid_ck" prompt="HLS030.ENABLED_FLAG" width="40"/>
                    <!--电子签约文本-->
                    <a:column name="ele_content_flag" editor="con202_clause_templet_grid_ck" prompt="电子签约合同文本" width="120"/>
                    <a:column name="language_name" editor="con202_clause_templet_grid_cb" prompt="CON202.LANGUAGE" width="60"/>
                    <a:column name="where_caluse" prompt="文本打印条件" renderer="where_caluse_renderer" width="100"/>
                    <a:column name="version_date" editor="con202_clause_templet_grid_tf" prompt="版本号" width="100"/>
                    <a:column name="order_seq" align="center" editor="con202_clause_templet_grid_tf" prompt="序号" width="80"/>
                    <a:column name="tax_type_rate" align="right" editor="con202_clause_templet_grid_lv" prompt="税率" renderer="Leaf.formatNumber"/>
                    <a:column name="doc_plugin_flag" editor="con202_clause_templet_grid_ck" prompt="插件标志" width="50"/>
                    <a:column name="doc_template_id_des" editor="con202_clause_templet_grid_lv" prompt="文件模板" width="80"/>
                    <a:column name="note" editor="con202_clause_templet_grid_tf" prompt="备注" width="140"/>
                </a:columns>
                <a:editors>
                    <a:numberField id="con202_clause_templet_grid_nf" allowDecimals="false" allowNegative="false"/>
                    <a:textField id="con202_clause_templet_grid_tf"/>
                    <a:checkBox id="con202_clause_templet_grid_ck"/>
                    <a:comboBox id="con202_clause_templet_grid_cb"/>
                    <a:datePicker id="con202_date_ed"/>
                    <a:lov id="con202_clause_templet_grid_lv"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
