From fb44f66cf4d0105518c0f2e550860cd2d88a5ce0 Mon Sep 17 00:00:00 2001 From: zty Date: Thu, 1 Aug 2024 10:28:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:edu=20=20=E8=AF=81=E4=B9=A6=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E6=89=B9=E9=87=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/api/edu.js | 8 +++ client/src/views/exam/classify.vue | 6 +- client/src/views/exam/examRecord.vue | 8 +-- client/src/views/exam/index.vue | 6 +- client/src/views/exam/questionChoose.vue | 31 +++++---- client/src/views/exam/questions.vue | 18 +++-- client/src/views/testvideo/certificate.vue | 76 +++++++++++++++++++++- client/src/views/testvideo/videolist.vue | 42 ++++++++++-- server/apps/edu/views.py | 25 +++++++ 9 files changed, 185 insertions(+), 35 deletions(-) diff --git a/client/src/api/edu.js b/client/src/api/edu.js index b6000d9..391c7d5 100644 --- a/client/src/api/edu.js +++ b/client/src/api/edu.js @@ -85,4 +85,12 @@ export function createCourse(data) { url: `/edu/course/${id}/`, method: 'get' }) + } + + export function batchUpdate(data) { + return request({ + url: '/edu/certificate/batch-update/', + method: 'post', + data + }) } \ No newline at end of file diff --git a/client/src/views/exam/classify.vue b/client/src/views/exam/classify.vue index f79a45d..03342a9 100644 --- a/client/src/views/exam/classify.vue +++ b/client/src/views/exam/classify.vue @@ -4,7 +4,7 @@ 新增 + highlight-current-row max-height="700"> @@ -23,7 +23,7 @@ - @@ -50,7 +50,7 @@ const defaultObj = { }; const listQuery = { page: 1, - limit: 20 + page_size: 20 }; export default { components: { Pagination }, diff --git a/client/src/views/exam/examRecord.vue b/client/src/views/exam/examRecord.vue index cabb414..a199991 100644 --- a/client/src/views/exam/examRecord.vue +++ b/client/src/views/exam/examRecord.vue @@ -51,7 +51,7 @@ fit v-loading="listLoading" highlight-current-row - max-height="600" + max-height="700" @sort-change="changeSort" > @@ -124,7 +124,7 @@ v-show="tableData.count>0" :total="tableData.count" :page.sync="listQuery.page" - :limit.sync="listQuery.limit" + :limit.sync="listQuery.page_size" @pagination="getList" /> @@ -137,7 +137,7 @@ const listQuery = { page: 1, - limit: 20, + page_size: 20, search:'' }; export default { @@ -229,7 +229,7 @@ resetFilter() { this.listQuery = { page: 1, - limit: 20, + page_size: 20, search:'', }; this.value = [] diff --git a/client/src/views/exam/index.vue b/client/src/views/exam/index.vue index db4e268..9bd64a7 100644 --- a/client/src/views/exam/index.vue +++ b/client/src/views/exam/index.vue @@ -84,7 +84,7 @@ v-show="tableData.count>0" :total="tableData.count" :page.sync="listQuery.page" - :limit.sync="listQuery.limit" + :limit.sync="listQuery.page_size" @pagination="getList" /> @@ -230,7 +230,7 @@ }; const listQuery = { page: 1, - limit: 20, + page_size: 20, search: "" }; export default { @@ -330,7 +330,7 @@ resetFilter() { this.listQuery = { page: 1, - limit: 20, + page_size: 20, search: "" }; this.getList(); diff --git a/client/src/views/exam/questionChoose.vue b/client/src/views/exam/questionChoose.vue index b0d03e2..2c2e06b 100644 --- a/client/src/views/exam/questionChoose.vue +++ b/client/src/views/exam/questionChoose.vue @@ -20,7 +20,7 @@ /> - + - + @@ -88,7 +89,7 @@ v-show="tableData.count>0" :total="tableData.count" :page.sync="listQuery.page" - :limit.sync="listQuery.limit" + :limit.sync="listQuery.page_size" @pagination="getList" /> { + getQuestionList(this.listQuery).then(response => { if(response.data.results){ this.tableData = response.data } @@ -185,7 +185,14 @@ getQuestioncatList().then(response => { this.questioncatData = response.data.results; }); - + }, + changeSort(val) { + if (val.order == "ascending") { + this.listQuery.ordering = val.prop; + } else { + this.listQuery.ordering = "-" + val.prop; + } + this.getList(); }, handleFilter() { if(this.questioncatC.length) { @@ -197,12 +204,12 @@ this.getList(); }, resetFilter() { - this.search = "" - this.listQuery = listQuery + this.listQuery.search = '' this.getList(); }, handleSearch() { - this.getList({ search: this.search }); + this.listQuery.page = 1 + this.getList(); }, handleDetail(scope) { this.dialogVisible = true diff --git a/client/src/views/exam/questions.vue b/client/src/views/exam/questions.vue index 957eed8..22093fc 100644 --- a/client/src/views/exam/questions.vue +++ b/client/src/views/exam/questions.vue @@ -75,8 +75,18 @@ 批量删除 - + @@ -112,7 +122,7 @@ -
{{ question.type }}
@@ -152,7 +162,7 @@ const defaultObj = { }; const listQuery = { page: 1, - limit: 20, + page_size: 20, search: '', questioncat:'' }; diff --git a/client/src/views/testvideo/certificate.vue b/client/src/views/testvideo/certificate.vue index 78e1d50..5893f06 100644 --- a/client/src/views/testvideo/certificate.vue +++ b/client/src/views/testvideo/certificate.vue @@ -23,6 +23,7 @@
新增证书 + 批量修改 + + + + + + + + + + + + +
diff --git a/client/src/views/testvideo/videolist.vue b/client/src/views/testvideo/videolist.vue index 0e55a62..6076da5 100644 --- a/client/src/views/testvideo/videolist.vue +++ b/client/src/views/testvideo/videolist.vue @@ -9,6 +9,20 @@ + + 搜索 + 刷新重置
@@ -87,7 +101,11 @@ data() { return { type:null, - videoList: "", + videoList: [], + queryParams:{ + pageoff:true, + search:"" + }, typeOptions: [], hasLowerLevel:false, subTypeOptions:[], @@ -110,9 +128,10 @@ } let bigHeight = document.getElementsByClassName('app-main')[0].clientHeight; let topHeight = document.getElementsByClassName('typesButtons')[0].clientHeight; - console.log(topHeight); + let headerHeight = document.getElementsByClassName('el-header')[0].clientHeight; + // console.log(topHeight); debugger; - let domHeight = bigHeight-200-topHeight; + let domHeight = bigHeight-topHeight-headerHeight-80; document.getElementById('videoListWrap').style.height = domHeight + 'px'; // document.getElementById('videoListWrap').style.paddingTop = topHeight + 'px'; }, @@ -121,14 +140,23 @@ getList() { this.type = null; this.listLoading = true; - getVideoList({pageoff: true}).then((response) => { + getVideoList(this.queryParams).then((response) => { if (response.data) { this.videoList = response.data; } this.listLoading = false; }); }, - + handleSearch() { + this.getList(); + }, + resetFilter() { + this.queryParams = { + pageoff:true, + search: '', + }; + this.getList(); + }, getListtype(a) { this.type = a.id; if(a.children){ @@ -165,7 +193,7 @@ getTypeAll() { getDictList({type__code: "data_video",is_used:true}).then((res) => { this.typeOptions = genTree(res.data); - console.log(this.typeOptions); + // console.log(this.typeOptions); }); }, @@ -286,7 +314,7 @@ background-color: #ffffff; color: #333; text-align: center; - margin-top: 130px; + margin-top: 140px; } diff --git a/server/apps/edu/views.py b/server/apps/edu/views.py index 63e5c41..22e6c7c 100644 --- a/server/apps/edu/views.py +++ b/server/apps/edu/views.py @@ -136,3 +136,28 @@ class CertificateViewSet(CreateUpdateCustomMixin, ModelViewSet): make_img_x(obj) print(f"生成---{obj.姓名}---的证书") return Response() + + @action(detail=False, methods=['post'], url_path='batch-update', perms_map={"post": "certificate"}) + def batch_update(self, request): + data = request.data + ids = data.get('ids', []) + updates = data.get('updates', {}) + + if not ids or not updates: + raise ParseError("Invalid data") + + # Fetch the objects to update + objects = Certificate.objects.filter(id__in=ids) + if not objects.exists(): + raise ParseError("No objects found") + + # Update the objects + for obj in objects: + # for field, value in updates.items(): + # setattr(obj, field, value) + # obj.save() + serializer = CertificateSerializer(obj, data=updates, partial=True) + serializer.is_valid(raise_exception=True) + serializer.save() + + return Response() \ No newline at end of file