用组合穿梭器设置年月选择框的时候,最后一个选项截止到当前月的自定义json代码

{
    "status": 0,
    "msg": null,
    "data": {
        "options": [        
            {% set start_year=2019 %}            
            {% set ns=namespace(cur_year=1,cur_date="1") %}
            {% for x in range(100) if ns.cur_year > 0 %}
                {% if loop.index0 > 0 %},{%endif %}
                {
                    {% set ns.cur_year = start_year+loop.index0%}
                    "label": "{{ns.cur_year}}年",
                    "selectMode": "tree",
                    "children": [
                        {
                            "label": "全选",
                            "children": [
                                {% for x in range(12) if ns.cur_date %}
                                    {% if loop.index0 > 0 %},{%endif %}                        
                                    {% set ns.cur_date = "%d-%02d"|format(ns.cur_year,loop.index)%}                            
                                    {
                                        "label": "{{loop.index}}月",                                
                                        "value": "{{ns.cur_date}}-"
                                    }
                                    {% if ns.cur_date == "%Y-%m"|now_date %}
                                        {% set ns.cur_year = 0 %}
                                        {% set ns.cur_date = "" %}
                                    {% endif %}                            
                                {% endfor %}
                            ]
                        }
                    ]
                }
            {% endfor %}

        ]
    }
}

问题没有解决?请留言提问

results matching ""

    No results matching ""