<!doctype html>
{% load static simpletags sptags %}
<html>
<head>
    <meta charset="utf-8">
    <title>图表</title>

    <!-- 百度地图API，建议大家自己去申请一个AK -->
    {% block baidumap %}
        <script type="text/javascript"
                src="http://api.map.baidu.com/api?v=2.0&ak=BGBn4IcL3n0x5AFNrjQNeRld0Ursdug3"></script>
    {% endblock %}
    <script type="text/javascript" src="{% static '/admin/simpleui-x/js/vue.min.js' %}?_={% get_version %}"></script>
    <script type="text/javascript" src="{% static '/admin/simplepro/js/axios.min.js' %}?_={% get_version %}"></script>
    <script src="{% static 'admin/bawa/render.umd.min.js' %}?_=c_{% get_sp_version %}"></script>
    {#    <script src="{% static 'admin/bawa/render.umd.min.js' %}?_=a_{% get_sp_version %}"></script>#}
</head>
<body>
<div id="app">
    <bawa-render :data="data"></bawa-render>
</div>
<script>
    axios.defaults.withCredentials = true;
    new Vue({
        data: {
            data: {
                components: [],
                settings: {
                    baseUrl: '{% static 'admin/bawa' %}'
                }
            }
        },
        created() {
            const self = this;
            axios.get('{% url 'sp:bawa_data' %}').then(res => {
                let data = res.data;
                self.data.components = data.components;
                //如果settings没有的key，就不覆盖
                for (let key in data.settings) {
                    let value = data.settings[key];
                    //如果设置了属性，但是不合法，就不采用
                    if (typeof (value) != "undefined" && ("" + value).replace(/ /g, '').length != 0) {
                        self.data.settings[key] = data.settings[key];
                    }
                }
            }).catch(err => console.error(e));
        }
    }).$mount('#app');
</script>
</body>
</html>