﻿<template>
    <div>
        <input type="text" class="form-control" :name="name" ref="cron" :value="value" :title="value" />
    </div>
</template>
<script>
    export default {
        name: 'iot-cron',
        props: ['title', 'name', 'value', 'data'],
        watch: {
            value(val) {
                this.$emit('update:value', val)
            },
        },
        mounted: function () {
            var vm = this;
            this.$nextTick(function () {
                $(vm.$refs.cron).jqCron({
                    lang: 'cn',
                    enabled_year: true,
                    enabled_minute: true,
                    multiple_dom: true,
                    multiple_month: true,
                    multiple_mins: true,
                    multiple_dow: true,
                    multiple_time_hours: true,
                    multiple_time_minutes: true,
                    default_value: $(vm.$refs.cron).val().substr(2),
                    bind_method: {
                        set: function ($element, value) {
                            $element.val('0 ' + value);
                            vm.$emit('update:value', $(vm.$refs.cron).val());
                            vm.$emit('change', vm.name);
                        }
                    },
                    no_reset_button: false
                }).jqCronGetInstance();
            });
        }
    };
</script>