<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangyu  
    $Date: 2016-11-22 下午17:20:11  
    $Revision: 1.0  
    $Purpose: 工作流选择部门审批
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="wfl_workflow_assigned_unit_id_link" url="${/request/@context_path}/modules/wfl_screen/hn_wfl_unit_assigned.lsc"/>
        <script type="text/javascript"><![CDATA[
            function assign_wfl_unit_assign() {
                var ds = $('assigned_unit_id_ds');
                var records = ds.getAll();
                var param = {};
                var saveData = [];
                for (var i = 0;i < records.length;i++) {
                    var lineData = {};
                    lineData['unit_id'] = records[i].get('unit_id');
                    lineData['instance_id'] = '${/parameter/@instance_id}';
                    saveData.push(lineData);
                }
                param['details'] = saveData;
                Leaf.showConfirm('${l:HLS.PROMPT}', '是否确定由已选择的部门审批?', function() {
                    Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
                    Leaf.request({
                        url: $('wfl_workflow_assigned_unit_id_link').getUrl(),
                        para: {
                            param: param,
                            instance_id:'${/parameter/@instance_id}'
                        },
                        success: function(response) {
                            Leaf.Masker.unmask(Ext.getBody());
                                zjwfl5110_approvePage_close();
                        },
                        failure: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        error: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        scope: this
                    });
                });
            }
            
            function unit_query() {
                $('assigned_unit_id_ds').query();
                $('un_assign_unit_id_ds').query();
            }
            
            function win_close() {
                $('zj_wfl_workflow_service_window').close();
            }
            
            function right_selected() {
                var left_selectedAll = $('un_assign_unit_id_ds').getSelected();
                for (var i = 0;i < left_selectedAll.length;i++) {
                    $('assigned_unit_id_ds').add(left_selectedAll[i]);
                }
                $('un_assign_unit_id_ds_id').clear();
            }
            
            function left_selected() {
                var right_selectedAll = $('assigned_unit_id_ds').getSelected();
                for (var i = 0;i < right_selectedAll.length;i++) {
                    $('un_assign_unit_id_ds').add(right_selectedAll[i]);
                }
                $('assigned_unit_id_ds_id').clear();
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="query_unit_ds" autoCreate="true">
                <a:fields>
                    <a:field name="unit_code"/>
                    <a:field name="unit_name"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="assigned_unit_id_ds" autoQuery="true" queryDataSet="query_unit_ds" queryUrl="${/request/@context_path}/autocrud/wfl_screen.WORKFLOW_ASSIGN.hn_wfl_unit_assigned/query?instance_id=${/parameter/@instance_id}" selectable="true"/>
            <a:dataSet id="un_assign_unit_id_ds" autoQuery="true" model="wfl_screen.WORKFLOW_ASSIGN.hn_wfl_unit_un_assigned" queryDataSet="query_unit_ds" queryUrl="${/request/@context_path}/autocrud/wfl_screen.WORKFLOW_ASSIGN.hn_wfl_unit_un_assigned/query?instance_id=${/parameter/@instance_id}" selectable="true"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="win_close" text="关闭"/>
                <a:gridButton click="unit_query" text="查询"/>
                <a:gridButton click="assign_wfl_unit_assign" text="确定"/>
            </a:screenTopToolbar>
            <a:form title="查询条件" width="605">
                <a:hBox>
                    <a:textField name="unit_code" bindTarget="query_unit_ds" prompt="部门代码"/>
                    <a:textField name="unit_name" bindTarget="query_unit_ds" prompt="部门名称"/>
                </a:hBox>
            </a:form>
            <a:hBox>
                <a:form title="未选择部门">
                    <a:grid id="un_assign_unit_id_ds_id" bindTarget="un_assign_unit_id_ds" height="300" navBar="true" width="250">
                        <a:columns>
                            <a:column name="unit_code" prompt="部门代码" width="100"/>
                            <a:column name="unit_name" prompt="部门名称" width="100"/>
                        </a:columns>
                    </a:grid>
                </a:form>
                <a:vBox>
                    <a:button click="right_selected" height="25" style="margin-top:30px;" text="&gt;"/>
                    <a:button click="left_selected" height="25" style="margin-top:10px;" text="&lt;"/>
                </a:vBox>
                <a:form title="已选择部门">
                    <a:grid id="assigned_unit_id_ds_id" bindTarget="assigned_unit_id_ds" height="300" navBar="true" width="250">
                        <a:columns>
                            <a:column name="unit_code" prompt="部门代码" width="100"/>
                            <a:column name="unit_name" prompt="部门名称" width="100"/>
                        </a:columns>
                    </a:grid>
                </a:form>
            </a:hBox>
        </a:screenBody>
    </a:view>
</a:screen>