feat:edu 证书日期批量修改

This commit is contained in:
zty 2024-08-01 10:28:16 +08:00
parent 6805c0bc41
commit fb44f66cf4
9 changed files with 185 additions and 35 deletions

View File

@ -85,4 +85,12 @@ export function createCourse(data) {
url: `/edu/course/${id}/`, url: `/edu/course/${id}/`,
method: 'get' method: 'get'
}) })
}
export function batchUpdate(data) {
return request({
url: '/edu/certificate/batch-update/',
method: 'post',
data
})
} }

View File

@ -4,7 +4,7 @@
<el-button type="primary" @click="handleAdd" icon="el-icon-plus">新增</el-button> <el-button type="primary" @click="handleAdd" icon="el-icon-plus">新增</el-button>
</div> </div>
<el-table :data="tableData" style="width: 100%;margin-top:10px;" border fit v-loading="listLoading" <el-table :data="tableData" style="width: 100%;margin-top:10px;" border fit v-loading="listLoading"
highlight-current-row max-height="600"> highlight-current-row max-height="700">
<el-table-column type="index" width="50"></el-table-column> <el-table-column type="index" width="50"></el-table-column>
<el-table-column align="center" label="名称"> <el-table-column align="center" label="名称">
<template slot-scope="scope">{{ scope.row.name }}</template> <template slot-scope="scope">{{ scope.row.name }}</template>
@ -23,7 +23,7 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" <pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.page_size"
@pagination="getList" /> @pagination="getList" />
<el-dialog :visible.sync="dialogVisible" :title="dialogType === 'edit' ? '编辑分类' : '新增分类'"> <el-dialog :visible.sync="dialogVisible" :title="dialogType === 'edit' ? '编辑分类' : '新增分类'">
<el-form :model="questioncat" label-width="80px" label-position="right" :rules="rule1" ref="commonForm"> <el-form :model="questioncat" label-width="80px" label-position="right" :rules="rule1" ref="commonForm">
@ -50,7 +50,7 @@ const defaultObj = {
}; };
const listQuery = { const listQuery = {
page: 1, page: 1,
limit: 20 page_size: 20
}; };
export default { export default {
components: { Pagination }, components: { Pagination },

View File

@ -51,7 +51,7 @@
fit fit
v-loading="listLoading" v-loading="listLoading"
highlight-current-row highlight-current-row
max-height="600" max-height="700"
@sort-change="changeSort" @sort-change="changeSort"
> >
<el-table-column type="index" width="50"></el-table-column> <el-table-column type="index" width="50"></el-table-column>
@ -124,7 +124,7 @@
v-show="tableData.count>0" v-show="tableData.count>0"
:total="tableData.count" :total="tableData.count"
:page.sync="listQuery.page" :page.sync="listQuery.page"
:limit.sync="listQuery.limit" :limit.sync="listQuery.page_size"
@pagination="getList" @pagination="getList"
/> />
</div> </div>
@ -137,7 +137,7 @@
const listQuery = { const listQuery = {
page: 1, page: 1,
limit: 20, page_size: 20,
search:'' search:''
}; };
export default { export default {
@ -229,7 +229,7 @@
resetFilter() { resetFilter() {
this.listQuery = { this.listQuery = {
page: 1, page: 1,
limit: 20, page_size: 20,
search:'', search:'',
}; };
this.value = [] this.value = []

View File

@ -84,7 +84,7 @@
v-show="tableData.count>0" v-show="tableData.count>0"
:total="tableData.count" :total="tableData.count"
:page.sync="listQuery.page" :page.sync="listQuery.page"
:limit.sync="listQuery.limit" :limit.sync="listQuery.page_size"
@pagination="getList" @pagination="getList"
/> />
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='edit'?'编辑考试':'新增考试'" > <el-dialog :visible.sync="dialogVisible" :title="dialogType==='edit'?'编辑考试':'新增考试'" >
@ -230,7 +230,7 @@
}; };
const listQuery = { const listQuery = {
page: 1, page: 1,
limit: 20, page_size: 20,
search: "" search: ""
}; };
export default { export default {
@ -330,7 +330,7 @@
resetFilter() { resetFilter() {
this.listQuery = { this.listQuery = {
page: 1, page: 1,
limit: 20, page_size: 20,
search: "" search: ""
}; };
this.getList(); this.getList();

View File

@ -20,7 +20,7 @@
/> />
</el-select> </el-select>
<el-input <el-input
v-model="search" v-model="listQuery.search"
placeholder="输入题干进行搜索" placeholder="输入题干进行搜索"
style="width: 200px;" style="width: 200px;"
class="filter-item" class="filter-item"
@ -51,6 +51,7 @@
highlight-current-row highlight-current-row
max-height="400" max-height="400"
ref="table" ref="table"
@sort-change="changeSort"
> >
<el-table-column <el-table-column
type="selection" type="selection"
@ -65,10 +66,10 @@
<el-table-column align="left" label="题型"> <el-table-column align="left" label="题型">
<template slot-scope="scope">{{ scope.row.type }}</template> <template slot-scope="scope">{{ scope.row.type }}</template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="难易度"> <el-table-column align="left" sortable='custom' label="难易度" prop="level">
<template slot-scope="scope">{{ scope.row.level }}</template> <template slot-scope="scope">{{ scope.row.level }}</template>
</el-table-column> </el-table-column>
<el-table-column label="创建日期"> <el-table-column label="创建日期" sortable='custom' prop="create_time">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.create_time }}</span> <span>{{ scope.row.create_time }}</span>
</template> </template>
@ -88,7 +89,7 @@
v-show="tableData.count>0" v-show="tableData.count>0"
:total="tableData.count" :total="tableData.count"
:page.sync="listQuery.page" :page.sync="listQuery.page"
:limit.sync="listQuery.limit" :limit.sync="listQuery.page_size"
@pagination="getList" @pagination="getList"
/> />
<el-dialog <el-dialog
@ -124,7 +125,7 @@
const listQuery = { const listQuery = {
page: 1, page: 1,
limit: 20, page_size: 20,
search:'' search:''
}; };
export default { export default {
@ -140,7 +141,6 @@
name: "" name: ""
}, },
listQuery: listQuery, listQuery: listQuery,
search:"",
tableData: { tableData: {
count:0, count:0,
results:[] results:[]
@ -172,9 +172,9 @@
this.getQuestioncatAll(); this.getQuestioncatAll();
}, },
methods: { methods: {
getList(query = this.listQuery) { getList() {
this.listLoading = true; this.listLoading = true;
getQuestionList(query).then(response => { getQuestionList(this.listQuery).then(response => {
if(response.data.results){ if(response.data.results){
this.tableData = response.data this.tableData = response.data
} }
@ -185,7 +185,14 @@
getQuestioncatList().then(response => { getQuestioncatList().then(response => {
this.questioncatData = response.data.results; 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() { handleFilter() {
if(this.questioncatC.length) { if(this.questioncatC.length) {
@ -197,12 +204,12 @@
this.getList(); this.getList();
}, },
resetFilter() { resetFilter() {
this.search = "" this.listQuery.search = ''
this.listQuery = listQuery
this.getList(); this.getList();
}, },
handleSearch() { handleSearch() {
this.getList({ search: this.search }); this.listQuery.page = 1
this.getList();
}, },
handleDetail(scope) { handleDetail(scope) {
this.dialogVisible = true this.dialogVisible = true

View File

@ -75,8 +75,18 @@
<el-button type="danger" v-if="checkPermission(['question_batch_delete'])" :disabled="this.selects.length==0" @click="batchDelete()">批量删除</el-button> <el-button type="danger" v-if="checkPermission(['question_batch_delete'])" :disabled="this.selects.length==0" @click="batchDelete()">批量删除</el-button>
</div> </div>
</div> </div>
<el-table :data="tableData" style="width: 100%;margin-top:10px;" border stripe fit v-loading="listLoading" <el-table
highlight-current-row max-height="600" @sort-change="changeSort" @selection-change="handleSelectionChange"> :data="tableData"
style="width: 100%;
margin-top:6px;"
border
stripe
fit
v-loading="listLoading"
highlight-current-row
max-height="700"
@sort-change="changeSort"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"></el-table-column> <el-table-column type="selection" width="55"></el-table-column>
<el-table-column label="题干" sortable="custom" prop="name" width="400px"> <el-table-column label="题干" sortable="custom" prop="name" width="400px">
<template slot-scope="scope">{{ scope.row.name }}</template> <template slot-scope="scope">{{ scope.row.name }}</template>
@ -112,7 +122,7 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" <pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.page_size"
@pagination="getList" /> @pagination="getList" />
<el-dialog title="题目详情" :visible.sync="dialogVisible" width="30%"> <el-dialog title="题目详情" :visible.sync="dialogVisible" width="30%">
<div>{{ question.type }}</div> <div>{{ question.type }}</div>
@ -152,7 +162,7 @@ const defaultObj = {
}; };
const listQuery = { const listQuery = {
page: 1, page: 1,
limit: 20, page_size: 20,
search: '', search: '',
questioncat:'' questioncat:''
}; };

View File

@ -23,6 +23,7 @@
<div style="margin-top: 6px"> <div style="margin-top: 6px">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd" v-if="checkPermission(['certificate'])" <el-button type="primary" icon="el-icon-plus" @click="handleAdd" v-if="checkPermission(['certificate'])"
>新增证书</el-button> >新增证书</el-button>
<el-button @click="openBatchEditDialog" type="primary">批量修改</el-button>
<!-- <el-popover <!-- <el-popover
placement="top" placement="top"
width="160" width="160"
@ -81,13 +82,14 @@
<el-table <el-table
v-loading="listLoading" v-loading="listLoading"
:data="tableList.results" :data="tableList.results"
@selection-change="handleSelectionChange"
ref="multipleTable"
style="width: 100%;" style="width: 100%;"
border border
fit fit
stripe stripe
highlight-current-row highlight-current-row
max-height="700" max-height="700"
ref="filterTable"
> >
<el-table-column <el-table-column
type="selection" type="selection"
@ -299,6 +301,39 @@
<el-button @click="dialogVisible = false">关闭</el-button> <el-button @click="dialogVisible = false">关闭</el-button>
</div> --> </div> -->
</el-dialog> </el-dialog>
<el-dialog title="批量修改" :visible.sync="dialogVisible2" width="30%">
<el-form
:model="batchForm"
label-width="160px"
label-position="right"
:rules="rule"
>
<el-form-item label="培训开始日期" prop="培训日期">
<el-date-picker
v-model="batchForm.培训日期"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="培训日期"
style="width:100%">
</el-date-picker>
</el-form-item>
<el-form-item label="培训结束日期" prop="培训结束日期">
<el-date-picker
v-model="batchForm.培训结束日期"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="培训结束日期"
style="width:100%">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogVisible2 = false"> </el-button>
<el-button type="primary" @click="handleBatchEdit"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<style > <style >
@ -309,7 +344,7 @@
} }
</style> </style>
<script> <script>
import {getCertificateList,createCertificate,updateCertificate,impCertificate12,deleteCertificate,getCertificate,getCourseList} from "@/api/edu"; import {getCertificateList,createCertificate,updateCertificate,impCertificate12,deleteCertificate,getCertificate,getCourseList, batchUpdate} from "@/api/edu";
import checkPermission from "@/utils/permission"; import checkPermission from "@/utils/permission";
import { upUrl, upHeaders } from "@/api/file"; import { upUrl, upHeaders } from "@/api/file";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
@ -350,6 +385,7 @@ export default {
upUrl: upUrl(), upUrl: upUrl(),
delarr: [], delarr: [],
srcList:[], srcList:[],
selectedItems:[],
imgurl:'', imgurl:'',
groupBy: { sszx: [], glzz: [] }, groupBy: { sszx: [], glzz: [] },
tableList: { count: 0 ,list:[] }, tableList: { count: 0 ,list:[] },
@ -360,8 +396,13 @@ export default {
{ key: "true", display_name: "激活" }, { key: "true", display_name: "激活" },
{ key: "false", display_name: "禁用" }, { key: "false", display_name: "禁用" },
], ],
batchForm:{
培训日期:"",
培训结束日期:""
},
dialogShow:false, dialogShow:false,
dialogVisible: false, dialogVisible: false,
dialogVisible2:false,
dialogType: "new", dialogType: "new",
popovervisible: false, popovervisible: false,
rule: { rule: {
@ -435,6 +476,34 @@ export default {
this.$refs["Form"].clearValidate(); this.$refs["Form"].clearValidate();
}); });
}, },
handleBatchEdit(){
const ids = this.selectedItems.map(item => item.id);
const payload = {
ids: ids,
updates:{
培训日期:this.batchForm.培训日期,
培训结束日期:this.batchForm.培训结束日期,
}
};
// 发送请求
console.log(payload, "payload");
batchUpdate(payload).then(response => {
if (response.code >= 200){
this.$message.success('批量修改成功');
this.dialogVisible2 = false;
this.getList();
}else{
this.$message.error('批量修改失败');
}
});
},
openBatchEditDialog(){
if (this.selectedItems.length === 0){
this.$message.warning('请先选择至少一项记录');
return;
}
this.dialogVisible2 = true;
},
handleEdit(row) { handleEdit(row) {
this.form = Object.assign({}, row); // copy obj this.form = Object.assign({}, row); // copy obj
this.form.字体方案 = this.form.字体方案.toString(); this.form.字体方案 = this.form.字体方案.toString();
@ -517,6 +586,9 @@ export default {
} }
this.dialogShow = true; this.dialogShow = true;
}, },
handleSelectionChange(val){
this.selectedItems = val;
},
}, },
}; };
</script> </script>

View File

@ -9,6 +9,20 @@
</el-header> </el-header>
<el-main style="padding:20px 0;"> <el-main style="padding:20px 0;">
<el-row class="typesButtons"> <el-row class="typesButtons">
<el-input
v-model="queryParams.search"
placeholder="输入视频名搜索"
style="width: 400px;"
class="filter-item"
@keyup.enter.native="handleSearch"
/>
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
<el-button
class="filter-item"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>刷新重置</el-button>
<div style="width: fit-content;"> <div style="width: fit-content;">
<el-col class="typeItemWrap" style="width:100px;margin-top: 6px;"> <el-col class="typeItemWrap" style="width:100px;margin-top: 6px;">
<el-link :underline="false" @click="getList"> <el-link :underline="false" @click="getList">
@ -87,7 +101,11 @@
data() { data() {
return { return {
type:null, type:null,
videoList: "", videoList: [],
queryParams:{
pageoff:true,
search:""
},
typeOptions: [], typeOptions: [],
hasLowerLevel:false, hasLowerLevel:false,
subTypeOptions:[], subTypeOptions:[],
@ -110,9 +128,10 @@
} }
let bigHeight = document.getElementsByClassName('app-main')[0].clientHeight; let bigHeight = document.getElementsByClassName('app-main')[0].clientHeight;
let topHeight = document.getElementsByClassName('typesButtons')[0].clientHeight; let topHeight = document.getElementsByClassName('typesButtons')[0].clientHeight;
console.log(topHeight); let headerHeight = document.getElementsByClassName('el-header')[0].clientHeight;
// console.log(topHeight);
debugger; debugger;
let domHeight = bigHeight-200-topHeight; let domHeight = bigHeight-topHeight-headerHeight-80;
document.getElementById('videoListWrap').style.height = domHeight + 'px'; document.getElementById('videoListWrap').style.height = domHeight + 'px';
// document.getElementById('videoListWrap').style.paddingTop = topHeight + 'px'; // document.getElementById('videoListWrap').style.paddingTop = topHeight + 'px';
}, },
@ -121,14 +140,23 @@
getList() { getList() {
this.type = null; this.type = null;
this.listLoading = true; this.listLoading = true;
getVideoList({pageoff: true}).then((response) => { getVideoList(this.queryParams).then((response) => {
if (response.data) { if (response.data) {
this.videoList = response.data; this.videoList = response.data;
} }
this.listLoading = false; this.listLoading = false;
}); });
}, },
handleSearch() {
this.getList();
},
resetFilter() {
this.queryParams = {
pageoff:true,
search: '',
};
this.getList();
},
getListtype(a) { getListtype(a) {
this.type = a.id; this.type = a.id;
if(a.children){ if(a.children){
@ -165,7 +193,7 @@
getTypeAll() { getTypeAll() {
getDictList({type__code: "data_video",is_used:true}).then((res) => { getDictList({type__code: "data_video",is_used:true}).then((res) => {
this.typeOptions = genTree(res.data); this.typeOptions = genTree(res.data);
console.log(this.typeOptions); // console.log(this.typeOptions);
}); });
}, },
@ -286,7 +314,7 @@
background-color: #ffffff; background-color: #ffffff;
color: #333; color: #333;
text-align: center; text-align: center;
margin-top: 130px; margin-top: 140px;
} }

View File

@ -136,3 +136,28 @@ class CertificateViewSet(CreateUpdateCustomMixin, ModelViewSet):
make_img_x(obj) make_img_x(obj)
print(f"生成---{obj.姓名}---的证书") print(f"生成---{obj.姓名}---的证书")
return Response() 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()