上报率

This commit is contained in:
caoqianming 2021-03-17 13:54:08 +08:00
parent f175379237
commit 41ccca16cc
6 changed files with 252 additions and 215 deletions

View File

@ -23,7 +23,7 @@
v-model="record.note" v-model="record.note"
placeholder="" placeholder=""
type="textarea" type="textarea"
:readonly="data.action!= 'update'" :readonly="data.action!= 'update' && data.action != 'reject'"
> >
</el-input> </el-input>
</div> </div>
@ -51,13 +51,14 @@
</div> </div>
<div class="ma"> <div class="ma">
<el-upload <el-upload
:disabled="data.action!='up'"
ref="upload" ref="upload"
:action="upUrl" :action="upUrl"
:before-upload="beforeUpload" :before-upload="beforeUpload"
:on-success="handleUpSuccess" :on-success="handleUpSuccess"
:headers="upHeaders" :headers="upHeaders"
:on-preview="handlePreview"
multiple multiple
:on-preview="handlePreview"
:file-list="fileList" :file-list="fileList"
accept="image/*,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/msword,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" accept="image/*,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/msword,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
> >
@ -115,9 +116,9 @@ export default {
initList(){ initList(){
for(var i=0;i<this.record.files_.length;i++){ for(var i=0;i<this.record.files_.length;i++){
this.fileList.push({ this.fileList.push({
id:this.record.files_.id, id:this.record.files_[i].id,
name:this.record.files_.name, name:this.record.files_[i].name,
url:this.record.files_.path url:this.record.files_[i].path
}) })
} }
}, },
@ -129,7 +130,11 @@ export default {
} }
}, },
handleUpSuccess(res, file, filelist) { handleUpSuccess(res, file, filelist) {
this.$message.success('成功') this.fileList.push({
id: res.data.id,
name: res.data.name,
url: res.data.path
})
}, },
beforeRemove(){ beforeRemove(){
if(this.record.state!='待上报'&& this.record.state!='待整改'){ if(this.record.state!='待上报'&& this.record.state!='待整改'){
@ -149,24 +154,34 @@ export default {
if(this.data.action=='update'){ if(this.data.action=='update'){
updateRecord(this.record.id, this.record).then(res=>{ updateRecord(this.record.id, this.record).then(res=>{
this.$message.success('成功') this.$message.success('成功')
this.$emit('handleDo')
}) })
} }
else if(this.data.action=='up'){ else if(this.data.action=='up'){
var files = []
for(var i=0;i<this.fileList.length;i++){
files.push(this.fileList[i].id)
}
this.record.files = files
upRecord(this.record.id, this.record).then(res=>{ upRecord(this.record.id, this.record).then(res=>{
this.$message.success('成功') this.$message.success('成功')
this.$emit('handleDo')
}) })
} }
else if(this.data.action=='reject'){ else if(this.data.action=='reject'){
rejectRecord(this.record.id, this.record).then(res=>{ rejectRecord(this.record.id, this.record).then(res=>{
this.$message.success('成功') this.$message.success('成功')
this.$emit('handleDo')
}) })
} }
else if(this.data.action=='confirm'){ else if(this.data.action=='confirm'){
confirmRecord(this.record.id).then(res=>{ confirmRecord(this.record.id).then(res=>{
this.$message.success('成功') this.$message.success('成功')
this.$emit('handleDo')
}) })
} }
this.$emit('handleDo')
} }
}, },
}; };

View File

