增加我的报送任务

This commit is contained in:
caoqianming 2021-04-08 12:14:09 +08:00
parent 51c3aa4520
commit dda86a2d10
7 changed files with 457 additions and 13 deletions

View File

@ -89,4 +89,11 @@ export function gettaskdeptall(id) {
url: `/supervision/task/${id}/deptall/`,
method: 'get'
})
}
export function getmytasklist(query) {
return request({
url: '/supervision/task/self/',
method: 'get',
params: query
})
}

View File

@ -130,6 +130,12 @@ export const asyncRoutes = [
component: () => import('@/views/supervision/task.vue'),
meta: { title: '报送任务', perms: ['task_view'] }
},
{
path: 'mytask',
name: 'myTask',
component: () => import('@/views/supervision/mytask.vue'),
meta: { title: '我的报送任务', perms: ['record_view'] }
},
{
path: 'record',
name: 'Record',

View File

@ -0,0 +1,100 @@
<template>
<div class="app-container">
<el-card>
<div slot="header" class="clearfix">
<span>我的报送任务</span>
</div>
<el-table
v-loading="listLoading"
:data="taskList"
border
fit
stripe
highlight-current-row
max-height="300"
@row-click="clickRow"
>
<el-table-column type="index" width="50" />
<el-table-column label="任务名">
<template slot-scope="scope" v-if="scope.row.task_">{{ scope.row.task_.name }}</template>
</el-table-column>
<el-table-column label="任务状态">
<template slot-scope="scope" v-if="scope.row.task_">
<el-tag
v-if="scope.row.task_.state == '创建中' || scope.row.task_.state == '待发布'"
type="warning"
>{{ scope.row.task_.state }}</el-tag
>
<el-tag v-else-if="scope.row.task_.state == '执行中'" type="primary">{{
scope.row.task_.state
}}</el-tag>
<el-tag v-else type="success">{{ scope.row.task_.state }}</el-tag>
</template>
</el-table-column>
<el-table-column label="截止日期">
<template slot-scope="scope" v-if="scope.row.task_">{{ scope.row.task_.end_date }}</template>
</el-table-column>
<el-table-column label="报送率">
<template slot-scope="scope">{{ scope.row.up_rate }}%</template>
</el-table-column>
<el-table-column label="确认率">
<template slot-scope="scope">{{ scope.row.confirm_rate }}%</template>
</el-table-column>
</el-table>
</el-card>
<el-card style="margin-top:6px">
<div slot="header" class="clearfix">
<span>记录详情</span>
</div>
<mytaskrecord :query="query" @handleDo="handleDo"></mytaskrecord>
</el-card>
</div>
</template>
<script>
import {
getmytasklist,
} from "@/api/task";
import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
import mytaskrecord from "@/views/supervision/mytaskrecord";
export default {
components: { Pagination, mytaskrecord },
data() {
return {
taskList: [],
listQuery: {
page: 1,
page_size: 20,
},
listLoading: true,
query:null
};
},
computed: {},
watch: {},
created() {
this.getList();
},
methods: {
checkPermission,
getList() {
this.listLoading = true;
getmytasklist(this.listQuery).then((response) => {
if (response.data) {
this.taskList = response.data;
}
this.listLoading = false;
});
},
clickRow(obj){
this.query = {
dept:obj.dept,
task:obj.task
}
},
handleDo(val){
this.getList()
}
},
};
</script>

View File

@ -0,0 +1,320 @@
<template>
<div>
<div>
<el-select
v-model="listQuery.belong_dept"
placeholder="报送部门"
clearable
@change="handleFilter"
>
<el-option
v-for="item in orgData"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</div>
<el-table
style="margin-top: 6px"
v-loading="listLoading"
:data="recordList.results"
border
fit
stripe
highlight-current-row
max-height="400"
>
<el-table-column type="index" width="50" />
<el-table-column width="150px" label="任务标题">
<template slot-scope="scope">
<span v-if="scope.row.task">{{ scope.row.task_.name }}</span>
<el-tag type="warning" effect="plain" v-else> 主动报送 </el-tag>
</template>
</el-table-column>
<el-table-column label="材料名称">
<template slot-scope="scope">{{ scope.row.content_name }}</template>
</el-table-column>
<el-table-column label="报送要求/备注">
<template slot-scope="scope">{{ scope.row.note }}</template>
</el-table-column>
<el-table-column label="是否适用">
<template slot-scope="scope">
<el-tag v-if="scope.row.is_yes" effect="plain"></el-tag>
<el-tag type="danger" effect="plain" v-else></el-tag>
</template>
</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-table-column>
<el-table-column label="报送说明">
<template slot-scope="scope">{{ scope.row.noteb }}</template>
</el-table-column>
<el-table-column label="记录状态">
<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 == '待发布'
"
>{{ 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" v-if="scope.row.files">
<el-link
v-if="scope.row.files.length > 1"
@click="handleRecord({ action: 'view', record: scope.row })"
>
<span style="color: red">{{ scope.row.files.length }}</span>
个文件</el-link
>
<div v-else v-for="item in scope.row.files_" v-bind:key="item.id">
<el-link :href="item.path" target="_blank" type="primary">{{
item.name
}}</el-link>
</div>
</template>
</el-table-column>
<el-table-column align="center" label="操作" fixed="right">
<template slot-scope="scope">
<el-link
v-if="
(scope.row.state == '待报送' || scope.row.state == '待发布') &&
checkPermission(['record_update'])
"
type="warning"
size="small"
@click="handleRecord({ action: 'update', record: scope.row })"
>编辑</el-link
>
<el-link
v-if="
(scope.row.state == '待报送' || scope.row.state == '待整改') &&
checkPermission(['record_up'])
"
type="primary"
size="small"
@click="handleRecord({ action: 'up', record: scope.row })"
>报送</el-link
>
<el-link
v-if="
scope.row.state == '已报送' && checkPermission(['record_confirm'])
"
type="success"
size="small"
@click="handleRecord({ action: 'confirm', record: scope.row })"
>确认</el-link
>
<el-link
v-if="
scope.row.state == '已报送' &&
checkPermission(['record_reject']) &&
scope.row.belong_dept != $store.state.user.dept
"
type="danger"
size="small"
@click="handleRecord({ action: 'reject', record: scope.row })"
>驳回</el-link
>
<el-link
v-if="checkPermission(['record_view'])"
size="small"
@click="handleRecord({ action: 'view', record: scope.row })"
>查看</el-link
>
<el-link
v-if="checkPermission(['record_delete'])"
type="danger"
size="small"
@click="handleRecord({ action: 'delete', record: scope.row })"
>删除</el-link
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="recordList.count > 0"
:total="recordList.count"
:page.sync="listQuery.page"
:limit.sync="listQuery.page_size"
@pagination="getList"
/>
<el-drawer
title="记录"
:visible.sync="drawer"
:with-header="false"
size="40%"
>
<recorddo
ref="recorddo"
:data="data"
@handleDo="handleDo"
v-if="drawer"
></recorddo>
</el-drawer>
</div>
</template>
<style lang="scss">
.el-transfer-panel {
width: 470px;
}
.el-transfer__buttons {
padding: 0 2px;
.el-button {
display: block;
}
}
</style>
<script>
import { getOrgList, getSubOrgList } from "@/api/org";
import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination";
import recorddo from "@/views/supervision/recorddo";
import { getRecordList } from "@/api/record";
const defaultrecord = {
name: "",
};
export default {
name: "mytaskrecord",
props: ["query"],
components: { Pagination, recorddo },
data() {
return {
record: defaultrecord,
recordList: {
count: 0,
},
can_doself: true,
contentOptions: [],
contents: [],
centerDialogVisible: false,
orgData: [],
drawer: false,
stateOptions: [
{ key: "待报送", name: "待报送" },
{ key: "已报送", name: "已报送" },
{ key: "已确认", name: "已确认" },
{ key: "待整改", name: "待整改" },
],
isOptions: [
{ key: "true", name: "" },
{ key: "false", name: "" },
],
pickerOptions2: {
shortcuts: [
{
text: "最近一周",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近一个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近三个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit("pick", [start, end]);
},
},
],
},
listQuery: {
page: 1,
page_size: 20,
belong_dept: this.$store.state.user.dept,
},
listLoading: false,
dialogVisible: false,
dialogType: "new",
rule1: {
name: [{ required: true, message: "请输入", trigger: "blur" }],
},
};
},
computed: {},
watch: {
query: function (newV, oldV) {
if (newV) {
this.listQuery = {
page: 1,
page_size: 20,
belong_dept: newV.dept,
task: newV.task,
};
this.getList();
}
},
},
created() {
this.initQuery();
this.getOrgList();
},
methods: {
checkPermission,
initQuery() {
this.getList();
},
getOrgList() {
if (this.checkPermission(["record_confirm"])) {
getOrgList({ can_supervision: true }).then((res) => {
this.orgData = res.data;
});
} else {
getSubOrgList().then((res) => {
this.orgData = res.data;
});
}
},
getList() {
getRecordList(this.listQuery).then((response) => {
this.recordList = response.data;
});
},
handleFilter() {
this.listQuery.page = 1;
this.getList();
},
handleRecord(data) {
this.data = data;
this.drawer = true;
},
handleDo(val) {
this.drawer = false;
if(val){
this.getList();
this.$emit("handleDo",true);
}
},
},
};
</script>

View File

@ -203,7 +203,7 @@ export default {
if (this.data.action == "update") {
updateRecord(this.record.id, this.record).then((res) => {
this.$message.success("成功");
this.$emit("handleDo");
this.$emit("handleDo",true);
});
} else if (this.data.action == "up") {
var files = [];
@ -213,25 +213,20 @@ export default {
this.record.files = files;
upRecord(this.record.id, this.record).then((res) => {
this.$message.success("成功");
this.$emit("handleDo");
this.$emit("handleDo",true);
});
} else if (this.data.action == "reject") {
rejectRecord(this.record.id, this.record).then((res) => {
this.$message.success("成功");
this.$emit("handleDo");
this.$emit("handleDo",true);
});
} else if (this.data.action == "confirm") {
confirmRecord(this.record.id).then((res) => {
this.$message.success("成功");
this.$emit("handleDo");
this.$emit("handleDo",true);
});
} else if (this.data.action == "confirm") {
confirmRecord(this.record.id).then((res) => {
this.$message.success("成功");
this.$emit("handleDo");
});
} else if (this.data.action == "view") {
this.$emit("handleDo");
} else if (this.data.action == "view") {
this.$emit("handleDo",false);
} else if (this.data.action == "delete") {
this.$confirm("确认删除?", "警告", {
type: "error",
@ -239,7 +234,7 @@ export default {
.then(async () => {
await deleteRecord(this.record.id);
this.$message.success("成功");
this.$emit("handleDo");
this.$emit("handleDo",true);
})
.catch((err) => {
console.error(err);

View File

@ -64,8 +64,14 @@ class TaksDetailSerializer(serializers.ModelSerializer):
fields = '__all__'
class TaskDeptSerializer(serializers.ModelSerializer):
task_ = TaskListSerializer(source='task', read_only=True)
dept_ = OrganizationSimpleSerializer(source='dept', read_only=True)
class Meta:
model = TaskDept
fields = '__all__'
fields = '__all__'
@staticmethod
def setup_eager_loading(queryset):
queryset = queryset.select_related('task', 'dept')
return queryset

View File

@ -159,6 +159,16 @@ class TaskViewSet(CreateUpdateCustomMixin, ModelViewSet):
obj = self.get_object()
serializer = TaskDeptSerializer(TaskDept.objects.filter(task=obj).order_by('dept__sort'), many=True)
return Response(serializer.data)
@action(methods=['get'], detail=False, perms_map = {'get':'*'})
def self(self, request, *args, **kwargs):
"""
我的报送任务
"""
queryset = TaskDept.objects.filter(dept=request.user.dept).exclude(task__state='待发布').order_by('-create_time')
serializer = TaskDeptSerializer(queryset, many=True)
return Response(serializer.data)
@action(methods=['put'], detail=True, perms_map = {'put':'task_close'})
def close(self, request, *args, **kwargs):