<template>
    <div class="page">
        <headNav title="移离情况"></headNav>

        <div class="illegal-container" v-if="show">
            <van-cell-group title="是否按规定移离违法车辆">
                <van-radio-group v-model="result">
                    <template v-for="item in move_result">
                        <van-radio class="radio" :key="item.k" :name="item.k">{{item.v}}</van-radio>
                    </template>
                </van-radio-group>
            </van-cell-group>

            <div style="margin: 16px;">
                <van-button block round type="info" @click="onSubmit">确定</van-button>
            </div>
        </div>

        <v-mask :showOverLay="showOverLay"></v-mask>
    </div>
</template>

<script>
import headNav from '@/components/headNav.vue';
import mask_overLay from "@/components/overLay_xy.vue";

import { isEmpty } from '@/utils/tool';
import punishmentMixin from '@/mixins/punishment';
import { put } from '@/utils/http.js';
import { Notify } from 'vant';

export default {
    components: {
        headNav,
        "v-mask": mask_overLay,
    },
    data () {
        return {
            showOverLay: false,
            result: '',
        }
    },
    computed: {
        id() {
            return this.$route.params.id + '';
        },
        show() {
            return !isEmpty(this.id);
        },
    },
    mixins: [punishmentMixin],
    methods: {
        onSubmit() {
            if (isEmpty(this.result)) {
                Notify({ type: 'warning', message: '请选择移离情况' });
                return;
            }
            this.showOverLay = true;
            put(`/v2/api/illegal_occupy/${this.id}/move_result?move_result=${this.result}`).then(res => {
                this.$toast.success('提交成功');
                this.showOverLay = false;
                this.$router.back();
            }).catch(e => {
                this.showOverLay = false;
            });
        },
    },
}
</script>

<style lang="scss" scoped>
.illegal-container {
    margin-top: 47px;
    .radio {
        font-size: 14px;
        padding: 10px;
    }
}
</style>