chore: initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { createBoxes } from '@/data/demo-data.js'
|
||||
import { createItemStates } from '@/utils/picking-state.js'
|
||||
|
||||
function clone(value) {
|
||||
return JSON.parse(JSON.stringify(value))
|
||||
}
|
||||
|
||||
function createInitialState() {
|
||||
const boxes = createBoxes()
|
||||
return {
|
||||
boxes,
|
||||
currentBoxIndex: 0,
|
||||
itemStates: createItemStates(boxes[0].items),
|
||||
partialQuantities: {}, boxDrafts: {}, completedBoxes: {}, scanValue: '', scanHistory: []
|
||||
}
|
||||
}
|
||||
|
||||
let state = createInitialState()
|
||||
|
||||
export function getPickingSession() {
|
||||
return clone(state)
|
||||
}
|
||||
|
||||
export function savePickingSession(nextState) {
|
||||
state = clone(nextState)
|
||||
}
|
||||
|
||||
export function resetPickingSession() {
|
||||
state = createInitialState()
|
||||
}
|
||||
|
||||
export function getPickingOverview() {
|
||||
const completedCount = Object.values(state.completedBoxes).filter(Boolean).length
|
||||
return { boxes: clone(state.boxes), completedBoxes: { ...state.completedBoxes }, completedCount, pendingBoxCount: state.boxes.length - completedCount }
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { reactive } from 'vue'
|
||||
import { resetPickingSession } from '@/stores/picking.js'
|
||||
|
||||
export const session = reactive({ currentUser: null })
|
||||
|
||||
export function signIn(account, warehouse) {
|
||||
session.currentUser = { id: account.id, name: account.name, role: account.role, warehouse }
|
||||
return session.currentUser
|
||||
}
|
||||
|
||||
export function signOut() {
|
||||
session.currentUser = null
|
||||
resetPickingSession()
|
||||
}
|
||||
|
||||
export function requireSession() {
|
||||
if (session.currentUser) return true
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user