<template>
<div id="app">
    <a href="javascript: void(0);" class="btn" @click="showModal">Show Modal</a>
    <at-modal v-model="modal.show" @on-ok="ok">
        {{date | date}}
    </at-modal>
    <el-button @click="() => panel.show = true">Panel</el-button>
    <at-editor ref="editor"
               @ready="editorReady" />
    <at-upload v-model="mutilpFileList" :limit="5" httpRequest="qiniu" ref="attachesRef">
        <el-button size="small" type="primary">上传附件</el-button>
    </at-upload>
    <image-upload v-model="fileList" httpRequest="qiniu" :limit="1" multiple @on-success="afterImageUpload" />
    <at-panel v-model="panel.show" :keepAlive="false">

        <a href="javascript: void(0);" @click="() => panel.show = false">关闭</a>
        <image-upload v-model="fileList" httpRequest="qiniu" :limit="5" multiple @on-success="afterImageUpload" />
    </at-panel>
</div>
</template>

<script>
import {
    AtModal,
    AtEditor,
    AtImageUpload as ImageUpload
} from '@packages'
import axios from 'axios'
import {
    dataToHump,
    dataToUnderline
} from '@packages/utils'
export default {
    name: 'app',
    components: {
        AtModal,
        AtEditor,
        ImageUpload
    },
    data() {
        return {
            msg: 'Welcome to Your Vue.js App',
            modal: {
                show: false
            },
            fileList: [],
            mutilpFileList: [{
                url:"http://shilin.dkuykt.com/FoDV9CX6ux8Y8XBS1gwp5fBNWncy",
                name:'11111111.png'
            }],
            // fileList: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
            panel: {
                show: false
            },
            date: new Date()
        }
    },
    created() {

        //this.load()

        let data = {
            'first_name': '张',
            'last_name': '三',
            'sex': 1,
            'en': 'zhangSan',
            'likes': ['foot_ball', 'scrollBar', {
                'my_name': 'asd',
                'yourName': 'sss'
            }],
            'obj': {
                'my_name': 'asd',
                'yourName': 'sss'
            }
        }

        let hump = dataToHump(data)
        let line = dataToUnderline(hump)
        console.log(hump)
        console.log(line)
    },
    methods: {
        getToken(data) {
            console.log(data)
        },
        showModal() {
            this.modal.show = true
        },
        ok(done) {
            done()
        },
        editorReady(editor) {
            editor.setData(this.msg)
        },
        load() {
            console.log(axios.interceptors)
            let fn = (opts = {}) => {
                return axios(Object.assign({
                    url: 'http://120.55.12.229:9001/eam/v1.0/equ_types',
                    method: 'POST',
                    data: {
                        type_code: "1",
                        type_name: "1"
                    }
                }, opts)).then(response => {
                    console.log(`success: ${response}`)
                }, error => {
                    console.log(`error: ${error}`)
                })
            }
            fn()
        },
        afterImageUpload(res, file) {
            // debugger
        }
    }
}
</script>

<style>
#app {}
</style>
