This commit is contained in:
shilixia 2021-03-17 14:40:11 +08:00
commit 178236e2e5
6 changed files with 176 additions and 127 deletions

View File

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

View File

@ -1,5 +1,4 @@
<template>
<div class="app-container">
@ -104,13 +103,16 @@
<taskinit ref="taskinit" @handleChose="chooseComplete"></taskinit>
</el-dialog>
<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>
</div>
</template>
<script>
import { getRecordList } from "@/api/record";
import Pagination from "@/components/Pagination";
import taskinit from "@/views/supervision/taskinit";
@ -187,9 +189,9 @@ export default {
};
this.drawer = true;
},
handleDo(data){
this.drawer = false
this.getRecordList()
handleDo(data) {
this.drawer = false;
this.getRecordList();
},
handleView(scope) {
this.data = {

View File

@ -52,6 +52,9 @@
<el-table-column label="截止日期">
<template slot-scope="scope">{{ scope.row.end_date }}</template>
</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="任务备注">
<template slot-scope="scope">{{ scope.row.note }}</template>

View File

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

View File

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