<?php
$this->layout('layout/dashboardLayout');
?>

<div id="app">
    <div class="navbar-form" role="search">
        <div class="form-group">
            主键ID:
            <input v-model="state.searchDataProvider.params" type="text" class="form-control" placeholder="Search">
        </div>
        <button type="submit" class="btn btn-default" @click="fetchData">Go!</button>
    </div>

    <div class="panel panel-default">
        <!-- Table -->
        <table class="table">
            <thead>
            <tr>
                <th>value</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="item in state.dataProvider">
                <td>{{ item }}</td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<script>
    const { createApp, reactive } = Vue

    createApp({
        setup() {
            const state = reactive({
                dataProvider: {},
                searchDataProvider: {
                    params: '1'
                }
            })

            function fetchData() {
                fetch('/api/dashboard/form-log', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
                    },
                    body: Qs.stringify(state.searchDataProvider)
                }).then(res => res.json()).then(res => {
                    state.dataProvider = res.data
                    console.log(res)
                })
            }
            return {
                fetchData,
                state
            }
        }
    }).mount('#app')
</script>
