| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import {
- defineStore
- } from 'pinia';
- export const useSetDictStore = defineStore('dict', {
- state: () => ({
- dicts: []
- }),
- getters: {
- getData: (state) => {
- state.dicts
- },
- },
- actions: {
- // 仓库列表数据
- getList(state) {
- return new Promise((resolve, reject) => {
- uni.$reqGet('getDictDataAllPage')
- .then(({
- code,
- data,
- msg
- }) => {
- if (code === 0) {
- this.dicts = data
- // data?.forEach(item => {
- // this.dicts.push({
- // id: item.id,
- // text: item.name,
- // value: item.id
- // })
- // })
- resolve(this.dicts)
- } else {
- reject(msg)
- }
- })
- })
- }
- },
- persist: true, // 设置持久化
- // 单独设置存储位置
- // persist: {
- // storage: window.localStorage,
- // },
- })
|