Реализация смены статуса

Добавлен move метод
Правка в поиске
This commit is contained in:
brusnitsyn
2025-12-07 22:33:19 +09:00
parent 2e1b5a3d0e
commit 945b53c578
10 changed files with 142 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ const emits = defineEmits(['closeWithoutSave'])
const loading = ref(false)
const archiveHistory = ref({
historyable_id: props.archiveHistoryId,
issue_at: null,
org_id: null,
return_at: null,
@@ -23,6 +24,7 @@ const orgs = ref([])
const onResetData = () => {
archiveHistory.value = {
historyable_id: props.archiveHistoryId,
issue_at: null,
org_id: null,
return_at: null,
@@ -39,13 +41,13 @@ const onCloseWithoutSave = () => {
const loadArchiveHistoryData = async () => {
try {
axios.get('/api/orgs').then(res => {
await axios.get('/api/orgs').then(res => {
orgs.value = res.data
})
if (!props.archiveHistoryId) return
axios.get(`/api/archive/histories/${props.archiveHistoryId}`).then(res => {
await axios.get(`/api/archive/histories/${props.archiveHistoryId}`).then(res => {
archiveHistory.value = res.data
})
} catch (error) {
@@ -55,10 +57,22 @@ const loadArchiveHistoryData = async () => {
}
}
const submit = () => {
try {
axios.post('/api/archive/histories/move', archiveHistory.value).then(res => {
onCloseWithoutSave()
})
} catch (error) {
console.error(error)
} finally {
loading.value = false
}
}
// Наблюдаем за изменением archiveHistoryId
watch(() => props.archiveHistoryId, (newId) => {
watch(() => props.archiveHistoryId, async (newId) => {
if (newId) {
loadArchiveHistoryData()
await loadArchiveHistoryData()
} else {
onResetData()
}
@@ -101,7 +115,7 @@ watch(() => props.archiveHistoryId, (newId) => {
Закрыть без сохранения
</NButton>
<NDivider vertical />
<NButton secondary type="primary">
<NButton secondary type="primary" @click="submit">
Сохранить
</NButton>
</NSpace>