<?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[
            function lov_query() {
                var brand_list_details;
                var purchase_purpose_details;
                try {
                    var brand_list_bm = $bm('app.lov.app_hls_car_brand_list');
                    var purchase_purpose_bm = $bm('app.lov.app_hls_car_purchase_purpose_list');
                    var brand_list_map = brand_list_bm.queryAsMap();
                    var purchase_purpose_map = purchase_purpose_bm.queryAsMap();
                    brand_list_details = brand_list_map.getChildren();
                    purchase_purpose_details = purchase_purpose_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,
                    brand_list: [],
                    purchase_purpose_list: []
                };
                var brand_list = result.brand_list;
                var purchase_purpose_list = result.purchase_purpose_list;
            
                for (var i = 0;i < brand_list_details.length;i++) {
                    var brand_list_detail = brand_list_details[i];
                    brand_list.push({
                        "code": brand_list_detail.code,
                        "name": brand_list_detail.name
                    });
                }
                for (var j = 0;j < purchase_purpose_details.length;j++) {
                    var purchase_purpose_detail = purchase_purpose_details[j];
                    purchase_purpose_list.push({
                        "code": purchase_purpose_detail.code,
                        "name": purchase_purpose_detail.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>
