<template>
    <div>
        <h2>从其他游戏复制分类结构</h2>
        <el-form ref="form" :model="form" label-width="120px">

            <el-form-item label="当前游戏名称" style="width: 60%;">
                <el-input v-model="form.title"></el-input>
            </el-form-item>
            <el-form-item label="复制游戏" style="width: 60%;">
                <el-select v-model="form.id" filterable placeholder="请选择">
                    <el-option
                            v-for="item in codes"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="onSubmit">立即创建</el-button>
            </el-form-item>
        </el-form>
    </div>

</template>

<script>
    import axios from '../../../common/axios';
    export default {
        name: "add",
        data() {
            return {
                codes: [{
                    value: '选项1',
                    label: '黄金糕'
                }, {
                    value: '选项2',
                    label: '双皮奶'
                }, {
                    value: '选项3',
                    label: '蚵仔煎'
                }, {
                    value: '选项4',
                    label: '龙须面'
                }, {
                    value: '选项5',
                    label: '北京烤鸭'
                }],
                radio: '1',
                form: {
                    title: '',
                    region: '',
                    date1: '',
                    date2: '',
                    delivery: false,
                    type: [],
                    resource: '',
                    desc: '',
                    radio: '1'
                }
            };
        },
        methods: {
            getRootTree() {
                let array = [];
                axios({
                    method: 'post',
                    url: 'https://api-ces-test.oasgames.com/api/item/list',
                    params: {
                        parent_id: 0
                    }
                }).then(function (response) {

                    for (let key in response.data) {

                        array.push({value: response.data[key].id, label: response.data[key].title});
                    }
                    console.log(array);

                });
                this.codes = array;
            },
            onSubmit() {
                console.log('submit!');
            }
        },
        mounted() {
            this.getRootTree();
        }
    };
</script>

<style scoped>

</style>
