<template>
  <div style="height: 100%;">
    <route-draft
      ref="routeEdit"
      :selected="selected"
      :map-info="mapInfo"
      :route-data="routeData"
    />
    <route-detail ref="routeDetail" :map-info="mapInfo" @routingSelected="routingSelected" />
  </div>
</template>
<script>
import RouteDraft from './route';
import RouteDetail from './detail';

export default {
    name: 'PathOperate',
    components: {
        RouteDraft,
        RouteDetail
    },
    props: {
        mapInfo: {
            type: Object,
            default() {
                return null;
            }
        },
        selected: {
            type: Object,
            default() {
                return null;
            }
        }
    },
    data() {
        return {
            enabledTab: 'Route',
            routeData: null
        };
    },
    methods: {
        clickEvent(e, model) {
            this.onSelect(model);
        },
        onSelect(model) {
            if (model) {
                this.selected = model;
            } else {
                this.selected = null;
            }
        },
        setDelayUnlockStatus(data, status) {
            if (data && data.delayShowList) {
                data.delayShowList.forEach(elem => {
                    elem.status = status;
                });
            }
        },
        routingSelected: function (data) {
            this.routeData = data;
            if (this.$refs && this.$refs.routeEdit) {
                this.$refs.routeEdit.editData();
            }
        },
        previewRouteEvent: function () {
            if (this.$refs && this.$refs.routeDetail) {
                this.$refs.routeDetail.doShow();
            }
        },
        createRouteEvent: function () {
            if (this.$refs && this.$refs.routeEdit) {
                this.$refs.routeEdit.clear();
            }
        },
        initLoad() {
            this.$refs.routeEdit.batchSectionListFocus(true);
        },
        setSelected(selected) {
            this.$refs.routeEdit.setSelected(selected);
        },
        setCenter(code) {
            this.$emit('setCenter', code);
        },
        batchSectionListFocus(flag) {
            this.$refs.routeEdit.batchSectionListFocus(flag);
        }
    }
};
</script>
