<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: peter soong $
    $Date: 2014-07-31 10:09:47 $
    $Revision: 1.0 $
    $Purpose:  编码规则分配
    
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure><![CDATA[
    ]]></a:init-procedure>
    <a:view>
        <a:link id="pageLink_objectScreen_rule_info" url="${/request/@context_path}/modules/fnd/FND1910/fnd_coding_rules.lview"/>
        <a:link id="sys_service_welcome_link" url="${/request/@context_path}/welcome.lview"/>
        <script type="text/javascript"><![CDATA[
            function fnd_1910_next() {
                history.go(1);
            }
            
            function fnd_1910_back() {
                history.go(-1);
            }
            
            function fnd_1910_quit() {
                location.href = $('sys_service_welcome_link').getUrl();
                parent.shMenu('show');
            }
            
            function objectDs_grid_add() {
                $('objectDs_grid').showEditorByRecord($('objectDs').create());
            }
            
            function objectDs_grid_clear() {
                $('objectDs_grid').clear();
            }
            
            
            
            function objectDs_query() {
                $('objectDs').query();
            }
            
            function resetCodingRuleObject() {
                $('para_objectDs').reset();
            }
            
            function render_objectDs_grid(value, record, name) {
                if (name == 'rule_info') {
                    if (!record.isNew) {
                        return '<a href="javascript:winOpen_rule_info(' + record.get('coding_rule_object_id') + ')">${l:FND1910.LINK.RULE_INFO}</a>';
                    }
                }
            }
            
            function winOpen_rule_info(coding_rule_object_id) {
                new Leaf.Window({
                    id: 'fnd_coding_rules_window',
                    url: $('pageLink_objectScreen_rule_info').getUrl(),
                    params: {
                        coding_rule_object_id: coding_rule_object_id
                    },
                    title: '${l:FND1910.WIN_TITLE.RULE_INFO}',
                    height: 580,
                    width: 750
                });
            }
            
            function editorFunction_objectDs_grid(record, name) {
                if (record.isNew) {
                    if (name == 'document_type_desc') {
                        var document_category = record.get('document_category');
                        if (Ext.isEmpty(document_category)) {
                            return '';
                        } else {
                            record.getField('document_type_desc').setLovPara('document_category', document_category);
                            return 'objectDs_grid_editor_lov';
                        }
            
                    }
                    if (name == 'company_code' || name == 'operation_unit_name') {
                        return 'objectDs_grid_editor_lov';
                    }
                    if (name == 'document_category_desc') {
                        return 'objectDs_grid_editor_comb';
                    }
            
            
                }
                return '';
            
            
            
            }
            
            function priorityEdit(record, name) {
            
                if (record.isNew) {
                    return 'objectDs_grid_editor_nf';
                }
                return '';
            }
            
            function onUpdate_objectDs(ds, record, name, value, oldValue) {
                if (name == 'document_category_desc') {
                    record.set('document_type', '');
                    record.set('document_type_desc', '');
                }
            }
            
            function objectDs_grid_submit() {
                var result_ds = $('objectDs');
                if (result_ds.validate()) {
                    result_ds.submit();
                }
            }
            
            /*  function on_beforetriggerclick(lov) {
             var record = $('hls_ebank_log_query').getCurrentRecord();
             var bp_id = record.get('bp_id');
             record.getField('accnbr').setLovPara('bp_id', bp_id);
             } */
            
            function initLov(value, record, name) {
                var document_category = record.get('document_category');
                record.getField('coding_rule_desc').setLovPara('document_category', document_category);
                return value;
            
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="documentCategoryDs" loadData="true" model="fnd.FND1910.fnd_code_rule_doc_category_v"/>
            <a:dataSet id="para_objectDs" model="fnd.FND1910.fnd_coding_rule_objects_query">
                <a:fields>
                    <a:field name="operation_unit_name" lovGridHeight="300" lovHeight="450" lovLabelWidth="100" lovService="fnd.FND1910.fnd_operation_units_lov?ORDER_FIELD=operation_unit_code" lovWidth="550" title="HLS.OPERATION_UNIT">
                        <a:mapping>
                            <a:map from="operation_unit_id" to="operation_unit_id"/>
                            <a:map from="description" to="operation_unit_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="company_short_name" lovGridHeight="300" lovHeight="450" lovService="fnd.FND1910.fnd_coding_rule_objects_company_lov?ORDER_FIELD=company_code" lovWidth="500" title="HLS.COMPANY_SHORT_NAME">
                        <a:mapping>
                            <a:map from="company_id" to="company_id"/>
                            <a:map from="company_short_name" to="company_short_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="document_category_desc" displayField="description" options="documentCategoryDs" returnField="document_category" valueField="document_category"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="objectDs" autoQuery="true" fetchAll="false" model="fnd.FND1910.fnd_coding_rule_objects_query" pageSize="15" queryDataSet="para_objectDs" queryUrl="${/request/@context_path}/autocrud/fnd.FND1910.fnd_coding_rule_objects_query/query?ORDER_FIELD=document_category_dec,priority" selectable="true" submitUrl="${/request/@context_path}/autocrud/fnd.FND1910.fnd_coding_rule_objects_save_update/batch_update">
                <a:fields>
                    <a:field name="document_category_desc" displayField="description" options="documentCategoryDs" required="true" returnField="document_category" valueField="document_category"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="document_type_desc" lovGridHeight="300" lovHeight="450" lovLabelWidth="100" lovService="fnd.FND1910.fnd_code_rule_doc_type_v" lovWidth="600" title="HLS.DOCUMENT_TYPE_DESC">
                        <a:mapping>
                            <a:map from="document_type" to="document_type"/>
                            <a:map from="description" to="document_type_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="company_code" lovGridHeight="300" lovHeight="450" lovService="fnd.FND1910.fnd_coding_rule_objects_company_lov?ORDER_FIELD=company_code" lovWidth="500" title="HLS.COMPANY_SHORT_NAME">
                        <a:mapping>
                            <a:map from="company_id" to="company_id"/>
                            <a:map from="company_code" to="company_code"/>
                            <a:map from="company_short_name" to="company_short_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="operation_unit_name" lovGridHeight="300" lovHeight="450" lovLabelWidth="100" lovService="fnd.FND1910.fnd_operation_units_lov?ORDER_FIELD=operation_unit_code" lovWidth="550" title="HLS.OPERATION_UNIT">
                        <a:mapping>
                            <a:map from="operation_unit_id" to="operation_unit_id"/>
                            <a:map from="operation_unit_code" to="operation_unit_code"/>
                            <a:map from="description" to="operation_unit_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="priority" defaultValue="1" required="true"/>
                    <a:field name="coding_rule_desc" lovGridHeight="300" lovHeight="450" lovLabelWidth="100" lovService="fnd.FND1911.fnd_code_rule_v" lovWidth="600" title="编码规则分配">
                        <a:mapping>
                            <a:map from="description" to="coding_rule_desc"/>
                            <a:map from="coding_rule_id" to="coding_rule_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="coding_rules_id"/>
                    <a:field name="priority"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onUpdate_objectDs"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="fnd_1910_back" text="HLS.BACK"/>
                <a:gridButton click="fnd_1910_next" text="HLS.FORWARD"/>
                <a:gridButton click="fnd_1910_quit" text="HLS.EXIT"/>
                <a:gridButton click="objectDs_grid_add" text="HLS.NEW"/>
                <a:gridButton click="objectDs_grid_clear" text="HLS.CLEAR"/>
                <a:gridButton click="objectDs_grid_submit" text="HLS.SAVE"/>
                <a:gridButton click="objectDs_query" text="HLS.QUERY"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="90" title="HAP_QUERY_TITLE">
                <a:comboBox name="document_category_desc" bindTarget="para_objectDs">
                    <a:events>
                        <a:event name="enterdown" handler="objectDs_query"/>
                    </a:events>
                </a:comboBox>
                <a:textField name="document_type_desc" bindTarget="para_objectDs">
                    <a:events>
                        <a:event name="enterdown" handler="objectDs_query"/>
                    </a:events>
                </a:textField>
                <a:lov name="company_short_name" bindTarget="para_objectDs">
                    <a:events>
                        <a:event name="enterdown" handler="objectDs_query"/>
                    </a:events>
                </a:lov>
                <a:lov name="operation_unit_name" bindTarget="para_objectDs">
                    <a:events>
                        <a:event name="enterdown" handler="objectDs_query"/>
                    </a:events>
                </a:lov>
            </a:form>
            <a:grid id="objectDs_grid" bindTarget="objectDs" marginHeight="180" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="document_category_desc" align="left" editorFunction="editorFunction_objectDs_grid" width="150"/>
                    <a:column name="document_type_desc" align="left" editorFunction="editorFunction_objectDs_grid" width="150"/>
                    <a:column name="company_code" align="left" editorFunction="editorFunction_objectDs_grid" width="150"/>
                    <a:column name="company_short_name" align="left" width="150"/>
                    <a:column name="operation_unit_name" align="left" editorFunction="editorFunction_objectDs_grid" width="150"/>
                    <a:column name="priority" align="right" editor="objectDs_grid_editor_nf" width="50"/>
                    <a:column name="enabled_flag" editor="objectDs_grid_editor_check" sortable="true" width="50"/>
                    <!-- <a:column name="rule_info" align="center" prompt="FND1910.WIN_TITLE.RULE_INFO" renderer="render_objectDs_grid"/> -->
                    <a:column name="coding_rule_desc" align="center" editor="objectDs_grid_editor_lov" prompt="编码规则" renderer="initLov"/>
                </a:columns>
                <a:editors>
                    <a:comboBox id="objectDs_grid_editor_comb"/>
                    <a:lov id="objectDs_grid_editor_lov"/>
                    <a:textField id="objectDs_grid_editor_tf"/>
                    <a:numberField id="objectDs_grid_editor_nf" allowDecimals="false" allowNegative="false"/>
                    <a:checkBox id="objectDs_grid_editor_check"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>