Compare commits
2 Commits
361bb0c1ed
...
a7225eb054
Author | SHA1 | Date | |
---|---|---|---|
a7225eb054 | |||
6459dbd68c |
@ -13,7 +13,8 @@
|
|||||||
"import-categories": "node ./scripts/import_categories.js",
|
"import-categories": "node ./scripts/import_categories.js",
|
||||||
"import-stock": "node ./scripts/import_stock.js",
|
"import-stock": "node ./scripts/import_stock.js",
|
||||||
"import-history": "node ./scripts/import_history.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": {
|
"dependencies": {
|
||||||
"@quasar/extras": "^1.16.4",
|
"@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()
|
@ -20,7 +20,7 @@
|
|||||||
</q-item-section>
|
</q-item-section>
|
||||||
|
|
||||||
<q-item-section side top>
|
<q-item-section side top>
|
||||||
<q-item-label caption>{{timeAgo(history.date)}}</q-item-label>
|
<q-item-label caption>{{timeAgo(history.date || history.created)}}</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
</q-list>
|
</q-list>
|
||||||
@ -63,7 +63,7 @@ export default {
|
|||||||
if (hoursDiff < 24) {
|
if (hoursDiff < 24) {
|
||||||
return `il y a ${hoursDiff} heure(s)`
|
return `il y a ${hoursDiff} heure(s)`
|
||||||
} else {
|
} else {
|
||||||
let daysDiff = date.getDateDiff(date2, date1)
|
let daysDiff = date.getDateDiff(date2, date1, 'days')
|
||||||
return `il y a ${daysDiff} jour(s)`
|
return `il y a ${daysDiff} jour(s)`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -188,6 +188,8 @@ export default {
|
|||||||
},
|
},
|
||||||
async addItem (category) {
|
async addItem (category) {
|
||||||
this.$q.loading.show()
|
this.$q.loading.show()
|
||||||
|
// Get next short id
|
||||||
|
let shortId = await this.$store.dispatch('core/getNextShortId')
|
||||||
let newItem = {
|
let newItem = {
|
||||||
available: true,
|
available: true,
|
||||||
comment: '',
|
comment: '',
|
||||||
@ -196,7 +198,8 @@ export default {
|
|||||||
ref: null,
|
ref: null,
|
||||||
state: null,
|
state: null,
|
||||||
type: category.name,
|
type: category.name,
|
||||||
system: null
|
system: null,
|
||||||
|
short_id: shortId
|
||||||
}
|
}
|
||||||
newItem.ref = `${category.code}-${String(this.counters[category.name] + 1).padStart(4, '0')}`
|
newItem.ref = `${category.code}-${String(this.counters[category.name] + 1).padStart(4, '0')}`
|
||||||
await this.$store.dispatch('core/addToCollection', {
|
await this.$store.dispatch('core/addToCollection', {
|
||||||
@ -224,12 +227,9 @@ export default {
|
|||||||
ok: 'Oui, STP',
|
ok: 'Oui, STP',
|
||||||
cancel: 'Osef'
|
cancel: 'Osef'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.onOk(() => {
|
||||||
this.$router.push(`/item/${newItem.ref}`)
|
this.$router.push(`/item/${newItem.ref}`)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
|
||||||
// Picked "Cancel" or dismissed
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<div class="q-ma-none text-h3 text-weight-bolder row" :class="{'text-faded': !item.name}">
|
<div class="q-ma-none text-h3 text-weight-bolder row" :class="{'text-faded': !item.name}">
|
||||||
<span class="q-mr-md">{{ item.name || '---- -- ----' }}</span>
|
<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 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>
|
<q-chip square size="lg" v-if="item.deleted" color="red">Supprimé</q-chip>
|
||||||
</div>
|
</div>
|
||||||
<h5 class="q-ma-none q-pb-md text-grey">{{item.type}}</h5>
|
<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-section>
|
<q-item-section>
|
||||||
<q-item-label lines="3" v-html="event.text.split('\n').join('</br>')"></q-item-label>
|
<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>
|
||||||
<q-item-section side top>
|
<q-item-section side top>
|
||||||
<q-item-label caption>{{ getDate(event.created) }}</q-item-label>
|
<q-item-label caption>{{ getDate(event.created) }}</q-item-label>
|
||||||
@ -178,6 +189,11 @@
|
|||||||
color="secondary"
|
color="secondary"
|
||||||
/>
|
/>
|
||||||
<br/>
|
<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
|
<q-uploader
|
||||||
:accept="'.jpg,.png'"
|
:accept="'.jpg,.png'"
|
||||||
:factory="uploadFile"
|
:factory="uploadFile"
|
||||||
@ -214,6 +230,10 @@
|
|||||||
<span>{{ getDate(selectedHistory.created) }}</span>
|
<span>{{ getDate(selectedHistory.created) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</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-card-actions align="right">
|
||||||
<q-btn flat color="red" @click.stop="removeHistory(selectedHistory)">Supprimer</q-btn>
|
<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>
|
<q-btn flat color="grey" @click.stop="showHistory = false;selectedHistory = null">Fermer</q-btn>
|
||||||
@ -231,11 +251,12 @@ import QRCode from 'qrcode'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'StockItem',
|
name: 'StockItem',
|
||||||
props: ['itemRef'],
|
props: ['itemRef', 'shortId'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
showHistoryForm: false,
|
showHistoryForm: false,
|
||||||
pendingHistory: null,
|
pendingHistory: null,
|
||||||
|
pendingHistoryType: 'comment',
|
||||||
changed: false,
|
changed: false,
|
||||||
hasFile: false,
|
hasFile: false,
|
||||||
username: null,
|
username: null,
|
||||||
@ -272,7 +293,20 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
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.loadItem()
|
||||||
|
this.$watch(
|
||||||
|
() => this.itemRef,
|
||||||
|
(newId, oldId) => {
|
||||||
|
this.loadItem()
|
||||||
|
}
|
||||||
|
)
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.username = this.$q.localStorage.getItem('username')
|
this.username = this.$q.localStorage.getItem('username')
|
||||||
@ -296,6 +330,7 @@ export default {
|
|||||||
data: {
|
data: {
|
||||||
ref: this.itemRef,
|
ref: this.itemRef,
|
||||||
text: this.pendingHistory,
|
text: this.pendingHistory,
|
||||||
|
type: this.pendingHistoryType,
|
||||||
user: this.$store.state.core.username,
|
user: this.$store.state.core.username,
|
||||||
image_file: file,
|
image_file: file,
|
||||||
date: date.toISOString()
|
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) {
|
async uploadFile (file) {
|
||||||
// Resize and compress the image before uploading
|
// Resize and compress the image before uploading
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -13,7 +13,8 @@ const routes = [
|
|||||||
{ path: 'dashboard', component: () => import('pages/Dashboard.vue') },
|
{ path: 'dashboard', component: () => import('pages/Dashboard.vue') },
|
||||||
{ path: 'category/:categoryCode', props: true, component: () => import('pages/StockItems.vue') },
|
{ path: 'category/:categoryCode', props: true, component: () => import('pages/StockItems.vue') },
|
||||||
{ path: 'item/:itemRef', props: true, component: () => import('pages/StockItem.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)
|
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) {
|
// export function uploadFile (store, file) {
|
||||||
// return Firebase.storage().ref().child(Date.now() + file.name).put(file)
|
// return Firebase.storage().ref().child(Date.now() + file.name).put(file)
|
||||||
// }
|
// }
|
||||||
|
Reference in New Issue
Block a user