任务确认率计算 任务完成

This commit is contained in:
caoqianming 2021-03-18 09:15:34 +08:00
parent 8820904e27
commit 6b1bd8eac8
3 changed files with 18 additions and 4 deletions

View File

@ -46,7 +46,9 @@
</el-table-column>
<el-table-column label="状态">
<template slot-scope="scope">
<el-tag>{{scope.row.state}}</el-tag>
<el-tag v-if="scope.row.state=='创建中'" type="warning">{{scope.row.state}}</el-tag>
<el-tag v-else-if="scope.row.state=='执行中'" type="primary">{{scope.row.state}}</el-tag>
<el-tag v-else type="success">{{scope.row.state}}</el-tag>
</template>
</el-table-column>
<el-table-column label="截止日期">
@ -216,7 +218,7 @@ export default {
});
},
handleDelete(scope) {
this.$confirm("确认删除?", "警告", {
this.$confirm("确认删除?该操作将删除该任务所有上报记录!", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",

View File

@ -32,7 +32,11 @@
<el-col :span="8">
<div style="margin-bottom: 6px">
<span class="term">任务状态</span>
<span class="desc"> {{ task.state }}</span>
<span class="desc">
<el-tag v-if="task.state=='创建中'" type="warning">{{task.state}}</el-tag>
<el-tag v-else-if="task.state=='执行中'" type="primary">{{task.state}}</el-tag>
<el-tag v-else type="success">{{task.state}}</el-tag>
</span>
</div>
</el-col>
<el-col :span="8">
@ -434,7 +438,7 @@ export default {
this.gettask()
if(this.activeName == 'contenttab'){
this.chosecontent(this.nowcontent)
}else if(activeName == 'depttab'){
}else if(this.activeName == 'depttab'){
this.chosedept(this.nowdept)
}
},

View File

@ -46,6 +46,12 @@ class TaskViewSet(CreateUpdateCustomMixin, ModelViewSet):
return TaksDetailSerializer
return TaskListSerializer
def destroy(self, request, *args, **kwargs):
instance = self.get_object()
instance.delete()
Record.objects.filter(task=instance).delete()
return Response(status=status.HTTP_204_NO_CONTENT)
@action(methods=['post'], detail=True, perms_map = {'post':'task_init'})
def init(self, request, *args, **kwargs):
"""
@ -100,6 +106,8 @@ def cal_task_rate(task):
confirm_rate = objs.filter(state='已确认').count()/count
task.up_rate = int(up_rate*100)
task.confirm_rate = int(confirm_rate*100)
if task.confirm_rate == 100:
task.state ='已完成'
task.save()
class RecordViewSet(RbacFilterSet, PageOrNot, CreateUpdateCustomMixin, ModelViewSet):