<template>
    <el-button
        type="primary"
        icon="el-icon-plus"
        @click="table_add"
    ></el-button>
	<el-divider></el-divider>
	<scTable
		ref="table"
		:apiObj="apiObj"
		row-key="id"
		:query="query"
		:params="params"
		hidePagination
		hideDo
		style="height: 400px"
	>
		<el-table-column label="类型" prop="name" width="80"></el-table-column>
		<el-table-column
			label="名称"
			prop="name"
			min-width="100"
		></el-table-column>
	</scTable>
    <el-dialog title="创建/编辑" v-model="dialogVisible" width="80%">
        <el-form-item label="策略类型" prop="note" required>
            <el-select
                v-model="saveForm.type"
            >
        </el-select>
		</el-form-item>
        <el-form-item label="策略式" required>
            每隔
            <el-input-number
                v-model="saveForm.interval_.every"
                :min="1"
                style="margin-left: 4px"
            ></el-input-number>
            <el-select
                v-model="saveForm.interval_.period"
            >
            <el-option
                v-for="e in schedulePeriodEnum.values"
                :key="e.key"
                :value="e.key"
                :label="e.text"
            ></el-option>
            </el-select>
		</el-form-item>
    </el-dialog>
</template>
<script>
import { scheduleTypeEnum, schedulePeriodEnum } from "@/utils/enum.js";
const defaultForm = {
    interval_: {},
    crontab_: {}
}
export default {
	name: "myschedule",
	data() {
		return {
            schedulePeriodEnum, scheduleTypeEnum,
            dialogVisible: false,
			apiObj: this.$API.system.myschedule.list,
			query: {
				search: "",
			},
            saveForm: Object.assign({}, defaultForm)
		};
	},
	methods: {
        table_add(){
            this.dialogVisible = true;
            this.$nextTick(() => {
               this.saveForm = Object.assign({}, defaultForm)
            });
        }
    },
	created() {},
	mounted() {},
	computed: {},
	watch: {},
	components: {},
};
</script>
