55 tk-searchfilters( :fields ="fieldsList" )
66 .q-pa-md
77 q-table(
8- :rows ="rows " : rows- per- page- options= "[5, 10, 15]" : loading= "pending" : columns= "columns" row-key ="sequence" : visible- columns= "visibleColumns"
8+ :rows ="tickets.data " : rows- per- page- options= "[5, 10, 15]" : loading= "pending" : columns= "columns" row-key ="sequence" : visible- columns= "visibleColumns"
99 v-model:pagination ="pagination" title ="Tickets" @request ="onRequest"
1010 rows-per-page-label ="Lignes par page" no-data-label ="Aucune donnée" loading-label ="Chargement..." no-results-label ="Aucun résultat"
1111 :pagination-label ="(firstRowIndex, endRowIndex, totalRowsNumber) => `${firstRowIndex}-${endRowIndex} sur ${totalRowsNumber} lignes`"
6363 span.q-ml-sm {{ props.row.envelope.assigned.length === 0 ? "Pas d'assigné" : props.row.envelope.assigned[0].name }}
6464 span( v-if ="props.row.envelope.assigned.length > 1" ) , {{ props.row.envelope.assigned.length -1 }} autre{{ props.row.envelope.assigned.length === 2 ? '' : 's' }}...
6565 q-tooltip.text-body2 ( transition-show ="scale" transition-hide ="scale" ) ...{{ [...props.row.envelope.assigned].slice(1).map(s => s.name).join(', ') }}
66-
67-
68-
69-
7066</template >
7167
7268<script lang="ts" setup>
@@ -83,8 +79,19 @@ const daysjs = useDayjs()
8379const route = useRoute ()
8480const router = useRouter ()
8581
82+ const { data : tickets, pending, refresh, error } = await useHttpApi (' tickets/ticket' , {
83+ method: ' get' ,
84+ query: computed (() => {
85+ return {
86+ ... route .query ,
87+ }
88+ })
89+ })
90+ const { data : categories, pending : categoriesPending, refresh : categoriesRefresh, error : categoriesError } = await useHttpApi (' core/categories' )
91+ const { data : states, pending : statesPending, refresh : statesRefresh, error : statesError } = await useHttpApi (' tickets/state' )
92+
8693onMounted (async () => {
87- pagination .value ! .rowsNumber = await ticketFetch . data . value ? .total
94+ pagination .value ! .rowsNumber = tickets .total
8895 const query = { ... route .query }
8996 const limit = query .limit ?? 10
9097 const skip = query .skip ?? 0
@@ -201,36 +208,6 @@ const columnsType = ref([
201208 { name: ' actions' , type: ' text' },
202209])
203210
204- const ticketFetch = useHttpApi (' tickets/ticket' , {
205- method: ' get' ,
206- query: computed (() => {
207- console .log (" ticketFetch computed" )
208- return {
209- ... route .query ,
210- }
211- })
212- })
213- const categoriesFetch = useHttpApi (' core/categories' )
214- const stateFetch = useHttpApi (' tickets/state' )
215-
216- const states = computed (() => {
217- return {
218- data: [... stateFetch .data .value ?.data ],
219- total: stateFetch .data .value ?.total
220- }
221- })
222- const rows = computed (() => {
223- return ticketFetch .data .value ?.data ?? []
224- })
225-
226- const refresh = () => {
227- ticketFetch .refresh ()
228- }
229-
230- const pending = computed (() => {
231- return ticketFetch .pending .value
232- })
233-
234211const goToTicket = (ticket : Ticket ) => {
235212 router .push (` /ticket/${ticket ._id } ` )
236213}
@@ -245,7 +222,7 @@ const pagination = ref<QTableProps['pagination']>({
245222
246223const onRequest = async (props : any ) => {
247224 const { page, rowsPerPage, sortBy, descending } = props .pagination
248- pagination .value ! .rowsNumber = await ticketFetch . data . value ? .total
225+ pagination .value ! .rowsNumber = tickets .total
249226 pagination .value ! .page = page
250227 pagination .value ! .rowsPerPage = rowsPerPage
251228 pagination .value ! .sortBy = sortBy
@@ -324,8 +301,8 @@ const deleteTickets = () => {
324301}
325302
326303provide (' fieldsList' , fieldsList )
327- provide (' stateFetch' , stateFetch )
328- provide (' categoriesFetch' , categoriesFetch )
304+ provide (' stateFetch' , { data: states , pending: statesPending , refresh: statesRefresh , error: statesError } )
305+ provide (' categoriesFetch' , { data: categories , pending: categoriesPending , refresh: categoriesRefresh , error: categoriesError } )
329306provide (' ticketType' , ticketType )
330307
331308 </script >
0 commit comments