From 3d071d4d5f603ad4a40262c11dc8a87d235ca5d1 Mon Sep 17 00:00:00 2001 From: qz_cx Date: Fri, 17 Oct 2025 13:34:51 +0800 Subject: [PATCH] Add cancellation application function --- appStore/api/router.py | 2 + appStore/testMachine/views.py | 12 ++++++ templates/front-project/src/api/api.js | 8 ++++ .../src/views/machineViews/ServerList.vue | 37 ++++++++++++++----- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/appStore/api/router.py b/appStore/api/router.py index 115a9c1..7eaf21b 100644 --- a/appStore/api/router.py +++ b/appStore/api/router.py @@ -47,6 +47,7 @@ router.register(r'machine_list', TestMachineViewSet, basename='machine_list') urlpatterns = [ url(r'', include(router.urls)), url('^apply_use_machine/', TestMachineViewSet.as_view({'post': 'apply_use_machine'}), name='apply_use_machine'), + url('^cancel_apply_use_machine/', TestMachineViewSet.as_view({'post': 'cancel_apply_use_machine'}), name='cancel_apply_use_machine'), url('^modify_server/', TestMachineViewSet.as_view({'post': 'modify_server'}), name='modify_server'), url('^get_filter_name/', ProjectViewSet.as_view({'get': 'get_filter_name'}), name='get_filter_name'), url('^merge_data/', ProjectViewSet.as_view({'post': 'merge_data'}), name='merge_data'), @@ -55,4 +56,5 @@ urlpatterns = [ url('^change_password/', UserProfileViewSet.as_view({'put': 'change_password'}), name='change_password'), url('^do_test_case/', TestCaseViewSet.as_view({'post': 'do_test_case'}), name='do_test_case'), url('^down_message/', TestCaseViewSet.as_view({'get': 'down_message'}), name='down_message'), + ] diff --git a/appStore/testMachine/views.py b/appStore/testMachine/views.py index 66dbb8a..7334c10 100644 --- a/appStore/testMachine/views.py +++ b/appStore/testMachine/views.py @@ -66,6 +66,18 @@ class TestMachineViewSet(viewsets.ModelViewSet): machine_data.save() return json_response({}, status.HTTP_200_OK, '申请成功') + def cancel_apply_use_machine(self, request, *args, **kwargs): + machine_id = request.data.get('id') + machine_data = TestMachine.objects.get(id=machine_id) + if not machine_id or not machine_data: + return json_response({}, status.HTTP_205_RESET_CONTENT, '没有该数据') + if machine_data.queue_user == request.user.chinese_name: + machine_data.queue_user = None + machine_data.save() + return json_response({}, status.HTTP_200_OK, '取消申请成功') + else: + return json_response({}, status.HTTP_200_OK, '不可取消别人的申请') + def modify_server(self, request, *args, **kwargs): machine_id = request.data.get('id') machine_data = TestMachine.objects.get(id=machine_id) diff --git a/templates/front-project/src/api/api.js b/templates/front-project/src/api/api.js index 833d27c..8cb593f 100644 --- a/templates/front-project/src/api/api.js +++ b/templates/front-project/src/api/api.js @@ -234,6 +234,14 @@ export function apply_use_machine(data) { data }) } +//取消申请使用设备 +export function cancel_apply_use_machine(data) { + return service({ + method: 'post', + url: '/cancel_apply_use_machine/', + data + }) +} //修改服务器系统信息 export function modify_server(data) { diff --git a/templates/front-project/src/views/machineViews/ServerList.vue b/templates/front-project/src/views/machineViews/ServerList.vue index 8537317..63f0620 100644 --- a/templates/front-project/src/views/machineViews/ServerList.vue +++ b/templates/front-project/src/views/machineViews/ServerList.vue @@ -32,8 +32,9 @@ @@ -66,7 +67,7 @@