Add shortId handling for QR

Add renumerate script
Add Tasks
This commit is contained in:
mcarquigny
2025-06-27 15:35:31 +02:00
parent 6459dbd68c
commit a7225eb054
6 changed files with 95 additions and 5 deletions

View File

@ -4,6 +4,7 @@
<div class="q-ma-none text-h3 text-weight-bolder row" :class="{'text-faded': !item.name}">
<span class="q-mr-md">{{ item.name || '---- -- ----' }}</span>
<q-chip square size="lg" class="text-white q-mr-md" color="secondary">{{item.ref}}</q-chip>
<q-chip square outline size="lg" class="q-mr-md" color="secondary">{{item.short_id}}</q-chip>
<q-chip square size="lg" v-if="item.deleted" color="red">Supprimé</q-chip>
</div>
<h5 class="q-ma-none q-pb-md text-grey">{{item.type}}</h5>
@ -151,7 +152,17 @@
</q-item-section>
<q-item-section>
<q-item-label lines="3" v-html="event.text.split('\n').join('</br>')"></q-item-label>
<q-item-label caption><span class="text-capitalize">{{ event.user }}</span></q-item-label>
<q-item-label caption>
<q-icon name="task" class="q-mr-sm" size="xs"
v-if="event.type === 'issue'"
:color="event.solved_at ? 'green' : 'grey'"
/>
<span class="text-capitalize">{{ event.user }}</span>
<template v-if="event.solved_at">
<q-icon name="arrow_right" size="sm"/>
fait par <span class="text-capitalize">{{ event.solved_by }}</span> le {{getDate(event.solved_at)}}
</template>
</q-item-label>
</q-item-section>
<q-item-section side top>
<q-item-label caption>{{ getDate(event.created) }}</q-item-label>
@ -178,6 +189,11 @@
color="secondary"
/>
<br/>
<q-btn-group outline spread>
<q-btn :outline="pendingHistoryType !== 'comment'" color="secondary" label="Info" icon="info" @click="pendingHistoryType = 'comment'"/>
<q-btn :outline="pendingHistoryType !== 'issue'" color="secondary" label="Tâche" icon="task" @click="pendingHistoryType = 'issue'"/>
</q-btn-group>
<br/>
<q-uploader
:accept="'.jpg,.png'"
:factory="uploadFile"
@ -214,6 +230,10 @@
<span>{{ getDate(selectedHistory.created) }}</span>
</div>
</q-card-section>
<q-card-section>
<q-btn outline color="secondary" label="Marquer comme terminé" @click="setTaskDone(selectedHistory)"></q-btn>
</q-card-section>
<q-separator/>
<q-card-actions align="right">
<q-btn flat color="red" @click.stop="removeHistory(selectedHistory)">Supprimer</q-btn>
<q-btn flat color="grey" @click.stop="showHistory = false;selectedHistory = null">Fermer</q-btn>
@ -231,11 +251,12 @@ import QRCode from 'qrcode'
export default {
name: 'StockItem',
props: ['itemRef'],
props: ['itemRef', 'shortId'],
data () {
return {
showHistoryForm: false,
pendingHistory: null,
pendingHistoryType: 'comment',
changed: false,
hasFile: false,
username: null,
@ -272,7 +293,20 @@ export default {
}
},
created: function () {
if (this.shortId) {
let itemRef = this.stock.find(item => {
return item.short_id === parseInt(this.shortId)
})?.ref
console.log('Redirecting to item with ref:', itemRef)
if (itemRef) this.$router.push(`/item/${itemRef}`)
}
this.loadItem()
this.$watch(
() => this.itemRef,
(newId, oldId) => {
this.loadItem()
}
)
},
mounted () {
this.username = this.$q.localStorage.getItem('username')
@ -296,6 +330,7 @@ export default {
data: {
ref: this.itemRef,
text: this.pendingHistory,
type: this.pendingHistoryType,
user: this.$store.state.core.username,
image_file: file,
date: date.toISOString()
@ -351,6 +386,17 @@ export default {
})
})
},
setTaskDone (history) {
this.$store.dispatch('core/updateItem', {
collection: 'history',
itemId: history.id,
data: {
...history,
solved_at: new Date().toISOString(),
solved_by: this.username
}
})
},
async uploadFile (file) {
// Resize and compress the image before uploading
const options = {