import { defineStore } from 'pinia'; export const useSetWareHouseStore = defineStore('warehouse', { state: () => ({ warehouseList: [], regionList: [], locationList: [] }), getters: { getData: (state) => { state.warehouseList, state.regionList, state.locationList }, }, actions: { // 仓库列表数据 getList(state) { return new Promise((resolve, reject) => { uni.$reqGet('warehouseDropDownList') .then(({ code, data, msg }) => { if (code === 0) { this.warehouseList = [] data?.forEach(item => { this.warehouseList.push({ id: item.id, text: item.name, value: item.id }) }) resolve(this.warehouseList) } else { reject(msg) } }) }) }, // 根据ID查询区域列表数据 handleGetRegionList(wmsStockId) { return new Promise((resolve, reject) => { uni.$reqGet('regionDropDownList', { wmsStockId }) .then(({ code, data, msg }) => { if (code === 0) { this.regionList = [] data?.forEach(item => { this.regionList.push({ id: item.id, text: item.name, value: item.id }) }) resolve(this.regionList) } else { reject(msg) } }) }) }, // 根据ID查询货位列表数据 handleGetLocationList(stockArea) { return new Promise((resolve, reject) => { uni.$reqGet('locationDropDownList', { stockArea }) .then(({ code, data, msg }) => { if (code === 0) { this.locationList = [] data?.forEach(item => { this.locationList.push({ id: item.id, text: item.name, value: item.id }) }) resolve(this.locationList) } else { reject(msg) } }) }) } }, persist: true, // 设置持久化 // 单独设置存储位置 // persist: { // storage: window.localStorage, // }, })