@ -1,92 +1,80 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div style="margin-top: 10px">
<el-tabs v-model="activeName">
<div <el-tab-pane label="待上报" name="first" lazy> </el-tab-pane>
style="margin-top: 10px" <el-tab-pane label="已上报" name="three" lazy> </el-tab-pane>
<el-tab-pane label="待整改" name="secord" lazy> </el-tab-pane>
<el-tab-pane label="已确认" name="fore" lazy> </el-tab-pane>
</el-tabs>
</div>
<el-table
v-loading="listLoading"
:data="recordList"
border
fit
stripe
highlight-current-row
max-height="600px"
> >
<el-tabs v-model="activeName"> <el-table-column label="序号" type="index" align="center" />
<el-tab-pane label="待上报" name="first" lazy> <el-table-column label="单位">
</el-tab-pane> <template slot-scope="scope">{{
<el-tab-pane label="已上报" name="three" lazy> scope.row.belong_dept_.name
</el-tab-pane> }}</template>
<el-tab-pane label="待整改" name="secord" lazy> </el-table-column>
</el-tab-pane> <el-table-column label="状态">
<el-tab-pane label="已确认" name="fore" lazy> <template slot-scope="scope">{{ scope.row.state }}</template>
</el-tab-pane> </el-table-column>
<el-table-column label="上报情况">
<template slot-scope="scope" v-if="scope.row.up_user_"
>{{ scope.row.up_user_.name }}/{{ scope.row.up_date }}</template
</el-tabs> >
</el-table-column>
</div> <el-table-column align="center" label="操作">
<el-table <template slot-scope="scope">
v-loading="listLoading" <el-button
:data="recordList" v-if="
border scope.row.state == '待上报' && checkPermission(['record_update'])
fit "
stripe type="primary"
highlight-current-row size="small"
max-height="600px" @click="handleUpdate(scope)"
> >编辑</el-button
<el-table-column label="序号" type="index" align="center" /> >
<el-table-column label="单位"> <el-button
<template slot-scope="scope">{{ v-if="scope.row.state == '待上报' && checkPermission(['record_up'])"
scope.row.belong_dept_.name type="primary"
}}</template> size="small"
</el-table-column> @click="handleUp(scope)"
<el-table-column label="状态"> >上报</el-button
<template slot-scope="scope">{{ >
scope.row.state <el-button
}}</template> v-if="
</el-table-column> scope.row.state == '已提交' && checkPermission(['record_confirm'])
<el-table-column label="上报情况"> "
<template slot-scope="scope" type="primary"
v-if="scope.row.up_user_">{{ scope.row.up_user_.name }}/{{ scope.row.up_date }}</template size="small"
> @click="handleConfirm(scope)"
</el-table-column> >确认</el-button
<el-table-column align="center" label="操作"> >
<template slot-scope="scope"> <el-button
<el-button v-if="scope.state == '已提交' && checkPermission(['record_reject'])"
v-if="scope.row.state == '待上报' && checkPermission(['record_update'])" type="danger"
type="primary" size="small"
size="small" @click="handleReject(scope)"
@click="handleUpdate(scope)" >驳回</el-button
>编辑</el-button >
> <el-button
<el-button v-if="checkPermission(['record_view'])"
v-if="scope.row.state == '待上报' && checkPermission(['record_up'])" size="small"
type="primary" @click="handleView(scope)"
size="small" >查看</el-button
@click="handleUp(scope)" >
>上报</el-button </template>
> </el-table-column>
<el-button </el-table>
v-if="scope.row.state == '已提交' && checkPermission(['record_confirm'])" <el-dialog
type="primary"
size="small"
@click="handleConfirm(scope)"
>确认</el-button
>
<el-button
v-if="scope.state == '已提交' && checkPermission(['record_reject'])"
type="danger"
size="small"
@click="handleReject(scope)"
>驳回</el-button
>
<el-button
v-if="checkPermission(['record_view'])"
size="small"
@click="handleView(scope)"
>查看</el-button
>
</template>
</el-table-column>
</el-table>
<el-dialog
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
title="主动上报" title="主动上报"
:close-on-click-modal="false" :close-on-click-modal="false"
@ -94,13 +82,16 @@
<taskinit ref="taskinit" @handleChose="chooseComplete"></taskinit> <taskinit ref="taskinit" @handleChose="chooseComplete"></taskinit>
</el-dialog> </el-dialog>
<el-drawer title="记录" :visible.sync="drawer" :with-header="false"> <el-drawer title="记录" :visible.sync="drawer" :with-header="false">
<recorddo ref="recorddo" :data="data" @handleDo="handleDo" v-if="drawer"></recorddo> <recorddo
ref="recorddo"
:data="data"
@handleDo="handleDo"
v-if="drawer"
></recorddo>
</el-drawer> </el-drawer>
</div> </div>
</template> </template>
<script> <script>
import { getRecordList } from "@/api/record"; import { getRecordList } from "@/api/record";
import Pagination from "@/components/Pagination"; import Pagination from "@/components/Pagination";
import taskinit from "@/views/supervision/taskinit"; import taskinit from "@/views/supervision/taskinit";
@ -124,9 +115,8 @@ export default {
this.getRecordList(); this.getRecordList();
}, },
methods: { methods: {
checkPermission, checkPermission,
getRecordList(){ getRecordList() {
getRecordList().then((res) => { getRecordList().then((res) => {
this.listLoading = false; this.listLoading = false;
this.recordList = res.data.results; this.recordList = res.data.results;
@ -146,9 +136,9 @@ export default {
}; };
this.drawer = true; this.drawer = true;
}, },
handleDo(data){ handleDo(data) {
this.drawer = false this.drawer = false;
this.getRecordList() this.getRecordList();
}, },
handleView(scope) { handleView(scope) {
this.data = { this.data = {

View File

@ -52,6 +52,9 @@
<el-table-column label="截止日期"> <el-table-column label="截止日期">
<template slot-scope="scope">{{ scope.row.end_date }}</template> <template slot-scope="scope">{{ scope.row.end_date }}</template>
</el-table-column> </el-table-column>
<el-table-column label="上报率/确认率">
<template slot-scope="scope">{{ scope.row.up_rate }}%/{{scope.row.confirm_rate}}%</template>
</el-table-column>
<el-table-column label="任务备注"> <el-table-column label="任务备注">
<template slot-scope="scope">{{ scope.row.note }}</template> <template slot-scope="scope">{{ scope.row.note }}</template>

View File

@ -37,8 +37,8 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<div style="margin-bottom: 6px"> <div style="margin-bottom: 6px">
<span class="term">完成度</span> <span class="term">上报/确认率</span>
<span class="desc"> {{ task.complete_rate }}%</span> <span class="desc"> {{ task.up_rate }}% -- {{task.confirm_rate}}%</span>
</div> </div>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
@ -65,7 +65,7 @@
<span>执行详情</span> <span>执行详情</span>
</div> </div>
<el-tabs v-model="activeName"> <el-tabs v-model="activeName">
<el-tab-pane label="按清单" name="tab1" lazy> <el-tab-pane label="按清单" name="contenttab" lazy>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="4"> <el-col :span="4">
<el-card <el-card
@ -76,7 +76,7 @@
v-for="item in contents" v-for="item in contents"
v-bind:key="item.id" v-bind:key="item.id"
class="litem" class="litem"
@click="chose1(item)" @click="chosecontent(item)"
> >
{{ item.name }} {{ item.name }}
</div> </div>
@ -87,13 +87,13 @@
shadow="never" shadow="never"
style="height: 600px; overflow-y: auto; overflow-x: auto" style="height: 600px; overflow-y: auto; overflow-x: auto"
> >
<div style="margin-bottom: 4px"> <div style="margin-bottom:6px">
当前选择的是 当前选择
<span style="color: red">{{ now.name }}</span> <span style="color:red">{{nowcontent.name}}</span>
</div> </div>
<el-table <el-table
v-loading="listLoading" v-loading="listLoading"
:data="recordList" :data="recordList1"
border border
fit fit
stripe stripe
@ -107,50 +107,65 @@
}}</template> }}</template>
</el-table-column> </el-table-column>
<el-table-column label="状态"> <el-table-column label="状态">
<template slot-scope="scope">{{ <template slot-scope="scope"><el-tag type="danger" v-if="scope.row.state == '待上报'">{{ scope.row.state }}</el-tag>
scope.row.state <el-tag type="warning" v-else-if="scope.row.state == '待整改'">{{ scope.row.state }}</el-tag>
}}</template> <el-tag type="success" v-else-if="scope.row.state == '已确认'">{{ scope.row.state }}</el-tag>
<el-tag v-else-if="scope.row.state == '已上报'">{{ scope.row.state }}</el-tag></template>
</el-table-column> </el-table-column>
<el-table-column label="上报情况"> <el-table-column label="上报情况">
<template slot-scope="scope" <template slot-scope="scope"
>{{ scope.row.up_user }}/{{ scope.row.up_date }}</template v-if="scope.row.up_user_">{{ scope.row.up_user_.name }}/{{ scope.row.up_date }}</template
> >
</el-table-column> </el-table-column>
<el-table-column label="文件"> <el-table-column label="文件">
<template slot-scope="scope"> <template slot-scope="scope"> </template>
</template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作"> <el-table-column align="center" label="操作" width="220px" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="scope.row.state == '待上报'" v-if="
scope.row.state == '待上报' &&
checkPermission(['record_update'])
"
type="primary" type="primary"
:disabled="!checkPermission(['record_update'])"
size="small" size="small"
@click="handleUpdate(scope)" @click="handleRecord({action:'update', record:scope.row})"
>编辑</el-button >编辑</el-button
> >
<el-button <el-button
v-if="scope.row.state == '已提交'" v-if="
(scope.row.state == '待上报' || scope.row.state == '待整改')&&
checkPermission(['record_up'])
"
type="primary" type="primary"
:disabled="!checkPermission(['record_confirm'])"
size="small" size="small"
@click="handleConfirm(scope)" @click="handleRecord({action:'up', record:scope.row})"
>上报</el-button
>
<el-button
v-if="
scope.row.state == '已上报' &&
checkPermission(['record_confirm'])
"
type="primary"
size="small"
@click="handleRecord({action:'confirm', record:scope.row})"
>确认</el-button >确认</el-button
> >
<el-button <el-button
v-if="scope.state == '已提交'" v-if="
:disabled="!checkPermission(['record_reject'])" scope.row.state == '已上报' &&
checkPermission(['record_reject'])
"
type="danger" type="danger"
size="small" size="small"
@click="handleReject(scope)" @click="handleRecord({action:'reject', record:scope.row})"
>驳回</el-button >驳回</el-button
> >
<el-button <el-button
:disabled="!checkPermission(['record_view'])" v-if="checkPermission(['record_view'])"
size="small" size="small"
@click="handleView(scope)" @click="handleRecord({action:'view', record:scope.row})"
>查看</el-button >查看</el-button
> >
</template> </template>
@ -160,7 +175,7 @@
</el-col> </el-col>
</el-row> </el-row>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="按单位" name="tab2" lazy> <el-tab-pane label="按单位" name="depttab" lazy>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="4"> <el-col :span="4">
<el-card <el-card
@ -171,7 +186,7 @@
v-for="item in depts" v-for="item in depts"
v-bind:key="item.id" v-bind:key="item.id"
class="litem" class="litem"
@click="chose2(item)" @click="chosedept(item)"
> >
{{ item.name }} {{ item.name }}
</div> </div>
@ -182,13 +197,13 @@
shadow="never" shadow="never"
style="height: 600px; overflow-y: auto; overflow-x: auto" style="height: 600px; overflow-y: auto; overflow-x: auto"
> >
<div style="margin-bottom: 4px"> <div style="margin-bottom:6px">
当前选择的是 当前选择
<span style="color: red">{{ now.name }}</span> <span style="color:red">{{nowdept.name}}</span>
</div> </div>
<el-table <el-table
v-loading="listLoading" v-loading="listLoading"
:data="recordList" :data="recordList2"
border border
fit fit
stripe stripe
@ -202,13 +217,16 @@
}}</template> }}</template>
</el-table-column> </el-table-column>
<el-table-column label="状态"> <el-table-column label="状态">
<template slot-scope="scope">{{ <template slot-scope="scope">
scope.row.state <el-tag type="danger" v-if="scope.row.state == '待上报'">{{ scope.row.state }}</el-tag>
}}</template> <el-tag type="warning" v-else-if="scope.row.state == '待整改'">{{ scope.row.state }}</el-tag>
<el-tag type="success" v-else-if="scope.row.state == '已确认'">{{ scope.row.state }}</el-tag>
<el-tag v-else-if="scope.row.state == '已上报'">{{ scope.row.state }}</el-tag>
</template>
</el-table-column> </el-table-column>
<el-table-column label="上报情况"> <el-table-column label="上报情况">
<template slot-scope="scope" <template slot-scope="scope"
>{{ scope.row.up_user }}/{{ scope.row.up_date }}</template v-if="scope.row.up_user_">{{ scope.row.up_user }}/{{ scope.row.up_date }}</template
> >
</el-table-column> </el-table-column>
<el-table-column label="文件"> <el-table-column label="文件">
@ -216,36 +234,53 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作"> <el-table-column align="center" label="操作" width="220px" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="scope.row.state == '待上报'" v-if="
scope.row.state == '待上报' &&
checkPermission(['record_update'])
"
type="primary" type="primary"
:disabled="!checkPermission(['record_update'])"
size="small" size="small"
@click="handleUpdate(scope)" @click="handleRecord({action:'update', record:scope.row})"
>编辑</el-button >编辑</el-button
> >
<el-button <el-button
v-if="scope.row.state == '已提交'" v-if="
(scope.row.state == '待上报' || scope.row.state == '待整改')
&&
checkPermission(['record_up'])
"
type="primary" type="primary"
:disabled="!checkPermission(['record_confirm'])"
size="small" size="small"
@click="handleConfirm(scope)" @click="handleRecord({action:'up', record:scope.row})"
>上报</el-button
>
<el-button
v-if="
scope.row.state == '已上报' &&
checkPermission(['record_confirm'])
"
type="primary"
size="small"
@click="handleRecord({action:'confirm', record:scope.row})"
>确认</el-button >确认</el-button
> >
<el-button <el-button
v-if="scope.state == '已提交'" v-if="
:disabled="!checkPermission(['record_reject'])" scope.row.state == '已上报' &&
checkPermission(['record_reject'])
"
type="danger" type="danger"
size="small" size="small"
@click="handleReject(scope)" @click="handleRecord({action:'reject', record:scope.row})"
>驳回</el-button >驳回</el-button
> >
<el-button <el-button
:disabled="!checkPermission(['record_view'])" v-if="checkPermission(['record_view'])"
size="small" size="small"
@click="handleView(scope)" @click="handleRecord({action:'view', record:scope.row})"
>查看</el-button >查看</el-button
> >
</template> </template>
@ -266,7 +301,12 @@
<taskinit ref="taskinit" @handleChose="chooseComplete"></taskinit> <taskinit ref="taskinit" @handleChose="chooseComplete"></taskinit>
</el-dialog> </el-dialog>
<el-drawer title="记录" :visible.sync="drawer" :with-header="false"> <el-drawer title="记录" :visible.sync="drawer" :with-header="false">
<recorddo ref="recorddo" :data="data" @handleDo="handleDo" v-if="drawer"></recorddo> <recorddo
ref="recorddo"
:data="data"
@handleDo="handleDo"
v-if="drawer"
></recorddo>
</el-drawer> </el-drawer>
</div> </div>
</template> </template>
@ -301,12 +341,14 @@ export default {
return { return {
task: { id: 0 }, task: { id: 0 },
dialogVisible: false, dialogVisible: false,
activeName: "tab1", activeName: "contenttab",
contents: [], contents: [],
depts: [], depts: [],
listLoading: false, listLoading: false,
recordList: [], recordList1: [],
now: {}, recordList2: [],
nowcontent:{},
nowdept:{},
drawer: false, drawer: false,
data: {}, data: {},
}; };
@ -343,15 +385,14 @@ export default {
gettaskcontents(this.task.id).then((res) => { gettaskcontents(this.task.id).then((res) => {
this.contents = res.data; this.contents = res.data;
this.listLoading = true; this.listLoading = true;
this.nowcontent = {id:this.contents[0].id, name:this.contents[0].name}
getRecordList({ getRecordList({
pageoff: true, pageoff: true,
content: this.contents[0].id, content: this.contents[0].id,
task: this.task.id, task: this.task.id,
}).then((res) => { }).then((res) => {
this.now = this.contents[0];
this.now.type = 'content';
this.listLoading = false; this.listLoading = false;
this.recordList = res.data; this.recordList1 = res.data;
}); });
}); });
}, },
@ -360,65 +401,45 @@ export default {
this.depts = res.data; this.depts = res.data;
}); });
}, },
getRecordList(){ chosecontent(item) {
this.listLoading = true; this.nowcontent = item
var data = { var data = {
pageoff: true, pageoff: true,
task: this.task.id, task: this.task.id,
} content:item.id
if (this.now.type=='content'){ };
data.content = this.now.id this.listLoading = true;
}else{
data.belong_dept = this.now.id
}
getRecordList(data).then((res) => { getRecordList(data).then((res) => {
this.listLoading = false; this.listLoading = false;
this.recordList = res.data; this.recordList1 = res.data;
}); });
}, },
chose1(item) { chosedept(item) {
this.now = item; this.nowdept = item
this.now.type = 'content' var data = {
pageoff: true,
task: this.task.id,
belong_dept:item.id
};
this.listLoading = true; this.listLoading = true;
this.getRecordList(); getRecordList(data).then((res) => {
this.listLoading = false;
this.recordList2 = res.data;
});
}, },
chose2(item) { handleRecord(data){
this.now = item; this.data = data;
this.now.type = 'belong_dept'
this.getRecordList();
},
handleUpdate(scope) {
this.data = {
action: "update",
record: scope.row,
};
this.drawer = true; this.drawer = true;
}, },
handleReject(scope) { handleDo(data) {
this.data = { this.drawer = false;
action: "reject", this.gettask()
record: scope.row, if(this.activeName == 'contenttab'){
}; this.chosecontent(this.nowcontent)
this.drawer = true; }else if(activeName == 'depttab'){
this.chosedept(this.nowdept)
}
}, },
handleConfirm(scope) {
this.data = {
action: "reject",
record: scope.row,
};
this.drawer = true;
},
handleView(scope) {
this.data = {
action: "view",
record: scope.row,
};
this.drawer = true;
},
handleDo(data){
this.drawer = false
this.getRecordList()
}
}, },
}; };
</script> </script>

