<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="oth201_other_list_deal_link" url="${/request/@context_path}/modules/oth/OTH401/oth_other_wfl_deal.lsc"/>
        <script type="text/javascript"><![CDATA[
            function oth201_query() {
                $('oth201_other_list_deal_ds').query();
            }
            
            function oth201_other_list_deal_select_func(record) {
                if (record.get('process_flag') !== 'Y' && record.get('status') === 'APPROVED') {
                    return true;
                }
                return false;
            }
            
            function oth201_save() {
                var list_ds = $('oth201_other_list_deal_ds');
                var records = list_ds.getSelected();
                var param = {};
                var saveData = [];
                if (records.length <= 0) {
                    Leaf.showMessage('提示', '请至少选择一条数据!');
                }else if(list_ds.validate(true)){
                    for (var i = 0;i < records.length;i++) {
                        var lineData = {};
                        lineData['oa_id'] = records[i].get('oa_id');
                        lineData['process_suggestion'] = records[i].get('process_suggestion');
                        saveData.push(lineData);
                    }
                    param['details'] = saveData;
                    Leaf.request({
                        url: $('oth201_other_list_deal_link').getUrl(),
                        para: {
                            param: param
                        },
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                            $('oth201_other_list_deal_ds').query();
                        },
                        scope: this
                    });
                }
            }
            
            function successHandle() {
                $('oth201_other_list_deal_ds').query();
            }
            
            function process_editor_func(record, name) {
                if (name == 'process_flag_desc' ) {
                    if(record.get('process_flag') !== 'Y' && record.get('status') === 'APPROVED'){
                        record.getField(name).setReadOnly(false);
                    }else{
                        record.getField(name).setReadOnly(true);
                    }
                	return 'editor_cb';
                }
                if (name == 'process_suggestion' ) {
                    if(record.get('process_flag') !== 'Y' && record.get('status') === 'APPROVED'){
                        record.getField(name).setReadOnly(false);
                    }else{
                        record.getField(name).setReadOnly(true);
                    }
                	return 'editor_tf';
                }
                return '';
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="oth201_status_ds" lookupCode="OTHER_WFL_WORKFLOW_STATUS"/>
            <a:dataSet id="oth201_process_flag_ds" lookupCode="YES_NO"/>
            <a:dataSet id="oa_type_ds" lookupCode="OA_TYPE"/>
            <a:dataSet id="oth201_other_query_deal_ds" autoCreate="true">
                <a:fields>
                    <a:field name="oa_type"/>
                    <a:field name="oa_type_n" displayField="code_value_name" options="oa_type_ds" returnField="oa_type" valueField="code_value"/>
                    <a:field name="config_id_desc" lovGridHeight="350" lovHeight="500" lovService="oth.OTH201.oth_get_other_auto_config_for_lov" lovWidth="500" title="自动处理方案选择">
                        <a:mapping>
                            <a:map from="config_id" to="config_id"/>
                            <a:map from="config_code" to="config_code"/>
                            <a:map from="description_desc" to="config_id_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="auto_flag_desc" displayField="code_value_name" options="oth201_process_flag_ds" returnField="auto_flag" valueField="code_value"/>
                    <a:field name="status_desc" displayField="code_value_name" options="oth201_status_ds" returnField="status" valueField="code_value"/>
                    <a:field name="process_flag_desc" displayField="code_value_name" options="oth201_process_flag_ds" returnField="process_flag" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="oth201_other_list_deal_ds" autoPageSize="true" autoQuery="true" bindName="list_ds" model="oth.OTH401.oth_bgfl_oa_auto_deal" queryDataSet="oth201_other_query_deal_ds" selectFunction="oth201_other_list_deal_select_func" selectable="true">
                <a:fields>
                    <a:field name="auto_flag"/>
                    <a:field name="description" readOnly="true"/>
                    <a:field name="reason" readOnly="true"/>
                    <a:field name="auto_flag_desc" displayField="code_value_name" options="oth201_process_flag_ds" returnField="auto_flag" valueField="code_value"/>
                    <a:field name="process_flag"/>
                    <a:field name="process_flag_desc" displayField="code_value_name" options="oth201_process_flag_ds" returnField="process_flag" valueField="code_value"/>
                    <a:field name="process_suggestion" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="successHandle"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="oth201_query" text="查询"/>
                <a:gridButton click="oth201_save" text="处理"/>
            </a:screenTopToolbar>
            <a:form column="3" labelWidth="120" marginWidth="30" title="HLS.QUERY_TITLE">
                <a:comboBox name="oa_type_n" bindTarget="oth201_other_query_deal_ds" prompt="事项分类"/>
                <a:textField name="description" bindTarget="oth201_other_query_deal_ds" prompt="申请事项"/>
                <a:textField name="reason" bindTarget="oth201_other_query_deal_ds" prompt="申请事项"/>
                <a:comboBox name="status_desc" bindTarget="oth201_other_query_deal_ds" prompt="审批状态"/>
                <a:comboBox name="process_flag_desc" bindTarget="oth201_other_query_deal_ds" prompt="是否处理"/>
                <a:textField name="process_suggestion" bindTarget="oth201_other_query_deal_ds" prompt="处理意见"/>
                <!-- <a:lov name="config_id_desc" bindTarget="oth201_other_query_deal_ds" prompt="自动处理方案"/>
                <a:textField name="oa_parameter1_desc" bindTarget="oth201_other_query_deal_ds" prompt="参数1描述"/>
                <a:comboBox name="auto_flag_desc" bindTarget="oth201_other_query_deal_ds" prompt="自动处理"/> -->
            </a:form>
            <a:grid id="oth201_other_deal_grid" bindTarget="oth201_other_list_deal_ds" marginHeight="200" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="oa_type_n" lock="true" prompt="事项分类" width="120"/>
                    <a:column name="description" editor="editor_tf" lock="true" prompt="申请事项" width="300"/>
                    <a:column name="reason" editor="editor_tf" prompt="申请原因" width="280"/>
                    <a:column name="status_desc" align="center" prompt="审批状态" width="80"/>
                    <a:column name="process_flag_desc" align="center" editorFunction="process_editor_func" prompt="是否处理" width="80"/>
                    <a:column name="process_suggestion" editorFunction="process_editor_func" prompt="处理意见" width="280"/>
                    <!-- <a:column name="auto_flag" editorFunction="editor_func" lock="true" prompt="是否自动处理" width="80"/>
                    <a:column name="config_id_desc" editorFunction="editor_func" prompt="自动处理方案" width="120"/>
                    <a:column name="oa_parameter1" align="center" editorFunction="editor_func" prompt="参数1" width="60"/>
                    <a:column name="oa_parameter1_desc" prompt="参数1描述" width="120"/>
                    <a:column name="oa_parameter2" align="center" editorFunction="editor_func" prompt="参数2" width="60"/>
                    <a:column name="oa_parameter2_desc" prompt="参数2描述" width="120"/>
                    <a:column name="oa_parameter3" align="center" editorFunction="editor_func" prompt="参数3" width="60"/>
                    <a:column name="oa_parameter3_desc" prompt="参数3描述" width="120"/> -->
                </a:columns>
                <a:editors>
                    <a:textArea id="editor_tf" height="200"/>
                    <a:comboBox id="editor_cb"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>