| | |
| | | import { ref, computed } from 'vue' |
| | | import { ref, watch } from 'vue' |
| | | import { defineStore } from 'pinia' |
| | | import type { CraftModel } from '@/api/craftModel' |
| | | import { apiGetCraftModelList } from '@/api' |
| | | import { useTasksStore } from '@/stores/tasks' |
| | | |
| | | const watcher = ref() |
| | | |
| | | export const useCraftModelStore = defineStore('craftModel', () => { |
| | | const craftModelList = ref<CraftModel[]>() |
| | |
| | | apiGetCraftModelList({ |
| | | procedureId: taskStore.activeTask?.Procedure.ID, |
| | | page: 1, |
| | | pageSize: 999, |
| | | number: taskStore.activeTask?.Procedure?.processModelNumber |
| | | pageSize: 999 |
| | | }).then((res) => { |
| | | craftModelList.value = res.data ?? [] |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (!watcher.value) { |
| | | watch( |
| | | () => taskStore.activeTask, |
| | | () => { |
| | | getCraftModelList() |
| | | } |
| | | ) |
| | | } |
| | | |
| | | return { craftModelList, getCraftModelList } |
| | | }) |