View File

@ -10,4 +10,4 @@ class RecordFilter(filters.FilterSet):
state = filters.CharFilter(field_name='state',lookup_expr='icontains') state = filters.CharFilter(field_name='state',lookup_expr='icontains')
class Meta: class Meta:
model = Record model = Record
fields = ['up_date','content__name','belong_dept','state', 'task'] fields = ['up_date','content__name','belong_dept','state', 'task', 'content']

View File

@ -108,8 +108,8 @@ def cal_task_rate(task):
count = objs.count() count = objs.count()
up_rate = objs.filter(state__in=['已确认','已上报']).count()/count up_rate = objs.filter(state__in=['已确认','已上报']).count()/count
confirm_rate = objs.filter(state='已确认').count()/count confirm_rate = objs.filter(state='已确认').count()/count
task.up_rate = int(up_rate) task.up_rate = int(up_rate*100)
task.confirm_rate = int(confirm_rate) task.confirm_rate = int(confirm_rate*100)
task.save() task.save()
class RecordViewSet(RbacFilterSet, PageOrNot, CreateUpdateCustomMixin, ModelViewSet): class RecordViewSet(RbacFilterSet, PageOrNot, CreateUpdateCustomMixin, ModelViewSet):
@ -118,7 +118,7 @@ class RecordViewSet(RbacFilterSet, PageOrNot, CreateUpdateCustomMixin, ModelView
queryset = Record.objects.all() queryset = Record.objects.all()
serializer_class = RecordSerializer serializer_class = RecordSerializer
search_fields = ['content__name','task__name'] search_fields = ['content__name','task__name']
ordering = ['-create_time'] ordering = ['create_time']
filter_class = RecordFilter # 过滤类 filter_class = RecordFilter # 过滤类
def update(self, request, *args, **kwargs): def update(self, request, *args, **kwargs):
@ -134,8 +134,9 @@ class RecordViewSet(RbacFilterSet, PageOrNot, CreateUpdateCustomMixin, ModelView
""" """
obj = self.get_object() obj = self.get_object()
if obj.state == '待上报' or obj.state == '待整改': if obj.state == '待上报' or obj.state == '待整改':
if request.data.get('files', None): if 'files' in request.data:
obj.files = request.data['files'] obj.files.clear()
obj.files.add(*request.data['files'])
if request.data.get('noteb', None): if request.data.get('noteb', None):
obj.noteb = request.data['noteb'] obj.noteb = request.data['noteb']
if request.data.get('is_yes', True): if request.data.get('is_yes', True):
@ -144,6 +145,8 @@ class RecordViewSet(RbacFilterSet, PageOrNot, CreateUpdateCustomMixin, ModelView
obj.up_user = request.user obj.up_user = request.user
obj.up_date = timezone.now() obj.up_date = timezone.now()
obj.save() obj.save()
if obj.task:
cal_task_rate(obj.task)
return Response(status=status.HTTP_200_OK) return Response(status=status.HTTP_200_OK)
return Response('记录状态错误', status=status.HTTP_400_BAD_REQUEST) return Response('记录状态错误', status=status.HTTP_400_BAD_REQUEST)
@ -156,10 +159,13 @@ class RecordViewSet(RbacFilterSet, PageOrNot, CreateUpdateCustomMixin, ModelView
if obj.state == '已上报': if obj.state == '已上报':
if request.data.get('note', None): if request.data.get('note', None):
obj.note = request.data['note'] obj.note = request.data['note']
obj.state = '待整改'
obj.save() obj.save()
if obj.task:
cal_task_rate(obj.task)
return Response(status=status.HTTP_200_OK) return Response(status=status.HTTP_200_OK)
else: else:
return Response('请填写备注', status=status.HTTP_200_OK) return Response('请填写备注', status=status.HTTP_400_BAD_REQUEST)
return Response('记录状态错误', status=status.HTTP_400_BAD_REQUEST) return Response('记录状态错误', status=status.HTTP_400_BAD_REQUEST)
@action(methods=['put'], detail=True, perms_map = {'post':'record_confirm'}) @action(methods=['put'], detail=True, perms_map = {'post':'record_confirm'})
@ -171,6 +177,8 @@ class RecordViewSet(RbacFilterSet, PageOrNot, CreateUpdateCustomMixin, ModelView
if obj.state == '已上报': if obj.state == '已上报':
obj.state = '已确认' obj.state = '已确认'
obj.save() obj.save()
if obj.task:
cal_task_rate(obj.task)
return Response(status=status.HTTP_200_OK) return Response(status=status.HTTP_200_OK)
return Response('记录状态错误', status=status.HTTP_400_BAD_REQUEST) return Response('记录状态错误', status=status.HTTP_400_BAD_REQUEST)