-

+
+
+
-
+
+
+
+
+
-
+
+
+
+
+
-
+
-
diff --git a/src/pages/StockItems.vue b/src/pages/StockItems.vue
index 0c5d0b7..eabc6af 100644
--- a/src/pages/StockItems.vue
+++ b/src/pages/StockItems.vue
@@ -1,69 +1,125 @@
-
- {{category.name}}
-
+
+
+
{{ category.name }}
+
+ {{ items.length }} article{{ items.length !== 1 ? 's' : '' }}
+
+ · {{ deletedCount }} supprimé{{ deletedCount !== 1 ? 's' : '' }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Supprimés
+
+
+
+
+
+ hide-pagination
+ class="stock-table"
+ :rows-per-page-options="[10, 15, 25, 50]"
+ >
+
+
+
+ {{ props.row.ref }}
+
+
+
+ {{ props.row.name || '—' }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ props.row.owner }}
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
- ✔
- ✘
-
-
- ✔
- ✘
-
-
- ✘
-
-
-
-
-
- {{ col.value }}
-
-
-
-
-
-
+
+
+
+ Ajouter un{{ category.name.endsWith('e') ? 'e' : '' }} {{ category.name }}
+ Référence : {{ newRef }}
+
+
+
+
+
+
+
+
+
+
+
@@ -77,56 +133,83 @@ export default {
return {
search: null,
showDeleted: false,
+ showAddDialog: false,
+ newName: '',
pagination: {
sortBy: null,
descending: false,
page: 1,
rowsPerPage: 15
- },
- columns: [
- { label: 'Référence', align: 'left', field: 'ref', sortable: true, name: 'ref' },
- { label: 'Nom', align: 'left', field: 'name', sortable: true, name: 'name' },
- { label: 'Etat', align: 'center', field: 'state', sortable: true, name: 'state' },
- { label: 'Fonctionnel', align: 'center', field: 'working', sortable: true, name: 'working' },
- { label: 'En stock', align: 'center', field: 'available', sortable: true, name: 'available' },
- { label: 'Propriétaire', align: 'left', field: 'owner', sortable: true, name: 'owner' },
- { label: 'Supprimé', align: 'left', field: 'deleted', sortable: false, name: 'deleted', format: val => val ? '✔' : '' }
- ]
+ }
}
},
created () {
if (!this.search) this.search = this.$route.query.search || null
- let paginationQuery = { ...this.$route.query }
- delete paginationQuery.search
- this.pagination = { ...this.pagination, ...paginationQuery }
- console.log('__Pagination:', this.pagination)
+ const q = { ...this.$route.query }
+ delete q.search
+ this.pagination = { ...this.pagination, ...q }
},
computed: {
+ columns () {
+ const base = [
+ { label: 'Référence', field: 'ref', sortable: true, name: 'ref', align: 'left' },
+ { label: 'Nom', field: 'name', sortable: true, name: 'name', align: 'left' },
+ { label: 'État', field: 'state', sortable: true, name: 'state', align: 'center' },
+ { label: 'Fonctionnel', field: 'working', sortable: true, name: 'working', align: 'center' },
+ { label: 'En stock', field: 'available', sortable: true, name: 'available', align: 'center' },
+ { label: 'Propriétaire', field: 'owner', sortable: true, name: 'owner', align: 'left' }
+ ]
+ if (this.showDeleted) {
+ base.push({ label: 'Supprimé', field: 'deleted', name: 'deleted', align: 'center' })
+ }
+ return base
+ },
dynamicColumns () {
- let columns = JSON.parse(JSON.stringify(this.columns))
- if (!this.showDeleted) columns.pop()
- return columns
+ return this.columns
},
category () {
return this.$store.state.core.firebase.categories.find(item => {
return parseInt(item.code) === parseInt(this.categoryCode)
}) || {}
},
+ allItems () {
+ return (this.$store.state.core.firebase.stock || [])
+ .filter(item => item.type === this.category.name)
+ },
+ filteredItems () {
+ return this.allItems.filter(item => {
+ if (this.showDeleted ? false : item.deleted) return false
+ if (this.search && this.search.length > 0) {
+ const s = this.search.toLowerCase()
+ return (item.ref.toLowerCase() + (item.name || '').toLowerCase()).includes(s)
+ }
+ return true
+ })
+ },
items () {
- let items = this.$store.state.core.firebase.stock.filter(item => {
- return item.type === this.category.name &&
- (this.search ? (item.ref + (item.name + '').toLowerCase()).search(this.search.toLowerCase()) !== -1 : true) &&
- (this.showDeleted ? true : !item.deleted)
- }).slice().reverse() || []
+ let list = [...this.filteredItems]
if (this.pagination.sortBy) {
- console.log('__Sorting:', this.pagination)
- return [...items].sort((a, b) => {
- const x = this.pagination.descending ? b : a
- const y = this.pagination.descending ? a : b
- return x[this.pagination.sortBy] > y[this.pagination.sortBy]
+ const desc = this.pagination.descending
+ list.sort((a, b) => {
+ const av = a[this.pagination.sortBy]
+ const bv = b[this.pagination.sortBy]
+ if (av == null) return desc ? -1 : 1
+ if (bv == null) return desc ? 1 : -1
+ return desc ? (bv > av ? 1 : -1) : (av > bv ? 1 : -1)
})
}
- return items
+ return list
+ },
+ pagesNumber () {
+ return Math.ceil(this.filteredItems.length / this.pagination.rowsPerPage)
+ },
+ deletedCount () {
+ return this.allItems.filter(i => i.deleted).length
+ },
+ newRef () {
+ const stock = this.allItems
+ const lastRef = stock.length > 0 ? parseInt((stock[0].ref || '').split('-')[1] || 0) : 0
+ return `${this.category.code}-${String(lastRef + 1).padStart(4, '0')}`
}
},
methods: {
@@ -134,31 +217,108 @@ export default {
this.$router.push(`/item/${data.key}`)
},
stateColor (state) {
- let colors = {
- Neuf: 'green-14',
- Excellent: 'green-12',
- Bon: 'lime-13',
+ const colors = {
+ Neuf: 'green-8',
+ Excellent: 'green',
+ Bon: 'lime-9',
Moyen: 'orange',
Abimé: 'red',
- Inutilisable: 'black'
+ Inutilisable: 'grey-7'
}
- return colors[state]
+ return colors[state] || 'grey'
+ },
+ addItem () {
+ this.showAddDialog = true
+ this.newName = ''
+ },
+ async confirmAddItem () {
+ const shortId = await this.$store.dispatch('core/getNextShortId')
+ const ref = this.newRef
+ const item = {
+ available: true,
+ comment: '',
+ name: this.newName,
+ owner: 'HFS',
+ ref,
+ state: null,
+ type: this.category.name,
+ short_id: shortId
+ }
+ await this.$store.dispatch('core/addToCollection', { collection: 'stock', data: item })
+ await this.$store.dispatch('core/addToCollection', {
+ collection: 'history',
+ data: {
+ ref,
+ text: 'Entrée en stock',
+ user: this.$store.state.core.username,
+ date: new Date().toISOString()
+ }
+ })
+ await this.$store.dispatch('core/loadAppData')
+ this.showAddDialog = false
+ this.$router.push(`/item/${ref}`)
},
updateSearchUrl: debounce(function () {
- this.$router.replace({ path: this.$router.path, query: { ...this.$route.query, search: this.search } })
+ this.$router.replace({ path: this.$router.path, query: { search: this.search } })
}, 300),
updatePaginationUrl: debounce(function () {
this.$router.replace({
path: this.$router.path,
- query: {
- ...this.$route.query,
- ...this.pagination
- }
+ query: { ...this.$route.query, ...this.pagination }
})
}, 300)
}
}
-
diff --git a/src/pages/TasksPage.vue b/src/pages/TasksPage.vue
index fb9fba5..c0bba2f 100644
--- a/src/pages/TasksPage.vue
+++ b/src/pages/TasksPage.vue
@@ -1,125 +1,159 @@
-
- Tâches
+
+
+
+
Tâches
+
+ {{ openCount }} ouverte{{ openCount !== 1 ? 's' : '' }}
+ · {{ closedCount }} résolue{{ closedCount !== 1 ? 's' : '' }}
+
+
+
-
-
-
-
-
-
-
-
-
-
-
- {{ issue.item.type }} /
- {{ issue.item.name }}
- #{{ issue.item.ref }}
-
-
- {{ issue.user }}
-
-
- fait par {{ issue.solved_by }} le {{ getDate(issue.solved_at) }}
-
-
-
-
- {{ getDate(issue.created) }}
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
Aucune tâche {{ filterTab === 'closed' ? 'résolue' : '' }} pour le moment
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ issue.item.type }}
+ / {{ issue.item.name || 'Sans nom' }}
+ #{{ issue.item.ref }}
+
+
+ {{ issue.user }}
+
+
+ résolue par {{ issue.solved_by }}
+ · {{ getDate(issue.solved_at) }}
+
+
+ · {{ getDate(issue.date || issue.created) }}
+
+
+
+
+
+
+
-
-
+
+
-
-
-
- {{ selectedHistory.item.type }} /
- {{ selectedHistory.item.name }}
- #{{ selectedHistory.item.ref }}
-
-
-
{{ selectedHistory.user }}
-
-
- fait par {{ selectedHistory.solved_by }} le {{ getDate(selectedHistory.solved_at) }}
-
-
+
+
+
+
+ {{ selectedHistory.user }}
+ · {{ getDate(selectedHistory.date || selectedHistory.created) }}
+
-
-
+
+
+ Résolue par {{ selectedHistory.solved_by }}
+ le {{ getDate(selectedHistory.solved_at) }}
+
-
+
+
+
+
+
- Supprimer
- Fermer
+
+
-
-
-