Много всего

This commit is contained in:
brusnitsyn
2025-12-12 17:10:05 +09:00
parent 54f36e91fa
commit 98e9f8b52e
25 changed files with 1118 additions and 145 deletions

View File

@@ -1,17 +1,25 @@
<script setup>
import {NButton, NDatePicker, NDivider, NFlex, NForm, NFormItem, NInput, NModal, NSpace, NSwitch, NSelect} from "naive-ui";
import {ref, watch} from "vue";
import {router} from "@inertiajs/vue3";
const open = defineModel('open')
const props = defineProps({
archiveHistoryId: {
type: Number
},
activeHistoryType: {
type: String
},
isCreateNew: {
type: Boolean
}
})
const emits = defineEmits(['closeWithoutSave'])
const emits = defineEmits(['closeWithoutSave', 'historyUpdated'])
const loading = ref(false)
const archiveHistory = ref({
historyable_id: props.archiveHistoryId,
historyable_type: props.activeHistoryType,
issue_at: null,
org_id: null,
return_at: null,
@@ -25,6 +33,7 @@ const orgs = ref([])
const onResetData = () => {
archiveHistory.value = {
historyable_id: props.archiveHistoryId,
historyable_type: props.activeHistoryType,
issue_at: null,
org_id: null,
return_at: null,
@@ -59,9 +68,19 @@ const loadArchiveHistoryData = async () => {
const submit = () => {
try {
axios.post('/api/archive/histories/move', archiveHistory.value).then(res => {
const url = props.isCreateNew
? '/api/archive/histories/move'
: `/api/archive/histories/move/${archiveHistory.value.id}`
axios.post(url, archiveHistory.value).then(res => {
onCloseWithoutSave()
emits('historyUpdated', {
type: props.isCreateNew ? 'created' : 'updated',
data: res.data,
historyId: archiveHistory.value.id
})
})
} catch (error) {
console.error(error)
} finally {
@@ -71,7 +90,7 @@ const submit = () => {
// Наблюдаем за изменением archiveHistoryId
watch(() => props.archiveHistoryId, async (newId) => {
if (newId) {
if (!props.isCreateNew) {
await loadArchiveHistoryData()
} else {
onResetData()