<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:ns1="leaf.application.action" xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
    <a:init-procedure>
        <s:server-script import="app/app_login_check.js"><![CDATA[
        //商业伙伴ORG_基本信息_下拉框
            function lov_query() {
                var legal_form_details;
                var province_details;
                var city_details;
                var district_details;
                try {
                    var legal_form_bm = $bm('app.bp_master.app_hls_legal_form_list');
                    var province_bm = $bm('app.bp_master.app_hls_province_list');
                    var city_bm = $bm('app.bp_master.app_hls_city_list');
                    var district_bm = $bm('app.bp_master.app_hls_district_list');
                    
                    var legal_form_map = legal_form_bm.queryAsMap();
                    var province_map = province_bm.queryAsMap();
                    var city_map = city_bm.queryAsMap();
                    var district_map = district_bm.queryAsMap();
                    
                    legal_form_details = legal_form_map.getChildren();
                    province_details = province_map.getChildren();
                    city_details = city_map.getChildren();
                    district_details = district_map.getChildren();
                    
                    $ctx.parameter.return_status = 'S';
                    $ctx.parameter.return_message = '执行成功';
                    
                } catch (e) {
                    $ctx.parameter.return_status = 'E';
                    $ctx.parameter.return_message = String(e);
                }
            
            
                var result = {
                    result: $ctx.parameter.return_status,
                    message: $ctx.parameter.return_message,
                    legal_form_list: [],
                    province_list: [],
                    city_list: [],
                    disctict_list: []
                };
                
                var legal_form_list = result.legal_form_list;
                var province_list = result.province_list;
                var city_list = result.city_list;
                var disctict_list = result.disctict_list;
            
                for (var i = 0;i < legal_form_details.length;i++) {
                    var legal_form_detail = legal_form_details[i];
                    legal_form_list.push({
                        "code": legal_form_detail.code,
                        "code_name": legal_form_detail.code_name
                    });
                }
                for (var j = 0;j < province_details.length;j++) {
                    var province_detail = province_details[j];
                    province_list.push({
                        "code": province_detail.code,
                        "code_name": province_detail.code_name
                    });
                }
            	for (var j = 0;j < city_details.length;j++) {
                    var city_detail = city_details[j];
                    city_list.push({
                        "code": city_detail.code,
                        "code_name": city_detail.code_name
                    });
                }
                for (var j = 0;j < district_details.length;j++) {
                    var district_detail = district_details[j];
                    disctict_list.push({
                        "code": district_detail.code,
                        "code_name": district_detail.code_name
                    });
                }
                $ctx.parameter.json = JSON.stringify(result);
            }
            
            if ($ctx.parameter.return_status != 'E'&& $ctx.parameter.return_status != 'TIMEOUT') {
                lov_query();
            }
        ]]></s:server-script>
    </a:init-procedure>
    <a:service-output output="/parameter/@json"/>
</a:service>
