<template>
  <div class="q-pa-md">
    <q-table :title="name+'一覧'" :selection="type" v-model:selected="selected" :columns="columns" :rows="rows" />
  </div>
</template>
<script>
import { ref,onMounted,reactive } from 'vue'
import { api } from 'boot/axios';

export default {
  name: 'AppSelect',
  props: {
    name: String,
    type: String
  },
  setup() {
  const columns = [
  { name: 'id', required: true,label: 'アプリID',align: 'left',field: 'id',sortable: true},
  { name: 'name', align: 'center', label: 'アプリ名', field: 'name', sortable: true },
  { name: 'creator', label: '作成者', field: 'creator', sortable: true },
  { name: 'createdate', label: '作成日時', field: 'createdate' }
  ]
  const rows = reactive([])
    onMounted( () => {
        api.get('allapps').then(res =>{
         res.data.apps.forEach((item) =>
        {
          rows.push({id:item.appId,name:item.name,creator:item.creator.name,createdate:item.createdAt});
        }
        )
      });
      });
    return {
      columns,
      rows,
      selected: ref([]),
    }
  },

}
</script>
