Add shortId handling for QR
Add renumerate script Add Tasks
This commit is contained in:
@ -13,7 +13,8 @@
|
||||
"import-categories": "node ./scripts/import_categories.js",
|
||||
"import-stock": "node ./scripts/import_stock.js",
|
||||
"import-history": "node ./scripts/import_history.js",
|
||||
"import-history-files": "node ./scripts/import_history_files.js"
|
||||
"import-history-files": "node ./scripts/import_history_files.js",
|
||||
"renumerate-stock": "node ./scripts/renumerate.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@quasar/extras": "^1.16.4",
|
||||
|
31
scripts/renumerate.js
Normal file
31
scripts/renumerate.js
Normal file
@ -0,0 +1,31 @@
|
||||
const PocketBase = require('pocketbase').default
|
||||
|
||||
// Initialize the PocketBase client
|
||||
// const pb = new PocketBase('https://stock.hfsplay.fr')
|
||||
const pb = new PocketBase('http://127.0.0.1:8090')
|
||||
|
||||
async function main () {
|
||||
try {
|
||||
// Authenticate as an admin
|
||||
// await pb.admins.authWithPassword('gyoza@hfsplay.fr', 'gyozagyoza') // Replace with your admin credentials
|
||||
await pb.collection('_superusers').authWithPassword('karkinge@gmail.com', 'k4rk1ng3*') // Replace with your admin credentials
|
||||
console.log('connected !')
|
||||
let stock = await pb.collection('stock').getFullList({
|
||||
sort: 'created'
|
||||
})
|
||||
console.log('Stock items count:', stock.length)
|
||||
for (let i = 0; i < stock.length; i++) {
|
||||
const item = stock[i]
|
||||
if (!item) continue
|
||||
// Update the item with a new ID
|
||||
const updatedItem = await pb.collection('stock').update(item.id, {
|
||||
short_id: i + 1 // Adjust the ID as needed
|
||||
})
|
||||
console.log(`Updated item ${item.id} to new ID ${updatedItem.id}`)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error:', error)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
@ -188,6 +188,8 @@ export default {
|
||||
},
|
||||
async addItem (category) {
|
||||
this.$q.loading.show()
|
||||
// Get next short id
|
||||
let shortId = await this.$store.dispatch('core/getNextShortId')
|
||||
let newItem = {
|
||||
available: true,
|
||||
comment: '',
|
||||
@ -196,7 +198,8 @@ export default {
|
||||
ref: null,
|
||||
state: null,
|
||||
type: category.name,
|
||||
system: null
|
||||
system: null,
|
||||
short_id: shortId
|
||||
}
|
||||
newItem.ref = `${category.code}-${String(this.counters[category.name] + 1).padStart(4, '0')}`
|
||||
await this.$store.dispatch('core/addToCollection', {
|
||||
|
@ -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 = {
|
||||
|
@ -13,7 +13,8 @@ const routes = [
|
||||
{ path: 'dashboard', component: () => import('pages/Dashboard.vue') },
|
||||
{ path: 'category/:categoryCode', props: true, component: () => import('pages/StockItems.vue') },
|
||||
{ path: 'item/:itemRef', props: true, component: () => import('pages/StockItem.vue') },
|
||||
{ path: 'print-settings', props: true, component: () => import('pages/PrintSettings.vue') }
|
||||
{ path: 'print-settings', props: true, component: () => import('pages/PrintSettings.vue') },
|
||||
{ path: ':shortId', props: true, component: () => import('pages/StockItem.vue') }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -30,6 +30,14 @@ export function deleteItem (store, data) {
|
||||
return pb.collection(data.collection).delete(data.data.id)
|
||||
}
|
||||
|
||||
export function getNextShortId (store) {
|
||||
return pb.collection('stock').getFirstListItem('short_id>0', {
|
||||
sort: '-short_id'
|
||||
}).then(item => {
|
||||
return item.short_id + 1
|
||||
})
|
||||
}
|
||||
|
||||
// export function uploadFile (store, file) {
|
||||
// return Firebase.storage().ref().child(Date.now() + file.name).put(file)
|
||||
// }
|
||||
|
Reference in New Issue
Block a user