Merge branch 'Workorder/improve' into 'master'

updated rml workorder

See merge request fronk/thetool!1851
This commit is contained in:
Luca Haid
2025-10-20 13:55:49 +00:00
2 changed files with 58 additions and 3 deletions

View File

@@ -311,5 +311,35 @@ class WorkorderAdminController extends WorkorderBaseController
}
return true;
}
protected function revertDocumentedStatusAction()
{
if (empty($this->postData['workorderId'])) {
self::sendError("Arbeitsauftrags-ID fehlt.");
}
$workorder = WorkorderModel::get($this->postData['workorderId']);
if (!$workorder) {
self::sendError("Arbeitsauftrag nicht gefunden.");
}
if ($workorder->status !== 'documented') {
self::sendError("Nur Aufträge mit Status 'Dokumentiert' können zurückgesetzt werden.");
}
$oldStatus = $workorder->status;
$workorder->status = 'assigned'; // Revert to 'assigned' status
WorkorderModel::update((array)$workorder);
WorkorderJournalModel::create([
'workorderId' => $workorder->id,
'text' => 'Status von Admin von "' . $this->getStatusText($oldStatus) . '" auf "' . $this->getStatusText('assigned') . '" zurückgesetzt.',
'statusChange' => $this->getStatusText($oldStatus) . " -> " . $this->getStatusText('assigned'),
'create' => time(),
'createBy' => $this->user->id,
]);
self::returnJson(['success' => true, 'message' => 'Status erfolgreich auf "Zugewiesen" zurückgesetzt.']);
}
//endregion
}

View File

@@ -205,6 +205,10 @@ Vue.component('workorder-details-manager', {
<hr>
<tt-button text="Dokumentation akzeptieren" @click="showAcceptModal = true"
additional-class="btn-success w-100" icon="fas fa-check"/>
<tt-button v-if="workorder.status === 'documented'"
text="Status zurücksetzen (auf Zugewiesen)"
@click="showRevertModal = true"
additional-class="btn-warning w-100 mt-1" icon="fas fa-undo"/>
</div>
</div>
@@ -229,7 +233,7 @@ Vue.component('workorder-details-manager', {
</div>
<div class="col-lg-7">
<div class="card mb-3" v-if="!isAdmin && !isReadOnly">
<div class="card mb-3" v-if="isAdmin || !isReadOnly">
<div class="card-body">
<h5 class="card-title">Neues Dokument hochladen</h5>
<tt-select label="Dokumententyp" :options="allDocTypes" v-model="uploadData.documentType" sm row/>
@@ -280,6 +284,9 @@ Vue.component('workorder-details-manager', {
<tt-modal :show.sync="showAcceptModal" title="Dokumentation akzeptieren" @submit="acceptDocumentation" :delete="false">
Soll die Dokumentation für diesen Arbeitsauftrag wirklich akzeptiert und der Auftrag abgeschlossen werden?
</tt-modal>
<tt-modal :show.sync="showRevertModal" title="Status zurücksetzen" @submit="revertDocumentedStatus" :delete="false">
Möchten Sie den Status dieses Auftrags wirklich von 'Dokumentiert' auf 'Zugewiesen' zurücksetzen? Die Firma muss den Auftrag dann erneut einreichen.
</tt-modal>
</div>`,
data: () => ({
loading: true, loadingConfig: true, workorder: null, docs: [], journals: [], tenantDocTypes: null,
@@ -290,10 +297,10 @@ Vue.component('workorder-details-manager', {
interventionData: null,
interventionTypes: [],
// Admin state
selectedDocs: [], correctionText: '', correctionLoading: false, showAcceptModal: false,
selectedDocs: [], correctionText: '', correctionLoading: false, showAcceptModal: false, showRevertModal: false,
}),
computed: {
isReadOnly() { return ['documented', 'completed', 'cancelled'].includes(this.workorder?.status); },
isReadOnly() { return ['completed', 'cancelled'].includes(this.workorder?.status); },
requiredDocTypes() {
return this.tenantDocTypes ?? [];
},
@@ -459,6 +466,24 @@ Vue.component('workorder-details-manager', {
this.showAcceptModal = false;
},
getInterventionLabel(type) { return this.interventionTypes.find(t => t.value === type)?.text || type; },
async revertDocumentedStatus() {
// Optional: Add loading state if needed
try {
const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/WorkorderAdmin/revertDocumentedStatus`, {
workorderId: this.workorderId
});
if (data.success) {
window.notify('success', data.message);
this.showRevertModal = false;
await this.fetchData(); // Refresh data to show new status
this.$emit('workorder-updated'); // Or a more specific event if needed
} else {
window.notify('error', data.message || 'Status konnte nicht zurückgesetzt werden.');
}
} catch (e) {
window.notify('error', 'Netzwerkfehler beim Zurücksetzen des Status.');
}
},
},
async mounted() {
await this.loadTenantConfig();