Много всего
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user