Ben Lin
2024-10-13 234b6cf8944ef95c415c4898f19b8fb4d12e898f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * @Description: 产品工艺路线Store
 * @Author: Ben Lin
 * @version:
 * @Date: 2024-06-18 15:09:47
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-10-08 16:10:48
 */
import { defineStore } from 'pinia';
import { store } from '@/store';
import { useI18n } from '@/hooks/web/useI18n';
import { useMessage } from '@/hooks/web/useMessage';
import { h } from 'vue';
import { MesRotTree } from '/@/api/tigerapi/model/mesModel';
 
interface ProdRouteState {
  curProdRotTree: Nullable<MesRotTree>;
  rotList: MesRotTree[];
}
 
export const useProdRouteStore = defineStore({
  id: 'app-prodrot',
  state: (): ProdRouteState => ({
    curProdRotTree: null,
    rotList: [],
  }),
  getters: {
    getCurProdRotTree(state): MesRotTree | null {
      return state.curProdRotTree;
    },
    getRotList(state): MesRotTree[] {
      return state.rotList;
    },
  },
  actions: {
    getRotList(roleList: MesRotTree[]) {
      this.rotList = roleList;
    },
    setUserInfo(info: MesRotTree | null) {
      this.curProdRotTree = info;
    },
    resetState() {
      this.curProdRotTree = null;
      this.rotList = [];
    },
    /**
     * @description: 设置默认工艺路线
     * @return {*}
     */    
    setDefaulRoute() {
      const { createConfirm } = useMessage();
      const { t } = useI18n();
      createConfirm({
        iconType: 'warning',
        title: () => h('span', t('sys.app.logoutTip')),
        content: () => h('span', t('sys.app.logoutMessage')),
        onOk: async () => {
          // 主动登出,不带redirect地址
          // await this.logout(true);
        },
      });
    },
  },
});
 
// Need to be used outside the setup
export function useProdRouteWithOut() {
  return useProdRouteStore(store);
}