From 049d3cc0981354adc3c53928a104feb7318a745d Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 2 Aug 2024 01:18:56 +0800 Subject: [PATCH] fix adding remark error --- .../AdminWorkFlowSectionComponent.vue | 39 +++++++++---------- routes/admin_work_flow.php | 6 +-- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/resources/assets/vue/components/general/sections/AdminWorkFlowSectionComponent.vue b/resources/assets/vue/components/general/sections/AdminWorkFlowSectionComponent.vue index 2df61d7d..3ceea3f0 100644 --- a/resources/assets/vue/components/general/sections/AdminWorkFlowSectionComponent.vue +++ b/resources/assets/vue/components/general/sections/AdminWorkFlowSectionComponent.vue @@ -13,7 +13,7 @@

{{ currentQuestion.text }}

- +

Login Information

@@ -461,8 +461,8 @@ export default { "answers": [ { "text": "Sensitive Goods", "next": "Sensitive Goods" }, { "text": "Others", "next": "PO Others" }, - { "text": "Stop Working", "next": "stop_working" }, - { "text": "Next PO", "next": "approve_po" } + // { "text": "Stop Working", "next": "stop_working" }, + // { "text": "Next PO", "next": "approve_po" } ] }, "issue_submit": { @@ -537,30 +537,29 @@ export default { if (nextQuestionId === 'refresh_page') return window.location.reload(); if (this.currentQuestionId === 'issue_po') { if (nextQuestionId === 'po_others') { - this.callApi(this.route('api.admin_work_flow.create_po_issue_remark'), 'post', 'section', { - 'marking': this.currentOrder, - 'remark': 'PO Others', - 'user_id': this.$store.getters.getUserId, - }, false, false); + this.callApi(this.route('api.admin_work_flow.create_po_issue_remark'), 'post', 'section', { + 'booking_id': this.currentOrder.id, + 'remark': 'PO Others', + 'user_id': this.$store.getters.getUserId, + }, false, false); } else { - this.callApi(this.route('api.admin_work_flow.create_po_issue_remark'), 'post', 'section', { - 'marking': this.currentOrder, - 'remark': nextQuestionId, - 'user_id': this.$store.getters.getUserId, - }, false, false); - nextQuestionId = 'issue_submit'; + this.callApi(this.route('api.admin_work_flow.create_po_issue_remark'), 'post', 'section', { + 'booking_id': this.currentOrder.id, + 'remark': nextQuestionId, + 'user_id': this.$store.getters.getUserId, + }, false, false); + nextQuestionId = 'issue_submit'; } } - if (this.currentQuestionId === 'login_issue' || this.currentQuestionId === '1688_issue_order' || this.currentQuestionId === '1688_order_issue') { + if (['login_issue', '1688_issue_order', '1688_order_issue'].includes(this.currentQuestionId)) { if (nextQuestionId === 'refund_request') { this.callApi(this.route('api.admin_work_flow.create_issue_remark'), 'post', 'section', { 'booking_id': this.currentOrder.booking_id, 'remark': nextQuestionId, 'user_id': this.$store.getters.getUserId, }, false, false); - nextQuestionId = 'refund_request'; } else if(nextQuestionId === '1688_issue_others') { // this.callApi(this.route('api.admin_work_flow.create_issue_remark'), 'post', 'section', { @@ -604,7 +603,7 @@ export default { 'user_id': this.$store.getters.getUserId, 'session_id': this.sessionId, }; - this.callApi(this.route('api.admin_work_flow.add_workflow_timestamp'), 'post', 'section', logBody, false, false); + // this.callApi(this.route('api.admin_work_flow.add_workflow_timestamp'), 'post', 'section', logBody, false, false); this.stepTime = 0; }, goBack() { @@ -643,10 +642,8 @@ export default { this.isLoading = false; } - if (url === this.route("api.admin_work_flow.fetch_oldest_order")) { - this.currentOrder = apiResponse.data.data; - } else if (url === this.route("api.admin_work_flow.fetch_oldest_order")) { - this.currentOrder = apiResponse.data + if ([this.route("api.admin_work_flow.fetch_oldest_order"), this.route("api.admin_work_flow.fetch_pending_approve_po"), this.route("api.admin_work_flow.fetch_pending_fill_po")].includes(url)) { + this.currentOrder = apiResponse.data.data } }) diff --git a/routes/admin_work_flow.php b/routes/admin_work_flow.php index ce35d458..f7767523 100644 --- a/routes/admin_work_flow.php +++ b/routes/admin_work_flow.php @@ -169,16 +169,16 @@ Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namesp Route::post('/create_po_issue_remark', function (Request $request) { $validator = Validator::make($request->all(), [ - 'marking' => 'required|exists:bookings,marking', // Validate if marking exists in the bookings table + 'booking_id' => 'required', 'remark' => 'required', - 'user_id' => 'required|exists:users,id', // Validate if user_id exists in the users table + 'user_id' => 'required', ]); if ($validator->fails()) { return response()->json(['message' => $validator->messages()->first()], 400); // Return validation error } - $booking = Booking::where('marking', $request->marking)->first(); + $booking = Booking::find($request->booking_id); if (!$booking) { return response()->json(['message' => 'Booking not found'], 404);